java jsr305,Java 9的JSR-305注释替换

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.

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.

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.

解决方案

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.

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值