Attribute (Java SE 23 & JDK 23)
Description: declaration: module: java.base, package: java.lang.classfile, interface: Attribute
Keywords: java.lang.classfile.Attribute interface

# Interface Attribute<A extends AttributePREVIEW<A>>

Type Parameters:
  `A` - the attribute type

All Superinterfaces:
  `ClassFileElementPREVIEW`, `WritableElementPREVIEW<A>`

All Known Subinterfaces:
  `AnnotationDefaultAttributePREVIEW`, `BootstrapMethodsAttributePREVIEW`, `CharacterRangeTableAttributePREVIEW`, `CodeAttributePREVIEW`, `CompilationIDAttributePREVIEW`, `ConstantValueAttributePREVIEW`, `DeprecatedAttributePREVIEW`, `EnclosingMethodAttributePREVIEW`, `ExceptionsAttributePREVIEW`, `InnerClassesAttributePREVIEW`, `LineNumberTableAttributePREVIEW`, `LocalVariableTableAttributePREVIEW`, `LocalVariableTypeTableAttributePREVIEW`, `MethodParametersAttributePREVIEW`, `ModuleAttributePREVIEW`, `ModuleHashesAttributePREVIEW`, `ModuleMainClassAttributePREVIEW`, `ModulePackagesAttributePREVIEW`, `ModuleResolutionAttributePREVIEW`, `ModuleTargetAttributePREVIEW`, `NestHostAttributePREVIEW`, `NestMembersAttributePREVIEW`, `PermittedSubclassesAttributePREVIEW`, `RecordAttributePREVIEW`, `RuntimeInvisibleAnnotationsAttributePREVIEW`, `RuntimeInvisibleParameterAnnotationsAttributePREVIEW`, `RuntimeInvisibleTypeAnnotationsAttributePREVIEW`, `RuntimeVisibleAnnotationsAttributePREVIEW`, `RuntimeVisibleParameterAnnotationsAttributePREVIEW`, `RuntimeVisibleTypeAnnotationsAttributePREVIEW`, `SignatureAttributePREVIEW`, `SourceDebugExtensionAttributePREVIEW`, `SourceFileAttributePREVIEW`, `SourceIDAttributePREVIEW`, `StackMapTableAttributePREVIEW`, `SyntheticAttributePREVIEW`, `UnknownAttributePREVIEW`

All Known Implementing Classes:
  `CustomAttributePREVIEW`

public sealed interface Attribute<A extends AttributePREVIEW<A>> extends WritableElementPREVIEW<A> permits AnnotationDefaultAttributePREVIEW, BootstrapMethodsAttributePREVIEW, CharacterRangeTableAttributePREVIEW, CodeAttributePREVIEW, CompilationIDAttributePREVIEW, ConstantValueAttributePREVIEW, DeprecatedAttributePREVIEW, EnclosingMethodAttributePREVIEW, ExceptionsAttributePREVIEW, InnerClassesAttributePREVIEW, LineNumberTableAttributePREVIEW, LocalVariableTableAttributePREVIEW, LocalVariableTypeTableAttributePREVIEW, MethodParametersAttributePREVIEW, ModuleAttributePREVIEW, ModuleHashesAttributePREVIEW, ModuleMainClassAttributePREVIEW, ModulePackagesAttributePREVIEW, ModuleResolutionAttributePREVIEW, ModuleTargetAttributePREVIEW, NestHostAttributePREVIEW, NestMembersAttributePREVIEW, PermittedSubclassesAttributePREVIEW, RecordAttributePREVIEW, RuntimeInvisibleAnnotationsAttributePREVIEW, RuntimeInvisibleParameterAnnotationsAttributePREVIEW, RuntimeInvisibleTypeAnnotationsAttributePREVIEW, RuntimeVisibleAnnotationsAttributePREVIEW, RuntimeVisibleParameterAnnotationsAttributePREVIEW, RuntimeVisibleTypeAnnotationsAttributePREVIEW, SignatureAttributePREVIEW, SourceDebugExtensionAttributePREVIEW, SourceFileAttributePREVIEW, SourceIDAttributePREVIEW, StackMapTableAttributePREVIEW, SyntheticAttributePREVIEW, UnknownAttributePREVIEW, CustomAttributePREVIEW<T> (not exhaustive)
`Attribute` is a preview API of the Java platform.
Programs can only use `Attribute` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Models a classfile attribute 4.7. Many, though not all, subtypes of AttributePREVIEW will implement `ClassElement`PREVIEW, `MethodElement`PREVIEW, `FieldElement`PREVIEW, or `CodeElement`PREVIEW; attributes that are also elements will be delivered when traversing the elements of the corresponding model type. Additionally, all attributes are accessible directly from the corresponding model type through `AttributedElement.findAttribute(AttributeMapper)`PREVIEW.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AttributeMapperPREVIEW<A>`
  `attributeMapper()`
  Returns the `AttributeMapper`PREVIEW associated with this attribute.
  `String`
  `attributeName()`
  Returns the name of the attribute.

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

  `writeTo`

- ## Method Details

  - ### attributeName

    String attributeName()
    Returns the name of the attribute.
    Returns:
      the name of the attribute

  - ### attributeMapper

    AttributeMapperPREVIEW<A> attributeMapper()
    Returns the `AttributeMapper`PREVIEW associated with this attribute.
    Returns:
      the `AttributeMapper`PREVIEW associated with this attribute