SonarQube rule java:S4449 (“Nullness of parameters should be guaranteed”) reports false positives when a method parameter is annotated with Nullable (Jakarta Validation or JSpecify) in a package that is marked as NullMarked (JSpecify).
Example
public abstract class AbstractBaseEntity<I> implements BaseEntity<I> {
@org.jspecify.annotations.Nullable`
@jakarta.annotation.Nullable`
private I id;
public void setId( @jakarta.annotation.Nullable @org.jspecify.annotations.Nullable final I id ) {
this.id = id;
}
Class Bar
public foo() {
entity.setId( null );
}
This setId raised always “Annotate the parameter with javax.annotation.Nullable in method setId declaration.”