java.lang.IllegalStateException

Failed to transform class with name com.test.MyTestClass. Reason: PowerMock internal error when modifying method.

Solutions on the web19052

  • Failed to transform class with name com.test.MyTestClass. Reason: PowerMock internal error when modifying method.
  • Failed to transform class with name com.test.MyTestClass. Reason: PowerMock internal error when modifying method.
  • Failed to transform class with name oracle.adf.share.ADFContext. Reason: PowerMock internal error when modifying method.
  • Stack trace

    • java.lang.IllegalStateException: Failed to transform class with name com.test.MyTestClass. Reason: PowerMock internal error when modifying method. at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:207) at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:145) at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:67) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.lang.ClassLoader.defineClass(ClassLoader.java:643) at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:210) at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:145) at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:67) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:270) at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:133) at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:39) at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.createTestDelegators(AbstractTestSuiteChunkerImpl.java:217) at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.<init>(JUnit4TestSuiteChunkerImpl.java:59) at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.<init>(AbstractCommonPowerMockRunner.java:32) at org.powermock.modules.junit4.PowerMockRunner.<init>(PowerMockRunner.java:31) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29) at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21) 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:26) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) Caused by: java.lang.RuntimeException: PowerMock internal error when modifying method. at org.powermock.core.transformers.impl.MainMockTransformer$PowerMockExpressionEditor.edit(MainMockTransformer.java:304) at javassist.expr.ExprEditor.loopBody(ExprEditor.java:192) at javassist.expr.ExprEditor.doit(ExprEditor.java:91) at javassist.CtClassType.instrument(CtClassType.java:1385) at org.powermock.core.transformers.impl.MainMockTransformer.transform(MainMockTransformer.java:75) at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:203) ... 36 more Caused by: javassist.NotFoundException: mockStatic(..) is not found in org.powermock.api.mockito.PowerMockito at javassist.CtClassType.getMethod(CtClassType.java:1130) at javassist.expr.MethodCall.getMethod(MethodCall.java:115) at org.powermock.core.transformers.impl.MainMockTransformer$PowerMockExpressionEditor.edit(MainMockTransformer.java:283) ... 41 more

    Write tip

    You have a different solution? A short tip here would help you and many other users who saw this issue last week.

    Users with the same issue

    Unknown user
    Once, 7 months ago
    Unknown user
    Once, 1 year ago