APIdia Launch Partner
Top Description Methods
java.lang.classfile.attribute

public sealed Interface SignatureAttribute

extends Attribute<SignatureAttribute>, ClassElement, MethodElement, FieldElement
permits BoundSignatureAttribute, UnboundSignatureAttribute
Known Direct Implementers
jdk.internal.classfile.impl.BoundAttribute.BoundSignatureAttribute, jdk.internal.classfile.impl.UnboundAttribute.UnboundSignatureAttribute
Imports
java.lang.classfile.*, java.lang.classfile.constantpool.Utf8Entry, java.lang.reflect.Field, .RecordComponent, jdk.internal.classfile.impl.BoundAttribute, .TemporaryConstantPool, .UnboundAttribute

Models the Signature attribute (JVMS 4.7.9), which indicates the generic signature of this structure.

This attribute appears on classes, fields, methods, and record components, and does not permit multiple instances in one structure. It has a data dependency on the constant pool.

The attribute was introduced in the Java SE Platform version 5.0, major version 49.

Since
24
Java Virtual Machine Specification
4.7.9 The Signature Attribute
See Also
Signature, ClassSignature, MethodSignature

Method Summary

Modifier and TypeMethod and Description
public default ClassSignature

Returns:

the class signature
asClassSignature
()

Parses the signature string as a class signature.

public default MethodSignature

Returns:

the method signature
asMethodSignature
()

Parse the signature string as a method signature.

public default Signature

Returns:

the type signature
asTypeSignature
()

Parses the signature string as a Java type signature.

public static SignatureAttribute

Returns:

a Signature attribute for a class
of
(ClassSignature
the class signature
classSignature
)

Returns a Signature attribute for a class.

public static SignatureAttribute

Returns:

a Signature attribute for a method
of
(MethodSignature
the method signature
methodSignature
)

Returns a Signature attribute for a method.

public static SignatureAttribute

Returns:

a Signature attribute for a field or a record component
of
(Signature
the Java type signature
signature
)

Returns a Signature attribute for a field or a record component.

public static SignatureAttribute

Returns:

a Signature attribute
of
(Utf8Entry
the signature string
signature
)

Returns a Signature attribute.

public Utf8Entry

Returns:

the signature string for the class, method, field, or record component
signature
()

Returns the signature string for the class, method, field, or record component.

Inherited from java.lang.classfile.Attribute:
attributeMapperattributeName

Method Detail

asClassSignatureback to summary
public default ClassSignature asClassSignature()

Parses the signature string as a class signature.

Returns:ClassSignature

the class signature

Exceptions
IllegalArgumentException:
if the signature string is not a valid class signature string
asMethodSignatureback to summary
public default MethodSignature asMethodSignature()

Parse the signature string as a method signature.

Returns:MethodSignature

the method signature

Exceptions
IllegalArgumentException:
if the signature string is not a valid method signature string
asTypeSignatureback to summary
public default Signature asTypeSignature()

Parses the signature string as a Java type signature.

Returns:Signature

the type signature

Exceptions
IllegalArgumentException:
if the signature string is not a valid Java type signature string
See Also
Field#getGenericType(), RecordComponent#getGenericType()
ofback to summary
public static SignatureAttribute of(ClassSignature classSignature)

Returns a Signature attribute for a class.

Parameters
classSignature:ClassSignature

the class signature

Returns:SignatureAttribute

a Signature attribute for a class

ofback to summary
public static SignatureAttribute of(MethodSignature methodSignature)

Returns a Signature attribute for a method.

Parameters
methodSignature:MethodSignature

the method signature

Returns:SignatureAttribute

a Signature attribute for a method

ofback to summary
public static SignatureAttribute of(Signature signature)

Returns a Signature attribute for a field or a record component.

Parameters
signature:Signature

the Java type signature

Returns:SignatureAttribute

a Signature attribute for a field or a record component

ofback to summary
public static SignatureAttribute of(Utf8Entry signature)

Returns a Signature attribute.

Parameters
signature:Utf8Entry

the signature string

Returns:SignatureAttribute

a Signature attribute

signatureback to summary
public Utf8Entry signature()

Returns the signature string for the class, method, field, or record component. It is a class signature string if this attribute is on a class, a method signature string if this attribute is on a method, or a field signature string if this attribute is on a field or a record component.

Returns:Utf8Entry

the signature string for the class, method, field, or record component

Java Virtual Machine Specification
4.7.9.1 Signatures