Skip to content

Commit 9859fbc

Browse files
philIipfacebook-github-bot
authored andcommitted
cleanup warnOnLegacyNativeModuleSystemUse (#39417)
Summary: Pull Request resolved: #39417 ## Changelog [Android][Breaking] - Deleting warnOnLegacyNativeModuleSystemUse this has not fired in over a year, we should clean it up. there's an argument we want to keep this for consumers that are in the middle of upgrading, but personally i think that this needs to be built into the interop layer - currently we can only configure this in Fb specific infra. Reviewed By: cortinico Differential Revision: D49209540 fbshipit-source-id: 0e2bb293999ad356e564a0acf069211a7a205f21
1 parent 9faf256 commit 9859fbc

File tree

6 files changed

+0
-82
lines changed

6 files changed

+0
-82
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,6 @@ private CatalystInstanceImpl(
140140
FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge before initializeBridge");
141141
Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "initializeCxxBridge");
142142

143-
if (ReactFeatureFlags.warnOnLegacyNativeModuleSystemUse) {
144-
warnOnLegacyNativeModuleSystemUse();
145-
}
146-
147143
initializeBridge(
148144
new BridgeCallback(this),
149145
jsExecutor,
@@ -211,8 +207,6 @@ public void extendNativeModules(NativeModuleRegistry modules) {
211207
private native void jniExtendNativeModules(
212208
Collection<JavaModuleWrapper> javaModules, Collection<ModuleHolder> cxxModules);
213209

214-
private native void warnOnLegacyNativeModuleSystemUse();
215-
216210
private native void initializeBridge(
217211
ReactCallback callback,
218212
JavaScriptExecutor jsExecutor,

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

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import androidx.annotation.Nullable;
1717
import com.facebook.proguard.annotations.DoNotStrip;
18-
import com.facebook.react.config.ReactFeatureFlags;
1918
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
2019
import com.facebook.systrace.Systrace;
2120
import com.facebook.systrace.SystraceMessage;
@@ -116,17 +115,6 @@ public List<MethodDescriptor> getMethodDescriptors() {
116115

117116
@DoNotStrip
118117
public @Nullable NativeMap getConstants() {
119-
if (ReactFeatureFlags.warnOnLegacyNativeModuleSystemUse) {
120-
ReactSoftExceptionLogger.logSoftException(
121-
TAG,
122-
new ReactNoCrashSoftException(
123-
"Calling getConstants() on Java NativeModule (name = \""
124-
+ mModuleHolder.getName()
125-
+ "\", className = "
126-
+ mModuleHolder.getClassName()
127-
+ ")."));
128-
}
129-
130118
if (!mModuleHolder.getHasConstants()) {
131119
return null;
132120
}
@@ -158,34 +146,10 @@ public List<MethodDescriptor> getMethodDescriptors() {
158146

159147
@DoNotStrip
160148
public void invoke(int methodId, ReadableNativeArray parameters) {
161-
if (ReactFeatureFlags.warnOnLegacyNativeModuleSystemUse) {
162-
ReactSoftExceptionLogger.logSoftException(
163-
TAG,
164-
new ReactNoCrashSoftException(
165-
"Calling method on Java NativeModule (name = \""
166-
+ mModuleHolder.getName()
167-
+ "\", className = "
168-
+ mModuleHolder.getClassName()
169-
+ ")."));
170-
}
171-
172149
if (mMethods == null || methodId >= mMethods.size()) {
173150
return;
174151
}
175152

176-
if (ReactFeatureFlags.warnOnLegacyNativeModuleSystemUse) {
177-
ReactSoftExceptionLogger.logSoftException(
178-
TAG,
179-
new ReactNoCrashSoftException(
180-
"Calling "
181-
+ mDescs.get(methodId).name
182-
+ "() on Java NativeModule (name = \""
183-
+ mModuleHolder.getName()
184-
+ "\", className = "
185-
+ mModuleHolder.getClassName()
186-
+ ")."));
187-
}
188-
189153
mMethods.get(methodId).invoke(mJSInstance, parameters);
190154
}
191155
}

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package com.facebook.react.bridge;
99

1010
import com.facebook.infer.annotation.Assertions;
11-
import com.facebook.react.config.ReactFeatureFlags;
1211
import com.facebook.react.module.annotations.ReactModule;
1312
import com.facebook.systrace.Systrace;
1413
import java.util.ArrayList;
@@ -42,17 +41,6 @@ private ReactApplicationContext getReactApplicationContext() {
4241
ArrayList<JavaModuleWrapper> javaModules = new ArrayList<>();
4342
for (Map.Entry<String, ModuleHolder> entry : mModules.entrySet()) {
4443
if (!entry.getValue().isCxxModule()) {
45-
if (ReactFeatureFlags.warnOnLegacyNativeModuleSystemUse) {
46-
ReactSoftExceptionLogger.logSoftException(
47-
TAG,
48-
new ReactNoCrashSoftException(
49-
"Registering legacy NativeModule: Java NativeModule (name = \""
50-
+ entry.getValue().getName()
51-
+ "\", className = "
52-
+ entry.getValue().getClassName()
53-
+ ")."));
54-
}
55-
5644
javaModules.add(new JavaModuleWrapper(jsInstance, entry.getValue()));
5745
}
5846
}
@@ -63,16 +51,6 @@ private ReactApplicationContext getReactApplicationContext() {
6351
ArrayList<ModuleHolder> cxxModules = new ArrayList<>();
6452
for (Map.Entry<String, ModuleHolder> entry : mModules.entrySet()) {
6553
if (entry.getValue().isCxxModule()) {
66-
if (ReactFeatureFlags.warnOnLegacyNativeModuleSystemUse) {
67-
ReactSoftExceptionLogger.logSoftException(
68-
TAG,
69-
new ReactNoCrashSoftException(
70-
"Registering legacy NativeModule: Cxx NativeModule (name = \""
71-
+ entry.getValue().getName()
72-
+ "\", className = "
73-
+ entry.getValue().getClassName()
74-
+ ")."));
75-
}
7654
cxxModules.add(entry.getValue());
7755
}
7856
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ public class ReactFeatureFlags {
7474
/** Does the bridgeless architecture use the new create/reload/destroy routines */
7575
public static volatile boolean enableBridgelessArchitectureNewCreateReloadDestroy = false;
7676

77-
/**
78-
* After TurboModules and Fabric are enabled, we need to ensure that the legacy NativeModule isn't
79-
* isn't used. So, turn this flag on to trigger warnings whenever the legacy NativeModule system
80-
* is used.
81-
*/
82-
public static volatile boolean warnOnLegacyNativeModuleSystemUse = false;
83-
8477
/** This feature flag enables logs for Fabric */
8578
public static boolean enableFabricLogs = false;
8679

packages/react-native/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ CatalystInstanceImpl::initHybrid(jni::alias_ref<jclass>) {
9999
CatalystInstanceImpl::CatalystInstanceImpl()
100100
: instance_(std::make_unique<Instance>()) {}
101101

102-
void CatalystInstanceImpl::warnOnLegacyNativeModuleSystemUse() {
103-
CxxNativeModule::setShouldWarnOnUse(true);
104-
}
105-
106102
void CatalystInstanceImpl::registerNatives() {
107103
registerHybrid({
108104
makeNativeMethod("initHybrid", CatalystInstanceImpl::initHybrid),
@@ -140,9 +136,6 @@ void CatalystInstanceImpl::registerNatives() {
140136
"getRuntimeExecutor", CatalystInstanceImpl::getRuntimeExecutor),
141137
makeNativeMethod(
142138
"getRuntimeScheduler", CatalystInstanceImpl::getRuntimeScheduler),
143-
makeNativeMethod(
144-
"warnOnLegacyNativeModuleSystemUse",
145-
CatalystInstanceImpl::warnOnLegacyNativeModuleSystemUse),
146139
});
147140
}
148141

packages/react-native/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ class CatalystInstanceImpl : public jni::HybridClass<CatalystInstanceImpl> {
6262
jni::alias_ref<jni::JCollection<ModuleHolder::javaobject>::javaobject>
6363
cxxModules);
6464

65-
// When called from CatalystInstanceImpl.java, warnings will be logged when
66-
// CxxNativeModules are used. Java NativeModule usages log error in Java.
67-
void warnOnLegacyNativeModuleSystemUse();
68-
6965
void extendNativeModules(
7066
jni::alias_ref<jni::JCollection<
7167
JavaModuleWrapper::javaobject>::javaobject> javaModules,

0 commit comments

Comments
 (0)