diff --git a/ReactAndroid/src/main/java/com/facebook/react/BUCK b/ReactAndroid/src/main/java/com/facebook/react/BUCK index 8f6ccfd11ee2e9..1d8a7bc4c74383 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/BUCK @@ -5,6 +5,8 @@ DEPS = [ 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/devsupport:devsupport'), + react_native_target('java/com/facebook/react/module/annotations:annotations'), + react_native_target('java/com/facebook/react/module/model:model'), react_native_target('java/com/facebook/react/modules/core:core'), react_native_target('java/com/facebook/react/modules/debug:debug'), react_native_target('java/com/facebook/react/modules/systeminfo:systeminfo'), diff --git a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java index 51f4776c5b72d3..f490595cd27abb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/CoreModulesPackage.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import com.facebook.react.bridge.JavaScriptModule; @@ -23,6 +24,7 @@ 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.modules.core.DefaultHardwareBackBtnHandler; import com.facebook.react.modules.core.DeviceEventManagerModule; import com.facebook.react.modules.core.ExceptionsManagerModule; @@ -45,6 +47,18 @@ * require special integration with other framework parts (e.g. with the list of packages to load * view managers from). */ +@ReactModuleList({ + AnimationsDebugModule.class, + AndroidInfoModule.class, + DeviceEventManagerModule.class, + ExceptionsManagerModule.class, + Timing.class, + SourceCodeModule.class, + UIManagerModule.class, + DebugComponentOwnershipModule.class, + JSCHeapCapture.class, + JSCSamplingProfiler.class, +}) /* package */ class CoreModulesPackage extends LazyReactPackage { private final ReactInstanceManager mReactInstanceManager; @@ -62,7 +76,7 @@ @Override public List getNativeModules(final ReactApplicationContext reactContext) { - List moduleSpecList = new ArrayList(); + List moduleSpecList = new ArrayList<>(); moduleSpecList.add( new ModuleSpec(AnimationsDebugModule.class, new Provider() { @Override @@ -164,7 +178,7 @@ public List> createJSModules() { @Override public List createViewManagers(ReactApplicationContext reactContext) { - return new ArrayList<>(0); + return Collections.emptyList(); } private UIManagerModule createUIManager(ReactApplicationContext reactContext) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK b/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK index a619b50902e200..791cf31ef335a2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/BUCK @@ -15,6 +15,7 @@ android_library( react_native_target('java/com/facebook/react/bridge:bridge'), react_native_target('java/com/facebook/react/common/network:network'), react_native_target('java/com/facebook/react/common:common'), + react_native_target('java/com/facebook/react/module/annotations:annotations'), react_native_target('java/com/facebook/react/modules/debug:debug'), react_native_target('java/com/facebook/react/modules/systeminfo:systeminfo'), react_native_target('res:devsupport'), diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java index a8824fd7923553..7db70f572a33a4 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java @@ -20,7 +20,9 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; +import com.facebook.react.module.annotations.ReactModule; +@ReactModule(name = "JSCHeapCapture") public class JSCHeapCapture extends ReactContextBaseJavaModule { public interface HeapCapture extends JavaScriptModule { void captureHeap(String path); diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCSamplingProfiler.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCSamplingProfiler.java index 89a03e8020c4c4..4a35aa74d01de9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCSamplingProfiler.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCSamplingProfiler.java @@ -11,7 +11,6 @@ import javax.annotation.Nullable; -import java.io.File; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -20,7 +19,9 @@ import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; +import com.facebook.react.module.annotations.ReactModule; +@ReactModule(name = "JSCSamplingProfiler") public class JSCSamplingProfiler extends ReactContextBaseJavaModule { public interface SamplingProfiler extends JavaScriptModule { void poke(int token); diff --git a/ReactAndroid/src/main/java/com/facebook/react/module/processing/ReactModuleSpecProcessor.java b/ReactAndroid/src/main/java/com/facebook/react/module/processing/ReactModuleSpecProcessor.java index 63cb066997dc51..4d582c9a9c099a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/module/processing/ReactModuleSpecProcessor.java +++ b/ReactAndroid/src/main/java/com/facebook/react/module/processing/ReactModuleSpecProcessor.java @@ -139,7 +139,8 @@ private CodeBlock getCodeBlockForReactModuleInfos(List nativeModules) TypeElement typeElement = mElements.getTypeElement(nativeModule); ReactModule reactModule = typeElement.getAnnotation(ReactModule.class); if (reactModule == null) { - throw new ReactModuleSpecException(keyString + " not found."); + throw new ReactModuleSpecException(keyString + " not found by ReactModuleSpecProcessor. " + + "Did you forget to add the @ReactModule annotation the the native module?"); } String valueString = new StringBuilder() .append("new ReactModuleInfo(") diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK index 3a0956b2754ebc..1c4d06fe911bcc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BUCK @@ -18,6 +18,7 @@ android_library( react_native_target('java/com/facebook/react/animation:animation'), 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/module/annotations:annotations'), react_native_target('java/com/facebook/react/modules/i18nmanager:i18nmanager'), react_native_target('java/com/facebook/react/touch:touch'), react_native_target('java/com/facebook/react/uimanager/annotations:annotations'), diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java index 7e6c389cda9185..f0d9938ea8f9dc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIManagerModule.java @@ -27,6 +27,7 @@ import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.common.ReactConstants; +import com.facebook.react.module.annotations.ReactModule; import com.facebook.react.uimanager.debug.NotThreadSafeViewHierarchyUpdateDebugListener; import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.systrace.Systrace; @@ -37,12 +38,12 @@ * *

*

== Transactional Requirement ==

- * A requirement of this class is to make sure that transactional UI updates occur all at once, meaning - * that no intermediate state is ever rendered to the screen. For example, if a JS application - * update changes the background of View A to blue and the width of View B to 100, both need to - * appear at once. Practically, this means that all UI update code related to a single transaction - * must be executed as a single code block on the UI thread. Executing as multiple code blocks - * could allow the platform UI system to interrupt and render a partial UI state. + * A requirement of this class is to make sure that transactional UI updates occur all at once, + * meaning that no intermediate state is ever rendered to the screen. For example, if a JS + * application update changes the background of View A to blue and the width of View B to 100, both + * need to appear at once. Practically, this means that all UI update code related to a single + * transaction must be executed as a single code block on the UI thread. Executing as multiple code + * blocks could allow the platform UI system to interrupt and render a partial UI state. *

* *

To facilitate this, this module enqueues operations that are then applied to native view @@ -61,6 +62,7 @@ * consider implementing a pool * TODO(5483063): Don't dispatch the view hierarchy at the end of a batch if no UI changes occurred */ +@ReactModule(name = "RKUIManager") public class UIManagerModule extends ReactContextBaseJavaModule implements OnBatchCompleteListener, LifecycleEventListener, PerformanceCounter { diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/DebugComponentOwnershipModule.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/DebugComponentOwnershipModule.java index 3500d64f915ffd..a38af1d06004a1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/DebugComponentOwnershipModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/debug/DebugComponentOwnershipModule.java @@ -20,12 +20,14 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; +import com.facebook.react.module.annotations.ReactModule; /** * Native module that can asynchronously request the owners hierarchy of a react tag. * * Example returned owner hierarchy: ['RootView', 'Dialog', 'TitleView', 'Text'] */ +@ReactModule(name = "DebugComponentOwnershipModule") public class DebugComponentOwnershipModule extends ReactContextBaseJavaModule { public interface RCTDebugComponentOwnership extends JavaScriptModule {