Interface MethodSignature
public sealed interface MethodSignature
Models the generic signature of a method or constructor, as defined by JVMS §4.7.9.1.
- See Java Language Specification:
- 8.4 Method Declarations
8.8 Constructor Declarations
- See Java Virtual Machine Specification:
- 4.7.9.1 Signatures
- Since:
- 24
- See Also:
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
List |
arguments() |
Returns the signatures of the parameters of this method or constructor, may be empty. |
static MethodSignature |
of |
Returns a method signature with no type parameter or exception type. |
static MethodSignature |
of |
Returns a method signature for a raw method descriptor. |
static MethodSignature |
of |
Returns a method signature. |
static MethodSignature |
parseFrom |
Parses a raw method signature string into a MethodSignature. |
Signature |
result() |
Returns the signatures of the return value of this method. |
String |
signatureString() |
Returns the raw signature string. |
List |
throwableSignatures() |
Returns the signatures of the exceptions thrown by this method or constructor. |
List |
typeParameters() |
Returns the type parameters of this method or constructor, may be empty. |
Method Details
typeParameters
List<Signature.TypeParam> typeParameters()
Returns the type parameters of this method or constructor, may be empty.
- Returns:
- the type parameters of this method or constructor, may be empty
- See Java Language Specification:
- 8.4.4 Generic Methods
8.8.4 Generic Constructors
- See Also:
arguments
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:
- the signatures of the parameters of this method or constructor, may be empty
- See Java Language Specification:
- 8.4.1 Formal Parameters
8.8.1 Formal Parameters
- See Also:
result
Signature result()
Returns the signatures of the return value of this method. For constructors, this returns a signature representing
void.- Returns:
- the signatures of the return value of this method
- See Java Language Specification:
- 8.4.5 Method Result
- See Also:
throwableSignatures
List<Signature.ThrowableSig> throwableSignatures()
Returns the signatures of the exceptions thrown by this method or constructor.
- Returns:
- the signatures of the exceptions thrown by this method or constructor
- See Java Language Specification:
- 8.4.6 Method Throws
8.8.5 Constructor Throws
- See Also:
signatureString
String signatureString()
Returns the raw signature string.
- Returns:
- the raw signature string
of
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- the method descriptor - Returns:
- a method signature for a raw method descriptor
of
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 for the return type -
arguments- signatures for the method parameters - Returns:
- a method signature with no type parameter or exception type
- Throws:
-
IllegalArgumentException- if any ofargumentsis void
of
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- signatures for the type parameters -
exceptions- signatures for the exceptions -
result- signature for the return type -
arguments- signatures for the method parameters - Returns:
- a method signature
- Throws:
-
IllegalArgumentException- if any ofargumentsis void
parseFrom
static MethodSignature parseFrom(String methodSignature)
Parses a raw method signature string into a
MethodSignature.- Parameters:
-
methodSignature- the raw method signature string - Returns:
- the parsed method signature
- Throws:
-
IllegalArgumentException- if the string is not a valid method signature string
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.