I have an executable Jar which is using reflection in order to access some java internal (actually I am shading some third party library like Netty, DNSJava...)
I see that adding this entry to the MANIFEST of the Jar
Add-Opens: java.base/sun.net.dns
solves my first problem:
WARNING: An illegal reflective access operation has occurred
WARNING: 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.ResolverConfig
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
But now I have a second warning:
WARNING: An illegal reflective access operation has occurred
WARNING: 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.defaultTimeZone
WARNING: Please consider reporting this to the maintainers of org.postgresql.jdbc.TimestampUtils
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
And I need to add this new exception
Add-Opens: java.base/java.util
I am trying with:
Add-Opens: java.base/java.util,java.base/sun.net.dns
Add-Opens: java.base/java.util;java.base/sun.net.dns
Add-Opens: java.base/java.util:java.base/sun.net.dns
Without results. I can't find any "specification" about Add-Opens
JEP 261: Module System explains how to specify multiple module/package combinations:
Two new JDK-specific JAR-file manifest attributes are defined to correspond to the --add-exports and --add-opens command-line options:
Add-Exports:
<module>/<package>( <module>/<package>)*
Add-Opens:
<module>/<package>( <module>/<package>)*
The value of each attribute is a space-separated list of slash-separated module-name/package-name pairs
Emphasis mine
You can add multiple add-opens during running application.
Example could help:
java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED -jar test.war
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With