Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

JAVA 17 Junit test cases failing with java.lang.reflect.InaccessibleObjectException

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:

  1. —add-opens java.base/java.lang=ALL-UNNAMED or
  2. --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.

Answer*

Draft saved
Draft discarded
Cancel
1
  • 4
    In your question you said you can’t use —add-opens, now your "solution" is exactly that. Commented May 23, 2023 at 7:36

lang-java

AltStyle によって変換されたページ (->オリジナル) /