Behavior of MethodHandles.convertArguments

Raffaello Giulietti raffaello.giulietti at gmail.com
Sun May 15 09:40:55 PDT 2011


Hello,

I would expect a WrongMethodTypeException to be thrown by
convertArguments in the following snippet, on the ground that String
is neither a wrapper nor a supertype of a wrapper of int, the return
type of mh0.

        MethodHandle mh0 = lookup.findVirtual(String.class, "length",
MethodType.methodType(int.class));
        MethodHandle mh1 = MethodHandles.convertArguments(mh0,
MethodType.methodType(String.class, String.class));

However, build 142 of the JDK 7 (2011-05-12) executes the code without
errors. Is this expected behavior?

Regards
Raffaello


More information about the mlvm-dev mailing list