« Return to Thread: Method created via ExpandoMetaClass is not recognized

Re: Method created via ExpandoMetaClass is not recognized

by Jochen Theodorou :: Rate this Message:

Reply to Author | View in Thread

Roshan Dawrani schrieb:
> I am also trying to learn Groovy and I tried this thing and for me both
> the things worked -

so they do work... strange

> 1) setting this.metaClass = null in the MyGroovyClassImpl constructor in
> MyGroovyClassImpl.groovy

well... null is an invalid meta class. But we ned one and the global
meta class is used to set the per instance meta class. That means if the
global meta class is changed and the current meta class of the object is
"delegted", then the global meta class becomes the new current meta class.

> 2) setting MyGroovyClassImpl.metaClass.getNext in a static block so that
> it happens only once.

this works, because at this point the meta class for the class is not
yet set.. since there is no instance yet. So if you change the global
meta class and then make an instance, then you get the global metaclass
as current meta class for the current instance.

so it is two different effects


bye blackdrag

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Method created via ExpandoMetaClass is not recognized