我有一个可执行 Jar,它使用反射来访问一些 Java 内部(实际上我正在隐藏一些第三方库,如 Netty、DNSJava ......)我看到将此条目添加到 Jar 的 MANIFESTAdd-Opens: java.base/sun.net.dns解决了我的第一个问题:WARNING: An illegal reflective access operation has occurredWARNING: Illegal reflective access by org.xbill.DNS.ResolverConfig (file:/home/diennea.lan/enrico.olivelli/dev/magnews/magnews.installer/target/magnews-24.05-SNAPSHOT.dev-b199bacf8f2-noci-installer.jar) to method sun.net.dns.ResolverConfiguration.open()WARNING: Please consider reporting this to the maintainers of org.xbill.DNS.ResolverConfigWARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operationsWARNING: All illegal access operations will be denied in a future release但现在我有第二个警告:WARNING: An illegal reflective access operation has occurredWARNING: Illegal reflective access by org.postgresql.jdbc.TimestampUtils (file:/home/diennea.lan/enrico.olivelli/dev/magnews/magnews.installer/target/example/.tmpPackage/packages/postgresql.jar) to field java.util.TimeZone.defaultTimeZoneWARNING: Please consider reporting this to the maintainers of org.postgresql.jdbc.TimestampUtilsWARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operationsWARNING: All illegal access operations will be denied in a future release我需要添加这个新的例外Add-Opens: java.base/java.util我正在尝试:Add-Opens: java.base/java.util,java.base/sun.net.dnsAdd-Opens: java.base/java.util;java.base/sun.net.dnsAdd-Opens: java.base/java.util:java.base/sun.net.dns没有结果。我找不到任何关于 Add-Opens 的“规范”
3 回答
吃鸡游戏
TA贡献1829条经验 获得超7个赞
JEP 261:模块系统解释了如何指定多个模块/包组合:
定义了两个新的特定于 JDK 的 JAR 文件清单属性以对应于 --add-exports 和 --add-opens 命令行选项:
添加导出:
<module>/<package>( <module>/<package>)*
添加打开:
<module>/<package>( <module>/<package>)*
每个属性的值是一个以空格分隔的列表,由斜杠分隔的模块名称/包名称对组成
强调我的
慕尼黑的夜晚无繁华
TA贡献1864条经验 获得超6个赞
您可以在运行应用程序期间添加多个添加打开。
示例可以帮助:
java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED -jar test.war
添加回答
举报
0/150
提交
取消