diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AbstractScrollViewTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AbstractScrollViewTestCase.java index afdf4bc90..159fee03e 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AbstractScrollViewTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/AbstractScrollViewTestCase.java @@ -40,8 +40,7 @@ public abstract class AbstractScrollViewTestCase extends ReactAppInstrumentation protected ReactInstanceSpecForTest createReactInstanceSpecForTest() { mScrollListenerModule = new ScrollListenerModule(); return super.createReactInstanceSpecForTest() - .addNativeModule(mScrollListenerModule) - .addJSModule(ScrollViewTestModule.class); + .addNativeModule(mScrollListenerModule); } // See ScrollViewListenerModule.js diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/InstanceSpecForTestPackage.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/InstanceSpecForTestPackage.java index fe7a2df02..9def548b0 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/InstanceSpecForTestPackage.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/InstanceSpecForTestPackage.java @@ -36,11 +36,6 @@ public class InstanceSpecForTestPackage implements ReactPackage { return mSpecForTest.getExtraNativeModulesForTest(); } - @Override - public List> createJSModules() { - return mSpecForTest.getExtraJSModulesForTest(); - } - @Override public List createViewManagers(ReactApplicationContext reactContext) { return mSpecForTest.getExtraViewManagers(); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstanceSpecForTest.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstanceSpecForTest.java index bf179010b..0a17e29b7 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstanceSpecForTest.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactInstanceSpecForTest.java @@ -38,11 +38,6 @@ public class ReactInstanceSpecForTest { return this; } - public ReactInstanceSpecForTest addJSModule(Class jsClass) { - mJSModuleSpecs.add(jsClass); - return this; - } - public ReactInstanceSpecForTest setPackage(ReactPackage reactPackage) { mReactPackage = reactPackage; return this; @@ -57,10 +52,6 @@ public class ReactInstanceSpecForTest { return mNativeModules; } - public List> getExtraJSModulesForTest() { - return mJSModuleSpecs; - } - public ReactPackage getAlternativeReactPackageForTest() { return mReactPackage; } diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestFactory.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestFactory.java index f77aa1665..95dc551ba 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestFactory.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestFactory.java @@ -18,7 +18,6 @@ public interface ReactTestFactory { public static interface ReactInstanceEasyBuilder { ReactInstanceEasyBuilder setContext(Context context); ReactInstanceEasyBuilder addNativeModule(NativeModule module); - ReactInstanceEasyBuilder addJSModule(Class moduleInterfaceClass); CatalystInstance build(); } diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestHelper.java b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestHelper.java index 1349655a0..79f10a822 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestHelper.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/ReactTestHelper.java @@ -16,6 +16,7 @@ import android.support.test.InstrumentationRegistry; import android.view.View; import android.view.ViewGroup; +import com.facebook.infer.annotation.Assertions; import com.facebook.react.NativeModuleRegistryBuilder; import com.facebook.react.R; import com.facebook.react.ReactInstanceManager; @@ -39,8 +40,6 @@ public class ReactTestHelper { private static class DefaultReactTestFactory implements ReactTestFactory { private static class ReactInstanceEasyBuilderImpl implements ReactInstanceEasyBuilder { - private final JavaScriptModuleRegistry.Builder mJSModuleRegistryBuilder = - new JavaScriptModuleRegistry.Builder(); private NativeModuleRegistryBuilder mNativeModuleRegistryBuilder; private @Nullable Context mContext; @@ -59,16 +58,11 @@ public class ReactTestHelper { null, false); } + Assertions.assertNotNull(nativeModule); mNativeModuleRegistryBuilder.addNativeModule(nativeModule); return this; } - @Override - public ReactInstanceEasyBuilder addJSModule(Class moduleInterfaceClass) { - mJSModuleRegistryBuilder.add(moduleInterfaceClass); - return this; - } - @Override public CatalystInstance build() { if (mNativeModuleRegistryBuilder == null) { @@ -87,7 +81,6 @@ public class ReactTestHelper { .setReactQueueConfigurationSpec(ReactQueueConfigurationSpec.createDefault()) .setJSExecutor(executor) .setRegistry(mNativeModuleRegistryBuilder.build()) - .setJSModuleRegistry(mJSModuleRegistryBuilder.build()) .setJSBundleLoader(JSBundleLoader.createAssetLoader( mContext, "assets://AndroidTestBundle.js", @@ -141,12 +134,6 @@ public class ReactTestHelper { return this; } - @Override - public ReactTestFactory.ReactInstanceEasyBuilder addJSModule(Class moduleInterfaceClass) { - builder.addJSModule(moduleInterfaceClass); - return this; - } - @Override public CatalystInstance build() { final CatalystInstance instance = builder.build(); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystMeasureLayoutTest.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystMeasureLayoutTest.java index ba34dda08..eb5a7e9d3 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystMeasureLayoutTest.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystMeasureLayoutTest.java @@ -74,9 +74,8 @@ public class CatalystMeasureLayoutTest extends ReactAppInstrumentationTestCase { @Override protected ReactInstanceSpecForTest createReactInstanceSpecForTest() { mAssertModule = new AssertModule(); - return new ReactInstanceSpecForTest() - .addNativeModule(mAssertModule) - .addJSModule(MeasureLayoutTestModule.class); + return super.createReactInstanceSpecForTest() + .addNativeModule(mAssertModule); } private void waitForBridgeIdleAndVerifyAsserts() { diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java index c0b40ef16..bf1e2e99a 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJSToJavaParametersTestCase.java @@ -109,7 +109,6 @@ public class CatalystNativeJSToJavaParametersTestCase extends ReactIntegrationTe .addNativeModule(new AppStateModule(getContext())) .addNativeModule(new FakeWebSocketModule()) .addNativeModule(mUIManager) - .addJSModule(TestJSToJavaParametersModule.class) .build(); } diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java index 0d077c3c2..bc5b3c52d 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSArgumentsTestCase.java @@ -85,7 +85,6 @@ public class CatalystNativeJavaToJSArgumentsTestCase extends ReactIntegrationTes .addNativeModule(new DeviceInfoModule(getContext())) .addNativeModule(new AppStateModule(getContext())) .addNativeModule(new FakeWebSocketModule()) - .addJSModule(TestJavaToJSArgumentsModule.class) .addNativeModule(mUIManager) .build(); } diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSReturnValuesTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSReturnValuesTestCase.java index c69be53b7..52c1d5ff0 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSReturnValuesTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystNativeJavaToJSReturnValuesTestCase.java @@ -126,7 +126,6 @@ public class CatalystNativeJavaToJSReturnValuesTestCase extends ReactIntegration .addNativeModule(new DeviceInfoModule(getContext())) .addNativeModule(new AppStateModule(getContext())) .addNativeModule(new FakeWebSocketModule()) - .addJSModule(TestJavaToJSReturnValuesModule.class) .addNativeModule(mUIManager) .addNativeModule(new TestModule()) .build(); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystSubviewsClippingTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystSubviewsClippingTestCase.java index 04f1f8a2e..6f7f5831f 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystSubviewsClippingTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystSubviewsClippingTestCase.java @@ -51,10 +51,8 @@ public class CatalystSubviewsClippingTestCase extends ReactAppInstrumentationTes @Override protected ReactInstanceSpecForTest createReactInstanceSpecForTest() { - ReactInstanceSpecForTest instanceSpec = new ReactInstanceSpecForTest(); - instanceSpec.addJSModule(SubviewsClippingTestModule.class); - instanceSpec.addViewManager(new ClippableViewManager(mEvents)); - return instanceSpec; + return super.createReactInstanceSpecForTest() + .addViewManager(new ClippableViewManager(mEvents)); } /** diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java index a0d65c9bc..8cbe26aa5 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/CatalystUIManagerTestCase.java @@ -99,7 +99,6 @@ public class CatalystUIManagerTestCase extends ReactIntegrationTestCase { .addNativeModule(new DeviceInfoModule(getContext())) .addNativeModule(new AppStateModule(getContext())) .addNativeModule(new FakeWebSocketModule()) - .addJSModule(UIManagerTestModule.class) .build() .getJSModule(UIManagerTestModule.class); } diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/DatePickerDialogTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/DatePickerDialogTestCase.java index 2ca86f482..4b6e2fd2a 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/DatePickerDialogTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/DatePickerDialogTestCase.java @@ -80,8 +80,7 @@ public class DatePickerDialogTestCase extends ReactAppInstrumentationTestCase { @Override protected ReactInstanceSpecForTest createReactInstanceSpecForTest() { return super.createReactInstanceSpecForTest() - .addNativeModule(mRecordingModule) - .addJSModule(DatePickerDialogTestModule.class); + .addNativeModule(mRecordingModule); } @Override diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java index 4c524e020..aed5e222c 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/JSLocaleTest.java @@ -66,7 +66,6 @@ public class JSLocaleTest extends ReactIntegrationTestCase { .addNativeModule(new DeviceInfoModule(getContext())) .addNativeModule(new AppStateModule(getContext())) .addNativeModule(new FakeWebSocketModule()) - .addJSModule(TestJSLocaleModule.class) .build(); } diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java index ea99a3ed7..5a0650aa5 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ProgressBarTestCase.java @@ -90,7 +90,6 @@ public class ProgressBarTestCase extends ReactIntegrationTestCase { .addNativeModule(new DeviceInfoModule(getContext())) .addNativeModule(new AppStateModule(getContext())) .addNativeModule(new FakeWebSocketModule()) - .addJSModule(ProgressBarTestModule.class) .build(); mRootView = new ReactRootView(getContext()); diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactPickerTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactPickerTestCase.java index 5ad6d82e6..dd93ee5fc 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactPickerTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactPickerTestCase.java @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ - + package com.facebook.react.tests; import java.util.ArrayList; @@ -68,7 +68,6 @@ public class ReactPickerTestCase extends ReactAppInstrumentationTestCase { protected ReactInstanceSpecForTest createReactInstanceSpecForTest() { mRecordingModule = new PickerAndroidRecordingModule(); return super.createReactInstanceSpecForTest() - .addJSModule(PickerAndroidTestModule.class) .addNativeModule(mRecordingModule); } diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactSwipeRefreshLayoutTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactSwipeRefreshLayoutTestCase.java index 1026be3c7..bbef082ff 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactSwipeRefreshLayoutTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ReactSwipeRefreshLayoutTestCase.java @@ -55,8 +55,7 @@ public class ReactSwipeRefreshLayoutTestCase extends ReactAppInstrumentationTest @Override protected ReactInstanceSpecForTest createReactInstanceSpecForTest() { return super.createReactInstanceSpecForTest() - .addNativeModule(mRecordingModule) - .addJSModule(SwipeRefreshLayoutTestModule.class); + .addNativeModule(mRecordingModule); } public void testRefreshNoScroll() { diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ShareTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ShareTestCase.java index 13ef775f3..184bda6c1 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ShareTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ShareTestCase.java @@ -73,8 +73,7 @@ public class ShareTestCase extends ReactAppInstrumentationTestCase { @Override protected ReactInstanceSpecForTest createReactInstanceSpecForTest() { return super.createReactInstanceSpecForTest() - .addNativeModule(mRecordingModule) - .addJSModule(ShareTestModule.class); + .addNativeModule(mRecordingModule); } @Override diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TextInputTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TextInputTestCase.java index 9eff4494c..08d19cae1 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TextInputTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TextInputTestCase.java @@ -248,7 +248,6 @@ public class TextInputTestCase extends ReactAppInstrumentationTestCase { @Override protected ReactInstanceSpecForTest createReactInstanceSpecForTest() { return super.createReactInstanceSpecForTest() - .addJSModule(TextInputTestModule.class) .addNativeModule(mRecordingModule); } diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TimePickerDialogTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TimePickerDialogTestCase.java index 516170de4..3988911c4 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TimePickerDialogTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/TimePickerDialogTestCase.java @@ -77,8 +77,7 @@ public class TimePickerDialogTestCase extends ReactAppInstrumentationTestCase { @Override protected ReactInstanceSpecForTest createReactInstanceSpecForTest() { return super.createReactInstanceSpecForTest() - .addNativeModule(mRecordingModule) - .addJSModule(TimePickerDialogTestModule.class); + .addNativeModule(mRecordingModule); } @Override diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java index daacff84f..bd1028418 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/ViewRenderingTestCase.java @@ -71,7 +71,6 @@ public class ViewRenderingTestCase extends ReactIntegrationTestCase { .addNativeModule(new DeviceInfoModule(getContext())) .addNativeModule(new AppStateModule(getContext())) .addNativeModule(new FakeWebSocketModule()) - .addJSModule(ViewRenderingTestModule.class) .build(); mRootView = new ReactRootView(getContext()); diff --git a/ReactAndroid/src/main/java/com/facebook/react/CompositeReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/CompositeReactPackage.java index f2d6e7776..e7695c8a5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/CompositeReactPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/CompositeReactPackage.java @@ -84,20 +84,6 @@ public class CompositeReactPackage extends ReactInstancePackage { return new ArrayList(moduleMap.values()); } - /** - * {@inheritDoc} - */ - @Override - public List> createJSModules() { - final Set> moduleSet = new HashSet<>(); - for (ReactPackage reactPackage: mChildReactPackages) { - for (Class jsModule: reactPackage.createJSModules()) { - moduleSet.add(jsModule); - } - } - return new ArrayList(moduleSet); - } - /** * {@inheritDoc} */ diff --git a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java index 1c17559bb..5bafb73d0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java @@ -12,27 +12,21 @@ package com.facebook.react; import javax.inject.Provider; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; -import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.ModuleSpec; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactMarker; import com.facebook.react.common.build.ReactBuildConfig; -import com.facebook.react.devsupport.HMRClient; import com.facebook.react.devsupport.JSCHeapCapture; import com.facebook.react.devsupport.JSCSamplingProfiler; import com.facebook.react.module.annotations.ReactModuleList; import com.facebook.react.module.model.ReactModuleInfoProvider; -import com.facebook.react.modules.appregistry.AppRegistry; import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; import com.facebook.react.modules.core.DeviceEventManagerModule; import com.facebook.react.modules.core.ExceptionsManagerModule; import com.facebook.react.modules.core.HeadlessJsTaskSupportModule; -import com.facebook.react.modules.core.JSTimersExecution; -import com.facebook.react.modules.core.RCTNativeAppEventEmitter; import com.facebook.react.modules.core.Timing; import com.facebook.react.modules.debug.AnimationsDebugModule; import com.facebook.react.modules.debug.SourceCodeModule; @@ -42,7 +36,6 @@ import com.facebook.react.uimanager.UIImplementationProvider; import com.facebook.react.uimanager.UIManagerModule; import com.facebook.react.uimanager.ViewManager; import com.facebook.react.uimanager.debug.DebugComponentOwnershipModule; -import com.facebook.react.uimanager.events.RCTEventEmitter; import com.facebook.systrace.Systrace; import static com.facebook.react.bridge.ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_END; @@ -187,26 +180,6 @@ import static com.facebook.react.bridge.ReactMarkerConstants.PROCESS_CORE_REACT_ return moduleSpecList; } - @Override - public List> createJSModules() { - List> jsModules = new ArrayList<>(Arrays.asList( - DeviceEventManagerModule.RCTDeviceEventEmitter.class, - JSTimersExecution.class, - RCTEventEmitter.class, - RCTNativeAppEventEmitter.class, - AppRegistry.class, - com.facebook.react.bridge.Systrace.class, - HMRClient.class)); - - if (ReactBuildConfig.DEBUG) { - jsModules.add(DebugComponentOwnershipModule.RCTDebugComponentOwnership.class); - jsModules.add(JSCHeapCapture.HeapCapture.class); - jsModules.add(JSCSamplingProfiler.SamplingProfiler.class); - } - - return jsModules; - } - @Override public ReactModuleInfoProvider getReactModuleInfoProvider() { // This has to be done via reflection or we break open source. diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index 6a8c9fabe..9339282e9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -926,7 +926,6 @@ public class ReactInstanceManager { reactContext, this, mLazyNativeModulesEnabled); - JavaScriptModuleRegistry.Builder jsModulesBuilder = new JavaScriptModuleRegistry.Builder(); if (mUseDeveloperSupport) { reactContext.setNativeModuleCallExceptionHandler(mDevSupportManager); } @@ -942,7 +941,7 @@ public class ReactInstanceManager { mBackBtnHandler, mUIImplementationProvider, mLazyViewManagersEnabled); - processPackage(coreModulesPackage, nativeModuleRegistryBuilder, jsModulesBuilder); + processPackage(coreModulesPackage, nativeModuleRegistryBuilder); } finally { Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); } @@ -953,7 +952,7 @@ public class ReactInstanceManager { TRACE_TAG_REACT_JAVA_BRIDGE, "createAndProcessCustomReactPackage"); try { - processPackage(reactPackage, nativeModuleRegistryBuilder, jsModulesBuilder); + processPackage(reactPackage, nativeModuleRegistryBuilder); } finally { Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); } @@ -979,7 +978,6 @@ public class ReactInstanceManager { ReactQueueConfigurationSpec.createDefault()) .setJSExecutor(jsExecutor) .setRegistry(nativeModuleRegistry) - .setJSModuleRegistry(jsModulesBuilder.build()) .setJSBundleLoader(jsBundleLoader) .setNativeModuleCallExceptionHandler(exceptionHandler); @@ -1010,8 +1008,7 @@ public class ReactInstanceManager { private void processPackage( ReactPackage reactPackage, - NativeModuleRegistryBuilder nativeModuleRegistryBuilder, - JavaScriptModuleRegistry.Builder jsModulesBuilder) { + NativeModuleRegistryBuilder nativeModuleRegistryBuilder) { SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processPackage") .arg("className", reactPackage.getClass().getSimpleName()) .flush(); @@ -1020,9 +1017,6 @@ public class ReactInstanceManager { } nativeModuleRegistryBuilder.processPackage(reactPackage); - for (Class jsModuleClass : reactPackage.createJSModules()) { - jsModulesBuilder.add(jsModuleClass); - } if (reactPackage instanceof ReactPackageLogger) { ((ReactPackageLogger) reactPackage).endProcessPackage(); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/ReactPackage.java index f11c2408c..fb1f8517d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactPackage.java @@ -38,15 +38,6 @@ public interface ReactPackage { */ List createNativeModules(ReactApplicationContext reactContext); - /** - * @return list of JS modules to register with the newly created catalyst instance. - * - * IMPORTANT: Note that only modules that needs to be accessible from the native code should be - * listed here. Also listing a native module here doesn't imply that the JS implementation of it - * will be automatically included in the JS bundle. - */ - List> createJSModules(); - /** * @return a list of view managers that should be registered with {@link UIManagerModule} */ diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java index 0395b00d7..3a2f82659 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java @@ -541,10 +541,6 @@ public class CatalystInstanceImpl implements CatalystInstance { return this; } - public Builder setJSModuleRegistry(JavaScriptModuleRegistry jsModuleRegistry) { - return this; - } - public Builder setJSBundleLoader(JSBundleLoader jsBundleLoader) { mJSBundleLoader = jsBundleLoader; return this; diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptModuleRegistry.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptModuleRegistry.java index a758c3610..6062e81db 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptModuleRegistry.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/JavaScriptModuleRegistry.java @@ -48,16 +48,6 @@ public final class JavaScriptModuleRegistry { return (T) interfaceProxy; } - public static class Builder { - public Builder add(Class moduleInterfaceClass) { - return this; - } - - public JavaScriptModuleRegistry build() { - return new JavaScriptModuleRegistry(); - } - } - private static class JavaScriptModuleInvocationHandler implements InvocationHandler { private final CatalystInstance mCatalystInstance; private final Class mModuleInterface; diff --git a/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java index cb35735d7..1d2e839ec 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java @@ -247,11 +247,6 @@ public class MainReactPackage extends LazyReactPackage { })); } - @Override - public List> createJSModules() { - return Collections.emptyList(); - } - @Override public List createViewManagers(ReactApplicationContext reactContext) { List viewManagers = new ArrayList<>(); diff --git a/ReactAndroid/src/test/java/com/facebook/react/CompositeReactPackageTest.java b/ReactAndroid/src/test/java/com/facebook/react/CompositeReactPackageTest.java index 38e2dce48..d6eb53327 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/CompositeReactPackageTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/CompositeReactPackageTest.java @@ -15,7 +15,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; @@ -68,20 +67,6 @@ public class CompositeReactPackageTest { verify(packageNo3).createNativeModules(reactContext); } - @Test - public void testThatCreateJSModulesIsCalledOnAllPackages() { - // Given - CompositeReactPackage composite = new CompositeReactPackage(packageNo1, packageNo2, packageNo3); - - // When - composite.createJSModules(); - - // Then - verify(packageNo1).createJSModules(); - verify(packageNo2).createJSModules(); - verify(packageNo3).createJSModules(); - } - @Test public void testThatCreateViewManagersIsCalledOnAllPackages() { // Given @@ -176,43 +161,4 @@ public class CompositeReactPackageTest { assertEquals(expected, actual); } - - // public access level is required by Mockito - public static class JavaScriptModuleNo1 implements JavaScriptModule {}; - public static class JavaScriptModuleNo2 implements JavaScriptModule {}; - public static class JavaScriptModuleNo3 implements JavaScriptModule {}; - - @Test - public void testThatCompositeReturnsASumOfJSModules() { - // Given - CompositeReactPackage composite = new CompositeReactPackage(packageNo1, packageNo2); - - Class moduleNo1 = mock(JavaScriptModuleNo1.class).getClass(); - Class moduleNo2 = mock(JavaScriptModuleNo2.class).getClass(); - Class moduleNo3 = mock(JavaScriptModuleNo3.class).getClass(); - - List> l1 = new ArrayList<>(); - l1.add(moduleNo1); - when(packageNo1.createJSModules()).thenReturn(l1); - - List> l2 = new ArrayList<>(); - l2.add(moduleNo2); - l2.add(moduleNo3); - when(packageNo2.createJSModules()).thenReturn(l2); - - // When - List> compositeModules = composite.createJSModules(); - - // Then - - // wrapping lists into sets to be order-independent - List> l3 = new ArrayList<>(); - l3.add(moduleNo1); - l3.add(moduleNo2); - l3.add(moduleNo3); - Set> expected = new HashSet<>(l3); - Set> actual = new HashSet<>(compositeModules); - - assertEquals(expected, actual); - } } diff --git a/docs/NativeModulesAndroid.md b/docs/NativeModulesAndroid.md index 1fb2bc33e..799d43764 100644 --- a/docs/NativeModulesAndroid.md +++ b/docs/NativeModulesAndroid.md @@ -102,7 +102,6 @@ The last step within Java is to register the Module; this happens in the `create package com.facebook.react.modules.toast; import com.facebook.react.ReactPackage; -import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; @@ -113,11 +112,6 @@ import java.util.List; public class AnExampleReactPackage implements ReactPackage { - @Override - public List> createJSModules() { - return Collections.emptyList(); - } - @Override public List createViewManagers(ReactApplicationContext reactContext) { return Collections.emptyList(); diff --git a/local-cli/core/__fixtures__/files/ReactPackage.java b/local-cli/core/__fixtures__/files/ReactPackage.java index b1ea14632..a884062d8 100644 --- a/local-cli/core/__fixtures__/files/ReactPackage.java +++ b/local-cli/core/__fixtures__/files/ReactPackage.java @@ -1,7 +1,6 @@ package com.some.example; import com.facebook.react.ReactPackage; -import com.facebook.react.bridge.JavaScriptModule; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.uimanager.ViewManager; @@ -13,8 +12,6 @@ import java.util.List; public class SomeExamplePackage implements ReactPackage { - public SomeExamplePackage() {} - @Override public List createNativeModules( ReactApplicationContext reactContext) { @@ -23,11 +20,6 @@ public class SomeExamplePackage implements ReactPackage { return modules; } - @Override - public List> createJSModules() { - return Collections.emptyList(); - } - @Override public List createViewManagers(ReactApplicationContext reactContext) { return Collections.emptyList();