APIdia Launch Partner
Top Description Methods
java.lang.classfile.instruction

public sealed Interface ExceptionCatch

extends PseudoInstruction
permits ExceptionCatchImpl
Known Direct Implementers
jdk.internal.classfile.impl.AbstractPseudoInstruction.ExceptionCatchImpl
Imports
java.lang.classfile.CodeBuilder, .CodeElement, .CodeModel, .Label, .PseudoInstruction, java.lang.classfile.attribute.CodeAttribute, java.lang.classfile.constantpool.ClassEntry, java.util.Optional, jdk.internal.classfile.impl.AbstractPseudoInstruction

A pseudo-instruction modeling an entry in the exception_table array of a Code attribute. Catch (JVMS 3.12) and finally (JVMS 3.14) blocks in Java source code compile to exception table entries. The order of exception table entries is significant: when an exception is thrown in a method, execution branches to the first matching exception handler if such a handler exists (JVMS 2.10). Delivered as a CodeElement when traversing the contents of a CodeModel.

An exception table entry is composite:

ExceptionCatch( Label handler, Label tryStart, Label tryEnd, Optional<ClassEntry> catchType )
ExceptionCatch(
    Label handler,
    Label tryStart,
    Label tryEnd,
    Optional<ClassEntry> catchType
)
Since
24
Java Virtual Machine Specification
4.7.3 The Code Attribute
See Also
CodeBuilder::exceptionCatch, CodeAttribute#exceptionHandlers()

Method Summary

Modifier and TypeMethod and Description
public Optional<ClassEntry>

Returns:

the type of the exception to catch, or empty if this handler catches everything
catchType
()

Returns the type of the exception to catch, or empty if this handler catches everything.

public Label

Returns:

the handler for the exception
handler
()

Returns the handler for the exception.

public static ExceptionCatch

Returns:

an exception table pseudo-instruction
of
(Label
the handler for the exception
handler
,
Label
the beginning of the instruction range for the guarded instructions
tryStart
,
Label
the end of the instruction range for the guarded instructions
tryEnd
,
Optional<ClassEntry>
the type of exception to catch, or empty if this handler is unconditional
catchTypeEntry
)

Returns an exception table pseudo-instruction.

public static ExceptionCatch

Returns:

an exception table pseudo-instruction to catch everything
of
(Label
the handler for the exception
handler
,
Label
the beginning of the instruction range for the guarded instructions
tryStart
,
Label
the end of the instruction range for the guarded instructions
tryEnd
)

Returns an exception table pseudo-instruction to catch everything.

public Label

Returns:

the end of the instruction range for the guarded instructions
tryEnd
()

Returns the end of the instruction range for the guarded instructions.

public Label

Returns:

the beginning of the instruction range for the guarded instructions
tryStart
()

Returns the beginning of the instruction range for the guarded instructions.

Method Detail

catchTypeback to summary
public Optional<ClassEntry> catchType()

Returns the type of the exception to catch, or empty if this handler catches everything.

Returns:Optional<ClassEntry>

the type of the exception to catch, or empty if this handler catches everything

handlerback to summary
public Label handler()

Returns the handler for the exception.

Returns:Label

the handler for the exception

ofback to summary
public static ExceptionCatch of(Label handler, Label tryStart, Label tryEnd, Optional<ClassEntry> catchTypeEntry)

Returns an exception table pseudo-instruction.

Parameters
handler:Label

the handler for the exception

tryStart:Label

the beginning of the instruction range for the guarded instructions

tryEnd:Label

the end of the instruction range for the guarded instructions

catchTypeEntry:Optional<ClassEntry>

the type of exception to catch, or empty if this handler is unconditional

Returns:ExceptionCatch

an exception table pseudo-instruction

ofback to summary
public static ExceptionCatch of(Label handler, Label tryStart, Label tryEnd)

Returns an exception table pseudo-instruction to catch everything.

Parameters
handler:Label

the handler for the exception

tryStart:Label

the beginning of the instruction range for the guarded instructions

tryEnd:Label

the end of the instruction range for the guarded instructions

Returns:ExceptionCatch

an exception table pseudo-instruction to catch everything

tryEndback to summary
public Label tryEnd()

Returns the end of the instruction range for the guarded instructions.

Returns:Label

the end of the instruction range for the guarded instructions

tryStartback to summary
public Label tryStart()

Returns the beginning of the instruction range for the guarded instructions.

Returns:Label

the beginning of the instruction range for the guarded instructions