jmockit / jmockit1

Advanced Java library for integration testing, mocking, faking, and code coverage
Other
465 stars 240 forks source link

IllegalStateException: JMockit requires a Java 6+ VM at mockit.internal.startup.AgentInitialization.loadAgentFromLocalJarFile #646

Closed milossesic closed 4 years ago

milossesic commented 4 years ago

Getting below stack trace with java 11 environment. the same setup works fine for jdk8 (tests pass).

java.lang.IllegalStateException: JMockit requires a Java 6+ VM at mockit.internal.startup.AgentInitialization.loadAgentFromLocalJarFile(AgentInitialization.java:23) at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:252) at mockit.integration.junit4.JMockit.(JMockit.java:21) 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:490) at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104) at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:101) at org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:87) at org.junit.runners.Suite.(Suite.java:102) at org.junit.runners.Suite.(Suite.java:70) 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:490) at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:107) at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49) 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)

rliesenfeld commented 4 years ago

You will have to use a newer version of JMockit, I suppose.

realduke2000 commented 2 years ago

I get the same issue.

java.lang.IllegalStateException: JMockit requires a Java 6+ VM at mockit.internal.startup.AgentInitialization.loadAgentFromLocalJarFile(AgentInitialization.java:25) at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:212) at mockit.integration.testng.Initializer.(Initializer.java:29) 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:490) at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:779) at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:721) at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1394) at org.testng.TestNG.addServiceLoaderListeners(TestNG.java:965) at org.testng.TestNG.initializeConfiguration(TestNG.java:914) at org.testng.TestNG.run(TestNG.java:1037) at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:73) at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123) java.util.ServiceConfigurationError: org.testng.ITestNGListener: Provider mockit.integration.testng.Initializer could not be instantiated at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:581) at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:803) at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:721) at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1394) at org.testng.TestNG.addServiceLoaderListeners(TestNG.java:965) at org.testng.TestNG.initializeConfiguration(TestNG.java:914) at org.testng.TestNG.run(TestNG.java:1037) at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:73) at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123) Caused by: java.lang.IllegalStateException: JMockit requires a Java 6+ VM at mockit.internal.startup.AgentInitialization.loadAgentFromLocalJarFile(AgentInitialization.java:25) at mockit.internal.startup.Startup.initializeIfPossible(Startup.java:212) at mockit.integration.testng.Initializer.(Initializer.java:29) 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:490) at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:779) ... 7 more

milossesic commented 2 years ago

As suggested by the dude, ramping up the version of jmockit solved it.

realduke2000 commented 2 years ago

I downloaded the java8 from zulu, and update the runtime enviornment for this...