Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Won't Fix
-
Affects Version/s: 1.6-beta-1
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
The type of a new instance of a class depends on whether the metaClass property on its class has been accessed before. That is just not right.
groovy> class A {}
groovy> println A.metaClass
groovy> def a = new A ()
groovy> println a.metaClass
groovy> println A.metaClass
groovy.lang.ExpandoMetaClass@b05c54[class A]
groovy.lang.ExpandoMetaClass@b05c54[class A]
groovy.lang.ExpandoMetaClass@b05c54[class A]
groovy> class A {}
groovy> //println A.metaClass
groovy> def a = new A ()
groovy> println a.metaClass
groovy> println A.metaClass
groovy.lang.MetaClassImpl@a7eb57[class A]
groovy.lang.ExpandoMetaClass@2e22ed[class A]
Activity
blackdrag blackdrag
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Status | Open [ 1 ] | Closed [ 6 ] |
| Resolution | Won't Fix [ 2 ] | |
| Assignee | Jochen Theodorou [ blackdrag ] |
this is at the moment by design. If you make a new instance of a GroovyObject, then this instace caches the metaClass once you ask for it. That means, if the MetaClass was not changed before you ask for the MetaClass, then the instance will have the new MetaClass. Else it will have the old one. This has been the case since early we have per instance MetaClasses in Groovy... so the only fix would be to remove per instance MetaClasses... I don't expect you will get a majority for this.