- All Superinterfaces:
ConstantDesc
,TypeDescriptor
,TypeDescriptor.OfMethod<ClassDesc,
MethodTypeDesc>
public sealed interface MethodTypeDesc
extends ConstantDesc, TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
A nominal descriptor for a
MethodType constant.
- Since:
- 12
-
Nested Class Summary
Nested classes/interfaces declared in interface java.lang.invoke.TypeDescriptor
TypeDescriptor.OfField<F extends TypeDescriptor.OfField<F>>, TypeDescriptor.OfMethod<F extends TypeDescriptor.OfField<F>,
M extends TypeDescriptor.OfMethod<F, M>> -
Method Summary
Modifier and TypeMethodDescriptionchangeParameterType
(int index, ClassDesc paramType) Returns a MethodTypeDesc that is identical to this one, except that a single parameter type has been changed to the specified type.changeReturnType
(ClassDesc returnType) Returns a MethodTypeDesc that is identical to this one, except with the specified return type.default String
Returns the method type descriptor string.default String
Returns a human-readable descriptor for this method type, using the canonical names for parameter and return types.dropParameterTypes
(int start, int end) Returns a MethodTypeDesc that is identical to this one, except that a range of parameter types have been removed.boolean
Compares the specified object with this descriptor for equality.insertParameterTypes
(int pos, ClassDesc... paramTypes) Returns a MethodTypeDesc that is identical to this one, except that a range of additional parameter types have been inserted.static MethodTypeDesc
Returns a MethodTypeDesc given the return type and parameter types.static MethodTypeDesc
ofDescriptor
(String descriptor) Creates a MethodTypeDesc given a method descriptor string.Returns the parameter types as an array.int
Returns the number of parameters of the method type described by this MethodTypeDesc.Returns the parameter types as an immutableList
.parameterType
(int index) Returns the parameter type of theindex
'th parameter of the method type described by this MethodTypeDesc.Gets the return type of the method type described by this MethodTypeDesc.Methods declared in interface java.lang.constant.ConstantDesc
resolveConstantDesc
-
Method Details
-
ofDescriptor
Creates a MethodTypeDesc given a method descriptor string.- Parameters:
descriptor
- a method descriptor string- Returns:
- a MethodTypeDesc describing the desired method type
- Throws:
NullPointerException
- if the argument isnull
IllegalArgumentException
- if the descriptor string is not a valid method descriptor- See Java Virtual Machine Specification:
-
4.3.3 Method Descriptors
-
of
Returns a MethodTypeDesc given the return type and parameter types.- Parameters:
returnDesc
- a ClassDesc describing the return typeparamDescs
- ClassDescs describing the argument types- Returns:
- a MethodTypeDesc describing the desired method type
- Throws:
NullPointerException
- if any argument or its contents arenull
IllegalArgumentException
- if any element ofparamDescs
is aClassDesc
forvoid
-
returnType
ClassDesc returnType()Gets the return type of the method type described by this MethodTypeDesc.- Specified by:
returnType
in interfaceTypeDescriptor.OfMethod<ClassDesc,
MethodTypeDesc> - Returns:
- a
ClassDesc
describing the return type of the method type
-
parameterCount
int parameterCount()Returns the number of parameters of the method type described by this MethodTypeDesc.- Specified by:
parameterCount
in interfaceTypeDescriptor.OfMethod<ClassDesc,
MethodTypeDesc> - Returns:
- the number of parameters
-
parameterType
Returns the parameter type of theindex
'th parameter of the method type described by this MethodTypeDesc.- Specified by:
parameterType
in interfaceTypeDescriptor.OfMethod<ClassDesc,
MethodTypeDesc> - Parameters:
index
- the index of the parameter to retrieve- Returns:
- a
ClassDesc
describing the desired parameter type - Throws:
IndexOutOfBoundsException
- if the index is outside the half-open range {[0, parameterCount())}
-
parameterList
Returns the parameter types as an immutableList
.- Specified by:
parameterList
in interfaceTypeDescriptor.OfMethod<ClassDesc,
MethodTypeDesc> - Returns:
- a
List
ofClassDesc
describing the parameter types
-
parameterArray
ClassDesc[] parameterArray()Returns the parameter types as an array.- Specified by:
parameterArray
in interfaceTypeDescriptor.OfMethod<ClassDesc,
MethodTypeDesc> - Returns:
- an array of
ClassDesc
describing the parameter types
-
changeReturnType
Returns a MethodTypeDesc that is identical to this one, except with the specified return type.- Specified by:
changeReturnType
in interfaceTypeDescriptor.OfMethod<ClassDesc,
MethodTypeDesc> - Parameters:
returnType
- aClassDesc
describing the new return type- Returns:
- a MethodTypeDesc describing the desired method type
- Throws:
NullPointerException
- if the argument isnull
-
changeParameterType
Returns a MethodTypeDesc that is identical to this one, except that a single parameter type has been changed to the specified type.- Specified by:
changeParameterType
in interfaceTypeDescriptor.OfMethod<ClassDesc,
MethodTypeDesc> - Parameters:
index
- the index of the parameter to changeparamType
- aClassDesc
describing the new parameter type- Returns:
- a MethodTypeDesc describing the desired method type
- Throws:
NullPointerException
- if any argument isnull
IndexOutOfBoundsException
- if the index is outside the half-open range {[0, parameterCount)}
-
dropParameterTypes
Returns a MethodTypeDesc that is identical to this one, except that a range of parameter types have been removed.- Specified by:
dropParameterTypes
in interfaceTypeDescriptor.OfMethod<ClassDesc,
MethodTypeDesc> - Parameters:
start
- the index of the first parameter to removeend
- the index after the last parameter to remove- Returns:
- a MethodTypeDesc describing the desired method type
- Throws:
IndexOutOfBoundsException
- ifstart
is outside the half-open range[0, parameterCount)
, orend
is outside the closed range[0, parameterCount]
, or ifstart > end
-
insertParameterTypes
Returns a MethodTypeDesc that is identical to this one, except that a range of additional parameter types have been inserted.- Specified by:
insertParameterTypes
in interfaceTypeDescriptor.OfMethod<ClassDesc,
MethodTypeDesc> - Parameters:
pos
- the index at which to insert the first inserted parameterparamTypes
-ClassDesc
s describing the new parameter types to insert- Returns:
- a MethodTypeDesc describing the desired method type
- Throws:
NullPointerException
- if any argument or its contents arenull
IndexOutOfBoundsException
- ifpos
is outside the closed range {[0, parameterCount]}IllegalArgumentException
- if any element ofparamTypes
is aClassDesc
forvoid
-
descriptorString
Returns the method type descriptor string.- Specified by:
descriptorString
in interfaceTypeDescriptor
- Returns:
- the method type descriptor string
- See Java Virtual Machine Specification:
-
4.3.3 Method Descriptors
-
displayDescriptor
Returns a human-readable descriptor for this method type, using the canonical names for parameter and return types.- Returns:
- the human-readable descriptor for this method type
-
equals
Compares the specified object with this descriptor for equality. Returnstrue
if and only if the specified object is also a MethodTypeDesc both have the same arity, their return types are equal, and each pair of corresponding parameter types are equal.
-