User defined method handle
John Rose
John.Rose at Sun.COM
Wed Feb 4 16:07:35 PST 2009
On Feb 4, 2009, at 7:38 AM, Rémi Forax wrote:
> It seems it's currently impossible to create a user defined method
> handle
> because the constructor of MethodHandle take a token (Token)
> which is not accessible to user code.
>
> I remember it was a requirement, is this change ?
Yes, it's a simplifying change the EG discussed a while ago. It
allows the JVM to put more constraints on the format of a MH.
Most use cases for Java method handles are covered by bound method
handles (aka curried functions), created with MethodHandles.bind or
MethodHandles.insertArgument. The only thing you can't do is have an
object which is simultaneously a MH and implements some other API
(e.g., a method handle and a Lisp S-expression). If a language wants
to treat a non-MH as a MH-callable thing, it needs to wrap a MH around
it somehow. The existing draft APIs should make this easy.
(I think that covers everything. Or did I miss a use case?)
> Also I don't understand why MethodHandle inherits from
> MethodHandleImpl,
> it should be the inverse. MethodHandle should be the base class
> and MethodHandleImpl a subclass for VM method handles.
Same reason as above: It constrains the format of *all* method
handles in an implementation-private way.
-- John
More information about the mlvm-dev
mailing list