[Nullsafe fix nullsafe FIXMEs for BaseJavaModule.java and mark nullsafe

Summary:
Gone trough all the FIXMEs added in the previous diff by the nullsafe tool, marked the class as nullsafe and ensured no remaining violations.
Changelog: [Android][Fixed] Made BaseJavaModule.java nullsafe

Reviewed By: alanleedev

Differential Revision: D72384078

fbshipit-source-id: aba0f261f3b3e77133ff2a148bf4903c73c54691
This commit is contained in:
Gijs Weterings
2025-04-09 09:07:30 -07:00
committed by Facebook GitHub Bot
parent 34b1edfa1e
commit 77ea9fd1f8
2 changed files with 4 additions and 3 deletions
@@ -442,7 +442,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
return
}
val reactApplicationContext = reactApplicationContext
val reactApplicationContext = reactApplicationContextIfActiveOrWarn
if (reactApplicationContext != null) {
val uiManager = UIManagerHelper.getUIManager(reactApplicationContext, uiManagerType)
if (uiManager != null) {
@@ -12,6 +12,7 @@ import static com.facebook.infer.annotation.ThreadConfined.ANY;
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.infer.annotation.ThreadConfined;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.common.ReactConstants;
@@ -48,6 +49,7 @@ import java.util.Map;
* <p>Please note that it is not allowed to have multiple methods annotated with {@link ReactMethod}
* with the same name.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
@StableReactNativeAPI
public abstract class BaseJavaModule implements NativeModule {
// taken from Libraries/Utilities/MessageQueue.js
@@ -118,8 +120,7 @@ public abstract class BaseJavaModule implements NativeModule {
*/
@ThreadConfined(ANY)
protected @Nullable final ReactApplicationContext getReactApplicationContextIfActiveOrWarn() {
// NULLSAFE_FIXME[Nullable Dereference]
if (mReactApplicationContext.hasActiveReactInstance()) {
if (mReactApplicationContext != null && mReactApplicationContext.hasActiveReactInstance()) {
return mReactApplicationContext;
}