PowerMock和Java 8问题:InterfaceMethodrefInfo无法强制转换为MethodrefInfo

我在尝试使用PowerMock和Mockito执行unit testing时遇到了问题。 我需要PowerMockito来模拟静态方法。

这些是我使用的版本:

PowerMock 1.6.2 Mockito 1.10.19 JUnit 4.12 Java 8 

当我添加注释@PrepareForTest(Graph.class)时,我收到以下错误:

 java.lang.IllegalStateException: Failed to transform class with name name.of.my.package.GraphUtil. Reason: javassist.bytecode.InterfaceMethodrefInfo cannot be cast to javassist.bytecode.MethodrefInfo 

我在官方的PowerMock Google页面上看到这与javassist有关。 但我有点失落,我不知道如何解决它。

为了以防万一,我也尝试下载最新的Powermock SNAPSHOT(1.6.3-SNAPSHOT),但也没有用。

请问有人帮帮我吗?

提前致谢

按照FranciscoGonzález的回答,这就是我必须做的事情:

  org.powermock powermock-module-junit4 1.5.5 test   org.javassist javassist     org.javassist javassist 3.20.0-GA test  

是的,那就是问题所在。 PowerMock依赖于javassist,因此我只需在我的pom中排除该传递依赖,然后将依赖包含在javassist的固定版本中。 这对我有用。 谢谢!

   org.javassist javassist 3.22.0-GA   org.powermock powermock-module-junit4   org.javassist javassist