MethodTypeDesc (Java SE 13 & JDK 13 )
- All Superinterfaces:
ConstantDesc,TypeDescriptor,TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
public interface MethodTypeDesc extends ConstantDesc, TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
- API Note:
- In the future, if the Java language permits, MethodTypeDesc
may become a
sealedinterface, which would prohibit subclassing except by explicitly permitted types. Non-platform classes should not implement MethodTypeDesc directly. - Since:
- 12
-
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 isnullIllegalArgumentException- 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 arenullIllegalArgumentException- if any element ofparamDescsis aClassDescforvoid
-
returnType
Gets the return type of the method type described by this MethodTypeDesc.
- Specified by:
returnTypein interfaceTypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>- Returns:
- a
ClassDescdescribing 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:
parameterCountin interfaceTypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>- Returns:
- the number of parameters
-
parameterType
Returns the parameter type of the
index'th parameter of the method type described by this MethodTypeDesc.- Specified by:
parameterTypein interfaceTypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>- Parameters:
index- the index of the parameter to retrieve- Returns:
- a
ClassDescdescribing the desired parameter type - Throws:
IndexOutOfBoundsException- if the index is outside the half-open range {[0, parameterCount())}
-
parameterList
Returns the parameter types as an immutable
List.- Specified by:
parameterListin interfaceTypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>- Returns:
- a
ListofClassDescdescribing the parameter types
-
parameterArray
Returns the parameter types as an array.
- Specified by:
parameterArrayin interfaceTypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>- Returns:
- an array of
ClassDescdescribing the parameter types
-
changeReturnType
Returns a MethodTypeDesc that is identical to this one, except with the specified return type.
- Specified by:
changeReturnTypein interfaceTypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>- Parameters:
returnType- aClassDescdescribing 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:
changeParameterTypein interfaceTypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>- Parameters:
index- the index of the parameter to changeparamType- aClassDescdescribing the new parameter type- Returns:
- a MethodTypeDesc describing the desired method type
- Throws:
NullPointerException- if any argument isnullIndexOutOfBoundsException- 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:
dropParameterTypesin 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- ifstartis outside the half-open range[0, parameterCount), orendis 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:
insertParameterTypesin interfaceTypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>- Parameters:
pos- the index at which to insert the first inserted parameterparamTypes-ClassDescs describing the new parameter types to insert- Returns:
- a MethodTypeDesc describing the desired method type
- Throws:
NullPointerException- if any argument or its contents arenullIndexOutOfBoundsException- ifposis outside the closed range {[0, parameterCount]}IllegalArgumentException- if any element ofparamTypesis aClassDescforvoid
-
descriptorString
default String descriptorString()
Returns the method type descriptor string.
- Specified by:
descriptorStringin interfaceTypeDescriptor- Returns:
- the method type descriptor string
- See Java Virtual Machine Specification:
-
4.3.3 Method Descriptors
-
displayDescriptor
default String 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
boolean equals(Object o)
Compares the specified object with this descriptor for equality. Returns
trueif 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.- Overrides:
equalsin classObject- Parameters:
o- the other object- Returns:
- whether this descriptor is equal to the other object
- See Also:
Object.hashCode(),HashMap
-
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2019, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.