ConstantDesc
, TypeDescriptor
, TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
public sealed interface MethodTypeDesc extends ConstantDesc, TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
TypeDescriptor.OfField<F extends TypeDescriptor.OfField<F>>, TypeDescriptor.OfMethod<F extends TypeDescriptor.OfField<F>,M extends TypeDescriptor.OfMethod<F,M>>
Modifier and Type | Method | Description |
---|---|---|
MethodTypeDesc |
changeParameterType |
Returns a MethodTypeDesc that is identical to this one, except that a single parameter type has been changed to the specified type. |
MethodTypeDesc |
changeReturnType |
Returns a MethodTypeDesc that is identical to this one, except with the specified return type. |
String |
descriptorString() |
Returns the method type descriptor string. |
default String |
displayDescriptor() |
Returns a human-readable descriptor for this method type, using the canonical names for parameter and return types. |
MethodTypeDesc |
dropParameterTypes |
Returns a MethodTypeDesc that is identical to this one, except that a range of parameter types have been removed. |
boolean |
equals |
Compares the specified object with this descriptor for equality. |
MethodTypeDesc |
insertParameterTypes |
Returns a MethodTypeDesc that is identical to this one, except that a range of additional parameter types have been inserted. |
static MethodTypeDesc |
of |
Returns a MethodTypeDesc with the given return type and no parameter types. |
static MethodTypeDesc |
of |
Returns a MethodTypeDesc given the return type and parameter types. |
static MethodTypeDesc |
of |
Returns a MethodTypeDesc given the return type and a list of parameter types. |
static MethodTypeDesc |
ofDescriptor |
Creates a MethodTypeDesc given a method descriptor string. |
ClassDesc[] |
parameterArray() |
Returns the parameter types as an array. |
int |
parameterCount() |
Returns the number of parameters of the method type described by this MethodTypeDesc. |
List |
parameterList() |
Returns the parameter types as an immutable List . |
ClassDesc |
parameterType |
Returns the parameter type of the index 'th parameter of the method type described by this MethodTypeDesc. |
MethodType |
resolveConstantDesc |
|
ClassDesc |
returnType() |
Gets the return type of the method type described by this MethodTypeDesc. |
static MethodTypeDesc ofDescriptor(String descriptor)
descriptor
- a method descriptor stringNullPointerException
- if the argument is null
IllegalArgumentException
- if the descriptor string is not a valid method descriptorstatic MethodTypeDesc of(ClassDesc returnDesc)
returnDesc
- a ClassDesc describing the return typeNullPointerException
- if returnDesc
is null
static MethodTypeDesc of(ClassDesc returnDesc, List<ClassDesc> paramDescs)
returnDesc
- a ClassDesc describing the return typeparamDescs
- a List of ClassDescs describing the parameter typesNullPointerException
- if any argument or its contents are null
IllegalArgumentException
- if any element of paramDescs
is a ClassDesc
for void
static MethodTypeDesc of(ClassDesc returnDesc, ClassDesc... paramDescs)
returnDesc
- a ClassDesc describing the return typeparamDescs
- ClassDescs describing the argument typesNullPointerException
- if any argument or its contents are null
IllegalArgumentException
- if any element of paramDescs
is a ClassDesc
for void
ClassDesc returnType()
returnType
in interface TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
ClassDesc
describing the return type of the method typeint parameterCount()
parameterCount
in interface TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
ClassDesc parameterType(int index)
index
'th parameter of the method type described by this MethodTypeDesc.parameterType
in interface TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
index
- the index of the parameter to retrieveClassDesc
describing the desired parameter typeIndexOutOfBoundsException
- if the index is outside the half-open range [0, parameterCount())
List<ClassDesc> parameterList()
List
.parameterList
in interface TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
List
of ClassDesc
describing the parameter typesClassDesc[] parameterArray()
parameterArray
in interface TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
ClassDesc
describing the parameter typesMethodTypeDesc changeReturnType(ClassDesc returnType)
changeReturnType
in interface TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
returnType
- a ClassDesc
describing the new return typeNullPointerException
- if the argument is null
MethodTypeDesc changeParameterType(int index, ClassDesc paramType)
changeParameterType
in interface TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
index
- the index of the parameter to changeparamType
- a ClassDesc
describing the new parameter typeNullPointerException
- if any argument is null
IndexOutOfBoundsException
- if the index is outside the half-open range [0, parameterCount)
MethodTypeDesc dropParameterTypes(int start, int end)
dropParameterTypes
in interface TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
start
- the index of the first parameter to removeend
- the index after the last parameter to removeIndexOutOfBoundsException
- if start
is outside the half-open range [0, parameterCount)
, or end
is outside the closed range [0, parameterCount]
, or if start > end
MethodTypeDesc insertParameterTypes(int pos, ClassDesc... paramTypes)
insertParameterTypes
in interface TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
pos
- the index at which to insert the first inserted parameterparamTypes
- ClassDesc
s describing the new parameter types to insertNullPointerException
- if any argument or its contents are null
IndexOutOfBoundsException
- if pos
is outside the closed range [0, parameterCount]
IllegalArgumentException
- if any element of paramTypes
is a ClassDesc
for void
String descriptorString()
descriptorString
in interface TypeDescriptor
default String displayDescriptor()
MethodType resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException
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 MethodTypeDesc both have the same arity, their return types are equal, and each pair of corresponding parameter types are equal.
© 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/MethodTypeDesc.html