mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
fix nullsafe FIXMEs for NativeModuleRegistry.java and mark nullsafe
Summary: Gone trough all the FIXMEs added in the previous diff by the nullsafe tool, marked the class as nullsafe and ensured no remaining violations. Changelog: [Android][Fixed] Made NativeModuleRegistry.java nullsafe Reviewed By: javache Differential Revision: D72384075 fbshipit-source-id: bebc637a757c9f86d6260f9076010de9d7c80d4a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
695df351ba
commit
8aaccef2ee
+8
-2
@@ -8,6 +8,7 @@
|
||||
package com.facebook.react.bridge;
|
||||
|
||||
import com.facebook.infer.annotation.Assertions;
|
||||
import com.facebook.infer.annotation.Nullsafe;
|
||||
import com.facebook.react.common.annotations.internal.LegacyArchitecture;
|
||||
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel;
|
||||
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
|
||||
@@ -20,6 +21,7 @@ import java.util.Map;
|
||||
|
||||
/** A set of Java APIs to expose to a particular JavaScript instance. */
|
||||
@LegacyArchitecture
|
||||
@Nullsafe(Nullsafe.Mode.LOCAL)
|
||||
public class NativeModuleRegistry {
|
||||
|
||||
private final ReactApplicationContext mReactApplicationContext;
|
||||
@@ -125,8 +127,12 @@ public class NativeModuleRegistry {
|
||||
}
|
||||
|
||||
public <T extends NativeModule> boolean hasModule(Class<T> moduleInterface) {
|
||||
// NULLSAFE_FIXME[Nullable Dereference]
|
||||
String name = moduleInterface.getAnnotation(ReactModule.class).name();
|
||||
ReactModule annotation = moduleInterface.getAnnotation(ReactModule.class);
|
||||
if (annotation == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Could not find @ReactModule annotation in class " + moduleInterface.getName());
|
||||
}
|
||||
String name = annotation.name();
|
||||
return mModules.containsKey(name);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user