Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Duplicate
-
1.6
-
None
Description
Starting from Groovy 1.6 final I experienced a regression on the Collection.sort
{Closure} method.
The minimal example to replicate it requires the following steps
1. Run groovysh
2. Write the following line
for (x in [1,2,3].sort
)
{ println x }3. An exception is raised
ERROR java.lang.NoSuchFieldError: $const$1
at groovysh_evaluate$_run_closure1.doCall (groovysh_evaluate:2)
at groovysh_evaluate.run (groovysh_evaluate:2)
...
The same example with Groovy 1.5.7 worked fine, printing
1
2
3
On Groovy 1.6 the error can be replicated also with
for (x in [1,2,3].sort{0}) { println x }
The problem seems somehow related to the for cycle, because the following code doesn't throw exceptions
[1,2,3].sort
[1,2,3].sort
{0}Attachments
Issue Links
- duplicates
-
GROOVY-3339 Calling a method that takes a closure containing a list or number (and maybe others) constant throws a weird exception
- Closed