xjar
xjar copied to clipboard
jdk11启动加密后jar失败,是不是xjar与jdk11不兼容呢?
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.xjar.reflection.XReflection (file:/usr/local/services/new.jar) to field java.net.URLClassLoader.ucp
WARNING: Please consider reporting this to the maintainers of io.xjar.reflection.XReflection
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
Exception in thread "main" java.lang.reflect.InaccessibleObjectException: Unable to make public jdk.internal.loader.Resource jdk.internal.loader.URLClassPath.getResource(java.lang.String) accessible: module java.base does not "exports jdk.internal.loader" to unnamed module @76a3e297
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:340)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:280)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:198)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:192)
at io.xjar.reflection.XReflection.method(XReflection.java:35)
at io.xjar.boot.XBootClassLoader.
java version "11.0.10"
这个是由于 jdk9 以上引入了 export module 的概念,启动参数添加这个可以解决 --add-opens java.base/jdk.internal.loader=ALL-UNNAMED
例如:./xjar java --add-opens java.base/jdk.internal.loader=ALL-UNNAMED -jar ./*.xjar
https://www.coder.work/article/61641
@1262135749 你这个解决了吗?或者有没有什么更好的替代品?谢谢!
@tanyaofei 我用的是Java17和Springboot3,加上了您说的那些参数 还是报错。这怎么办?谢谢!!