APIdia Launch Partner
Top Description Methods
java.lang.constant

public sealed Interface MethodTypeDesc

extends ConstantDesc, TypeDescriptor.OfMethod<ClassDesc, MethodTypeDesc>
permits MethodTypeDescImpl
Known Direct Implementers
jdk.internal.constant.MethodTypeDescImpl
Imports
java.lang.invoke.MethodHandles, .MethodType, .TypeDescriptor, java.util.List, java.util.stream.Collectors, .Stream, jdk.internal.constant.ConstantUtils, .MethodTypeDescImpl

A nominal descriptor for a MethodType constant.
Since
12

Method Summary

Modifier and TypeMethod and Description
public MethodTypeDesc

Returns:

a MethodTypeDesc describing the desired method type
changeParameterType
(int
the index of the parameter to change
index
,
ClassDesc
a ClassDesc describing the new parameter type
paramType
)

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.changeParameterType.

Returns a MethodTypeDesc that is identical to this one, except that a single parameter type has been changed to the specified type.

public MethodTypeDesc

Returns:

a MethodTypeDesc describing the desired method type
changeReturnType
(ClassDesc
a ClassDesc describing the new return type
returnType
)

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.changeReturnType.

Returns a MethodTypeDesc that is identical to this one, except with the specified return type.

public String

Returns:

the method type descriptor string
descriptorString
()

Redeclares java.lang.invoke.TypeDescriptor.descriptorString.

Returns the method type descriptor string.

public default String

Returns:

the human-readable descriptor for this method type
displayDescriptor
()

Returns a human-readable descriptor for this method type, using the canonical names for parameter and return types.

public MethodTypeDesc

Returns:

a MethodTypeDesc describing the desired method type
dropParameterTypes
(int
the index of the first parameter to remove
start
,
int
the index after the last parameter to remove
end
)

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.dropParameterTypes.

Returns a MethodTypeDesc that is identical to this one, except that a range of parameter types have been removed.

public boolean

Returns:

whether this descriptor is equal to the other object
equals
(Object
the other object
o
)

Compares the specified object with this descriptor for equality.

public MethodTypeDesc

Returns:

a MethodTypeDesc describing the desired method type
insertParameterTypes
(int
the index at which to insert the first inserted parameter
pos
,
ClassDesc...
ClassDescs describing the new parameter types to insert
paramTypes
)

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.insertParameterTypes.

Returns a MethodTypeDesc that is identical to this one, except that a range of additional parameter types have been inserted.

public static MethodTypeDesc

Returns:

a MethodTypeDesc with the given return type and no parameter types
of
(ClassDesc
a ClassDesc describing the return type
returnDesc
)

Returns a MethodTypeDesc with the given return type and no parameter types.

public static MethodTypeDesc

Returns:

a MethodTypeDesc given the return type and a list of parameter types
of
(ClassDesc
a ClassDesc describing the return type
returnDesc
,
List<ClassDesc>
a List of ClassDescs describing the parameter types
paramDescs
)

Returns a MethodTypeDesc given the return type and a list of parameter types.

public static MethodTypeDesc

Returns:

a MethodTypeDesc describing the desired method type
of
(ClassDesc
a ClassDesc describing the return type
returnDesc
,
ClassDesc...
ClassDescs describing the argument types
paramDescs
)

Returns a MethodTypeDesc given the return type and parameter types.

public static MethodTypeDesc

Returns:

a MethodTypeDesc describing the desired method type
ofDescriptor
(String
a method descriptor string
descriptor
)

Creates a MethodTypeDesc given a method descriptor string.

public ClassDesc[]

Returns:

an array of ClassDesc describing the parameter types
parameterArray
()

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.parameterArray.

Returns the parameter types as an array.

public int

Returns:

the number of parameters
parameterCount
()

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.parameterCount.

Returns the number of parameters of the method type described by this MethodTypeDesc.

public List<ClassDesc>

Returns:

a List of ClassDesc describing the parameter types
parameterList
()

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.parameterList.

Returns the parameter types as an immutable List.

public ClassDesc

Returns:

a ClassDesc describing the desired parameter type
parameterType
(int
the index of the parameter to retrieve
index
)

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.parameterType.

Returns the parameter type of the index'th parameter of the method type described by this MethodTypeDesc.

public MethodType
resolveConstantDesc(MethodHandles.Lookup lookup)

Redeclares java.lang.constant.ConstantDesc.resolveConstantDesc.

Resolves this descriptor reflectively, emulating the resolution behavior of JVMS 5.4.3 and the access control behavior of JVMS 5.4.4.

public ClassDesc

Returns:

a ClassDesc describing the return type of the method type
returnType
()

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.returnType.

Gets the return type of the method type described by this MethodTypeDesc.

Method Detail

changeParameterTypeback to summary
public MethodTypeDesc changeParameterType(int index, ClassDesc paramType)

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.changeParameterType.

Returns a MethodTypeDesc that is identical to this one, except that a single parameter type has been changed to the specified type.

Parameters
index:int

the index of the parameter to change

paramType:ClassDesc

a ClassDesc describing the new parameter type

Returns:MethodTypeDesc

a MethodTypeDesc describing the desired method type

Exceptions
NullPointerException:
if any argument is null
IndexOutOfBoundsException:
if the index is outside the half-open range [0, parameterCount)
changeReturnTypeback to summary
public MethodTypeDesc changeReturnType(ClassDesc returnType)

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.changeReturnType.

Returns a MethodTypeDesc that is identical to this one, except with the specified return type.

Parameters
returnType:ClassDesc

a ClassDesc describing the new return type

Returns:MethodTypeDesc

a MethodTypeDesc describing the desired method type

