javax.annotation.Nullable 导致的 SecurityException

java.lang.SecurityException: class "javax.annotation.Nullable"'s signer information does not match signer information of other classes in the same package

 

1.1. 场景

代码中使用了 javax.annotation.Nullable,项目启动时报 SecurityException。

1.2. 问题分析

项目依赖的两个 jar 包中都有 javax.annotation,一个是 com.google.code.findbugs:annotations 另一个是 org.eclipse.jetty.orbit:javax.annotation。

两个分别引入的是 JSR 305 和 JSR 250,但是 jetty 中的 jar 是带签名的,而 findbugs 中没有签名,jvm 加载检查数字签名有问题,会抛异常。

1.3. 原理分析

TODO

参考文档

jetty 8 (8.1.10.v20130312) 依赖 org.eclipse.jetty.orbit:javax.annotation;mtthrift、mtconfig 则依赖 com.google.code.findbugs:annotations。这两个依赖中都有 javax.annotation 包,但是前者 jar 是带签名的,后者没有签名。jvm 加载时,检查到数字签名有问题,就会抛出异常。

jetty 依赖的 javax.annotation 实现了 JSR 250: Common Annotations for the JavaTM Platform

  • javax.annotation (Generated, ManagedBean , PostConstruct, PreDestroy, Resource, Resources)

  • javax.annotation.security (DeclareRoles, DenyAll, PermitAll, RolesAllowed, RunAs) 

  • javax.annotation.sql (DataSourceDefinition, DataSourceDefinitions) - since version 1.1

除了 Jetty Orbit,还有以下常见的 JSR 250 实现:

而 findbugs:annotations 则实现了 JSR 305: Annotations for Software Defect Detection

  • javax.annotation (CheckForNull, ... , Nonnull, Nullable, ... , WillNotClose)

  • javax.annotation.concurrent (GuardedBy, ... , ThreadSafe)

  • javax.annotation.meta (Exclusive, ... , When)

除了这个 findbugs:annotations,还有一个实现 jsr305.jar http://mavenhub.com/c/javax/annotation/nullable/jar

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值