groovy

ExpandoMetaClass returns expando properties twice

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.5.1
  • Fix Version/s: 1.5.2
  • Component/s: groovy-jdk
  • Labels:
    None
  • Environment:
    WIndows XP SP 2
  • Testcase included:
    yes
  • Number of attachments :
    0

Description

i like to use the ExpandoMetaClass to add properties and methods during runtime.
For testing purposes I wrote:

class Foo{

}
println Foo.metaClass
def a1 = new Foo();
println a1.metaClass.class

Foo.metaClass.expando = true;

println Foo.metaClass.class
def a2 = new Foo();
println a2.metaClass.class

a2.metaClass.test = "value"
println a2.test
println a2.metaClass.properties.name

Unfortunately "println a2.metaClass.properties.name" returns
["expando", "test", "class", "expando", "metaClass", "test"]

I think this is related to the getProperties method in ExpandoMetaClass:

public List getProperties() { List propertyList = new ArrayList(); propertyList.addAll(expandoProperties.values()); propertyList.addAll(super.getProperties()); return propertyList; }

At first it reads the properties form the local list and adds the properties for MetaClassImpl afterwards. Why are all expando properties are hold twice?

Activity

Hide
Paul King added a comment -

close off release 1.5.4

Show
Paul King added a comment - close off release 1.5.4

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: