Skip to content

Commit e180072

Browse files
rshestfacebook-github-bot
authored andcommitted
Migrate SystemClock and JavaScriptException to Kotlin (facebook#43732)
Summary: Pull Request resolved: facebook#43732 ## Changelog: [Internal] - As in the title. Reviewed By: cortinico Differential Revision: D55574532 fbshipit-source-id: bffa17a4be0f881a574988c34d9446f6392c816c
1 parent f2bdec2 commit e180072

File tree

5 files changed

+55
-73
lines changed

5 files changed

+55
-73
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,7 +1687,7 @@ public abstract interface class com/facebook/react/common/HasJavascriptException
16871687
public class com/facebook/react/common/JavascriptException : java/lang/RuntimeException, com/facebook/react/common/HasJavascriptExceptionMetadata {
16881688
public fun <init> (Ljava/lang/String;)V
16891689
public fun getExtraDataAsJson ()Ljava/lang/String;
1690-
public fun setExtraDataAsJson (Ljava/lang/String;)Lcom/facebook/react/common/JavascriptException;
1690+
public final fun setExtraDataAsJson (Ljava/lang/String;)Lcom/facebook/react/common/JavascriptException;
16911691
}
16921692

16931693
public final class com/facebook/react/common/LifecycleState : java/lang/Enum {
@@ -1771,11 +1771,11 @@ public abstract interface class com/facebook/react/common/SurfaceDelegateFactory
17711771
public abstract fun createSurfaceDelegate (Ljava/lang/String;)Lcom/facebook/react/common/SurfaceDelegate;
17721772
}
17731773

1774-
public class com/facebook/react/common/SystemClock {
1775-
public fun <init> ()V
1776-
public static fun currentTimeMillis ()J
1777-
public static fun nanoTime ()J
1778-
public static fun uptimeMillis ()J
1774+
public final class com/facebook/react/common/SystemClock {
1775+
public static final field INSTANCE Lcom/facebook/react/common/SystemClock;
1776+
public static final fun currentTimeMillis ()J
1777+
public static final fun nanoTime ()J
1778+
public static final fun uptimeMillis ()J
17791779
}
17801780

17811781
public abstract interface annotation class com/facebook/react/common/annotations/DeprecatedInNewArchitecture : java/lang/annotation/Annotation {

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/JavascriptException.java

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.react.common
9+
10+
import com.facebook.proguard.annotations.DoNotStrip
11+
12+
/**
13+
* A JS exception that was propagated to native. In debug mode, these exceptions are normally shown
14+
* to developers in a redbox.
15+
*/
16+
@DoNotStrip
17+
public open class JavascriptException(jsStackTrace: String) :
18+
RuntimeException(jsStackTrace), HasJavascriptExceptionMetadata {
19+
private var extraDataAsJson: String? = null
20+
21+
override fun getExtraDataAsJson(): String? = extraDataAsJson
22+
23+
public fun setExtraDataAsJson(extraDataAsJson: String?): JavascriptException {
24+
this.extraDataAsJson = extraDataAsJson
25+
return this
26+
}
27+
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/common/SystemClock.java

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
package com.facebook.react.common
9+
10+
import android.os.SystemClock
11+
12+
/**
13+
* Detour for System.currentTimeMillis and System.nanoTime calls so that they can be mocked out in
14+
* tests.
15+
*/
16+
public object SystemClock {
17+
@JvmStatic public fun currentTimeMillis(): Long = System.currentTimeMillis()
18+
19+
@JvmStatic public fun nanoTime(): Long = System.nanoTime()
20+
21+
@JvmStatic public fun uptimeMillis(): Long = SystemClock.uptimeMillis()
22+
}

0 commit comments

Comments
 (0)