mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Migrate to FBJNI (#27729)
Summary: This is an incomplete effort to migrate from libfb to libfbjni. This is needed to restore the compatibility with Flipper and other FB Android projects that make use of FBJNI. Effectively, the outcome is that `fbjni` no longer has a checked-in copy here, but instead relies on the public artifacts published at github.com/facebookincubator/fbjni that can be deduplicated at build-time. **A non-exhaustive list of tasks:** * [X] Gradle builds the SDK and RNTester for Android. * [X] Buck build for rntester works in OSS. * [ ] Move from `java-only` release to full `fbjni` release. This requires finding a solution for stripping out `.so` files that the old `Android.mk` insists on including in the final artifacts and will clash with the full distribution. * [ ] Import this and fix potential internal build issues. * [ ] Verify that the changes made to the Hermes integration don't have any unintended consequences. ## Changelog [Android] [Changed] - Migrated from libfb to libfbjni for JNI calls Pull Request resolved: https://github.com/facebook/react-native/pull/27729 Test Plan: - CI is already passing again for Gradle and Buck in OSS. - After applying the following patch, RNTester builds and works with the latest Flipper SDK: ``` diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle index b8a6437d7..eac942104 100644 --- a/RNTester/android/app/build.gradle +++ b/RNTester/android/app/build.gradle @@ -170,10 +170,19 @@ dependencies { debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") - debugImplementation("com.facebook.flipper:flipper:0.23.4") { + debugImplementation("com.facebook.flipper🐬+") { exclude group:'com.facebook.yoga' - exclude group:'com.facebook.flipper', module: 'fbjni' - exclude group:'com.facebook.litho', module: 'litho-annotations' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-network-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' } if (useIntlJsc) { ``` Reviewed By: mdvacca Differential Revision: D19345270 Pulled By: passy fbshipit-source-id: 33811e7f97f44f2ec5999e1c35339909dc4fd3b1
This commit is contained in:
committed by
Rick Hanlon
parent
89eb287be1
commit
8c11d3ffce
@@ -5,7 +5,7 @@ rn_android_library(
|
||||
srcs = glob(["yoga/*.java"]),
|
||||
visibility = ["PUBLIC"],
|
||||
deps = [
|
||||
react_native_dep("java/com/facebook/jni:jni"),
|
||||
react_native_dep("libraries/fbjni:java"),
|
||||
react_native_dep("java/com/facebook/proguard/annotations:annotations"),
|
||||
react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"),
|
||||
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
|
||||
|
||||
@@ -19,7 +19,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(call find-no
|
||||
LOCAL_CPP_FEATURES := exceptions
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := libjsireact libjsi
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libreactnativejni libhermes
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libhermes
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ rn_android_library(
|
||||
deps = [
|
||||
react_native_dep("java/com/facebook/proguard/annotations:annotations"),
|
||||
react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"),
|
||||
react_native_dep("java/com/facebook/jni:jni"),
|
||||
react_native_dep("libraries/fbjni:java"),
|
||||
":jni_hermes_samplingprofiler",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <string>
|
||||
|
||||
namespace facebook {
|
||||
|
||||
+1
-2
@@ -8,8 +8,7 @@
|
||||
#ifndef HERMESSAMPLINGPROFILER_H_
|
||||
#define HERMESSAMPLINGPROFILER_H_
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <jni/Registration.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <jsi/jsi.h>
|
||||
|
||||
namespace facebook {
|
||||
|
||||
@@ -18,7 +18,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(call find-no
|
||||
LOCAL_CPP_FEATURES := exceptions
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := libjsireact libjsi
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libreactnativejni libhermes
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libhermes
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
@@ -35,6 +35,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(call find-no
|
||||
LOCAL_CPP_FEATURES := exceptions
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := libjsireact libjsi libhermes-inspector
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libreactnativejni libhermes
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libhermes
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <../instrumentation/HermesMemoryDumper.h>
|
||||
#include <HermesExecutorFactory.h>
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <hermes/Public/GCConfig.h>
|
||||
#include <hermes/Public/RuntimeConfig.h>
|
||||
#include <jni.h>
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "rn_android_library")
|
||||
|
||||
rn_android_library(
|
||||
name = "jni",
|
||||
srcs = glob(["**/*.java"]),
|
||||
proguard_config = "fbjni.pro",
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
],
|
||||
deps = [
|
||||
react_native_dep("third-party/android/androidx:annotation"),
|
||||
react_native_dep("java/com/facebook/proguard/annotations:annotations"),
|
||||
react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"),
|
||||
react_native_dep("third-party/java/jsr-305:jsr-305"),
|
||||
],
|
||||
)
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.jni;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
/**
|
||||
* A Java Object that has native memory allocated corresponding to this instance.
|
||||
*
|
||||
* <p>NB: THREAD SAFETY (this comment also exists at Countable.cpp)
|
||||
*
|
||||
* <p>{@link #dispose} deletes the corresponding native object on whatever thread the method is
|
||||
* called on. In the common case when this is called by Countable#finalize(), this will be called on
|
||||
* the system finalizer thread. If you manually call dispose on the Java object, the native object
|
||||
* will be deleted synchronously on that thread.
|
||||
*/
|
||||
@DoNotStrip
|
||||
public class Countable {
|
||||
|
||||
static {
|
||||
SoLoader.loadLibrary("fb");
|
||||
}
|
||||
|
||||
// Private C++ instance
|
||||
@DoNotStrip private long mInstance = 0;
|
||||
|
||||
public native void dispose();
|
||||
|
||||
protected void finalize() throws Throwable {
|
||||
dispose();
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.jni;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
/** Utility class to determine CPU capabilities */
|
||||
@DoNotStrip
|
||||
public class CpuCapabilitiesJni {
|
||||
|
||||
static {
|
||||
SoLoader.loadLibrary("fb");
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
public static native boolean nativeDeviceSupportsNeon();
|
||||
|
||||
@DoNotStrip
|
||||
public static native boolean nativeDeviceSupportsVFPFP16();
|
||||
|
||||
@DoNotStrip
|
||||
public static native boolean nativeDeviceSupportsX86();
|
||||
}
|
||||
@@ -1,139 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.jni;
|
||||
|
||||
import java.lang.ref.PhantomReference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* A thread which invokes the "destruct" routine for objects after they have been garbage collected.
|
||||
*
|
||||
* <p>An object which needs to be destructed should create a static subclass of {@link Destructor}.
|
||||
* Once the referent object is garbage collected, the DestructorThread will callback to the {@link
|
||||
* Destructor#destruct()} method.
|
||||
*
|
||||
* <p>The underlying thread in DestructorThread starts when the first Destructor is constructed and
|
||||
* then runs indefinitely.
|
||||
*/
|
||||
public class DestructorThread {
|
||||
|
||||
/**
|
||||
* N.B The Destructor <b>SHOULD NOT</b> refer back to its referent object either explicitly or
|
||||
* implicitly (for example, as a non-static inner class). This will create a reference cycle where
|
||||
* the referent object will never be garbage collected.
|
||||
*/
|
||||
public abstract static class Destructor extends PhantomReference<Object> {
|
||||
|
||||
private Destructor next;
|
||||
private Destructor previous;
|
||||
|
||||
public Destructor(Object referent) {
|
||||
super(referent, sReferenceQueue);
|
||||
sDestructorStack.push(this);
|
||||
}
|
||||
|
||||
private Destructor() {
|
||||
super(null, sReferenceQueue);
|
||||
}
|
||||
|
||||
/** Callback which is invoked when the original object has been garbage collected. */
|
||||
protected abstract void destruct();
|
||||
}
|
||||
|
||||
/** A list to keep all active Destructors in memory confined to the Destructor thread. */
|
||||
private static DestructorList sDestructorList;
|
||||
/** A thread safe stack where new Destructors are placed before being add to sDestructorList. */
|
||||
private static DestructorStack sDestructorStack;
|
||||
|
||||
private static ReferenceQueue sReferenceQueue;
|
||||
private static Thread sThread;
|
||||
|
||||
static {
|
||||
sDestructorStack = new DestructorStack();
|
||||
sReferenceQueue = new ReferenceQueue();
|
||||
sDestructorList = new DestructorList();
|
||||
sThread =
|
||||
new Thread("HybridData DestructorThread") {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
Destructor current = (Destructor) sReferenceQueue.remove();
|
||||
current.destruct();
|
||||
|
||||
// If current is in the sDestructorStack,
|
||||
// transfer all the Destructors in the stack to the list.
|
||||
if (current.previous == null) {
|
||||
sDestructorStack.transferAllToList();
|
||||
}
|
||||
|
||||
DestructorList.drop(current);
|
||||
} catch (InterruptedException e) {
|
||||
// Continue. This thread should never be terminated.
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
sThread.start();
|
||||
}
|
||||
|
||||
private static class Terminus extends Destructor {
|
||||
@Override
|
||||
protected void destruct() {
|
||||
throw new IllegalStateException("Cannot destroy Terminus Destructor.");
|
||||
}
|
||||
}
|
||||
|
||||
/** This is a thread safe, lock-free Treiber-like Stack of Destructors. */
|
||||
private static class DestructorStack {
|
||||
private AtomicReference<Destructor> mHead = new AtomicReference<>();
|
||||
|
||||
public void push(Destructor newHead) {
|
||||
Destructor oldHead;
|
||||
do {
|
||||
oldHead = mHead.get();
|
||||
newHead.next = oldHead;
|
||||
} while (!mHead.compareAndSet(oldHead, newHead));
|
||||
}
|
||||
|
||||
public void transferAllToList() {
|
||||
Destructor current = mHead.getAndSet(null);
|
||||
while (current != null) {
|
||||
Destructor next = current.next;
|
||||
sDestructorList.enqueue(current);
|
||||
current = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** A doubly-linked list of Destructors. */
|
||||
private static class DestructorList {
|
||||
private Destructor mHead;
|
||||
|
||||
public DestructorList() {
|
||||
mHead = new Terminus();
|
||||
mHead.next = new Terminus();
|
||||
mHead.next.previous = mHead;
|
||||
}
|
||||
|
||||
public void enqueue(Destructor current) {
|
||||
current.next = mHead.next;
|
||||
mHead.next = current;
|
||||
|
||||
current.next.previous = current;
|
||||
current.previous = mHead;
|
||||
}
|
||||
|
||||
private static void drop(Destructor current) {
|
||||
current.next.previous = current.previous;
|
||||
current.previous.next = current.next;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.jni;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
|
||||
@DoNotStrip
|
||||
public abstract class HybridClassBase extends HybridData {}
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.jni;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
/**
|
||||
* This object holds a native C++ member for hybrid Java/C++ objects.
|
||||
*
|
||||
* <p>NB: THREAD SAFETY
|
||||
*
|
||||
* <p>{@link #resetNative} deletes the corresponding native object synchronously on whatever thread
|
||||
* the method is called on. Otherwise, deletion will occur on the {@link DestructorThread} thread.
|
||||
*/
|
||||
@DoNotStrip
|
||||
public class HybridData {
|
||||
|
||||
static {
|
||||
SoLoader.loadLibrary("fb");
|
||||
}
|
||||
|
||||
@DoNotStrip private Destructor mDestructor = new Destructor(this);
|
||||
|
||||
/**
|
||||
* To explicitly delete the instance, call resetNative(). If the C++ instance is referenced after
|
||||
* this is called, a NullPointerException will be thrown. resetNative() may be called multiple
|
||||
* times safely. Because the {@link DestructorThread} also calls resetNative, the instance will
|
||||
* not leak if this is not called, but timing of deletion and the thread the C++ dtor is called on
|
||||
* will be at the whim of the Java GC. If you want to control the thread and timing of the
|
||||
* destructor, you should call resetNative() explicitly.
|
||||
*/
|
||||
public synchronized void resetNative() {
|
||||
mDestructor.destruct();
|
||||
}
|
||||
|
||||
/**
|
||||
* N.B. Thread safety. If you call isValid from a different thread than {@link #resetNative()}
|
||||
* then be sure to do so while synchronizing on the hybrid. For example:
|
||||
*
|
||||
* <pre><code>
|
||||
* synchronized(hybrid) {
|
||||
* if (hybrid.isValid) {
|
||||
* // Do stuff.
|
||||
* }
|
||||
* }
|
||||
* </code></pre>
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return mDestructor.mNativePointer != 0;
|
||||
}
|
||||
|
||||
public static class Destructor extends DestructorThread.Destructor {
|
||||
|
||||
// Private C++ instance
|
||||
@DoNotStrip private long mNativePointer;
|
||||
|
||||
Destructor(Object referent) {
|
||||
super(referent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void destruct() {
|
||||
// When invoked from the DestructorThread instead of resetNative,
|
||||
// the DestructorThread has exclusive ownership of the HybridData
|
||||
// so synchronization is not necessary.
|
||||
deleteNative(mNativePointer);
|
||||
mNativePointer = 0;
|
||||
}
|
||||
|
||||
static native void deleteNative(long pointer);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.jni;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* To iterate over an Iterator from C++ requires two calls per entry: hasNext() and next(). This
|
||||
* helper reduces it to one call and one field get per entry. It does not use a generic argument,
|
||||
* since in C++, the types will be erased, anyway. This is *not* a {@link java.util.Iterator}.
|
||||
*/
|
||||
@DoNotStrip
|
||||
public class IteratorHelper {
|
||||
private final Iterator mIterator;
|
||||
|
||||
// This is private, but accessed via JNI.
|
||||
@DoNotStrip private @Nullable Object mElement;
|
||||
|
||||
@DoNotStrip
|
||||
public IteratorHelper(Iterator iterator) {
|
||||
mIterator = iterator;
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
public IteratorHelper(Iterable iterable) {
|
||||
mIterator = iterable.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the helper to the next entry in the map, if any. Returns true iff there is an entry to
|
||||
* read.
|
||||
*/
|
||||
@DoNotStrip
|
||||
boolean hasNext() {
|
||||
if (mIterator.hasNext()) {
|
||||
mElement = mIterator.next();
|
||||
return true;
|
||||
} else {
|
||||
mElement = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.jni;
|
||||
|
||||
public class JniTerminateHandler {
|
||||
public static void handleTerminate(Throwable t) throws Throwable {
|
||||
Thread.UncaughtExceptionHandler h = Thread.getDefaultUncaughtExceptionHandler();
|
||||
if (h == null) {
|
||||
// Odd. Let the default std::terminate_handler deal with it.
|
||||
return;
|
||||
}
|
||||
h.uncaughtException(Thread.currentThread(), t);
|
||||
// That should exit. If it doesn't, let the default handler deal with it.
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.jni;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* To iterate over a Map from C++ requires four calls per entry: hasNext(), next(), getKey(),
|
||||
* getValue(). This helper reduces it to one call and two field gets per entry. It does not use a
|
||||
* generic argument, since in C++, the types will be erased, anyway. This is *not* a {@link
|
||||
* java.util.Iterator}.
|
||||
*/
|
||||
@DoNotStrip
|
||||
public class MapIteratorHelper {
|
||||
@DoNotStrip private final Iterator<Map.Entry> mIterator;
|
||||
@DoNotStrip private @Nullable Object mKey;
|
||||
@DoNotStrip private @Nullable Object mValue;
|
||||
|
||||
@DoNotStrip
|
||||
public MapIteratorHelper(Map map) {
|
||||
mIterator = map.entrySet().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the helper to the next entry in the map, if any. Returns true iff there is an entry to
|
||||
* read.
|
||||
*/
|
||||
@DoNotStrip
|
||||
boolean hasNext() {
|
||||
if (mIterator.hasNext()) {
|
||||
Map.Entry entry = mIterator.next();
|
||||
mKey = entry.getKey();
|
||||
mValue = entry.getValue();
|
||||
return true;
|
||||
} else {
|
||||
mKey = null;
|
||||
mValue = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.jni;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
|
||||
/** A Runnable that has a native run implementation. */
|
||||
@DoNotStrip
|
||||
public class NativeRunnable implements Runnable {
|
||||
|
||||
@DoNotStrip private final HybridData mHybridData;
|
||||
|
||||
@DoNotStrip
|
||||
private NativeRunnable(HybridData hybridData) {
|
||||
mHybridData = hybridData;
|
||||
}
|
||||
|
||||
public native void run();
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.jni;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
@DoNotStrip
|
||||
public class ThreadScopeSupport {
|
||||
static {
|
||||
SoLoader.loadLibrary("fb");
|
||||
}
|
||||
|
||||
// This is just used for ThreadScope::withClassLoader to have a java function
|
||||
// in the stack so that jni has access to the correct classloader.
|
||||
@DoNotStrip
|
||||
private static void runStdFunction(long ptr) {
|
||||
runStdFunctionImpl(ptr);
|
||||
}
|
||||
|
||||
private static native void runStdFunctionImpl(long ptr);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
# For common use cases for the hybrid pattern, keep symbols which may
|
||||
# be referenced only from C++.
|
||||
|
||||
-keepclassmembers class * {
|
||||
com.facebook.jni.HybridData *;
|
||||
<init>(com.facebook.jni.HybridData);
|
||||
}
|
||||
|
||||
-keepclasseswithmembers class * {
|
||||
com.facebook.jni.HybridData *;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ rn_android_library(
|
||||
react_native_target("java/com/facebook/react/turbomodule/core:callinvokerholder"),
|
||||
] + ([react_native_target("jni/react/jni:jni")] if not IS_OSS_BUILD else []),
|
||||
exported_deps = [
|
||||
react_native_dep("java/com/facebook/jni:jni"),
|
||||
react_native_dep("libraries/fbjni:java"),
|
||||
react_native_dep("java/com/facebook/proguard/annotations:annotations"),
|
||||
react_native_dep("third-party/java/jsr-330:jsr-330"),
|
||||
react_native_target("java/com/facebook/react/bridge:interfaces"),
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "StateWrapperImpl.h"
|
||||
|
||||
#import <better/set.h>
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <jsi/JSIDynamic.h>
|
||||
#include <jsi/jsi.h>
|
||||
#include <react/components/scrollview/ScrollViewProps.h>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/jni/JMessageQueueThread.h>
|
||||
#include <react/jni/ReadableNativeMap.h>
|
||||
#include <react/uimanager/Scheduler.h>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "ComponentFactoryDelegate.h"
|
||||
#include <android/log.h>
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <jsi/jsi.h>
|
||||
#include <react/uimanager/ComponentDescriptorRegistry.h>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <jsi/jsi.h>
|
||||
#include <react/uimanager/ComponentDescriptorRegistry.h>
|
||||
#include <react/uimanager/Scheduler.h>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "EventBeatManager.h"
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
using namespace facebook::jni;
|
||||
|
||||
namespace facebook {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/core/EventBeat.h>
|
||||
#include <react/utils/RuntimeExecutor.h>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "EventEmitterWrapper.h"
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
|
||||
using namespace facebook::jni;
|
||||
|
||||
@@ -33,4 +33,4 @@ void EventEmitterWrapper::registerNatives() {
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
} // namespace facebook
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/core/EventEmitter.h>
|
||||
#include <react/jni/ReadableNativeMap.h>
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "NodeStateWrapper.h"
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/jni/ReadableNativeMap.h>
|
||||
|
||||
using namespace facebook::jni;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/core/State.h>
|
||||
#include <react/jni/ReadableNativeMap.h>
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fb/xplat_init.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
|
||||
#include "Binding.h"
|
||||
#include "EventBeatManager.h"
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
|
||||
#import "ReactNativeConfigHolder.h"
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
|
||||
using namespace facebook::react;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/config/ReactNativeConfig.h>
|
||||
#include <react/jni/JMessageQueueThread.h>
|
||||
#include <react/jni/ReadableNativeMap.h>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "StateWrapperImpl.h"
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/jni/ReadableNativeMap.h>
|
||||
|
||||
using namespace facebook::jni;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <react/core/State.h>
|
||||
#include <react/jni/ReadableNativeMap.h>
|
||||
|
||||
|
||||
@@ -16,6 +16,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)
|
||||
LOCAL_CFLAGS += -fvisibility=hidden -fexceptions -frtti
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := libjsi libjsireact jscruntime
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libreactnativejni
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <jsi/JSCRuntime.h>
|
||||
#include <jsireact/JSIExecutor.h>
|
||||
#include <react/jni/JReactMarker.h>
|
||||
|
||||
@@ -16,6 +16,6 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)
|
||||
LOCAL_CFLAGS += -fvisibility=hidden -fexceptions -frtti
|
||||
|
||||
LOCAL_STATIC_LIBRARIES := libjsi libjsireact
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libreactnativejni
|
||||
LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "BlobCollector.h"
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <jsi/jsi.h>
|
||||
|
||||
namespace facebook {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
|
||||
#include "BlobCollector.h"
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ rn_android_library(
|
||||
],
|
||||
deps = [
|
||||
react_native_dep("third-party/android/androidx:annotation"),
|
||||
react_native_dep("java/com/facebook/jni:jni"),
|
||||
react_native_dep("libraries/fbjni:java"),
|
||||
react_native_dep("java/com/facebook/proguard/annotations:annotations"),
|
||||
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"),
|
||||
react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"),
|
||||
|
||||
@@ -43,6 +43,6 @@ rn_android_library(
|
||||
deps = [
|
||||
react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"),
|
||||
react_native_target("java/com/facebook/react/turbomodule/core/interfaces:interfaces"),
|
||||
react_native_dep("java/com/facebook/jni:jni"),
|
||||
react_native_dep("libraries/fbjni:java"),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -17,7 +17,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall
|
||||
|
||||
LOCAL_STATIC_LIBRARIES = libcallinvoker
|
||||
|
||||
LOCAL_SHARED_LIBRARIES = libfb
|
||||
LOCAL_SHARED_LIBRARIES = libfb libfbjni
|
||||
|
||||
# Name of this module.
|
||||
LOCAL_MODULE := callinvokerholder
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <ReactCommon/CallInvoker.h>
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <memory>
|
||||
|
||||
namespace facebook {
|
||||
|
||||
+1
-1
@@ -5,8 +5,8 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fb/xplat_init.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
|
||||
#include "TurboModuleManager.h"
|
||||
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <jsi/jsi.h>
|
||||
|
||||
#include <ReactCommon/TurboCxxModule.h>
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
#include <ReactCommon/JavaTurboModule.h>
|
||||
#include <ReactCommon/TurboModule.h>
|
||||
#include <ReactCommon/TurboModuleManagerDelegate.h>
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <jsi/jsi.h>
|
||||
#include <react/jni/CxxModuleWrapper.h>
|
||||
#include <react/jni/JMessageQueueThread.h>
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <ReactCommon/CallInvoker.h>
|
||||
#include <ReactCommon/JavaTurboModule.h>
|
||||
#include <fb/fbjni.h>
|
||||
#include <fbjni/fbjni.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user