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
final Object obj = ...
final boolean test = obj != null;
if (test) {
obj.getClass();
}
This gives a potential null pointer access warning on obj.getClass();, but it cannot be null.
I think this happens just because of the code prior to it including a null check somewhere. But in this case, the compiler should be able to figure out that the statement is conditioned by a boolean that already specifically claims that the object is not null.
Workaround; it works fine if the boolean declaration is moved into the condition as a literal expression like if (obj != null)
But the simplicity of above code should be recoverable in the first place.
The text was updated successfully, but these errors were encountered:
This gives a potential null pointer access warning on
obj.getClass();
, but it cannot be null.I think this happens just because of the code prior to it including a null check somewhere. But in this case, the compiler should be able to figure out that the statement is conditioned by a boolean that already specifically claims that the object is not null.
Workaround; it works fine if the boolean declaration is moved into the condition as a literal expression like
if (obj != null)
But the simplicity of above code should be recoverable in the first place.
The text was updated successfully, but these errors were encountered: