-2

目前我正在研究Java8的新特性:http://www.oracle.com/technetwork/java/javase/8-whats-new-2157071.html

从上面的链接中可以清楚地看出:

Type Annotations provide the ability to apply an annotation anywhere a type is used, not just on a declaration. Used with a pluggable type system, this feature enables improved type checking of your code.

但是当我尝试在 Eclipse Neon 中添加诸如@NotNullor之类的类型注释时@Readonly,它根本无法识别这些注释!这太令人沮丧了。

我错过了什么?或者如果我需要做更多的配置,比如添加额外的 jar,为什么这仍然被列为 Java 8 的新特性?

4

1 回答 1

0

@Jens 谢谢 :) 我再次从 Google 搜索并找到以下链接: https ://docs.oracle.com/javase/tutorial/java/annotations/type_annotations.html

在链接页面中,有人告诉The Java SE 8 release does not provide a type checking framework, but it allows you to write (or download) a type checking framework that is implemented as one or more pluggable modules that are used in conjunction with the Java compiler.

所以关键是有一个checker frameworkDIY 或使用现有的checker framework. 在链接页面的末尾,还有另一个现有的链接页面Checker Framework- https://checkerframework.org/这可能是迄今为止我们可以使用的最佳框架:)

于 2016-09-21T08:10:16.430 回答