java.lang.ClassFormatError: Invalid method Code length 65556 in class file

721 views
Skip to first unread message

red

unread,
Apr 30, 2015, 9:13:36 AM4/30/15
to spockfr...@googlegroups.com
Hi,

We have a simple test for a groovy file, and after adding 5 more params to it, we are now getting this error.

What is Spock doing under the covers to generate that?  And is there a way to avoid it?

grze...@gmail.com

unread,
May 6, 2015, 5:00:51 AM5/6/15
to spockfr...@googlegroups.com
Have you @Unroll your parameterized test method ? 

AFAIK if you don't do this, all cases will be generated in one method, so it could be possible that it will be very large.


Cheers,

Grzesiek

Raffael Herzog

unread,
May 6, 2015, 12:33:55 PM5/6/15
to spockfr...@googlegroups.com
Am Mittwoch, 6. Mai 2015, 02.00:51 schrieb grze...@gmail.com:
> Have you @Unroll your parameterized test method ?
>
> AFAIK if you don't do this, all cases will be generated in one method, so
> it could be possible that it will be very large.

If that is actually the case, I would seriously consider changing that.

Cheers,
Raffi
signature.asc

David Hay

unread,
May 6, 2015, 2:08:25 PM5/6/15
to spockfr...@googlegroups.com
Thanks for the suggestion...I tried @Unroll to no effect:

net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at net.sf.cglib.proxy.Enhancer.createClass(Enhancer.java:317)
at org.spockframework.mock.runtime.ProxyBasedMockFactory$CglibMockFactory.createMock(ProxyBasedMockFactory.java:91)
at org.spockframework.mock.runtime.ProxyBasedMockFactory.create(ProxyBasedMockFactory.java:49)
at org.spockframework.mock.runtime.JavaMockFactory.create(JavaMockFactory.java:51)
at org.spockframework.mock.runtime.CompositeMockFactory.create(CompositeMockFactory.java:44)
at org.spockframework.lang.SpecInternals.createMock(SpecInternals.java:47)
at org.spockframework.lang.SpecInternals.createMockImpl(SpecInternals.java:282)
at org.spockframework.lang.SpecInternals.MockImpl(SpecInternals.java:99)
at com.package.MySpec.$spock_initializeFields(MySpec.groovy:28)
Caused by: java.lang.reflect.InvocationTargetException
at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
... 10 more
Caused by: java.lang.ClassFormatError: Invalid method Code length 67622 in class file com.package.MyClass$$EnhancerByCGLIB$$281952b3_4
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
... 12 more


--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spockframewor...@googlegroups.com.
To post to this group, send email to spockfr...@googlegroups.com.
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.

Peter Niederwieser

unread,
May 6, 2015, 10:57:28 PM5/6/15
to spockfr...@googlegroups.com
In 7 years of using Spock, I've never seen this error for a Spock test class, but I’ve seen it for plain Groovy classes a few times. Perhaps try with a different/later Groovy version.

signature.asc

Peter Niederwieser

unread,
May 6, 2015, 10:57:43 PM5/6/15
to spockfr...@googlegroups.com
It’s absolutely not the case. @Unroll only effects how tests are *reported*, nothing else.
signature.asc

grze...@gmail.com

unread,
May 8, 2015, 7:11:37 AM5/8/15
to spockfr...@googlegroups.com


W dniu czwartek, 7 maja 2015 04:57:43 UTC+2 użytkownik Peter Niederwieser napisał:
It’s absolutely not the case. @Unroll only effects how tests are *reported*, nothing else.



Ok, apologies from my side,  I though that it is related how method is generated


@red 

Could you provide some example class which reproduces the bug if its possible ?


Regards,

Grzesiek
Reply all
Reply to author
Forward
0 new messages