APIdia Launch Partner
Top Description Methods
java.lang.classfile.attribute

public sealed Interface CodeAttribute

extends Attribute<CodeAttribute>, CodeModel
permits BoundCodeAttribute
Known Direct Implementers
jdk.internal.classfile.impl.BoundAttribute.BoundCodeAttribute
Imports
java.lang.classfile.*, .AttributeMapper.AttributeStability, jdk.internal.classfile.impl.BoundAttribute

Models the 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.

API Note

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.

Since
24
Java Virtual Machine Specification
4.7.3 The Code Attribute
See Also
Attributes#code(), CodeModel

Method Summary

Modifier and TypeMethod and Description
public byte[]

Returns:

the bytes (bytecode) of the code array
codeArray
()

Returns the bytes (bytecode) of the code array.

public int

Returns:

The length of the code array in bytes
codeLength
()

Returns The length of the code array in bytes.

public int

Returns:

the position of the label in the codeArray
labelToBci
(Label
a marker for a position within this CodeAttribute
label
)

Returns the position of the label in the codeArray.

public int

Returns:

the maximum size of the local variable table
maxLocals
()

Returns the maximum size of the local variable table.

public int

Returns:

the maximum size of the operand stack
maxStack
()

Returns the maximum size of the operand stack.

Inherited from java.lang.classfile.Attribute:
attributeMapperattributeName
Inherited from java.lang.classfile.CodeModel:
exceptionHandlersparent

Method Detail

codeArrayback to summary
public byte[] codeArray()

Returns the bytes (bytecode) of the code array.

Returns:byte[]

the bytes (bytecode) of the code array

codeLengthback to summary
public int codeLength()

Returns The length of the code array in bytes.

Returns:int

The length of the code array in bytes

labelToBciback to summary
public int labelToBci(Label label)

Returns the position of the label in the codeArray. The label represents a cursor pointing at immediately before the returned index into the code array.

Parameters
label:Label

a marker for a position within this CodeAttribute

Returns:int

the position of the label in the codeArray

Exceptions
IllegalArgumentException:
if the label is not from this attribute
maxLocalsback to summary
public int maxLocals()

Returns the maximum size of the local variable table.

Returns:int

the maximum size of the local variable table

maxStackback to summary
public int maxStack()

Returns the maximum size of the operand stack.

Returns:int

the maximum size of the operand stack