From e69faff265030a3e5d4d911621cd5e779ac72d05 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 23 Feb 2024 15:27:17 -0800 Subject: [PATCH] Mark classes of package uimanager as @Nullsafe (#43161) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43161 All these classes are NullSafe, let's mark them as NullSafe(Local) to ensure lint detect errors in the future changelog: [internal] internal bypass-github-export-checks Reviewed By: javache Differential Revision: D54027187 fbshipit-source-id: a25024ba7f7d4893a2b7d083e2ba10c5f2e3a035 --- .../src/main/java/com/facebook/react/uimanager/NativeKind.java | 3 +++ .../facebook/react/uimanager/NoSuchNativeViewException.java | 3 +++ .../main/java/com/facebook/react/uimanager/OnLayoutEvent.java | 2 ++ 3 files changed, 8 insertions(+) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeKind.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeKind.java index e45f7dd805b..35d40c38241 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeKind.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NativeKind.java @@ -7,10 +7,13 @@ package com.facebook.react.uimanager; +import com.facebook.infer.annotation.Nullsafe; + // Common conditionals: // - `kind == PARENT` checks whether the node can host children in the native tree. // - `kind != NONE` checks whether the node appears in the native tree. +@Nullsafe(Nullsafe.Mode.LOCAL) public enum NativeKind { // Node is in the native hierarchy and the HierarchyOptimizer should assume it can host children // (e.g. because it's a ViewGroup). Note that it's okay if the node doesn't support children. When diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NoSuchNativeViewException.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NoSuchNativeViewException.java index 02c6fe31efe..8bf0a04c8a4 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NoSuchNativeViewException.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/NoSuchNativeViewException.java @@ -7,10 +7,13 @@ package com.facebook.react.uimanager; +import com.facebook.infer.annotation.Nullsafe; + /** * Exception thrown when a class tries to access a native view by a tag that has no native view * associated with it. */ +@Nullsafe(Nullsafe.Mode.LOCAL) class NoSuchNativeViewException extends IllegalViewOperationException { public NoSuchNativeViewException(String detailMessage) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/OnLayoutEvent.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/OnLayoutEvent.java index 4d771f59492..37fc1905004 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/OnLayoutEvent.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/OnLayoutEvent.java @@ -9,11 +9,13 @@ package com.facebook.react.uimanager; import androidx.annotation.Nullable; import androidx.core.util.Pools; +import com.facebook.infer.annotation.Nullsafe; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.WritableMap; import com.facebook.react.uimanager.events.Event; /** Event used to notify JS component about changes of its position or dimensions */ +@Nullsafe(Nullsafe.Mode.LOCAL) public class OnLayoutEvent extends Event { private static final Pools.SynchronizedPool EVENTS_POOL =