ctolkmit / checker-framework

Automatically exported from code.google.com/p/checker-framework
0 stars 0 forks source link

checker-framework does not support version 2.0.0 of org.eclipse.jdt.annotation.NonNull #359

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Use the Nullness Checker on the following program
import org.eclipse.jdt.annotation.NonNull;

abstract class Foo<E> {
    E e;

    void bar() {
        e = null;
    }

    abstract <F> Foo<@NonNull F> foo(F newValue);
}

What is the expected output? What do you see instead?
Expected: The same output as if I had used 
org.checkerframework.checker.nullness.qual.NonNull:
Foo.java:7: error: [assignment.type.incompatible] incompatible types in 
assignment.
        e = null;
            ^
  found   : null
Actual: Foo.java:10: error: annotation type not applicable to this kind of 
declaration
    abstract <F> Foo<@NonNull F> foo(F newValue);

What version of the product are you using? On what operating system?
1.8.5 (Java 8 + org.eclipse.jdt.annotation-2.0.0.jar)

Please provide any additional information below.

Original issue reported on code.google.com by ClovisSe...@gmail.com on 25 Sep 2014 at 6:42

GoogleCodeExporter commented 9 years ago
Hi Clovis,

this is not a problem with the Checker Framework.
The @NonNull annotation from org.eclipse.jdt.annotation is a declaration 
annotation and cannot be used in that syntactic location.
You will get the same error message if you use the standard Java 8 compiler 
with this source code.
You must use a type annotation in that location.

Does this help?
cu, WMD.

Original comment by wdi...@gmail.com on 25 Sep 2014 at 6:56

GoogleCodeExporter commented 9 years ago
I have added the following text to the "Troubleshooting" chapter of the manual.

The error
error: annotation type not applicable to this kind of declaration
    ... List<@NonNull String> ...
indicates that you are using a definition of @NonNull that is a declaration 
annotation, which cannot be used in that syntactic location. For example, many 
legacy annotations such as those listed in Figure 3.2 are declaration 
annotations. You can fix the problem by instead using a definition of @NonNull 
that is a type annotation, such as the Checker Framework’s annotations; often 
this only requires changing an import statement. Alternately, if you wish to 
continue using the legacy annotations in declaration locations, see Section 
22.3.5.

Original comment by michael.ernst@gmail.com on 29 Sep 2014 at 9:21