java tekv,正确修复Java 10抱怨jaxb-impl 2.3.0的非法反射访问?

在升级到Java 10时遇到JAXB不可见的问题,添加了相关依赖后,启动时仍然出现非法反射访问警告。警告涉及com.sun.xml.bind.v2.runtime.reflect.opt.Injector。解决方案包括设置系统属性禁用优化或等待新的jaxb-ri版本,并调整pom.xml依赖至最新版本。
摘要由CSDN通过智能技术生成

We are looking at upgrading some legacy code to Java 10. As JAXB is not visible by default (EDIT: and the proper long term solution is not to circumvent the symptom using various JVM flags, but fix it properly) I have added this snippet to my pom.xml:

javax.xml.bind

jaxb-api

2.3.0

com.sun.xml.bind

jaxb-core

2.3.0

com.sun.xml.bind

jaxb-impl

2.3.0

Unfortunately there is still a warning printed at startup to stderr. Apparently this is not the correct fix.

WARNING: An illegal reflective access operation has occurred

WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/home/tra/.m2/repository/com/sun/xml/bind/jaxb-impl/2.3.0/jaxb-impl-2.3.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)

WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector

WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations

WARNING: All illegal access operations will be denied in a future release

The full output from --illegal-access=debug is:

WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/home/tra/.m2/repository/com/sun/xml/bind/jaxb-impl/2.3.0/jaxb-impl-2.3.0.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)

at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.getMethod(Injector.java:222)

at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.access$000(Injector.java:74)

at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$1.run(Injector.java:175)

at com.sun.xml.bind.v2.runtime.reflect.opt.Injector$1.run(Injector.java:172)

at java.base/java.security.AccessController.doPrivileged(Native Method)

at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.(Injector.java:171)

at com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector.prepare(AccessorInjector.java:81)

at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:179)

at com.sun.xml.bind.v2.runtime.reflect.Accessor$FieldReflection.optimize(Accessor.java:285)

at com.sun.xml.bind.v2.runtime.property.ArrayProperty.(ArrayProperty.java:68)

at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.(ArrayERProp

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值