Spec-Zone .ru
спецификации, руководства, описания, API
|
|
Java™ Platform Standard Ed. 7 DRAFT ea-b118 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MethodHandleProvider
An interface for an object to provide a target method handle to a invokedynamic
instruction.
There are many function-like objects in various Java APIs.
This interface provides a standard way for such function-like objects to be bound
to a dynamic call site, by providing a view of their behavior in the form of a low-level method handle.
The type MethodHandle
is a concrete class whose implementation
hierarchy (if any) may be tightly coupled to the underlying JVM implementation.
It cannot also serve as a base type for user-defined functional APIs.
For this reason, MethodHandle
cannot be subclassed to add new
behavior to method handles. But this interface can be used to provide
a link between a user-defined function and the invokedynamic
instruction and the method handle API.
Modifier and Type | Method and Description |
---|---|
MethodHandle |
asMethodHandle()
Produce a method handle which will serve as a behavioral proxy for the current object. |
MethodHandle |
asMethodHandle(MethodType type)
Produce a method handle of a given type which will serve as a behavioral proxy for the current object. |
Method Detail |
---|
MethodHandle asMethodHandle()
The current object may have a changeable behavior.
For example, CallSite
has a setTarget
method which changes its invocation.
In such a case, it is incorrect for asMethodHandle
to return
a method handle whose behavior may diverge from that of the current object.
Rather, the returned method handle must stably and permanently access
the behavior of the current object, even if that behavior is changeable.
The reference identity of the proxy method handle is not guaranteed to
have any particular relation to the reference identity of the object.
In particular, several objects with the same intended meaning could
share a common method handle, or the same object could return different
method handles at different times. In the latter case, the different
method handles should have the same type and invocation behavior,
and be usable from any thread at any time.
In particular, if a MethodHandleProvider is bound to an invokedynamic
call site, the proxy method handle extracted at the time of binding
will be used for an unlimited time, until the call site is rebound.
The type MethodHandle
itself implements MethodHandleProvider
, and
for this method simply returns this
.
MethodHandle asMethodHandle(MethodType type) throws WrongMethodTypeException
asMethodHandle()
, the invocation behavior of the
proxy method handle is user-defined. But the type must be the given type,
or else a WrongMethodTypeException
must be thrown.
If the current object somehow represents a variadic or overloaded behavior, the method handle returned for a given type might represent only a subset of the current object's repertoire of behaviors, which correspond to that type.
WrongMethodTypeException
|
Java™ Platform Standard Ed. 7 DRAFT ea-b118 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 1993, 2010, Oracle Corporation. All rights reserved.