Java VerifyError:类net.sf.cglib.core.DebuggingClassWriter重写最终方法访问
我在运行单元测试时遇到了这个错误 我使用intellij和EasyMock 3.0、cglib(2.2)和Objensis(1.2) 这是我的测试:Java VerifyError:类net.sf.cglib.core.DebuggingClassWriter重写最终方法访问,java,testing,junit,Java,Testing,Junit,我在运行单元测试时遇到了这个错误 我使用intellij和EasyMock 3.0、cglib(2.2)和Objensis(1.2) 这是我的测试: public void testGetContentOk() throws Exception { EasyMock.expect(mockConnectionFactory.getData()).andReturn(mockInputStream); EasyMock.expect(mockInputStream.read()).
public void testGetContentOk() throws Exception {
EasyMock.expect(mockConnectionFactory.getData()).andReturn(mockInputStream);
EasyMock.expect(mockInputStream.read()).andReturn(new Integer( (byte)'I'));
EasyMock.expect(mockInputStream.read()).andReturn(-1);
mockInputStream.close();
EasyMock.replay(mockConnectionFactory);
EasyMock.replay(mockInputStream);
WebClient webClient = new WebClient();
String result = webClient.getContent(mockConnectionFactory);
Assert.assertEquals("I", result);
}
有人知道为什么会这样吗
我对此很好奇,因为我已经使用了正确的版本,至少我这么认为。如果有任何帮助,我将不胜感激。检查项目的库依赖项。例如,如果您的项目使用asm.jar,请确保它的cglib版本正确。据我所知,ASM3.3可以与CGLIB2.2配合使用,但更高版本会冲突 我遇到了一些类似的问题。请尝试获取依赖关系树。 如果你能找到一些库依赖于ASM4.0。由于ASM4.0不能很好地与CGLIB2.2配合使用。这可能就是原因 在我自己的案例中,我使用maven for project,以便
mvn-dependency:tree
获得依赖关系树。我发现了这样的东西:
[INFO]| | |-com.esotericsoftware.kryo:kryo:jar:2.21:compile
[INFO]| | |+-com.esotericsoftware.reflectasm:reflectasm:jar:shaded:1.07:compile
[INFO]| | | |-org.ow2.asm:asm:jar:4.0:compile
我将asm改为3.1,它就可以工作了。EasyMock需要使用类似asm的东西,这取决于它。
希望这有帮助