mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
Make ReactModuleInfoProvider use string keys
Summary: `ReactModuleInfoProvider` was using `Class` as the keys. This would make the classes to load. This change makes the map use canonicalName Strings of the classes, removing the need for the classes to load at this point. Reviewed By: achen1 Differential Revision: D8944078 fbshipit-source-id: 4aa562d74d6ad3ebb9962b581d4e2f5e89d47ca6
This commit is contained in:
parent
9176fc00b5
commit
d891ee1dee
@ -49,12 +49,12 @@ public class NativeModuleRegistryBuilder {
|
||||
if (reactPackage instanceof LazyReactPackage) {
|
||||
LazyReactPackage lazyReactPackage = (LazyReactPackage) reactPackage;
|
||||
List<ModuleSpec> moduleSpecs = lazyReactPackage.getNativeModules(mReactApplicationContext);
|
||||
Map<Class, ReactModuleInfo> reactModuleInfoMap = lazyReactPackage.getReactModuleInfoProvider()
|
||||
.getReactModuleInfos();
|
||||
Map<String, ReactModuleInfo> reactModuleInfoMap =
|
||||
lazyReactPackage.getReactModuleInfoProvider().getReactModuleInfos();
|
||||
|
||||
for (ModuleSpec moduleSpec : moduleSpecs) {
|
||||
Class<? extends NativeModule> type = moduleSpec.getType();
|
||||
ReactModuleInfo reactModuleInfo = reactModuleInfoMap.get(type);
|
||||
ReactModuleInfo reactModuleInfo = reactModuleInfoMap.get(type.getCanonicalName());
|
||||
ModuleHolder moduleHolder;
|
||||
if (reactModuleInfo == null) {
|
||||
if (BaseJavaModule.class.isAssignableFrom(type)) {
|
||||
|
@ -12,5 +12,5 @@ import java.util.Map;
|
||||
*/
|
||||
public interface ReactModuleInfoProvider {
|
||||
|
||||
Map<Class, ReactModuleInfo> getReactModuleInfos();
|
||||
Map<String, ReactModuleInfo> getReactModuleInfos();
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
|
||||
private static final TypeName COLLECTIONS_TYPE = ParameterizedTypeName.get(Collections.class);
|
||||
private static final TypeName MAP_TYPE = ParameterizedTypeName.get(
|
||||
Map.class,
|
||||
Class.class,
|
||||
String.class,
|
||||
ReactModuleInfo.class);
|
||||
private static final TypeName INSTANTIATED_MAP_TYPE = ParameterizedTypeName.get(HashMap.class);
|
||||
|
||||
@ -155,7 +155,7 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
|
||||
builder.addStatement("$T map = new $T()", MAP_TYPE, INSTANTIATED_MAP_TYPE);
|
||||
|
||||
for (String nativeModule : nativeModules) {
|
||||
String keyString = nativeModule + ".class";
|
||||
String keyString = nativeModule;
|
||||
|
||||
TypeElement typeElement = mElements.getTypeElement(nativeModule);
|
||||
if (typeElement == null) {
|
||||
@ -191,7 +191,7 @@ public class ReactModuleSpecProcessor extends AbstractProcessor {
|
||||
.append(")")
|
||||
.toString();
|
||||
|
||||
builder.addStatement("map.put(" + keyString + ", " + valueString + ")");
|
||||
builder.addStatement("map.put(\"" + keyString + "\", " + valueString + ")");
|
||||
}
|
||||
builder.addStatement("return map");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user