java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module

734 views Asked by At

I am getting following error while running a test in my Project:

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 @XXXXXX

I am using the green run arrow next to my test method to execute the test as specified here.

Solution such as these might be helpful, but I am not sure how to pass a command line argument in this case --add-opens=java.base/java.lang=ALL-UNNAMED to be added while running the tests in a method specified above.?

1

There are 1 answers

0
Jacky Liu On

Please try the menu Run | Edit Configurations..., and click the Modify options drop-down, then click the checkbox menu Add VM Options, input:

--add-opens=java.base/java.lang=ALL-UNNAMED

This should fix this problem.

enter image description here