Java 8, Type Annotations and JSR 308

前端 未结 2 1772
醉梦人生
醉梦人生 2021-01-02 02:35

I\'ve installed the last JDK 8 (b116) but I noticed that I can\'t use type annotations. For example reading the Java tutorial if I write:

String str = null;
         


        
2条回答
  •  萌比男神i
    2021-01-02 02:48

    For the second part:

    I also don't understand if the annotations like: NonNull, Interned, etc. will be inserted in the JDK or if we have to download the Checker Framework.

    The Oracle-distributed JDK does not contain annotations like @NonNull and @Interned -- neither definitions of them, nor occurrences of them on JDK methods.

    However, the Checker Framework contains annotated versions of the JDK, as explained in the Checker Framework manual. The Checker Framework lets you use the definitive version of a library at run time and even at compile time, while pluggable type-checking sees the annotations and thus the type-checking results are more precise.

提交回复
热议问题