Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon Coretto 11, Spring Boot and PowerMock - tests failing

I have a java based Spring Boot project that uses PowerMock to mock static methods and contructor invocations where necessary Since upgrading to the latest version of IntelliJ - I need to use a JDK version greater than JDK 8 I moved to Amazon Coretto as I want to deploy my app on the latest support JDK on AWS Elastic Beanstalk When I upgraded and ran my tests, I started hitting issues After following this thread - https://github.com/java-decompiler/jd-gui/issues/187 and using this PowerMockIgnore syntax

@PowerMockIgnore("javax.management.", "com.sun.org.apache.xerces.", "javax.xml.", "org.xml.", "org.w3c.dom.", "com.sun.org.apache.xalan.", "javax.activation.*", "javax.xml.transform.*", "com.sun.org.apache.xalan.*")

I get this error

java.lang.RuntimeException: java.lang.reflect.InaccessibleObjectException: Unable to make protected java.lang.Class jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(java.lang.String,boolean) throws java.lang.ClassNotFoundException accessible: module java.base does not "opens jdk.internal.loader" to unnamed module @d5ce97f
    at org.powermock.core.classloader.DeferSupportingClassLoader.findResource(DeferSupportingClassLoader.java:154)
    at java.base/java.lang.ClassLoader.findResource(ClassLoader.java:1342)
    at java.base/java.lang.Module.getResourceAsStream(Module.java:1575)
    at kotlin.reflect.jvm.internal.impl.serialization.deserialization.builtins.BuiltInsResourceLoader.loadResource(BuiltInsResourceLoader.java:27)
    at kotlin.reflect.jvm.internal.impl.descriptors.runtime.components.ReflectKotlinClassFinder.findBuiltInsData(ReflectKotlinClassFinder.kt:52)
    at kotlin.reflect.jvm.internal.impl.builtins.jvm.JvmBuiltInsPackageFragmentProvider.findPackage(JvmBuiltInsPackageFragmentProvider.kt:60)

This has had me stumped for days now. Can anyone offer any further suggestions on what I could try

Regards Damien

like image 463
Damien Avatar asked Dec 15 '20 13:12

Damien


1 Answers

I could not find a solution to get PowerMock to work with Java 11 so I have removed it from my project

like image 111
Damien Avatar answered Oct 09 '22 09:10

Damien