Java 9的JSR-305注释替换 [英] JSR-305 annotations replacement for Java 9

查看:288
本文介绍了Java 9的JSR-305注释替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我们一直在使用Findbugs JSR-305批注(com.google.code.findbugs:jsr305),包括工具支持在内的所有组件(Sonar,Eclipse,Findbugs等)都可以正常工作.

So far we have been using the Findbugs JSR-305 annotations (com.google.code.findbugs:jsr305) and everything including tool support (Sonar, Eclipse, Findbugs, …) has been working fine.

但是,据我们了解,Java 9中的Jigsaw将破坏JSR-305注释(不允许在两个模块中使用一个软件包).这在JavaOne 2015上得到了证实.Oracle的推理是JSR-305从未发生过,JSR-250将不得不认可这些注释.

However it is our understanding that Jigsaw in Java 9 is going to break JSR-305 annotations (one package in two modules is not allowed). This was confirmed at JavaOne 2015. Oracle's reasoning is JSR-305 never happened and JSR-250 would have to endorse these annotations.

我们正在寻找可以在Java 8和Java 9中使用的JSR-305注释的替代品.事先与我们的代码不兼容.从理论上讲,我们可以升级JDK的注释模块,但是在整个工具链中这样做似乎是很多工作.

We're looking for replacements for JSR-305 annotations that work in both Java 8 and Java 9. If history is any guide the time between Java 9 GA and Java 8 EOL will be rather short and we would like to fix any incompatibilities in our code in advance. In theory we could upgrade the annotations module of the JDK but doing this across our toolchain seems like a lot of work.

推荐答案

的确,两个模块通常不能在同一模块中定义类型 包裹.直到最近,将jsr305.jar放在 JDK  9版本无效:该JAR文件定义了 javax.annotation程序包,但该程序包是在平台的内置程序中定义的 java.xml.ws.annotation模块,后者优先.

It’s true that two modules cannot, ordinarily, define types in the same package. Until recently, putting jsr305.jar on the class path of a JDK 9 build would have no effect: That JAR file defines types in the javax.annotation package but that package is defined in the platform’s built-in java.xml.ws.annotation module, and the latter takes precedence.

然而,部分原因是jsr305.jar的广泛使用以及 现有的应用程序服务器更容易迁移到JDK  9,我们进行了更改 在其中包括注释模块的默认根模块集 其他.将jsr305.jar放在JDK  9类路径上可以直接使用 同时使用JDK  9和JDK  10;有关详细信息,请参见 JEP  261 .它将继续 自注释模块以来,可以立即与更高版本一起使用 JDK  11中删除了所有其他Java&EE和CORBA模块 根据 JEP  320 .

Owing in part to the widespread use of jsr305.jar, however, and also to make it easier for existing application servers to migrate to JDK 9, we changed the default set of root modules to exclude the annotations module, among others. Putting jsr305.jar on the JDK 9 class path works out-of-the-box with both JDK 9 and JDK 10; details are available in JEP 261. It will continue to work out-of-the-box with later releases since the annotations module, along with all the other Java EE and CORBA modules, were removed in JDK 11 per JEP 320.

这篇关于Java 9的JSR-305注释替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