Exceptions
NullPointerException:
if the argument is null
descriptorStringback to summary
public String descriptorString()

Redeclares java.lang.invoke.TypeDescriptor.descriptorString.

Returns the method type descriptor string.

Returns:String

the method type descriptor string

Java Virtual Machine Specification
4.3.3 Method Descriptors
displayDescriptorback to summary
public default String displayDescriptor()

Returns a human-readable descriptor for this method type, using the canonical names for parameter and return types.

Returns:String

the human-readable descriptor for this method type

dropParameterTypesback to summary
public MethodTypeDesc dropParameterTypes(int start, int end)

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.dropParameterTypes.

Returns a MethodTypeDesc that is identical to this one, except that a range of parameter types have been removed.

Parameters
start:int

the index of the first parameter to remove

end:int

the index after the last parameter to remove

Returns:MethodTypeDesc

a MethodTypeDesc describing the desired method type

Exceptions
IndexOutOfBoundsException:
if start is outside the half-open range [0, parameterCount), or end is outside the closed range [0, parameterCount], or if start > end
equalsback to summary
public boolean equals(Object o)

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
o:Object

the other object

Returns:boolean

whether this descriptor is equal to the other object

insertParameterTypesback to summary
public MethodTypeDesc insertParameterTypes(int pos, ClassDesc... paramTypes)

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.insertParameterTypes.

Returns a MethodTypeDesc that is identical to this one, except that a range of additional parameter types have been inserted.

Parameters
pos:int

the index at which to insert the first inserted parameter

paramTypes:ClassDesc[]

ClassDescs describing the new parameter types to insert

Returns:MethodTypeDesc

a MethodTypeDesc describing the desired method type

Exceptions
NullPointerException:
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
ofback to summary
public static MethodTypeDesc of(ClassDesc returnDesc)

Returns a MethodTypeDesc with the given return type and no parameter types.

Parameters
returnDesc:ClassDesc

a ClassDesc describing the return type

Returns:MethodTypeDesc

a MethodTypeDesc with the given return type and no parameter types

Exceptions
NullPointerException:
if returnDesc is null
Since
21
ofback to summary
public static MethodTypeDesc of(ClassDesc returnDesc, List<ClassDesc> paramDescs)

Returns a MethodTypeDesc given the return type and a list of parameter types.

Parameters
returnDesc:ClassDesc

a ClassDesc describing the return type

paramDescs:List<ClassDesc>

a List of ClassDescs describing the parameter types

Returns:MethodTypeDesc

a MethodTypeDesc given the return type and a list of parameter types

Exceptions
NullPointerException:
if any argument or its contents are null
IllegalArgumentException:
if any element of paramDescs is a ClassDesc for void
Since
21
ofback to summary
public static MethodTypeDesc of(ClassDesc returnDesc, ClassDesc... paramDescs)

Returns a MethodTypeDesc given the return type and parameter types.

Parameters
returnDesc:ClassDesc

a ClassDesc describing the return type

paramDescs:ClassDesc[]

ClassDescs describing the argument types

Returns:MethodTypeDesc

a MethodTypeDesc describing the desired method type

Exceptions
NullPointerException:
if any argument or its contents are null
IllegalArgumentException:
if any element of paramDescs is a ClassDesc for void
ofDescriptorback to summary
public static MethodTypeDesc ofDescriptor(String descriptor)

Creates a MethodTypeDesc given a method descriptor string.

Parameters
descriptor:String

a method descriptor string

Returns:MethodTypeDesc

a MethodTypeDesc describing the desired method type

Exceptions
NullPointerException:
if the argument is null
IllegalArgumentException:
if the descriptor string is not a valid method descriptor
Java Virtual Machine Specification
4.3.3 Method Descriptors
parameterArrayback to summary
public ClassDesc[] parameterArray()

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.parameterArray.

Returns the parameter types as an array.

Returns:ClassDesc[]

an array of ClassDesc describing the parameter types

parameterCountback to summary
public int parameterCount()

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.parameterCount.

Returns the number of parameters of the method type described by this MethodTypeDesc.

Returns:int

the number of parameters

parameterListback to summary
public List<ClassDesc> parameterList()

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.parameterList.

Returns the parameter types as an immutable List.

Returns:List<ClassDesc>

a List of ClassDesc describing the parameter types

parameterTypeback to summary
public ClassDesc parameterType(int index)

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.parameterType.

Returns the parameter type of the index'th parameter of the method type described by this MethodTypeDesc.

Parameters
index:int

the index of the parameter to retrieve

Returns:ClassDesc

a ClassDesc describing the desired parameter type

Exceptions
IndexOutOfBoundsException:
if the index is outside the half-open range [0, parameterCount())
resolveConstantDescback to summary
public MethodType resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException

Redeclares java.lang.constant.ConstantDesc.resolveConstantDesc.

Doc from java.lang.constant.ConstantDesc.resolveConstantDesc.

Resolves this descriptor reflectively, emulating the resolution behavior of JVMS 5.4.3 and the access control behavior of JVMS 5.4.4. The resolution and access control context is provided by the MethodHandles.Lookup parameter. No caching of the resulting value is performed.

API Note

MethodTypeDesc can represent method type descriptors that are not representable by MethodType, such as methods with more than 255 parameter slots, so attempts to resolve these may result in errors.

Annotations
@Override
Exceptions
ReflectiveOperationException:
if a class, method, or field could not be reflectively resolved in the course of resolution
Since
21
returnTypeback to summary
public ClassDesc returnType()

Redeclares java.lang.invoke.TypeDescriptor.OfMethod.returnType.

Gets the return type of the method type described by this MethodTypeDesc.

Returns:ClassDesc

a ClassDesc describing the return type of the method type