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

Compiler does not inforce the Java rules for definite assignment before use

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-beta-5
    • 1.0-JSR-1
    • parser
    • None

    Description

      class C {
      static main(args) {
      c =

      {if (it == 1) x = 100 else println "!" println x }

      c(1)
      c(2)
      }
      }

      produces:

      Exception in thread "main" java.lang.VerifyError: (class: C$1, method: doCall signature: (Ljava/lang/Object;)Ljava/lang/Object Accessing value from uninitialized register 2

      If the compiler applied the standard Java flow analysis to ensure definite assignment before use (See chapter 16 of the JLS) then the program would be rejected at compile time.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            tug John Wilson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: