From ae698f4cdb257fd5c1fd79c5f7d9a84bc0f35f69 Mon Sep 17 00:00:00 2001 From: Ruslan Shestopalyuk Date: Wed, 15 May 2024 04:37:59 -0700 Subject: [PATCH] Migrate NativeArray classes to Kotlin (#44569) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44569 # Changelog: [Internal] - This converts the vertical of NativeArray/ReadableNativeArray/WritableNativeArray classes to Kotlin. Differential Revision: https://internalfb.com/D57327835 --- .../ReactAndroid/api/ReactAndroid.api | 13 +- .../facebook/react/bridge/NativeArray.java | 28 --- .../com/facebook/react/bridge/NativeArray.kt | 25 +++ .../facebook/react/bridge/ReadableArray.kt | 8 +- .../react/bridge/ReadableNativeArray.java | 174 ------------------ .../react/bridge/ReadableNativeArray.kt | 95 ++++++++++ .../react/bridge/WritableNativeArray.java | 68 ------- .../react/bridge/WritableNativeArray.kt | 56 ++++++ .../react/modules/image/ImageLoaderModule.kt | 2 +- .../facebook/react/uimanager/FilterHelper.kt | 6 +- .../com/facebook/react/util/JSStackTrace.kt | 2 +- .../DebuggingOverlayManager.kt | 8 +- 12 files changed, 200 insertions(+), 285 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArray.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArray.kt delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeArray.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeArray.kt delete mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/WritableNativeArray.java create mode 100644 packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/WritableNativeArray.kt diff --git a/packages/react-native/ReactAndroid/api/ReactAndroid.api b/packages/react-native/ReactAndroid/api/ReactAndroid.api index 340a04b69ec299..b40f9f1b7f0aaf 100644 --- a/packages/react-native/ReactAndroid/api/ReactAndroid.api +++ b/packages/react-native/ReactAndroid/api/ReactAndroid.api @@ -955,10 +955,14 @@ public class com/facebook/react/bridge/ModuleSpec { } public abstract class com/facebook/react/bridge/NativeArray : com/facebook/react/bridge/NativeArrayInterface { + protected static final field Companion Lcom/facebook/react/bridge/NativeArray$Companion; protected fun (Lcom/facebook/jni/HybridData;)V public fun toString ()Ljava/lang/String; } +protected final class com/facebook/react/bridge/NativeArray$Companion { +} + public abstract interface class com/facebook/react/bridge/NativeArrayInterface { public abstract fun toString ()Ljava/lang/String; } @@ -1382,6 +1386,7 @@ public abstract interface class com/facebook/react/bridge/ReadableMapKeySetItera } public class com/facebook/react/bridge/ReadableNativeArray : com/facebook/react/bridge/NativeArray, com/facebook/react/bridge/ReadableArray { + public static final field Companion Lcom/facebook/react/bridge/ReadableNativeArray$Companion; protected fun (Lcom/facebook/jni/HybridData;)V public fun equals (Ljava/lang/Object;)Z public synthetic fun getArray (I)Lcom/facebook/react/bridge/ReadableArray; @@ -1390,7 +1395,7 @@ public class com/facebook/react/bridge/ReadableNativeArray : com/facebook/react/ public fun getDouble (I)D public fun getDynamic (I)Lcom/facebook/react/bridge/Dynamic; public fun getInt (I)I - public static fun getJNIPassCounter ()I + public static final fun getJNIPassCounter ()I public fun getLong (I)J public synthetic fun getMap (I)Lcom/facebook/react/bridge/ReadableMap; public fun getMap (I)Lcom/facebook/react/bridge/ReadableNativeMap; @@ -1402,6 +1407,10 @@ public class com/facebook/react/bridge/ReadableNativeArray : com/facebook/react/ public fun toArrayList ()Ljava/util/ArrayList; } +public final class com/facebook/react/bridge/ReadableNativeArray$Companion { + public final fun getJNIPassCounter ()I +} + public class com/facebook/react/bridge/ReadableNativeMap : com/facebook/react/bridge/NativeMap, com/facebook/react/bridge/ReadableMap { protected fun (Lcom/facebook/jni/HybridData;)V public fun equals (Ljava/lang/Object;)Z @@ -1527,7 +1536,7 @@ public abstract interface class com/facebook/react/bridge/WritableMap : com/face public abstract fun putString (Ljava/lang/String;Ljava/lang/String;)V } -public class com/facebook/react/bridge/WritableNativeArray : com/facebook/react/bridge/ReadableNativeArray, com/facebook/react/bridge/WritableArray { +public final class com/facebook/react/bridge/WritableNativeArray : com/facebook/react/bridge/ReadableNativeArray, com/facebook/react/bridge/WritableArray { public fun ()V public fun pushArray (Lcom/facebook/react/bridge/ReadableArray;)V public fun pushBoolean (Z)V diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArray.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArray.java deleted file mode 100644 index c46dbcc6dad564..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArray.java +++ /dev/null @@ -1,28 +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.bridge; - -import com.facebook.jni.HybridData; -import com.facebook.proguard.annotations.DoNotStrip; - -/** Base class for an array whose members are stored in native code (C++). */ -@DoNotStrip -public abstract class NativeArray implements NativeArrayInterface { - static { - ReactBridge.staticInit(); - } - - protected NativeArray(HybridData hybridData) { - mHybridData = hybridData; - } - - @Override - public native String toString(); - - @DoNotStrip private HybridData mHybridData; -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArray.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArray.kt new file mode 100644 index 00000000000000..d947a2cf5dd659 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeArray.kt @@ -0,0 +1,25 @@ +/* + * 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.bridge + +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStrip + +/** Base class for an array whose members are stored in native code (C++). */ +@DoNotStrip +public abstract class NativeArray +protected constructor(@field:DoNotStrip private val mHybridData: HybridData?) : + NativeArrayInterface { + external override fun toString(): String + + protected companion object { + init { + ReactBridge.staticInit() + } + } +} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableArray.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableArray.kt index de59f930ad5829..06334d7cc9f14c 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableArray.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableArray.kt @@ -14,7 +14,7 @@ import java.util.ArrayList * to Kotlin. */ public interface ReadableArray { - public fun getArray(index: Int): ReadableArray + public fun getArray(index: Int): ReadableArray? public fun getBoolean(index: Int): Boolean @@ -26,9 +26,9 @@ public interface ReadableArray { public fun getLong(index: Int): Long - public fun getMap(index: Int): ReadableMap + public fun getMap(index: Int): ReadableMap? - public fun getString(index: Int): String + public fun getString(index: Int): String? public fun getType(index: Int): ReadableType @@ -36,5 +36,5 @@ public interface ReadableArray { public fun size(): Int - public fun toArrayList(): ArrayList + public fun toArrayList(): ArrayList } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeArray.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeArray.java deleted file mode 100644 index 2f74df2334cac6..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeArray.java +++ /dev/null @@ -1,174 +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.bridge; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import com.facebook.infer.annotation.Assertions; -import com.facebook.jni.HybridData; -import com.facebook.proguard.annotations.DoNotStrip; -import java.util.ArrayList; -import java.util.Arrays; - -/** - * Implementation of a NativeArray that allows read-only access to its members. This will generally - * be constructed and filled in native code so you shouldn't construct one yourself. - */ -@DoNotStrip -public class ReadableNativeArray extends NativeArray implements ReadableArray { - static { - ReactBridge.staticInit(); - } - - protected ReadableNativeArray(HybridData hybridData) { - super(hybridData); - } - - // WriteOnce but not in the constructor fields - private @Nullable Object[] mLocalArray; - private @Nullable ReadableType[] mLocalTypeArray; - - private static int jniPassCounter = 0; - - public static int getJNIPassCounter() { - return jniPassCounter; - } - - private Object[] getLocalArray() { - if (mLocalArray != null) { - return mLocalArray; - } - synchronized (this) { - // Make sure no concurrent call already updated - if (mLocalArray == null) { - jniPassCounter++; - mLocalArray = Assertions.assertNotNull(importArray()); - } - } - return mLocalArray; - } - - private native Object[] importArray(); - - private ReadableType[] getLocalTypeArray() { - if (mLocalTypeArray != null) { - return mLocalTypeArray; - } - synchronized (this) { - // Make sure no concurrent call already updated - if (mLocalTypeArray == null) { - jniPassCounter++; - Object[] tempArray = Assertions.assertNotNull(importTypeArray()); - mLocalTypeArray = Arrays.copyOf(tempArray, tempArray.length, ReadableType[].class); - } - } - return mLocalTypeArray; - } - - private native Object[] importTypeArray(); - - @Override - public int size() { - return getLocalArray().length; - } - - @Override - public boolean isNull(int index) { - return getLocalArray()[index] == null; - } - - @Override - public boolean getBoolean(int index) { - return ((Boolean) getLocalArray()[index]).booleanValue(); - } - - @Override - public double getDouble(int index) { - return ((Double) getLocalArray()[index]).doubleValue(); - } - - @Override - public int getInt(int index) { - return ((Double) getLocalArray()[index]).intValue(); - } - - @Override - public long getLong(int index) { - return ((Long) getLocalArray()[index]).longValue(); - } - - @Override - public @NonNull String getString(int index) { - return (String) getLocalArray()[index]; - } - - @Override - public @NonNull ReadableNativeArray getArray(int index) { - return (ReadableNativeArray) getLocalArray()[index]; - } - - @Override - public @NonNull ReadableNativeMap getMap(int index) { - return (ReadableNativeMap) getLocalArray()[index]; - } - - @Override - public @NonNull ReadableType getType(int index) { - return getLocalTypeArray()[index]; - } - - @Override - public @NonNull Dynamic getDynamic(int index) { - return DynamicFromArray.create(this, index); - } - - @Override - public int hashCode() { - return getLocalArray().hashCode(); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof ReadableNativeArray)) { - return false; - } - ReadableNativeArray other = (ReadableNativeArray) obj; - return Arrays.deepEquals(getLocalArray(), other.getLocalArray()); - } - - @Override - public @NonNull ArrayList toArrayList() { - ArrayList arrayList = new ArrayList<>(); - - for (int i = 0; i < this.size(); i++) { - switch (getType(i)) { - case Null: - arrayList.add(null); - break; - case Boolean: - arrayList.add(getBoolean(i)); - break; - case Number: - arrayList.add(getDouble(i)); - break; - case String: - arrayList.add(getString(i)); - break; - case Map: - arrayList.add(getMap(i).toHashMap()); - break; - case Array: - arrayList.add(getArray(i).toArrayList()); - break; - default: - throw new IllegalArgumentException("Could not convert object at index: " + i + "."); - } - } - return arrayList; - } -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeArray.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeArray.kt new file mode 100644 index 00000000000000..f5a7c071d1a489 --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/ReadableNativeArray.kt @@ -0,0 +1,95 @@ +/* + * 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.bridge + +import com.facebook.infer.annotation.Assertions +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStripAny +import java.util.Arrays + +/** + * Implementation of a NativeArray that allows read-only access to its members. This will generally + * be constructed and filled in native code so you shouldn't construct one yourself. + */ +@DoNotStripAny +public open class ReadableNativeArray protected constructor(hybridData: HybridData?) : + NativeArray(hybridData), ReadableArray { + + private val localArray: Array by + lazy(LazyThreadSafetyMode.SYNCHRONIZED) { + // WriteOnce but not in the constructor fields + jniPassCounter++ + Assertions.assertNotNull(importArray()) + } + + private external fun importArray(): Array + + private val localTypeArray: Array by + lazy(LazyThreadSafetyMode.SYNCHRONIZED) { + // WriteOnce but not in the constructor fields + jniPassCounter++ + val tempArray = Assertions.assertNotNull(importTypeArray()) + Arrays.copyOf(tempArray, tempArray.size, Array::class.java) + } + + private external fun importTypeArray(): Array + + override fun size(): Int = localArray.size + + override fun isNull(index: Int): Boolean = localArray[index] == null + + override fun getBoolean(index: Int): Boolean = localArray[index] as Boolean + + override fun getDouble(index: Int): Double = localArray[index] as Double + + override fun getInt(index: Int): Int = (localArray[index] as Double).toInt() + + override fun getLong(index: Int): Long = localArray[index] as Long + + override fun getString(index: Int): String? = localArray[index] as? String + + override fun getArray(index: Int): ReadableNativeArray? = + localArray[index] as? ReadableNativeArray + + override fun getMap(index: Int): ReadableNativeMap? = localArray[index] as? ReadableNativeMap + + override fun getType(index: Int): ReadableType = localTypeArray[index] + + override fun getDynamic(index: Int): Dynamic = DynamicFromArray.create(this, index) + + override fun hashCode(): Int = localArray.hashCode() + + override fun equals(other: Any?): Boolean = + if (other !is ReadableNativeArray) false else Arrays.deepEquals(localArray, other.localArray) + + override fun toArrayList(): ArrayList { + val arrayList = ArrayList() + for (i in 0 until size()) { + when (getType(i)) { + ReadableType.Null -> arrayList.add(null) + ReadableType.Boolean -> arrayList.add(getBoolean(i)) + ReadableType.Number -> arrayList.add(getDouble(i)) + ReadableType.String -> arrayList.add(getString(i)) + ReadableType.Map -> arrayList.add(getMap(i)?.toHashMap()) + ReadableType.Array -> arrayList.add(getArray(i)?.toArrayList()) + else -> throw IllegalArgumentException("Could not convert object at index: $i.") + } + } + return arrayList + } + + public companion object { + init { + ReactBridge.staticInit() + } + + private var jniPassCounter: Int = 0 + + @JvmStatic public fun getJNIPassCounter(): Int = jniPassCounter + } +} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/WritableNativeArray.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/WritableNativeArray.java deleted file mode 100644 index 06ad5650e11c45..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/WritableNativeArray.java +++ /dev/null @@ -1,68 +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.bridge; - -import androidx.annotation.Nullable; -import com.facebook.infer.annotation.Assertions; -import com.facebook.jni.HybridData; -import com.facebook.proguard.annotations.DoNotStrip; - -/** - * Implementation of a write-only array stored in native memory. Use {@link Arguments#createArray()} - * if you need to stub out creating this class in a test. TODO(5815532): Check if consumed on read - */ -@DoNotStrip -public class WritableNativeArray extends ReadableNativeArray implements WritableArray { - static { - ReactBridge.staticInit(); - } - - public WritableNativeArray() { - super(initHybrid()); - } - - @Override - public native void pushNull(); - - @Override - public native void pushBoolean(boolean value); - - @Override - public native void pushDouble(double value); - - @Override - public native void pushInt(int value); - - @Override - public native void pushLong(long value); - - @Override - public native void pushString(@Nullable String value); - - // Note: this consumes the map so do not reuse it. - @Override - public void pushArray(@Nullable ReadableArray array) { - Assertions.assertCondition( - array == null || array instanceof ReadableNativeArray, "Illegal type provided"); - pushNativeArray((ReadableNativeArray) array); - } - - // Note: this consumes the map so do not reuse it. - @Override - public void pushMap(@Nullable ReadableMap map) { - Assertions.assertCondition( - map == null || map instanceof ReadableNativeMap, "Illegal type provided"); - pushNativeMap((ReadableNativeMap) map); - } - - private static native HybridData initHybrid(); - - private native void pushNativeArray(ReadableNativeArray array); - - private native void pushNativeMap(ReadableNativeMap map); -} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/WritableNativeArray.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/WritableNativeArray.kt new file mode 100644 index 00000000000000..65395e592aa99f --- /dev/null +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/bridge/WritableNativeArray.kt @@ -0,0 +1,56 @@ +/* + * 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.bridge + +import com.facebook.infer.annotation.Assertions +import com.facebook.jni.HybridData +import com.facebook.proguard.annotations.DoNotStripAny + +/** + * Implementation of a write-only array stored in native memory. Use [Arguments.createArray] if you + * need to stub out creating this class in a test. TODO(5815532): Check if consumed on read + */ +@DoNotStripAny +public class WritableNativeArray : ReadableNativeArray(initHybrid()), WritableArray { + external override fun pushNull() + + external override fun pushBoolean(value: Boolean) + + external override fun pushDouble(value: Double) + + external override fun pushInt(value: Int) + + external override fun pushLong(value: Long) + + external override fun pushString(value: String?) + + // Note: this consumes the map so do not reuse it. + override fun pushArray(array: ReadableArray?) { + Assertions.assertCondition( + array == null || array is ReadableNativeArray, "Illegal type provided") + pushNativeArray(array as ReadableNativeArray?) + } + + // Note: this consumes the map so do not reuse it. + override fun pushMap(map: ReadableMap?) { + Assertions.assertCondition(map == null || map is ReadableNativeMap, "Illegal type provided") + pushNativeMap(map as ReadableNativeMap?) + } + + private external fun pushNativeArray(array: ReadableNativeArray?) + + private external fun pushNativeMap(map: ReadableNativeMap?) + + private companion object { + init { + ReactBridge.staticInit() + } + + @JvmStatic private external fun initHybrid(): HybridData? + } +} diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/image/ImageLoaderModule.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/image/ImageLoaderModule.kt index 978a8f488f148f..7b88865dc3d4a0 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/image/ImageLoaderModule.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/image/ImageLoaderModule.kt @@ -249,7 +249,7 @@ public class ImageLoaderModule : NativeImageLoaderAndroidSpec, LifecycleEventLis val result: WritableMap = Arguments.createMap() val imagePipeline: ImagePipeline = this@ImageLoaderModule.imagePipeline for (i in 0 until uris.size()) { - val uriString: String = uris.getString(i) + val uriString: String = uris.getString(i) ?: "" if (!uriString.isNullOrEmpty()) { val uri = Uri.parse(uriString) if (imagePipeline.isInBitmapMemoryCache(uri)) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/FilterHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/FilterHelper.kt index c7cca54c52df7e..783066817a01ac 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/FilterHelper.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/FilterHelper.kt @@ -24,7 +24,7 @@ internal object FilterHelper { filters ?: return null var chainedEffects: RenderEffect? = null for (i in 0 until filters.size()) { - val filter = filters.getMap(i).getEntryIterator().next() + val filter = filters.getMap(i)!!.getEntryIterator().next() val filterName = filter.key val amount = (filter.value as Double).toFloat() @@ -51,7 +51,7 @@ internal object FilterHelper { // New ColorMatrix objects represent the identity matrix val resultColorMatrix = ColorMatrix() for (i in 0 until filters.size()) { - val filter = filters.getMap(i).getEntryIterator().next() + val filter = filters.getMap(i)!!.getEntryIterator().next() val filterName = filter.key val amount = (filter.value as Double).toFloat() @@ -78,7 +78,7 @@ internal object FilterHelper { public fun isOnlyColorMatrixFilters(filters: ReadableArray?): Boolean { filters ?: return false for (i in 0 until filters.size()) { - val filter = filters.getMap(i).getEntryIterator().next() + val filter = filters.getMap(i)!!.getEntryIterator().next() val filterName = filter.key if (filterName == "blur") { return false diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/util/JSStackTrace.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/util/JSStackTrace.kt index 67f39388f27d46..413b51dd1eb7b8 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/util/JSStackTrace.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/util/JSStackTrace.kt @@ -24,7 +24,7 @@ public object JSStackTrace { public fun format(message: String, stack: ReadableArray): String { val stringBuilder = StringBuilder(message).append(", stack:\n") for (i in 0 until stack.size()) { - val frame = stack.getMap(i) + val frame = stack.getMap(i)!! stringBuilder.append(frame.getString(METHOD_NAME_KEY)).append("@").append(parseFileId(frame)) if (frame.hasKey(LINE_NUMBER_KEY) && !frame.isNull(LINE_NUMBER_KEY) && diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/debuggingoverlay/DebuggingOverlayManager.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/debuggingoverlay/DebuggingOverlayManager.kt index cb4e0a0482fb48..30fa56fe6114eb 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/debuggingoverlay/DebuggingOverlayManager.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/debuggingoverlay/DebuggingOverlayManager.kt @@ -27,12 +27,12 @@ public class DebuggingOverlayManager : SimpleViewManager() { return } - val providedTraceUpdates = args.getArray(0) + val providedTraceUpdates = args.getArray(0)!! val formattedTraceUpdates = mutableListOf() var successfullyParsedPayload = true for (i in 0 until providedTraceUpdates.size()) { - val traceUpdate = providedTraceUpdates.getMap(i) + val traceUpdate = providedTraceUpdates.getMap(i)!! val serializedRectangle = traceUpdate.getMap("rectangle") if (serializedRectangle == null) { ReactSoftExceptionLogger.logSoftException( @@ -86,12 +86,12 @@ public class DebuggingOverlayManager : SimpleViewManager() { return } - val providedElements = args.getArray(0) + val providedElements = args.getArray(0)!! val elementsRectangles = mutableListOf() var successfullyParsedPayload = true for (i in 0 until providedElements.size()) { - val element = providedElements.getMap(i) + val element = providedElements.getMap(i)!! try { val left = element.getDouble("x").toFloat()