From 37e1f39e11e9ad3c998b124eb4950c6138d182c9 Mon Sep 17 00:00:00 2001 From: Arushi Kesarwani Date: Tue, 2 Apr 2024 01:26:41 -0700 Subject: [PATCH] Migrate JSRuntimeFactory to Kotlin (#43748) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43748 Changelog: [Internal] Differential Revision: D55605824 --- .../ReactAndroid/api/ReactAndroid.api | 4 +++ .../react/runtime/JSRuntimeFactory.java | 26 ----------------- .../react/runtime/JSRuntimeFactory.kt | 28 +++++++++++++++++++ 3 files changed, 32 insertions(+), 26 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSRuntimeFactory.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSRuntimeFactory.kt diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 73449433924335..2acf9f3952aa66 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -3654,9 +3654,13 @@ public final class com/facebook/react/runtime/JSCInstance$Companion { } public abstract class com/facebook/react/runtime/JSRuntimeFactory { + public static final field Companion Lcom/facebook/react/runtime/JSRuntimeFactory$Companion; protected fun (Lcom/facebook/jni/HybridData;)V } +public final class com/facebook/react/runtime/JSRuntimeFactory$Companion { +} + public class com/facebook/react/runtime/ReactHostImpl : com/facebook/react/ReactHost { public fun (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;Ljava/util/concurrent/Executor;Ljava/util/concurrent/Executor;Lcom/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler;ZZ)V public fun (Landroid/content/Context;Lcom/facebook/react/runtime/ReactHostDelegate;Lcom/facebook/react/fabric/ComponentFactory;ZLcom/facebook/react/interfaces/exceptionmanager/ReactJsExceptionHandler;Z)V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSRuntimeFactory.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSRuntimeFactory.java deleted file mode 100644 index 83d3e9f841a801..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSRuntimeFactory.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.runtime; - -import com.facebook.infer.annotation.Nullsafe; -import com.facebook.jni.HybridData; -import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.soloader.SoLoader; - -@Nullsafe(Nullsafe.Mode.LOCAL) -public abstract class JSRuntimeFactory { - static { - SoLoader.loadLibrary("rninstance"); - } - - @DoNotStrip private final HybridData mHybridData; - - protected JSRuntimeFactory(HybridData hybridData) { - mHybridData = hybridData; - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSRuntimeFactory.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSRuntimeFactory.kt new file mode 100644 index 00000000000000..785850224cf098 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSRuntimeFactory.kt @@ -0,0 +1,28 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.runtime + +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.facebook.soloader.SoLoader +import com.facebook.soloader.annotation.SoLoaderLibrary + +@SoLoaderLibrary("rninstance") +public abstract class JSRuntimeFactory { + public companion object { + init { + SoLoader.loadLibrary("rninstance") + } + } + + @DoNotStrip private val mHybridData: HybridData + + protected constructor(hybridData: HybridData) { + mHybridData = hybridData + } +}