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

Key: GROOVY-2514
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Graeme Rocher
Reporter: Christoph Hartmann
Votes: 0
Watchers: 0
Operations

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

ExpandoMetaClass returns expando properties twice

Created: 18/Jan/08 08:37 AM   Updated: 08/Feb/08 01:26 AM
Component/s: groovy-jdk
Affects Version/s: 1.5.1
Fix Version/s: 1.5.2

Time Tracking:
Not Specified

Environment: WIndows XP SP 2

Testcase included: yes


 Description  « Hide
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?



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Paul King - 08/Feb/08 01:26 AM
close off release 1.5.4