Module java.base
Package java.lang.classfile.instructionPREVIEW

# Interface ExceptionCatch

All Superinterfaces:
  `ClassFileElementPREVIEW`, `CodeElementPREVIEW`, `PseudoInstructionPREVIEW`

public sealed interface ExceptionCatch extends PseudoInstructionPREVIEW
`ExceptionCatch` is a preview API of the Java platform.
Programs can only use `ExceptionCatch` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
A pseudo-instruction modeling an entry in the exception table of a code attribute. Entries in the exception table model catch and finally blocks. Delivered as a `CodeElement`PREVIEW when traversing the contents of a `CodeModel`PREVIEW.

Since:
  22
See Also:
  - `PseudoInstruction`PREVIEW

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Optional<ClassEntryPREVIEW>`
  `catchType()`
  Returns the type of the exception to catch, or empty if this handler is unconditional.
  `LabelPREVIEW`
  `handler()`
  Returns the handler for the exception.
  `static ExceptionCatchPREVIEW`
  `of(LabelPREVIEW handler, LabelPREVIEW tryStart, LabelPREVIEW tryEnd)`
  Returns an exception table pseudo-instruction for an unconditional handler.
  `static ExceptionCatchPREVIEW`
  `of(LabelPREVIEW handler, LabelPREVIEW tryStart, LabelPREVIEW tryEnd, Optional<ClassEntryPREVIEW> catchTypeEntry)`
  Returns an exception table pseudo-instruction.
  `LabelPREVIEW`
  `tryEnd()`
  Returns the end of the instruction range for the guarded instructions.
  `LabelPREVIEW`
  `tryStart()`
  Returns the beginning of the instruction range for the guarded instructions.

- ## Method Details

  - ### handler

    LabelPREVIEW handler()
    Returns the handler for the exception.
    Returns:
      the handler for the exception

  - ### tryStart

    LabelPREVIEW tryStart()
    Returns the beginning of the instruction range for the guarded instructions.
    Returns:
      the beginning of the instruction range for the guarded instructions

  - ### tryEnd

    LabelPREVIEW tryEnd()
    Returns the end of the instruction range for the guarded instructions.
    Returns:
      the end of the instruction range for the guarded instructions

  - ### catchType

    Optional<ClassEntryPREVIEW> catchType()
    Returns the type of the exception to catch, or empty if this handler is unconditional.
    Returns:
      the type of the exception to catch, or empty if this handler is unconditional

  - ### of

    static ExceptionCatchPREVIEW of(LabelPREVIEW handler, LabelPREVIEW tryStart, LabelPREVIEW tryEnd, Optional<ClassEntryPREVIEW> catchTypeEntry)
    Returns an exception table pseudo-instruction.
    Parameters:
      `handler` - the handler for the exception
      `tryStart` - the beginning of the instruction range for the guarded instructions
      `tryEnd` - the end of the instruction range for the guarded instructions
      `catchTypeEntry` - the type of exception to catch, or empty if this handler is unconditional
    Returns:
      an exception table pseudo-instruction

  - ### of

    static ExceptionCatchPREVIEW of(LabelPREVIEW handler, LabelPREVIEW tryStart, LabelPREVIEW tryEnd)
    Returns an exception table pseudo-instruction for an unconditional handler.
    Parameters:
      `handler` - the handler for the exception
      `tryStart` - the beginning of the instruction range for the gaurded instructions
      `tryEnd` - the end of the instruction range for the gaurded instructions
    Returns:
      an exception table pseudo-instruction for an unconditional handler