groovy

Closure parameters unnecessarily wrapped in groovy.lang.References

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-5
  • Fix Version/s: 1.0-JSR-6
  • Component/s: None
  • Labels:
    None
  • Environment:
    XP Pro SP2
    Java 5
  • Number of attachments :
    1

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.

Activity

Hide
blackdrag blackdrag added a comment -

this was a issue in jsr-05 but is fixed in jsr-06

Show
blackdrag blackdrag added a comment - this was a issue in jsr-05 but is fixed in jsr-06

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: