Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-JSR-5
-
None
-
None
-
XP Pro SP2
Java 5
Description
I have a closure that constructs a node of a DOMBuilder tree. I am passing a parameter into this closure. This parameter becomes wrapped by nested groovy.lang.Reference objects with respect to the depth of the DOMBuilder node tree.
Example code (abridged):
def getNode = { parent, int i ->
def j = i
println("getNode: i = ${i}")
println("getNode: (j = ${j})")
parent.childOne() {
println("childOne: i = ${i}")
println("childOne: (j = ${j})")
childTwo() {
println("childTwo: i = ${i}")
println("childTwo: i.get() = ${i.get()}")
println("childTwo: (j = ${j})")
childThree() {
println("childThree: i = ${i}")
println("childThree: i.get() = ${i.get()}")
println("childThree: i.get().get() = ${i.get().get()}")
println("childThree: (j = ${j})")
}
}
}
}
def root = DOMBuilder.newInstance().rootElement() {
getNode(this, 1)
}
This produces the output:
getNode: i = 1
getNode: (j = 1)
childOne: i = 1
childOne: (j = 1)
childTwo: i = groovy.lang.Reference@14b5f4a
childTwo: i.get() = 1
childTwo: (j = 1)
childThree: i = groovy.lang.Reference@979e8b
childThree: i.get() = groovy.lang.Reference@14b5f4a
childThree: i.get().get() = 1
childThree: (j = 1)
Full source code is attached.