Eclipse Nullable, NonNullByDefault

java

(Frank Benoit) #1

Hi

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

Assert.java:

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 );

Regards
Frank


(Andrei Epure) #3

Hello
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,
Andrei


(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?

Frank