Skip to content

Commit a4fedf9

Browse files
cortinicometa-codesync[bot]
authored andcommitted
Migrate ReactNativeHost from Java to Kotlin
Summary: Mechanical migration of the deprecated `ReactNativeHost` class from Java to Kotlin. All methods retain their exact JVM signatures to preserve API compatibility. Key migration decisions: - Class remains `abstract` (implicitly open) - All non-final, non-abstract methods marked `open` to match Java virtual-by-default - `getApplication()` remains `final` (no `open`) - Methods kept as explicit `fun` (not Kotlin properties) to preserve exact JVM getter names like `getJSMainModuleName()`, `getJSBundleFile()`, `getUIManagerProvider()` - `Nullable` return types converted to Kotlin nullable types (`?`) - `synchronized` methods use `Synchronized` annotation - `Nullsafe` annotation removed (redundant in Kotlin) - Static initializer converted to companion object `init` block Changelog: [Android][Changed] - Migrate `ReactNativeHost` from Java to Kotlin (no behavioral changes) Differential Revision: D105013283
1 parent 5f6a705 commit a4fedf9

5 files changed

Lines changed: 223 additions & 259 deletions

File tree

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ public final class com/facebook/react/ReactInstanceManagerBuilder {
314314
}
315315

316316
public abstract class com/facebook/react/ReactNativeHost {
317+
public static final field Companion Lcom/facebook/react/ReactNativeHost$Companion;
317318
protected fun <init> (Landroid/app/Application;)V
318319
public fun clear ()V
319320
protected fun createReactInstanceManager ()Lcom/facebook/react/ReactInstanceManager;
@@ -340,6 +341,9 @@ public abstract class com/facebook/react/ReactNativeHost {
340341
public fun hasInstance ()Z
341342
}
342343

344+
public final class com/facebook/react/ReactNativeHost$Companion {
345+
}
346+
343347
public abstract interface class com/facebook/react/ReactPackage {
344348
public fun createNativeModules (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/List;
345349
public abstract fun createViewManagers (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/List;

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public open class ReactDelegate {
252252
((ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
253253
reactHost?.devSupportManager != null) ||
254254
(reactNativeHost?.hasInstance() == true &&
255-
reactNativeHost?.useDeveloperSupport == true))
255+
reactNativeHost?.getUseDeveloperSupport() == true))
256256
) {
257257
event.startTracking()
258258
return true
@@ -273,7 +273,8 @@ public open class ReactDelegate {
273273
}
274274
} else {
275275
if (
276-
reactNativeHost?.hasInstance() == true && reactNativeHost?.useDeveloperSupport == true
276+
reactNativeHost?.hasInstance() == true &&
277+
reactNativeHost?.getUseDeveloperSupport() == true
277278
) {
278279
reactNativeHost?.reactInstanceManager?.showDevOptionsDialog()
279280
return true

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java

Lines changed: 0 additions & 251 deletions
This file was deleted.

0 commit comments

Comments
 (0)