/
Java - Handling error "accessible: module <module name> does not "opens java.lang" to unnamed module"
Java - Handling error "accessible: module <module name> does not "opens java.lang" to unnamed module"
Problem
JVM return an error like
Caused by: 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 @1d7acb34
Cause
The issue at hand is caused by newer versions of Java restricting access to certain libraries. We can see that issues are occurring as SeaLights added support to Java 17.
Solution
Adding the option --add-opens java.base/java.lang=ALL-UNNAMED
to the Maven Surefire plugin
and Maven Failsafe plugin
configuration prevents exceptions like that.
Example for the Maven Surefire plugin
"surefireArgLine": "-Xms1280m -Xmx1280m @{sealightsArgLine} ${surefireArgLine} --add-opens java.base/java.lang=ALL-UNNAMED"
Example for the Maven Failsafe plugin
"failsafeArgLine": "-Xmx8192m @{sealightsArgLine} -Dsl.testStage=\"Integration Tests\" --add-opens java.base/java.lang=ALL-UNNAMED"
, multiple selections available,
Related content
Supporting Special Use Cases - Test Runners & SeaLights Java Agent
Supporting Special Use Cases - Test Runners & SeaLights Java Agent
More like this
SeaLights Java agent - Command Reference
SeaLights Java agent - Command Reference
Read with this
Java Agent - Minimum Version Supported
Java Agent - Minimum Version Supported
More like this
Maven build tool - Sealights plugin
Maven build tool - Sealights plugin
More like this
SeaLights Java Agent - AWS Lambda Support
SeaLights Java Agent - AWS Lambda Support
Read with this
SeaLights Node.js agent - AWS Lambda Support
SeaLights Node.js agent - AWS Lambda Support
Read with this