YYDS
发布于

Java 11 下使用xjar报错

错误信息


WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.xjar.reflection.XReflection (file:/D:/sss/*****system.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 @670b40af
        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.<init>(XBootClassLoader.java:42)
        at io.xjar.boot.XJarLauncher.createClassLoader(XJarLauncher.java:31)
        at org.springframework.boot.loader.ExecutableArchiveLauncher.createClassLoader(ExecutableArchiveLauncher.java:92)
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:55)
        at io.xjar.boot.XJarLauncher.launch(XJarLauncher.java:26)
        at io.xjar.boot.XJarLauncher.main(XJarLauncher.java:22)
panic: exit status 1

goroutine 1 [running]:
main.main()
        /var/jenkins_home/workspace/system/target/xjarwin.go:73 +0x646

解决办法 启动参数新增 --add-opens java.base/jdk.internal.loader=ALL-UNNAMED

java --add-opens java.base/jdk.internal.loader=ALL-UNNAMED  -Dfile.encoding=utf-8 -Dspring.profiles.active=dev -Xms2048m -Xmx2048m  -XX:PermSize=64m -XX:MaxPermSize=128m  -Djava.awt.headless=true -Dspring.config.additional-location=./config/application-dev.yml  -jar  

评论