I have a very simple class and using Immutables library. The auto-generated code defines equals method like so:
@Override
public boolean equals(@Nullable Object another) {
The @Nullable annotation causes the following FindBugs error:
NP_METHOD_PARAMETER_TIGHTENS_ANNOTATION: Method tightens nullness annotation on parameter
A method should always implement the contract of a method it overrides. Thus, if a method takes a parameter that is marked as @Nullable, you shouldn't override that method in a subclass with a method where that parameter is @Nonnull. Doing so violates the contract that the method should handle a null parameter.
I am using Immutables-value-2.5.6.jar
Has anyone seen this error?
I have mitigated the issue temporarily by adding:
@SuppressFBWarnings
to the Immutables class. But I don't think this is a long term solution. There must be something else I am missing.