Interface CodeBuilder.CatchBuilder
- Enclosing interface:
- CodeBuilder
- Since:
- 24
- See Also:
- 
Method SummaryModifier and TypeMethodDescriptioncatching(ClassDesc exceptionType, Consumer<CodeBuilder.BlockCodeBuilder> catchHandler) Adds a catch block that catches an exception of the given type.voidcatchingAll(Consumer<CodeBuilder.BlockCodeBuilder> catchAllHandler) Adds a "catch" block that catches all exceptions.catchingMulti(List<ClassDesc> exceptionTypes, Consumer<CodeBuilder.BlockCodeBuilder> catchHandler) Adds a catch block that catches exceptions of the given types.
- 
Method Details- 
catchingCodeBuilder.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 thetryHandlerblock inCodeBuilder.trying(java.util.function.Consumer<java.lang.classfile.CodeBuilder.BlockCodeBuilder>, java.util.function.Consumer<java.lang.classfile.CodeBuilder.CatchBuilder>).If the type of exception is nullthen the catch block catches all exceptions.- Parameters:
- exceptionType- the type of exception to catch, may be- null
- catchHandler- handler that receives a- CodeBuilder.BlockCodeBuilderto 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- exceptionTyperepresents a primitive type
- See Also:
 
- 
catchingMultiCodeBuilder.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 thetryHandlerblock inCodeBuilder.trying(java.util.function.Consumer<java.lang.classfile.CodeBuilder.BlockCodeBuilder>, java.util.function.Consumer<java.lang.classfile.CodeBuilder.CatchBuilder>).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.BlockCodeBuilderto 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:
 
- 
catchingAllAdds a "catch" block that catches all exceptions.The CodeBuilder.BlockCodeBuilder.breakLabel()for the catch block corresponds to the break label of thetryHandlerblock inCodeBuilder.trying(java.util.function.Consumer<java.lang.classfile.CodeBuilder.BlockCodeBuilder>, java.util.function.Consumer<java.lang.classfile.CodeBuilder.CatchBuilder>).The caught exception will be on top of the operand stack when the catch block is entered. - Parameters:
- catchAllHandler- handler that receives a- CodeBuilder.BlockCodeBuilderto generate the body of the catch block
- Throws:
- IllegalArgumentException- if an existing catch block catches all exceptions
- See Also:
 
 
-