For the following code:
import javax.annotation.Nullable;
class Foo {
public boolean equals(@Nullable Object o) {
return this == o;
}
}
FindBugs gives the error:
NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION
Method tightens nullness annotation on parameter
If I understand @Nullable correctly, it should never be a tightening annotation, as unannotated parameters are implicitly nullable.
This is particularly an issue when the @Nullable annotation is there to undo a @ParametersAreNonnullByDefault annotation.
This bug interacts with https://sourceforge.net/p/findbugs/feature-requests/191/
Code auto-generators, like the Java Immutables project (http://immutables.github.io/), generate equals() annotated with @Nullable which is a false positive in Findbugs.
This is causing me some issues.
First of all, it's wrong. It's loosening the annotation, not tightening it. Second, loosening a method parameter annotation is perfectly acceptable.
On the other hand, loosening a return value is not (but tightening is).