美文网首页
Java 11 下使用xjar报错

Java 11 下使用xjar报错

作者: 木木111314 | 来源:发表于2021-12-28 18:12 被阅读0次

    问题描述

    环境

    java 11

    启动脚本

    .\xjarwin.exe  D:\java\jdk-11.0.6\\bin\\java.exe    -jar .\\system.jar 
    

    错误信息

    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
    

    解决方式

    参考修改启动脚本
    Java 9 Compatibility · Issue #187 · java-decompiler/jd-gui (github.com)

    添加

     --add-opens java.base/jdk.internal.loader=ALL-UNNAMED 
    

    最终启动命令

    .\xjarwin.exe  D:\java\jdk-11.0.6\\bin\\java.exe --add-opens java.base/jdk.internal.loader=ALL-UNNAMED  -jar .\\system.jar 
    

    相关文章

      网友评论

          本文标题:Java 11 下使用xjar报错

          本文链接:https://www.haomeiwen.com/subject/zvopqrtx.html