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

If one constructor calls another, instance variables may be initialized incorrectly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-4
    • 1.5.2
    • None
    • None
    • Linux with JDK 1.5.0

    Description

      Run the following Groovy program. The instance variable "success" changes value between the end of the second constructor and the end of the first constructor. This program works as expected in Java.

      class Pinger {
      boolean success

      Pinger(String destHost) {
      this(destHost, 1, 100)
      println "at end of little constructor, success is type ${success.class} a\
      nd value ${success}"
      }

      Pinger(String destHost, int in_n, int in_hops) {
      success = true
      println "at end of constructor, success is type ${success.class} and valu\
      e ${success}"
      }

      }

      Pinger p = new Pinger("www.yahoo.com")
      println "Success is ${p.success}"

      Attachments

        Activity

          People

            Unassigned Unassigned
            riedl John Riedl
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: