From ed3c0a1423cb44790a3856decd03481b0ace1beb Mon Sep 17 00:00:00 2001 From: Fabrizio Cucci Date: Wed, 3 Apr 2024 02:43:36 -0700 Subject: [PATCH] Kotlinify IllegalViewOperationException (#43794) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43794 Changelog: [Internal] As part of the Sustainability Week (see [post](https://fb.workplace.com/groups/251759413609061/permalink/742797531171911/)). Reviewed By: alanleedev Differential Revision: D55653543 fbshipit-source-id: 71414e4b46aea7497bb64881cfb99d3b5c84c150 --- .../ReactAndroid/api/ReactAndroid.api | 2 +- .../IllegalViewOperationException.java | 34 ------------------- .../IllegalViewOperationException.kt | 24 +++++++++++++ 3 files changed, 25 insertions(+), 35 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IllegalViewOperationException.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IllegalViewOperationException.kt diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 4e8b9a8fe19..063cc9e4bf2 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -4055,7 +4055,7 @@ public abstract interface class com/facebook/react/uimanager/IViewManagerWithChi public class com/facebook/react/uimanager/IllegalViewOperationException : com/facebook/react/bridge/JSApplicationCausedNativeException { public fun (Ljava/lang/String;)V public fun (Ljava/lang/String;Landroid/view/View;Ljava/lang/Throwable;)V - public fun getView ()Landroid/view/View; + public final fun getView ()Landroid/view/View; } public class com/facebook/react/uimanager/JSPointerDispatcher { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IllegalViewOperationException.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IllegalViewOperationException.java deleted file mode 100644 index 215293188ea..00000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IllegalViewOperationException.java +++ /dev/null @@ -1,34 +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.uimanager; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.infer.annotation.Nullsafe; -import com.facebook.react.bridge.JSApplicationCausedNativeException; - -/** An exception caused by JS requesting the UI manager to perform an illegal view operation. */ -@Nullsafe(Nullsafe.Mode.LOCAL) -public class IllegalViewOperationException extends JSApplicationCausedNativeException { - - @Nullable private View mView; - - public IllegalViewOperationException(String msg) { - super(msg); - } - - public IllegalViewOperationException(String msg, @Nullable View view, Throwable cause) { - super(msg, cause); - mView = view; - } - - @Nullable - public View getView() { - return mView; - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IllegalViewOperationException.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IllegalViewOperationException.kt new file mode 100644 index 00000000000..c03768f9890 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/IllegalViewOperationException.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.uimanager + +import android.view.View +import com.facebook.react.bridge.JSApplicationCausedNativeException + +/** An exception caused by JS requesting the UI manager to perform an illegal view operation. */ +public open class IllegalViewOperationException : JSApplicationCausedNativeException { + private var view: View? = null + + public constructor(msg: String) : super(msg) + + public constructor(msg: String, view: View?, cause: Throwable) : super(msg, cause) { + this.view = view + } + + public fun getView(): View? = view +}