Migrate CxxModuleWrapper & DefaultJSExceptionHandler to Kotlin (#49706)

Summary:
Migrating two more classes from com.facebook.react.bridge to Kotlin, `CxxModuleWrapper` & `DefaultJSExceptionHandler`.

## Changelog:

[INTERNAL] - Migrate CxxModuleWrapper & DefaultJSExceptionHandler to Kotlin

Pull Request resolved: https://github.com/facebook/react-native/pull/49706

Test Plan:
```sh
yarn test-android
yarn android
```

Reviewed By: cortinico

Differential Revision: D70317975

Pulled By: javache

fbshipit-source-id: 642d96faa131dd859f18cd811a5a223acba4c722
This commit is contained in:
Mateo Guzmán
2025-02-27 05:23:56 -08:00
committed by Facebook GitHub Bot
parent 3226c328bf
commit 63dea206ff
3 changed files with 12 additions and 17 deletions
@@ -695,7 +695,7 @@ public class com/facebook/react/bridge/CxxModuleWrapperBase : com/facebook/react
protected fun resetModule (Lcom/facebook/jni/HybridData;)V
}
public class com/facebook/react/bridge/DefaultJSExceptionHandler : com/facebook/react/bridge/JSExceptionHandler {
public final class com/facebook/react/bridge/DefaultJSExceptionHandler : com/facebook/react/bridge/JSExceptionHandler {
public fun <init> ()V
public fun handleException (Ljava/lang/Exception;)V
}
@@ -5,15 +5,12 @@
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.bridge;
package com.facebook.react.bridge
import com.facebook.jni.HybridData;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.jni.HybridData
import com.facebook.proguard.annotations.DoNotStrip
/** This does nothing interesting, except avoid breaking existing code. */
@DoNotStrip
public class CxxModuleWrapper extends CxxModuleWrapperBase {
protected CxxModuleWrapper(HybridData hd) {
super(hd);
}
}
public open class CxxModuleWrapper protected constructor(hybridData: HybridData) :
CxxModuleWrapperBase(hybridData)
@@ -5,19 +5,17 @@
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.bridge;
package com.facebook.react.bridge
/** Crashy crashy exception handler. */
public class DefaultJSExceptionHandler implements JSExceptionHandler {
@Override
public void handleException(Exception e) {
if (e instanceof RuntimeException) {
public class DefaultJSExceptionHandler : JSExceptionHandler {
override fun handleException(e: Exception) {
throw if (e is RuntimeException) {
// Because we are rethrowing the original exception, the original stacktrace will be
// preserved.
throw (RuntimeException) e;
e
} else {
throw new RuntimeException(e);
RuntimeException(e)
}
}
}