Class Code

java.lang.Object
org.fife.rsta.ac.java.classreader.attributes.AttributeInfo
org.fife.rsta.ac.java.classreader.attributes.Code

public class Code extends AttributeInfo
A variable-length attribute used in the attributes table of MethodInfo structures. A Code attribute contains the JVM instructions and auxiliary information for a single method, instance initialization method, or class or interface initialization method. Every JVM implementation must recognize Code attributes. If the method is either native or abstract, its MethodInfo structure must not have a Code attribute. Otherwise, its MethodInfo structure must have exactly one Code attribute.
Version:
1.0
  • Field Details

    • mi

      private MethodInfo mi
      The parent method.
    • maxStack

      private int maxStack
      The maximum depth of the operand stack of this method at any point during its execution.
    • maxLocals

      private int maxLocals
      The number of local variables in the local variable array allocated upon invocation of this method, including the local variables used to pass parameters to the method on invocation.

      The greatest local variable index for a value of type long or double is maxLocals-2. The greatest local variable index for a value of any other type is maxLocals-1.

    • codeLength

      private int codeLength
      The size of the method's code, in bytes.
    • exceptionTable

      private ExceptionTableEntry[] exceptionTable
      The exception handlers in the code array. The order of the handlers in this table is significant.
    • paramNames

      private String[] paramNames
      The names of parameters to the parent method, if debugging was enabled during compilation.
      See Also:
    • attributes

      private List<AttributeInfo> attributes
      Attributes of this Code attribute.
    • LINE_NUMBER_TABLE

      private static final String LINE_NUMBER_TABLE
      See Also:
    • LOCAL_VARIABLE_TABLE

      private static final String LOCAL_VARIABLE_TABLE
      See Also:
    • LOCAL_VARIABLE_TYPE_TABLE

      private static final String LOCAL_VARIABLE_TYPE_TABLE
      See Also:
    • STACK_MAP_TABLE

      private static final String STACK_MAP_TABLE
      See Also:
  • Constructor Details

    • Code

      public Code(MethodInfo mi)
      Constructor.
      Parameters:
      mi - Information on the parent method.
  • Method Details

    • getCodeLength

      public int getCodeLength()
      Returns the length of the code array, in bytes.
      Returns:
      The length of the code array.
    • getMaxLocals

      public int getMaxLocals()
      Returns the number of local variables in the local variable array allocated upon invocation of this method, including the local variables used to pass parameters to the method on invocation.

      The greatest local variable index for a value of type long or double is maxLocals-2. The greatest local variable index for a value of any other type is maxLocals-1.

      Returns:
      the maximum size of the local variable array.
    • getMaxStack

      public int getMaxStack()
      Returns the maximum depth of the operand stack of this method at any point during its execution.
      Returns:
      The maximum value of the operand stack.
    • getMethodInfo

      public MethodInfo getMethodInfo()
      Returns the method containing this code.
      Returns:
      The method containing this code.
    • getParameterName

      public String getParameterName(int index)
      If debugging was enabled during compilation, this method returns the name of the given parameter to this method. Otherwise, null is returned.
      Parameters:
      index - The index of the parameter.
      Returns:
      The name of the parameter, or null.
    • read

      public static Code read(MethodInfo mi, DataInputStream in) throws IOException
      Reads a Code attribute from an input stream.
      Parameters:
      mi - The parent method.
      in - The input stream.
      Returns:
      The Code attribute.
      Throws:
      IOException - If an IO error occurs.
    • readAttribute

      private AttributeInfo readAttribute(DataInputStream in) throws IOException
      Reads an attribute for this Code attribute from an input stream.
      Parameters:
      in - The input stream to read from.
      Returns:
      The attribute read.
      Throws:
      IOException - If an IO error occurs.