Recently I was upgrading my project from JDK 11 to JDK 17. After upgrading, powermock seems to have an issue. While running AUT's , I am getting following error:
java.lang.RuntimeException: PowerMock internal error: Should never throw exception at this level
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException accessible: module java.base does not "opens java.lang" to unnamed module @3fc34119
Do you know any workaround this issue, If so can you please provide the solution.
As a stop gap measure (until Powermock gets updated), you should be able to run your tests by passing the following argument to your JVM:
--add-opens java.base/java.lang=ALL-UNNAMED
If you're running your tests with Maven
, you can configure the surefire-plugin
like this:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${plugin.surefire.version}</version>
<configuration>
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
</configuration>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With