-
Notifications
You must be signed in to change notification settings - Fork 586
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When having inheritance in class under test adding class in @PrepareForTest and running the test gives initilizationError #583
Comments
Could you try upgrading to the latest version and see if it's still an issue? |
I am using the latest version only downloaded from below link |
Oh sorry. Did you experience the same problem in a previous version? |
I have tried with version 1.6.2 same problem. I tried writing simple test case this time different error. The code is follows
Stack trace
As soon as I remove extends A in Class TestB every thing is fin. |
To me this sound like a byte-code problem. Byte-code is handled by javassist so I think that you should report it as a bug there. |
I have raised issue with Javaassist below the link https://issues.jboss.org/projects/JASSIST/issues/JASSIST-252 |
Thanks! |
Close the issue as cannot be reproduced. I cannot reproduce the issue with using latest JDK, javassist and PowerMock
|
I am trying to run test for last couple of days not much help provided on web search as well.
I am using below JARS
cglib-nodep-2.2.2.jar
javassist-3.20.0-GA.jar
junit-4.12.jar
mockito-all-1.10.19.jar
objenesis-2.1.jar
powermock-mockito-1.6.3-full.jar
Stack trace is below :-
java.lang.ClassFormatError: JVMCFRE013 local variable PC length invalid; class=, offset=18919
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:284)
at java.lang.ClassLoader.defineClass(ClassLoader.java:221)
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:268)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:179)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:70)
at java.lang.ClassLoader.loadClass(ClassLoader.java:658)
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:284)
at java.lang.ClassLoader.defineClass(ClassLoader.java:221)
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:268)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:179)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:70)
at java.lang.ClassLoader.loadClass(ClassLoader.java:658)
at java.lang.Class.forNameImpl(Native Method)
at java.lang.Class.forName(Class.java:176)
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:126)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:137)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:61)
at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:402)
at sun.reflect.annotation.AnnotationParser.parseClassValue(AnnotationParser.java:383)
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:685)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:492)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:318)
at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:253)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:100)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:82)
at java.lang.Class.getDeclaredAnnotations(Class.java:1685)
at java.lang.Class.getAnnotations(Class.java:1641)
at java.lang.Class.getAnnotation(Class.java:1621)
at org.junit.internal.MethodSorter.getDeclaredMethods(MethodSorter.java:52)
at org.junit.internal.runners.TestClass.getAnnotatedMethods(TestClass.java:45)
at org.junit.internal.runners.MethodValidator.validateTestMethods(MethodValidator.java:71)
at org.junit.internal.runners.MethodValidator.validateStaticMethods(MethodValidator.java:44)
at org.junit.internal.runners.MethodValidator.validateMethodsForDefaultRunner(MethodValidator.java:50)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.validate(PowerMockJUnit44RunnerDelegateImpl.java:108)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.(PowerMockJUnit44RunnerDelegateImpl.java:70)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl.(PowerMockJUnit47RunnerDelegateImpl.java:42)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit49RunnerDelegateImpl.(PowerMockJUnit49RunnerDelegateImpl.java:25)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:156)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:40)
at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.createTestDelegators(AbstractTestSuiteChunkerImpl.java:244)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.(JUnit4TestSuiteChunkerImpl.java:61)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.(AbstractCommonPowerMockRunner.java:32)
at org.powermock.modules.junit4.PowerMockRunner.(PowerMockRunner.java:34)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:539)
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.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.(JUnit4TestReference.java:32)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)
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)
The text was updated successfully, but these errors were encountered: