Interface CodeAttribute
- All Superinterfaces:
Attribute<CodeAttribute>, AttributedElement, ClassFileElement, CodeModel, CompoundElement<CodeElement>, Iterable<CodeElement>, MethodElement
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:
CodeAttributemodels properties of aCodeattribute read fromclassfiles. Generalclassfile transformation should process and traverse aCodeModelin the traversal of aMethodModel, to support transformation ofCodeattributes currently being built.- See Java Virtual Machine Specification:
-
4.7.3 The
CodeAttribute - Since:
- 24
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]Returns the bytes (bytecode) of the code array.intReturns The length of the code array in bytes.intlabelToBci(Label label) Returns the position of thelabelin thecodeArray.intReturns the maximum size of the local variable table.intmaxStack()Returns the maximum size of the operand stack.Methods declared in interface Attribute
attributeMapper, attributeNameModifier and TypeMethodDescriptionReturns theAttributeMapperassociated with this attribute.Returns the name of the attribute.Methods declared in interface AttributedElement
attributes, findAttribute, findAttributesModifier and TypeMethodDescriptionReturns the attributes of this structure.findAttribute(AttributeMapper<T> attr) Finds an attribute by name.findAttributes(AttributeMapper<T> attr) Finds attributes by name.Methods declared in interface CodeModel
exceptionHandlers, parentModifier and TypeMethodDescriptionReturns the exception table of the method.parent()Returns the enclosing method, if known.Methods declared in interface CompoundElement
elementList, elementStream, forEach, iterator, toDebugStringModifier and TypeMethodDescriptiondefault List<CodeElement> Returns aListcontaining all member elements in this compound element.default Stream<CodeElement> Returns aStreamcontaining all member elements in this compound element.voidforEach(Consumer<? super CodeElement> consumer) Invokes the provided handler with each member element in this compound element.default Iterator<CodeElement> iterator()Returns anIteratordescribing all member elements in this compound element.default StringReturns a text representation of the compound element and its contents for debugging purposes.Methods declared in interface Iterable
spliteratorModifier and TypeMethodDescriptiondefault Spliterator<CodeElement> Creates aSpliteratorover the elements described by thisIterable.
-
Method Details
-
maxLocals
int maxLocals()Returns the maximum size of the local variable table.- Returns:
- the maximum size of the local variable table
-
maxStack
int maxStack()Returns the maximum size of the operand stack.- Returns:
- the maximum size of the operand stack
-
codeLength
int codeLength()Returns The length of the code array in bytes.- Returns:
- The length of the code array in bytes
-
codeArray
byte[] codeArray()Returns the bytes (bytecode) of the code array.- Returns:
- the bytes (bytecode) of the code array
-
labelToBci
Returns the position of thelabelin thecodeArray. The label represents a cursor pointing at immediately before the returned index into thecodearray.- Parameters:
label- a marker for a position within thisCodeAttribute- Returns:
- the position of the
labelin thecodeArray - Throws:
IllegalArgumentException- if thelabelis not from this attribute
-