CodeBuilderpublic static sealed interface CodeBuilder.CatchBuilder
| Modifier and Type | Method | Description |
|---|---|---|
CodeBuilder.CatchBuilder |
catching |
Adds a catch block that catches an exception of the given type. |
void |
catchingAll |
Adds a "catch" block that catches all exceptions. |
CodeBuilder.CatchBuilder |
catchingMulti |
Adds a catch block that catches exceptions of the given types. |
CodeBuilder.CatchBuilder catching(ClassDesc exceptionType, Consumer<CodeBuilder.BlockCodeBuilder> catchHandler)
The caught exception will be on top of the operand stack when the catch block is entered.
The CodeBuilder.BlockCodeBuilder.breakLabel() for the catch block corresponds to the break label of the tryHandler block in CodeBuilder.trying(Consumer, Consumer).
If the type of exception is null then the catch block catches all exceptions.
exceptionType - the type of exception to catch, may be null
catchHandler - handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of the catch blockIllegalArgumentException - if an existing catch block catches an exception of the given type or exceptionType represents a primitive typeCodeBuilder.CatchBuilder catchingMulti(List<ClassDesc> exceptionTypes, Consumer<CodeBuilder.BlockCodeBuilder> catchHandler)
The caught exception will be on top of the operand stack when the catch block is entered.
The CodeBuilder.BlockCodeBuilder.breakLabel() for the catch block corresponds to the break label of the tryHandler block in CodeBuilder.trying(Consumer, Consumer).
If list of exception types is empty then the catch block catches all exceptions.
exceptionTypes - the types of exception to catchcatchHandler - handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of the catch blockIllegalArgumentException - if an existing catch block catches one or more exceptions of the given typesvoid catchingAll(Consumer<CodeBuilder.BlockCodeBuilder> catchAllHandler)
The CodeBuilder.BlockCodeBuilder.breakLabel() for the catch block corresponds to the break label of the tryHandler block in CodeBuilder.trying(Consumer, Consumer).
The caught exception will be on top of the operand stack when the catch block is entered.
catchAllHandler - handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of the catch blockIllegalArgumentException - if an existing catch block catches all exceptions
© 1993, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/classfile/CodeBuilder.CatchBuilder.html