John Rose wrote: > On Aug 18, 2009, at 6:07 AM, Raffaello Giulietti wrote: > >> Hi Christian, >> >> do an upcast >> >> String result = mh.<String>invoke((Object) "foo"); > > Yes. The difference between the two call sites is: > (Ljava/lang/String;)Ljava/lang/String; > vs. > (Ljava/lang/Object;)Ljava/lang/String; > > The actual (erased) types of the arguments determine the descriptor, > and hence the required MethodType. > > To avoid all such issues, with a possible performance hit, use the > more lenient calling sequence supplied (as a non-primitive) by > MethodHandles.invoke: > String result = (String) MethodHandles.invoke(mh, "foo"); > > MHs.invoke (which has fixed-arity and varargs versions) supplies all- > you-can-eat boxing and casting. > > This is an issue being discussed by the EG, whether the lenient > semantics of MHs.invoke should be supported at all times by the > primitive MH.invoke. The cost of doing so would be increased > complexity at every MH invocation site, in many JVMs. The benefit > would be ease of programming.
I see. Thank you for the explanation. -- Christian _______________________________________________ mlvm-dev mailing list mlvm-dev@openjdk.java.net http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev