java.lang.constant.MethodTypeDesc
A nominal descriptor for a MethodType constant.
Declaration
public interface MethodTypeDesc extends ConstantDesc, TypeDescriptor.OfMethod<ClassDesc, MethodTypeDesc> {
static MethodTypeDesc ofDescriptor(String descriptor) {
return MethodTypeDescImpl.ofDescriptor(descriptor);
}
static MethodTypeDesc of(ClassDesc returnDesc, ClassDesc... paramDescs) {
return new MethodTypeDescImpl(returnDesc, paramDescs);
}
ClassDesc returnType();
int parameterCount();
ClassDesc parameterType(int index);
List<ClassDesc> parameterList();
ClassDesc[] parameterArray();
MethodTypeDesc changeReturnType(ClassDesc returnType);
MethodTypeDesc changeParameterType(int index, ClassDesc paramType);
MethodTypeDesc dropParameterTypes(int start, int end);
MethodTypeDesc insertParameterTypes(int pos, ClassDesc... paramTypes);
default String descriptorString() {
return String.format("(%s)%s",
Stream.of(parameterArray()).map(ClassDesc::descriptorString).collect(Collectors.joining()),
returnType().descriptorString());
}
default String displayDescriptor() {
return String.format("(%s)%s",
Stream.of(parameterArray()).map(ClassDesc::displayName).collect(Collectors.joining(",")),
returnType().displayName());
}
boolean equals(Object o);
}
Methods
1. ofDescriptor(String descriptor)
MethodTypeDesc java.lang.constant.MethodTypeDesc.ofDescriptor(String descriptor)
This method takes one argument. This method creates a MethodTypeDesc given a method descriptor string.
Parameters: One parameter is required for this method.
descriptor: a method descriptor string.
Returns: a MethodTypeDesc describing the desired method type.
Throws:
1. NullPointerException - if the argument is null.
2. IllegalArgumentException - if the descriptor string is not a valid method descriptor.
2. of(ClassDesc returnDesc, ClassDesc... paramDescs)
MethodTypeDesc java.lang.constant.MethodTypeDesc.of(ClassDesc returnDesc, ClassDesc... paramDescs)
This method takes two arguments. This method returns a MethodTypeDesc given the return type and parameter types.
Parameters: Two parameters are required for this method.
returnDesc: a ClassDesc describing the return type.
paramDescs: ClassDescs describing the argument types.
Returns: a MethodTypeDesc describing the desired method type.
Throws:
1. NullPointerException - if any argument or its contents are null.
2. IllegalArgumentException - if any element of paramDescs is a ClassDesc for void
3. returnType()
ClassDesc java.lang.constant.MethodTypeDesc.returnType()
This method gets the return type of the method type described by this MethodTypeDesc.
Returns: a ClassDesc describing the return type of the method type
4. parameterCount()
int java.lang.constant.MethodTypeDesc.parameterCount()
This method returns the number of parameters of the method type described by this MethodTypeDesc.
Returns: the number of parameters
5. parameterType(int index)
ClassDesc java.lang.constant.MethodTypeDesc.parameterType(int index)
This method takes one argument. This method returns the parameter type of the index's parameter of the method type described by this MethodTypeDesc.
Parameters: One parameter is required for this method.
index: the index of the parameter to retrieve.
Returns: a ClassDesc describing the desired parameter type.
Throws:
1. IndexOutOfBoundsException - if the index is outside the half-open range {[0, parameterCount())}
6. parameterList()
List<ClassDesc> java.lang.constant.MethodTypeDesc.parameterList()
This method returns the parameter types as an immutable List.
Returns: a List of ClassDesc describing the parameter types.
7. parameterArray()
ClassDesc[] java.lang.constant.MethodTypeDesc.parameterArray()
This method returns the parameter types as an array.
Returns: an array of ClassDesc describing the parameter types.
8. changeReturnType(ClassDesc returnType)
MethodTypeDesc java.lang.constant.MethodTypeDesc.changeReturnType(ClassDesc returnType)
This method takes one argument. This method returns a MethodTypeDesc that is identical to this one, except with the specified return type.
Parameters: One parameter is required for this method.
returnType: a ClassDesc describing the new return type.
Returns: a MethodTypeDesc describing the desired method type.
Throws:
1. NullPointerException - if the argument is null.
9. changeParameterType(int index, ClassDesc paramType)
MethodTypeDesc java.lang.constant.MethodTypeDesc.changeParameterType(int index, ClassDesc paramType)
This method takes two arguments. This method returns a MethodTypeDesc that is identical to this one, except that a single parameter type has been changed to the specified type.
Parameters: Two parameters are required for this method.
index: the index of the parameter to change.
paramType: a ClassDesc describing the new parameter type.
Returns: a MethodTypeDesc describing the desired method type.
Throws:
1. NullPointerException - if any argument is null.
2. IndexOutOfBoundsException - if the index is outside the half-open range {[0, parameterCount)}.
10. dropParameterTypes(int start, int end)
MethodTypeDesc java.lang.constant.MethodTypeDesc.dropParameterTypes(int start, int end)
This method takes two arguments. This method returns a MethodTypeDesc that is identical to this one, except that a range of parameter types have been removed.
Parameters: Two parameters are required for this method.
start: the index of the first parameter to remove.
end: the index after the last parameter to remove.
Returns: a MethodTypeDesc describing the desired method type.
Throws:
1. IndexOutOfBoundsException - if start is outside the half-open range [0, parameterCount), or end is outside the closed range [0, parameterCount], or if start > end.
11. insertParameterTypes(int pos, ClassDesc... paramTypes)
MethodTypeDesc java.lang.constant.MethodTypeDesc.insertParameterTypes(int pos, ClassDesc... paramTypes)
This method takes two arguments. This method returns a MethodTypeDesc that is identical to this one, except that a range of additional parameter types have been inserted.
Parameters: Two parameters are required for this method.
pos: the index at which to insert the first inserted parameter.
paramTypes: ClassDescs describing the new parameter types to insert.
Returns: a MethodTypeDesc describing the desired method type.
Throws:
1. NullPointerException - if any argument or its contents are null.
2. IndexOutOfBoundsException - if pos is outside the closed range {[0, parameterCount]}.
3. IllegalArgumentException - if any element of paramTypes is a ClassDesc for void
12. descriptorString()
String java.lang.constant.MethodTypeDesc.descriptorString()
This method returns the method type descriptor string.
Returns: the method type descriptor string.
13. displayDescriptor()
String java.lang.constant.MethodTypeDesc.displayDescriptor()
This method 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.
14. equals(Object o)
boolean java.lang.constant.MethodTypeDesc.equals(Object o)
This method takes one argument. This method compares the specified object with this descriptor for equality. Returns 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.
Parameters: One parameter is required for this method.
o: the other object.
Returns: whether this descriptor is equal to the other object.
Some other classes/interfaces of java.lang.constant
MethodTypeDesc: A nominal descriptor for a MethodType constant.
MethodHandleDesc: A nominal descriptor for a MethodHandle constant.
DynamicConstantDesc: A nominal descriptor for a dynamic constant.
DynamicCallSiteDesc: A nominal descriptor for an invoke dynamic call site.
DirectMethodHandleDesc: A nominal descriptor for a direct MethodHandle. A DirectMethodHandleDesc corresponds to a Constant_MethodHandle_info entry in the constant pool of a class file.
ConstantDescs: Predefined values of nominal descriptors for common constants, including descriptors for primitive class types and other common platform types, and descriptors for method handles for standard bootstrap methods.
ConstantDesc: A nominal descriptor for a loadable constant value. Such a descriptor can be resolved via ConstantDesc.resolveConstantDesc(MethodHandles.Lookup) to yield the constant value itself.
Constable: Represents a type that is constable. A constable type is one whose values are constants that can be represented in the constant pool of a Java class file.
ClassDesc: A nominal descriptor for a Class constant.