Spec-Zone.ru › OpenJDK 25

Interface CodeBuilder.CatchBuilder

Enclosing interface:
CodeBuilder
public static sealed interface CodeBuilder.CatchBuilder
A builder to add catch blocks.
Since:
24
See Also:
  • CodeBuilder.trying(Consumer, Consumer)
  • ExceptionCatch

Method Summary

Modifier and Type Method Description
CodeBuilder.CatchBuilder catching(ClassDesc exceptionType, Consumer<CodeBuilder.BlockCodeBuilder> catchHandler)
Adds a catch block that catches an exception of the given type.
void catchingAll(Consumer<CodeBuilder.BlockCodeBuilder> catchAllHandler)
Adds a "catch" block that catches all exceptions.
CodeBuilder.CatchBuilder catchingMulti(List<ClassDesc> exceptionTypes, Consumer<CodeBuilder.BlockCodeBuilder> catchHandler)
Adds a catch block that catches exceptions of the given types.

Method Details

catching

CodeBuilder.CatchBuilder catching(ClassDesc exceptionType, Consumer<CodeBuilder.BlockCodeBuilder> catchHandler)
Adds a catch block that catches an exception of the given type.

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.

Parameters:
exceptionType - the type of exception to catch, may be null
catchHandler - handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of the catch block
Returns:
this builder
Throws:
IllegalArgumentException - if an existing catch block catches an exception of the given type or exceptionType represents a primitive type
See Also:
  • catchingMulti(List, Consumer)
  • catchingAll(Consumer)

catchingMulti

CodeBuilder.CatchBuilder catchingMulti(List<ClassDesc> exceptionTypes, Consumer<CodeBuilder.BlockCodeBuilder> catchHandler)
Adds a catch block that catches exceptions of the given types.

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.

Parameters:
exceptionTypes - the types of exception to catch
catchHandler - handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of the catch block
Returns:
this builder
Throws:
IllegalArgumentException - if an existing catch block catches one or more exceptions of the given types
See Also:
  • catching(ClassDesc, Consumer)
  • catchingAll(Consumer)

catchingAll

void catchingAll(Consumer<CodeBuilder.BlockCodeBuilder> catchAllHandler)
Adds a "catch" block that catches all exceptions.

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.

Parameters:
catchAllHandler - handler that receives a CodeBuilder.BlockCodeBuilder to generate the body of the catch block
Throws:
IllegalArgumentException - if an existing catch block catches all exceptions
See Also:
  • catching(ClassDesc, Consumer)
  • catchingMulti(List, Consumer)

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2025, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

© 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

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API