Skip to content

Commit 274baae

Browse files
mateoguzmanagabrieldonadel
authored andcommitted
Migrate CxxModuleWrapper & DefaultJSExceptionHandler to Kotlin (facebook#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: facebook#49706 Test Plan: ```sh yarn test-android yarn android ``` Reviewed By: cortinico Differential Revision: D70317975 Pulled By: javache fbshipit-source-id: 642d96faa131dd859f18cd811a5a223acba4c722
1 parent b1ff676 commit 274baae

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

packages/react-native/ReactAndroid/api/ReactAndroid.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ public class com/facebook/react/bridge/CxxModuleWrapperBase : com/facebook/react
695695
protected fun resetModule (Lcom/facebook/jni/HybridData;)V
696696
}
697697

698-
public class com/facebook/react/bridge/DefaultJSExceptionHandler : com/facebook/react/bridge/JSExceptionHandler {
698+
public final class com/facebook/react/bridge/DefaultJSExceptionHandler : com/facebook/react/bridge/JSExceptionHandler {
699699
public fun <init> ()V
700700
public fun handleException (Ljava/lang/Exception;)V
701701
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapper.java renamed to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/CxxModuleWrapper.kt

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
package com.facebook.react.bridge;
8+
package com.facebook.react.bridge
99

10-
import com.facebook.jni.HybridData;
11-
import com.facebook.proguard.annotations.DoNotStrip;
10+
import com.facebook.jni.HybridData
11+
import com.facebook.proguard.annotations.DoNotStrip
1212

1313
/** This does nothing interesting, except avoid breaking existing code. */
1414
@DoNotStrip
15-
public class CxxModuleWrapper extends CxxModuleWrapperBase {
16-
protected CxxModuleWrapper(HybridData hd) {
17-
super(hd);
18-
}
19-
}
15+
public open class CxxModuleWrapper protected constructor(hybridData: HybridData) :
16+
CxxModuleWrapperBase(hybridData)
Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
package com.facebook.react.bridge;
8+
package com.facebook.react.bridge
99

1010
/** Crashy crashy exception handler. */
11-
public class DefaultJSExceptionHandler implements JSExceptionHandler {
12-
13-
@Override
14-
public void handleException(Exception e) {
15-
if (e instanceof RuntimeException) {
11+
public class DefaultJSExceptionHandler : JSExceptionHandler {
12+
override fun handleException(e: Exception) {
13+
throw if (e is RuntimeException) {
1614
// Because we are rethrowing the original exception, the original stacktrace will be
1715
// preserved.
18-
throw (RuntimeException) e;
16+
e
1917
} else {
20-
throw new RuntimeException(e);
18+
RuntimeException(e)
2119
}
2220
}
2321
}

0 commit comments

Comments
 (0)