From e69f6755c8d73e412acc444fbb1d36cad472e1bc Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Tue, 26 Mar 2024 07:15:29 -0700 Subject: [PATCH] Make ReactContext and ReactApplicationContext classes abstract (#43625) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43625 Changelog: [Android][Breaking] Make ReactApplicationContext and ReactContext abstract. Please instantiate BridgeReactContext instead (bridge mode). Or BridgelessReactContext instead (bridgeless mode). Reviewed By: arushikesarwani94 Differential Revision: D55218590 fbshipit-source-id: d507cc47c67cb5cd6c548844c08aa9ed8fb74796 --- packages/react-native/ReactAndroid/api/ReactAndroid.api | 4 ++-- .../com/facebook/react/bridge/ReactApplicationContext.java | 2 +- .../src/main/java/com/facebook/react/bridge/ReactContext.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 37b12bcdee0382..c29f1481e289e3 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -1056,7 +1056,7 @@ public class com/facebook/react/bridge/ProxyJavaScriptExecutor$Factory : com/fac public fun stopSamplingProfiler (Ljava/lang/String;)V } -public class com/facebook/react/bridge/ReactApplicationContext : com/facebook/react/bridge/ReactContext { +public abstract class com/facebook/react/bridge/ReactApplicationContext : com/facebook/react/bridge/ReactContext { public fun (Landroid/content/Context;)V } @@ -1068,7 +1068,7 @@ public class com/facebook/react/bridge/ReactBridge { public static fun staticInit ()V } -public class com/facebook/react/bridge/ReactContext : android/content/ContextWrapper { +public abstract class com/facebook/react/bridge/ReactContext : android/content/ContextWrapper { protected field mInteropModuleRegistry Lcom/facebook/react/bridge/interop/InteropModuleRegistry; public fun (Landroid/content/Context;)V public fun addActivityEventListener (Lcom/facebook/react/bridge/ActivityEventListener;)V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactApplicationContext.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactApplicationContext.java index 0b8520bf95d39b..ba7dc4536ac784 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactApplicationContext.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactApplicationContext.java @@ -13,7 +13,7 @@ * A context wrapper that always wraps Android Application {@link Context} and {@link * CatalystInstance} by extending {@link ReactContext} */ -public class ReactApplicationContext extends ReactContext { +public abstract class ReactApplicationContext extends ReactContext { // We want to wrap ApplicationContext, since there is no easy way to verify that application // context is passed as a param, we use {@link Context#getApplicationContext} to ensure that // the context we're wrapping is in fact an application context. diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java index e3d14e5da87816..9111da5ebd9fae 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java @@ -37,7 +37,7 @@ * Abstract ContextWrapper for Android application or activity {@link Context} and {@link * CatalystInstance} */ -public class ReactContext extends ContextWrapper { +public abstract class ReactContext extends ContextWrapper { @DoNotStrip public interface RCTDeviceEventEmitter extends JavaScriptModule {