java version:17 mockito version:5.3.0
As I am upgrading to java 17, junit test cases are failing with reason:
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 @38cccef
Please suggest some solution as I CANNOT use solutions:
- —add-opens java.base/java.lang=ALL-UNNAMED or
- --illegal-access=permit (removed in java 17)
I am expecting to solve this problem by adding any new dependency in pom.xml or different version of mockito. with minimal code change.
Follow the instructions in the mockito release notes under '5.0.0' here. Essentially, switch the mockmaker implementation.
That, or downgrade back to JDK11.