Eclipse Nullable, NonNullByDefault


(Frank Benoit) #1


Running SonarJava 5.6, i get this:
squid:S4449 “Annotate the parameter with @ javax.annotation.Nullable in method ‘isNotNull’ declaration, or make sure that null can not be passed as argument.”

package is marked with @ org.eclipse.jdt.annotation.NonNullByDefault

import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;

public final class Assert {
	public static <T> @ NonNull T isNotNull( @ Nullable T obj, String message, Object ... args ){

Code that triggers the error:

Assert.isNotNull( obj, "Module %s cannot resolve obj %s", getObjectName(), path );


(Andrei Epure) #3

Thank you for your report. I am trying to reproduce the issue but cannot.
Could you please tell me what version of org.eclipse.jdt.annotation you are using?

I tested with version 2.1.100 of org.eclipse.jdt.annotation and could not reproduce your problem (i.e. issues will not be raised for parameters annotated with @org.eclipse.jdt.annotation.Nullable).

Thank you,

(Frank Benoit) #4

Hello Andrei,

thanks for trying this.
I use 2.2.0 of this bundle from Eclipse 4.8.
There is a difference in the @NonNullByDefault annotation.
Might this make a difference?