ConstantDesc
DirectMethodHandleDesc
public sealed interface MethodHandleDesc extends ConstantDesc permits DirectMethodHandleDesc (not exhaustive)
MethodHandle
constant.Modifier and Type | Method | Description |
---|---|---|
default MethodHandleDesc |
asType |
Returns a MethodHandleDesc that describes this method handle adapted to a different type, as if by MethodHandle.asType(MethodType) . |
boolean |
equals |
Compares the specified object with this descriptor for equality. |
MethodTypeDesc |
invocationType() |
Returns a MethodTypeDesc describing the invocation type of the method handle described by this nominal descriptor. |
static DirectMethodHandleDesc |
of |
Creates a MethodHandleDesc corresponding to an invocation of a declared method, invocation of a constructor, or access to a field. |
static DirectMethodHandleDesc |
ofConstructor |
Returns a MethodHandleDesc corresponding to invocation of a constructor |
static DirectMethodHandleDesc |
ofField |
Creates a MethodHandleDesc corresponding to a method handle that accesses a field. |
static DirectMethodHandleDesc |
ofMethod |
Creates a MethodHandleDesc corresponding to an invocation of a declared method or constructor. |
MethodHandle |
resolveConstantDesc |
static DirectMethodHandleDesc of(DirectMethodHandleDesc.Kind kind, ClassDesc owner, 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 describedowner
- 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 nullIllegalArgumentException
- if the descriptor string is not a valid method or field descriptorstatic DirectMethodHandleDesc ofMethod(DirectMethodHandleDesc.Kind kind, ClassDesc owner, 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
owner
- 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 owner, 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
owner
- 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 values or if the field name is not validstatic DirectMethodHandleDesc ofConstructor(ClassDesc owner, ClassDesc... paramTypes)
owner
- a ClassDesc
describing the class containing the constructorparamTypes
- ClassDesc
s describing the parameter types of the constructorNullPointerException
- if any argument or its contents is null
default MethodHandleDesc asType(MethodTypeDesc type)
MethodHandle.asType(MethodType)
.type
- a MethodHandleDesc
describing the new method typeNullPointerException
- if the argument is null
MethodTypeDesc 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).MethodHandle resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException
ConstantDesc
MethodHandles.Lookup
parameter. No caching of the resulting value is performed.resolveConstantDesc
in interface ConstantDesc
lookup
- The MethodHandles.Lookup
to provide name resolution and access control contextReflectiveOperationException
- if a class, method, or field could not be reflectively resolved in the course of resolutionboolean equals(Object o)
true
if and only if the specified object is also a MethodHandleDesc, and both encode the same nominal description of a method handle.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/constant/MethodHandleDesc.html