mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
trigger codegenned reflection if module is a turbomodule (#36672)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36672 Changelog: [Internal] if we look at usages of ReactModuleWithSpec, we see that it's existence was to simply identify generated native modules since the inheritance graph of native modules was different if they were generated. this was introduced before we created the TurboModule interface, which all codegenned native modules also conform to. since that exists now, there's no need for both of these. this is the only callsite in our code where ReactModuleWithSpec triggers any logic, so i'm updating it. bypass-github-export-checks Reviewed By: javache Differential Revision: D44450687 fbshipit-source-id: f9c26fce8e360b6e319153aad83fc788079bac91
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e4a0a02d6a
commit
bd7aa2c82d
+2
-1
@@ -16,6 +16,7 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.config.ReactFeatureFlags;
|
||||
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
||||
import com.facebook.systrace.Systrace;
|
||||
import com.facebook.systrace.SystraceMessage;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -71,7 +72,7 @@ public class JavaModuleWrapper {
|
||||
Class<? extends NativeModule> classForMethods = mModuleHolder.getModule().getClass();
|
||||
Class<? extends NativeModule> superClass =
|
||||
(Class<? extends NativeModule>) classForMethods.getSuperclass();
|
||||
if (ReactModuleWithSpec.class.isAssignableFrom(superClass)) {
|
||||
if (TurboModule.class.isAssignableFrom(superClass)) {
|
||||
// For java module that is based on generated flow-type spec, inspect the
|
||||
// spec abstract class instead, which is the super class of the given java
|
||||
// module.
|
||||
|
||||
+2
-2
@@ -14,11 +14,11 @@ import com.facebook.react.bridge.Dynamic;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.Promise;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.bridge.ReactModuleWithSpec;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.WritableArray;
|
||||
import com.facebook.react.bridge.WritableMap;
|
||||
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -112,7 +112,7 @@ public class TurboModuleInteropUtils {
|
||||
Class<? extends NativeModule> classForMethods = module.getClass();
|
||||
Class<? extends NativeModule> superClass =
|
||||
(Class<? extends NativeModule>) classForMethods.getSuperclass();
|
||||
if (ReactModuleWithSpec.class.isAssignableFrom(superClass)) {
|
||||
if (TurboModule.class.isAssignableFrom(superClass)) {
|
||||
// For java module that is based on generated flow-type spec, inspect the
|
||||
// spec abstract class instead, which is the super class of the given java
|
||||
// module.
|
||||
|
||||
@@ -40,6 +40,7 @@ rn_robolectric_test(
|
||||
react_native_dep("third-party/java/junit:junit"),
|
||||
react_native_target("java/com/facebook/react/bridge:bridge"),
|
||||
react_native_target("java/com/facebook/react/common:common"),
|
||||
react_native_target("java/com/facebook/react/turbomodule/core/interfaces:interfaces"),
|
||||
react_native_target("java/com/facebook/react/uimanager:uimanager"),
|
||||
react_native_tests_target("java/com/facebook/common/logging:logging"),
|
||||
],
|
||||
|
||||
+2
-1
@@ -10,6 +10,7 @@ package com.facebook.react.bridge;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
import java.util.List;
|
||||
import org.junit.Before;
|
||||
@@ -127,7 +128,7 @@ public class BaseJavaModuleTest {
|
||||
}
|
||||
|
||||
private abstract class NativeTestGeneratedModuleSpec extends BaseJavaModule
|
||||
implements ReactModuleWithSpec {
|
||||
implements TurboModule {
|
||||
@ReactMethod
|
||||
public abstract void generatedMethod(String a, int b);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user