|
15 | 15 |
|
16 | 16 | import androidx.annotation.Nullable;
|
17 | 17 | import com.facebook.proguard.annotations.DoNotStrip;
|
| 18 | +import com.facebook.react.config.ReactFeatureFlags; |
18 | 19 | import com.facebook.systrace.Systrace;
|
19 | 20 | import com.facebook.systrace.SystraceMessage;
|
20 | 21 | import java.lang.reflect.Method;
|
@@ -43,6 +44,7 @@ public class MethodDescriptor {
|
43 | 44 | private final ModuleHolder mModuleHolder;
|
44 | 45 | private final ArrayList<NativeModule.NativeMethod> mMethods;
|
45 | 46 | private final ArrayList<MethodDescriptor> mDescs;
|
| 47 | + private static final String TAG = JavaModuleWrapper.class.getSimpleName(); |
46 | 48 |
|
47 | 49 | public JavaModuleWrapper(JSInstance jsInstance, ModuleHolder moduleHolder) {
|
48 | 50 | mJSInstance = jsInstance;
|
@@ -113,6 +115,17 @@ public List<MethodDescriptor> getMethodDescriptors() {
|
113 | 115 |
|
114 | 116 | @DoNotStrip
|
115 | 117 | public @Nullable NativeMap getConstants() {
|
| 118 | + if (ReactFeatureFlags.warnOnLegacyNativeModuleSystemUse) { |
| 119 | + ReactSoftExceptionLogger.logSoftException( |
| 120 | + TAG, |
| 121 | + new ReactNoCrashSoftException( |
| 122 | + "Calling getConstants() on Java NativeModule (name = \"" |
| 123 | + + mModuleHolder.getName() |
| 124 | + + "\", className = " |
| 125 | + + mModuleHolder.getClassName() |
| 126 | + + ").")); |
| 127 | + } |
| 128 | + |
116 | 129 | if (!mModuleHolder.getHasConstants()) {
|
117 | 130 | return null;
|
118 | 131 | }
|
@@ -144,10 +157,34 @@ public List<MethodDescriptor> getMethodDescriptors() {
|
144 | 157 |
|
145 | 158 | @DoNotStrip
|
146 | 159 | public void invoke(int methodId, ReadableNativeArray parameters) {
|
| 160 | + if (ReactFeatureFlags.warnOnLegacyNativeModuleSystemUse) { |
| 161 | + ReactSoftExceptionLogger.logSoftException( |
| 162 | + TAG, |
| 163 | + new ReactNoCrashSoftException( |
| 164 | + "Calling method on Java NativeModule (name = \"" |
| 165 | + + mModuleHolder.getName() |
| 166 | + + "\", className = " |
| 167 | + + mModuleHolder.getClassName() |
| 168 | + + ").")); |
| 169 | + } |
| 170 | + |
147 | 171 | if (mMethods == null || methodId >= mMethods.size()) {
|
148 | 172 | return;
|
149 | 173 | }
|
150 | 174 |
|
| 175 | + if (ReactFeatureFlags.warnOnLegacyNativeModuleSystemUse) { |
| 176 | + ReactSoftExceptionLogger.logSoftException( |
| 177 | + TAG, |
| 178 | + new ReactNoCrashSoftException( |
| 179 | + "Calling " |
| 180 | + + mDescs.get(methodId).name |
| 181 | + + "() on Java NativeModule (name = \"" |
| 182 | + + mModuleHolder.getName() |
| 183 | + + "\", className = " |
| 184 | + + mModuleHolder.getClassName() |
| 185 | + + ").")); |
| 186 | + } |
| 187 | + |
151 | 188 | mMethods.get(methodId).invoke(mJSInstance, parameters);
|
152 | 189 | }
|
153 | 190 | }
|
0 commit comments