Skip to content

Commit

Permalink
Migrate SystemClock and JavaScriptException to Kotlin (facebook#43732)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#43732

## Changelog:
[Internal] -

As in the title.

Reviewed By: cortinico

Differential Revision: D55574532

fbshipit-source-id: bffa17a4be0f881a574988c34d9446f6392c816c
  • Loading branch information
rshest authored and facebook-github-bot committed Apr 3, 2024
1 parent f2bdec2 commit e180072
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 73 deletions.
12 changes: 6 additions & 6 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -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 <init> (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 {
Expand Down Expand Up @@ -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 <init> ()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 {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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()
}

0 comments on commit e180072

Please sign in to comment.