Interface MethodHandleDesc
- All Superinterfaces:
ConstantDesc
- All Known Subinterfaces:
DirectMethodHandleDesc
public sealed interface MethodHandleDesc extends ConstantDesc permits DirectMethodHandleDesc (not exhaustive)
MethodHandle
constant.- Since:
- 12
Method Summary
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. |
Methods declared in interface java.lang.constant.ConstantDesc
resolveConstantDesc
Method Details
of
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.
- Parameters:
-
kind
- The kind of method handle to be described -
owner
- aClassDesc
describing the class containing the method, constructor, or field -
name
- the unqualified name of the method or field (ignored ifkind
isCONSTRUCTOR
) -
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 constructor - Returns:
- the MethodHandleDesc
- Throws:
-
NullPointerException
- if any of the non-ignored arguments are null -
IllegalArgumentException
- if the descriptor string is not a valid method or field descriptor - See Java Virtual Machine Specification:
- 4.4.8 The CONSTANT_MethodHandle_info Structure
4.2.2 Unqualified Names
4.3.2 Field Descriptors
4.3.3 Method Descriptors
ofMethod
static 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.
- Parameters:
-
kind
- The kind of method handle to be described; must be one ofSPECIAL, VIRTUAL, STATIC, INTERFACE_SPECIAL, INTERFACE_VIRTUAL, INTERFACE_STATIC, CONSTRUCTOR
-
owner
- aClassDesc
describing the class containing the method or constructor -
name
- the unqualified name of the method (ignored ifkind
isCONSTRUCTOR
) -
lookupMethodType
- aMethodTypeDesc
describing the lookup type - Returns:
- the MethodHandleDesc
- Throws:
-
NullPointerException
- if any non-ignored arguments are null -
IllegalArgumentException
- if thename
has the incorrect format, or the kind is invalid - See Java Virtual Machine Specification:
- 4.2.2 Unqualified Names
ofField
static DirectMethodHandleDesc ofField(DirectMethodHandleDesc.Kind kind, ClassDesc owner, String fieldName, ClassDesc fieldType)
- Parameters:
-
kind
- the kind of the method handle to be described; must be one ofGETTER
,SETTER
,STATIC_GETTER
, orSTATIC_SETTER
-
owner
- aClassDesc
describing the class containing the field -
fieldName
- the unqualified name of the field -
fieldType
- aClassDesc
describing the type of the field - Returns:
- the MethodHandleDesc
- Throws:
-
NullPointerException
- if any of the arguments are null -
IllegalArgumentException
- if thekind
is not one of the valid values or if the field name is not valid - See Java Virtual Machine Specification:
- 4.2.2 Unqualified Names
ofConstructor
static DirectMethodHandleDesc ofConstructor(ClassDesc owner, ClassDesc... paramTypes)
- Parameters:
-
owner
- aClassDesc
describing the class containing the constructor -
paramTypes
-ClassDesc
s describing the parameter types of the constructor - Returns:
- the MethodHandleDesc
- Throws:
-
NullPointerException
- if any argument or its contents isnull
asType
default MethodHandleDesc asType(MethodTypeDesc type)
MethodHandle.asType(MethodType)
.- Parameters:
-
type
- aMethodHandleDesc
describing the new method type - Returns:
- a MethodHandleDesc for the adapted method handle
- Throws:
-
NullPointerException
- if the argument isnull
invocationType
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).- Returns:
- a MethodHandleDesc describing the method handle type
equals
boolean 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, 2021, 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/17/docs/api/java.base/java/lang/constant/MethodHandleDesc.html