Few questions about invokeDynamic

Rémi Forax forax at univ-mlv.fr
Tue Jan 11 02:47:57 PST 2011


  Le 11/01/2011 11:32, Christian Thalinger a écrit :
> On Jan 10, 2011, at 2:32 PM, Rémi Forax wrote:
>>> I just got back to this bug and now that InvokeDynamic is gone how can I rewrite that code to work again (without John's Indify magic)?
>>>
>>> -- Christian
>>>
>> Good question.
>>
>> First, I don't know if this bug is specific to invokedynamic or if the
>> conversion code is shared
>> between MetodHandle and invokedynamic. If the code is shared, you can
>> rewrite it using MethodHandle
>> because invokedynamic can be rewritten to
>> bootstrap().getTarget().invokeExact(...)
>>
>> The other solution is to use this small class:
>> http://weblogs.java.net/blog/forax/archive/2011/01/07/call-invokedynamic-java
> I tried that but it does not work.  I get an error on invokeExact (and I think I can't use invokeGeneric)

You can, but it's not needed because you fully specifie the parameter 
types (MethodType) of invokedynamic.

> :
>
> Exception in thread "main" java.dyn.WrongMethodTypeException: ()V cannot be called as ()Z
>
> for:
>
>    assertEquals(false, (boolean) mh.invokeExact());  // void ->  boolean

I think you forget to change the method type of invokedynamic:

MethodHandle mh = dynamicIndy.invokeDynamic("_", MethodType.methodType(boolean.class),
                                                                        ^^^^^^^__________ here

   DynamicIndyTest.class, "bsm", MethodType.methodType(CallSite.class, Lookup.class, String.class, MethodType.class),
   );


>> The last solution is to send enough mails to Brian asking him (he
>> currently own the Java language token)
>> to re-introduce a Java syntax for invokedynamic.
> Yeah, that would help me a lot :-)
>
> -- Christian

Rémi


More information about the mlvm-dev mailing list