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

# Interface ExceptionsAttribute

All Superinterfaces:
  `AttributePREVIEW<ExceptionsAttributePREVIEW>`, `ClassFileElementPREVIEW`, `MethodElementPREVIEW`, `WritableElementPREVIEW<ExceptionsAttributePREVIEW>`

public sealed interface ExceptionsAttribute extends AttributePREVIEW<ExceptionsAttributePREVIEW>, MethodElementPREVIEW
`ExceptionsAttribute` is a preview API of the Java platform.
Programs can only use `ExceptionsAttribute` 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 `Exceptions` attribute 4.7.5, which can appear on methods, and records the exceptions declared to be thrown by this method. Delivered as a `MethodElement`PREVIEW when traversing the elements of a `MethodModel`PREVIEW.

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
  `List<ClassEntryPREVIEW>`
  `exceptions()`
  Returns the exceptions declared to be thrown by this method.
  `static ExceptionsAttributePREVIEW`
  `of(ClassEntryPREVIEW... exceptions)`
  Returns an `Exceptions` attribute.
  `static ExceptionsAttributePREVIEW`
  `of(List<ClassEntryPREVIEW> exceptions)`
  Returns an `Exceptions` attribute.
  `static ExceptionsAttributePREVIEW`
  `ofSymbols(ClassDesc... exceptions)`
  Returns an `Exceptions` attribute.
  `static ExceptionsAttributePREVIEW`
  `ofSymbols(List<ClassDesc> exceptions)`
  Returns an `Exceptions` attribute.

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

  `attributeMapper, attributeName`

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

  `writeTo`

- ## Method Details

  - ### exceptions

    List<ClassEntryPREVIEW> exceptions()
    Returns the exceptions declared to be thrown by this method.
    Returns:
      the exceptions declared to be thrown by this method

  - ### of

    static ExceptionsAttributePREVIEW of(List<ClassEntryPREVIEW> exceptions)
    Returns an `Exceptions` attribute.
    Parameters:
      `exceptions` - the checked exceptions that may be thrown from this method
    Returns:
      an `Exceptions` attribute

  - ### of

    static ExceptionsAttributePREVIEW of(ClassEntryPREVIEW... exceptions)
    Returns an `Exceptions` attribute.
    Parameters:
      `exceptions` - the checked exceptions that may be thrown from this method
    Returns:
      an `Exceptions` attribute

  - ### ofSymbols

    static ExceptionsAttributePREVIEW ofSymbols(List<ClassDesc> exceptions)
    Returns an `Exceptions` attribute.
    Parameters:
      `exceptions` - the checked exceptions that may be thrown from this method
    Returns:
      an `Exceptions` attribute

  - ### ofSymbols

    static ExceptionsAttributePREVIEW ofSymbols(ClassDesc... exceptions)
    Returns an `Exceptions` attribute.
    Parameters:
      `exceptions` - the checked exceptions that may be thrown from this method
    Returns:
      an `Exceptions` attribute