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

查看:36
本文介绍了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 注释的替代品.如果历史可以作为指导,Java 9 GA 和 Java 8 EOL 之间的时间将相当短,我们希望修复任何我们的代码提前不兼容.理论上,我们可以升级 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.它将继续开箱即用地使用自注释模块以来的更高版本,以及与所有其他 Java EE 和 CORBA 模块一起在 JDK 11 中删除根据 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天全站免登陆