Skip to content

Commit

Permalink
deprecate hasConstants from ReactModuleInfo (#39459)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #39459

## Changelog
[Android][Deprecated] - ReactModuleInfo constructor with getConstants arg is deprecated

introducing a new constructor that doesn't use getConstants and updating the internal codebase to use it. deprecated the old one since it's been copypasta'd a lot in oss.

Reviewed By: cortinico

Differential Revision: D49262824

fbshipit-source-id: 1a4d36b3153d8ce0ee869b8635c94005fe7c9594
  • Loading branch information
philIip authored and facebook-github-bot committed Sep 16, 2023
1 parent 4919741 commit 9f52378
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public Map<String, ReactModuleInfo> getReactModuleInfos() {
moduleClass.getName(),
reactModule.canOverrideExistingModule(),
reactModule.needsEagerInit(),
reactModule.hasConstants(),
reactModule.isCxxModule(),
false));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ public ReactModuleInfoProvider getReactModuleInfoProvider() {
moduleClass.getName(),
reactModule.canOverrideExistingModule(),
reactModule.needsEagerInit(),
reactModule.hasConstants(),
reactModule.isCxxModule(),
TurboModule.class.isAssignableFrom(moduleClass)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public ReactModuleInfoProvider getReactModuleInfoProvider() {
moduleClass.getName(),
reactModule.canOverrideExistingModule(),
reactModule.needsEagerInit(),
reactModule.hasConstants(),
reactModule.isCxxModule(),
TurboModule.class.isAssignableFrom(moduleClass)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,13 @@ protected ReactPackageTurboModuleManagerDelegate(
moduleClass.getName(),
reactModule.canOverrideExistingModule(),
true,
reactModule.hasConstants(),
reactModule.isCxxModule(),
TurboModule.class.isAssignableFrom(moduleClass))
: new ReactModuleInfo(
moduleName,
moduleClass.getName(),
module.canOverrideExistingModule(),
true,
true,
CxxModuleWrapper.class.isAssignableFrom(moduleClass),
TurboModule.class.isAssignableFrom(moduleClass));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public ModuleHolder(NativeModule nativeModule) {
nativeModule.getClass().getSimpleName(),
nativeModule.canOverrideExistingModule(),
true,
true,
CxxModuleWrapper.class.isAssignableFrom(nativeModule.getClass()),
TurboModule.class.isAssignableFrom(nativeModule.getClass()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public ReactModuleInfo(
String className,
boolean canOverrideExistingModule,
boolean needsEagerInit,
boolean hasConstants,
boolean isCxxModule,
boolean isTurboModule) {
mName = name;
Expand All @@ -36,6 +35,22 @@ public ReactModuleInfo(
mIsTurboModule = isTurboModule;
}

/**
* @deprecated use {@link ReactModuleInfo#ReactModuleInfo(String, String, boolean, boolean,
* boolean, boolean)}
*/
@Deprecated
public ReactModuleInfo(
String name,
String className,
boolean canOverrideExistingModule,
boolean needsEagerInit,
boolean hasConstants,
boolean isCxxModule,
boolean isTurboModule) {
this(name, className, canOverrideExistingModule, needsEagerInit, isCxxModule, isTurboModule);
}

public String name() {
return mName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ private CodeBlock getCodeBlockForReactModuleInfos(List<String> nativeModules)
.append(", ")
.append(reactModule.needsEagerInit())
.append(", ")
.append(hasConstants)
.append(", ")
.append(reactModule.isCxxModule())
.append(", ")
.append(isTurboModule)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public ReactModuleInfoProvider getReactModuleInfoProvider() {
moduleClass.getName(),
reactModule.canOverrideExistingModule(),
reactModule.needsEagerInit(),
reactModule.hasConstants(),
reactModule.isCxxModule(),
TurboModule.class.isAssignableFrom(moduleClass)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ public ReactModuleInfoProvider getReactModuleInfoProvider() {
final Map<String, ReactModuleInfo> reactModuleInfoMap = new HashMap<>();
for (Class<? extends NativeModule> moduleClass : moduleList) {
ReactModule reactModule = moduleClass.getAnnotation(ReactModule.class);

if (reactModule != null) {
reactModuleInfoMap.put(
reactModule.name(),
Expand All @@ -292,12 +291,10 @@ public ReactModuleInfoProvider getReactModuleInfoProvider() {
moduleClass.getName(),
reactModule.canOverrideExistingModule(),
reactModule.needsEagerInit(),
reactModule.hasConstants(),
reactModule.isCxxModule(),
TurboModule.class.isAssignableFrom(moduleClass)));
}
}

return () -> reactModuleInfoMap;
} catch (InstantiationException e) {
throw new RuntimeException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public Map<String, ReactModuleInfo> getReactModuleInfos() {
"SampleTurboModule",
false, // canOverrideExistingModule
false, // needsEagerInit
true, // hasConstants
false, // isCxxModule
true // isTurboModule
));
Expand All @@ -114,7 +113,6 @@ public Map<String, ReactModuleInfo> getReactModuleInfos() {
"SampleLegacyModule",
false, // canOverrideExistingModule
false, // needsEagerInit
true, // hasConstants
false, // isCxxModule
false // isTurboModule
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class RNTesterReactHostDelegate internal constructor(context: Context) : ReactHo
"SampleTurboModule",
false, // canOverrideExistingModule
false, // needsEagerInit
true, // hasConstants
false, // isCxxModule
true // isTurboModule
),
Expand All @@ -100,7 +99,6 @@ class RNTesterReactHostDelegate internal constructor(context: Context) : ReactHo
"SampleLegacyModule",
false, // canOverrideExistingModule
false, // needsEagerInit
true, // hasConstants
false, // isCxxModule
false // isTurboModule
),
Expand Down

0 comments on commit 9f52378

Please sign in to comment.