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

for(;;) {} does not behave the same as in Java

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.5.7, 1.6-beta-2
    • 1.6-rc-1, 1.5.8, 1.7-beta-1
    • Compiler
    • None
    • All

    Description

      Given the following code:

      for(;;) {
      }
      

      groovyc generates the following bytecode:
      114: bipush 0
      116: ifeq 122
      119: goto 114

      Unfortunately, that bipush 0/ifeq means that this loop always exits immediately, unlike javac, which treats that identically to while(true) {}

      Attachments

        Activity

          People

            guillaume Guillaume Sauthier
            didge didge
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: