c***@frontiernet.net
2014-09-13 13:56:22 UTC
The FindBugs [most recent plugin download, v. 3.0.0] plugin produces this warning
[...]/NullCheck.java:18 o must be nonnull but is marked as nullable [Troubling(14), High confidence]
on this code
public final static @NonNull <T> T checkNonNull(@Nullable T o) {
if (o == null) throw new NullPointerException(); // <<< Line 18
return o;
}
Why?
At line 18, a Nullable parameter is compared to null
At line 19, o is no longer possibly null, so it can be returned as NonNull
The same warning happens if the method does not use generic types.
The warning does not appear if @Nullable is removed.
[The annotations are from org.eclipse.jdt.annotation ]
[...]/NullCheck.java:18 o must be nonnull but is marked as nullable [Troubling(14), High confidence]
on this code
public final static @NonNull <T> T checkNonNull(@Nullable T o) {
if (o == null) throw new NullPointerException(); // <<< Line 18
return o;
}
Why?
At line 18, a Nullable parameter is compared to null
At line 19, o is no longer possibly null, so it can be returned as NonNull
The same warning happens if the method does not use generic types.
The warning does not appear if @Nullable is removed.
[The annotations are from org.eclipse.jdt.annotation ]