diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 0c037160bd7b6f..585734f3b5a1f9 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -1687,7 +1687,7 @@ public abstract interface class com/facebook/react/common/HasJavascriptException public class com/facebook/react/common/JavascriptException : java/lang/RuntimeException, com/facebook/react/common/HasJavascriptExceptionMetadata { public fun (Ljava/lang/String;)V public fun getExtraDataAsJson ()Ljava/lang/String; - public fun setExtraDataAsJson (Ljava/lang/String;)Lcom/facebook/react/common/JavascriptException; + public final fun setExtraDataAsJson (Ljava/lang/String;)Lcom/facebook/react/common/JavascriptException; } public final class com/facebook/react/common/LifecycleState : java/lang/Enum { @@ -1771,11 +1771,11 @@ public abstract interface class com/facebook/react/common/SurfaceDelegateFactory public abstract fun createSurfaceDelegate (Ljava/lang/String;)Lcom/facebook/react/common/SurfaceDelegate; } -public class com/facebook/react/common/SystemClock { - public fun ()V - public static fun currentTimeMillis ()J - public static fun nanoTime ()J - public static fun uptimeMillis ()J +public final class com/facebook/react/common/SystemClock { + public static final field INSTANCE Lcom/facebook/react/common/SystemClock; + public static final fun currentTimeMillis ()J + public static final fun nanoTime ()J + public static final fun uptimeMillis ()J } public abstract interface annotation class com/facebook/react/common/annotations/DeprecatedInNewArchitecture : java/lang/annotation/Annotation { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/JavascriptException.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/JavascriptException.java deleted file mode 100644 index e8caa1c6bff93d..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/JavascriptException.java +++ /dev/null @@ -1,37 +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.common; - -import com.facebook.infer.annotation.Nullsafe; -import com.facebook.proguard.annotations.DoNotStrip; -import javax.annotation.Nullable; - -/** - * A JS exception that was propagated to native. In debug mode, these exceptions are normally shown - * to developers in a redbox. - */ -@Nullsafe(Nullsafe.Mode.LOCAL) -@DoNotStrip -public class JavascriptException extends RuntimeException - implements HasJavascriptExceptionMetadata { - - private @Nullable String extraDataAsJson; - - public JavascriptException(String jsStackTrace) { - super(jsStackTrace); - } - - public @Nullable String getExtraDataAsJson() { - return extraDataAsJson; - } - - public JavascriptException setExtraDataAsJson(@Nullable String extraDataAsJson) { - this.extraDataAsJson = extraDataAsJson; - return this; - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/JavascriptException.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/JavascriptException.kt new file mode 100644 index 00000000000000..df15d4567f924b --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/JavascriptException.kt @@ -0,0 +1,27 @@ +/* + * 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.common + +import com.facebook.proguard.annotations.DoNotStrip + +/** + * A JS exception that was propagated to native. In debug mode, these exceptions are normally shown + * to developers in a redbox. + */ +@DoNotStrip +public open class JavascriptException(jsStackTrace: String) : + RuntimeException(jsStackTrace), HasJavascriptExceptionMetadata { + private var extraDataAsJson: String? = null + + override fun getExtraDataAsJson(): String? = extraDataAsJson + + public fun setExtraDataAsJson(extraDataAsJson: String?): JavascriptException { + this.extraDataAsJson = extraDataAsJson + return this + } +} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/SystemClock.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/SystemClock.java deleted file mode 100644 index 53aada5deb7b95..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/SystemClock.java +++ /dev/null @@ -1,30 +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.common; - -import com.facebook.infer.annotation.Nullsafe; - -/** - * Detour for System.currentTimeMillis and System.nanoTime calls so that they can be mocked out in - * tests. - */ -@Nullsafe(Nullsafe.Mode.LOCAL) -public class SystemClock { - - public static long currentTimeMillis() { - return System.currentTimeMillis(); - } - - public static long nanoTime() { - return System.nanoTime(); - } - - public static long uptimeMillis() { - return android.os.SystemClock.uptimeMillis(); - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/SystemClock.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/SystemClock.kt new file mode 100644 index 00000000000000..049c9ab927a0e4 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/SystemClock.kt @@ -0,0 +1,22 @@ +/* + * 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.common + +import android.os.SystemClock + +/** + * Detour for System.currentTimeMillis and System.nanoTime calls so that they can be mocked out in + * tests. + */ +public object SystemClock { + @JvmStatic public fun currentTimeMillis(): Long = System.currentTimeMillis() + + @JvmStatic public fun nanoTime(): Long = System.nanoTime() + + @JvmStatic public fun uptimeMillis(): Long = SystemClock.uptimeMillis() +}