surefire + powermock = java.lang.IllegalStateException: Failed to transform class with name ... Reason: bad array type for AALOAD: null

899 views
Skip to first unread message

ruben

unread,
Oct 26, 2010, 10:43:58 AM10/26/10
to PowerMock
Hi,

when trying to run powermock tests with maven using
the surefire plugin, javassist class preparation fails.

The SimpleTest class is annotated with

@RunWith(PowerMockRunner.class)
@PrepareForTest( { TestEntity.class } )

The test works when running it in eclipse but using maven surefire
from commandline
fails with the following error:

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.032
sec <<< FAILURE!
initializationError(com.example.SimpleTest) Time elapsed: 0.016 sec
<<< ERROR!
java.lang.IllegalStateException: Failed to transform class with name
com.example.TestEntity. Reason: bad array type for AALOAD: null
at
org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:
208)
at
org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:
146)
at
org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:
65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at
org.junit.internal.runners.TestClass.getAnnotatedMethods(TestClass.java:
44)
at
org.junit.internal.runners.MethodValidator.validateTestMethods(MethodValidator.java:
69)
at
org.junit.internal.runners.MethodValidator.validateStaticMethods(MethodValidator.java:
43)
at
org.junit.internal.runners.MethodValidator.validateMethodsForDefaultRunner(MethodValidator.java:
49)
at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.validate(PowerMockJUnit44RunnerDelegateImpl.java:
123)
at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.<init>(PowerMockJUnit44RunnerDelegateImpl.java:
85)
at
org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl.<init>(PowerMockJUnit47RunnerDelegateImpl.java:
42)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:
513)
at
org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:
154)
at
org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:
49)
at
org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.createTestDelegators(AbstractTestSuiteChunkerImpl.java:
231)
at
org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.<init>(JUnit4TestSuiteChunkerImpl.java:
69)
at
org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.<init>(AbstractCommonPowerMockRunner.java:
36)
at
org.powermock.modules.junit4.PowerMockRunner.<init>(PowerMockRunner.java:
27)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:
39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:
27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:
513)
at
org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:
31)
at
org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:
24)
at
org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:
57)
at
org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:
29)
at
org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:
57)
at
org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:
24)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.<init>(JUnit4TestSet.java:
45)
at
org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite.createTestSet(JUnit4DirectoryTestSuite.java:
56)

Any idea what is wrong here?
Thanks for your help!

Regards,
Ruben

Johan Haleby

unread,
Oct 26, 2010, 1:12:03 PM10/26/10
to powe...@googlegroups.com
Hm I don't know what's causing this.. Do you have any other plugins that
fiddles with the byte-code (aspectj, cobertura or something)? Do you
always get this stack trace or is it just when preparing TestEntity?

/Johan

Amanda von Zuben

unread,
Nov 27, 2013, 1:29:58 PM11/27/13
to powe...@googlegroups.com, rjen...@googlemail.com
Hi, 
I'm having the same problem! Did you find a solution?


/Amanda

KARR, DAVID

unread,
Dec 3, 2013, 12:44:23 PM12/3/13
to powe...@googlegroups.com

It appears this was fixed in a revision of javassist earlier this year.  What version of javassist are you using?

 

--
You received this message because you are subscribed to the Google Groups "PowerMock" group.
To unsubscribe from this group and stop receiving emails from it, send an email to powermock+...@googlegroups.com.
To post to this group, send email to powe...@googlegroups.com.
Visit this group at http://groups.google.com/group/powermock.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages