junit-team / junit4

A programmer-oriented testing framework for Java.
https://junit.org/junit4
Eclipse Public License 1.0
8.53k stars 3.29k forks source link

Junit Testcases Execution issue if using Powermockito #1685

Closed PriyankaKeer closed 3 years ago

PriyankaKeer commented 3 years ago

Hi team,

We are using powermockito in our junit test cases and facing this issue while executing it with java 8

Caused by: java.lang.RuntimeException: java.io.IOException: invalid constant type: 15 at javassist.CtClassType.getClassFile2(CtClassType.java:203) at javassist.CtClassType.makeFieldCache(CtClassType.java:837) at javassist.CtClassType.getMembers(CtClassType.java:828) at javassist.CtClassType.getMethod0(CtClassType.java:1126) at javassist.CtClassType.getMethod(CtClassType.java:1115) at javassist.expr.MethodCall.getMethod(MethodCall.java:114) at org.powermock.core.transformers.impl.MainMockTransformer$PowerMockExpressionEditor.edit(MainMockTransformer.java:272) at javassist.expr.ExprEditor.loopBody(ExprEditor.java:191) at javassist.expr.ExprEditor.doit(ExprEditor.java:90) at javassist.CtClassType.instrument(CtClassType.java:1374) at org.powermock.core.transformers.impl.MainMockTransformer.transform(MainMockTransformer.java:74) at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:252) ... 60 more Caused by: java.io.IOException: invalid constant type: 15 at javassist.bytecode.ConstPool.readOne(ConstPool.java:1090) at javassist.bytecode.ConstPool.read(ConstPool.java:1033) at javassist.bytecode.ConstPool.(ConstPool.java:149) at javassist.bytecode.ClassFile.read(ClassFile.java:737) at javassist.bytecode.ClassFile.(ClassFile.java:108) at javassist.CtClassType.getClassFile2(CtClassType.java:190) ... 71 more

Tried with different versions of javassist still issue is persisting. Tried executing the test case with java 7 and it is working fine. Is there any solution or workaround to handle the same with Java8 as our application need to be build with Java8.

Please Suggest Thanks in Advance!

marcphilipp commented 3 years ago

IIRC Javassist is not compatible with Java 8. In any case, it's not a JUnit issue since it doesn't use Javassist and you're probably better of searching/asking on StackOverflow.