APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.internal.constant

public final Class MethodTypeDescImpl

extends Object
implements MethodTypeDesc
Class Inheritance
All Implemented Interfaces
java.lang.constant.MethodTypeDesc, java.lang.invoke.TypeDescriptor.OfMethod, java.lang.invoke.TypeDescriptor, java.lang.constant.ConstantDesc
Imports
jdk.internal.vm.annotation.Stable, java.lang.constant.ClassDesc, .ConstantDescs, .MethodTypeDesc, java.lang.invoke.MethodHandles, .MethodType, java.util.ArrayList, .Arrays, .List, .Objects

A nominal descriptor for a MethodType. A MethodTypeDescImpl corresponds to a Constant_MethodType_info entry in the constant pool of a classfile.

Field Summary

Modifier and TypeField and Description
private final ClassDesc[]
private String
private final ClassDesc

Constructor Summary

AccessConstructor and Description
private
MethodTypeDescImpl(ClassDesc
a ClassDesc describing the return type
returnType
,
ClassDesc[]
ClassDescs describing the trusted and validated parameter types
validatedArgTypes
)

Constructs a MethodTypeDesc with the specified return type and a trusted and already-validated parameter types array.

Method Summary

Modifier and TypeMethod and Description
private String
private static ClassDesc[]
buildParamTypes(String descriptor, int cur, int end, List<ClassDesc> list)

public MethodTypeDesc
changeParameterType(int index, ClassDesc paramType)

Implements java.lang.constant.MethodTypeDesc.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
changeReturnType(ClassDesc returnType)

Implements java.lang.constant.MethodTypeDesc.changeReturnType.

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

public String
descriptorString()

Implements java.lang.constant.MethodTypeDesc.descriptorString.

Returns the method type descriptor string.

public MethodTypeDesc
dropParameterTypes(int start, int end)

Implements java.lang.constant.MethodTypeDesc.dropParameterTypes.

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

public boolean

Returns:

true if the specified MethodTypeDescImpl is equal to this MethodTypeDescImpl.
equals
(Object
the MethodTypeDescImpl to compare to this MethodTypeDescImpl
o
)

Overrides java.lang.Object.equals.

Implements java.lang.constant.MethodTypeDesc.equals.

Returns true if this MethodTypeDescImpl is equal to another MethodTypeDescImpl.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public MethodTypeDesc
insertParameterTypes(int pos, ClassDesc... paramTypes)

Implements java.lang.constant.MethodTypeDesc.insertParameterTypes.

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

public static MethodTypeDescImpl

Returns:

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

Hides java.lang.constant.MethodTypeDesc.ofDescriptor.

Creates a MethodTypeDescImpl given a method descriptor string.

public static MethodTypeDescImpl
ofTrusted(ClassDesc
a ClassDesc describing the return type
returnType
,
ClassDesc[]
ClassDescs describing the trusted parameter types
trustedArgTypes
)

Constructs a MethodTypeDesc with the specified return type and a trusted parameter types array, which will be validated.

public static MethodTypeDescImpl
ofValidated(ClassDesc
a ClassDesc describing the return type
returnType
,
ClassDesc...
ClassDescs describing the trusted parameter types
trustedArgTypes
)

Constructs a MethodTypeDesc with the specified pre-validated return type and a pre-validated trusted parameter types array.

public ClassDesc[]
parameterArray()

Implements java.lang.constant.MethodTypeDesc.parameterArray.

Returns the parameter types as an array.

public int
parameterCount()

Implements java.lang.constant.MethodTypeDesc.parameterCount.

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

public List<ClassDesc>
parameterList()

Implements java.lang.constant.MethodTypeDesc.parameterList.

Returns the parameter types as an immutable List.

public ClassDesc
parameterType(int index)

Implements java.lang.constant.MethodTypeDesc.parameterType.

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

private static ClassDesc[]
paramTypes(String descriptor, int start, int end)

public MethodType
resolveConstantDesc(MethodHandles.Lookup lookup)

Implements java.lang.constant.MethodTypeDesc.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
returnType()

Implements java.lang.constant.MethodTypeDesc.returnType.

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

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private static ClassDesc
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

argTypesback to summary
private final ClassDesc[] argTypes
Annotations
@Stable
cachedDescriptorStringback to summary
private String cachedDescriptorString
Annotations
@Stable
returnTypeback to summary
private final ClassDesc returnType

Constructor Detail

MethodTypeDescImplback to summary
private MethodTypeDescImpl(ClassDesc returnType, ClassDesc[] validatedArgTypes)

Constructs a MethodTypeDesc with the specified return type and a trusted and already-validated parameter types array.

Parameters
returnType:ClassDesc

a ClassDesc describing the return type

validatedArgTypes:ClassDesc[]

ClassDescs describing the trusted and validated parameter types

Method Detail

