Skip to content

Commit bd7aa2c

Browse files
philIipfacebook-github-bot
authored andcommitted
trigger codegenned reflection if module is a turbomodule (#36672)
Summary: Pull Request resolved: #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
1 parent e4a0a02 commit bd7aa2c

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaModuleWrapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import androidx.annotation.Nullable;
1717
import com.facebook.proguard.annotations.DoNotStrip;
1818
import com.facebook.react.config.ReactFeatureFlags;
19+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
1920
import com.facebook.systrace.Systrace;
2021
import com.facebook.systrace.SystraceMessage;
2122
import java.lang.reflect.Method;
@@ -71,7 +72,7 @@ private void findMethods() {
7172
Class<? extends NativeModule> classForMethods = mModuleHolder.getModule().getClass();
7273
Class<? extends NativeModule> superClass =
7374
(Class<? extends NativeModule>) classForMethods.getSuperclass();
74-
if (ReactModuleWithSpec.class.isAssignableFrom(superClass)) {
75+
if (TurboModule.class.isAssignableFrom(superClass)) {
7576
// For java module that is based on generated flow-type spec, inspect the
7677
// spec abstract class instead, which is the super class of the given java
7778
// module.

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/TurboModuleInteropUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
import com.facebook.react.bridge.NativeModule;
1515
import com.facebook.react.bridge.Promise;
1616
import com.facebook.react.bridge.ReactMethod;
17-
import com.facebook.react.bridge.ReactModuleWithSpec;
1817
import com.facebook.react.bridge.ReadableArray;
1918
import com.facebook.react.bridge.ReadableMap;
2019
import com.facebook.react.bridge.WritableArray;
2120
import com.facebook.react.bridge.WritableMap;
21+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
2222
import java.lang.reflect.Method;
2323
import java.util.ArrayList;
2424
import java.util.HashSet;
@@ -112,7 +112,7 @@ private static Method[] getMethodsFromModule(NativeModule module) {
112112
Class<? extends NativeModule> classForMethods = module.getClass();
113113
Class<? extends NativeModule> superClass =
114114
(Class<? extends NativeModule>) classForMethods.getSuperclass();
115-
if (ReactModuleWithSpec.class.isAssignableFrom(superClass)) {
115+
if (TurboModule.class.isAssignableFrom(superClass)) {
116116
// For java module that is based on generated flow-type spec, inspect the
117117
// spec abstract class instead, which is the super class of the given java
118118
// module.

packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ rn_robolectric_test(
4040
react_native_dep("third-party/java/junit:junit"),
4141
react_native_target("java/com/facebook/react/bridge:bridge"),
4242
react_native_target("java/com/facebook/react/common:common"),
43+
react_native_target("java/com/facebook/react/turbomodule/core/interfaces:interfaces"),
4344
react_native_target("java/com/facebook/react/uimanager:uimanager"),
4445
react_native_tests_target("java/com/facebook/common/logging:logging"),
4546
],

packages/react-native/ReactAndroid/src/test/java/com/facebook/react/bridge/BaseJavaModuleTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import static org.mockito.Mockito.when;
1111

1212
import android.content.Context;
13+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
1314
import com.facebook.soloader.SoLoader;
1415
import java.util.List;
1516
import org.junit.Before;
@@ -127,7 +128,7 @@ public int syncMethod(int a, int b) {
127128
}
128129

129130
private abstract class NativeTestGeneratedModuleSpec extends BaseJavaModule
130-
implements ReactModuleWithSpec {
131+
implements TurboModule {
131132
@ReactMethod
132133
public abstract void generatedMethod(String a, int b);
133134
}

0 commit comments

Comments
 (0)