Deprecate LazyReactPackage.getReactModuleInfoProviderViaReflection

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
This commit is contained in:
Ramanpreet Nara 2023-02-14 14:31:52 -08:00 коммит произвёл Facebook GitHub Bot
Родитель 611f9c615e
Коммит 11570e71a2
1 изменённых файлов: 7 добавлений и 35 удалений

Просмотреть файл

@ -33,44 +33,16 @@ import java.util.Map;
*/
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
*