Hi
goal
my goal is to launch spring boot application with docker without having to manipulate custom --add-opens JVM options
needed by my application
- my Dockerfile format is very close to this documentation so today using layers and JarLauncher (with jdk 8).
issue
when migrating to JDK 17 the AddOpens entries that are in (jar file::)META-INF/MANIFEST.MF file are not well undertaken by JarLauncher.
MANIFEST.MF extract (Add-Opens doc):
Add-Opens: java.base/java.lang java.base/java.util
NB: when using java -jar executable.jar, I've no issue, because (manifest)Add-Opens are well undertaken.
If I understand well JarLauncher mecanism, and in my case for an exploded jar mode, the jarLauncher will only retrieve, classpath entries, mainclass from exploded jar and create a mainclasswrapper to launch my app. So this is too late to include bootstrap VM options like --add-opens.
But in source code I saw that a jarmode property could be used to drive a custom launcher.
how to fix ?
- Is there any chance to handle manifest
Add-Opensentries withJarLauncher? or with a "jarmode custom launcher" ? (any sample?) - another way to fix that is to say that
JarLauncheris unable to support this entries: in this case (in layer mode), there is maybe a need to document thatadd-opensmust be driven by user manually (prior to JarLauncher).
Comment From: wilkinsona
Unfortunately, what you're trying to do is not possible. Add-Opens manifest entries are only supported when launching the JVM using java -jar. This is how the JVM behaves and is unrelated to whether or not JarLauncher is used as the main class. You'll have to customize the entry point in your Dockerfile to specify the necessary --add-opens arguments.