Skip to content

Commit

Permalink
Deprecate LazyReactPackage.getReactModuleInfoProviderViaReflection
Browse files Browse the repository at this point in the history
Summary:
There are two different ways of getting the ReactModuleInfoProvider from LazyReactPackage:
1. static LazyReactPackage.getReactModuleInfoProviderViaReflection(LazyReactPackage)
2. LazyReactPackage.getReactModuleInfoProvider()

The first way calls into codegen that only works within Meta's infra. This code-path is *now* dead. Therefore, this diff deprecates the first path, to make LazyReactPackage less confusing.

This diff simplifies the implementation to return an empty ReactModuleInfoProvider for the v0.72 cut.

In the v0.73 cut, we'll just outright delete this method.

Changelog: [Android][Changed] - Deprecate LazyReactPackage.getReactModuleInfoProviderViaReflection()

Reviewed By: sshic

Differential Revision: D43066800

fbshipit-source-id: 2145c3265ff2bd24e6828b193577ba1f500bce49
  • Loading branch information
RSNara authored and facebook-github-bot committed Feb 14, 2023
1 parent 611f9c6 commit 11570e7
Showing 1 changed file with 7 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,44 +33,16 @@
*/
public abstract class LazyReactPackage implements ReactPackage {

@Deprecated
public static ReactModuleInfoProvider getReactModuleInfoProviderViaReflection(
LazyReactPackage lazyReactPackage) {
Class<?> reactModuleInfoProviderClass;
try {
reactModuleInfoProviderClass =
Class.forName(
lazyReactPackage.getClass().getCanonicalName() + "$$ReactModuleInfoProvider");
} catch (ClassNotFoundException e) {
// In OSS case, when the annotation processor does not run, we fall back to non-lazy mode
// For this, we simply return an empty moduleMap.
// NativeModuleRegistryBuilder will eagerly get all the modules, and get the info from the
// modules directly
return new ReactModuleInfoProvider() {
@Override
public Map<String, ReactModuleInfo> getReactModuleInfos() {
return Collections.emptyMap();
}
};
}

if (reactModuleInfoProviderClass == null) {
throw new RuntimeException(
"ReactModuleInfoProvider class for "
+ lazyReactPackage.getClass().getCanonicalName()
+ " not found.");
}

try {
return (ReactModuleInfoProvider) reactModuleInfoProviderClass.newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(
"Unable to instantiate ReactModuleInfoProvider for " + lazyReactPackage.getClass(), e);
} catch (IllegalAccessException e) {
throw new RuntimeException(
"Unable to instantiate ReactModuleInfoProvider for " + lazyReactPackage.getClass(), e);
}
return new ReactModuleInfoProvider() {
@Override
public Map<String, ReactModuleInfo> getReactModuleInfos() {
return Collections.emptyMap();
}
};
}

/**
* We return an iterable
*
Expand Down

0 comments on commit 11570e7

Please sign in to comment.