MethodHandle.bindTo() only for reference types?
John Rose
john.r.rose at oracle.com
Tue Jul 24 12:02:18 PDT 2012
On Jul 24, 2012, at 11:09 AM, Attila Szegedi wrote:
> I don't think technically there'd be a difficulty in having it
> work on primitives, it's just that it ain't the intent; you still use
> insertArguments() for uses that are not semantically "bind"s.
MethodHandle.bind is a less-general primitive. The general API is insertArguments.
Good 292 support for primitives requires a signature-polymorphic API.
Therefore, we have been considering adding something like this, to fill functionality not covered by bind and insertArguments:
class MethodHandle {
/** Binds the given argument(s) to the method handle, but does not invoke it.
* Arguments are not boxed, but rather passed in a signature-polymorphic call.
* Requires an exact match to the corresponding leading parameter types.
* Returns a method handle which accepts any remaining arguments,
* and invokes the original on the combined argument lists.
* Equivalent to insertArguments(this, 0, args), but may be more efficient.
* Equivalent to this.bind(args[0]), but may be more efficient.
*/
public final native Object invokePartial(Object… args) throws Throwable;
}
If we do, we will first experiment internally with it (as a non-public API).
— John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20120724/fd58ac55/attachment.html
More information about the mlvm-dev
mailing list