15 May 18:23
Re: [groovy-dev] invokedynamic: Is It What We Really Need?
From: tugwilson <tug@...>
Subject: Re: [groovy-dev] invokedynamic: Is It What We Really Need?
Newsgroups: gmane.comp.lang.groovy.devel
Date: 2008-05-15 16:23:49 GMT
Subject: Re: [groovy-dev] invokedynamic: Is It What We Really Need?
Newsgroups: gmane.comp.lang.groovy.devel
Date: 2008-05-15 16:23:49 GMT
Jochen Theodorou wrote:
>
>
> how do you do super calls in static methods? I mean ok, you give the
> object you make the call on and all that... but:
>
> class Foo{
> def bar(){}
> }
>
> class Bar extend Foo{
> def bar(){super.bar()}
> }
>
> now if this would actually become:
>
> class Foo{
> def bar(){}
> static synthetic access$bar1(Foo f){f.bar()}
> }
>
> class Bar extend Foo{
> def bar(){access$bar1(this)}
> }
>
> then nothing is gained... I mean that would end up with a stack
> overflow, or not?
>
Remember this is a dynamic language and the calls are not made directly but
via the MetaClass. As I describe in detail in
http://docs.google.com/View?docID=ah76zbd6xsx2_9ck33c8dp&revision=_latest
each method in an Ng class is identified by a unique number and is called by
casting the object to CompiledNgObject and calling ng$Call with the
appropriate parameters. So bar() in Foo has a different number to bar() in
Bar and super.bar() in Bar results in a different method handle being used
and hence a different value being passed to ng$Call.
The bottom line is that the runtime system is able to call any method in the
Ng class hierarchy even if that method is overridden in a subclass.
When an Ng class extends a Java class the Ng class handles the calls to all
the visible methods in the Java superclass(es) in its ng$Call
implementations. You can interleave Java and Ng classes in an arbitrary way
and the method dispatch still works.
John Wilson
--
--
View this message in context: http://www.nabble.com/invokedynamic%3A-Is-It-What-We-Really-Need--tp17145635p17257152.html
Sent from the groovy - dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
RSS Feed