From cfa03db98b8fdb163869965eec0731b93b49058f Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Sat, 11 Mar 2023 16:59:39 -0800 Subject: [PATCH] Refactor: In JavaTurboModule, use jobject to hold module object Summary: ## Rationale JavaTurboModule holds the module object as a JTurboModule. With the TurboModule inteorp layer, JavaTurboModule will also need to hold NativeModule objects. ## Changes So, this diff makes JavaTurboModule hold the module object as a jobject instead. This shouldn't impact method dispatch, because method dispatch doesn't rely on the JTurboModule interface. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D43918939 fbshipit-source-id: 7cc43dfe2df7571e39bcf4d6f362dde0e500e2fe --- .../core/platform/android/ReactCommon/JavaTurboModule.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h index 3581fedea2..89881890bc 100644 --- a/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h +++ b/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h @@ -30,7 +30,7 @@ class JSI_EXPORT JavaTurboModule : public TurboModule { // TODO(T65603471): Should we unify this with a Fabric abstraction? struct InitParams { std::string moduleName; - jni::alias_ref instance; + jni::alias_ref instance; std::shared_ptr jsInvoker; std::shared_ptr nativeInvoker; }; @@ -48,7 +48,8 @@ class JSI_EXPORT JavaTurboModule : public TurboModule { jmethodID &cachedMethodID); private: - jni::global_ref instance_; + // instance_ can be of type JTurboModule, or JNativeModule + jni::global_ref instance_; std::shared_ptr nativeInvoker_; };