Interface CodeModel
- All Superinterfaces:
AttributedElement
,ClassFileElement
,CompoundElement<CodeElement>
,Iterable<CodeElement>
,MethodElement
- All Known Subinterfaces:
CodeAttribute
Code
attribute). ACode
attribute is viewed as acomposition ofCodeElement
s, which is the only way to accessInstruction
s; the order of elements of a code model is significant. ACodeModel
is obtained fromMethodModel.code()
, or in the traversal of the member elements of a method.
MethodBuilder.withCode(java.util.function.Consumer<? super java.lang.classfile.CodeBuilder>)
is the main way to build code models.MethodBuilder.transformCode(java.lang.classfile.CodeModel, java.lang.classfile.CodeTransform)
andCodeBuilder.transforming(java.lang.classfile.CodeTransform, java.util.function.Consumer<java.lang.classfile.CodeBuilder>)
allow creating newCode
attributes by selectively processing the original code elements and directing the results to a code builder.
ACode
attribute holds attributes, but they are usually not member elements, but are decomposed toPseudoInstruction
, accessible according toClassFile.DeadLabelsOption
,ClassFile.DebugElementsOption
, andClassFile.LineNumbersOption
.StackMapTableAttribute
can only be accessed viaexplicit attribute reading, as it is considered a derived property from the code body.
- SeeJava Virtual Machine Specification:
- 4.7.3 The
Code
Attribute - Since:
- 24
- See Also:
Method Summary
Modifier and TypeMethodDescriptionReturns the exception table of the method.parent()
Returns the enclosing method, if known.Methods declared in interface java.lang.classfile.AttributedElement
attributes,findAttribute,findAttributes
Methods declared in interface java.lang.classfile.CompoundElement
elementList,elementStream,forEach,iterator,toDebugString
Methods declared in interface java.lang.Iterable
spliterator
Method Details
parent
Optional<MethodModel> parent()Returns the enclosing method, if known.- Returns:
- the enclosing method, if known
exceptionHandlers
List<ExceptionCatch> exceptionHandlers()Returns the exception table of the method. The exception table is also modeled byExceptionCatch
elements in the streaming view.- Returns:
- the exception table of the method