Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.1.7
-
None
-
None
Description
One of the fellows on my team ran into what we think is an issue with the way that closures are handled post 2.1.7.
The following test case illustrates the issue
public class Foo { public static class InnerFoo { public InnerFoo() { bar() } public static bar() { (1..10).each { baz(it) } } public static baz(output) { println output } } } new Foo.InnerFoo ()
This code seems to be ok in 2.1.6.
I had a quick email chat with Andres Almiray and he dug a bit further into this example. He noticed the following:
Hi Todd,
As far as I can tell the problem appears in Groovy 2.1.7 and has not been fixed in 2.3.1.
There's indeed a compilation difference between 2.1.6 and 2.1.7 as seen here2.1.6:
total 56
rw-rr- 1 aalmiray wheel 6291 May 27 11:13 Foo$InnerFoo.class
rw-rr- 1 aalmiray wheel 2571 May 27 11:13 Foo$_InnerFoo_bar_closure1.class
rw-rr- 1 aalmiray wheel 4654 May 27 11:13 Foo.class
rw-rr- 1 aalmiray wheel 5964 May 27 11:13 shawn.class2.1.7:
total 56
rw-rr- 1 aalmiray wheel 6291 May 27 11:13 Foo$InnerFoo.class
rw-rr- 1 aalmiray wheel 2562 May 27 11:13 Foo$_InnerFoo_bar_closure1.class
rw-rr- 1 aalmiray wheel 4654 May 27 11:13 Foo.class
rw-rr- 1 aalmiray wheel 5964 May 27 11:13 shawn.classThere are 9 missing bytes since 2.1.7. I think it's best if you file a bug and ping @cedricchampeau as this might be related to some typing optimizations.
Cheers,
Andres
I can appreciate this is not a typical case and likely why it hasn't been noticed yet. Our specific case where we bumped into this was in a Jenkins Test Runner that uses this idiom.
Let me know if we can provide any further information.