ConstantDesc
DirectMethodHandleDesc
public interface MethodHandleDesc extends ConstantDesc
MethodHandle
constant.Modifier and Type | Method | Description |
---|---|---|
default MethodHandleDesc |
asType(MethodTypeDesc type) |
Return a MethodHandleDesc that describes this method handle
adapted to a different type, as if by
MethodHandle.asType(MethodType) . |
MethodTypeDesc |
invocationType() |
Return a
MethodTypeDesc describing the invocation type of the
method handle described by this nominal descriptor. |
static DirectMethodHandleDesc |
of(DirectMethodHandleDesc.Kind kind,
ClassDesc clazz,
String name,
String lookupDescriptor) |
Create a MethodHandleDesc corresponding to an invocation of a
declared method, invocation of a constructor, or access to a field.
|
static DirectMethodHandleDesc |
ofConstructor(ClassDesc clazz,
ClassDesc... paramTypes) |
Return a MethodHandleDesc corresponding to invocation of a constructor
|
static DirectMethodHandleDesc |
ofField(DirectMethodHandleDesc.Kind kind,
ClassDesc clazz,
String fieldName,
ClassDesc fieldType) |
Create a MethodHandleDesc corresponding to a method handle
that accesses a field.
|
static DirectMethodHandleDesc |
ofMethod(DirectMethodHandleDesc.Kind kind,
ClassDesc clazz,
String name,
MethodTypeDesc lookupMethodType) |
Create a MethodHandleDesc corresponding to an invocation of a
declared method or constructor.
|
resolveConstantDesc
static DirectMethodHandleDesc of(DirectMethodHandleDesc.Kind kind, ClassDesc clazz, String name, String lookupDescriptor)
The lookup descriptor string has the same format as for the various
variants of CONSTANT_MethodHandle_info
and for the lookup
methods on MethodHandles.Lookup
. For a method or constructor
invocation, it is interpreted as a method type descriptor; for field
access, it is interpreted as a field descriptor. If kind
is
CONSTRUCTOR
, the name
parameter is ignored and the return
type of the lookup descriptor must be void
. If kind
corresponds to a virtual method invocation, the lookup type includes the
method parameters but not the receiver type.
kind
- The kind of method handle to be describedclazz
- a ClassDesc
describing the class containing the
method, constructor, or fieldname
- the unqualified name of the method or field (ignored if
kind
is CONSTRUCTOR
)lookupDescriptor
- a method descriptor string the lookup type,
if the request is for a method invocation, or
describing the invocation type, if the request is
for a field or constructorNullPointerException
- if any of the non-ignored arguments are nullstatic DirectMethodHandleDesc ofMethod(DirectMethodHandleDesc.Kind kind, ClassDesc clazz, String name, MethodTypeDesc lookupMethodType)
The lookup descriptor string has the same format as for the lookup
methods on MethodHandles.Lookup
. If kind
is
CONSTRUCTOR
, the name is ignored and the return type of the lookup
type must be void
. If kind
corresponds to a virtual method
invocation, the lookup type includes the method parameters but not the
receiver type.
kind
- The kind of method handle to be described; must be one of
SPECIAL, VIRTUAL, STATIC, INTERFACE_SPECIAL,
INTERFACE_VIRTUAL, INTERFACE_STATIC, CONSTRUCTOR
clazz
- a ClassDesc
describing the class containing the
method or constructorname
- the unqualified name of the method (ignored if kind
is CONSTRUCTOR
)lookupMethodType
- a MethodTypeDesc
describing the lookup typeNullPointerException
- if any non-ignored arguments are nullIllegalArgumentException
- if the name
has the incorrect
format, or the kind is invalidstatic DirectMethodHandleDesc ofField(DirectMethodHandleDesc.Kind kind, ClassDesc clazz, String fieldName, ClassDesc fieldType)
kind
- the kind of the method handle to be described; must be one of GETTER
,
SETTER
, STATIC_GETTER
, or STATIC_SETTER
clazz
- a ClassDesc
describing the class containing the fieldfieldName
- the unqualified name of the fieldfieldType
- a ClassDesc
describing the type of the fieldNullPointerException
- if any of the arguments are nullIllegalArgumentException
- if the kind
is not one of the
valid valuesstatic DirectMethodHandleDesc ofConstructor(ClassDesc clazz, ClassDesc... paramTypes)
clazz
- a ClassDesc
describing the class containing the
constructorparamTypes
- ClassDesc
s describing the parameter types of
the constructorNullPointerException
- if any of the arguments are nulldefault MethodHandleDesc asType(MethodTypeDesc type)
MethodHandle.asType(MethodType)
.type
- a MethodHandleDesc
describing the new method typeMethodTypeDesc invocationType()
MethodTypeDesc
describing the invocation type of the
method handle described by this nominal descriptor. The invocation type
describes the full set of stack values that are consumed by the invocation
(including the receiver, if any).