Module java.base
Package java.lang.classfile.attributePREVIEW

# Interface SignatureAttribute

All Superinterfaces:
  `AttributePREVIEW<SignatureAttributePREVIEW>`, `ClassElementPREVIEW`, `ClassFileElementPREVIEW`, `FieldElementPREVIEW`, `MethodElementPREVIEW`, `WritableElementPREVIEW<SignatureAttributePREVIEW>`

public sealed interface SignatureAttribute extends AttributePREVIEW<SignatureAttributePREVIEW>, ClassElementPREVIEW, MethodElementPREVIEW, FieldElementPREVIEW
`SignatureAttribute` is a preview API of the Java platform.
Programs can only use `SignatureAttribute` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Models the `Signature` attribute 4.7.9, which can appear on classes, methods, or fields. Delivered as a `ClassElement`PREVIEW, `FieldElement`PREVIEW, or `MethodElement`PREVIEW when traversing the corresponding model type.

The attribute does not permit multiple instances in a given location. Subsequent occurrence of the attribute takes precedence during the attributed element build or transformation.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default ClassSignaturePREVIEW`
  `asClassSignature()`
  Parse the signature as a class signature.
  `default MethodSignaturePREVIEW`
  `asMethodSignature()`
  Parse the signature as a method signature.
  `default SignaturePREVIEW`
  `asTypeSignature()`
  Parse the signature as a type signature.
  `static SignatureAttributePREVIEW`
  `of(ClassSignaturePREVIEW classSignature)`
  Returns a `Signature` attribute for a class.
  `static SignatureAttributePREVIEW`
  `of(Utf8EntryPREVIEW signature)`
  Returns a `Signature` attribute.
  `static SignatureAttributePREVIEW`
  `of(MethodSignaturePREVIEW methodSignature)`
  Returns a `Signature` attribute for a method.
  `static SignatureAttributePREVIEW`
  `of(SignaturePREVIEW signature)`
  Returns a `Signature` attribute.
  `Utf8EntryPREVIEW`
  `signature()`
  Returns the signature for the class, method, or field.

  ### Methods declared in interface java.lang.classfile.AttributePREVIEW

  `attributeMapper, attributeName`

  ### Methods declared in interface java.lang.classfile.WritableElementPREVIEW

  `writeTo`

- ## Method Details

  - ### signature

    Utf8EntryPREVIEW signature()
    Returns the signature for the class, method, or field.
    Returns:
      the signature for the class, method, or field

  - ### asClassSignature

    default ClassSignaturePREVIEW asClassSignature()
    Parse the signature as a class signature.
    Returns:
      the class signature

  - ### asMethodSignature

    default MethodSignaturePREVIEW asMethodSignature()
    Parse the signature as a method signature.
    Returns:
      the method signature

  - ### asTypeSignature

    default SignaturePREVIEW asTypeSignature()
    Parse the signature as a type signature.
    Returns:
      the type signature

  - ### of

    static SignatureAttributePREVIEW of(ClassSignaturePREVIEW classSignature)
    Returns a `Signature` attribute for a class.
    Parameters:
      `classSignature` - the signature
    Returns:
      a `Signature` attribute for a class

  - ### of

    static SignatureAttributePREVIEW of(MethodSignaturePREVIEW methodSignature)
    Returns a `Signature` attribute for a method.
    Parameters:
      `methodSignature` - the signature
    Returns:
      a `Signature` attribute for a method

  - ### of

    static SignatureAttributePREVIEW of(SignaturePREVIEW signature)
    Returns a `Signature` attribute.
    Parameters:
      `signature` - the signature
    Returns:
      a `Signature` attribute

  - ### of

    static SignatureAttributePREVIEW of(Utf8EntryPREVIEW signature)
    Returns a `Signature` attribute.
    Parameters:
      `signature` - the signature
    Returns:
      a `Signature` attribute