You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suppose that we use 0.14+ up to 0.14.2 with -XepOpt:NullAway:JSpecifyJDKModels=true.
In order to pass all checks we have to either suppress code that contains Optional.orElseGet or wrap the call into Objects.requireNonNull(optional.orElseGet(() -> guaranteed non-null return)).
With 0.14.3 at least some such cases are handled "as expected", and we could remove unnecessary suppressions and requireNonNull-s.
nullaway-suppression-remover helps with finding and removing the unnecessary suppressions.
It would be good if there was something similar that would help with finding unnecessary requireNonNull calls.
Best case if it is an additional error-prone check or null-away option, so it could be enforced automatically.
Somehow i was under impression that CastToNonNullMethod has some default value and already does something.
Adding -XepOpt:NullAway:CastToNonNullMethod=java.util.Objects.requireNonNull does exactly what i want - produces a compilation failure with a message like [NullAway] passing known @NonNull parameter 'xxx' to CastToNonNullMethod.
Activity
msridhar commentedon Oct 23, 2026
Could you try setting
requireNonNullas theCastToNonNullMethod:https://github.com/uber/NullAway/wiki/Configuration#specify-casttononnull-method
Possibly you'll then get warnings in the places you want?
estekhin commentedon Oct 24, 2026
Somehow i was under impression that
CastToNonNullMethodhas some default value and already does something.Adding
-XepOpt:NullAway:CastToNonNullMethod=java.util.Objects.requireNonNulldoes exactly what i want - produces a compilation failure with a message like[NullAway] passing known @NonNull parameter 'xxx' to CastToNonNullMethod.Thank you for pointing out this exsiting option!
msridhar commentedon Oct 24, 2026
Great, so glad it worked!