When I attempt to run a spec that mocks java.io.PrintStream I get an IllegalArgumentException thrown:
class PrintSpec extends Specification { private PrintStream printStream = Mock() }
spock-core version - 0.7-groovy-2.0 cglib-nodep version - 3.1 objenesis version - 2.1 groovy-all version - 2.3.9
Here is the stacktrace: java.lang.IllegalArgumentException at net.sf.cglib.proxy.BridgeMethodResolver.resolveAll(BridgeMethodResolver.java:61) at net.sf.cglib.proxy.Enhancer.emitMethods(Enhancer.java:911) at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:498) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216) 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:83)
Comment #1
Posted on Mar 13, 2015 by Massive GiraffeWe get the same exception when mocking. This happens in Java 8, but not Java 7.
A thread around the same issue: https://groups.google.com/forum/#!topic/spockframework/59WIHGgcSNE
We built the latest cglib 3.2.0-SNAPSHOT from github, which fixed this for us. This ought to be fixed when the next cglib is released
Status: New
Labels:
Type-Defect
Module-Core