History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GROOVY-1207
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: John Riedl
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
groovy

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

Created: 11/Jan/06 09:59 PM   Updated: 08/Feb/08 01:26 AM
Component/s: None
Affects Version/s: 1.0-JSR-4
Fix Version/s: 1.5.2

Time Tracking:
Not Specified

Environment: Linux with JDK 1.5.0


 Description  « Hide
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}"



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Andres Almiray - 27/Nov/07 05:35 PM
Running the provided script in groovyConsole (1.1-final-SNAPSHOT, jdk1.6.0_03,winxp)
groovy> class Pinger {
groovy>    boolean success
groovy>    Pinger(String destHost) {
groovy>       this(destHost, 1, 100)
groovy>       println "at end of little constructor, success is type ${success.class} and value ${success}"
groovy>    }
groovy>    Pinger(String destHost, int in_n, int in_hops) {
groovy>       success = true
groovy>       println "at end of constructor, success is type ${success.class} and value ${success}"
groovy>    }
groovy> }
groovy> Pinger p = new Pinger("www.yahoo.com")
groovy> println "Success is ${p.success}"

at end of constructor, success is type class java.lang.Boolean and value true
at end of little constructor, success is type class java.lang.Boolean and value true
Success is true

seems like its working now


Paul King - 06/Jan/08 02:02 AM
Works for me too. Please reopen if you find a problem.

Paul King - 08/Feb/08 01:26 AM
close off release 1.5.4