From 11570e71a2747602ff485552094b413375b19a96 Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Tue, 14 Feb 2023 14:31:52 -0800 Subject: [PATCH] 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 --- .../com/facebook/react/LazyReactPackage.java | 42 ++++--------------- 1 file changed, 7 insertions(+), 35 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java index 34bbe1c198be0f..9ec077bc04d73d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/LazyReactPackage.java @@ -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 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 getReactModuleInfos() { + return Collections.emptyMap(); + } + }; } - /** * We return an iterable *