Attribute<CodeAttribute>, AttributedElement, ClassFileElement, CodeModel, CompoundElement<CodeElement>, Iterable<CodeElement>, MethodElementpublic sealed interface CodeAttribute extends Attribute<CodeAttribute>, CodeModel
Code attribute (JVMS 4.7.3), which contains the bytecode of this method. This attribute only appears on methods, and does not permit multiple instances in a method. It has a data dependency on the constant pool.
This attribute was introduced in the Java Platform version 1.0.2, major version 45.
CodeAttribute models properties of a Code attribute read from class files. General class file transformation should process and traverse a CodeModel in the traversal of a MethodModel, to support transformation of Code attributes currently being built.Code Attribute| Modifier and Type | Method | Description |
|---|---|---|
byte[] |
codeArray() |
Returns the bytes (bytecode) of the code array. |
int |
codeLength() |
Returns The length of the code array in bytes. |
int |
labelToBci |
Returns the position of the label in the codeArray. |
int |
maxLocals() |
Returns the maximum size of the local variable table. |
int |
maxStack() |
Returns the maximum size of the operand stack. |
attributeMapper, attributeName
attributes, findAttribute, findAttributes
exceptionHandlers, parent
elementList, elementStream, forEach, iterator, toDebugString
spliterator
int maxLocals()
int maxStack()
int codeLength()
byte[] codeArray()
int labelToBci(Label label)
label in the codeArray. The label represents a cursor pointing at immediately before the returned index into the code array.label - a marker for a position within this CodeAttribute
label in the codeArray
IllegalArgumentException - if the label is not from this attribute
© 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/attribute/CodeAttribute.html