From c3c19377d6533fbe5ad9621ffde0ae42c60a5be2 Mon Sep 17 00:00:00 2001 From: Arushi Kesarwani Date: Tue, 2 Apr 2024 01:27:00 -0700 Subject: [PATCH] Migrate JSCInstance to Kotlin (#43750) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43750 Changelog: [Internal] Differential Revision: D55610929 --- .../ReactAndroid/api/ReactAndroid.api | 7 +++-- .../facebook/react/runtime/JSCInstance.java | 27 ------------------- .../com/facebook/react/runtime/JSCInstance.kt | 24 +++++++++++++++++ 3 files changed, 29 insertions(+), 29 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSCInstance.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSCInstance.kt diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index f82ec0593a43bd..73449433924335 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -3645,9 +3645,12 @@ public class com/facebook/react/runtime/CoreReactPackage$$ReactModuleInfoProvide public fun getReactModuleInfos ()Ljava/util/Map; } -public class com/facebook/react/runtime/JSCInstance : com/facebook/react/runtime/JSRuntimeFactory { +public final class com/facebook/react/runtime/JSCInstance : com/facebook/react/runtime/JSRuntimeFactory { + public static final field Companion Lcom/facebook/react/runtime/JSCInstance$Companion; public fun ()V - protected static fun initHybrid ()Lcom/facebook/jni/HybridData; +} + +public final class com/facebook/react/runtime/JSCInstance$Companion { } public abstract class com/facebook/react/runtime/JSRuntimeFactory { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSCInstance.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSCInstance.java deleted file mode 100644 index 0524c58eac2312..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSCInstance.java +++ /dev/null @@ -1,27 +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.jni.annotations.DoNotStrip; -import com.facebook.soloader.SoLoader; - -@Nullsafe(Nullsafe.Mode.LOCAL) -public class JSCInstance extends JSRuntimeFactory { - static { - SoLoader.loadLibrary("jscinstance"); - } - - @DoNotStrip - protected static native HybridData initHybrid(); - - public JSCInstance() { - super(initHybrid()); - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSCInstance.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSCInstance.kt new file mode 100644 index 00000000000000..6f3cfcb21c4417 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSCInstance.kt @@ -0,0 +1,24 @@ +/* + * 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.jni.annotations.DoNotStrip +import com.facebook.soloader.SoLoader +import com.facebook.soloader.annotation.SoLoaderLibrary + +@SoLoaderLibrary("jscinstance") +public class JSCInstance constructor() : JSRuntimeFactory(initHybrid()) { + public companion object { + init { + SoLoader.loadLibrary("jscinstance") + } + + @DoNotStrip protected external fun initHybrid(): HybridData + } +}