docstring_tokens
stringlengths
18
16.9k
code_tokens
stringlengths
75
1.81M
html_url
stringlengths
74
116
file_name
stringlengths
3
311
keep keep keep keep replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> /// jstring <mask> FBEXPORT local_ref<JString> make_jstring(const char* modifiedUtf8); <mask> FBEXPORT local_ref<JString> make_jstring(const std::string& modifiedUtf8); <mask> <mask> /// Wrapper to provide functionality to jthrowable references <mask> class FBEXPORT JThrowable : public JavaClass<JThrowable, JObject, jthrowable> { <mask> public: <mask> static constexpr const char* kJavaDescriptor = "Ljava/lang/Throwable;"; <mask> <mask> local_ref<JThrowable> initCause(alias_ref<JThrowable> cause); <mask> }; <mask> <mask> namespace detail { <mask> template<typename Target> <mask> class ElementProxy { <mask> private: <mask> Target* target_; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove class Value; class Context; class JSException : public std::exception { public: explicit JSException(const char* msg) : msg_(msg), stack_("") {} JSException(const char* msg, const char* stack) : msg_(msg), stack_(stack) {} const std::string& getStack() const { return stack_; } virtual const char* what() const noexcept override { return msg_.c_str(); } </s> add #ifndef RN_EXPORT #define RN_EXPORT __attribute__((visibility("default"))) #endif </s> remove void setNativePointer(std::unique_ptr<BaseHybridClass> new_value); BaseHybridClass* getNativePointer(); </s> add </s> remove private: std::string msg_; std::string stack_; }; </s> add class Value; </s> add FBEXPORT local_ref<JThrowable> getJavaExceptionForCppBackTrace(const char* msg); </s> remove auto length = env->GetStringLength(self()); return detail::utf16toUTF8(utf16String, length); </s> add return detail::utf16toUTF8(utf16String.chars(), utf16String.length()); </s> remove // jthrowable ////////////////////////////////////////////////////////////////////////////////////// inline local_ref<JThrowable> JThrowable::initCause(alias_ref<JThrowable> cause) { static auto meth = javaClassStatic()->getMethod<javaobject(javaobject)>("initCause"); return meth(self(), cause.get()); } </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/CoreClasses.h
keep keep add keep keep keep keep keep
<mask> #include "References.h" <mask> #include "CoreClasses.h" <mask> <mask> namespace facebook { <mask> namespace jni { <mask> <mask> class JThrowable; <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove #include <sys/system_properties.h> </s> add # include <fb/Build.h> </s> remove #include <cxxreact/JsArgumentHelpers.h> </s> add #include "JsArgumentHelpers.h" #include "SystraceSection.h" </s> add namespace internal { struct CacheEnvTag {}; } </s> remove StaticInitialized<ThreadLocal<JNIEnv>> g_env; JavaVM* g_vm = nullptr; struct JThreadScopeSupport : JavaClass<JThreadScopeSupport> { static auto constexpr kJavaDescriptor = "Lcom/facebook/jni/ThreadScopeSupport;"; // These reinterpret_casts are a totally dangerous pattern. Don't use them. Use HybridData instead. static void runStdFunction(std::function<void()>&& func) { static auto method = javaClassStatic()->getStaticMethod<void(jlong)>("runStdFunction"); method(javaClassStatic(), reinterpret_cast<jlong>(&func)); } </s> add </s> remove class Value; class Context; class JSException : public std::exception { public: explicit JSException(const char* msg) : msg_(msg), stack_("") {} JSException(const char* msg, const char* stack) : msg_(msg), stack_(stack) {} const std::string& getStack() const { return stack_; } virtual const char* what() const noexcept override { return msg_.c_str(); } </s> add #ifndef RN_EXPORT #define RN_EXPORT __attribute__((visibility("default"))) #endif </s> add #ifdef USE_LYRA #include <fb/lyra.h> #include <fb/lyra_exceptions.h> #endif
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Exceptions.h
keep keep keep keep replace replace keep keep keep keep keep
<mask> throwNewJavaException(throwableName, msg); <mask> } <mask> <mask> // Identifies any pending C++ exception and throws it as a Java exception. If the exception can't <mask> // be thrown, it aborts the program. This is a noexcept function at C++ level. <mask> FBEXPORT void translatePendingCppExceptionToJavaException() noexcept; <mask> <mask> // For convenience, some exception names in java.lang are available here. <mask> <mask> const char* const gJavaLangIllegalArgumentException = "java/lang/IllegalArgumentException"; <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add FBEXPORT local_ref<JThrowable> getJavaExceptionForCppBackTrace(const char* msg); </s> remove // The implementation std::rethrow_if_nested uses a dynamic_cast to determine // if the exception is a nested_exception. If the exception is from a library // built with -fno-rtti, then that will crash. This avoids that. void rethrow_if_nested() { </s> add // For each exception in the chain of the exception_ptr argument, func // will be called with that exception (in reverse order, i.e. innermost first). #ifndef FBJNI_NO_EXCEPTION_PTR void denest(const std::function<void(std::exception_ptr)>& func, std::exception_ptr ptr) { FBASSERT(ptr); </s> remove // TODO(T6618159) Take a stack dump here to save context if it results in a crash when propagated </s> add // TODO(T6618159) Inject the c++ stack into the exception's stack trace. One // issue: when a java exception is created, it captures the full java stack // across jni boundaries. lyra will only capture the c++ stack to the jni // boundary. So, as we pass the java exception up to c++, we need to capture // the c++ stack and then insert it into the correct place in the java stack // trace. Then, as the exception propagates across the boundaries, we will // slowly fill in the c++ parts of the trace. </s> remove throw; </s> add std::rethrow_exception(ptr); </s> remove // For each exception in the chain of the currently handled exception, func // will be called with that exception as the currently handled exception (in // reverse order, i.e. innermost first). void denest(std::function<void()> func) { </s> add local_ref<JThrowable> convertCppExceptionToJavaException(std::exception_ptr ptr) { FBASSERT(ptr); local_ref<JThrowable> current; bool addCppStack = true; </s> remove FBLOGE("unexpected exception in translatePendingCppExceptionToJavaException"); throw; </s> add #ifdef USE_LYRA FBLOGE("Unexpected error in translatePendingCppExceptionToJavaException(): %s", lyra::toString(std::current_exception()).c_str()); #endif std::terminate();
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Exceptions.h
keep keep keep add keep keep keep keep keep
<mask> #endif <mask> <mask> FBEXPORT local_ref<JThrowable> getJavaExceptionForCppBackTrace(); <mask> <mask> // For convenience, some exception names in java.lang are available here. <mask> <mask> const char* const gJavaLangIllegalArgumentException = "java/lang/IllegalArgumentException"; <mask> <mask> }} </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove // be thrown, it aborts the program. This is a noexcept function at C++ level. FBEXPORT void translatePendingCppExceptionToJavaException() noexcept; </s> add // be thrown, it aborts the program. FBEXPORT void translatePendingCppExceptionToJavaException(); #ifndef FBJNI_NO_EXCEPTION_PTR FBEXPORT local_ref<JThrowable> getJavaExceptionForCppException(std::exception_ptr ptr); #endif FBEXPORT local_ref<JThrowable> getJavaExceptionForCppBackTrace(); </s> remove /// Wrapper to provide functionality to jthrowable references class FBEXPORT JThrowable : public JavaClass<JThrowable, JObject, jthrowable> { public: static constexpr const char* kJavaDescriptor = "Ljava/lang/Throwable;"; local_ref<JThrowable> initCause(alias_ref<JThrowable> cause); }; </s> add </s> remove // For each exception in the chain of the currently handled exception, func // will be called with that exception as the currently handled exception (in // reverse order, i.e. innermost first). void denest(std::function<void()> func) { </s> add local_ref<JThrowable> convertCppExceptionToJavaException(std::exception_ptr ptr) { FBASSERT(ptr); local_ref<JThrowable> current; bool addCppStack = true; </s> add return current; } #endif local_ref<JThrowable> getJavaExceptionForCppBackTrace() { return getJavaExceptionForCppBackTrace(nullptr); </s> add local_ref<JThrowable> getJavaExceptionForCppBackTrace(const char* msg) { local_ref<JThrowable> current = msg ? JUnknownCppException::create(msg) : JUnknownCppException::create(); #ifndef FBJNI_NO_EXCEPTION_PTR addCppStacktraceToJavaException(current, nullptr); #endif return current; </s> remove FBLOGE("unexpected exception in translatePendingCppExceptionToJavaException"); throw; </s> add #ifdef USE_LYRA FBLOGE("Unexpected error in translatePendingCppExceptionToJavaException(): %s", lyra::toString(std::current_exception()).c_str()); #endif std::terminate();
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Exceptions.h
keep keep keep keep replace replace keep keep keep keep keep
<mask> }; <mask> <mask> struct FBEXPORT HybridData : public JavaClass<HybridData> { <mask> constexpr static auto kJavaDescriptor = "Lcom/facebook/jni/HybridData;"; <mask> void setNativePointer(std::unique_ptr<BaseHybridClass> new_value); <mask> BaseHybridClass* getNativePointer(); <mask> static local_ref<HybridData> create(); <mask> }; <mask> <mask> template <typename Base, typename Enabled = void> <mask> struct HybridTraits { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add struct JVoid : public jni::JavaClass<JVoid> { static auto constexpr kJavaDescriptor = "Ljava/lang/Void;"; }; </s> remove // registration wrapper for legacy JNI-style functions template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, Args... args) { // Note that if func was declared noexcept, then both gcc and clang are smart // enough to elide the try/catch. try { (*func)(env, static_cast<C>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); } } }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add template <typename R> struct CreateDefault { static R create() { return R{}; } }; template <> struct CreateDefault<void> { static void create() {} }; template <typename R> using Converter = Convert<typename std::decay<R>::type>; template <typename F, F func, typename R, typename... Args> struct WrapForVoidReturn { static typename Converter<R>::jniType call(Args&&... args) { return Converter<R>::toJniRet(func(std::forward<Args>(args)...)); } }; template <typename F, F func, typename... Args> struct WrapForVoidReturn<F, func, void, Args...> { static void call(Args&&... args) { func(std::forward<Args>(args)...); } }; </s> remove StaticInitialized<ThreadLocal<JNIEnv>> g_env; JavaVM* g_vm = nullptr; struct JThreadScopeSupport : JavaClass<JThreadScopeSupport> { static auto constexpr kJavaDescriptor = "Lcom/facebook/jni/ThreadScopeSupport;"; // These reinterpret_casts are a totally dangerous pattern. Don't use them. Use HybridData instead. static void runStdFunction(std::function<void()>&& func) { static auto method = javaClassStatic()->getStaticMethod<void(jlong)>("runStdFunction"); method(javaClassStatic(), reinterpret_cast<jlong>(&func)); } </s> add </s> remove /// Wrapper to provide functionality to jthrowable references class FBEXPORT JThrowable : public JavaClass<JThrowable, JObject, jthrowable> { public: static constexpr const char* kJavaDescriptor = "Ljava/lang/Throwable;"; local_ref<JThrowable> initCause(alias_ref<JThrowable> cause); }; </s> add </s> remove const YGNodeRef node, YGLogLevel level, const char *format, va_list args) { </s> add const YGNodeRef node, YGLogLevel level, const char *format, va_list args) { </s> remove static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); </s> add detail::BaseHybridClass* result = 0; static bool isHybrid = detail::HybridClassBase::isHybridClassBase(this->getClass()); if (isHybrid) { result = getNativePointer(this); } else { static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } result = getNativePointer(hybridData);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Hybrid.h
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> static local_ref<detail::HybridData> makeHybridData(std::unique_ptr<T> cxxPart) { <mask> auto hybridData = detail::HybridData::create(); <mask> hybridData->setNativePointer(std::move(cxxPart)); <mask> return hybridData; <mask> } <mask> <mask> template <typename... Args> <mask> static local_ref<detail::HybridData> makeCxxInstance(Args&&... args) { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add template <typename... Args> static void setCxxInstance(alias_ref<jhybridobject> o, Args&&... args) { setNativePointer(o, std::unique_ptr<T>(new T(std::forward<Args>(args)...))); } </s> remove // TODO? Create reusable interface for Allocatable classes and use it to </s> add // TODO? Create reusable interface for Allocatable classes and use it to </s> remove auto hybridData = makeCxxInstance(std::forward<Args>(args)...); return JavaPart::newInstance(hybridData); </s> add static bool isHybrid = detail::HybridClassBase::isHybridClassBase(javaClassStatic()); auto cxxPart = std::unique_ptr<T>(new T(std::forward<Args>(args)...)); local_ref<JavaPart> result; if (isHybrid) { result = JavaPart::newInstance(); setNativePointer(result, std::move(cxxPart)); } else { auto hybridData = makeHybridData(std::move(cxxPart)); result = JavaPart::newInstance(hybridData); } return result; </s> remove // registration wrapper for legacy JNI-style functions template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, Args... args) { // Note that if func was declared noexcept, then both gcc and clang are smart // enough to elide the try/catch. try { (*func)(env, static_cast<C>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); } } }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add template <typename R> struct CreateDefault { static R create() { return R{}; } }; template <> struct CreateDefault<void> { static void create() {} }; template <typename R> using Converter = Convert<typename std::decay<R>::type>; template <typename F, F func, typename R, typename... Args> struct WrapForVoidReturn { static typename Converter<R>::jniType call(Args&&... args) { return Converter<R>::toJniRet(func(std::forward<Args>(args)...)); } }; template <typename F, F func, typename... Args> struct WrapForVoidReturn<F, func, void, Args...> { static void call(Args&&... args) { func(std::forward<Args>(args)...); } }; </s> remove static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); </s> add detail::BaseHybridClass* result = 0; static bool isHybrid = detail::HybridClassBase::isHybridClassBase(this->getClass()); if (isHybrid) { result = getNativePointer(this); } else { static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } result = getNativePointer(hybridData); </s> remove bool JByteBuffer::isDirect() { </s> add bool JByteBuffer::isDirect() const {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Hybrid.h
keep keep keep add keep keep keep keep keep
<mask> static local_ref<detail::HybridData> makeCxxInstance(Args&&... args) { <mask> return makeHybridData(std::unique_ptr<T>(new T(std::forward<Args>(args)...))); <mask> } <mask> <mask> public: <mask> // Factory method for creating a hybrid object where the arguments <mask> // are used to initialize the C++ part directly without passing them <mask> // through java. This method requires the Java part to have a ctor <mask> // which takes a HybridData, and for the C++ part to have a ctor </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove // shouldn't have to jump through java. </s> add // shouldn't have to jump through java. It should be enough to check if the // attach state env* is set. </s> remove static jniType toJniRet(global_ref<jniType> t) { </s> add static jniType toJniRet(global_ref<jniType>&& t) { // If this gets called, ownership the global_ref was passed in here. (It's // probably a copy of a persistent global_ref made when a function was // declared to return a global_ref, but it could moved out or otherwise not // referenced elsewhere. Doesn't matter.) Either way, the only safe way // to return it is to make a local_ref, release it, and return the // underlying local jobject. auto ret = make_local(t); return ret.release(); } static jniType toJniRet(const global_ref<jniType>& t) { // If this gets called, the function was declared to return const&. We // have a ref to a global_ref whose lifetime will exceed this call, so we // can just get the underlying jobject and return it to java without // needing to make a local_ref. </s> remove auto hybridData = makeCxxInstance(std::forward<Args>(args)...); return JavaPart::newInstance(hybridData); </s> add static bool isHybrid = detail::HybridClassBase::isHybridClassBase(javaClassStatic()); auto cxxPart = std::unique_ptr<T>(new T(std::forward<Args>(args)...)); local_ref<JavaPart> result; if (isHybrid) { result = JavaPart::newInstance(); setNativePointer(result, std::move(cxxPart)); } else { auto hybridData = makeHybridData(std::move(cxxPart)); result = JavaPart::newInstance(hybridData); } return result; </s> remove // The implementation std::rethrow_if_nested uses a dynamic_cast to determine // if the exception is a nested_exception. If the exception is from a library // built with -fno-rtti, then that will crash. This avoids that. void rethrow_if_nested() { </s> add // For each exception in the chain of the exception_ptr argument, func // will be called with that exception (in reverse order, i.e. innermost first). #ifndef FBJNI_NO_EXCEPTION_PTR void denest(const std::function<void(std::exception_ptr)>& func, std::exception_ptr ptr) { FBASSERT(ptr); </s> remove // non-void return type </s> add </s> remove void HybridData::setNativePointer(std::unique_ptr<BaseHybridClass> new_value) { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* old_value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (new_value) { // Modify should only ever be called once with a non-null // new_value. If this happens again it's a programmer error, so // blow up. FBASSERTMSGF(old_value == 0, "Attempt to set C++ native pointer twice"); } else if (old_value == 0) { return; } // delete on a null pointer is defined to be a noop. delete old_value; // This releases ownership from the unique_ptr, and passes the pointer, and // ownership of it, to HybridData which is managed by the java GC. The // finalizer on hybridData calls resetNative which will delete the object, if // resetNative has not already been called. setFieldValue(pointerField, reinterpret_cast<jlong>(new_value.release())); } BaseHybridClass* HybridData::getNativePointer() { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (!value) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } return value; } </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Hybrid.h
keep keep keep replace replace keep keep replace keep keep keep
<mask> // C++ object fails, or any JNI methods throw. <mask> template <typename... Args> <mask> static local_ref<JavaPart> newObjectCxxArgs(Args&&... args) { <mask> auto hybridData = makeCxxInstance(std::forward<Args>(args)...); <mask> return JavaPart::newInstance(hybridData); <mask> } <mask> <mask> // TODO? Create reusable interface for Allocatable classes and use it to <mask> // strengthen type-checking (and possibly provide a default <mask> // implementation of allocate().) <mask> template <typename... Args> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove hybridData->setNativePointer(std::move(cxxPart)); </s> add setNativePointer(hybridData, std::move(cxxPart)); </s> add template <typename... Args> static void setCxxInstance(alias_ref<jhybridobject> o, Args&&... args) { setNativePointer(o, std::unique_ptr<T>(new T(std::forward<Args>(args)...))); } </s> remove // registration wrapper for legacy JNI-style functions template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, Args... args) { // Note that if func was declared noexcept, then both gcc and clang are smart // enough to elide the try/catch. try { (*func)(env, static_cast<C>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); } } }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add template <typename R> struct CreateDefault { static R create() { return R{}; } }; template <> struct CreateDefault<void> { static void create() {} }; template <typename R> using Converter = Convert<typename std::decay<R>::type>; template <typename F, F func, typename R, typename... Args> struct WrapForVoidReturn { static typename Converter<R>::jniType call(Args&&... args) { return Converter<R>::toJniRet(func(std::forward<Args>(args)...)); } }; template <typename F, F func, typename... Args> struct WrapForVoidReturn<F, func, void, Args...> { static void call(Args&&... args) { func(std::forward<Args>(args)...); } }; </s> remove template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (...) { translatePendingCppExceptionToJavaException(); } </s> add // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename R, typename... Args> struct MethodWrapper { using jhybrid = typename C::jhybridobject; static R dispatch(alias_ref<jhybrid> ref, Args&&... args) { try { // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(ref->cthis()); return (cobj->*method)(std::forward<Args>(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; </s> remove // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { translatePendingCppExceptionToJavaException(); } } }; </s> add template<typename F, F func, typename C, typename R, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Hybrid.h
keep keep keep replace replace replace replace replace keep replace replace keep keep keep
<mask> <mask> template <typename T, typename B> <mask> inline T* HybridClass<T, B>::JavaPart::cthis() { <mask> static auto field = <mask> HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); <mask> auto hybridData = this->getFieldValue(field); <mask> if (!hybridData) { <mask> throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); <mask> } <mask> // I'd like to use dynamic_cast here, but -fno-rtti is the default. <mask> T* value = static_cast<T*>(hybridData->getNativePointer()); <mask> // This would require some serious programmer error. <mask> FBASSERTMSGF(value != 0, "Incorrect C++ type in hybrid field"); <mask> return value; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove FBASSERTMSGF(value != 0, "Incorrect C++ type in hybrid field"); return value; </s> add FBASSERTMSGF(result != 0, "Incorrect C++ type in hybrid field"); // I'd like to use dynamic_cast here, but -fno-rtti is the default. return static_cast<T*>(result); </s> remove void HybridData::setNativePointer(std::unique_ptr<BaseHybridClass> new_value) { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* old_value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (new_value) { // Modify should only ever be called once with a non-null // new_value. If this happens again it's a programmer error, so // blow up. FBASSERTMSGF(old_value == 0, "Attempt to set C++ native pointer twice"); } else if (old_value == 0) { return; } // delete on a null pointer is defined to be a noop. delete old_value; // This releases ownership from the unique_ptr, and passes the pointer, and // ownership of it, to HybridData which is managed by the java GC. The // finalizer on hybridData calls resetNative which will delete the object, if // resetNative has not already been called. setFieldValue(pointerField, reinterpret_cast<jlong>(new_value.release())); } BaseHybridClass* HybridData::getNativePointer() { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (!value) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } return value; } </s> add </s> remove auto hybridData = makeCxxInstance(std::forward<Args>(args)...); return JavaPart::newInstance(hybridData); </s> add static bool isHybrid = detail::HybridClassBase::isHybridClassBase(javaClassStatic()); auto cxxPart = std::unique_ptr<T>(new T(std::forward<Args>(args)...)); local_ref<JavaPart> result; if (isHybrid) { result = JavaPart::newInstance(); setNativePointer(result, std::move(cxxPart)); } else { auto hybridData = makeHybridData(std::move(cxxPart)); result = JavaPart::newInstance(hybridData); } return result; </s> remove struct funcWrapper { JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); return Convert<typename std::decay<R>::type>::toJniRet( (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...)); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { using jniRet = typename Convert<typename std::decay<R>::type>::jniType; translatePendingCppExceptionToJavaException(); return jniRet{}; } } }; </s> add </s> remove // TODO? Create reusable interface for Allocatable classes and use it to </s> add // TODO? Create reusable interface for Allocatable classes and use it to
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Hybrid.h
keep keep keep keep replace replace keep keep keep keep keep
<mask> } <mask> // I'd like to use dynamic_cast here, but -fno-rtti is the default. <mask> T* value = static_cast<T*>(hybridData->getNativePointer()); <mask> // This would require some serious programmer error. <mask> FBASSERTMSGF(value != 0, "Incorrect C++ type in hybrid field"); <mask> return value; <mask> }; <mask> <mask> template <typename T, typename B> <mask> /* static */ inline std::string HybridClass<T, B>::JavaPart::get_instantiated_java_descriptor() { <mask> return T::kJavaDescriptor; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove // I'd like to use dynamic_cast here, but -fno-rtti is the default. T* value = static_cast<T*>(hybridData->getNativePointer()); </s> add </s> remove static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); </s> add detail::BaseHybridClass* result = 0; static bool isHybrid = detail::HybridClassBase::isHybridClassBase(this->getClass()); if (isHybrid) { result = getNativePointer(this); } else { static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } result = getNativePointer(hybridData); </s> remove // registration wrapper for legacy JNI-style functions template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, Args... args) { // Note that if func was declared noexcept, then both gcc and clang are smart // enough to elide the try/catch. try { (*func)(env, static_cast<C>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); } } }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add template <typename R> struct CreateDefault { static R create() { return R{}; } }; template <> struct CreateDefault<void> { static void create() {} }; template <typename R> using Converter = Convert<typename std::decay<R>::type>; template <typename F, F func, typename R, typename... Args> struct WrapForVoidReturn { static typename Converter<R>::jniType call(Args&&... args) { return Converter<R>::toJniRet(func(std::forward<Args>(args)...)); } }; template <typename F, F func, typename... Args> struct WrapForVoidReturn<F, func, void, Args...> { static void call(Args&&... args) { func(std::forward<Args>(args)...); } }; </s> remove struct funcWrapper { JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); return Convert<typename std::decay<R>::type>::toJniRet( (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...)); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { using jniRet = typename Convert<typename std::decay<R>::type>::jniType; translatePendingCppExceptionToJavaException(); return jniRet{}; } } }; </s> add </s> remove // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { translatePendingCppExceptionToJavaException(); } } }; </s> add template<typename F, F func, typename C, typename R, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { </s> remove template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (...) { translatePendingCppExceptionToJavaException(); } </s> add // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename R, typename... Args> struct MethodWrapper { using jhybrid = typename C::jhybridobject; static R dispatch(alias_ref<jhybrid> ref, Args&&... args) { try { // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(ref->cthis()); return (cobj->*method)(std::forward<Args>(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Hybrid.h
keep keep keep keep replace keep keep keep keep keep
<mask> #include "References.h" <mask> #include "Boxed.h" <mask> <mask> #if defined(__ANDROID__) <mask> #include <sys/system_properties.h> <mask> #endif <mask> <mask> namespace facebook { <mask> namespace jni { <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add #if defined(__ANDROID__) && defined(__ARM_ARCH_5TE__) && !defined(FBJNI_NO_EXCEPTION_PTR) // ARMv5 NDK does not support exception_ptr so we cannot use that when building for it. #define FBJNI_NO_EXCEPTION_PTR #endif </s> remove #include <cxxreact/JsArgumentHelpers.h> </s> add #include "JsArgumentHelpers.h" #include "SystraceSection.h" </s> add #ifdef USE_LYRA #include <fb/lyra.h> #include <fb/lyra_exceptions.h> #endif </s> remove #include <fb/StaticInitialized.h> </s> add </s> add namespace internal { struct CacheEnvTag {}; } </s> remove #include <pthread.h> </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Meta-inl.h
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
<mask> // On Android 6.0, art crashes when attempting to call a function on a Proxy. <mask> // So, when we detect that case we must use the safe, slow workaround. That is, <mask> // we resolve the method id to the corresponding java.lang.reflect.Method object <mask> // and make the call via it's invoke() method. <mask> static auto android_sdk = ([] { <mask> char sdk_version_str[PROP_VALUE_MAX]; <mask> __system_property_get("ro.build.version.sdk", sdk_version_str); <mask> return atoi(sdk_version_str); <mask> })(); <mask> static auto is_bad_android = android_sdk == 23; <mask> if (!is_bad_android) return false; <mask> static auto proxy_class = findClassStatic("java/lang/reflect/Proxy"); <mask> return obj->isInstanceOf(proxy_class); <mask> #else <mask> return false; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove static jniType toJniRet(global_ref<jniType> t) { </s> add static jniType toJniRet(global_ref<jniType>&& t) { // If this gets called, ownership the global_ref was passed in here. (It's // probably a copy of a persistent global_ref made when a function was // declared to return a global_ref, but it could moved out or otherwise not // referenced elsewhere. Doesn't matter.) Either way, the only safe way // to return it is to make a local_ref, release it, and return the // underlying local jobject. auto ret = make_local(t); return ret.release(); } static jniType toJniRet(const global_ref<jniType>& t) { // If this gets called, the function was declared to return const&. We // have a ref to a global_ref whose lifetime will exceed this call, so we // can just get the underlying jobject and return it to java without // needing to make a local_ref. </s> remove // TODO(T6618159) Take a stack dump here to save context if it results in a crash when propagated </s> add // TODO(T6618159) Inject the c++ stack into the exception's stack trace. One // issue: when a java exception is created, it captures the full java stack // across jni boundaries. lyra will only capture the c++ stack to the jni // boundary. So, as we pass the java exception up to c++, we need to capture // the c++ stack and then insert it into the correct place in the java stack // trace. Then, as the exception propagates across the boundaries, we will // slowly fill in the c++ parts of the trace. </s> remove private static String getHostForJSProxy() { return AndroidInfoHelpers.DEVICE_LOCALHOST; </s> add private String getHostForJSProxy() { // Use custom port if configured. Note that host stays "localhost". String host = Assertions.assertNotNull(mSettings.getPackagerConnectionSettings().getDebugServerHost()); int portOffset = host.lastIndexOf(':'); if (portOffset > -1) { return "localhost" + host.substring(portOffset); } else { return AndroidInfoHelpers.DEVICE_LOCALHOST; } </s> remove static void runStdFunctionImpl(alias_ref<JClass>, jlong ptr) { (*reinterpret_cast<std::function<void()>*>(ptr))(); } static void OnLoad() { // We need the javaClassStatic so that the class lookup is cached and that // runStdFunction can be called from a ThreadScope-attached thread. javaClassStatic()->registerNatives({ makeNativeMethod("runStdFunctionImpl", runStdFunctionImpl), }); } }; </s> add ThreadLocal<ThreadScope>& scopeStorage() { // We don't want the ThreadLocal to delete the ThreadScopes. static ThreadLocal<ThreadScope> scope([] (void*) {}); return scope; </s> remove void HybridData::setNativePointer(std::unique_ptr<BaseHybridClass> new_value) { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* old_value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (new_value) { // Modify should only ever be called once with a non-null // new_value. If this happens again it's a programmer error, so // blow up. FBASSERTMSGF(old_value == 0, "Attempt to set C++ native pointer twice"); } else if (old_value == 0) { return; } // delete on a null pointer is defined to be a noop. delete old_value; // This releases ownership from the unique_ptr, and passes the pointer, and // ownership of it, to HybridData which is managed by the java GC. The // finalizer on hybridData calls resetNative which will delete the object, if // resetNative has not already been called. setFieldValue(pointerField, reinterpret_cast<jlong>(new_value.release())); } BaseHybridClass* HybridData::getNativePointer() { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (!value) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } return value; } </s> add </s> remove auto hybridData = makeCxxInstance(std::forward<Args>(args)...); return JavaPart::newInstance(hybridData); </s> add static bool isHybrid = detail::HybridClassBase::isHybridClassBase(javaClassStatic()); auto cxxPart = std::unique_ptr<T>(new T(std::forward<Args>(args)...)); local_ref<JavaPart> result; if (isHybrid) { result = JavaPart::newInstance(); setNativePointer(result, std::move(cxxPart)); } else { auto hybridData = makeHybridData(std::move(cxxPart)); result = JavaPart::newInstance(hybridData); } return result;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Meta-inl.h
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> #pragma push_macro("DEFINE_PRIMITIVE_CALL") <mask> #undef DEFINE_PRIMITIVE_CALL <mask> #define DEFINE_PRIMITIVE_CALL(TYPE, METHOD, CLASS) \ <mask> template<typename... Args> \ <mask> inline TYPE JMethod<TYPE(Args...)>::operator()(alias_ref<jobject> self, Args... args) { \ <mask> const auto env = internal::getEnv(); \ <mask> auto result = env->Call ## METHOD ## Method( \ <mask> self.get(), \ </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove #define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \ type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \ YGAssertWithNode(node, edge < YGEdgeEnd, "Cannot get layout properties of multi-edge shorthands"); \ \ if (edge == YGEdgeLeft) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeEnd]; \ } else { \ return node->layout.instanceName[YGEdgeStart]; \ } \ } \ \ if (edge == YGEdgeRight) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeStart]; \ } else { \ return node->layout.instanceName[YGEdgeEnd]; \ } \ } \ \ return node->layout.instanceName[edge]; \ </s> add #define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \ type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \ YGAssertWithNode(node, \ edge < YGEdgeEnd, \ "Cannot get layout properties of multi-edge shorthands"); \ \ if (edge == YGEdgeLeft) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeEnd]; \ } else { \ return node->layout.instanceName[YGEdgeStart]; \ } \ } \ \ if (edge == YGEdgeRight) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeStart]; \ } else { \ return node->layout.instanceName[YGEdgeEnd]; \ } \ } \ \ return node->layout.instanceName[edge]; \ </s> remove Dummy.cpp \ </s> add CatalystInstanceImpl.cpp \ CxxModuleWrapper.cpp \ JavaModuleWrapper.cpp \ JMessageQueueThread.cpp \ JSCPerfLogging.cpp \ JSLoader.cpp \ JSLogging.cpp \ JniJSModulesUnbundle.cpp \ MethodInvoker.cpp \ ModuleRegistryBuilder.cpp \ NativeArray.cpp \ NativeCommon.cpp \ NativeMap.cpp \ OnLoad.cpp \ ProxyExecutor.cpp \ ReadableNativeArray.cpp \ ReadableNativeMap.cpp \ WritableNativeArray.cpp \ WritableNativeMap.cpp \ </s> remove LOCAL_MODULE := libreactnativefb </s> add LOCAL_MODULE := reactnative </s> add YGNodeType nodeType; </s> remove const float marginColumn); </s> add const float marginColumn, YGConfigRef config); </s> remove LOCAL_MODULE := libreactnativejni </s> add LOCAL_MODULE := reactnativejni
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Meta-inl.h
keep keep keep keep replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); \ <mask> return result; \ <mask> } <mask> <mask> DEFINE_PRIMITIVE_CALL(jboolean, Boolean, JBoolean) <mask> DEFINE_PRIMITIVE_CALL(jbyte, Byte, JByte) <mask> DEFINE_PRIMITIVE_CALL(jchar, Char, JCharacter) <mask> DEFINE_PRIMITIVE_CALL(jshort, Short, JShort) <mask> DEFINE_PRIMITIVE_CALL(jint, Int, JInteger) <mask> DEFINE_PRIMITIVE_CALL(jlong, Long, JLong) <mask> DEFINE_PRIMITIVE_CALL(jfloat, Float, JFloat) <mask> DEFINE_PRIMITIVE_CALL(jdouble, Double, JDouble) <mask> #pragma pop_macro("DEFINE_PRIMITIVE_CALL") <mask> <mask> /// JMethod specialization for references that wraps the return value in a @ref local_ref <mask> template<typename R, typename... Args> <mask> class JMethod<R(Args...)> : public JMethodBase { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove #define DEFINE_PRIMITIVE_CALL(TYPE, METHOD, CLASS) \ </s> add #define DEFINE_PRIMITIVE_CALL(TYPE, METHOD) \ </s> remove #define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \ type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \ YGAssertWithNode(node, edge < YGEdgeEnd, "Cannot get layout properties of multi-edge shorthands"); \ \ if (edge == YGEdgeLeft) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeEnd]; \ } else { \ return node->layout.instanceName[YGEdgeStart]; \ } \ } \ \ if (edge == YGEdgeRight) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeStart]; \ } else { \ return node->layout.instanceName[YGEdgeEnd]; \ } \ } \ \ return node->layout.instanceName[edge]; \ </s> add #define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \ type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \ YGAssertWithNode(node, \ edge < YGEdgeEnd, \ "Cannot get layout properties of multi-edge shorthands"); \ \ if (edge == YGEdgeLeft) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeEnd]; \ } else { \ return node->layout.instanceName[YGEdgeStart]; \ } \ } \ \ if (edge == YGEdgeRight) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeStart]; \ } else { \ return node->layout.instanceName[YGEdgeEnd]; \ } \ } \ \ return node->layout.instanceName[edge]; \ </s> remove // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { translatePendingCppExceptionToJavaException(); } } }; </s> add template<typename F, F func, typename C, typename R, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { </s> remove struct funcWrapper { JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); return Convert<typename std::decay<R>::type>::toJniRet( (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...)); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { using jniRet = typename Convert<typename std::decay<R>::type>::jniType; translatePendingCppExceptionToJavaException(); return jniRet{}; } } }; </s> add </s> add template<typename F, F func, typename C, typename R, typename... Args> struct FunctionWrapper { using jniRet = typename Converter<R>::jniType; JNI_ENTRY_POINT static jniRet call(JNIEnv* env, jobject obj, typename Converter<Args>::jniType... args) { ThreadScope ts(env, internal::CacheEnvTag{}); try { return WrapForVoidReturn<F, func, R, JniType<C>, Args...>::call( static_cast<JniType<C>>(obj), Converter<Args>::fromJni(args)...); } catch (...) { translatePendingCppExceptionToJavaException(); return CreateDefault<jniRet>::create(); } } }; </s> remove return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); </s> add return reinterpret_cast<NativeMethodWrapper*>(&(MethodWrapper<M, method, C, R, Args...>::call));
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Meta-inl.h
keep keep keep keep replace keep keep keep keep keep
<mask> template <typename T> <mask> struct Convert<global_ref<T>> { <mask> typedef JniType<T> jniType; <mask> // No automatic synthesis of global_ref <mask> static jniType toJniRet(global_ref<jniType> t) { <mask> return t.get(); <mask> } <mask> static jniType toCall(global_ref<jniType> t) { <mask> return t.get(); <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove // registration wrapper for legacy JNI-style functions template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, Args... args) { // Note that if func was declared noexcept, then both gcc and clang are smart // enough to elide the try/catch. try { (*func)(env, static_cast<C>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); } } }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add template <typename R> struct CreateDefault { static R create() { return R{}; } }; template <> struct CreateDefault<void> { static void create() {} }; template <typename R> using Converter = Convert<typename std::decay<R>::type>; template <typename F, F func, typename R, typename... Args> struct WrapForVoidReturn { static typename Converter<R>::jniType call(Args&&... args) { return Converter<R>::toJniRet(func(std::forward<Args>(args)...)); } }; template <typename F, F func, typename... Args> struct WrapForVoidReturn<F, func, void, Args...> { static void call(Args&&... args) { func(std::forward<Args>(args)...); } }; </s> remove void setNativePointer(std::unique_ptr<BaseHybridClass> new_value); BaseHybridClass* getNativePointer(); </s> add </s> remove hybridData->setNativePointer(std::move(cxxPart)); </s> add setNativePointer(hybridData, std::move(cxxPart)); </s> remove inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { try { return (*func)(env, static_cast<JniType<C>>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); return R{}; } </s> add struct BareJniWrapper { JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { ThreadScope ts(env, internal::CacheEnvTag{}); try { return (*func)(env, static_cast<JniType<C>>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); return CreateDefault<R>::create(); </s> remove /* static */ void Environment::detachCurrentThread() { auto env = g_env->get(); if (env) { FBASSERT(g_vm); g_vm->DetachCurrentThread(); g_env->reset(); } } </s> add JavaVM* g_vm = nullptr; </s> add template<typename F, F func, typename C, typename R, typename... Args> struct FunctionWrapper { using jniRet = typename Converter<R>::jniType; JNI_ENTRY_POINT static jniRet call(JNIEnv* env, jobject obj, typename Converter<Args>::jniType... args) { ThreadScope ts(env, internal::CacheEnvTag{}); try { return WrapForVoidReturn<F, func, R, JniType<C>, Args...>::call( static_cast<JniType<C>>(obj), Converter<Args>::fromJni(args)...); } catch (...) { translatePendingCppExceptionToJavaException(); return CreateDefault<jniRet>::create(); } } };
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/MetaConvert.h
keep keep keep keep replace keep keep keep keep keep
<mask> namespace internal { <mask> <mask> // Statistics mostly provided for test (only updated if FBJNI_DEBUG_REFS is defined) <mask> struct ReferenceStats { <mask> std::atomic_uint locals_deleted, globals_deleted, weaks_deleted; <mask> <mask> void reset() noexcept; <mask> }; <mask> <mask> extern ReferenceStats g_reference_stats; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add namespace internal { struct CacheEnvTag {}; } </s> remove StaticInitialized<ThreadLocal<JNIEnv>> g_env; JavaVM* g_vm = nullptr; struct JThreadScopeSupport : JavaClass<JThreadScopeSupport> { static auto constexpr kJavaDescriptor = "Lcom/facebook/jni/ThreadScopeSupport;"; // These reinterpret_casts are a totally dangerous pattern. Don't use them. Use HybridData instead. static void runStdFunction(std::function<void()>&& func) { static auto method = javaClassStatic()->getStaticMethod<void(jlong)>("runStdFunction"); method(javaClassStatic(), reinterpret_cast<jlong>(&func)); } </s> add </s> remove // registration wrapper for legacy JNI-style functions template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, Args... args) { // Note that if func was declared noexcept, then both gcc and clang are smart // enough to elide the try/catch. try { (*func)(env, static_cast<C>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); } } }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add template <typename R> struct CreateDefault { static R create() { return R{}; } }; template <> struct CreateDefault<void> { static void create() {} }; template <typename R> using Converter = Convert<typename std::decay<R>::type>; template <typename F, F func, typename R, typename... Args> struct WrapForVoidReturn { static typename Converter<R>::jniType call(Args&&... args) { return Converter<R>::toJniRet(func(std::forward<Args>(args)...)); } }; template <typename F, F func, typename... Args> struct WrapForVoidReturn<F, func, void, Args...> { static void call(Args&&... args) { func(std::forward<Args>(args)...); } }; </s> remove template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (...) { translatePendingCppExceptionToJavaException(); } </s> add // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename R, typename... Args> struct MethodWrapper { using jhybrid = typename C::jhybridobject; static R dispatch(alias_ref<jhybrid> ref, Args&&... args) { try { // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(ref->cthis()); return (cobj->*method)(std::forward<Args>(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; </s> add template<typename F, F func, typename C, typename R, typename... Args> struct FunctionWrapper { using jniRet = typename Converter<R>::jniType; JNI_ENTRY_POINT static jniRet call(JNIEnv* env, jobject obj, typename Converter<Args>::jniType... args) { ThreadScope ts(env, internal::CacheEnvTag{}); try { return WrapForVoidReturn<F, func, R, JniType<C>, Args...>::call( static_cast<JniType<C>>(obj), Converter<Args>::fromJni(args)...); } catch (...) { translatePendingCppExceptionToJavaException(); return CreateDefault<jniRet>::create(); } } }; </s> remove void setNativePointer(std::unique_ptr<BaseHybridClass> new_value); BaseHybridClass* getNativePointer(); </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/ReferenceAllocators-inl.h
keep keep keep add keep keep keep keep keep keep
<mask> // LocalReferenceAllocator ///////////////////////////////////////////////////////////////////////// <mask> <mask> inline jobject LocalReferenceAllocator::newReference(jobject original) const { <mask> internal::dbglog("Local new: %p", original); <mask> auto ref = internal::getEnv()->NewLocalRef(original); <mask> FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); <mask> return ref; <mask> } <mask> <mask> inline void LocalReferenceAllocator::deleteReference(jobject reference) const noexcept { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add #ifdef FBJNI_DEBUG_REFS ++internal::g_reference_stats.globals_created; #endif </s> add #ifdef FBJNI_DEBUG_REFS ++internal::g_reference_stats.weaks_created; #endif </s> remove // jthrowable ////////////////////////////////////////////////////////////////////////////////////// inline local_ref<JThrowable> JThrowable::initCause(alias_ref<JThrowable> cause) { static auto meth = javaClassStatic()->getMethod<javaobject(javaobject)>("initCause"); return meth(self(), cause.get()); } </s> add </s> remove const auto result = env->IsAssignableFrom(self(), other.get()); </s> add // Ths method has behavior compatible with the // java.lang.Class#isAssignableFrom method. The order of the // arguments to the JNI IsAssignableFrom C function is "opposite" // from what some might expect, which makes this code look a little // odd, but it is correct. const auto result = env->IsAssignableFrom(other.get(), self()); </s> remove uint8_t* JByteBuffer::getDirectBytes() { </s> add uint8_t* JByteBuffer::getDirectBytes() const { </s> remove size_t JByteBuffer::getDirectSize() { </s> add size_t JByteBuffer::getDirectSize() const {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/ReferenceAllocators-inl.h
keep keep add keep keep keep keep
<mask> <mask> inline jobject GlobalReferenceAllocator::newReference(jobject original) const { <mask> internal::dbglog("Global new: %p", original); <mask> auto ref = internal::getEnv()->NewGlobalRef(original); <mask> FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); <mask> return ref; <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add #ifdef FBJNI_DEBUG_REFS ++internal::g_reference_stats.weaks_created; #endif </s> add #ifdef FBJNI_DEBUG_REFS ++internal::g_reference_stats.locals_created; #endif </s> remove // jthrowable ////////////////////////////////////////////////////////////////////////////////////// inline local_ref<JThrowable> JThrowable::initCause(alias_ref<JThrowable> cause) { static auto meth = javaClassStatic()->getMethod<javaobject(javaobject)>("initCause"); return meth(self(), cause.get()); } </s> add </s> remove uint8_t* JByteBuffer::getDirectBytes() { </s> add uint8_t* JByteBuffer::getDirectBytes() const { </s> remove size_t JByteBuffer::getDirectSize() { </s> add size_t JByteBuffer::getDirectSize() const { </s> remove const auto result = env->IsAssignableFrom(self(), other.get()); </s> add // Ths method has behavior compatible with the // java.lang.Class#isAssignableFrom method. The order of the // arguments to the JNI IsAssignableFrom C function is "opposite" // from what some might expect, which makes this code look a little // odd, but it is correct. const auto result = env->IsAssignableFrom(other.get(), self());
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/ReferenceAllocators-inl.h
keep keep add keep keep keep keep
<mask> <mask> inline jobject WeakGlobalReferenceAllocator::newReference(jobject original) const { <mask> internal::dbglog("Weak global new: %p", original); <mask> auto ref = internal::getEnv()->NewWeakGlobalRef(original); <mask> FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); <mask> return ref; <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add #ifdef FBJNI_DEBUG_REFS ++internal::g_reference_stats.globals_created; #endif </s> add #ifdef FBJNI_DEBUG_REFS ++internal::g_reference_stats.locals_created; #endif </s> remove // jthrowable ////////////////////////////////////////////////////////////////////////////////////// inline local_ref<JThrowable> JThrowable::initCause(alias_ref<JThrowable> cause) { static auto meth = javaClassStatic()->getMethod<javaobject(javaobject)>("initCause"); return meth(self(), cause.get()); } </s> add </s> remove uint8_t* JByteBuffer::getDirectBytes() { </s> add uint8_t* JByteBuffer::getDirectBytes() const { </s> remove size_t JByteBuffer::getDirectSize() { </s> add size_t JByteBuffer::getDirectSize() const { </s> remove const auto result = env->IsAssignableFrom(self(), other.get()); </s> add // Ths method has behavior compatible with the // java.lang.Class#isAssignableFrom method. The order of the // arguments to the JNI IsAssignableFrom C function is "opposite" // from what some might expect, which makes this code look a little // odd, but it is correct. const auto result = env->IsAssignableFrom(other.get(), self());
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/ReferenceAllocators-inl.h
keep replace keep keep keep replace keep keep
<mask> { <mask> if (! ref) { <mask> return decltype(static_ref_cast<T>(ref))(); <mask> } <mask> <mask> std::string target_class_name{jtype_traits<T>::base_name()}; <mask> <mask> // If not found, will throw an exception. </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove // If not found, will throw an exception. alias_ref<jclass> target_class = findClassStatic(target_class_name.c_str()); </s> add } </s> remove /* static */ JNIEnv* Environment::current() { JNIEnv* env = g_env->get(); if ((env == nullptr) && (g_vm != nullptr)) { if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK) { FBLOGE("Error retrieving JNI Environment, thread is probably not attached to JVM"); // TODO(cjhopman): This should throw an exception. env = nullptr; } else { g_env->reset(env); } } return env; </s> add ThreadScope* currentScope() { return scopeStorage().get(); </s> remove throw new IllegalViewOperationException("Trying to add a root view with an explicit id already set. React Native uses " + "the id field to track react tags and will overwrite this field. If that is fine, " + "explicitly overwrite the id field to View.NO_ID before calling addMeasuredRootView."); </s> add throw new IllegalViewOperationException("Trying to add a root view with an explicit id already set. React Native uses " + "the id field to track react tags and will overwrite this field. If that is fine, " + "explicitly overwrite the id field to View.NO_ID before calling addRootView."); </s> remove throw; </s> add std::rethrow_exception(ptr); </s> remove return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); </s> add return reinterpret_cast<NativeMethodWrapper*>(&(MethodWrapper<M, method, C, R, Args...>::call));
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/References-inl.h
keep keep replace replace keep keep keep replace keep keep keep keep
<mask> std::string target_class_name{jtype_traits<T>::base_name()}; <mask> <mask> // If not found, will throw an exception. <mask> alias_ref<jclass> target_class = findClassStatic(target_class_name.c_str()); <mask> <mask> local_ref<jclass> source_class = ref->getClass(); <mask> <mask> if ( ! source_class->isAssignableFrom(target_class)) { <mask> throwNewJavaException("java/lang/ClassCastException", <mask> "Tried to cast from %s to %s.", <mask> source_class->toString().c_str(), <mask> target_class_name.c_str()); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove std::string target_class_name{jtype_traits<T>::base_name()}; </s> add static alias_ref<jclass> target_class = findClassStatic(jtype_traits<T>::base_name().c_str()); if (!target_class) { throwNewJavaException("java/lang/ClassCastException", "Could not find class %s.", jtype_traits<T>::base_name().c_str()); </s> remove target_class_name.c_str()); </s> add jtype_traits<T>::base_name().c_str()); </s> remove /* static */ JNIEnv* Environment::current() { JNIEnv* env = g_env->get(); if ((env == nullptr) && (g_vm != nullptr)) { if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK) { FBLOGE("Error retrieving JNI Environment, thread is probably not attached to JVM"); // TODO(cjhopman): This should throw an exception. env = nullptr; } else { g_env->reset(env); } } return env; </s> add ThreadScope* currentScope() { return scopeStorage().get(); </s> remove auto cls = env->FindClass(name); </s> add local_ref<jclass> cls = adopt_local(env->FindClass(name)); </s> remove throw new IllegalViewOperationException("Trying to add a root view with an explicit id already set. React Native uses " + "the id field to track react tags and will overwrite this field. If that is fine, " + "explicitly overwrite the id field to View.NO_ID before calling addMeasuredRootView."); </s> add throw new IllegalViewOperationException("Trying to add a root view with an explicit id already set. React Native uses " + "the id field to track react tags and will overwrite this field. If that is fine, " + "explicitly overwrite the id field to View.NO_ID before calling addRootView.");
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/References-inl.h
keep keep keep keep replace keep keep keep keep keep
<mask> if ( ! source_class->isAssignableFrom(target_class)) { <mask> throwNewJavaException("java/lang/ClassCastException", <mask> "Tried to cast from %s to %s.", <mask> source_class->toString().c_str(), <mask> target_class_name.c_str()); <mask> } <mask> <mask> return static_ref_cast<T>(ref); <mask> } <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove if ( ! source_class->isAssignableFrom(target_class)) { </s> add if (!target_class->isAssignableFrom(source_class)) { </s> remove // If not found, will throw an exception. alias_ref<jclass> target_class = findClassStatic(target_class_name.c_str()); </s> add } </s> add public BundleDownloader getBundleDownloader() { return mBundleDownloader; } </s> remove std::string target_class_name{jtype_traits<T>::base_name()}; </s> add static alias_ref<jclass> target_class = findClassStatic(jtype_traits<T>::base_name().c_str()); if (!target_class) { throwNewJavaException("java/lang/ClassCastException", "Could not find class %s.", jtype_traits<T>::base_name().c_str()); </s> remove private static String getHostForJSProxy() { return AndroidInfoHelpers.DEVICE_LOCALHOST; </s> add private String getHostForJSProxy() { // Use custom port if configured. Note that host stays "localhost". String host = Assertions.assertNotNull(mSettings.getPackagerConnectionSettings().getDebugServerHost()); int portOffset = host.lastIndexOf(':'); if (portOffset > -1) { return "localhost" + host.substring(portOffset); } else { return AndroidInfoHelpers.DEVICE_LOCALHOST; } </s> remove void HybridData::setNativePointer(std::unique_ptr<BaseHybridClass> new_value) { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* old_value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (new_value) { // Modify should only ever be called once with a non-null // new_value. If this happens again it's a programmer error, so // blow up. FBASSERTMSGF(old_value == 0, "Attempt to set C++ native pointer twice"); } else if (old_value == 0) { return; } // delete on a null pointer is defined to be a noop. delete old_value; // This releases ownership from the unique_ptr, and passes the pointer, and // ownership of it, to HybridData which is managed by the java GC. The // finalizer on hybridData calls resetNative which will delete the object, if // resetNative has not already been called. setFieldValue(pointerField, reinterpret_cast<jlong>(new_value.release())); } BaseHybridClass* HybridData::getNativePointer() { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (!value) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } return value; } </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/References-inl.h
keep keep keep keep replace keep keep keep keep keep
<mask> weak_ref() noexcept <mask> : base_owned_ref<T, Allocator>{} {} <mask> <mask> /// Create a null reference <mask> explicit weak_ref(std::nullptr_t) noexcept <mask> : base_owned_ref<T, Allocator>{nullptr} {} <mask> <mask> /// Copy constructor (note creates a new reference) <mask> weak_ref(const weak_ref& other) <mask> : base_owned_ref<T, Allocator>{other} {} </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove explicit basic_strong_ref(std::nullptr_t) noexcept </s> add /* implicit */ basic_strong_ref(std::nullptr_t) noexcept </s> remove alias_ref(std::nullptr_t) noexcept; </s> add /* implicit */ alias_ref(std::nullptr_t) noexcept; </s> remove explicit String(JSContextRef context, const char* utf8) : m_context(context), m_string(JSC_JSStringCreateWithUTF8CString(context, utf8)) {} </s> add explicit String(): m_context(nullptr), m_string(nullptr) {} // dummy empty constructor explicit String(JSContextRef context, const char* utf8) : m_context(context), m_string(JSC_JSStringCreateWithUTF8CString(context, utf8)) {} </s> add // C++ object wrapper for JSStringRef </s> remove class Value; class Context; class JSException : public std::exception { public: explicit JSException(const char* msg) : msg_(msg), stack_("") {} JSException(const char* msg, const char* stack) : msg_(msg), stack_(stack) {} const std::string& getStack() const { return stack_; } virtual const char* what() const noexcept override { return msg_.c_str(); } </s> add #ifndef RN_EXPORT #define RN_EXPORT __attribute__((visibility("default"))) #endif </s> remove __attribute__((visibility("default"))) Value(JSContextRef context, JSValueRef value); __attribute__((visibility("default"))) Value(JSContextRef context, JSStringRef value); __attribute__((visibility("default"))) Value(Value&&); </s> add RN_EXPORT Value(JSContextRef context, JSValueRef value); RN_EXPORT Value(JSContextRef context, JSStringRef value); RN_EXPORT Value(const Value &o) : Value(o.m_context, o.m_value) {} RN_EXPORT Value(const String &o) : Value(o.context(), o) {}
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/References.h
keep keep keep keep replace keep keep keep keep keep
<mask> basic_strong_ref() noexcept <mask> : base_owned_ref<T, Alloc>{} {} <mask> <mask> /// Create a null reference <mask> explicit basic_strong_ref(std::nullptr_t) noexcept <mask> : base_owned_ref<T, Alloc>{nullptr} {} <mask> <mask> /// Copy constructor (note creates a new reference) <mask> basic_strong_ref(const basic_strong_ref& other) <mask> : base_owned_ref<T, Alloc>{other} {} </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove explicit weak_ref(std::nullptr_t) noexcept </s> add /* implicit */ weak_ref(std::nullptr_t) noexcept </s> remove alias_ref(std::nullptr_t) noexcept; </s> add /* implicit */ alias_ref(std::nullptr_t) noexcept; </s> remove explicit String(JSContextRef context, const char* utf8) : m_context(context), m_string(JSC_JSStringCreateWithUTF8CString(context, utf8)) {} </s> add explicit String(): m_context(nullptr), m_string(nullptr) {} // dummy empty constructor explicit String(JSContextRef context, const char* utf8) : m_context(context), m_string(JSC_JSStringCreateWithUTF8CString(context, utf8)) {} </s> add // C++ object wrapper for JSStringRef </s> remove class Value; class Context; class JSException : public std::exception { public: explicit JSException(const char* msg) : msg_(msg), stack_("") {} JSException(const char* msg, const char* stack) : msg_(msg), stack_(stack) {} const std::string& getStack() const { return stack_; } virtual const char* what() const noexcept override { return msg_.c_str(); } </s> add #ifndef RN_EXPORT #define RN_EXPORT __attribute__((visibility("default"))) #endif </s> remove __attribute__((visibility("default"))) Value(JSContextRef context, JSValueRef value); __attribute__((visibility("default"))) Value(JSContextRef context, JSStringRef value); __attribute__((visibility("default"))) Value(Value&&); </s> add RN_EXPORT Value(JSContextRef context, JSValueRef value); RN_EXPORT Value(JSContextRef context, JSStringRef value); RN_EXPORT Value(const Value &o) : Value(o.m_context, o.m_value) {} RN_EXPORT Value(const String &o) : Value(o.context(), o) {}
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/References.h
keep keep keep keep replace keep keep keep keep keep
<mask> /// Create a null reference <mask> alias_ref() noexcept; <mask> <mask> /// Create a null reference <mask> alias_ref(std::nullptr_t) noexcept; <mask> <mask> /// Copy constructor <mask> alias_ref(const alias_ref& other) noexcept; <mask> <mask> /// Wrap an existing plain JNI reference </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove explicit weak_ref(std::nullptr_t) noexcept </s> add /* implicit */ weak_ref(std::nullptr_t) noexcept </s> remove explicit basic_strong_ref(std::nullptr_t) noexcept </s> add /* implicit */ basic_strong_ref(std::nullptr_t) noexcept </s> add namespace internal { struct CacheEnvTag {}; } </s> remove /// Wrapper to provide functionality to jthrowable references class FBEXPORT JThrowable : public JavaClass<JThrowable, JObject, jthrowable> { public: static constexpr const char* kJavaDescriptor = "Ljava/lang/Throwable;"; local_ref<JThrowable> initCause(alias_ref<JThrowable> cause); }; </s> add </s> remove DEFINE_PRIMITIVE_CALL(jboolean, Boolean, JBoolean) DEFINE_PRIMITIVE_CALL(jbyte, Byte, JByte) DEFINE_PRIMITIVE_CALL(jchar, Char, JCharacter) DEFINE_PRIMITIVE_CALL(jshort, Short, JShort) DEFINE_PRIMITIVE_CALL(jint, Int, JInteger) DEFINE_PRIMITIVE_CALL(jlong, Long, JLong) DEFINE_PRIMITIVE_CALL(jfloat, Float, JFloat) DEFINE_PRIMITIVE_CALL(jdouble, Double, JDouble) </s> add DEFINE_PRIMITIVE_CALL(jboolean, Boolean) DEFINE_PRIMITIVE_CALL(jbyte, Byte) DEFINE_PRIMITIVE_CALL(jchar, Char) DEFINE_PRIMITIVE_CALL(jshort, Short) DEFINE_PRIMITIVE_CALL(jint, Int) DEFINE_PRIMITIVE_CALL(jlong, Long) DEFINE_PRIMITIVE_CALL(jfloat, Float) DEFINE_PRIMITIVE_CALL(jdouble, Double) </s> remove std::atomic_uint locals_deleted, globals_deleted, weaks_deleted; </s> add std::atomic_uint locals_created, globals_created, weaks_created, locals_deleted, globals_deleted, weaks_deleted;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/References.h
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> #else <mask> #define JNI_ENTRY_POINT <mask> #endif <mask> <mask> // registration wrapper for legacy JNI-style functions <mask> <mask> template<typename F, F func, typename C, typename... Args> <mask> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(JNIEnv*, C, Args... args)) { <mask> struct funcWrapper { <mask> JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, Args... args) { <mask> // Note that if func was declared noexcept, then both gcc and clang are smart <mask> // enough to elide the try/catch. <mask> try { <mask> (*func)(env, static_cast<C>(obj), args...); <mask> } catch (...) { <mask> translatePendingCppExceptionToJavaException(); <mask> } <mask> } <mask> }; <mask> <mask> // This intentionally erases the real type; JNI will do it anyway <mask> return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); <mask> } <mask> <mask> template<typename F, F func, typename C, typename R, typename... Args> <mask> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { <mask> struct funcWrapper { <mask> JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { try { return (*func)(env, static_cast<JniType<C>>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); return R{}; } </s> add struct BareJniWrapper { JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { ThreadScope ts(env, internal::CacheEnvTag{}); try { return (*func)(env, static_cast<JniType<C>>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); return CreateDefault<R>::create(); </s> remove // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add JNI_ENTRY_POINT static typename Converter<R>::jniType call( JNIEnv* env, jobject obj, typename Converter<Args>::jniType... args) { return FunctionWrapper<R(*)(alias_ref<jhybrid>, Args&&...), dispatch, jhybrid, R, Args...>::call(env, obj, args...); } }; </s> add // registration wrapper for legacy JNI-style functions </s> remove inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { return Convert<typename std::decay<R>::type>::toJniRet( (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...)); } catch (...) { using jniRet = typename Convert<typename std::decay<R>::type>::jniType; translatePendingCppExceptionToJavaException(); return jniRet{}; } } }; </s> add inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { </s> remove // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { translatePendingCppExceptionToJavaException(); } } }; </s> add template<typename F, F func, typename C, typename R, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { </s> remove }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add } };
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Registration-inl.h
keep keep keep add keep keep keep keep keep keep
<mask> func(std::forward<Args>(args)...); <mask> } <mask> }; <mask> <mask> template<typename F, F func, typename C, typename R, typename... Args> <mask> struct BareJniWrapper { <mask> JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { <mask> ThreadScope ts(env, internal::CacheEnvTag{}); <mask> try { <mask> return (*func)(env, static_cast<JniType<C>>(obj), args...); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { try { return (*func)(env, static_cast<JniType<C>>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); return R{}; } </s> add struct BareJniWrapper { JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { ThreadScope ts(env, internal::CacheEnvTag{}); try { return (*func)(env, static_cast<JniType<C>>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); return CreateDefault<R>::create(); </s> add template<typename F, F func, typename C, typename R, typename... Args> struct FunctionWrapper { using jniRet = typename Converter<R>::jniType; JNI_ENTRY_POINT static jniRet call(JNIEnv* env, jobject obj, typename Converter<Args>::jniType... args) { ThreadScope ts(env, internal::CacheEnvTag{}); try { return WrapForVoidReturn<F, func, R, JniType<C>, Args...>::call( static_cast<JniType<C>>(obj), Converter<Args>::fromJni(args)...); } catch (...) { translatePendingCppExceptionToJavaException(); return CreateDefault<jniRet>::create(); } } }; </s> remove // registration wrapper for legacy JNI-style functions template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, Args... args) { // Note that if func was declared noexcept, then both gcc and clang are smart // enough to elide the try/catch. try { (*func)(env, static_cast<C>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); } } }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add template <typename R> struct CreateDefault { static R create() { return R{}; } }; template <> struct CreateDefault<void> { static void create() {} }; template <typename R> using Converter = Convert<typename std::decay<R>::type>; template <typename F, F func, typename R, typename... Args> struct WrapForVoidReturn { static typename Converter<R>::jniType call(Args&&... args) { return Converter<R>::toJniRet(func(std::forward<Args>(args)...)); } }; template <typename F, F func, typename... Args> struct WrapForVoidReturn<F, func, void, Args...> { static void call(Args&&... args) { func(std::forward<Args>(args)...); } }; </s> remove // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add JNI_ENTRY_POINT static typename Converter<R>::jniType call( JNIEnv* env, jobject obj, typename Converter<Args>::jniType... args) { return FunctionWrapper<R(*)(alias_ref<jhybrid>, Args&&...), dispatch, jhybrid, R, Args...>::call(env, obj, args...); } }; </s> remove inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { return Convert<typename std::decay<R>::type>::toJniRet( (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...)); } catch (...) { using jniRet = typename Convert<typename std::decay<R>::type>::jniType; translatePendingCppExceptionToJavaException(); return jniRet{}; } } }; </s> add inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { </s> remove // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { translatePendingCppExceptionToJavaException(); } } }; </s> add template<typename F, F func, typename C, typename R, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Registration-inl.h
keep keep keep keep replace replace replace replace replace replace replace replace replace keep replace replace replace replace replace keep keep keep
<mask> return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); <mask> } <mask> <mask> template<typename F, F func, typename C, typename R, typename... Args> <mask> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { <mask> struct funcWrapper { <mask> JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { <mask> try { <mask> return (*func)(env, static_cast<JniType<C>>(obj), args...); <mask> } catch (...) { <mask> translatePendingCppExceptionToJavaException(); <mask> return R{}; <mask> } <mask> } <mask> }; <mask> <mask> // This intentionally erases the real type; JNI will do it anyway <mask> return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); <mask> } <mask> <mask> // registration wrappers for functions, with autoconversion of arguments. <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { return Convert<typename std::decay<R>::type>::toJniRet( (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...)); } catch (...) { using jniRet = typename Convert<typename std::decay<R>::type>::jniType; translatePendingCppExceptionToJavaException(); return jniRet{}; } } }; </s> add inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { </s> remove // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add JNI_ENTRY_POINT static typename Converter<R>::jniType call( JNIEnv* env, jobject obj, typename Converter<Args>::jniType... args) { return FunctionWrapper<R(*)(alias_ref<jhybrid>, Args&&...), dispatch, jhybrid, R, Args...>::call(env, obj, args...); } }; </s> remove // registration wrapper for legacy JNI-style functions template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, Args... args) { // Note that if func was declared noexcept, then both gcc and clang are smart // enough to elide the try/catch. try { (*func)(env, static_cast<C>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); } } }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add template <typename R> struct CreateDefault { static R create() { return R{}; } }; template <> struct CreateDefault<void> { static void create() {} }; template <typename R> using Converter = Convert<typename std::decay<R>::type>; template <typename F, F func, typename R, typename... Args> struct WrapForVoidReturn { static typename Converter<R>::jniType call(Args&&... args) { return Converter<R>::toJniRet(func(std::forward<Args>(args)...)); } }; template <typename F, F func, typename... Args> struct WrapForVoidReturn<F, func, void, Args...> { static void call(Args&&... args) { func(std::forward<Args>(args)...); } }; </s> remove // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { translatePendingCppExceptionToJavaException(); } } }; </s> add template<typename F, F func, typename C, typename R, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { </s> remove template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (...) { translatePendingCppExceptionToJavaException(); } </s> add // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename R, typename... Args> struct MethodWrapper { using jhybrid = typename C::jhybridobject; static R dispatch(alias_ref<jhybrid> ref, Args&&... args) { try { // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(ref->cthis()); return (cobj->*method)(std::forward<Args>(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Registration-inl.h
keep keep add keep keep keep keep
<mask> }; <mask> <mask> // registration wrappers for functions, with autoconversion of arguments. <mask> <mask> // registration wrappers for non-static methods, with autoconvertion of arguments. <mask> template<typename M, M method, typename C, typename R, typename... Args> <mask> struct MethodWrapper { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); </s> add return reinterpret_cast<NativeMethodWrapper*>(&(BareJniWrapper<F, func, C, R, Args...>::call)); </s> remove template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (...) { translatePendingCppExceptionToJavaException(); } </s> add // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename R, typename... Args> struct MethodWrapper { using jhybrid = typename C::jhybridobject; static R dispatch(alias_ref<jhybrid> ref, Args&&... args) { try { // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(ref->cthis()); return (cobj->*method)(std::forward<Args>(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; </s> remove }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add } }; </s> remove // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { translatePendingCppExceptionToJavaException(); } } }; </s> add template<typename F, F func, typename C, typename R, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { </s> remove inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { return Convert<typename std::decay<R>::type>::toJniRet( (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...)); } catch (...) { using jniRet = typename Convert<typename std::decay<R>::type>::jniType; translatePendingCppExceptionToJavaException(); return jniRet{}; } } }; </s> add inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { </s> remove return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); </s> add return reinterpret_cast<NativeMethodWrapper*>(&(FunctionWrapper<F, func, C, R, Args...>::call));
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Registration-inl.h
keep replace replace replace replace replace replace replace replace replace replace keep replace keep keep
<mask> <mask> template<typename F, F func, typename C, typename... Args> <mask> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(alias_ref<C>, Args... args)) { <mask> struct funcWrapper { <mask> JNI_ENTRY_POINT static void call(JNIEnv*, jobject obj, <mask> typename Convert<typename std::decay<Args>::type>::jniType... args) { <mask> try { <mask> (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...); <mask> } catch (...) { <mask> translatePendingCppExceptionToJavaException(); <mask> } <mask> } <mask> }; <mask> <mask> // This intentionally erases the real type; JNI will do it anyway </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Registration-inl.h
keep replace replace replace keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep
<mask> <mask> // This intentionally erases the real type; JNI will do it anyway <mask> return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); <mask> } <mask> <mask> template<typename F, F func, typename C, typename R, typename... Args> <mask> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { <mask> struct funcWrapper { <mask> <mask> JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv*, jobject obj, <mask> typename Convert<typename std::decay<Args>::type>::jniType... args) { <mask> try { <mask> return Convert<typename std::decay<R>::type>::toJniRet( <mask> (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...)); <mask> } catch (...) { <mask> using jniRet = typename Convert<typename std::decay<R>::type>::jniType; <mask> translatePendingCppExceptionToJavaException(); <mask> return jniRet{}; <mask> } <mask> } <mask> }; <mask> <mask> // This intentionally erases the real type; JNI will do it anyway <mask> return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove struct funcWrapper { JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); return Convert<typename std::decay<R>::type>::toJniRet( (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...)); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { using jniRet = typename Convert<typename std::decay<R>::type>::jniType; translatePendingCppExceptionToJavaException(); return jniRet{}; } } }; </s> add </s> remove // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { translatePendingCppExceptionToJavaException(); } } }; </s> add template<typename F, F func, typename C, typename R, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { </s> remove return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); </s> add return reinterpret_cast<NativeMethodWrapper*>(&(FunctionWrapper<F, func, C, R, Args...>::call)); </s> remove inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { try { return (*func)(env, static_cast<JniType<C>>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); return R{}; } </s> add struct BareJniWrapper { JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { ThreadScope ts(env, internal::CacheEnvTag{}); try { return (*func)(env, static_cast<JniType<C>>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); return CreateDefault<R>::create(); </s> remove template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (...) { translatePendingCppExceptionToJavaException(); } </s> add // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename R, typename... Args> struct MethodWrapper { using jhybrid = typename C::jhybridobject; static R dispatch(alias_ref<jhybrid> ref, Args&&... args) { try { // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(ref->cthis()); return (cobj->*method)(std::forward<Args>(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Registration-inl.h
keep replace keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep
<mask> // This intentionally erases the real type; JNI will do it anyway <mask> return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); <mask> } <mask> <mask> // registration wrappers for non-static methods, with autoconvertion of arguments. <mask> <mask> template<typename M, M method, typename C, typename... Args> <mask> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { <mask> struct funcWrapper { <mask> JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, <mask> typename Convert<typename std::decay<Args>::type>::jniType... args) { <mask> try { <mask> try { <mask> auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); <mask> // This is usually a noop, but if the hybrid object is a <mask> // base class of other classes which register JNI methods, <mask> // this will get the right type for the registered method. <mask> auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); <mask> (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...); <mask> } catch (const std::exception& ex) { <mask> C::mapException(ex); <mask> throw; <mask> } <mask> } catch (...) { <mask> translatePendingCppExceptionToJavaException(); <mask> } <mask> } <mask> }; <mask> <mask> // This intentionally erases the real type; JNI will do it anyway <mask> return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove struct funcWrapper { JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); return Convert<typename std::decay<R>::type>::toJniRet( (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...)); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { using jniRet = typename Convert<typename std::decay<R>::type>::jniType; translatePendingCppExceptionToJavaException(); return jniRet{}; } } }; </s> add </s> remove template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (...) { translatePendingCppExceptionToJavaException(); } </s> add // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename R, typename... Args> struct MethodWrapper { using jhybrid = typename C::jhybridobject; static R dispatch(alias_ref<jhybrid> ref, Args&&... args) { try { // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(ref->cthis()); return (cobj->*method)(std::forward<Args>(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; </s> remove inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { return Convert<typename std::decay<R>::type>::toJniRet( (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...)); } catch (...) { using jniRet = typename Convert<typename std::decay<R>::type>::jniType; translatePendingCppExceptionToJavaException(); return jniRet{}; } } }; </s> add inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { </s> remove return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); </s> add return reinterpret_cast<NativeMethodWrapper*>(&(FunctionWrapper<F, func, C, R, Args...>::call)); </s> remove }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add } };
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Registration-inl.h
keep keep keep replace keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep
<mask> }; <mask> <mask> // This intentionally erases the real type; JNI will do it anyway <mask> return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); <mask> } <mask> <mask> template<typename M, M method, typename C, typename R, typename... Args> <mask> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (C::*method0)(Args... args)) { <mask> struct funcWrapper { <mask> <mask> JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv* env, jobject obj, <mask> typename Convert<typename std::decay<Args>::type>::jniType... args) { <mask> try { <mask> try { <mask> auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); <mask> // This is usually a noop, but if the hybrid object is a <mask> // base class of other classes which register JNI methods, <mask> // this will get the right type for the registered method. <mask> auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); <mask> return Convert<typename std::decay<R>::type>::toJniRet( <mask> (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...)); <mask> } catch (const std::exception& ex) { <mask> C::mapException(ex); <mask> throw; <mask> } <mask> } catch (...) { <mask> using jniRet = typename Convert<typename std::decay<R>::type>::jniType; <mask> translatePendingCppExceptionToJavaException(); <mask> return jniRet{}; <mask> } <mask> } <mask> }; <mask> <mask> // This intentionally erases the real type; JNI will do it anyway <mask> return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); <mask> } <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { translatePendingCppExceptionToJavaException(); } } }; </s> add template<typename F, F func, typename C, typename R, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { </s> remove inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { return Convert<typename std::decay<R>::type>::toJniRet( (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...)); } catch (...) { using jniRet = typename Convert<typename std::decay<R>::type>::jniType; translatePendingCppExceptionToJavaException(); return jniRet{}; } } }; </s> add inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { </s> remove template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (...) { translatePendingCppExceptionToJavaException(); } </s> add // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename R, typename... Args> struct MethodWrapper { using jhybrid = typename C::jhybridobject; static R dispatch(alias_ref<jhybrid> ref, Args&&... args) { try { // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(ref->cthis()); return (cobj->*method)(std::forward<Args>(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; </s> remove // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add JNI_ENTRY_POINT static typename Converter<R>::jniType call( JNIEnv* env, jobject obj, typename Converter<Args>::jniType... args) { return FunctionWrapper<R(*)(alias_ref<jhybrid>, Args&&...), dispatch, jhybrid, R, Args...>::call(env, obj, args...); } }; </s> remove inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { try { return (*func)(env, static_cast<JniType<C>>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); return R{}; } </s> add struct BareJniWrapper { JNI_ENTRY_POINT static R call(JNIEnv* env, jobject obj, Args... args) { ThreadScope ts(env, internal::CacheEnvTag{}); try { return (*func)(env, static_cast<JniType<C>>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); return CreateDefault<R>::create();
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Registration-inl.h
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> }; <mask> <mask> // This intentionally erases the real type; JNI will do it anyway <mask> return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); <mask> } <mask> <mask> template<typename R, typename C, typename... Args> <mask> inline std::string makeDescriptor(R (*)(JNIEnv*, C, Args... args)) { <mask> return jmethod_traits<R(Args...)>::descriptor(); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); </s> add return reinterpret_cast<NativeMethodWrapper*>(&(FunctionWrapper<F, func, C, R, Args...>::call)); </s> remove }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add } }; </s> remove // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add JNI_ENTRY_POINT static typename Converter<R>::jniType call( JNIEnv* env, jobject obj, typename Converter<Args>::jniType... args) { return FunctionWrapper<R(*)(alias_ref<jhybrid>, Args&&...), dispatch, jhybrid, R, Args...>::call(env, obj, args...); } }; </s> remove return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); </s> add return reinterpret_cast<NativeMethodWrapper*>(&(BareJniWrapper<F, func, C, R, Args...>::call)); </s> remove inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static typename Convert<typename std::decay<R>::type>::jniType call(JNIEnv*, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { return Convert<typename std::decay<R>::type>::toJniRet( (*func)(static_cast<JniType<C>>(obj), Convert<typename std::decay<Args>::type>::fromJni(args)...)); } catch (...) { using jniRet = typename Convert<typename std::decay<R>::type>::jniType; translatePendingCppExceptionToJavaException(); return jniRet{}; } } }; </s> add inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(JNIEnv*, C, Args... args)) { </s> remove // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { translatePendingCppExceptionToJavaException(); } } }; </s> add template<typename F, F func, typename C, typename R, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Registration-inl.h
keep keep replace replace replace replace keep keep keep keep replace replace replace replace replace
<mask> // cause a (static member) function to exist with the same signature, <mask> // but with try/catch exception translation. <mask> template<typename F, F func, typename C, typename... Args> <mask> NativeMethodWrapper* exceptionWrapJNIMethod(void (*func0)(JNIEnv*, jobject, Args... args)); <mask> <mask> // Same as above, but for non-void return types. <mask> template<typename F, F func, typename C, typename R, typename... Args> <mask> NativeMethodWrapper* exceptionWrapJNIMethod(R (*func0)(JNIEnv*, jobject, Args... args)); <mask> <mask> // Automatically wrap object argument, and don't take env explicitly. <mask> template<typename F, F func, typename C, typename... Args> <mask> NativeMethodWrapper* exceptionWrapJNIMethod(void (*func0)(alias_ref<C>, Args... args)); <mask> <mask> // Automatically wrap object argument, and don't take env explicitly, <mask> // non-void return type. </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove // Extract C++ instance from object, and invoke given method on it. template<typename M, M method, typename C, typename... Args> NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)); </s> add </s> remove // non-void return type </s> add </s> remove }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add } }; </s> remove // registration wrapper for legacy JNI-style functions template<typename F, F func, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (*)(JNIEnv*, C, Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, Args... args) { // Note that if func was declared noexcept, then both gcc and clang are smart // enough to elide the try/catch. try { (*func)(env, static_cast<C>(obj), args...); } catch (...) { translatePendingCppExceptionToJavaException(); } } }; // This intentionally erases the real type; JNI will do it anyway return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); } </s> add template <typename R> struct CreateDefault { static R create() { return R{}; } }; template <> struct CreateDefault<void> { static void create() {} }; template <typename R> using Converter = Convert<typename std::decay<R>::type>; template <typename F, F func, typename R, typename... Args> struct WrapForVoidReturn { static typename Converter<R>::jniType call(Args&&... args) { return Converter<R>::toJniRet(func(std::forward<Args>(args)...)); } }; template <typename F, F func, typename... Args> struct WrapForVoidReturn<F, func, void, Args...> { static void call(Args&&... args) { func(std::forward<Args>(args)...); } }; </s> remove // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { translatePendingCppExceptionToJavaException(); } } }; </s> add template<typename F, F func, typename C, typename R, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Registration.h
keep keep keep replace replace replace replace keep replace
<mask> template<typename F, F func, typename C, typename R, typename... Args> <mask> NativeMethodWrapper* exceptionWrapJNIMethod(R (*func0)(alias_ref<C>, Args... args)); <mask> <mask> // Extract C++ instance from object, and invoke given method on it. <mask> template<typename M, M method, typename C, typename... Args> <mask> NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)); <mask> <mask> // Extract C++ instance from object, and invoke given method on it, <mask> // non-void return type </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove template<typename F, F func, typename C, typename... Args> NativeMethodWrapper* exceptionWrapJNIMethod(void (*func0)(alias_ref<C>, Args... args)); // Automatically wrap object argument, and don't take env explicitly, // non-void return type. </s> add </s> remove template<typename F, F func, typename C, typename... Args> NativeMethodWrapper* exceptionWrapJNIMethod(void (*func0)(JNIEnv*, jobject, Args... args)); // Same as above, but for non-void return types. </s> add </s> remove return reinterpret_cast<NativeMethodWrapper*>(&(funcWrapper::call)); </s> add return reinterpret_cast<NativeMethodWrapper*>(&(FunctionWrapper<F, func, C, R, Args...>::call)); </s> remove // registration wrappers for non-static methods, with autoconvertion of arguments. template<typename M, M method, typename C, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(void (C::*method0)(Args... args)) { struct funcWrapper { JNI_ENTRY_POINT static void call(JNIEnv* env, jobject obj, typename Convert<typename std::decay<Args>::type>::jniType... args) { try { try { auto aref = wrap_alias(static_cast<typename C::jhybridobject>(obj)); // This is usually a noop, but if the hybrid object is a // base class of other classes which register JNI methods, // this will get the right type for the registered method. auto cobj = static_cast<C*>(facebook::jni::cthis(aref)); (cobj->*method)(Convert<typename std::decay<Args>::type>::fromJni(args)...); } catch (const std::exception& ex) { C::mapException(ex); throw; } } catch (...) { translatePendingCppExceptionToJavaException(); } } }; </s> add template<typename F, F func, typename C, typename R, typename... Args> inline NativeMethodWrapper* exceptionWrapJNIMethod(R (*)(alias_ref<C>, Args... args)) { </s> add template<typename F, F func, typename C, typename R, typename... Args> struct FunctionWrapper { using jniRet = typename Converter<R>::jniType; JNI_ENTRY_POINT static jniRet call(JNIEnv* env, jobject obj, typename Converter<Args>::jniType... args) { ThreadScope ts(env, internal::CacheEnvTag{}); try { return WrapForVoidReturn<F, func, R, JniType<C>, Args...>::call( static_cast<JniType<C>>(obj), Converter<Args>::fromJni(args)...); } catch (...) { translatePendingCppExceptionToJavaException(); return CreateDefault<jniRet>::create(); } } };
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/fb/fbjni/Registration.h
keep keep add keep keep keep keep keep keep
<mask> JStringUtf16Extractor(JNIEnv* env, jstring javaString) <mask> : env_(env) <mask> , javaString_(javaString) <mask> , utf16String_(nullptr) { <mask> if (env_ && javaString_) { <mask> length_ = env_->GetStringLength(javaString_); <mask> utf16String_ = env_->GetStringCritical(javaString_, nullptr); <mask> } <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add length_ = env_->GetStringLength(javaString_); </s> remove auto length = env->GetStringLength(str); return detail::utf16toUTF8(utf16String, length); </s> add return detail::utf16toUTF8(utf16String.chars(), utf16String.length()); </s> remove ThreadScope::ThreadScope() : attachedWithThisScope_(false) { JNIEnv* env = nullptr; if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_EDETACHED) { </s> add ThreadScope::ThreadScope() : ThreadScope(nullptr, internal::CacheEnvTag{}) {} ThreadScope::ThreadScope(JNIEnv* env, internal::CacheEnvTag) : previous_(nullptr), env_(nullptr), attachedWithThisScope_(false) { auto& storage = scopeStorage(); previous_ = storage.get(); storage.reset(this); if (previous_ && previous_->env_) { FBASSERT(!env || env == previous_->env_); env = previous_->env_; } env_ = env; if (env_) { </s> remove auto env = g_env->get(); if (!env) { FBASSERT(g_vm); g_vm->AttachCurrentThread(&env, nullptr); g_env->reset(env); </s> add auto scope = currentScope(); if (scope && scope->env_) { return scope->env_; </s> add local_ref<JThrowable> getJavaExceptionForCppBackTrace(const char* msg) { local_ref<JThrowable> current = msg ? JUnknownCppException::create(msg) : JUnknownCppException::create(); #ifndef FBJNI_NO_EXCEPTION_PTR addCppStacktraceToJavaException(current, nullptr); #endif return current; </s> remove const bool flexBasisOverflows = measureModeMainDim == YGMeasureModeUndefined ? false : totalFlexBasis > availableInnerMainDim; </s> add const bool flexBasisOverflows = measureModeMainDim == YGMeasureModeUndefined ? false : totalOuterFlexBasis > availableInnerMainDim;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/jni/LocalString.h
keep keep keep add keep keep keep keep keep keep
<mask> , javaString_(javaString) <mask> , length_(0) <mask> , utf16String_(nullptr) { <mask> if (env_ && javaString_) { <mask> utf16String_ = env_->GetStringCritical(javaString_, nullptr); <mask> } <mask> } <mask> <mask> ~JStringUtf16Extractor() { <mask> if (utf16String_) { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add , length_(0) </s> remove auto env = g_env->get(); if (!env) { FBASSERT(g_vm); g_vm->AttachCurrentThread(&env, nullptr); g_env->reset(env); </s> add auto scope = currentScope(); if (scope && scope->env_) { return scope->env_; </s> add if (mContentSizeWatcher != null) { mContentSizeWatcher.onLayout(); } </s> add // Root nodes flexShrink should always be 0 if (node->parent == NULL) { return 0.0; } </s> remove ThreadScope::ThreadScope() : attachedWithThisScope_(false) { JNIEnv* env = nullptr; if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_EDETACHED) { </s> add ThreadScope::ThreadScope() : ThreadScope(nullptr, internal::CacheEnvTag{}) {} ThreadScope::ThreadScope(JNIEnv* env, internal::CacheEnvTag) : previous_(nullptr), env_(nullptr), attachedWithThisScope_(false) { auto& storage = scopeStorage(); previous_ = storage.get(); storage.reset(this); if (previous_ && previous_->env_) { FBASSERT(!env || env == previous_->env_); env = previous_->env_; } env_ = env; if (env_) { </s> add local_ref<JThrowable> getJavaExceptionForCppBackTrace(const char* msg) { local_ref<JThrowable> current = msg ? JUnknownCppException::create(msg) : JUnknownCppException::create(); #ifndef FBJNI_NO_EXCEPTION_PTR addCppStacktraceToJavaException(current, nullptr); #endif return current;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/jni/LocalString.h
keep keep keep keep replace keep keep keep keep keep
<mask> env_->ReleaseStringCritical(javaString_, utf16String_); <mask> } <mask> } <mask> <mask> operator const jchar* () const { <mask> return utf16String_; <mask> } <mask> <mask> private: <mask> JNIEnv* env_; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add jsize length_; </s> add String& operator=(String&& other) { if (m_string) { JSC_JSStringRelease(m_context, m_string); } m_context = other.m_context; m_string = other.m_string; other.m_string = nullptr; return *this; } </s> remove class Value; class Context; class JSException : public std::exception { public: explicit JSException(const char* msg) : msg_(msg), stack_("") {} JSException(const char* msg, const char* stack) : msg_(msg), stack_(stack) {} const std::string& getStack() const { return stack_; } virtual const char* what() const noexcept override { return msg_.c_str(); } </s> add #ifndef RN_EXPORT #define RN_EXPORT __attribute__((visibility("default"))) #endif </s> remove const char *YGExperimentalFeatureToString(const YGExperimentalFeature value) { switch (value) { </s> add const char *YGExperimentalFeatureToString(const YGExperimentalFeature value){ switch(value){ </s> remove private: std::string msg_; std::string stack_; }; </s> add class Value; </s> add JSContextRef context() const { return m_context; }
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/jni/LocalString.h
keep keep add keep keep keep keep keep keep
<mask> private: <mask> JNIEnv* env_; <mask> jstring javaString_; <mask> const jchar* utf16String_; <mask> }; <mask> <mask> // The string from JNI is converted to standard UTF-8 if the string contains supplementary <mask> // characters. <mask> FBEXPORT std::string fromJString(JNIEnv* env, jstring str); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove auto length = env->GetStringLength(str); return detail::utf16toUTF8(utf16String, length); </s> add return detail::utf16toUTF8(utf16String.chars(), utf16String.length()); </s> remove operator const jchar* () const { </s> add const jsize length() const { return length_; } const jchar* chars() const { </s> add friend struct Environment; ThreadScope* previous_; // If the JNIEnv* is set, it is guaranteed to be valid at least through the // lifetime of this ThreadScope. The only case where that guarantee can be // made is when there is a java frame in the stack below this. JNIEnv* env_; </s> remove /// Wrapper to provide functionality to jthrowable references class FBEXPORT JThrowable : public JavaClass<JThrowable, JObject, jthrowable> { public: static constexpr const char* kJavaDescriptor = "Ljava/lang/Throwable;"; local_ref<JThrowable> initCause(alias_ref<JThrowable> cause); }; </s> add </s> remove const auto result = env->IsAssignableFrom(self(), other.get()); </s> add // Ths method has behavior compatible with the // java.lang.Class#isAssignableFrom method. The order of the // arguments to the JNI IsAssignableFrom C function is "opposite" // from what some might expect, which makes this code look a little // odd, but it is correct. const auto result = env->IsAssignableFrom(other.get(), self()); </s> add // This constructor is only used internally by fbjni. ThreadScope(JNIEnv*, internal::CacheEnvTag);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/include/jni/LocalString.h
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> return res; <mask> } <mask> <mask> uint8_t* JByteBuffer::getDirectBytes() { <mask> if (!self()) { <mask> throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); <mask> } <mask> void* bytes = Environment::current()->GetDirectBufferAddress(self()); <mask> FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove size_t JByteBuffer::getDirectSize() { </s> add size_t JByteBuffer::getDirectSize() const { </s> remove static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); </s> add detail::BaseHybridClass* result = 0; static bool isHybrid = detail::HybridClassBase::isHybridClassBase(this->getClass()); if (isHybrid) { result = getNativePointer(this); } else { static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } result = getNativePointer(hybridData); </s> remove // I'd like to use dynamic_cast here, but -fno-rtti is the default. T* value = static_cast<T*>(hybridData->getNativePointer()); </s> add </s> remove // Length in bytes of a null-terminated utf8 encoded value </s> add // Length in bytes of a nul-terminated utf8 encoded value </s> remove void HybridData::setNativePointer(std::unique_ptr<BaseHybridClass> new_value) { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* old_value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (new_value) { // Modify should only ever be called once with a non-null // new_value. If this happens again it's a programmer error, so // blow up. FBASSERTMSGF(old_value == 0, "Attempt to set C++ native pointer twice"); } else if (old_value == 0) { return; } // delete on a null pointer is defined to be a noop. delete old_value; // This releases ownership from the unique_ptr, and passes the pointer, and // ownership of it, to HybridData which is managed by the java GC. The // finalizer on hybridData calls resetNative which will delete the object, if // resetNative has not already been called. setFieldValue(pointerField, reinterpret_cast<jlong>(new_value.release())); } BaseHybridClass* HybridData::getNativePointer() { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (!value) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } return value; } </s> add </s> add String& operator=(String&& other) { if (m_string) { JSC_JSStringRelease(m_context, m_string); } m_context = other.m_context; m_string = other.m_string; other.m_string = nullptr; return *this; }
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/ByteBuffer.cpp
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> return static_cast<uint8_t*>(bytes); <mask> } <mask> <mask> size_t JByteBuffer::getDirectSize() { <mask> if (!self()) { <mask> throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); <mask> } <mask> int size = Environment::current()->GetDirectBufferCapacity(self()); <mask> FACEBOOK_JNI_THROW_PENDING_EXCEPTION(); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove uint8_t* JByteBuffer::getDirectBytes() { </s> add uint8_t* JByteBuffer::getDirectBytes() const { </s> remove static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); </s> add detail::BaseHybridClass* result = 0; static bool isHybrid = detail::HybridClassBase::isHybridClassBase(this->getClass()); if (isHybrid) { result = getNativePointer(this); } else { static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } result = getNativePointer(hybridData); </s> add if (!m_string) { return ""; } </s> remove // jthrowable ////////////////////////////////////////////////////////////////////////////////////// inline local_ref<JThrowable> JThrowable::initCause(alias_ref<JThrowable> cause) { static auto meth = javaClassStatic()->getMethod<javaobject(javaobject)>("initCause"); return meth(self(), cause.get()); } </s> add </s> remove // I'd like to use dynamic_cast here, but -fno-rtti is the default. T* value = static_cast<T*>(hybridData->getNativePointer()); </s> add </s> add JSContextRef context() const { return m_context; }
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/ByteBuffer.cpp
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> return static_cast<size_t>(size); <mask> } <mask> <mask> bool JByteBuffer::isDirect() { <mask> static auto meth = javaClassStatic()->getMethod<jboolean()>("isDirect"); <mask> return meth(self()); <mask> } <mask> <mask> }} </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove // jthrowable ////////////////////////////////////////////////////////////////////////////////////// inline local_ref<JThrowable> JThrowable::initCause(alias_ref<JThrowable> cause) { static auto meth = javaClassStatic()->getMethod<javaobject(javaobject)>("initCause"); return meth(self(), cause.get()); } </s> add </s> add struct JVoid : public jni::JavaClass<JVoid> { static auto constexpr kJavaDescriptor = "Ljava/lang/Void;"; }; </s> remove auto env = g_env->get(); if (!env) { FBASSERT(g_vm); g_vm->AttachCurrentThread(&env, nullptr); g_env->reset(env); </s> add auto scope = currentScope(); if (scope && scope->env_) { return scope->env_; </s> remove auto length = env->GetStringLength(str); return detail::utf16toUTF8(utf16String, length); </s> add return detail::utf16toUTF8(utf16String.chars(), utf16String.length()); </s> remove /* static */ void Environment::detachCurrentThread() { auto env = g_env->get(); if (env) { FBASSERT(g_vm); g_vm->DetachCurrentThread(); g_env->reset(); } } </s> add JavaVM* g_vm = nullptr; </s> remove hybridData->setNativePointer(std::move(cxxPart)); </s> add setNativePointer(hybridData, std::move(cxxPart));
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/ByteBuffer.cpp
keep keep replace keep replace keep
<mask> */ <mask> <mask> #include <pthread.h> <mask> #include <fb/log.h> <mask> #include <fb/StaticInitialized.h> <mask> #include <fb/ThreadLocal.h> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add #ifdef USE_LYRA #include <fb/lyra.h> #include <fb/lyra_exceptions.h> #endif </s> remove #include <cxxreact/JsArgumentHelpers.h> </s> add #include "JsArgumentHelpers.h" #include "SystraceSection.h" </s> remove #include <sys/system_properties.h> </s> add # include <fb/Build.h> </s> add #if defined(__ANDROID__) && defined(__ARM_ARCH_5TE__) && !defined(FBJNI_NO_EXCEPTION_PTR) // ARMv5 NDK does not support exception_ptr so we cannot use that when building for it. #define FBJNI_NO_EXCEPTION_PTR #endif </s> remove const char *YGAlignToString(const YGAlign value) { switch (value) { </s> add const char *YGAlignToString(const YGAlign value){ switch(value){
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Environment.cpp
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace keep replace replace replace replace replace replace replace replace replace replace replace replace keep
<mask> namespace facebook { <mask> namespace jni { <mask> <mask> namespace { <mask> StaticInitialized<ThreadLocal<JNIEnv>> g_env; <mask> JavaVM* g_vm = nullptr; <mask> <mask> struct JThreadScopeSupport : JavaClass<JThreadScopeSupport> { <mask> static auto constexpr kJavaDescriptor = "Lcom/facebook/jni/ThreadScopeSupport;"; <mask> <mask> // These reinterpret_casts are a totally dangerous pattern. Don't use them. Use HybridData instead. <mask> static void runStdFunction(std::function<void()>&& func) { <mask> static auto method = javaClassStatic()->getStaticMethod<void(jlong)>("runStdFunction"); <mask> method(javaClassStatic(), reinterpret_cast<jlong>(&func)); <mask> } <mask> <mask> static void runStdFunctionImpl(alias_ref<JClass>, jlong ptr) { <mask> (*reinterpret_cast<std::function<void()>*>(ptr))(); <mask> } <mask> <mask> static void OnLoad() { <mask> // We need the javaClassStatic so that the class lookup is cached and that <mask> // runStdFunction can be called from a ThreadScope-attached thread. <mask> javaClassStatic()->registerNatives({ <mask> makeNativeMethod("runStdFunctionImpl", runStdFunctionImpl), <mask> }); <mask> } <mask> }; <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add namespace internal { struct CacheEnvTag {}; } </s> remove void HybridData::setNativePointer(std::unique_ptr<BaseHybridClass> new_value) { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* old_value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (new_value) { // Modify should only ever be called once with a non-null // new_value. If this happens again it's a programmer error, so // blow up. FBASSERTMSGF(old_value == 0, "Attempt to set C++ native pointer twice"); } else if (old_value == 0) { return; } // delete on a null pointer is defined to be a noop. delete old_value; // This releases ownership from the unique_ptr, and passes the pointer, and // ownership of it, to HybridData which is managed by the java GC. The // finalizer on hybridData calls resetNative which will delete the object, if // resetNative has not already been called. setFieldValue(pointerField, reinterpret_cast<jlong>(new_value.release())); } BaseHybridClass* HybridData::getNativePointer() { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (!value) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } return value; } </s> add </s> remove /* static */ void Environment::detachCurrentThread() { auto env = g_env->get(); if (env) { FBASSERT(g_vm); g_vm->DetachCurrentThread(); g_env->reset(); } } </s> add JavaVM* g_vm = nullptr; </s> remove void setNativePointer(std::unique_ptr<BaseHybridClass> new_value); BaseHybridClass* getNativePointer(); </s> add </s> remove // jthrowable ////////////////////////////////////////////////////////////////////////////////////// inline local_ref<JThrowable> JThrowable::initCause(alias_ref<JThrowable> cause) { static auto meth = javaClassStatic()->getMethod<javaobject(javaobject)>("initCause"); return meth(self(), cause.get()); } </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Environment.cpp
keep replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep replace replace replace replace replace replace replace replace replace keep keep
<mask> <mask> /* static */ <mask> JNIEnv* Environment::current() { <mask> JNIEnv* env = g_env->get(); <mask> if ((env == nullptr) && (g_vm != nullptr)) { <mask> if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK) { <mask> FBLOGE("Error retrieving JNI Environment, thread is probably not attached to JVM"); <mask> // TODO(cjhopman): This should throw an exception. <mask> env = nullptr; <mask> } else { <mask> g_env->reset(env); <mask> } <mask> } <mask> return env; <mask> } <mask> <mask> /* static */ <mask> void Environment::detachCurrentThread() { <mask> auto env = g_env->get(); <mask> if (env) { <mask> FBASSERT(g_vm); <mask> g_vm->DetachCurrentThread(); <mask> g_env->reset(); <mask> } <mask> } <mask> <mask> struct EnvironmentInitializer { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove auto env = g_env->get(); if (!env) { FBASSERT(g_vm); g_vm->AttachCurrentThread(&env, nullptr); g_env->reset(env); </s> add auto scope = currentScope(); if (scope && scope->env_) { return scope->env_; </s> add int getEnv(JNIEnv** env) { FBASSERT(g_vm); // g_vm->GetEnv() might not clear the env* in failure cases. *env = nullptr; return g_vm->GetEnv((void**)env, JNI_VERSION_1_6); } JNIEnv* attachCurrentThread() { JavaVMAttachArgs args{JNI_VERSION_1_6, nullptr, nullptr}; JNIEnv* env = nullptr; auto result = g_vm->AttachCurrentThread(&env, &args); FBASSERT(result == JNI_OK); return env; } } </s> remove env = facebook::jni::Environment::ensureCurrentThreadIsAttached(); FBASSERT(env); </s> add // Check if the thread is attached by someone else. auto result = getEnv(&env); if (result == JNI_OK) { return; } // We don't know how to deal with anything other than JNI_OK or JNI_DETACHED. FBASSERT(result == JNI_EDETACHED); // If there's already a ThreadScope on the stack, then the thread should be attached. FBASSERT(!previous_); attachCurrentThread(); </s> remove ThreadScope::ThreadScope() : attachedWithThisScope_(false) { JNIEnv* env = nullptr; if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_EDETACHED) { </s> add ThreadScope::ThreadScope() : ThreadScope(nullptr, internal::CacheEnvTag{}) {} ThreadScope::ThreadScope(JNIEnv* env, internal::CacheEnvTag) : previous_(nullptr), env_(nullptr), attachedWithThisScope_(false) { auto& storage = scopeStorage(); previous_ = storage.get(); storage.reset(this); if (previous_ && previous_->env_) { FBASSERT(!env || env == previous_->env_); env = previous_->env_; } env_ = env; if (env_) { </s> remove static void runStdFunctionImpl(alias_ref<JClass>, jlong ptr) { (*reinterpret_cast<std::function<void()>*>(ptr))(); } static void OnLoad() { // We need the javaClassStatic so that the class lookup is cached and that // runStdFunction can be called from a ThreadScope-attached thread. javaClassStatic()->registerNatives({ makeNativeMethod("runStdFunctionImpl", runStdFunctionImpl), }); } }; </s> add ThreadLocal<ThreadScope>& scopeStorage() { // We don't want the ThreadLocal to delete the ThreadScopes. static ThreadLocal<ThreadScope> scope([] (void*) {}); return scope;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Environment.cpp
keep keep keep keep replace keep keep keep keep keep
<mask> EnvironmentInitializer(JavaVM* vm) { <mask> FBASSERT(!g_vm); <mask> FBASSERT(vm); <mask> g_vm = vm; <mask> g_env.initialize([] (void*) {}); <mask> } <mask> }; <mask> <mask> /* static */ <mask> void Environment::initialize(JavaVM* vm) { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove /* static */ void Environment::detachCurrentThread() { auto env = g_env->get(); if (env) { FBASSERT(g_vm); g_vm->DetachCurrentThread(); g_env->reset(); } } </s> add JavaVM* g_vm = nullptr; </s> add int getEnv(JNIEnv** env) { FBASSERT(g_vm); // g_vm->GetEnv() might not clear the env* in failure cases. *env = nullptr; return g_vm->GetEnv((void**)env, JNI_VERSION_1_6); } JNIEnv* attachCurrentThread() { JavaVMAttachArgs args{JNI_VERSION_1_6, nullptr, nullptr}; JNIEnv* env = nullptr; auto result = g_vm->AttachCurrentThread(&env, &args); FBASSERT(result == JNI_OK); return env; } } </s> remove static void runStdFunctionImpl(alias_ref<JClass>, jlong ptr) { (*reinterpret_cast<std::function<void()>*>(ptr))(); } static void OnLoad() { // We need the javaClassStatic so that the class lookup is cached and that // runStdFunction can be called from a ThreadScope-attached thread. javaClassStatic()->registerNatives({ makeNativeMethod("runStdFunctionImpl", runStdFunctionImpl), }); } }; </s> add ThreadLocal<ThreadScope>& scopeStorage() { // We don't want the ThreadLocal to delete the ThreadScopes. static ThreadLocal<ThreadScope> scope([] (void*) {}); return scope; </s> remove /* static */ JNIEnv* Environment::current() { JNIEnv* env = g_env->get(); if ((env == nullptr) && (g_vm != nullptr)) { if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK) { FBLOGE("Error retrieving JNI Environment, thread is probably not attached to JVM"); // TODO(cjhopman): This should throw an exception. env = nullptr; } else { g_env->reset(env); } } return env; </s> add ThreadScope* currentScope() { return scopeStorage().get(); </s> remove auto env = g_env->get(); if (!env) { FBASSERT(g_vm); g_vm->AttachCurrentThread(&env, nullptr); g_env->reset(env); </s> add auto scope = currentScope(); if (scope && scope->env_) { return scope->env_; </s> remove StaticInitialized<ThreadLocal<JNIEnv>> g_env; JavaVM* g_vm = nullptr; struct JThreadScopeSupport : JavaClass<JThreadScopeSupport> { static auto constexpr kJavaDescriptor = "Lcom/facebook/jni/ThreadScopeSupport;"; // These reinterpret_casts are a totally dangerous pattern. Don't use them. Use HybridData instead. static void runStdFunction(std::function<void()>&& func) { static auto method = javaClassStatic()->getStaticMethod<void(jlong)>("runStdFunction"); method(javaClassStatic(), reinterpret_cast<jlong>(&func)); } </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Environment.cpp
keep keep keep add keep keep keep keep keep
<mask> g_vm = vm; <mask> } <mask> }; <mask> <mask> /* static */ <mask> void Environment::initialize(JavaVM* vm) { <mask> static EnvironmentInitializer init(vm); <mask> } <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove g_env.initialize([] (void*) {}); </s> add </s> remove /* static */ void Environment::detachCurrentThread() { auto env = g_env->get(); if (env) { FBASSERT(g_vm); g_vm->DetachCurrentThread(); g_env->reset(); } } </s> add JavaVM* g_vm = nullptr; </s> remove /* static */ JNIEnv* Environment::current() { JNIEnv* env = g_env->get(); if ((env == nullptr) && (g_vm != nullptr)) { if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK) { FBLOGE("Error retrieving JNI Environment, thread is probably not attached to JVM"); // TODO(cjhopman): This should throw an exception. env = nullptr; } else { g_env->reset(env); } } return env; </s> add ThreadScope* currentScope() { return scopeStorage().get(); </s> remove static void runStdFunctionImpl(alias_ref<JClass>, jlong ptr) { (*reinterpret_cast<std::function<void()>*>(ptr))(); } static void OnLoad() { // We need the javaClassStatic so that the class lookup is cached and that // runStdFunction can be called from a ThreadScope-attached thread. javaClassStatic()->registerNatives({ makeNativeMethod("runStdFunctionImpl", runStdFunctionImpl), }); } }; </s> add ThreadLocal<ThreadScope>& scopeStorage() { // We don't want the ThreadLocal to delete the ThreadScopes. static ThreadLocal<ThreadScope> scope([] (void*) {}); return scope; </s> remove auto env = g_env->get(); if (!env) { FBASSERT(g_vm); g_vm->AttachCurrentThread(&env, nullptr); g_env->reset(env); </s> add auto scope = currentScope(); if (scope && scope->env_) { return scope->env_; </s> remove StaticInitialized<ThreadLocal<JNIEnv>> g_env; JavaVM* g_vm = nullptr; struct JThreadScopeSupport : JavaClass<JThreadScopeSupport> { static auto constexpr kJavaDescriptor = "Lcom/facebook/jni/ThreadScopeSupport;"; // These reinterpret_casts are a totally dangerous pattern. Don't use them. Use HybridData instead. static void runStdFunction(std::function<void()>&& func) { static auto method = javaClassStatic()->getStaticMethod<void(jlong)>("runStdFunction"); method(javaClassStatic(), reinterpret_cast<jlong>(&func)); } </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Environment.cpp
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
<mask> } <mask> <mask> /* static */ <mask> JNIEnv* Environment::ensureCurrentThreadIsAttached() { <mask> auto env = g_env->get(); <mask> if (!env) { <mask> FBASSERT(g_vm); <mask> g_vm->AttachCurrentThread(&env, nullptr); <mask> g_env->reset(env); <mask> } <mask> return env; <mask> } <mask> <mask> ThreadScope::ThreadScope() </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove /* static */ JNIEnv* Environment::current() { JNIEnv* env = g_env->get(); if ((env == nullptr) && (g_vm != nullptr)) { if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK) { FBLOGE("Error retrieving JNI Environment, thread is probably not attached to JVM"); // TODO(cjhopman): This should throw an exception. env = nullptr; } else { g_env->reset(env); } } return env; </s> add ThreadScope* currentScope() { return scopeStorage().get(); </s> remove /* static */ void Environment::detachCurrentThread() { auto env = g_env->get(); if (env) { FBASSERT(g_vm); g_vm->DetachCurrentThread(); g_env->reset(); } } </s> add JavaVM* g_vm = nullptr; </s> add int getEnv(JNIEnv** env) { FBASSERT(g_vm); // g_vm->GetEnv() might not clear the env* in failure cases. *env = nullptr; return g_vm->GetEnv((void**)env, JNI_VERSION_1_6); } JNIEnv* attachCurrentThread() { JavaVMAttachArgs args{JNI_VERSION_1_6, nullptr, nullptr}; JNIEnv* env = nullptr; auto result = g_vm->AttachCurrentThread(&env, &args); FBASSERT(result == JNI_OK); return env; } } </s> remove ThreadScope::ThreadScope() : attachedWithThisScope_(false) { JNIEnv* env = nullptr; if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_EDETACHED) { </s> add ThreadScope::ThreadScope() : ThreadScope(nullptr, internal::CacheEnvTag{}) {} ThreadScope::ThreadScope(JNIEnv* env, internal::CacheEnvTag) : previous_(nullptr), env_(nullptr), attachedWithThisScope_(false) { auto& storage = scopeStorage(); previous_ = storage.get(); storage.reset(this); if (previous_ && previous_->env_) { FBASSERT(!env || env == previous_->env_); env = previous_->env_; } env_ = env; if (env_) { </s> remove static void runStdFunctionImpl(alias_ref<JClass>, jlong ptr) { (*reinterpret_cast<std::function<void()>*>(ptr))(); } static void OnLoad() { // We need the javaClassStatic so that the class lookup is cached and that // runStdFunction can be called from a ThreadScope-attached thread. javaClassStatic()->registerNatives({ makeNativeMethod("runStdFunctionImpl", runStdFunctionImpl), }); } }; </s> add ThreadLocal<ThreadScope>& scopeStorage() { // We don't want the ThreadLocal to delete the ThreadScopes. static ThreadLocal<ThreadScope> scope([] (void*) {}); return scope; </s> remove auto cls = env->FindClass(name); </s> add local_ref<jclass> cls = adopt_local(env->FindClass(name));
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Environment.cpp
keep keep add keep keep keep keep
<mask> if (scope && scope->env_) { <mask> return scope->env_; <mask> } <mask> return env; <mask> } <mask> <mask> ThreadScope::ThreadScope() : ThreadScope(nullptr, internal::CacheEnvTag{}) {} </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove auto env = g_env->get(); if (!env) { FBASSERT(g_vm); g_vm->AttachCurrentThread(&env, nullptr); g_env->reset(env); </s> add auto scope = currentScope(); if (scope && scope->env_) { return scope->env_; </s> remove ThreadScope::ThreadScope() : attachedWithThisScope_(false) { JNIEnv* env = nullptr; if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_EDETACHED) { </s> add ThreadScope::ThreadScope() : ThreadScope(nullptr, internal::CacheEnvTag{}) {} ThreadScope::ThreadScope(JNIEnv* env, internal::CacheEnvTag) : previous_(nullptr), env_(nullptr), attachedWithThisScope_(false) { auto& storage = scopeStorage(); previous_ = storage.get(); storage.reset(this); if (previous_ && previous_->env_) { FBASSERT(!env || env == previous_->env_); env = previous_->env_; } env_ = env; if (env_) { </s> add // Root nodes flexShrink should always be 0 if (node->parent == NULL) { return 0.0; } </s> remove class Value; class Context; class JSException : public std::exception { public: explicit JSException(const char* msg) : msg_(msg), stack_("") {} JSException(const char* msg, const char* stack) : msg_(msg), stack_(stack) {} const std::string& getStack() const { return stack_; } virtual const char* what() const noexcept override { return msg_.c_str(); } </s> add #ifndef RN_EXPORT #define RN_EXPORT __attribute__((visibility("default"))) #endif </s> remove /* static */ JNIEnv* Environment::current() { JNIEnv* env = g_env->get(); if ((env == nullptr) && (g_vm != nullptr)) { if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK) { FBLOGE("Error retrieving JNI Environment, thread is probably not attached to JVM"); // TODO(cjhopman): This should throw an exception. env = nullptr; } else { g_env->reset(env); } } return env; </s> add ThreadScope* currentScope() { return scopeStorage().get(); </s> remove /* static */ void Environment::detachCurrentThread() { auto env = g_env->get(); if (env) { FBASSERT(g_vm); g_vm->DetachCurrentThread(); g_env->reset(); } } </s> add JavaVM* g_vm = nullptr;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Environment.cpp
keep keep replace replace replace replace keep keep replace replace keep keep keep
<mask> } <mask> <mask> ThreadScope::ThreadScope() <mask> : attachedWithThisScope_(false) { <mask> JNIEnv* env = nullptr; <mask> if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_EDETACHED) { <mask> return; <mask> } <mask> env = facebook::jni::Environment::ensureCurrentThreadIsAttached(); <mask> FBASSERT(env); <mask> attachedWithThisScope_ = true; <mask> } <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove /* static */ JNIEnv* Environment::current() { JNIEnv* env = g_env->get(); if ((env == nullptr) && (g_vm != nullptr)) { if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK) { FBLOGE("Error retrieving JNI Environment, thread is probably not attached to JVM"); // TODO(cjhopman): This should throw an exception. env = nullptr; } else { g_env->reset(env); } } return env; </s> add ThreadScope* currentScope() { return scopeStorage().get(); </s> remove auto env = g_env->get(); if (!env) { FBASSERT(g_vm); g_vm->AttachCurrentThread(&env, nullptr); g_env->reset(env); </s> add auto scope = currentScope(); if (scope && scope->env_) { return scope->env_; </s> add int getEnv(JNIEnv** env) { FBASSERT(g_vm); // g_vm->GetEnv() might not clear the env* in failure cases. *env = nullptr; return g_vm->GetEnv((void**)env, JNI_VERSION_1_6); } JNIEnv* attachCurrentThread() { JavaVMAttachArgs args{JNI_VERSION_1_6, nullptr, nullptr}; JNIEnv* env = nullptr; auto result = g_vm->AttachCurrentThread(&env, &args); FBASSERT(result == JNI_OK); return env; } } </s> add JNIEnv* env; // We should be able to just get the JNIEnv* by just calling // AttachCurrentThread, but the spec is unclear (and using getEnv is probably // generally more reliable). auto result = getEnv(&env); // We don't know how to deal with anything other than JNI_OK or JNI_DETACHED. FBASSERT(result == JNI_OK || result == JNI_EDETACHED); if (result == JNI_EDETACHED) { // The thread should not be detached while a ThreadScope is in the stack. FBASSERT(!scope); env = attachCurrentThread(); } FBASSERT(env); </s> remove /* static */ void Environment::detachCurrentThread() { auto env = g_env->get(); if (env) { FBASSERT(g_vm); g_vm->DetachCurrentThread(); g_env->reset(); } } </s> add JavaVM* g_vm = nullptr;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Environment.cpp
keep add keep keep keep keep
<mask> <mask> ThreadScope::~ThreadScope() { <mask> if (attachedWithThisScope_) { <mask> Environment::detachCurrentThread(); <mask> } <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove env = facebook::jni::Environment::ensureCurrentThreadIsAttached(); FBASSERT(env); </s> add // Check if the thread is attached by someone else. auto result = getEnv(&env); if (result == JNI_OK) { return; } // We don't know how to deal with anything other than JNI_OK or JNI_DETACHED. FBASSERT(result == JNI_EDETACHED); // If there's already a ThreadScope on the stack, then the thread should be attached. FBASSERT(!previous_); attachCurrentThread(); </s> remove FLog.e(ReactConstants.TAG, stackTraceToString(title, details)); </s> add FLog.e(ReactConstants.TAG, JSStackTrace.format(title, details)); </s> remove func(); </s> add current = JUnknownCppException::create(); } if (addCppStack) { addCppStacktraceToJavaException(current, ptr); </s> remove public synchronized void sendMessage(RequestBody message) throws IOException { </s> add public synchronized void sendMessage(String message) throws IOException { if (mWebSocket != null) { mWebSocket.send(message); } else { throw new ClosedChannelException(); } } public synchronized void sendMessage(ByteString message) throws IOException { </s> remove mWebSocket.sendMessage(message); </s> add mWebSocket.send(message); </s> remove public synchronized void onPong(Buffer payload) { } </s> add public synchronized void onMessage(WebSocket webSocket, ByteString bytes) { if (mMessageCallback != null) { mMessageCallback.onMessage(bytes); } }
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Environment.cpp
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> /* static */ <mask> void ThreadScope::WithClassLoader(std::function<void()>&& runnable) { <mask> // TODO(cjhopman): If the classloader is already available in this scope, we <mask> // shouldn't have to jump through java. <mask> ThreadScope ts; <mask> JThreadScopeSupport::runStdFunction(std::move(runnable)); <mask> } <mask> <mask> } } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove // space we've used is all space we need </s> add // space we've used is all space we need. Root node also should be shrunk to minimum </s> add template <typename... Args> static void setCxxInstance(alias_ref<jhybridobject> o, Args&&... args) { setNativePointer(o, std::unique_ptr<T>(new T(std::forward<Args>(args)...))); } </s> remove /* static */ JNIEnv* Environment::current() { JNIEnv* env = g_env->get(); if ((env == nullptr) && (g_vm != nullptr)) { if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK) { FBLOGE("Error retrieving JNI Environment, thread is probably not attached to JVM"); // TODO(cjhopman): This should throw an exception. env = nullptr; } else { g_env->reset(env); } } return env; </s> add ThreadScope* currentScope() { return scopeStorage().get(); </s> remove ThreadScope ts; throwable_.reset(); </s> add try { ThreadScope ts; throwable_.reset(); } catch (...) { FBLOGE("Exception in ~JniException()"); std::terminate(); } </s> remove ThreadScope ts; </s> add </s> add friend struct Environment; ThreadScope* previous_; // If the JNIEnv* is set, it is guaranteed to be valid at least through the // lifetime of this ThreadScope. The only case where that guarantee can be // made is when there is a java frame in the stack below this. JNIEnv* env_;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Environment.cpp
keep keep add keep keep keep keep keep keep
<mask> #include <fb/assert.h> <mask> #include <fb/log.h> <mask> <mask> #include <alloca.h> <mask> #include <cstdlib> <mask> #include <ios> <mask> #include <stdexcept> <mask> #include <stdio.h> <mask> #include <string> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove #include <fb/StaticInitialized.h> </s> add </s> remove #include <pthread.h> </s> add </s> remove #include <cxxreact/JsArgumentHelpers.h> </s> add #include "JsArgumentHelpers.h" #include "SystraceSection.h" </s> remove #include <sys/system_properties.h> </s> add # include <fb/Build.h> </s> add #if defined(__ANDROID__) && defined(__ARM_ARCH_5TE__) && !defined(FBJNI_NO_EXCEPTION_PTR) // ARMv5 NDK does not support exception_ptr so we cannot use that when building for it. #define FBJNI_NO_EXCEPTION_PTR #endif </s> remove const char *YGAlignToString(const YGAlign value) { switch (value) { </s> add const char *YGAlignToString(const YGAlign value){ switch(value){
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> // Functions that throw C++ exceptions <mask> <mask> // TODO(T6618159) Take a stack dump here to save context if it results in a crash when propagated <mask> void throwPendingJniExceptionAsCppException() { <mask> JNIEnv* env = Environment::current(); <mask> if (env->ExceptionCheck() == JNI_FALSE) { <mask> return; <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove env = facebook::jni::Environment::ensureCurrentThreadIsAttached(); FBASSERT(env); </s> add // Check if the thread is attached by someone else. auto result = getEnv(&env); if (result == JNI_OK) { return; } // We don't know how to deal with anything other than JNI_OK or JNI_DETACHED. FBASSERT(result == JNI_EDETACHED); // If there's already a ThreadScope on the stack, then the thread should be attached. FBASSERT(!previous_); attachCurrentThread(); </s> remove /* static */ JNIEnv* Environment::current() { JNIEnv* env = g_env->get(); if ((env == nullptr) && (g_vm != nullptr)) { if (g_vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK) { FBLOGE("Error retrieving JNI Environment, thread is probably not attached to JVM"); // TODO(cjhopman): This should throw an exception. env = nullptr; } else { g_env->reset(env); } } return env; </s> add ThreadScope* currentScope() { return scopeStorage().get(); </s> add friend struct Environment; ThreadScope* previous_; // If the JNIEnv* is set, it is guaranteed to be valid at least through the // lifetime of this ThreadScope. The only case where that guarantee can be // made is when there is a java frame in the stack below this. JNIEnv* env_; </s> remove // If the file name of a stack frame is numeric (+ ".js"), we assume it's a lazily injected module // coming from a "random access bundle". We are using special source maps for these bundles, so // that we can symbolicate stack traces for multiple injected files with a single source map. // We have to include the module id in the stack for that, though. The ".js" suffix is kept to // avoid ambiguities between "module-id:line" and "line:column". private static String stackFrameToModuleId(ReadableMap frame) { if (frame.hasKey("file") && !frame.isNull("file") && frame.getType("file") == ReadableType.String) { final Matcher matcher = mJsModuleIdPattern.matcher(frame.getString("file")); if (matcher.find()) { return matcher.group(1) + ":"; } } return ""; } private String stackTraceToString(String message, ReadableArray stack) { StringBuilder stringBuilder = new StringBuilder(message).append(", stack:\n"); for (int i = 0; i < stack.size(); i++) { ReadableMap frame = stack.getMap(i); stringBuilder.append(frame.getString("methodName")).append("@").append(stackFrameToModuleId(frame)).append(frame.getInt("lineNumber")); if (frame.hasKey("column") && !frame.isNull("column") && frame.getType("column") == ReadableType.Number) { stringBuilder.append(":").append(frame.getInt("column")); } stringBuilder.append("\n"); } return stringBuilder.toString(); } </s> add </s> remove static void runStdFunctionImpl(alias_ref<JClass>, jlong ptr) { (*reinterpret_cast<std::function<void()>*>(ptr))(); } static void OnLoad() { // We need the javaClassStatic so that the class lookup is cached and that // runStdFunction can be called from a ThreadScope-attached thread. javaClassStatic()->registerNatives({ makeNativeMethod("runStdFunctionImpl", runStdFunctionImpl), }); } }; </s> add ThreadLocal<ThreadScope>& scopeStorage() { // We don't want the ThreadLocal to delete the ThreadScopes. static ThreadLocal<ThreadScope> scope([] (void*) {}); return scope; </s> remove void HybridData::setNativePointer(std::unique_ptr<BaseHybridClass> new_value) { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* old_value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (new_value) { // Modify should only ever be called once with a non-null // new_value. If this happens again it's a programmer error, so // blow up. FBASSERTMSGF(old_value == 0, "Attempt to set C++ native pointer twice"); } else if (old_value == 0) { return; } // delete on a null pointer is defined to be a noop. delete old_value; // This releases ownership from the unique_ptr, and passes the pointer, and // ownership of it, to HybridData which is managed by the java GC. The // finalizer on hybridData calls resetNative which will delete the object, if // resetNative has not already been called. setFieldValue(pointerField, reinterpret_cast<jlong>(new_value.release())); } BaseHybridClass* HybridData::getNativePointer() { static auto pointerField = getClass()->getField<jlong>("mNativePointer"); auto* value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); if (!value) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } return value; } </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep keep keep keep replace replace replace replace keep replace keep keep keep
<mask> // Translate C++ to Java Exception <mask> <mask> namespace { <mask> <mask> // The implementation std::rethrow_if_nested uses a dynamic_cast to determine <mask> // if the exception is a nested_exception. If the exception is from a library <mask> // built with -fno-rtti, then that will crash. This avoids that. <mask> void rethrow_if_nested() { <mask> try { <mask> throw; <mask> } catch (const std::nested_exception& e) { <mask> e.rethrow_nested(); <mask> } catch (...) { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove e.rethrow_nested(); </s> add denest(func, e.nested_ptr()); </s> remove // For each exception in the chain of the currently handled exception, func // will be called with that exception as the currently handled exception (in // reverse order, i.e. innermost first). void denest(std::function<void()> func) { </s> add local_ref<JThrowable> convertCppExceptionToJavaException(std::exception_ptr ptr) { FBASSERT(ptr); local_ref<JThrowable> current; bool addCppStack = true; </s> remove throw; } catch (const std::exception& e) { try { rethrow_if_nested(); } catch (...) { denest(func); } func(); </s> add std::rethrow_exception(ptr); addCppStack = false; } catch (const JniException& ex) { current = ex.getThrowable(); } catch (const std::ios_base::failure& ex) { current = JIOException::create(ex.what()); } catch (const std::bad_alloc& ex) { current = JOutOfMemoryError::create(ex.what()); } catch (const std::out_of_range& ex) { current = JArrayIndexOutOfBoundsException::create(ex.what()); } catch (const std::system_error& ex) { current = JCppSystemErrorException::create(ex); } catch (const std::runtime_error& ex) { current = JRuntimeException::create(ex.what()); } catch (const std::exception& ex) { current = JCppException::create(ex.what()); } catch (const char* msg) { current = JUnknownCppException::create(msg); </s> remove messageQueueThread_->runOnQueue([method, params=std::move(params), first, second] () { </s> add messageQueueThread_->runOnQueue([method, params=std::move(params), first, second, callId] () { #ifdef WITH_FBSYSTRACE if (callId != -1) { fbsystrace_end_async_flow(TRACE_TAG_REACT_APPS, "native", callId); } #endif SystraceSection s(method.name.c_str()); </s> remove denest(func); setJavaExceptionAndAbortOnFailure(previous); } catch (std::exception& e) { FBLOGE("unexpected exception in translatePendingCppExceptionToJavaException: %s", e.what()); // rethrow the exception and let the noexcept handling abort. throw; </s> add #ifndef FBJNI_NO_EXCEPTION_PTR auto exc = getJavaExceptionForCppException(std::current_exception()); #else auto exc = JUnknownCppException::create(); #endif setJavaExceptionAndAbortOnFailure(exc);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep keep keep keep replace keep keep keep keep keep
<mask> void rethrow_if_nested() { <mask> try { <mask> throw; <mask> } catch (const std::nested_exception& e) { <mask> e.rethrow_nested(); <mask> } catch (...) { <mask> } <mask> } <mask> <mask> // For each exception in the chain of the currently handled exception, func </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove // For each exception in the chain of the currently handled exception, func // will be called with that exception as the currently handled exception (in // reverse order, i.e. innermost first). void denest(std::function<void()> func) { </s> add local_ref<JThrowable> convertCppExceptionToJavaException(std::exception_ptr ptr) { FBASSERT(ptr); local_ref<JThrowable> current; bool addCppStack = true; </s> remove throw; </s> add std::rethrow_exception(ptr); </s> remove // The implementation std::rethrow_if_nested uses a dynamic_cast to determine // if the exception is a nested_exception. If the exception is from a library // built with -fno-rtti, then that will crash. This avoids that. void rethrow_if_nested() { </s> add // For each exception in the chain of the exception_ptr argument, func // will be called with that exception (in reverse order, i.e. innermost first). #ifndef FBJNI_NO_EXCEPTION_PTR void denest(const std::function<void(std::exception_ptr)>& func, std::exception_ptr ptr) { FBASSERT(ptr); </s> remove throw; } catch (const std::exception& e) { try { rethrow_if_nested(); } catch (...) { denest(func); } func(); </s> add std::rethrow_exception(ptr); addCppStack = false; } catch (const JniException& ex) { current = ex.getThrowable(); } catch (const std::ios_base::failure& ex) { current = JIOException::create(ex.what()); } catch (const std::bad_alloc& ex) { current = JOutOfMemoryError::create(ex.what()); } catch (const std::out_of_range& ex) { current = JArrayIndexOutOfBoundsException::create(ex.what()); } catch (const std::system_error& ex) { current = JCppSystemErrorException::create(ex); } catch (const std::runtime_error& ex) { current = JRuntimeException::create(ex.what()); } catch (const std::exception& ex) { current = JCppException::create(ex.what()); } catch (const char* msg) { current = JUnknownCppException::create(msg); </s> add // ignored. </s> remove denest(func); setJavaExceptionAndAbortOnFailure(previous); } catch (std::exception& e) { FBLOGE("unexpected exception in translatePendingCppExceptionToJavaException: %s", e.what()); // rethrow the exception and let the noexcept handling abort. throw; </s> add #ifndef FBJNI_NO_EXCEPTION_PTR auto exc = getJavaExceptionForCppException(std::current_exception()); #else auto exc = JUnknownCppException::create(); #endif setJavaExceptionAndAbortOnFailure(exc);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep keep add keep keep keep keep keep
<mask> } catch (const std::nested_exception& e) { <mask> denest(func, e.nested_ptr()); <mask> } catch (...) { <mask> } <mask> func(ptr); <mask> } <mask> #endif <mask> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove e.rethrow_nested(); </s> add denest(func, e.nested_ptr()); </s> remove throw; } catch (const std::exception& e) { try { rethrow_if_nested(); } catch (...) { denest(func); } func(); </s> add std::rethrow_exception(ptr); addCppStack = false; } catch (const JniException& ex) { current = ex.getThrowable(); } catch (const std::ios_base::failure& ex) { current = JIOException::create(ex.what()); } catch (const std::bad_alloc& ex) { current = JOutOfMemoryError::create(ex.what()); } catch (const std::out_of_range& ex) { current = JArrayIndexOutOfBoundsException::create(ex.what()); } catch (const std::system_error& ex) { current = JCppSystemErrorException::create(ex); } catch (const std::runtime_error& ex) { current = JRuntimeException::create(ex.what()); } catch (const std::exception& ex) { current = JCppException::create(ex.what()); } catch (const char* msg) { current = JUnknownCppException::create(msg); </s> remove throw; </s> add std::rethrow_exception(ptr); </s> remove denest(func); setJavaExceptionAndAbortOnFailure(previous); } catch (std::exception& e) { FBLOGE("unexpected exception in translatePendingCppExceptionToJavaException: %s", e.what()); // rethrow the exception and let the noexcept handling abort. throw; </s> add #ifndef FBJNI_NO_EXCEPTION_PTR auto exc = getJavaExceptionForCppException(std::current_exception()); #else auto exc = JUnknownCppException::create(); #endif setJavaExceptionAndAbortOnFailure(exc); </s> remove // For each exception in the chain of the currently handled exception, func // will be called with that exception as the currently handled exception (in // reverse order, i.e. innermost first). void denest(std::function<void()> func) { </s> add local_ref<JThrowable> convertCppExceptionToJavaException(std::exception_ptr ptr) { FBASSERT(ptr); local_ref<JThrowable> current; bool addCppStack = true; </s> remove mWebSocket.sendMessage(RequestBody.create(WebSocket.TEXT, message)); } catch (IOException e) { </s> add mWebSocket.send(message); } catch (Exception e) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep keep replace replace replace replace keep replace replace replace replace replace replace replace replace keep keep keep keep
<mask> } <mask> <mask> // For each exception in the chain of the currently handled exception, func <mask> // will be called with that exception as the currently handled exception (in <mask> // reverse order, i.e. innermost first). <mask> void denest(std::function<void()> func) { <mask> try { <mask> throw; <mask> } catch (const std::exception& e) { <mask> try { <mask> rethrow_if_nested(); <mask> } catch (...) { <mask> denest(func); <mask> } <mask> func(); <mask> } catch (...) { <mask> func(); <mask> } <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove e.rethrow_nested(); </s> add denest(func, e.nested_ptr()); </s> remove // The implementation std::rethrow_if_nested uses a dynamic_cast to determine // if the exception is a nested_exception. If the exception is from a library // built with -fno-rtti, then that will crash. This avoids that. void rethrow_if_nested() { </s> add // For each exception in the chain of the exception_ptr argument, func // will be called with that exception (in reverse order, i.e. innermost first). #ifndef FBJNI_NO_EXCEPTION_PTR void denest(const std::function<void(std::exception_ptr)>& func, std::exception_ptr ptr) { FBASSERT(ptr); </s> remove throw; </s> add std::rethrow_exception(ptr); </s> remove denest(func); setJavaExceptionAndAbortOnFailure(previous); } catch (std::exception& e) { FBLOGE("unexpected exception in translatePendingCppExceptionToJavaException: %s", e.what()); // rethrow the exception and let the noexcept handling abort. throw; </s> add #ifndef FBJNI_NO_EXCEPTION_PTR auto exc = getJavaExceptionForCppException(std::current_exception()); #else auto exc = JUnknownCppException::create(); #endif setJavaExceptionAndAbortOnFailure(exc); </s> remove func(); </s> add current = JUnknownCppException::create(); } if (addCppStack) { addCppStacktraceToJavaException(current, ptr);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep keep keep keep replace keep keep keep keep keep
<mask> denest(func); <mask> } <mask> func(); <mask> } catch (...) { <mask> func(); <mask> } <mask> } <mask> } <mask> <mask> void translatePendingCppExceptionToJavaException() noexcept { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove throw; } catch (const std::exception& e) { try { rethrow_if_nested(); } catch (...) { denest(func); } func(); </s> add std::rethrow_exception(ptr); addCppStack = false; } catch (const JniException& ex) { current = ex.getThrowable(); } catch (const std::ios_base::failure& ex) { current = JIOException::create(ex.what()); } catch (const std::bad_alloc& ex) { current = JOutOfMemoryError::create(ex.what()); } catch (const std::out_of_range& ex) { current = JArrayIndexOutOfBoundsException::create(ex.what()); } catch (const std::system_error& ex) { current = JCppSystemErrorException::create(ex); } catch (const std::runtime_error& ex) { current = JRuntimeException::create(ex.what()); } catch (const std::exception& ex) { current = JCppException::create(ex.what()); } catch (const char* msg) { current = JUnknownCppException::create(msg); </s> remove denest(func); setJavaExceptionAndAbortOnFailure(previous); } catch (std::exception& e) { FBLOGE("unexpected exception in translatePendingCppExceptionToJavaException: %s", e.what()); // rethrow the exception and let the noexcept handling abort. throw; </s> add #ifndef FBJNI_NO_EXCEPTION_PTR auto exc = getJavaExceptionForCppException(std::current_exception()); #else auto exc = JUnknownCppException::create(); #endif setJavaExceptionAndAbortOnFailure(exc); </s> remove ThreadScope ts; throwable_.reset(); </s> add try { ThreadScope ts; throwable_.reset(); } catch (...) { FBLOGE("Exception in ~JniException()"); std::terminate(); } </s> remove void translatePendingCppExceptionToJavaException() noexcept { </s> add #ifndef FBJNI_NO_EXCEPTION_PTR local_ref<JThrowable> getJavaExceptionForCppException(std::exception_ptr ptr) { FBASSERT(ptr); </s> add // ignored. </s> remove e.rethrow_nested(); </s> add denest(func, e.nested_ptr());
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep add keep keep keep keep keep
<mask> addCppStacktraceToJavaException(current, ptr); <mask> } <mask> } <mask> <mask> local_ref<JThrowable> getJavaExceptionForCppBackTrace(const char* msg) { <mask> local_ref<JThrowable> current = <mask> msg ? JUnknownCppException::create(msg) : JUnknownCppException::create(); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add local_ref<JThrowable> getJavaExceptionForCppBackTrace(const char* msg) { local_ref<JThrowable> current = msg ? JUnknownCppException::create(msg) : JUnknownCppException::create(); #ifndef FBJNI_NO_EXCEPTION_PTR addCppStacktraceToJavaException(current, nullptr); #endif return current; </s> remove auto func = [&previous] () { local_ref<JThrowable> current; try { throw; } catch(const JniException& ex) { current = ex.getThrowable(); } catch(const std::ios_base::failure& ex) { current = JIOException::create(ex.what()); } catch(const std::bad_alloc& ex) { current = JOutOfMemoryError::create(ex.what()); } catch(const std::out_of_range& ex) { current = JArrayIndexOutOfBoundsException::create(ex.what()); } catch(const std::system_error& ex) { current = JCppSystemErrorException::create(ex); } catch(const std::runtime_error& ex) { current = JRuntimeException::create(ex.what()); } catch(const std::exception& ex) { current = JCppException::create(ex.what()); } catch(const char* msg) { current = JUnknownCppException::create(msg); } catch(...) { current = JUnknownCppException::create(); } </s> add auto func = [&previous] (std::exception_ptr ptr) { auto current = convertCppExceptionToJavaException(ptr); </s> remove func(); </s> add current = JUnknownCppException::create(); } if (addCppStack) { addCppStacktraceToJavaException(current, ptr); </s> add FBEXPORT local_ref<JThrowable> getJavaExceptionForCppBackTrace(const char* msg); </s> remove void translatePendingCppExceptionToJavaException() noexcept { </s> add #ifndef FBJNI_NO_EXCEPTION_PTR local_ref<JThrowable> getJavaExceptionForCppException(std::exception_ptr ptr) { FBASSERT(ptr); </s> remove throw; } catch (const std::exception& e) { try { rethrow_if_nested(); } catch (...) { denest(func); } func(); </s> add std::rethrow_exception(ptr); addCppStack = false; } catch (const JniException& ex) { current = ex.getThrowable(); } catch (const std::ios_base::failure& ex) { current = JIOException::create(ex.what()); } catch (const std::bad_alloc& ex) { current = JOutOfMemoryError::create(ex.what()); } catch (const std::out_of_range& ex) { current = JArrayIndexOutOfBoundsException::create(ex.what()); } catch (const std::system_error& ex) { current = JCppSystemErrorException::create(ex); } catch (const std::runtime_error& ex) { current = JRuntimeException::create(ex.what()); } catch (const std::exception& ex) { current = JCppException::create(ex.what()); } catch (const char* msg) { current = JUnknownCppException::create(msg);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep keep add keep keep keep keep
<mask> local_ref<JThrowable> getJavaExceptionForCppBackTrace() { <mask> return getJavaExceptionForCppBackTrace(nullptr); <mask> } <mask> } <mask> <mask> <mask> #ifndef FBJNI_NO_EXCEPTION_PTR </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add return current; } #endif local_ref<JThrowable> getJavaExceptionForCppBackTrace() { return getJavaExceptionForCppBackTrace(nullptr); </s> remove void translatePendingCppExceptionToJavaException() noexcept { </s> add #ifndef FBJNI_NO_EXCEPTION_PTR local_ref<JThrowable> getJavaExceptionForCppException(std::exception_ptr ptr) { FBASSERT(ptr); </s> add denest(func, ptr); return previous; } #endif </s> add void translatePendingCppExceptionToJavaException() { </s> remove denest(func); setJavaExceptionAndAbortOnFailure(previous); } catch (std::exception& e) { FBLOGE("unexpected exception in translatePendingCppExceptionToJavaException: %s", e.what()); // rethrow the exception and let the noexcept handling abort. throw; </s> add #ifndef FBJNI_NO_EXCEPTION_PTR auto exc = getJavaExceptionForCppException(std::current_exception()); #else auto exc = JUnknownCppException::create(); #endif setJavaExceptionAndAbortOnFailure(exc); </s> remove ThreadScope ts; throwable_.reset(); </s> add try { ThreadScope ts; throwable_.reset(); } catch (...) { FBLOGE("Exception in ~JniException()"); std::terminate(); }
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep keep replace keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep
<mask> } <mask> <mask> void translatePendingCppExceptionToJavaException() noexcept { <mask> local_ref<JThrowable> previous; <mask> auto func = [&previous] () { <mask> local_ref<JThrowable> current; <mask> try { <mask> throw; <mask> } catch(const JniException& ex) { <mask> current = ex.getThrowable(); <mask> } catch(const std::ios_base::failure& ex) { <mask> current = JIOException::create(ex.what()); <mask> } catch(const std::bad_alloc& ex) { <mask> current = JOutOfMemoryError::create(ex.what()); <mask> } catch(const std::out_of_range& ex) { <mask> current = JArrayIndexOutOfBoundsException::create(ex.what()); <mask> } catch(const std::system_error& ex) { <mask> current = JCppSystemErrorException::create(ex); <mask> } catch(const std::runtime_error& ex) { <mask> current = JRuntimeException::create(ex.what()); <mask> } catch(const std::exception& ex) { <mask> current = JCppException::create(ex.what()); <mask> } catch(const char* msg) { <mask> current = JUnknownCppException::create(msg); <mask> } catch(...) { <mask> current = JUnknownCppException::create(); <mask> } <mask> if (previous) { <mask> current->initCause(previous); <mask> } <mask> previous = current; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove throw; } catch (const std::exception& e) { try { rethrow_if_nested(); } catch (...) { denest(func); } func(); </s> add std::rethrow_exception(ptr); addCppStack = false; } catch (const JniException& ex) { current = ex.getThrowable(); } catch (const std::ios_base::failure& ex) { current = JIOException::create(ex.what()); } catch (const std::bad_alloc& ex) { current = JOutOfMemoryError::create(ex.what()); } catch (const std::out_of_range& ex) { current = JArrayIndexOutOfBoundsException::create(ex.what()); } catch (const std::system_error& ex) { current = JCppSystemErrorException::create(ex); } catch (const std::runtime_error& ex) { current = JRuntimeException::create(ex.what()); } catch (const std::exception& ex) { current = JCppException::create(ex.what()); } catch (const char* msg) { current = JUnknownCppException::create(msg); </s> add return current; } #endif local_ref<JThrowable> getJavaExceptionForCppBackTrace() { return getJavaExceptionForCppBackTrace(nullptr); </s> add local_ref<JThrowable> getJavaExceptionForCppBackTrace(const char* msg) { local_ref<JThrowable> current = msg ? JUnknownCppException::create(msg) : JUnknownCppException::create(); #ifndef FBJNI_NO_EXCEPTION_PTR addCppStacktraceToJavaException(current, nullptr); #endif return current; </s> remove func(); </s> add current = JUnknownCppException::create(); } if (addCppStack) { addCppStacktraceToJavaException(current, ptr); </s> add denest(func, ptr); return previous; } #endif
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep add keep keep keep keep
<mask> previous = current; <mask> }; <mask> <mask> void translatePendingCppExceptionToJavaException() { <mask> try { <mask> #ifndef FBJNI_NO_EXCEPTION_PTR </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove void translatePendingCppExceptionToJavaException() noexcept { </s> add #ifndef FBJNI_NO_EXCEPTION_PTR local_ref<JThrowable> getJavaExceptionForCppException(std::exception_ptr ptr) { FBASSERT(ptr); </s> add void translatePendingCppExceptionToJavaException() { </s> remove denest(func); setJavaExceptionAndAbortOnFailure(previous); } catch (std::exception& e) { FBLOGE("unexpected exception in translatePendingCppExceptionToJavaException: %s", e.what()); // rethrow the exception and let the noexcept handling abort. throw; </s> add #ifndef FBJNI_NO_EXCEPTION_PTR auto exc = getJavaExceptionForCppException(std::current_exception()); #else auto exc = JUnknownCppException::create(); #endif setJavaExceptionAndAbortOnFailure(exc); </s> add local_ref<JThrowable> getJavaExceptionForCppBackTrace(const char* msg) { local_ref<JThrowable> current = msg ? JUnknownCppException::create(msg) : JUnknownCppException::create(); #ifndef FBJNI_NO_EXCEPTION_PTR addCppStacktraceToJavaException(current, nullptr); #endif return current; </s> remove auto func = [&previous] () { local_ref<JThrowable> current; try { throw; } catch(const JniException& ex) { current = ex.getThrowable(); } catch(const std::ios_base::failure& ex) { current = JIOException::create(ex.what()); } catch(const std::bad_alloc& ex) { current = JOutOfMemoryError::create(ex.what()); } catch(const std::out_of_range& ex) { current = JArrayIndexOutOfBoundsException::create(ex.what()); } catch(const std::system_error& ex) { current = JCppSystemErrorException::create(ex); } catch(const std::runtime_error& ex) { current = JRuntimeException::create(ex.what()); } catch(const std::exception& ex) { current = JCppException::create(ex.what()); } catch(const char* msg) { current = JUnknownCppException::create(msg); } catch(...) { current = JUnknownCppException::create(); } </s> add auto func = [&previous] (std::exception_ptr ptr) { auto current = convertCppExceptionToJavaException(ptr); </s> remove func(); </s> add current = JUnknownCppException::create(); } if (addCppStack) { addCppStacktraceToJavaException(current, ptr);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep add keep keep keep keep
<mask> #endif <mask> <mask> try { <mask> #ifndef FBJNI_NO_EXCEPTION_PTR <mask> auto exc = getJavaExceptionForCppException(std::current_exception()); <mask> #else </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove denest(func); setJavaExceptionAndAbortOnFailure(previous); } catch (std::exception& e) { FBLOGE("unexpected exception in translatePendingCppExceptionToJavaException: %s", e.what()); // rethrow the exception and let the noexcept handling abort. throw; </s> add #ifndef FBJNI_NO_EXCEPTION_PTR auto exc = getJavaExceptionForCppException(std::current_exception()); #else auto exc = JUnknownCppException::create(); #endif setJavaExceptionAndAbortOnFailure(exc); </s> add denest(func, ptr); return previous; } #endif </s> add local_ref<JThrowable> getJavaExceptionForCppBackTrace(const char* msg) { local_ref<JThrowable> current = msg ? JUnknownCppException::create(msg) : JUnknownCppException::create(); #ifndef FBJNI_NO_EXCEPTION_PTR addCppStacktraceToJavaException(current, nullptr); #endif return current; </s> remove void translatePendingCppExceptionToJavaException() noexcept { </s> add #ifndef FBJNI_NO_EXCEPTION_PTR local_ref<JThrowable> getJavaExceptionForCppException(std::exception_ptr ptr) { FBASSERT(ptr); </s> add #ifdef FBJNI_DEBUG_REFS ++internal::g_reference_stats.globals_created; #endif </s> add #ifdef FBJNI_DEBUG_REFS ++internal::g_reference_stats.weaks_created; #endif
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep replace replace replace replace replace replace keep replace replace
<mask> try { <mask> denest(func); <mask> setJavaExceptionAndAbortOnFailure(previous); <mask> } catch (std::exception& e) { <mask> FBLOGE("unexpected exception in translatePendingCppExceptionToJavaException: %s", e.what()); <mask> // rethrow the exception and let the noexcept handling abort. <mask> throw; <mask> } catch (...) { <mask> FBLOGE("unexpected exception in translatePendingCppExceptionToJavaException"); <mask> throw; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove e.rethrow_nested(); </s> add denest(func, e.nested_ptr()); </s> remove // For each exception in the chain of the currently handled exception, func // will be called with that exception as the currently handled exception (in // reverse order, i.e. innermost first). void denest(std::function<void()> func) { </s> add local_ref<JThrowable> convertCppExceptionToJavaException(std::exception_ptr ptr) { FBASSERT(ptr); local_ref<JThrowable> current; bool addCppStack = true; </s> remove throw; </s> add std::rethrow_exception(ptr); </s> remove // The implementation std::rethrow_if_nested uses a dynamic_cast to determine // if the exception is a nested_exception. If the exception is from a library // built with -fno-rtti, then that will crash. This avoids that. void rethrow_if_nested() { </s> add // For each exception in the chain of the exception_ptr argument, func // will be called with that exception (in reverse order, i.e. innermost first). #ifndef FBJNI_NO_EXCEPTION_PTR void denest(const std::function<void(std::exception_ptr)>& func, std::exception_ptr ptr) { FBASSERT(ptr); </s> remove throw; } catch (const std::exception& e) { try { rethrow_if_nested(); } catch (...) { denest(func); } func(); </s> add std::rethrow_exception(ptr); addCppStack = false; } catch (const JniException& ex) { current = ex.getThrowable(); } catch (const std::ios_base::failure& ex) { current = JIOException::create(ex.what()); } catch (const std::bad_alloc& ex) { current = JOutOfMemoryError::create(ex.what()); } catch (const std::out_of_range& ex) { current = JArrayIndexOutOfBoundsException::create(ex.what()); } catch (const std::system_error& ex) { current = JCppSystemErrorException::create(ex); } catch (const std::runtime_error& ex) { current = JRuntimeException::create(ex.what()); } catch (const std::exception& ex) { current = JCppException::create(ex.what()); } catch (const char* msg) { current = JUnknownCppException::create(msg);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep keep keep keep replace replace keep keep keep keep keep
<mask> throwable_ = make_global(rhs.throwable_); <mask> } <mask> <mask> JniException::~JniException() { <mask> ThreadScope ts; <mask> throwable_.reset(); <mask> } <mask> <mask> local_ref<JThrowable> JniException::getThrowable() const noexcept { <mask> return make_local(throwable_); <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add ThreadScope ts; </s> remove ThreadScope ts; </s> add </s> remove void translatePendingCppExceptionToJavaException() noexcept { </s> add #ifndef FBJNI_NO_EXCEPTION_PTR local_ref<JThrowable> getJavaExceptionForCppException(std::exception_ptr ptr) { FBASSERT(ptr); </s> remove // jthrowable ////////////////////////////////////////////////////////////////////////////////////// inline local_ref<JThrowable> JThrowable::initCause(alias_ref<JThrowable> cause) { static auto meth = javaClassStatic()->getMethod<javaobject(javaobject)>("initCause"); return meth(self(), cause.get()); } </s> add </s> add return current; } #endif local_ref<JThrowable> getJavaExceptionForCppBackTrace() { return getJavaExceptionForCppBackTrace(nullptr); </s> remove auto func = [&previous] () { local_ref<JThrowable> current; try { throw; } catch(const JniException& ex) { current = ex.getThrowable(); } catch(const std::ios_base::failure& ex) { current = JIOException::create(ex.what()); } catch(const std::bad_alloc& ex) { current = JOutOfMemoryError::create(ex.what()); } catch(const std::out_of_range& ex) { current = JArrayIndexOutOfBoundsException::create(ex.what()); } catch(const std::system_error& ex) { current = JCppSystemErrorException::create(ex); } catch(const std::runtime_error& ex) { current = JRuntimeException::create(ex.what()); } catch(const std::exception& ex) { current = JCppException::create(ex.what()); } catch(const char* msg) { current = JUnknownCppException::create(msg); } catch(...) { current = JUnknownCppException::create(); } </s> add auto func = [&previous] (std::exception_ptr ptr) { auto current = convertCppExceptionToJavaException(ptr);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep keep keep keep replace keep keep keep keep keep
<mask> } <mask> <mask> // TODO 6900503: consider making this thread-safe. <mask> void JniException::populateWhat() const noexcept { <mask> ThreadScope ts; <mask> try { <mask> what_ = throwable_->toString(); <mask> isMessageExtracted_ = true; <mask> } catch(...) { <mask> what_ = kExceptionMessageFailure_; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add ThreadScope ts; </s> remove ThreadScope ts; throwable_.reset(); </s> add try { ThreadScope ts; throwable_.reset(); } catch (...) { FBLOGE("Exception in ~JniException()"); std::terminate(); } </s> remove auto func = [&previous] () { local_ref<JThrowable> current; try { throw; } catch(const JniException& ex) { current = ex.getThrowable(); } catch(const std::ios_base::failure& ex) { current = JIOException::create(ex.what()); } catch(const std::bad_alloc& ex) { current = JOutOfMemoryError::create(ex.what()); } catch(const std::out_of_range& ex) { current = JArrayIndexOutOfBoundsException::create(ex.what()); } catch(const std::system_error& ex) { current = JCppSystemErrorException::create(ex); } catch(const std::runtime_error& ex) { current = JRuntimeException::create(ex.what()); } catch(const std::exception& ex) { current = JCppException::create(ex.what()); } catch(const char* msg) { current = JUnknownCppException::create(msg); } catch(...) { current = JUnknownCppException::create(); } </s> add auto func = [&previous] (std::exception_ptr ptr) { auto current = convertCppExceptionToJavaException(ptr); </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove void translatePendingCppExceptionToJavaException() noexcept { </s> add #ifndef FBJNI_NO_EXCEPTION_PTR local_ref<JThrowable> getJavaExceptionForCppException(std::exception_ptr ptr) { FBASSERT(ptr); </s> remove // jthrowable ////////////////////////////////////////////////////////////////////////////////////// inline local_ref<JThrowable> JThrowable::initCause(alias_ref<JThrowable> cause) { static auto meth = javaClassStatic()->getMethod<javaobject(javaobject)>("initCause"); return meth(self(), cause.get()); } </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep add keep keep keep keep
<mask> void JniException::populateWhat() const noexcept { <mask> try { <mask> what_ = throwable_->toString(); <mask> isMessageExtracted_ = true; <mask> } catch(...) { <mask> what_ = kExceptionMessageFailure_; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove ThreadScope ts; </s> add </s> remove auto func = [&previous] () { local_ref<JThrowable> current; try { throw; } catch(const JniException& ex) { current = ex.getThrowable(); } catch(const std::ios_base::failure& ex) { current = JIOException::create(ex.what()); } catch(const std::bad_alloc& ex) { current = JOutOfMemoryError::create(ex.what()); } catch(const std::out_of_range& ex) { current = JArrayIndexOutOfBoundsException::create(ex.what()); } catch(const std::system_error& ex) { current = JCppSystemErrorException::create(ex); } catch(const std::runtime_error& ex) { current = JRuntimeException::create(ex.what()); } catch(const std::exception& ex) { current = JCppException::create(ex.what()); } catch(const char* msg) { current = JUnknownCppException::create(msg); } catch(...) { current = JUnknownCppException::create(); } </s> add auto func = [&previous] (std::exception_ptr ptr) { auto current = convertCppExceptionToJavaException(ptr); </s> remove ThreadScope ts; throwable_.reset(); </s> add try { ThreadScope ts; throwable_.reset(); } catch (...) { FBLOGE("Exception in ~JniException()"); std::terminate(); } </s> remove } catch (IOException e) { </s> add } catch (Exception e) { </s> remove void translatePendingCppExceptionToJavaException() noexcept { </s> add #ifndef FBJNI_NO_EXCEPTION_PTR local_ref<JThrowable> getJavaExceptionForCppException(std::exception_ptr ptr) { FBASSERT(ptr); </s> remove // jthrowable ////////////////////////////////////////////////////////////////////////////////////// inline local_ref<JThrowable> JThrowable::initCause(alias_ref<JThrowable> cause) { static auto meth = javaClassStatic()->getMethod<javaobject(javaobject)>("initCause"); return meth(self(), cause.get()); } </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Exceptions.cpp
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> namespace jni { <mask> <mask> namespace detail { <mask> <mask> void HybridData::setNativePointer(std::unique_ptr<BaseHybridClass> new_value) { <mask> static auto pointerField = getClass()->getField<jlong>("mNativePointer"); <mask> auto* old_value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); <mask> if (new_value) { <mask> // Modify should only ever be called once with a non-null <mask> // new_value. If this happens again it's a programmer error, so <mask> // blow up. <mask> FBASSERTMSGF(old_value == 0, "Attempt to set C++ native pointer twice"); <mask> } else if (old_value == 0) { <mask> return; <mask> } <mask> // delete on a null pointer is defined to be a noop. <mask> delete old_value; <mask> // This releases ownership from the unique_ptr, and passes the pointer, and <mask> // ownership of it, to HybridData which is managed by the java GC. The <mask> // finalizer on hybridData calls resetNative which will delete the object, if <mask> // resetNative has not already been called. <mask> setFieldValue(pointerField, reinterpret_cast<jlong>(new_value.release())); <mask> } <mask> <mask> BaseHybridClass* HybridData::getNativePointer() { <mask> static auto pointerField = getClass()->getField<jlong>("mNativePointer"); <mask> auto* value = reinterpret_cast<BaseHybridClass*>(getFieldValue(pointerField)); <mask> if (!value) { <mask> throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); <mask> } <mask> return value; <mask> } <mask> <mask> local_ref<HybridData> HybridData::create() { <mask> return newInstance(); <mask> } <mask> <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove static void runStdFunctionImpl(alias_ref<JClass>, jlong ptr) { (*reinterpret_cast<std::function<void()>*>(ptr))(); } static void OnLoad() { // We need the javaClassStatic so that the class lookup is cached and that // runStdFunction can be called from a ThreadScope-attached thread. javaClassStatic()->registerNatives({ makeNativeMethod("runStdFunctionImpl", runStdFunctionImpl), }); } }; </s> add ThreadLocal<ThreadScope>& scopeStorage() { // We don't want the ThreadLocal to delete the ThreadScopes. static ThreadLocal<ThreadScope> scope([] (void*) {}); return scope; </s> remove env = facebook::jni::Environment::ensureCurrentThreadIsAttached(); FBASSERT(env); </s> add // Check if the thread is attached by someone else. auto result = getEnv(&env); if (result == JNI_OK) { return; } // We don't know how to deal with anything other than JNI_OK or JNI_DETACHED. FBASSERT(result == JNI_EDETACHED); // If there's already a ThreadScope on the stack, then the thread should be attached. FBASSERT(!previous_); attachCurrentThread(); </s> remove static jniType toJniRet(global_ref<jniType> t) { </s> add static jniType toJniRet(global_ref<jniType>&& t) { // If this gets called, ownership the global_ref was passed in here. (It's // probably a copy of a persistent global_ref made when a function was // declared to return a global_ref, but it could moved out or otherwise not // referenced elsewhere. Doesn't matter.) Either way, the only safe way // to return it is to make a local_ref, release it, and return the // underlying local jobject. auto ret = make_local(t); return ret.release(); } static jniType toJniRet(const global_ref<jniType>& t) { // If this gets called, the function was declared to return const&. We // have a ref to a global_ref whose lifetime will exceed this call, so we // can just get the underlying jobject and return it to java without // needing to make a local_ref. </s> remove // The implementation std::rethrow_if_nested uses a dynamic_cast to determine // if the exception is a nested_exception. If the exception is from a library // built with -fno-rtti, then that will crash. This avoids that. void rethrow_if_nested() { </s> add // For each exception in the chain of the exception_ptr argument, func // will be called with that exception (in reverse order, i.e. innermost first). #ifndef FBJNI_NO_EXCEPTION_PTR void denest(const std::function<void(std::exception_ptr)>& func, std::exception_ptr ptr) { FBASSERT(ptr); </s> add namespace internal { struct CacheEnvTag {}; } </s> remove static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); </s> add detail::BaseHybridClass* result = 0; static bool isHybrid = detail::HybridClassBase::isHybridClassBase(this->getClass()); if (isHybrid) { result = getNativePointer(this); } else { static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } result = getNativePointer(hybridData);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Hybrid.cpp
keep keep keep keep replace replace keep keep keep keep keep
<mask> <mask> } <mask> <mask> namespace { <mask> void resetNative(alias_ref<detail::HybridData> jthis) { <mask> jthis->setNativePointer(nullptr); <mask> } <mask> } <mask> <mask> void HybridDataOnLoad() { <mask> registerNatives("com/facebook/jni/HybridData", { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove registerNatives("com/facebook/jni/HybridData", { makeNativeMethod("resetNative", resetNative), </s> add registerNatives("com/facebook/jni/HybridData$Destructor", { makeNativeMethod("deleteNative", deleteNative), </s> remove StaticInitialized<ThreadLocal<JNIEnv>> g_env; JavaVM* g_vm = nullptr; struct JThreadScopeSupport : JavaClass<JThreadScopeSupport> { static auto constexpr kJavaDescriptor = "Lcom/facebook/jni/ThreadScopeSupport;"; // These reinterpret_casts are a totally dangerous pattern. Don't use them. Use HybridData instead. static void runStdFunction(std::function<void()>&& func) { static auto method = javaClassStatic()->getStaticMethod<void(jlong)>("runStdFunction"); method(javaClassStatic(), reinterpret_cast<jlong>(&func)); } </s> add </s> remove public synchronized void sendMessage(RequestBody message) throws IOException { </s> add public synchronized void sendMessage(String message) throws IOException { if (mWebSocket != null) { mWebSocket.send(message); } else { throw new ClosedChannelException(); } } public synchronized void sendMessage(ByteString message) throws IOException { </s> add namespace internal { struct CacheEnvTag {}; } </s> remove public void onMessage(ResponseBody message) throws IOException { </s> add public void onMessage(WebSocket webSocket, String text) { </s> remove public synchronized void onPong(Buffer payload) { } </s> add public synchronized void onMessage(WebSocket webSocket, ByteString bytes) { if (mMessageCallback != null) { mMessageCallback.onMessage(bytes); } }
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Hybrid.cpp
keep keep keep keep replace replace keep keep keep keep
<mask> } <mask> } <mask> <mask> void HybridDataOnLoad() { <mask> registerNatives("com/facebook/jni/HybridData", { <mask> makeNativeMethod("resetNative", resetNative), <mask> }); <mask> } <mask> <mask> }} </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove void resetNative(alias_ref<detail::HybridData> jthis) { jthis->setNativePointer(nullptr); </s> add void deleteNative(alias_ref<jclass>, jlong ptr) { delete reinterpret_cast<detail::BaseHybridClass*>(ptr); </s> remove bool JByteBuffer::isDirect() { </s> add bool JByteBuffer::isDirect() const { </s> remove } catch (IOException | JSONException e) { </s> add } catch (JSONException e) { </s> remove handlePokeSamplingProfiler(responder); </s> add if (mCurrentContext == null) { responder.error("JSCContext is missing, unable to profile"); return; } try { long jsContext = mCurrentContext.getJavaScriptContext(); Class clazz = Class.forName("com.facebook.react.packagerconnection.SamplingProfilerPackagerMethod"); RequestHandler handler = (RequestHandler) clazz.getConstructor(long.class).newInstance(jsContext); handler.onRequest(null, responder); } catch (Exception e) { } </s> remove handlePokeSamplingProfiler(null); </s> add handlePokeSamplingProfiler(); </s> remove public void onPokeSamplingProfilerCommand(@Nullable final Responder responder) { </s> add public void onPokeSamplingProfilerCommand(final Responder responder) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/Hybrid.cpp
keep keep keep keep replace replace keep keep keep
<mask> } <mask> <mask> std::string fromJString(JNIEnv* env, jstring str) { <mask> auto utf16String = JStringUtf16Extractor(env, str); <mask> auto length = env->GetStringLength(str); <mask> return detail::utf16toUTF8(utf16String, length); <mask> } <mask> <mask> } } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove auto length = env->GetStringLength(self()); return detail::utf16toUTF8(utf16String, length); </s> add return detail::utf16toUTF8(utf16String.chars(), utf16String.length()); </s> add jsize length_; </s> add , length_(0) </s> remove auto leaking_ref = (jclass)env->NewGlobalRef(cls); </s> add auto leaking_ref = (jclass)env->NewGlobalRef(cls.get()); </s> remove auto cls = env->FindClass(name); </s> add local_ref<jclass> cls = adopt_local(env->FindClass(name)); </s> remove auto env = g_env->get(); if (!env) { FBASSERT(g_vm); g_vm->AttachCurrentThread(&env, nullptr); g_env->reset(env); </s> add auto scope = currentScope(); if (scope && scope->env_) { return scope->env_;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/LocalString.cpp
keep keep keep keep replace keep replace
<mask> const auto env = internal::getEnv(); <mask> if (!env) { <mask> throw std::runtime_error("Unable to retrieve JNIEnv*."); <mask> } <mask> auto cls = env->FindClass(name); <mask> FACEBOOK_JNI_THROW_EXCEPTION_IF(!cls); <mask> auto leaking_ref = (jclass)env->NewGlobalRef(cls); </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove auto length = env->GetStringLength(self()); return detail::utf16toUTF8(utf16String, length); </s> add return detail::utf16toUTF8(utf16String.chars(), utf16String.length()); </s> remove auto env = g_env->get(); if (!env) { FBASSERT(g_vm); g_vm->AttachCurrentThread(&env, nullptr); g_env->reset(env); </s> add auto scope = currentScope(); if (scope && scope->env_) { return scope->env_; </s> remove // jthrowable ////////////////////////////////////////////////////////////////////////////////////// inline local_ref<JThrowable> JThrowable::initCause(alias_ref<JThrowable> cause) { static auto meth = javaClassStatic()->getMethod<javaobject(javaobject)>("initCause"); return meth(self(), cause.get()); } </s> add </s> remove #define DEFINE_PRIMITIVE_CALL(TYPE, METHOD, CLASS) \ </s> add #define DEFINE_PRIMITIVE_CALL(TYPE, METHOD) \ </s> remove const auto result = env->IsAssignableFrom(self(), other.get()); </s> add // Ths method has behavior compatible with the // java.lang.Class#isAssignableFrom method. The order of the // arguments to the JNI IsAssignableFrom C function is "opposite" // from what some might expect, which makes this code look a little // odd, but it is correct. const auto result = env->IsAssignableFrom(other.get(), self());
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/fbjni.cpp
keep keep keep keep replace replace keep keep keep keep keep
<mask> <mask> std::string JString::toStdString() const { <mask> const auto env = internal::getEnv(); <mask> auto utf16String = JStringUtf16Extractor(env, self()); <mask> auto length = env->GetStringLength(self()); <mask> return detail::utf16toUTF8(utf16String, length); <mask> } <mask> <mask> local_ref<JString> make_jstring(const char* utf8) { <mask> if (!utf8) { <mask> return {}; </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove auto length = env->GetStringLength(str); return detail::utf16toUTF8(utf16String, length); </s> add return detail::utf16toUTF8(utf16String.chars(), utf16String.length()); </s> remove auto cls = env->FindClass(name); </s> add local_ref<jclass> cls = adopt_local(env->FindClass(name)); </s> remove // jthrowable ////////////////////////////////////////////////////////////////////////////////////// inline local_ref<JThrowable> JThrowable::initCause(alias_ref<JThrowable> cause) { static auto meth = javaClassStatic()->getMethod<javaobject(javaobject)>("initCause"); return meth(self(), cause.get()); } </s> add </s> remove const auto result = env->IsAssignableFrom(self(), other.get()); </s> add // Ths method has behavior compatible with the // java.lang.Class#isAssignableFrom method. The order of the // arguments to the JNI IsAssignableFrom C function is "opposite" // from what some might expect, which makes this code look a little // odd, but it is correct. const auto result = env->IsAssignableFrom(other.get(), self()); </s> remove auto env = g_env->get(); if (!env) { FBASSERT(g_vm); g_vm->AttachCurrentThread(&env, nullptr); g_env->reset(env); </s> add auto scope = currentScope(); if (scope && scope->env_) { return scope->env_; </s> remove auto leaking_ref = (jclass)env->NewGlobalRef(cls); </s> add auto leaking_ref = (jclass)env->NewGlobalRef(cls.get());
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/fb/jni/fbjni.cpp
keep keep keep keep replace replace replace replace keep keep keep keep keep
<mask> static constexpr auto kJavaDescriptor = "Lcom/facebook/yoga/YogaLogLevel;"; <mask> }; <mask> <mask> static int YGJNILogFunc(const YGConfigRef config, <mask> const YGNodeRef node, <mask> YGLogLevel level, <mask> const char *format, <mask> va_list args) { <mask> char buffer[256]; <mask> int result = vsnprintf(buffer, sizeof(buffer), format, args); <mask> <mask> static auto logFunc = <mask> findClassStatic("com/facebook/yoga/YogaLogger") </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove void setNativePointer(std::unique_ptr<BaseHybridClass> new_value); BaseHybridClass* getNativePointer(); </s> add </s> remove YGPrintNumberIfNotUndefined(node, str, YGComputedEdgeValue(edges, YGEdgeLeft, &YGValueUndefined)); </s> add YGPrintNumberIfNotUndefined(node, str, YGComputedEdgeValue(edges, edge, &YGValueUndefined)); </s> add struct JVoid : public jni::JavaClass<JVoid> { static auto constexpr kJavaDescriptor = "Ljava/lang/Void;"; }; </s> remove bool isDirect(); </s> add bool isDirect() const; </s> remove StaticInitialized<ThreadLocal<JNIEnv>> g_env; JavaVM* g_vm = nullptr; struct JThreadScopeSupport : JavaClass<JThreadScopeSupport> { static auto constexpr kJavaDescriptor = "Lcom/facebook/jni/ThreadScopeSupport;"; // These reinterpret_casts are a totally dangerous pattern. Don't use them. Use HybridData instead. static void runStdFunction(std::function<void()>&& func) { static auto method = javaClassStatic()->getStaticMethod<void(jlong)>("runStdFunction"); method(javaClassStatic(), reinterpret_cast<jlong>(&func)); } </s> add </s> remove static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); </s> add detail::BaseHybridClass* result = 0; static bool isHybrid = detail::HybridClassBase::isHybridClassBase(this->getClass()); if (isHybrid) { result = getNativePointer(this); } else { static auto field = HybridClass<T, B>::JavaPart::javaClassStatic()->template getField<detail::HybridData::javaobject>("mHybridData"); auto hybridData = this->getFieldValue(field); if (!hybridData) { throwNewJavaException("java/lang/NullPointerException", "java.lang.NullPointerException"); } result = getNativePointer(hybridData);
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/first-party/yogajni/jni/YGJNI.cpp
keep keep keep keep replace keep keep keep keep keep
<mask> LOCAL_PATH := $(call my-dir) <mask> <mask> include $(CLEAR_VARS) <mask> <mask> LOCAL_MODULE := libreactnativejni <mask> <mask> LOCAL_SRC_FILES := \ <mask> Dummy.cpp \ <mask> <mask> LOCAL_C_INCLUDES := $(LOCAL_PATH) </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove LOCAL_MODULE := libreactnativefb </s> add LOCAL_MODULE := reactnative </s> remove Dummy.cpp \ </s> add CatalystInstanceImpl.cpp \ CxxModuleWrapper.cpp \ JavaModuleWrapper.cpp \ JMessageQueueThread.cpp \ JSCPerfLogging.cpp \ JSLoader.cpp \ JSLogging.cpp \ JniJSModulesUnbundle.cpp \ MethodInvoker.cpp \ ModuleRegistryBuilder.cpp \ NativeArray.cpp \ NativeCommon.cpp \ NativeMap.cpp \ OnLoad.cpp \ ProxyExecutor.cpp \ ReadableNativeArray.cpp \ ReadableNativeMap.cpp \ WritableNativeArray.cpp \ WritableNativeMap.cpp \ </s> remove LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. $(LOCAL_PATH)/.. </s> add LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. </s> remove LOCAL_SHARED_LIBRARIES := libreactnativejnifb LOCAL_STATIC_LIBRARIES := </s> add LOCAL_SHARED_LIBRARIES := libfolly_json libfbjni libjsc libglog_init libyoga LOCAL_STATIC_LIBRARIES := libreactnative </s> remove $(call import-module,xreact/jni) </s> add $(call import-module,cxxreact) $(call import-module,fb) $(call import-module,fbgloginit) $(call import-module,folly) $(call import-module,jsc) $(call import-module,yogajni) </s> remove #define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \ type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \ YGAssertWithNode(node, edge < YGEdgeEnd, "Cannot get layout properties of multi-edge shorthands"); \ \ if (edge == YGEdgeLeft) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeEnd]; \ } else { \ return node->layout.instanceName[YGEdgeStart]; \ } \ } \ \ if (edge == YGEdgeRight) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeStart]; \ } else { \ return node->layout.instanceName[YGEdgeEnd]; \ } \ } \ \ return node->layout.instanceName[edge]; \ </s> add #define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \ type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \ YGAssertWithNode(node, \ edge < YGEdgeEnd, \ "Cannot get layout properties of multi-edge shorthands"); \ \ if (edge == YGEdgeLeft) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeEnd]; \ } else { \ return node->layout.instanceName[YGEdgeStart]; \ } \ } \ \ if (edge == YGEdgeRight) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeStart]; \ } else { \ return node->layout.instanceName[YGEdgeEnd]; \ } \ } \ \ return node->layout.instanceName[edge]; \
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/react/jni/Android.mk
keep keep keep replace keep keep replace keep keep keep
<mask> LOCAL_MODULE := libreactnativejni <mask> <mask> LOCAL_SRC_FILES := \ <mask> Dummy.cpp \ <mask> <mask> LOCAL_C_INCLUDES := $(LOCAL_PATH) <mask> LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. $(LOCAL_PATH)/.. <mask> <mask> LOCAL_CFLAGS += -Wall -Werror -fvisibility=hidden -fexceptions -frtti <mask> CXX11_FLAGS := -std=c++11 </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove LOCAL_MODULE := libreactnativejni </s> add LOCAL_MODULE := reactnativejni </s> remove LOCAL_MODULE := libreactnativefb </s> add LOCAL_MODULE := reactnative </s> remove LOCAL_SHARED_LIBRARIES := libreactnativejnifb LOCAL_STATIC_LIBRARIES := </s> add LOCAL_SHARED_LIBRARIES := libfolly_json libfbjni libjsc libglog_init libyoga LOCAL_STATIC_LIBRARIES := libreactnative </s> remove $(call import-module,xreact/jni) </s> add $(call import-module,cxxreact) $(call import-module,fb) $(call import-module,fbgloginit) $(call import-module,folly) $(call import-module,jsc) $(call import-module,yogajni) </s> remove #define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \ type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \ YGAssertWithNode(node, edge < YGEdgeEnd, "Cannot get layout properties of multi-edge shorthands"); \ \ if (edge == YGEdgeLeft) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeEnd]; \ } else { \ return node->layout.instanceName[YGEdgeStart]; \ } \ } \ \ if (edge == YGEdgeRight) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeStart]; \ } else { \ return node->layout.instanceName[YGEdgeEnd]; \ } \ } \ \ return node->layout.instanceName[edge]; \ </s> add #define YG_NODE_LAYOUT_RESOLVED_PROPERTY_IMPL(type, name, instanceName) \ type YGNodeLayoutGet##name(const YGNodeRef node, const YGEdge edge) { \ YGAssertWithNode(node, \ edge < YGEdgeEnd, \ "Cannot get layout properties of multi-edge shorthands"); \ \ if (edge == YGEdgeLeft) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeEnd]; \ } else { \ return node->layout.instanceName[YGEdgeStart]; \ } \ } \ \ if (edge == YGEdgeRight) { \ if (node->layout.direction == YGDirectionRTL) { \ return node->layout.instanceName[YGEdgeStart]; \ } else { \ return node->layout.instanceName[YGEdgeEnd]; \ } \ } \ \ return node->layout.instanceName[edge]; \
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/react/jni/Android.mk
keep keep keep keep replace replace keep keep keep replace
<mask> LOCAL_CFLAGS += $(CXX11_FLAGS) <mask> LOCAL_EXPORT_CPPFLAGS := $(CXX11_FLAGS) <mask> <mask> LOCAL_LDLIBS += -landroid <mask> LOCAL_SHARED_LIBRARIES := libreactnativejnifb <mask> LOCAL_STATIC_LIBRARIES := <mask> <mask> include $(BUILD_SHARED_LIBRARY) <mask> <mask> $(call import-module,xreact/jni) </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. $(LOCAL_PATH)/.. </s> add LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../.. </s> remove LOCAL_MODULE := libreactnativejni </s> add LOCAL_MODULE := reactnativejni </s> remove LOCAL_MODULE := libreactnativefb </s> add LOCAL_MODULE := reactnative </s> remove Dummy.cpp \ </s> add CatalystInstanceImpl.cpp \ CxxModuleWrapper.cpp \ JavaModuleWrapper.cpp \ JMessageQueueThread.cpp \ JSCPerfLogging.cpp \ JSLoader.cpp \ JSLogging.cpp \ JniJSModulesUnbundle.cpp \ MethodInvoker.cpp \ ModuleRegistryBuilder.cpp \ NativeArray.cpp \ NativeCommon.cpp \ NativeMap.cpp \ OnLoad.cpp \ ProxyExecutor.cpp \ ReadableNativeArray.cpp \ ReadableNativeMap.cpp \ WritableNativeArray.cpp \ WritableNativeMap.cpp \ </s> remove sizeConsumedOnCurrentLine += flexBasisWithMaxConstraints + childMarginMainAxis; </s> add sizeConsumedOnCurrentLine += flexBasisWithMinAndMaxConstraints + childMarginMainAxis;
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/react/jni/Android.mk
keep replace keep keep replace replace replace keep
<mask> <mask> # TODO(cjhopman): Remove this target (or move the xreact target to this directory). <mask> cxx_library( <mask> name = "jni", <mask> srcs = [ <mask> "Dummy.cpp", <mask> ], <mask> header_namespace = "react/jni", </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove exported_headers = [ "CxxModule.h", "JsArgumentHelpers.h", "JsArgumentHelpers-inl.h", </s> add exported_headers = subdir_glob( [ ("", "CxxModule.h"), ("", "JsArgumentHelpers.h"), ("", "JsArgumentHelpers-inl.h"), ], prefix = "cxxreact", ), force_static = True, header_namespace = "", visibility = [ "PUBLIC", ], xcode_public_headers_symlinks = True, deps = [ "//xplat/folly:molly", ], ) rn_xplat_cxx_library( name = "jsbigstring", srcs = [ "JSBigString.cpp", </s> remove "-std=c++1y", ] + REACT_LIBRARY_EXTRA_COMPILER_FLAGS, exported_headers = CXXREACT_PUBLIC_HEADERS, </s> add ], exported_headers = dict([ ( "cxxreact/%s" % header, header, ) for header in CXXREACT_PUBLIC_HEADERS ]), fbandroid_preprocessor_flags = [ "-DWITH_JSC_EXTRA_TRACING=1", "-DWITH_JSC_MEMORY_PRESSURE=1", "-DWITH_REACT_INTERNAL_SETTINGS=1", "-DWITH_FB_MEMORY_PROFILING=1", ], fbandroid_visibility = [ # TL;DR: If you depend on this target directly, you're gonna have a # Bad Time(TM). # # `facebook::react::JSCExecutor::initOnJSVMThread` (in `:bridge`) does # some platform-dependant setup. Exactly what setup to do is # determined by some static functors, defined in `Platform.h`, which # are initially `nullptr`. On Android, these functors are properly # assigned as part of `xreact`'s `JNI_OnLoad`. By depending directly # on the bridge, we can mess up the SO initialisation order, causing # `initOnJSVMThread` to be called before the platform-specific hooks # have been properly initialised. Bad Times(TM). # -- @ashokmenon (2017/01/03) react_native_target("jni/react/jni:jni"), react_native_xplat_target("cxxreact/..."), ], fbobjc_frameworks = [ "$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework", ], fbobjc_inherited_buck_flags = STATIC_LIBRARY_IOS_FLAGS, fbobjc_preprocessor_flags = DEBUG_PREPROCESSOR_FLAGS, fbobjc_visibility = ["PUBLIC"], </s> remove CXX_LIBRARY_COMPILER_FLAGS = inherited_buck_flags.get_flag_value('compiler_flags') REACT_LIBRARY_EXTRA_COMPILER_FLAGS = ['-Wno-shadow', '-Wno-missing-prototypes', '-Wno-global-constructors'] def kwargs_add(base_kwargs, **new_kwargs): ret_kwargs = dict(base_kwargs) for name, add_value in new_kwargs.iteritems(): if name in ret_kwargs: # Don't use +=, it will modify base_kwargs ret_kwargs[name] = ret_kwargs[name] + add_value else: ret_kwargs[name] = add_value return ret_kwargs if THIS_IS_FBANDROID: include_defs('//ReactAndroid/DEFS') def react_library(**kwargs): kwargs = kwargs_add( kwargs, compiler_flags = [ '-Wno-pessimizing-move', ], deps = [ '//xplat/folly:molly' ]) cxx_library( name = 'bridge', **kwargs_add( kwargs, preprocessor_flags = [ '-DWITH_JSC_EXTRA_TRACING=1', '-DWITH_JSC_MEMORY_PRESSURE=1', '-DWITH_REACT_INTERNAL_SETTINGS=1', '-DWITH_FB_MEMORY_PROFILING=1', '-DWITH_INSPECTOR=1', ], deps = JSC_DEPS, visibility = [ # TL;DR: If you depend on this target directly, you're gonna have a # Bad Time(TM). # # `facebook::react::JSCExecutor::initOnJSVMThread` (in `:bridge`) does # some platform-dependant setup. Exactly what setup to do is # determined by some static functors, defined in `Platform.h`, which # are initially `nullptr`. On Android, these functors are properly # assigned as part of `xreact`'s `JNI_OnLoad`. By depending directly # on the bridge, we can mess up the SO initialisation order, causing # `initOnJSVMThread` to be called before the platform-specific hooks # have been properly initialised. Bad Times(TM). # -- @ashokmenon (2017/01/03) react_native_target('jni/xreact/jni:jni'), react_native_xplat_target('cxxreact/...'), ], ) ) if THIS_IS_FBOBJC: if should_use_dependency_aggregation(): INSPECTOR_FLAGS = [] else: INSPECTOR_FLAGS = [ '-DWITH_INSPECTOR=1', ] </s> add CXX_LIBRARY_COMPILER_FLAGS += inherited_buck_flags.get_flag_value('compiler_flags') </s> remove cxx_library( </s> add rn_xplat_cxx_library( </s> add compiler_flags = CXX_LIBRARY_COMPILER_FLAGS + [ "-fexceptions", "-frtti", ], exported_headers = subdir_glob( [("", "JSBigString.h")], prefix = "cxxreact", ),
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/react/jni/BUCK
keep keep keep keep replace replace replace keep
<mask> soname = "libreactnativejni.$(ext)", <mask> visibility = [ <mask> "PUBLIC", <mask> ], <mask> deps = [ <mask> react_native_target("jni/xreact/jni:jni"), <mask> ], <mask> ) </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove react_native_target("java/com/facebook/react/bridge:bridge"), </s> add </s> add react_native_dep("java/com/facebook/jni:jni"), react_native_dep("java/com/facebook/proguard/annotations:annotations"), </s> remove srcs = [ "Dummy.cpp", ], </s> add srcs = glob(["*.cpp"]), headers = glob( ["*.h"], excludes = EXPORTED_HEADERS, ), </s> remove exported_headers = [ "CxxModule.h", "JsArgumentHelpers.h", "JsArgumentHelpers-inl.h", </s> add exported_headers = subdir_glob( [ ("", "CxxModule.h"), ("", "JsArgumentHelpers.h"), ("", "JsArgumentHelpers-inl.h"), ], prefix = "cxxreact", ), force_static = True, header_namespace = "", visibility = [ "PUBLIC", ], xcode_public_headers_symlinks = True, deps = [ "//xplat/folly:molly", ], ) rn_xplat_cxx_library( name = "jsbigstring", srcs = [ "JSBigString.cpp", </s> remove header_namespace = "cxxreact", labels = ["accounts_for_platform_and_build_mode_flags"], </s> add header_namespace = "", </s> remove def react_library(**kwargs): fb_apple_library( name = 'bridge', header_path_prefix = "cxxreact", inherited_buck_flags = STATIC_LIBRARY_IOS_FLAGS, frameworks = [ '$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework', ], tests = [ react_native_xplat_target('cxxreact/tests:tests') ], **kwargs_add( kwargs, preprocessor_flags = DEBUG_PREPROCESSOR_FLAGS + INSPECTOR_FLAGS, deps = [ '//xplat/folly:molly', ], visibility = [ 'PUBLIC' ], ) ) cxx_library( </s> add rn_xplat_cxx_library(
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/jni/react/jni/BUCK
keep keep keep keep replace keep keep keep keep keep
<mask> <?xml version="1.0" encoding="utf-8"?> <mask> <resources> <mask> <style name="Theme"/> <mask> <style name="Theme.Catalyst"/> <mask> <style name="Theme.Catalyst.RedBox" parent="@style/Theme.AppCompat.DialogWhenLarge"> <mask> <item name="android:windowBackground">@color/catalyst_redbox_background</item> <mask> <item name="android:windowAnimationStyle">@style/Animation.Catalyst.RedBox</item> <mask> <item name="android:inAnimation">@android:anim/fade_in</item> <mask> <item name="android:outAnimation">@android:anim/fade_out</item> <mask> <item name="android:textColor">@android:color/white</item> </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> add YG_NODE_PROPERTY(YGNodeType, NodeType, nodeType); </s> add react_native_dep("java/com/facebook/jni:jni"), react_native_dep("java/com/facebook/proguard/annotations:annotations"), </s> remove import okhttp3.RequestBody; </s> add </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import java.net.URISyntaxException; import java.net.URI; import java.util.HashMap; import java.util.Map; import java.util.List; import java.util.concurrent.TimeUnit; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener; </s> remove WebSocketCall.create(client, builder.build()).enqueue(new WebSocketListener() { </s> add client.newWebSocket(builder.build(), new WebSocketListener() { </s> remove public void onClose(int code, String reason) { </s> add public void onClosed(WebSocket webSocket, int code, String reason) {
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/res/devsupport/values/styles.xml
keep keep keep keep replace replace keep keep keep keep keep
<mask> ) <mask> <mask> remote_file( <mask> name = "okhttp3-binary-jar", <mask> sha1 = "c7c4f9e35c2fd5900da24f9872e3971801f08ce0", <mask> url = "mvn:com.squareup.okhttp3:okhttp:jar:3.4.1", <mask> ) <mask> <mask> prebuilt_jar( <mask> name = "okhttp3-urlconnection", <mask> binary_jar = ":okhttp3-urlconnection-binary-jar", </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove sha1 = "63994437f62bc861bc20c605d12962f7246116d1", url = "mvn:com.squareup.okhttp3:okhttp-urlconnection:jar:3.4.1", ) prebuilt_jar( name = "okhttp3-ws", binary_jar = ":okhttp3-ws-binary-jar", visibility = ["//ReactAndroid/..."], ) remote_file( name = "okhttp3-ws-binary-jar", sha1 = "8ace66ef7002d98f633377c9e67daeeb196d8c3b", url = "mvn:com.squareup.okhttp3:okhttp-ws:jar:3.4.1", </s> add sha1 = "3f9b16b774f2c36cfd86dd2053d0b3059531dacc", url = "mvn:com.squareup.okhttp3:okhttp-urlconnection:jar:3.6.0", </s> remove sha1 = "f824591a0016efbaeddb8300bee54832a1398cfa", url = "mvn:com.squareup.okio:okio:jar:1.9.0", </s> add sha1 = "a9283170b7305c8d92d25aff02a6ab7e45d06cbe", url = "mvn:com.squareup.okio:okio:jar:1.13.0", </s> remove cxx_library( </s> add rn_xplat_cxx_library( </s> remove def react_library(**kwargs): fb_apple_library( name = 'bridge', header_path_prefix = "cxxreact", inherited_buck_flags = STATIC_LIBRARY_IOS_FLAGS, frameworks = [ '$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework', ], tests = [ react_native_xplat_target('cxxreact/tests:tests') ], **kwargs_add( kwargs, preprocessor_flags = DEBUG_PREPROCESSOR_FLAGS + INSPECTOR_FLAGS, deps = [ '//xplat/folly:molly', ], visibility = [ 'PUBLIC' ], ) ) cxx_library( </s> add rn_xplat_cxx_library( </s> remove exported_headers = [ "CxxModule.h", "JsArgumentHelpers.h", "JsArgumentHelpers-inl.h", </s> add exported_headers = subdir_glob( [ ("", "CxxModule.h"), ("", "JsArgumentHelpers.h"), ("", "JsArgumentHelpers-inl.h"), ], prefix = "cxxreact", ), force_static = True, header_namespace = "", visibility = [ "PUBLIC", ], xcode_public_headers_symlinks = True, deps = [ "//xplat/folly:molly", ], ) rn_xplat_cxx_library( name = "jsbigstring", srcs = [ "JSBigString.cpp", </s> remove react_library( </s> add rn_xplat_cxx_library( name = "bridge",
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/third-party/java/okhttp/BUCK
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep
<mask> ) <mask> <mask> remote_file( <mask> name = "okhttp3-urlconnection-binary-jar", <mask> sha1 = "63994437f62bc861bc20c605d12962f7246116d1", <mask> url = "mvn:com.squareup.okhttp3:okhttp-urlconnection:jar:3.4.1", <mask> ) <mask> <mask> prebuilt_jar( <mask> name = "okhttp3-ws", <mask> binary_jar = ":okhttp3-ws-binary-jar", <mask> visibility = ["//ReactAndroid/..."], <mask> ) <mask> <mask> remote_file( <mask> name = "okhttp3-ws-binary-jar", <mask> sha1 = "8ace66ef7002d98f633377c9e67daeeb196d8c3b", <mask> url = "mvn:com.squareup.okhttp3:okhttp-ws:jar:3.4.1", <mask> ) </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove sha1 = "c7c4f9e35c2fd5900da24f9872e3971801f08ce0", url = "mvn:com.squareup.okhttp3:okhttp:jar:3.4.1", </s> add sha1 = "69edde9fc4b01c9fd51d25b83428837478c27254", url = "mvn:com.squareup.okhttp3:okhttp:jar:3.6.0", </s> remove sha1 = "f824591a0016efbaeddb8300bee54832a1398cfa", url = "mvn:com.squareup.okio:okio:jar:1.9.0", </s> add sha1 = "a9283170b7305c8d92d25aff02a6ab7e45d06cbe", url = "mvn:com.squareup.okio:okio:jar:1.13.0", </s> remove def react_library(**kwargs): fb_apple_library( name = 'bridge', header_path_prefix = "cxxreact", inherited_buck_flags = STATIC_LIBRARY_IOS_FLAGS, frameworks = [ '$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework', ], tests = [ react_native_xplat_target('cxxreact/tests:tests') ], **kwargs_add( kwargs, preprocessor_flags = DEBUG_PREPROCESSOR_FLAGS + INSPECTOR_FLAGS, deps = [ '//xplat/folly:molly', ], visibility = [ 'PUBLIC' ], ) ) cxx_library( </s> add rn_xplat_cxx_library( </s> remove cxx_library( </s> add rn_xplat_cxx_library( </s> remove exported_headers = [ "CxxModule.h", "JsArgumentHelpers.h", "JsArgumentHelpers-inl.h", </s> add exported_headers = subdir_glob( [ ("", "CxxModule.h"), ("", "JsArgumentHelpers.h"), ("", "JsArgumentHelpers-inl.h"), ], prefix = "cxxreact", ), force_static = True, header_namespace = "", visibility = [ "PUBLIC", ], xcode_public_headers_symlinks = True, deps = [ "//xplat/folly:molly", ], ) rn_xplat_cxx_library( name = "jsbigstring", srcs = [ "JSBigString.cpp", </s> remove deps = [ react_native_target("jni/xreact/jni:jni"), ], </s> add xcode_public_headers_symlinks = True, deps = ([ "//native/third-party/android-ndk:android", "//xplat/folly:molly", "//xplat/fbgloginit:fbgloginit", "//xplat/fbsystrace:fbsystrace", react_native_xplat_target("cxxreact:bridge"), react_native_xplat_target("cxxreact:module"), FBJNI_TARGET, ] + JSC_DEPS) if not IS_OSS_BUILD else [],
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/third-party/java/okhttp/BUCK
keep keep keep keep replace replace keep
<mask> ) <mask> <mask> remote_file( <mask> name = "okio-binary-jar", <mask> sha1 = "f824591a0016efbaeddb8300bee54832a1398cfa", <mask> url = "mvn:com.squareup.okio:okio:jar:1.9.0", <mask> ) </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove sha1 = "63994437f62bc861bc20c605d12962f7246116d1", url = "mvn:com.squareup.okhttp3:okhttp-urlconnection:jar:3.4.1", ) prebuilt_jar( name = "okhttp3-ws", binary_jar = ":okhttp3-ws-binary-jar", visibility = ["//ReactAndroid/..."], ) remote_file( name = "okhttp3-ws-binary-jar", sha1 = "8ace66ef7002d98f633377c9e67daeeb196d8c3b", url = "mvn:com.squareup.okhttp3:okhttp-ws:jar:3.4.1", </s> add sha1 = "3f9b16b774f2c36cfd86dd2053d0b3059531dacc", url = "mvn:com.squareup.okhttp3:okhttp-urlconnection:jar:3.6.0", </s> remove sha1 = "c7c4f9e35c2fd5900da24f9872e3971801f08ce0", url = "mvn:com.squareup.okhttp3:okhttp:jar:3.4.1", </s> add sha1 = "69edde9fc4b01c9fd51d25b83428837478c27254", url = "mvn:com.squareup.okhttp3:okhttp:jar:3.6.0", </s> remove cxx_library( </s> add rn_xplat_cxx_library( </s> remove def react_library(**kwargs): fb_apple_library( name = 'bridge', header_path_prefix = "cxxreact", inherited_buck_flags = STATIC_LIBRARY_IOS_FLAGS, frameworks = [ '$SDKROOT/System/Library/Frameworks/JavaScriptCore.framework', ], tests = [ react_native_xplat_target('cxxreact/tests:tests') ], **kwargs_add( kwargs, preprocessor_flags = DEBUG_PREPROCESSOR_FLAGS + INSPECTOR_FLAGS, deps = [ '//xplat/folly:molly', ], visibility = [ 'PUBLIC' ], ) ) cxx_library( </s> add rn_xplat_cxx_library( </s> remove exported_headers = [ "CxxModule.h", "JsArgumentHelpers.h", "JsArgumentHelpers-inl.h", </s> add exported_headers = subdir_glob( [ ("", "CxxModule.h"), ("", "JsArgumentHelpers.h"), ("", "JsArgumentHelpers-inl.h"), ], prefix = "cxxreact", ), force_static = True, header_namespace = "", visibility = [ "PUBLIC", ], xcode_public_headers_symlinks = True, deps = [ "//xplat/folly:molly", ], ) rn_xplat_cxx_library( name = "jsbigstring", srcs = [ "JSBigString.cpp", </s> add react_native_dep("third-party/java/okio:okio"),
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/main/third-party/java/okio/BUCK
keep keep keep add keep keep
<mask> react_native_dep("third-party/java/robolectric3/robolectric:robolectric"), <mask> react_native_target("java/com/facebook/react/bridge:bridge"), <mask> react_native_target("java/com/facebook/react/common:common"), <mask> react_native_target("java/com/facebook/react/uimanager:uimanager"), <mask> ], <mask> ) </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add </s> add react_native_dep("third-party/java/okio:okio"), </s> remove react_native_target("java/com/facebook/react/bridge:bridge"), </s> add </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add react_native_dep("third-party/java/okio:okio"), </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK
keep keep keep keep replace keep keep keep keep keep
<mask> react_native_dep("third-party/java/jsr-305:jsr-305"), <mask> react_native_dep("third-party/java/junit:junit"), <mask> react_native_dep("third-party/java/mockito:mockito"), <mask> react_native_dep("third-party/java/okhttp:okhttp3"), <mask> react_native_dep("third-party/java/okhttp:okhttp3-ws"), <mask> react_native_dep("third-party/java/okio:okio"), <mask> react_native_dep("third-party/java/robolectric3/robolectric:robolectric"), <mask> react_native_target("java/com/facebook/react:react"), <mask> react_native_target("java/com/facebook/react/bridge:bridge"), <mask> react_native_target("java/com/facebook/react/common:common"), </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add react_native_dep("third-party/java/okio:okio"), </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add </s> add react_native_dep("third-party/java/okio:okio"), </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add </s> add react_native_tests_target("java/com/facebook/common/logging:logging"),
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/devsupport/BUCK
keep keep keep keep replace replace keep keep keep keep keep
<mask> import org.robolectric.RobolectricTestRunner; <mask> <mask> import java.util.HashMap; <mask> <mask> import okhttp3.ResponseBody; <mask> import okhttp3.ws.WebSocket; <mask> <mask> import static org.mockito.Mockito.*; <mask> <mask> @PrepareForTest({ JSDebuggerWebSocketClient.class }) <mask> @RunWith(RobolectricTestRunner.class) </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; </s> add import okio.ByteString; </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import java.net.URISyntaxException; import java.net.URI; import java.util.HashMap; import java.util.Map; import java.util.List; import java.util.concurrent.TimeUnit; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener; </s> remove import okhttp3.RequestBody; </s> add </s> remove import okhttp3.RequestBody; </s> add </s> remove import okhttp3.RequestBody; </s> add </s> remove import okhttp3.RequestBody; </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java
keep keep keep keep replace keep keep keep keep keep
<mask> @Test <mask> public void test_onMessage_WithInvalidContentType_ShouldNotTriggerCallbacks() throws Exception { <mask> JSDebuggerWebSocketClient client = PowerMockito.spy(new JSDebuggerWebSocketClient()); <mask> <mask> client.onMessage(ResponseBody.create(WebSocket.BINARY, "{\"replyID\":0, \"result\":\"OK\"}")); <mask> PowerMockito.verifyPrivate(client, never()).invoke("triggerRequestSuccess", anyInt(), anyString()); <mask> PowerMockito.verifyPrivate(client, never()).invoke("triggerRequestFailure", anyInt(), any()); <mask> } <mask> <mask> @Test </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":null, \"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"replyID\":null, \"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"replyID\":0, \"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":null}")); </s> add client.onMessage(null, "{\"replyID\":0, \"result\":null}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":null}")); </s> add client.onMessage(null, "{\"replyID\":0, \"error\":null}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":\"BOOM\"}")); </s> add client.onMessage(null, "{\"replyID\":0, \"error\":\"BOOM\"}");
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java
keep keep keep keep replace keep keep keep keep keep
<mask> @Test <mask> public void test_onMessage_WithoutReplyId_ShouldNotTriggerCallbacks() throws Exception { <mask> JSDebuggerWebSocketClient client = PowerMockito.spy(new JSDebuggerWebSocketClient()); <mask> <mask> client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"result\":\"OK\"}")); <mask> PowerMockito.verifyPrivate(client, never()).invoke("triggerRequestSuccess", anyInt(), anyString()); <mask> PowerMockito.verifyPrivate(client, never()).invoke("triggerRequestFailure", anyInt(), any()); <mask> } <mask> <mask> @Test </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":null, \"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"replyID\":null, \"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.BINARY, "{\"replyID\":0, \"result\":\"OK\"}")); </s> add client.onMessage(null, ByteString.encodeUtf8("{\"replyID\":0, \"result\":\"OK\"}")); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":null}")); </s> add client.onMessage(null, "{\"replyID\":0, \"result\":null}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"replyID\":0, \"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":null}")); </s> add client.onMessage(null, "{\"replyID\":0, \"error\":null}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":\"BOOM\"}")); </s> add client.onMessage(null, "{\"replyID\":0, \"error\":\"BOOM\"}");
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java
keep keep keep keep replace keep keep keep keep keep
<mask> @Test <mask> public void test_onMessage_With_Null_ReplyId_ShouldNotTriggerCallbacks() throws Exception { <mask> JSDebuggerWebSocketClient client = PowerMockito.spy(new JSDebuggerWebSocketClient()); <mask> <mask> client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":null, \"result\":\"OK\"}")); <mask> PowerMockito.verifyPrivate(client, never()).invoke("triggerRequestSuccess", anyInt(), anyString()); <mask> PowerMockito.verifyPrivate(client, never()).invoke("triggerRequestFailure", anyInt(), any()); <mask> } <mask> <mask> @Test </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove client.onMessage(ResponseBody.create(WebSocket.BINARY, "{\"replyID\":0, \"result\":\"OK\"}")); </s> add client.onMessage(null, ByteString.encodeUtf8("{\"replyID\":0, \"result\":\"OK\"}")); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"replyID\":0, \"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":null}")); </s> add client.onMessage(null, "{\"replyID\":0, \"result\":null}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":null}")); </s> add client.onMessage(null, "{\"replyID\":0, \"error\":null}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":\"BOOM\"}")); </s> add client.onMessage(null, "{\"replyID\":0, \"error\":\"BOOM\"}");
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java
keep keep keep keep replace keep keep keep keep keep
<mask> @Test <mask> public void test_onMessage_WithResult_ShouldTriggerRequestSuccess() throws Exception { <mask> JSDebuggerWebSocketClient client = PowerMockito.spy(new JSDebuggerWebSocketClient()); <mask> <mask> client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":\"OK\"}")); <mask> PowerMockito.verifyPrivate(client).invoke("triggerRequestSuccess", 0, "OK"); <mask> PowerMockito.verifyPrivate(client, never()).invoke("triggerRequestFailure", anyInt(), any()); <mask> } <mask> <mask> @Test </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":null}")); </s> add client.onMessage(null, "{\"replyID\":0, \"result\":null}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.BINARY, "{\"replyID\":0, \"result\":\"OK\"}")); </s> add client.onMessage(null, ByteString.encodeUtf8("{\"replyID\":0, \"result\":\"OK\"}")); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":null, \"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"replyID\":null, \"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":null}")); </s> add client.onMessage(null, "{\"replyID\":0, \"error\":null}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":\"BOOM\"}")); </s> add client.onMessage(null, "{\"replyID\":0, \"error\":\"BOOM\"}");
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java
keep keep keep keep replace keep keep keep keep keep
<mask> @Test <mask> public void test_onMessage_With_Null_Result_ShouldTriggerRequestSuccess() throws Exception { <mask> JSDebuggerWebSocketClient client = PowerMockito.spy(new JSDebuggerWebSocketClient()); <mask> <mask> client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":null}")); <mask> PowerMockito.verifyPrivate(client).invoke("triggerRequestSuccess", 0, null); <mask> PowerMockito.verifyPrivate(client, never()).invoke("triggerRequestFailure", anyInt(), any()); <mask> } <mask> <mask> @Test </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"replyID\":0, \"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.BINARY, "{\"replyID\":0, \"result\":\"OK\"}")); </s> add client.onMessage(null, ByteString.encodeUtf8("{\"replyID\":0, \"result\":\"OK\"}")); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":null, \"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"replyID\":null, \"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":null}")); </s> add client.onMessage(null, "{\"replyID\":0, \"error\":null}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":\"BOOM\"}")); </s> add client.onMessage(null, "{\"replyID\":0, \"error\":\"BOOM\"}");
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java
keep keep keep keep replace keep keep keep keep keep
<mask> @Test <mask> public void test_onMessage_WithError_ShouldCallAbort() throws Exception { <mask> JSDebuggerWebSocketClient client = PowerMockito.spy(new JSDebuggerWebSocketClient()); <mask> <mask> client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":\"BOOM\"}")); <mask> PowerMockito.verifyPrivate(client).invoke("abort", eq("BOOM"), isA(JavascriptException.class)); <mask> } <mask> <mask> @Test <mask> public void test_onMessage_With_Null_Error_ShouldTriggerRequestSuccess() throws Exception { </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":null}")); </s> add client.onMessage(null, "{\"replyID\":0, \"error\":null}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"replyID\":0, \"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":null}")); </s> add client.onMessage(null, "{\"replyID\":0, \"result\":null}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.BINARY, "{\"replyID\":0, \"result\":\"OK\"}")); </s> add client.onMessage(null, ByteString.encodeUtf8("{\"replyID\":0, \"result\":\"OK\"}")); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":null, \"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"replyID\":null, \"result\":\"OK\"}");
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java
keep keep keep keep replace keep keep keep
<mask> @Test <mask> public void test_onMessage_With_Null_Error_ShouldTriggerRequestSuccess() throws Exception { <mask> JSDebuggerWebSocketClient client = PowerMockito.spy(new JSDebuggerWebSocketClient()); <mask> <mask> client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":null}")); <mask> PowerMockito.verifyPrivate(client).invoke("triggerRequestSuccess", anyInt(), anyString()); <mask> } <mask> } </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"replyID\":0, \"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"result\":null}")); </s> add client.onMessage(null, "{\"replyID\":0, \"result\":null}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":0, \"error\":\"BOOM\"}")); </s> add client.onMessage(null, "{\"replyID\":0, \"error\":\"BOOM\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"result\":\"OK\"}"); </s> remove client.onMessage(ResponseBody.create(WebSocket.BINARY, "{\"replyID\":0, \"result\":\"OK\"}")); </s> add client.onMessage(null, ByteString.encodeUtf8("{\"replyID\":0, \"result\":\"OK\"}")); </s> remove client.onMessage(ResponseBody.create(WebSocket.TEXT, "{\"replyID\":null, \"result\":\"OK\"}")); </s> add client.onMessage(null, "{\"replyID\":null, \"result\":\"OK\"}");
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/devsupport/JSDebuggerWebSocketClientTest.java
keep keep keep keep replace keep keep keep keep
<mask> react_native_dep("third-party/java/jsr-305:jsr-305"), <mask> react_native_dep("third-party/java/junit:junit"), <mask> react_native_dep("third-party/java/mockito:mockito"), <mask> react_native_dep("third-party/java/okhttp:okhttp3"), <mask> react_native_dep("third-party/java/okhttp:okhttp3-ws"), <mask> react_native_dep("third-party/java/robolectric3/robolectric:robolectric"), <mask> react_native_target("java/com/facebook/react/packagerconnection:packagerconnection"), <mask> ], <mask> ) </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add </s> remove ], </s> add ] + ([react_native_target("jni/packagerconnection:jni")] if not IS_OSS_BUILD else []), </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add </s> remove react_native_dep("third-party/java/okhttp:okhttp3-ws"), </s> add </s> add react_native_tests_target("java/com/facebook/common/logging:logging"),
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/packagerconnection/BUCK
keep keep keep keep replace replace keep keep keep keep keep
<mask> import java.io.IOException; <mask> import java.util.HashMap; <mask> import java.util.Map; <mask> <mask> import okhttp3.ResponseBody; <mask> import okhttp3.ws.WebSocket; <mask> <mask> import static org.mockito.Mockito.*; <mask> import org.robolectric.RobolectricTestRunner; <mask> <mask> @RunWith(RobolectricTestRunner.class) </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; </s> add import okio.ByteString; </s> remove import java.lang.IllegalStateException; import javax.annotation.Nullable; </s> add import java.net.URI; import java.net.URISyntaxException; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; </s> remove import okhttp3.ResponseBody; import okhttp3.ws.WebSocket; import okhttp3.ws.WebSocketCall; import okhttp3.ws.WebSocketListener; import java.net.URISyntaxException; import java.net.URI; import java.util.HashMap; import java.util.Map; import java.util.List; import java.util.concurrent.TimeUnit; import okio.Buffer; </s> add import okhttp3.WebSocket; import okhttp3.WebSocketListener; </s> add import java.io.StringReader; </s> remove import okhttp3.RequestBody; </s> add </s> remove import okhttp3.RequestBody; </s> add
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/packagerconnection/JSPackagerClientTest.java
keep keep keep keep replace replace replace replace keep keep keep keep keep
<mask> public void test_onMessage_ShouldTriggerNotification() throws IOException { <mask> RequestHandler handler = mock(RequestHandler.class); <mask> final JSPackagerClient client = new JSPackagerClient("test_client", mSettings, createRH("methodValue", handler)); <mask> <mask> client.onMessage( <mask> ResponseBody.create( <mask> WebSocket.TEXT, <mask> "{\"version\": 2, \"method\": \"methodValue\", \"params\": \"paramsValue\"}")); <mask> verify(handler).onNotification(eq("paramsValue")); <mask> verify(handler, never()).onRequest(any(), any(Responder.class)); <mask> } <mask> <mask> @Test </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove client.onMessage( ResponseBody.create( WebSocket.TEXT, "{\"version\": 2, \"id\": \"idValue\", \"method\": \"methodValue\", \"params\": \"paramsValue\"}")); </s> add client.onMessage("{\"version\": 2, \"id\": \"idValue\", \"method\": \"methodValue\", \"params\": \"paramsValue\"}"); </s> remove client.onMessage( ResponseBody.create( WebSocket.TEXT, "{\"version\": 2, \"method\": null}")); </s> add client.onMessage("{\"version\": 2, \"method\": null}"); </s> remove client.onMessage( ResponseBody.create( WebSocket.TEXT, "{\"version\": 2, \"method\": \"methodValue\"}")); </s> add client.onMessage("{\"version\": 2, \"method\": \"methodValue\"}"); </s> remove client.onMessage( ResponseBody.create( WebSocket.BINARY, "{\"version\": 2, \"method\": \"methodValue\"}")); </s> add client.onMessage(ByteString.encodeUtf8("{\"version\": 2, \"method\": \"methodValue\"}")); </s> remove client.onMessage( ResponseBody.create( WebSocket.BINARY, "{\"version\": 2, \"method\": \"methodValue2\"}")); </s> add client.onMessage(ByteString.EMPTY); </s> remove client.onMessage( ResponseBody.create( WebSocket.TEXT, "{\"version\": 2}")); </s> add client.onMessage("{\"version\": 2}");
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/packagerconnection/JSPackagerClientTest.java
keep keep keep keep replace replace replace replace keep keep keep keep keep
<mask> public void test_onMessage_ShouldTriggerRequest() throws IOException { <mask> RequestHandler handler = mock(RequestHandler.class); <mask> final JSPackagerClient client = new JSPackagerClient("test_client", mSettings, createRH("methodValue", handler)); <mask> <mask> client.onMessage( <mask> ResponseBody.create( <mask> WebSocket.TEXT, <mask> "{\"version\": 2, \"id\": \"idValue\", \"method\": \"methodValue\", \"params\": \"paramsValue\"}")); <mask> verify(handler, never()).onNotification(any()); <mask> verify(handler).onRequest(eq("paramsValue"), any(Responder.class)); <mask> } <mask> <mask> @Test </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove client.onMessage( ResponseBody.create( WebSocket.TEXT, "{\"version\": 2, \"method\": \"methodValue\", \"params\": \"paramsValue\"}")); </s> add client.onMessage("{\"version\": 2, \"method\": \"methodValue\", \"params\": \"paramsValue\"}"); </s> remove client.onMessage( ResponseBody.create( WebSocket.TEXT, "{\"version\": 2, \"method\": null}")); </s> add client.onMessage("{\"version\": 2, \"method\": null}"); </s> remove client.onMessage( ResponseBody.create( WebSocket.BINARY, "{\"version\": 2, \"method\": \"methodValue\"}")); </s> add client.onMessage(ByteString.encodeUtf8("{\"version\": 2, \"method\": \"methodValue\"}")); </s> remove client.onMessage( ResponseBody.create( WebSocket.BINARY, "{\"version\": 2, \"method\": \"methodValue2\"}")); </s> add client.onMessage(ByteString.EMPTY); </s> remove client.onMessage( ResponseBody.create( WebSocket.TEXT, "{\"version\": 2, \"method\": \"methodValue\"}")); </s> add client.onMessage("{\"version\": 2, \"method\": \"methodValue\"}"); </s> remove client.onMessage( ResponseBody.create( WebSocket.TEXT, "{\"version\": 2}")); </s> add client.onMessage("{\"version\": 2}");
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/packagerconnection/JSPackagerClientTest.java
keep keep keep keep replace replace replace replace keep keep keep keep keep
<mask> public void test_onMessage_WithoutParams_ShouldTriggerNotification() throws IOException { <mask> RequestHandler handler = mock(RequestHandler.class); <mask> final JSPackagerClient client = new JSPackagerClient("test_client", mSettings, createRH("methodValue", handler)); <mask> <mask> client.onMessage( <mask> ResponseBody.create( <mask> WebSocket.TEXT, <mask> "{\"version\": 2, \"method\": \"methodValue\"}")); <mask> verify(handler).onNotification(eq(null)); <mask> verify(handler, never()).onRequest(any(), any(Responder.class)); <mask> } <mask> <mask> @Test </s> Update RN Android with SDK 19 fbshipit-source-id: fcb472a571 </s> remove client.onMessage( ResponseBody.create( WebSocket.BINARY, "{\"version\": 2, \"method\": \"methodValue\"}")); </s> add client.onMessage(ByteString.encodeUtf8("{\"version\": 2, \"method\": \"methodValue\"}")); </s> remove client.onMessage( ResponseBody.create( WebSocket.TEXT, "{\"version\": 2, \"method\": null}")); </s> add client.onMessage("{\"version\": 2, \"method\": null}"); </s> remove client.onMessage( ResponseBody.create( WebSocket.TEXT, "{\"version\": 1, \"method\": \"methodValue\"}")); </s> add client.onMessage("{\"version\": 1, \"method\": \"methodValue\"}"); </s> remove client.onMessage( ResponseBody.create( WebSocket.TEXT, "{\"version\": 2, \"method\": \"methodValue\", \"params\": \"paramsValue\"}")); </s> add client.onMessage("{\"version\": 2, \"method\": \"methodValue\", \"params\": \"paramsValue\"}"); </s> remove client.onMessage( ResponseBody.create( WebSocket.BINARY, "{\"version\": 2, \"method\": \"methodValue2\"}")); </s> add client.onMessage(ByteString.EMPTY); </s> remove client.onMessage( ResponseBody.create( WebSocket.TEXT, "{\"version\": 2}")); </s> add client.onMessage("{\"version\": 2}");
https://github.com/expo/expo/commit/7b58f4ab024999b96bc75072438f9d9cdc0bc7d2
android/ReactAndroid/src/test/java/com/facebook/react/packagerconnection/JSPackagerClientTest.java