Class Code

java.lang.Object
de.inetsoftware.classparser.Code

public class Code extends Object
  • Field Details

    • NO_TRY_CATCHES

      private static final TryCatchFinally[] NO_TRY_CATCHES
    • constantPool

      private final ConstantPool constantPool
    • maxStack

      private final int maxStack
    • maxLocals

      private final int maxLocals
    • codeData

      private final byte[] codeData
    • exceptionTable

      private final TryCatchFinally[] exceptionTable
    • attributes

      private final Attributes attributes
    • lineNumberTable

      private LineNumberTable lineNumberTable
    • localVariableTable

      private LocalVariableTable localVariableTable
  • Constructor Details

    • Code

      Code(DataInputStream input, @Nonnull ConstantPool constantPool) throws IOException
      The code of a method attribute. http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.3 http://docs.oracle.com/javase/specs/jvms/se5.0/html/ClassFile.doc.html#1546
      Parameters:
      input - the stream of the code attribute
      constantPool - the ConstantPool of the class
      Throws:
      IOException - if an I/O error occurs
  • Method Details

    • readExceptionTable

      private static TryCatchFinally[] readExceptionTable(DataInputStream input, @Nonnull ConstantPool constantPool) throws IOException
      Read the exception table and correct some problems.
      Parameters:
      input - the stream of the code attribute
      constantPool - the ConstantPool of the class
      Returns:
      the exception table
      Throws:
      IOException - if an I/O error occurs
    • getConstantPool

      @Nonnull public ConstantPool getConstantPool()
      Get the constant pool of this code.
      Returns:
      the ConstantPool of the class
    • getExceptionTable

      @Nonnull public TryCatchFinally[] getExceptionTable()
      Get exception table of this code block.
      Returns:
      the table, can be empty
    • getLineNumberTable

      @Nullable public LineNumberTable getLineNumberTable() throws IOException
      Get the line number table. is null if the code was optimized.
      Returns:
      the table or null
      Throws:
      IOException - if any I/O error occur
    • getLocalVariableTable

      @Nullable public LocalVariableTable getLocalVariableTable() throws IOException
      Get the local variable table of this method.
      Returns:
      the variables
      Throws:
      IOException - if any I/O error occur
    • getFirstLineNr

      public int getFirstLineNr() throws IOException
      Throws:
      IOException
    • getByteCode

      public CodeInputStream getByteCode()
      Get the stream of Java Byte code instruction of this method.
      Returns:
      the stream
    • getCodeSize

      public int getCodeSize()
      Get the last position of the code.
      Returns:
      the size.