I am trying to fix the issue with running Nexus IQ scanner using Java 17 runtime.
The error is
java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @7225790e
So I try to pass --add-opens java.base/java.lang=ALL-UNNAMED
fix to the JVM which runs nexus-iq-cli.jar
.
Unfortunately, I do not have a full control over java -jar ...
command which gets executed on CI, otherwise I would just pass --add-opens java.base/java.lang=ALL-UNNAMED
explicitly. Because of that limitation I try to use some other ways to set global JVM argument settings. One way to do it which came to my mind is using _JAVA_OPTIONS
environment variable.
The thing which surprises me is that Java quits with an error:
Unrecognized option: --add-opens
When I try to pass it as follows:
# with unix shell you can set value to some variable and execute something in one line
_JAVA_OPTIONS='--add-opens java.base/java.lang=ALL-UNNAMED' java
On the other hand, Java is totally fine and acts as expected when I pass this option directly as:
java --add-opens java.base/java.lang=ALL-UNNAMED
What am I missing and what are the other possible ways to pass --add-opens java.base/java.lang=ALL-UNNAMED
argument if I do not have a direct control over the java -jar
command which CI executes to perform Nexus IQ scan step?
JAVA_TOOL_OPTIONS
as a temporary workaround. – Dawson