Invokedynamic and Multiple Dispatch
John Rose
John.Rose at Sun.COM
Sat Mar 6 17:59:04 PST 2010
On Mar 6, 2010, at 5:21 PM, Larry Chester wrote:
> Then to invoke on an Object x:
>
> lookup.get(x.getClass()).invokeGeneric(x);
>
> This is quite slow though (although I believe the bottleneck is in the
> invokeGeneric call).
I can certainly believe that: invokeGeneric is not fully implemented yet.
Try this instead:
lookup.put(String.class, func.asType(func.type().generic()));
Then you can call any handler with a fast exact call:
lookup.get(x.getClass()).invoke(x); // x must be an Object
-- John
P.S. The name MH.invoke will be changing to MH.invokeExact, to emphasize the difference from invokeGeneric.
More information about the mlvm-dev
mailing list