buildDescriptorStringback to summary
private String buildDescriptorString()
buildParamTypesback to summary
private static ClassDesc[] buildParamTypes(String descriptor, int cur, int end, List<ClassDesc> list)
changeParameterTypeback to summary
public MethodTypeDesc changeParameterType(int index, ClassDesc paramType)

Implements java.lang.constant.MethodTypeDesc.changeParameterType.

Doc from java.lang.constant.MethodTypeDesc.changeParameterType.

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

Annotations
@Override
changeReturnTypeback to summary
public MethodTypeDesc changeReturnType(ClassDesc returnType)

Implements java.lang.constant.MethodTypeDesc.changeReturnType.

Doc from java.lang.constant.MethodTypeDesc.changeReturnType.

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

Annotations
@Override
descriptorStringback to summary
public String descriptorString()

Implements java.lang.constant.MethodTypeDesc.descriptorString.

Doc from java.lang.constant.MethodTypeDesc.descriptorString.

Returns the method type descriptor string.

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

Implements java.lang.constant.MethodTypeDesc.dropParameterTypes.

Doc from java.lang.constant.MethodTypeDesc.dropParameterTypes.

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

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Implements java.lang.constant.MethodTypeDesc.equals.

Returns true if this MethodTypeDescImpl is equal to another MethodTypeDescImpl. Equality is determined by the two descriptors having equal return types and argument types.

Parameters
o:Object

the MethodTypeDescImpl to compare to this MethodTypeDescImpl

Returns:boolean

true if the specified MethodTypeDescImpl is equal to this MethodTypeDescImpl.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
insertParameterTypesback to summary
public MethodTypeDesc insertParameterTypes(int pos, ClassDesc... paramTypes)

Implements java.lang.constant.MethodTypeDesc.insertParameterTypes.

Doc from java.lang.constant.MethodTypeDesc.insertParameterTypes.

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

Annotations
@Override
ofDescriptorback to summary
public static MethodTypeDescImpl ofDescriptor(String descriptor)

Hides java.lang.constant.MethodTypeDesc.ofDescriptor.

Creates a MethodTypeDescImpl given a method descriptor string.

Parameters
descriptor:String

the method descriptor string

Returns:MethodTypeDescImpl

a MethodTypeDescImpl describing the desired method type

Exceptions
IllegalArgumentException:
if the descriptor string is not a valid method descriptor
Java Virtual Machine Specification
4.3.3 Method Descriptors
ofTrustedback to summary
public static MethodTypeDescImpl ofTrusted(ClassDesc returnType, ClassDesc[] trustedArgTypes)

Constructs a MethodTypeDesc with the specified return type and a trusted parameter types array, which will be validated.

Parameters
returnType:ClassDesc

a ClassDesc describing the return type

trustedArgTypes:ClassDesc[]

ClassDescs describing the trusted parameter types

ofValidatedback to summary
public static MethodTypeDescImpl ofValidated(ClassDesc returnType, ClassDesc... trustedArgTypes)

Constructs a MethodTypeDesc with the specified pre-validated return type and a pre-validated trusted parameter types array.

Parameters
returnType:ClassDesc

a ClassDesc describing the return type

trustedArgTypes:ClassDesc[]

ClassDescs describing the trusted parameter types

parameterArrayback to summary
public ClassDesc[] parameterArray()

Implements java.lang.constant.MethodTypeDesc.parameterArray.

Doc from java.lang.constant.MethodTypeDesc.parameterArray.

Returns the parameter types as an array.

Annotations
@Override
parameterCountback to summary
public int parameterCount()

Implements java.lang.constant.MethodTypeDesc.parameterCount.

Doc from java.lang.constant.MethodTypeDesc.parameterCount.

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

Annotations
@Override
parameterListback to summary
public List<ClassDesc> parameterList()

Implements java.lang.constant.MethodTypeDesc.parameterList.

Doc from java.lang.constant.MethodTypeDesc.parameterList.

Returns the parameter types as an immutable List.

Annotations
@Override
parameterTypeback to summary
public ClassDesc parameterType(int index)

Implements java.lang.constant.MethodTypeDesc.parameterType.

Doc from java.lang.constant.MethodTypeDesc.parameterType.

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

Annotations
@Override
paramTypesback to summary
private static ClassDesc[] paramTypes(String descriptor, int start, int end)
resolveConstantDescback to summary
public MethodType resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException

Implements java.lang.constant.MethodTypeDesc.resolveConstantDesc.

Doc from java.lang.constant.MethodTypeDesc.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.

Annotations
@Override
Exceptions
ReflectiveOperationException:

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

if a class, method, or field could not be reflectively resolved in the course of resolution

returnTypeback to summary
public ClassDesc returnType()

Implements java.lang.constant.MethodTypeDesc.returnType.

Doc from java.lang.constant.MethodTypeDesc.returnType.

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

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override
validateArgumentback to summary
private static ClassDesc validateArgument(ClassDesc arg)