Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-3368

Collection.sort{Closure} regression

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Duplicate
    • 1.6
    • 1.6.1, 1.7-beta-1
    • groovy-jdk
    • 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

      {it*2}

      )

      { 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

      {it * 2}

      [1,2,3].sort

      {0}

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              aldo Aldo Bongio
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: