Interface CodeAttribute

All Superinterfaces:
Attribute<CodeAttribute>, AttributedElement, ClassFileElement, CodeModel, CompoundElement<CodeElement>, Iterable<CodeElement>, MethodElement, WritableElement<CodeAttribute>
All Known Implementing Classes:
BoundAttribute.BoundCodeAttribute, CodeImpl

public sealed interface CodeAttribute extends Attribute<CodeAttribute>, CodeModel permits BoundAttribute.BoundCodeAttribute
Models the Code attribute , appears on non-native, non-abstract methods and contains the bytecode of the method body. Delivered as a MethodElement when traversing the elements of a MethodModel.

The attribute does not permit multiple instances in a given location. Subsequent occurrence of the attribute takes precedence during the attributed element build or transformation.

Since:
22
  • Method Details

    • 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

      int labelToBci(Label label)
      Returns the position of the Label in the codeArray or -1 if the Label does not point to the codeArray.
      Parameters:
      label - a marker for a position within this CodeAttribute
      Returns:
      the position of the Label in the codeArray or -1 if the Label does not point to the codeArray