Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
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 :
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?
close off release 1.5.4