On invoke dynamic and method handles

Iulian Dragos jaguarul at gmail.com
Wed Dec 17 12:47:54 PST 2008


On Wed, Dec 17, 2008 at 9:13 PM, Rémi Forax <forax at univ-mlv.fr> wrote:
> Iulian Dragos a écrit :
>> I noticed several differences between what JSR 292
>> (http://jcp.org/en/jsr/detail?id=292) says and the current
>> implementation. I know this is work in progress, but at least one
>> difference seems small enough to be an oversight.
>>
> Currently, the first draft of the spec is outdated
> and the implemntation is not up to date too.

I see. So where can I get up to date information?

>> The signature of the bootstrap method is defined as Object(CallSite
>> cs, Object... args) in code, but the JSR lists it as Object(CallSite
>> cs, Object receiver, Object... args). The latter has a great
>> advantage: the arguments are already prepared for a reflective call.
>>
> The current idea is to implement invokedynamic like invokestatic,
> i.e without a receiver.

I see. So how does one generate invoke dynamic in bytecode? Is it
still by using the special marker interface java.dyn.Dynamic?


>> A second question: Is there a way to invoke a method handle
>> generically? That means by passing an Object array, as done above
>> using java.lang.reflect.Method. In other words, could method handles
>> be used in the bootstrap method instead of reflect.Method?
>>
> You can directly call a MethodHandle without put object in a array
> by calling a invoke method with any arguments you want:
> MethodHandle mh=...
> mh.invoke(3,"foo");     // here 3 is not boxed

Yes, but I wanted the opposite: to call it from a context where I
don't know the number of arguments, I just have a bunch of them
stuffed in an array. For example, from inside the bootstrap method.

Rémi, thanks for your answers. The main issue now is how can I get
more up to date information, and whether I'm not trying to use this
feature much too early. For instance, I still cannot compile the javac
compiler with the mlvm patches, they fail with lots of conflicts...

cheers,
iulian

-- 
« Je déteste la montagne, ça cache le paysage »
Alphonse Allais



More information about the mlvm-dev mailing list