Skip to content

Commit

Permalink
Mark IntBufferBatchMountItem as nullsafe (#44540)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #44540

Noticed when running `arc nn`

> Advice xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java:39
> [Class has 0 issues and can be marked Nullsafe] Congrats! `IntBufferBatchMountItem` is free of nullability issues. Mark it `Nullsafe(Nullsafe.Mode.LOCAL)` to prevent regressions.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D57249958

fbshipit-source-id: d38559a3fafae0ad778c19dd85c5da610a650d7c
  • Loading branch information
NickGerleman authored and facebook-github-bot committed May 14, 2024
1 parent 6188733 commit 2cc3ba1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -776,9 +776,12 @@ private void preallocateView(
@AnyThread
@ThreadConfined(ANY)
private MountItem createIntBufferBatchMountItem(
int rootTag, int[] intBuffer, Object[] objBuffer, int commitNumber) {
int rootTag, @Nullable int[] intBuffer, @Nullable Object[] objBuffer, int commitNumber) {
return MountItemFactory.createIntBufferBatchMountItem(
rootTag, intBuffer, objBuffer, commitNumber);
rootTag,
intBuffer == null ? new int[0] : intBuffer,
objBuffer == null ? new Object[0] : objBuffer,
commitNumber);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import static com.facebook.react.fabric.FabricUIManager.IS_DEVELOPMENT_ENVIRONMENT;
import static com.facebook.react.fabric.mounting.mountitems.FabricNameComponentMapping.getFabricComponentName;

import androidx.annotation.NonNull;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants;
Expand All @@ -35,6 +35,7 @@
* allocations in C++ and JNI round-trips.
*/
@DoNotStrip
@Nullsafe(Nullsafe.Mode.LOCAL)
final class IntBufferBatchMountItem implements BatchMountItem {
static final String TAG = IntBufferBatchMountItem.class.getSimpleName();

Expand All @@ -55,8 +56,8 @@ final class IntBufferBatchMountItem implements BatchMountItem {
private final int mSurfaceId;
private final int mCommitNumber;

private final @NonNull int[] mIntBuffer;
private final @NonNull Object[] mObjBuffer;
private final int[] mIntBuffer;
private final Object[] mObjBuffer;

private final int mIntBufferLen;
private final int mObjBufferLen;
Expand All @@ -68,8 +69,8 @@ final class IntBufferBatchMountItem implements BatchMountItem {
mIntBuffer = intBuf;
mObjBuffer = objBuf;

mIntBufferLen = mIntBuffer != null ? mIntBuffer.length : 0;
mObjBufferLen = mObjBuffer != null ? mObjBuffer.length : 0;
mIntBufferLen = mIntBuffer.length;
mObjBufferLen = mObjBuffer.length;
}

private void beginMarkers(String reason) {
Expand All @@ -91,7 +92,7 @@ private void endMarkers() {
}

@Override
public void execute(@NonNull MountingManager mountingManager) {
public void execute(MountingManager mountingManager) {
SurfaceMountingManager surfaceMountingManager = mountingManager.getSurfaceManager(mSurfaceId);
if (surfaceMountingManager == null) {
FLog.e(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public object MountItemFactory {
@JvmStatic
public fun createIntBufferBatchMountItem(
surfaceId: Int,
intBuf: IntArray?,
objBuf: Array<Any?>?,
intBuf: IntArray,
objBuf: Array<Any?>,
commitNumber: Int
): MountItem = IntBufferBatchMountItem(surfaceId, intBuf, objBuf, commitNumber)
}

0 comments on commit 2cc3ba1

Please sign in to comment.