Cglib & Spock problems with Gradle 2.5

cglib throws an IllegalArgumentException in some Spock tests when using spock.lang.MockingApi#Mock(java.lang.Class<T>):

13-Jul-2015 17:07:56 > Builds the info mapping lazily and once on the first lookup call FAILED
13-Jul-2015 17:07:56	    java.lang.IllegalArgumentException
13-Jul-2015 17:07:56	        at net.sf.cglib.proxy.BridgeMethodResolver.resolveAll(
13-Jul-2015 17:07:56	        at net.sf.cglib.proxy.Enhancer.emitMethods(
13-Jul-2015 17:07:56	        at net.sf.cglib.proxy.Enhancer.generateClass(
13-Jul-2015 17:07:56	        at net.sf.cglib.core.DefaultGeneratorStrategy.generate(
13-Jul-2015 17:07:56	        at net.sf.cglib.core.AbstractClassGenerator.create(
13-Jul-2015 17:07:56	        at net.sf.cglib.proxy.Enhancer.createHelper(
13-Jul-2015 17:07:56	        at net.sf.cglib.proxy.Enhancer.createClass(
13-Jul-2015 17:07:56	        at org.spockframework.mock.runtime.ProxyBasedMockFactory$CglibMockFactory.createMock(
13-Jul-2015 17:07:56	        at org.spockframework.mock.runtime.ProxyBasedMockFactory.create(
13-Jul-2015 17:07:56	        at org.spockframework.mock.runtime.JavaMockFactory.create(
13-Jul-2015 17:07:56	        at org.spockframework.mock.runtime.CompositeMockFactory.create(
13-Jul-2015 17:07:56	        at org.spockframework.lang.SpecInternals.createMock(
13-Jul-2015 17:07:56	        at org.spockframework.lang.SpecInternals.createMockImpl(
13-Jul-2015 17:07:56	        at org.spockframework.lang.SpecInternals.MockImpl(
13-Jul-2015 17:07:56	        at

Lines 15-18 of MyTest is only

def mockSupplier
def setup() {
    mockSupplier = Mock(SomeSupplier)

This only happens with a couple of mocks, not all. One mock is of a public java class (which extends an abstract java class), the other of a default groovy class (which implements a java class). I haven’t been able to pinpoint why these two are special.

Is this only happening when running your tests with Gradle 2.5? Do they work fine with 2.4? Can you try and extract a standalone reproducible example?

Yes, this happened after we upgraded from Gradle 2.4 to 2.5.

I created a small example project, but now it fails with both 2.4 and 2.5. Can’t figure out why. Annoying.

I’ll try switching to com.github.cglib:cglib.cglib-nodep:e10bc3dda2 as mentioned in