- All Superinterfaces:
ConstantDesc,TypeDescriptor,TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
public sealed interfaceMethodTypeDescextendsConstantDesc,TypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc>
Anominal descriptor for aMethodType constant.
- Since:
- 12
Nested Class Summary
Nested classes/interfaces declared in interface java.lang.invoke.TypeDescriptor
TypeDescriptor.OfField<F extendsTypeDescriptor.OfField<F>>,TypeDescriptor.OfMethod<F extendsTypeDescriptor.OfField<F>,M extendsTypeDescriptor.OfMethod<F, M>> Method Summary
Modifier and TypeMethodDescriptionchangeParameterType(int index,ClassDesc paramType) Returns aMethodTypeDesc that is identical to this one, except that a single parameter type has been changed to the specified type.changeReturnType(ClassDesc returnType) Returns aMethodTypeDesc that is identical to this one, except with the specified return type.Returns the method type descriptor string.defaultStringReturns a human-readable descriptor for this method type, using the canonical names for parameter and return types.dropParameterTypes(int start, int end) Returns aMethodTypeDesc that is identical to this one, except that a range of parameter types have been removed.booleanCompares the specified object with this descriptor for equality.insertParameterTypes(int pos,ClassDesc... paramTypes) Returns aMethodTypeDesc that is identical to this one, except that a range of additional parameter types have been inserted.staticMethodTypeDescReturns aMethodTypeDesc with the given return type and no parameter types.staticMethodTypeDescReturns aMethodTypeDesc given the return type and parameter types.staticMethodTypeDescReturns aMethodTypeDesc given the return type and a list of parameter types.staticMethodTypeDescofDescriptor(String descriptor) Creates aMethodTypeDesc given a method descriptor string.Returns the parameter types as an array.intReturns the number of parameters of the method type described by thisMethodTypeDesc.Returns the parameter types as an immutableList.parameterType(int index) Returns the parameter type of theindex'th parameter of the method type described by thisMethodTypeDesc.Gets the return type of the method type described by thisMethodTypeDesc.
Method Details
ofDescriptor
Creates aMethodTypeDesc given a method descriptor string.- Parameters:
descriptor- a method descriptor string- Returns:
- aMethodTypeDesc describing the desired method type
- Throws:
NullPointerException- if the argument isnullIllegalArgumentException- if the descriptor string is not a valid method descriptor- SeeJava Virtual Machine Specification:
- 4.3.3 Method Descriptors
of
Returns aMethodTypeDesc with the given return type and no parameter types.- Parameters:
returnDesc- aClassDesc describing the return type- Returns:
- aMethodTypeDesc with the given return type and no parameter types
- Throws:
NullPointerException- ifreturnDescisnull- Since:
- 21
of
Returns aMethodTypeDesc given the return type and a list of parameter types.- Parameters:
returnDesc- aClassDesc describing the return typeparamDescs- aList ofClassDescs describing the parameter types- Returns:
- aMethodTypeDesc given the return type and a list of parameter types
- Throws:
NullPointerException- if any argument or its contents arenullIllegalArgumentException- if any element ofparamDescsis aClassDescforvoid- Since:
- 21
of
Returns aMethodTypeDesc given the return type and parameter types.- Parameters:
returnDesc- aClassDesc describing the return typeparamDescs-ClassDescs describing the argument types- Returns:
- aMethodTypeDesc describing the desired method type
- Throws:
NullPointerException- if any argument or its contents arenullIllegalArgumentException- if any element ofparamDescsis aClassDescforvoid
returnType
ClassDesc returnType()Gets the return type of the method type described by thisMethodTypeDesc.- 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 thisMethodTypeDesc.- Specified by:
parameterCountin interfaceTypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc> - Returns:
- the number of parameters
parameterType
Returns the parameter type of theindex'th parameter of the method type described by thisMethodTypeDesc.- 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 immutableList.- Specified by:
parameterListin interfaceTypeDescriptor.OfMethod<ClassDesc,MethodTypeDesc> - Returns:
- a
ListofClassDescdescribing the parameter types
parameterArray
ClassDesc[] 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 aMethodTypeDesc 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:
- aMethodTypeDesc describing the desired method type
- Throws:
NullPointerException- if the argument isnull
changeParameterType
Returns aMethodTypeDesc 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:
- aMethodTypeDesc describing the desired method type
- Throws:
NullPointerException- if any argument isnullIndexOutOfBoundsException- if the index is outside the half-open range[0, parameterCount)
dropParameterTypes
Returns aMethodTypeDesc 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:
- aMethodTypeDesc 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 aMethodTypeDesc 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:
- aMethodTypeDesc 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
String descriptorString()Returns the method type descriptor string.- Specified by:
descriptorStringin interfaceTypeDescriptor- Returns:
- the method type descriptor string
- SeeJava 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
resolveConstantDesc
Resolves this descriptor reflectively, emulating the resolution behavior of JVMS5.4.3 and the access control behavior of JVMS5.4.4. The resolution and access control context is provided by theMethodHandles.Lookupparameter. No caching of the resulting value is performed.- Specified by:
resolveConstantDescin interfaceConstantDesc- API Note:
- MethodTypeDesc can represent method type descriptors that are not representable byMethodType, such as methods with more than 255 parameter slots, so attempts to resolve these may result in errors.
- Parameters:
lookup- TheMethodHandles.Lookupto provide name resolution and access control context- Returns:
- the resolved constant value
- Throws:
ReflectiveOperationException- if a class, method, or field could not be reflectively resolved in the course of resolution
equals
Compares the specified object with this descriptor for equality. Returnstrueif and only if the specified object is also aMethodTypeDesc both have the same arity, their return types are equal, and each pair of corresponding parameter types are equal.