APIdia Launch Partner
Top Description Methods
java.lang.classfile

public sealed Interface MethodSignature

permits MethodSignatureImpl
Known Direct Implementers
jdk.internal.classfile.impl.SignaturesImpl.MethodSignatureImpl
Imports
java.lang.classfile.attribute.SignatureAttribute, java.lang.constant.MethodTypeDesc, java.lang.reflect.Executable, .Method, java.util.List, jdk.internal.classfile.impl.SignaturesImpl, .Util

Models the generic signature of a method or constructor, as defined by JVMS 4.7.9.1.
Since
24
Java Language Specification
8.4 Method Declarations, 8.8 Constructor Declarations
Java Virtual Machine Specification
4.7.9.1 Signatures
See Also
Executable, SignatureAttribute

Method Summary

Modifier and TypeMethod and Description
public List<Signature>

Returns:

the signatures of the parameters of this method or constructor, may be empty
arguments
()

Returns the signatures of the parameters of this method or constructor, may be empty.

public static MethodSignature

Returns:

a method signature for a raw method descriptor
of
(MethodTypeDesc
the method descriptor
methodDescriptor
)

Returns a method signature for a raw method descriptor.

public static MethodSignature

Returns:

a method signature with no type parameter or exception type
of
(Signature
signature for the return type
result
,
Signature...
signatures for the method parameters
arguments
)

Returns a method signature with no type parameter or exception type.

public static MethodSignature

Returns:

a method signature
of
(List<Signature.TypeParam>
signatures for the type parameters
typeParameters
,
List<Signature.ThrowableSig>
signatures for the exceptions
exceptions
,
Signature
signature for the return type
result
,
Signature...
signatures for the method parameters
arguments
)

Returns a method signature.

public static MethodSignature

Returns:

the parsed method signature
parseFrom
(String
the raw method signature string
methodSignature
)

Parses a raw method signature string into a MethodSignature.

public Signature

Returns:

the signatures of the return value of this method
result
()

Returns the signatures of the return value of this method.

public String

Returns:

the raw signature string
signatureString
()

Returns the raw signature string.

public List<Signature.ThrowableSig>

Returns:

the signatures of the exceptions thrown by this method or constructor
throwableSignatures
()

Returns the signatures of the exceptions thrown by this method or constructor.

public List<Signature.TypeParam>

Returns:

the type parameters of this method or constructor, may be empty
typeParameters
()

Returns the type parameters of this method or constructor, may be empty.

Method Detail

argumentsback to summary
public List<Signature> arguments()

Returns the signatures of the parameters of this method or constructor, may be empty. The parameters may differ from those in the method descriptor because some synthetic or implicit parameters are omitted.

Returns:List<Signature>

the signatures of the parameters of this method or constructor, may be empty

Java Language Specification
8.4.1 Formal Parameters, 8.8.1 Formal Parameters
See Also
Executable#getGenericParameterTypes()
ofback to summary
public static MethodSignature of(MethodTypeDesc methodDescriptor)

Returns a method signature for a raw method descriptor. The resulting signature has no type parameter or exception type declared.

Parameters
methodDescriptor:MethodTypeDesc

the method descriptor

Returns:MethodSignature

a method signature for a raw method descriptor

ofback to summary
public static MethodSignature of(Signature result, Signature... arguments)

Returns a method signature with no type parameter or exception type. The parameters may differ from those in the method descriptor because some synthetic or implicit parameters are omitted.

Parameters
result:Signature

signature for the return type

arguments:Signature[]

signatures for the method parameters

Returns:MethodSignature

a method signature with no type parameter or exception type

Exceptions
IllegalArgumentException:
if any of arguments is void
ofback to summary
public static MethodSignature of(List<Signature.TypeParam> typeParameters, List<Signature.ThrowableSig> exceptions, Signature result, Signature... arguments)

Returns a method signature. The parameters may differ from those in the method descriptor because some synthetic or implicit parameters are omitted.

Parameters
typeParameters:List<Signature.TypeParam>

signatures for the type parameters

exceptions:List<Signature.ThrowableSig>

signatures for the exceptions

result:Signature

signature for the return type

arguments:Signature[]

signatures for the method parameters

Returns:MethodSignature

a method signature

Exceptions
IllegalArgumentException:
if any of arguments is void
parseFromback to summary
public static MethodSignature parseFrom(String methodSignature)

Parses a raw method signature string into a MethodSignature.

Parameters
methodSignature:String

the raw method signature string

Returns:MethodSignature

the parsed method signature

Exceptions
IllegalArgumentException:
if the string is not a valid method signature string
resultback to summary
public Signature result()

Returns the signatures of the return value of this method. For constructors, this returns a signature representing void.

Returns:Signature

the signatures of the return value of this method

Java Language Specification
8.4.5 Method Result
See Also
Method#getGenericReturnType()
signatureStringback to summary
public String signatureString()

Returns the raw signature string.

Returns:String

the raw signature string

throwableSignaturesback to summary
public List<Signature.ThrowableSig> throwableSignatures()

Returns the signatures of the exceptions thrown by this method or constructor.

Returns:List<Signature.ThrowableSig>

the signatures of the exceptions thrown by this method or constructor

Java Language Specification
8.4.6 Method Throws, 8.8.5 Constructor Throws
See Also
Executable#getGenericExceptionTypes()
typeParametersback to summary
public List<Signature.TypeParam> typeParameters()

Returns the type parameters of this method or constructor, may be empty.

Returns:List<Signature.TypeParam>

the type parameters of this method or constructor, may be empty

Java Language Specification
8.4.4 Generic Methods, 8.8.4 Generic Constructors
See Also
Executable#getTypeParameters()