title: PowerMock and javassist conflict
body: <p>I have faced with a problem that when I am trying to run my unit tests on this versions:</p>
  
  <pre><code>PowerMock - 1.6.5
  
  javaassist - 3.12.1.GA
  
  java8
  </code></pre>
  
  <p>I am getting this:</p>
  
  <pre><code>java.lang.IllegalStateException: Failed to transform class with name com.energyict.ems.mstr.MstrSessionManager. Reason: java.io.IOException: invalid constant type: 15
  
      at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:283)
      at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:192)
      at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:71)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:348)
      at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
      at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
      at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
      at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:439)
      at sun.reflect.annotation.AnnotationParser.parseClassValue(AnnotationParser.java:420)
      at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
      at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
      at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
      at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
      at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
      at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
      at java.lang.Class.createAnnotationData(Class.java:3521)
      at java.lang.Class.annotationData(Class.java:3510)
      at java.lang.Class.getAnnotation(Class.java:3415)
      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.&lt;init&gt;(PowerMockJUnit44RunnerDelegateImpl.java:70)
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl.&lt;init&gt;(PowerMockJUnit47RunnerDelegateImpl.java:42)
      at org.powermock.modules.junit4.internal.impl.PowerMockJUnit49RunnerDelegateImpl.&lt;init&gt;(PowerMockJUnit49RunnerDelegateImpl.java:25)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:172)
      at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:48)
      at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.createTestDelegators(AbstractTestSuiteChunkerImpl.java:113)
      at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.&lt;init&gt;(JUnit4TestSuiteChunkerImpl.java:71)
      at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.&lt;init&gt;(AbstractCommonPowerMockRunner.java:32)
      at org.powermock.modules.junit4.PowerMockRunner.&lt;init&gt;(PowerMockRunner.java:34)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      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 com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
      at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
  Caused by: java.lang.RuntimeException: java.io.IOException: invalid constant type: 15
      at javassist.CtClassType.getClassFile2(CtClassType.java:203)
      at javassist.CtClassType.subtypeOf(CtClassType.java:303)
      at javassist.CtClassType.subtypeOf(CtClassType.java:318)
      at javassist.compiler.MemberResolver.compareSignature(MemberResolver.java:247)
      at javassist.compiler.MemberResolver.lookupMethod(MemberResolver.java:119)
      at javassist.compiler.MemberResolver.lookupMethod(MemberResolver.java:96)
      at javassist.compiler.TypeChecker.atMethodCallCore(TypeChecker.java:704)
      at javassist.expr.NewExpr$ProceedForNew.setReturnType(NewExpr.java:243)
      at javassist.compiler.JvstTypeChecker.atCallExpr(JvstTypeChecker.java:146)
      at javassist.compiler.ast.CallExpr.accept(CallExpr.java:45)
      at javassist.compiler.TypeChecker.atVariableAssign(TypeChecker.java:248)
      at javassist.compiler.TypeChecker.atAssignExpr(TypeChecker.java:217)
      at javassist.compiler.ast.AssignExpr.accept(AssignExpr.java:38)
      at javassist.compiler.CodeGen.doTypeCheck(CodeGen.java:241)
      at javassist.compiler.CodeGen.atStmnt(CodeGen.java:329)
      at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
      at javassist.compiler.CodeGen.atStmnt(CodeGen.java:350)
      at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
      at javassist.compiler.CodeGen.atIfStmnt(CodeGen.java:404)
      at javassist.compiler.CodeGen.atStmnt(CodeGen.java:354)
      at javassist.compiler.ast.Stmnt.accept(Stmnt.java:49)
      at javassist.compiler.Javac.compileStmnt(Javac.java:568)
      at javassist.expr.NewExpr.replace(NewExpr.java:206)
      at org.powermock.core.transformers.impl.AbstractMainMockTransformer$PowerMockExpressionEditor.edit(AbstractMainMockTransformer.java:436)
      at javassist.expr.ExprEditor.loopBody(ExprEditor.java:211)
      at javassist.expr.ExprEditor.doit(ExprEditor.java:90)
      at javassist.CtClassType.instrument(CtClassType.java:1374)
      at org.powermock.core.transformers.impl.ClassMockTransformer.transformMockClass(ClassMockTransformer.java:65)
      at org.powermock.core.transformers.impl.AbstractMainMockTransformer.transform(AbstractMainMockTransformer.java:247)
      at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:264)
      ... 57 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.&lt;init&gt;(ConstPool.java:149)
      at javassist.bytecode.ClassFile.read(ClassFile.java:737)
      at javassist.bytecode.ClassFile.&lt;init&gt;(ClassFile.java:108)
      at javassist.CtClassType.getClassFile2(CtClassType.java:190)
      ... 86 more
  </code></pre>
  
  <p>But when I am trying to change javaassist version on, for example: 3.20.0-GA</p>
  
  <pre><code>        &lt;dependency&gt;
              &lt;groupId&gt;org.javassist&lt;/groupId&gt;
              &lt;artifactId&gt;javassist&lt;/artifactId&gt;
              &lt;version&gt;3.20.0-GA&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>I am getting next error:</p>
  
  <pre><code>java.lang.NoSuchMethodError: javassist.CtMethod.hasAnnotation(Ljava/lang/Class;)Z
  
      at org.powermock.core.transformers.impl.TestClassTransformer.removeTestAnnotationsForTestMethodsThatRunOnOtherClassLoader(TestClassTransformer.java:189)
      at org.powermock.core.transformers.impl.TestClassTransformer.transform(TestClassTransformer.java:203)
      at org.powermock.core.classloader.MockClassLoader.loadMockClass(MockClassLoader.java:264)
      at org.powermock.core.classloader.MockClassLoader.loadModifiedClass(MockClassLoader.java:192)
      at org.powermock.core.classloader.DeferSupportingClassLoader.loadClass(DeferSupportingClassLoader.java:71)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:348)
      at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:161)
      at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.createDelegatorFromClassloader(JUnit4TestSuiteChunkerImpl.java:48)
      at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.createTestDelegators(AbstractTestSuiteChunkerImpl.java:113)
      at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.&lt;init&gt;(JUnit4TestSuiteChunkerImpl.java:71)
      at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.&lt;init&gt;(AbstractCommonPowerMockRunner.java:32)
      at org.powermock.modules.junit4.PowerMockRunner.&lt;init&gt;(PowerMockRunner.java:34)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      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 com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
      at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
  
  
  Process finished with exit code -1
  </code></pre>
  
  <p>Could anyone please suggest solution?</p>