diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapper.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapper.java index a50ced0771ea1a..40928a6c6c0c58 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapper.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapper.java @@ -9,7 +9,6 @@ import com.facebook.jni.HybridData; import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.soloader.SoLoader; /** This does nothing interesting, except avoid breaking existing code. */ @DoNotStrip @@ -17,12 +16,4 @@ public class CxxModuleWrapper extends CxxModuleWrapperBase { protected CxxModuleWrapper(HybridData hd) { super(hd); } - - private static native CxxModuleWrapper makeDsoNative(String soPath, String factory); - - public static CxxModuleWrapper makeDso(String library, String factory) { - SoLoader.loadLibrary(library); - String soPath = SoLoader.unpackLibraryAndDependencies(library).getAbsolutePath(); - return makeDsoNative(soPath, factory); - } } diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/CxxModuleWrapper.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/jni/CxxModuleWrapper.cpp deleted file mode 100644 index 82db6c3d03bf65..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/CxxModuleWrapper.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include "CxxModuleWrapper.h" - -#include - -#include - -#include - -using namespace facebook::jni; -using namespace facebook::xplat::module; - -namespace facebook::react { - -jni::local_ref CxxModuleWrapper::makeDsoNative( - jni::alias_ref, - const std::string& soPath, - const std::string& fname) { - // soPath is the path of a library which has already been loaded by - // java SoLoader.loadLibrary(). So this returns the same handle, - // and increments the reference counter. We can't just use - // dlsym(RTLD_DEFAULT, ...), because that crashes on 4.4.2 and - // earlier: https://code.google.com/p/android/issues/detail?id=61799 - void* handle = dlopen(soPath.c_str(), RTLD_NOW); - if (!handle) { - throwNewJavaException( - gJavaLangIllegalArgumentException, - "module shared library %s is not found", - soPath.c_str()); - } - // Now, arrange to close the handle so the counter is decremented. - // The handle will remain valid until java closes it. There's no - // way to do this on Android, but that's no reason to be sloppy - // here. - auto guard = folly::makeGuard([&] { CHECK(dlclose(handle) == 0); }); - - void* sym = dlsym(handle, fname.c_str()); - if (!sym) { - throwNewJavaException( - gJavaLangIllegalArgumentException, - "module function %s in shared library %s is not found", - fname.c_str(), - soPath.c_str()); - } - auto factory = reinterpret_cast(sym); - - return CxxModuleWrapper::newObjectCxxArgs( - std::unique_ptr((*factory)())); -} - -} // namespace facebook::react diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/CxxModuleWrapper.h b/packages/react-native/ReactAndroid/src/main/jni/react/jni/CxxModuleWrapper.h index 5cbb95966c2fc3..80747e18f8d5d8 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/CxxModuleWrapper.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jni/CxxModuleWrapper.h @@ -17,16 +17,6 @@ class CxxModuleWrapper constexpr static const char* const kJavaDescriptor = "Lcom/facebook/react/bridge/CxxModuleWrapper;"; - static void registerNatives() { - registerHybrid( - {makeNativeMethod("makeDsoNative", CxxModuleWrapper::makeDsoNative)}); - } - - static jni::local_ref makeDsoNative( - jni::alias_ref, - const std::string& soPath, - const std::string& fname); - std::string getName() override { return module_->getName(); } diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp index a3a60afb27feab..6b37fefee6576c 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp @@ -14,7 +14,7 @@ #include #include "CatalystInstanceImpl.h" -#include "CxxModuleWrapper.h" +#include "CxxModuleWrapperBase.h" #include "JCallback.h" #include "JReactMarker.h" #include "JavaScriptExecutorHolder.h" @@ -78,7 +78,6 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { ProxyJavaScriptExecutorHolder::registerNatives(); CatalystInstanceImpl::registerNatives(); CxxModuleWrapperBase::registerNatives(); - CxxModuleWrapper::registerNatives(); JCxxCallbackImpl::registerNatives(); NativeArray::registerNatives(); ReadableNativeArray::registerNatives();