Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 1.2.0
-
Fix Version/s: None
-
Component/s: JMock 1.x.x Library
-
Labels:None
-
Number of attachments :
Description
In some code that I have inherited I have a class with a static nested class. In the past (jMock 1.1.0) I was able to successfully mock this static nested class. After upgrading to jMock 1.2.0, this no longer works. I end up getting the following exception:
net.sf.cglib.core.CodeGenerationException: java.lang.IllegalAccessError-->tried to access method org.jmock.codegen.com.mycompany.core.util.DataPage$DataPageDefinition$$EnhancerByCGLIB$$3417fee6.CGLIB$setPageNumber$6(I)V from class org.jmock.codegen.org.jmock.codegen.com.mycompany.core.util.DataPage$DataPageDefinition$$EnhancerByCGLIB$$3417fee6$$FastClassByCGLIB$$e9f65fd5
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:235)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:220)
at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:636)
at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:538)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:225)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:304)
at org.jmock.cglib.CGLIBCoreMock.<init>(CGLIBCoreMock.java:63)
at org.jmock.cglib.CGLIBCoreMock.<init>(CGLIBCoreMock.java:46)
at org.jmock.cglib.CGLIBCoreMock.<init>(CGLIBCoreMock.java:35)
at org.jmock.cglib.MockObjectTestCase.newCoreMock(MockObjectTestCase.java:33)
at org.jmock.MockObjectTestCase.mock(MockObjectTestCase.java:67)
at org.jmock.MockObjectTestCase.mock(MockObjectTestCase.java:55)
at com.mycompany.core.persistence.hbm.HBMBaseDAOTest.testLimitResultSet(HBMBaseDAOTest.java:117)
Caused by: java.lang.IllegalAccessError: tried to access method org.jmock.codegen.com.mycompany.core.util.DataPage$DataPageDefinition$$EnhancerByCGLIB$$3417fee6.CGLIB$setPageNumber$6(I)V from class org.jmock.codegen.org.jmock.codegen.com.mycompany.core.util.DataPage$DataPageDefinition$$EnhancerByCGLIB$$3417fee6$$FastClassByCGLIB$$e9f65fd5
at org.jmock.codegen.org.jmock.codegen.com.mycompany.core.util.DataPage$DataPageDefinition$$EnhancerByCGLIB$$3417fee6$$FastClassByCGLIB$$e9f65fd5.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:167)
at org.jmock.cglib.CGLIBCoreMock.intercept(CGLIBCoreMock.java:79)
at org.jmock.codegen.com.mycompany.core.util.DataPage$DataPageDefinition$$EnhancerByCGLIB$$3417fee6.setPageNumber(<generated>)
at com.mycompany.core.util.DataPage$DataPageDefinition.<init>(DataPage.java:280)
at com.mycompany.core.util.DataPage$DataPageDefinition.<init>(DataPage.java:267)
at org.jmock.codegen.com.mycompany.core.util.DataPage$DataPageDefinition$$EnhancerByCGLIB$$3417fee6.<init>(<generated>)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at net.sf.cglib.core.ReflectUtils.newInstance(ReflectUtils.java:228)
... 58 more
Research led me to the following:
http://www.gg3721.com/list/50/44427.html
and the followup
http://www.gg3721.com/list/50/44774.html
Is there any workaround to get this to work again, short of rolling back to jMock 1.1.0 or breaking out the static nested class into it's own file?