In my Eclipse Neon workspace settings i checked [x] Enable annotation-based null analysis. Now when I'm doing Assign statement to new variable from quick assist, Eclipse sometimes adds @NonNull to the new variable assigment. So intead of line 1, I get line 2:
Deprecated annotation = Main.class.getAnnotation(Deprecated.class); // line 1
@NonNull Deprecated annotation = Main.class.getAnnotation(Deprecated.class); // line 2
This raises two questions:
How can I enable and disable this behaviour? In a second project within the same workspace Eclipse doesn't to this. So it doesn't only depend on the annotation-based null analysis which was configured in the workspace settings.
Why does Eclipse conclude
annotationis@NonNullwhile the return value can be clearly benull(by documentation):
java.lang.annotation.Annotation java.lang.Class.getAnnotation(java.lang.Class annotationClass)Returns this element's annotation for the specified type if such an annotation is present, else null.