RecordComponentInfo (Java SE 26 & JDK 26)
Description: declaration: module: java.base, package: java.lang.classfile.attribute, interface: RecordComponentInfo
Keywords: java.lang.classfile.attribute.RecordComponentInfo interface

# Interface RecordComponentInfo

All Superinterfaces:
  `AttributedElement, ClassFileElement`

public sealed interface RecordComponentInfo extends AttributedElement
Models a single record component in the `RecordAttribute`.

`SignatureAttribute`, `RuntimeVisibleAnnotationsAttribute`, `RuntimeInvisibleAnnotationsAttribute`, `RuntimeVisibleTypeAnnotationsAttribute`, and `RuntimeInvisibleTypeAnnotationsAttribute` are the only predefined attributes that may exist on record components.

See Java Virtual Machine Specification:
  4.7.30 The `Record` Attribute
Since:
  24
See Also:
  - `RecordAttribute.components()`
  - `RecordComponent`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Utf8Entry`
  `descriptor()`
  Returns the field descriptor string of this component.
  `default ClassDesc`
  `descriptorSymbol()`
  Returns the symbolic field descriptor of this component.
  `Utf8Entry`
  `name()`
  Returns the name of this component.
  `static RecordComponentInfo`
  `of(Utf8Entry name, Utf8Entry descriptor, Attribute<?>... attributes)`
  Returns a record component description.
  `static RecordComponentInfo`
  `of(Utf8Entry name, Utf8Entry descriptor, List<Attribute<?>> attributes)`
  Returns a record component description.
  `static RecordComponentInfo`
  `of(String name, ClassDesc descriptor, Attribute<?>... attributes)`
  Returns a record component description.
  `static RecordComponentInfo`
  `of(String name, ClassDesc descriptor, List<Attribute<?>> attributes)`
  Returns a record component description.

  ### Methods declared in interface AttributedElement

  `attributes, findAttribute, findAttributes`
  Modifier and Type
  Method
  Description
  `List<Attribute<?>>`
  `attributes()`
  Returns the attributes of this structure.
  `default <T extends Attribute<T>>
  Optional<T>`
  `findAttribute(AttributeMapper<T> attr)`
  Finds an attribute by name.
  `default <T extends Attribute<T>>
  List<T>`
  `findAttributes(AttributeMapper<T> attr)`
  Finds attributes by name.

- ## Method Details

  - ### name

    Utf8Entry name()
    Returns the name of this component.
    Returns:
      the name of this component
    See Also:
      - `RecordComponent.getName()`

  - ### descriptor

    Utf8Entry descriptor()
    Returns the field descriptor string of this component.
    API Note:
      A record component may have a generic type; this information is stored in the `Signature` attribute in this component.
    Returns:
      the field descriptor string of this component
    See Also:
      - `RecordComponent.getType()`

  - ### descriptorSymbol

    default ClassDesc descriptorSymbol()
    Returns the symbolic field descriptor of this component.
    API Note:
      A record component may have a generic type; this information is stored in the `Signature` attribute in this component.
    Returns:
      the symbolic field descriptor of this component
    See Also:
      - `RecordComponent.getType()`

  - ### of

    static RecordComponentInfo of(Utf8Entry name, Utf8Entry descriptor, List<Attribute<?>> attributes)
    Returns a record component description.
    Parameters:
      `name` - the component name
      `descriptor` - the component field descriptor string
      `attributes` - the component attributes
    Returns:
      a record component description
    Throws:
      `IllegalArgumentException` - if the number of attributes exceeds the limit of `u2`

  - ### of

    static RecordComponentInfo of(Utf8Entry name, Utf8Entry descriptor, Attribute<?>... attributes)
    Returns a record component description.
    Parameters:
      `name` - the component name
      `descriptor` - the component field descriptor sting
      `attributes` - the component attributes
    Returns:
      a record component description
    Throws:
      `IllegalArgumentException` - if the number of attributes exceeds the limit of `u2`

  - ### of

    static RecordComponentInfo of(String name, ClassDesc descriptor, List<Attribute<?>> attributes)
    Returns a record component description.
    Parameters:
      `name` - the component name
      `descriptor` - the component symbolic field descriptor
      `attributes` - the component attributes
    Returns:
      a record component description
    Throws:
      `IllegalArgumentException` - if the number of attributes exceeds the limit of `u2`

  - ### of

    static RecordComponentInfo of(String name, ClassDesc descriptor, Attribute<?>... attributes)
    Returns a record component description.
    Parameters:
      `name` - the component name
      `descriptor` - the component symbolic field descriptor
      `attributes` - the component attributes
    Returns:
      a record component description
    Throws:
      `IllegalArgumentException` - if the number of attributes exceeds the limit of `u2`