Open GoogleCodeExporter opened 9 years ago
Can you provide an example test and code under test?
Original comment by johan.ha...@gmail.com
on 22 Feb 2012 at 9:36
I will, give me a couple of minutes to create a minimal project.
Original comment by petrkn...@gmail.com
on 22 Feb 2012 at 10:00
I did get the same issue. But after digging further we got figured it out. It
is actually one of the interface change which caused the issue. Possibly you
can look into sterotyped collection objects
Original comment by anandara...@gmail.com
on 27 Feb 2012 at 9:41
So what is the solution to this problem. Is this an issue with PowerMock or is
their something wrong with the code. I'm facing this same issue and wondering
what the solution is. Thanks.
Original comment by bog...@gmail.com
on 23 May 2012 at 5:18
Original comment by johan.ha...@gmail.com
on 24 May 2012 at 5:04
Did anybody find a solution to this? I'm experiencing the same issue when I try
to run my tests from within Intellij IDEA 11.
Original comment by oghe...@gmail.com
on 28 Jun 2012 at 1:49
Hmm if you remove @beforeclass and @afterclass does it make any difference?
Original comment by johan.ha...@gmail.com
on 29 Jun 2012 at 6:34
I'm not using @BeforeClass or @AfterClass. I am however using inheritance in
both the tests and the classes under test (the inheritance is mirrored across
the source trees) with two @Override'd methods.
Do you think that may be causing the problem?
Original comment by oghe...@gmail.com
on 29 Jun 2012 at 3:33
I am using Intellij 10.5.4 and i dont get this issue. However, when i run it at
the command line using Ant, this problem occurs.
Original comment by srohith85
on 27 Jul 2012 at 4:04
[deleted comment]
Maybe this helps. I had the same problem and I managed to solve it by not using
static imports. In my case the issue was with PowerMockito static imports for
'mockStatic' and 'when' which I replace with direct calls as
'PowerMockito.mockStatic' and 'PowerMockito.when'.
Original comment by santmatt...@gmail.com
on 1 Aug 2012 at 9:58
For what it's worth, I have what appears that it may be the same problem. I
encounter the problem when running at the command line using Maven, but only
when running the WHOLE test suite, not when running a single test. I am not
using @beforeClass or @afterClass. Others building it (like our build server)
do not encounter the same problem. I tried removing static imports and that
didn't fix it. I'd love to follow up by saying what DID fix it, but I haven't
been able to solve the problem.
Original comment by mcherm
on 26 Sep 2012 at 1:55
Was a solution found for this problem?
Original comment by vivek.na...@gmail.com
on 28 Nov 2012 at 12:44
I found the solution to my issue. I was using a different version of a jar in
my build path. After cleaning the Maven repository, this error just
disappeared. Hope this helps.
Original comment by vivek.na...@gmail.com
on 6 Dec 2012 at 5:14
Thanks for sharing.
Original comment by johan.ha...@gmail.com
on 6 Dec 2012 at 7:22
I am getting this error when a colleague of mine using the same code is not.
I've looked through this list and 4 or 5 other proposed fixes. It seems that a
different thing fixes it for someone else, none of which worked for me. I am
starting to conclude that Powermock with javassist is not stable enough to be
used.
Original comment by mpeters...@gmail.com
on 14 Dec 2012 at 6:55
Usually this turn out to be a classpath issue and PowerMock can do nothing
about this. Are you using Maven? Even if you are you can run into nasty
classpath issues that are not always easy to resolve if you're using frameworks
that depend on different versions of the same jar files.
Original comment by johan.ha...@gmail.com
on 15 Dec 2012 at 9:06
mvn clean install solved the problem for me
Original comment by kareemel...@v-cumulus.com
on 21 Nov 2013 at 2:08
Thanks for sharing.
Original comment by johan.ha...@gmail.com
on 21 Nov 2013 at 2:12
Is there any solution for this problem. I am also getting same problem?
initializationError (pakcage name): Failed to transform class with name XXXXX.
Reason: javassist.bytecode.StringInfo cannot be cast to
javassist.bytecode.MethodrefInfo
Original comment by umasanka...@gmail.com
on 17 Jul 2014 at 10:30
What's the stacktrace?
Original comment by johan.ha...@gmail.com
on 17 Jul 2014 at 4:58
[deleted comment]
<testcase time="0.001" classname=XXXTest" name="initializationError">
<error message="Failed to transform class with name YY. Reason: javassist.bytecode.StringInfo cannot be cast to javassist.bytecode.MethodrefInfo" type="java.lang.IllegalStateException">java.lang.IllegalStateException: Failed to transform class with name YY. Reason: javassist.bytecode.StringInfo cannot be cast to javassist.bytecode.MethodrefInfo
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:219)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:147)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
at java.lang.Class.privateGetPublicMethods(Class.java:2641)
at java.lang.Class.getMethods(Class.java:1457)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.getTestMethods(PowerMockJUnit44RunnerDelegateImpl.java:95)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.<init>(PowerMockJUnit44RunnerDelegateImpl.java:71)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit49RunnerDelegateImpl.<init>(PowerMockJUnit49RunnerDelegateImpl.java:29)
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.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:143)
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:33)
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.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:51)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:119)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
at com.sun.proxy.$Proxy0.invoke(Unknown Source)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Caused by: java.lang.ClassCastException: javassist.bytecode.StringInfo cannot
be cast to javassist.bytecode.MethodrefInfo
at javassist.bytecode.ConstPool.getMethodrefType(ConstPool.java:383)
at javassist.bytecode.stackmap.Tracer.doInvokeMethod(Tracer.java:812)
at javassist.bytecode.stackmap.Tracer.doOpcode148_201(Tracer.java:617)
at javassist.bytecode.stackmap.Tracer.doOpcode(Tracer.java:101)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:161)
at javassist.bytecode.stackmap.MapMaker.traceException(MapMaker.java:192)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:154)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:120)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:96)
at javassist.bytecode.MethodInfo.rebuildStackMap(MethodInfo.java:404)
at javassist.bytecode.MethodInfo.rebuildStackMapIf6(MethodInfo.java:389)
at javassist.expr.ExprEditor.doit(ExprEditor.java:112)
at javassist.CtClassType.instrument(CtClassType.java:1289)
at org.powermock.core.transformers.impl.MainMockTransformer.transform(MainMockTransformer.java:75)
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:215)
... 42 more
Original comment by umasanka...@gmail.com
on 18 Jul 2014 at 10:55
Hm are you using the latest version of PowerMock? When I check at line 75 in
MainMockTransfomer all I see is a "}"
Original comment by johan.ha...@gmail.com
on 18 Jul 2014 at 11:48
I am using 1.5, below are the entries in pom.xml
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4-rule</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-classloading-xstream</artifactId>
<version>1.5</version>
</dependency>
Original comment by umasanka...@gmail.com
on 19 Jul 2014 at 3:24
Try upgrading to version 1.5.5 and see if the problem still exist. If it does
show me the stacktrace.
Original comment by johan.ha...@gmail.com
on 19 Jul 2014 at 6:12
[deleted comment]
[deleted comment]
No Luck..errors again upgrading to 1.5.5
java.lang.IllegalStateException: Failed to transform class with name XXX.
Reason: bad LDC: 10
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:247)
at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:177)
at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:68)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
at java.lang.Class.privateGetPublicMethods(Class.java:2641)
at java.lang.Class.getMethods(Class.java:1457)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.getTestMethods(PowerMockJUnit44RunnerDelegateImpl.java:93)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.<init>(PowerMockJUnit44RunnerDelegateImpl.java:69)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl.<init>(PowerMockJUnit47RunnerDelegateImpl.java:42)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit49RunnerDelegateImpl.<init>(PowerMockJUnit49RunnerDelegateImpl.java:25)
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.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:149)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:39)
at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.createTestDelegators(AbstractTestSuiteChunkerImpl.java:218)
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:33)
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.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:51)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:119)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
at com.sun.proxy.$Proxy0.invoke(Unknown Source)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Caused by: java.lang.RuntimeException: bad LDC: 10
at javassist.bytecode.stackmap.Tracer.doLDC(Tracer.java:289)
at javassist.bytecode.stackmap.Tracer.doOpcode0_53(Tracer.java:189)
at javassist.bytecode.stackmap.Tracer.doOpcode(Tracer.java:94)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:161)
at javassist.bytecode.stackmap.MapMaker.traceException(MapMaker.java:192)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:154)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:120)
at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:96)
at javassist.bytecode.MethodInfo.rebuildStackMap(MethodInfo.java:404)
at javassist.bytecode.MethodInfo.rebuildStackMapIf6(MethodInfo.java:389)
at javassist.expr.ExprEditor.doit(ExprEditor.java:112)
at javassist.CtClassType.instrument(CtClassType.java:1289)
at org.powermock.core.transformers.impl.MainMockTransformer.transform(MainMockTransformer.java:74)
at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:243)
... 43 more
Original comment by umasanka...@gmail.com
on 21 Jul 2014 at 5:28
Unfortunately I suspect that this is an issue with Javassist (the byte-code
manipulation framework that PowerMock uses). It would be great if you could
file an issue at Javassist with as much information as possible.
Original comment by johan.ha...@gmail.com
on 23 Jul 2014 at 6:53
Original issue reported on code.google.com by
petrkn...@gmail.com
on 21 Feb 2012 at 8:31