Exception occurs when change Java 8 to Java 9 in IDEA
See original GitHub issuewhen I change the JDK 8 to JDK 9 in IDEA , the follow code can’t run.
LinkedList mockedList = mock(LinkedList.class);
and my configure is
group 'mindw'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.9
repositories {
mavenCentral()
jcenter()
}
dependencies {
testCompile("org.junit.jupiter:junit-jupiter-api:5.0.3")
testCompile "org.mockito:mockito-inline:2.13.0"
}
and the exception is
C:\software\Java\jdk-9.0.4\bin\java -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:C:\software\IntelliJ\lib\idea_rt.jar=63432:C:\software\IntelliJ\bin -Dfile.encoding=UTF-8 -classpath C:\software\IntelliJ\lib\idea_rt.jar;C:\software\IntelliJ\plugins\junit\lib\junit-rt.jar;C:\software\IntelliJ\plugins\junit\lib\junit5-rt.jar;C:\software\apache-maven-3.2.5\depends\org\junit\platform\junit-platform-launcher\1.0.3\junit-platform-launcher-1.0.3.jar;C:\software\apache-maven-3.2.5\depends\org\apiguardian\apiguardian-api\1.0.0\apiguardian-api-1.0.0.jar;C:\software\apache-maven-3.2.5\depends\org\junit\platform\junit-platform-engine\1.0.3\junit-platform-engine-1.0.3.jar;C:\software\apache-maven-3.2.5\depends\org\junit\platform\junit-platform-commons\1.0.3\junit-platform-commons-1.0.3.jar;C:\software\apache-maven-3.2.5\depends\org\opentest4j\opentest4j\1.0.0\opentest4j-1.0.0.jar;C:\software\apache-maven-3.2.5\depends\org\junit\jupiter\junit-jupiter-engine\5.0.3\junit-jupiter-engine-5.0.3.jar;C:\software\apache-maven-3.2.5\depends\org\junit\jupiter\junit-jupiter-api\5.0.3\junit-jupiter-api-5.0.3.jar;C:\project\TestDemos\out\test\classes;C:\project\TestDemos\out\production\classes;C:\Users\mindw\.gradle\caches\modules-2\files-2.1\org.junit.jupiter\junit-jupiter-api\5.0.3\43872be66bab0172073ac698062419755e563353\junit-jupiter-api-5.0.3.jar;C:\Users\mindw\.gradle\caches\modules-2\files-2.1\org.mockito\mockito-inline\2.13.0\b22f846db0263bfcb35e561f793233af5e69fe1\mockito-inline-2.13.0.jar;C:\Users\mindw\.gradle\caches\modules-2\files-2.1\org.junit.platform\junit-platform-commons\1.0.3\3663f3ddfe47df2a7bf363d5c0196f0c7a09820f\junit-platform-commons-1.0.3.jar;C:\Users\mindw\.gradle\caches\modules-2\files-2.1\org.apiguardian\apiguardian-api\1.0.0\3ef5276905e36f4d8055fe3cb0bdcc7503ffc85d\apiguardian-api-1.0.0.jar;C:\Users\mindw\.gradle\caches\modules-2\files-2.1\org.opentest4j\opentest4j\1.0.0\6f09c598e9ff64bf0ce2fa7e7de49a99ba83c0b4\opentest4j-1.0.0.jar;C:\Users\mindw\.gradle\caches\modules-2\files-2.1\org.mockito\mockito-core\2.13.0\8e372943974e4a121fb8617baced8ebfe46d54f0\mockito-core-2.13.0.jar;C:\Users\mindw\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy\1.7.9\51218a01a882c04d0aba8c028179cce488bbcb58\byte-buddy-1.7.9.jar;C:\Users\mindw\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy-agent\1.7.9\a6c65f9da7f467ee1f02ff2841ffd3155aee2fc9\byte-buddy-agent-1.7.9.jar;C:\Users\mindw\.gradle\caches\modules-2\files-2.1\org.objenesis\objenesis\2.6\639033469776fd37c08358c6b92a4761feb2af4b\objenesis-2.6.jar com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit5 mockito.MockitoDemo
java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker
at org.mockito.internal.configuration.plugins.PluginLoader$1.invoke(PluginLoader.java:60)
at com.sun.proxy.$Proxy9.isTypeMockable(Unknown Source)
at org.mockito.internal.util.MockUtil.typeMockabilityOf(MockUtil.java:29)
at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:232)
at org.mockito.internal.creation.MockSettingsImpl.build(MockSettingsImpl.java:226)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:64)
at org.mockito.Mockito.mock(Mockito.java:1821)
at org.mockito.Mockito.mock(Mockito.java:1734)
at mockito.MockitoDemo.testUseDemo(MockitoDemo.java:22)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:389)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:167)
at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:163)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:110)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$3(HierarchicalTestExecutor.java:83)
at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:77)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$null$2(HierarchicalTestExecutor.java:92)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:430)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$3(HierarchicalTestExecutor.java:92)
at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:77)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$null$2(HierarchicalTestExecutor.java:92)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:430)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$3(HierarchicalTestExecutor.java:92)
at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:77)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:51)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:65)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in java.lang.CompoundEnumeration@3349e9bb
at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:94)
at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:48)
at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:20)
at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:18)
at org.mockito.internal.util.MockUtil.<clinit>(MockUtil.java:24)
... 58 more
Caused by: org.mockito.exceptions.base.MockitoInitializationException:
Could not initialize inline Byte Buddy mock maker. (This mock maker is not supported on Android.)
Java : 9
JVM vendor name : Oracle Corporation
JVM vendor version : 9.0.4+11
JVM name : Java HotSpot(TM) 64-Bit Server VM
JVM version : 9.0.4+11
JVM info : mixed mode
OS name : Windows 10
OS version : 10.0
at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<init>(InlineByteBuddyMockMaker.java:171)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
at java.base/java.lang.Class.newInstance(Class.java:558)
at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:89)
... 62 more
Caused by: java.lang.IllegalStateException: Could not self-attach to current VM using external process
at net.bytebuddy.agent.ByteBuddyAgent.installExternal(ByteBuddyAgent.java:433)
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:371)
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:352)
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:320)
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:306)
at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<clinit>(InlineByteBuddyMockMaker.java:101)
... 68 more
How can I solve the problem?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:12
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Migrating From JDK 8 to Later JDK Releases
Changed JDK and JRE Layout After you install the JDK, if you look at the file system, you'll notice that the directory layout...
Read more >Selecting the JDK version the IDE will run under
I tried to run IntelliJ 14 with Java 8 in the past and found that I had to set java.net.preferIPv4Stack=false to get it...
Read more >Class has been compiled by a more recent version of the Java ...
This is just a version mismatch. You have compiled your code using java version 9 and your current JRE is version 8. Try...
Read more >Java Features from Java 8 to Java 17 - Reflectoring
The main changes of the Java 8 release were these: ... Since I am working in the IntelliJ IDEA there is something that...
Read more >How to Fix UnsupportedClassVersion Error in Java - Rollbar
The UnsupportedClassVersionError in Java occurs when the JVM attempts to read a malformed or otherwise erroneous class file.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello, I have a similar issue on Windows 10 with Windows Subsystem for Linux with a jdk 8 update 172 with mockito-core version 2.18.3.
We are now succesfully running on JDK 11 and newer versions such as JDK 17.