From 3a15af7467db4bdc8b37e10946b2991afc474427 Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Mon, 8 Apr 2024 05:24:39 -0700 Subject: [PATCH] Kotlinify NativeMethodCallInvokerHolderImpl (#43809) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43809 Changelog: [Internal] As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)). Reviewed By: rshest Differential Revision: D55687786 fbshipit-source-id: 45eb656e066348ee4b26d7c4b92db642361c7598 --- .../ReactAndroid/api/ReactAndroid.api | 2 +- ...a => NativeMethodCallInvokerHolderImpl.kt} | 31 ++++++++----------- 2 files changed, 14 insertions(+), 19 deletions(-) rename packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/{NativeMethodCallInvokerHolderImpl.java => NativeMethodCallInvokerHolderImpl.kt} (52%) diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 0e9cb196e12..4fe7fc8edb4 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -3906,7 +3906,7 @@ public abstract interface class com/facebook/react/touch/ReactInterceptingViewGr public final class com/facebook/react/turbomodule/core/CallInvokerHolderImpl : com/facebook/react/turbomodule/core/interfaces/CallInvokerHolder { } -public class com/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl : com/facebook/react/turbomodule/core/interfaces/NativeMethodCallInvokerHolder { +public final class com/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl : com/facebook/react/turbomodule/core/interfaces/NativeMethodCallInvokerHolder { } public abstract interface class com/facebook/react/turbomodule/core/interfaces/CallInvokerHolder { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl.kt similarity index 52% rename from packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl.java rename to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl.kt index c68b5a69aab..d777783a041 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/NativeMethodCallInvokerHolderImpl.kt @@ -5,14 +5,13 @@ * LICENSE file in the root directory of this source tree. */ -package com.facebook.react.turbomodule.core; +package com.facebook.react.turbomodule.core -import com.facebook.infer.annotation.Nullsafe; -import com.facebook.jni.HybridData; -import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.react.common.annotations.FrameworkAPI; -import com.facebook.react.internal.turbomodule.core.NativeModuleSoLoader; -import com.facebook.react.turbomodule.core.interfaces.NativeMethodCallInvokerHolder; +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip +import com.facebook.react.common.annotations.FrameworkAPI +import com.facebook.react.internal.turbomodule.core.NativeModuleSoLoader +import com.facebook.react.turbomodule.core.interfaces.NativeMethodCallInvokerHolder /** * NativeMethodCallInvokerHolder is created at a different time/place (i.e: in CatalystInstance) @@ -20,17 +19,13 @@ import com.facebook.react.turbomodule.core.interfaces.NativeMethodCallInvokerHol * class so that we may pass it from CatalystInstance, through Java, to * TurboModuleManager::initHybrid. */ -@Nullsafe(Nullsafe.Mode.LOCAL) @FrameworkAPI -public class NativeMethodCallInvokerHolderImpl implements NativeMethodCallInvokerHolder { - - @DoNotStrip private final HybridData mHybridData; - - static { - NativeModuleSoLoader.maybeLoadSoLibrary(); - } - - private NativeMethodCallInvokerHolderImpl(HybridData hd) { - mHybridData = hd; +public class NativeMethodCallInvokerHolderImpl +private constructor(@field:DoNotStrip private val mHybridData: HybridData) : + NativeMethodCallInvokerHolder { + private companion object { + init { + NativeModuleSoLoader.maybeLoadSoLibrary() + } } }