liuyingyyll / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

IllegalArgumentException when mocking java.io.PrintStream #384

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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)

Original issue reported on code.google.com by jameslor...@gmail.com on 21 Jan 2015 at 5:38

GoogleCodeExporter commented 8 years ago
We 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

Original comment by hend...@shendrix.com on 13 Mar 2015 at 8:24