I've got a Spring Boot application (V3 + JDK 17) that prints a warning to open some modules (because of JRuby):
2023-07-14T11:13:35.651Z [main] WARN FilenoUtil : Native subprocess control requires open access to the JDK IO subsystem
Pass '--add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED' to enable.
Now passing the suggested params (either as command-line args or via JDK_JAVA_OPTIONS
env var) removes the warning.
I also learned that the same can be achieved by adding the modules in an Add-Opens
entry:
// build.gradle.kts
bootJar {
requiresUnpack("**/asciidoctorj-*.jar")
manifest {
attributes["Add-Opens"] = "java.base/java.io java.base/sun.nio.ch"
}
}
And I can confirm that the final fat JAR file created by Spring Boot plugin does indeed have a MANIFEST.MF with the expected entry:
Manifest-Version: 1.0
Add-Opens: java.base/java.io java.base/sun.nio.ch
Main-Class: org.springframework.boot.loader.JarLauncher
# Other entries!!!
And when I run the JAR file (using java -jar
) I can see the warning is gone.
However, when I deploy the docker image built by gradle bootBuildImage
(default configuration, nothing customized), I still see the warning. I checked the MANIFEST.MF file in the container and the expected entry exists.
Does anyone know why it doesn't work? Or generally what's the right way to get rid of the warning?
Update
The short answer is "Add-Opens
manifest entries are only supported when launching the JVM using java -jar
." (see this and this).