Class Code


  • public class Code
    extends java.lang.Object
    • Field Detail

      • maxStack

        private final int maxStack
      • maxLocals

        private final int maxLocals
      • codeData

        private final byte[] codeData
    • Constructor Detail

      • Code

        Code​(java.io.DataInputStream input,
             @Nonnull
             ConstantPool constantPool)
        throws java.io.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:
        java.io.IOException - if an I/O error occurs
    • Method Detail

      • readExceptionTable

        private static TryCatchFinally[] readExceptionTable​(java.io.DataInputStream input,
                                                            @Nonnull
                                                            ConstantPool constantPool)
                                                     throws java.io.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:
        java.io.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 java.io.IOException
        Get the line number table. is null if the code was optimized.
        Returns:
        the table or null
        Throws:
        java.io.IOException - if any I/O error occur
      • getLocalVariableTable

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

        public int getFirstLineNr()
                           throws java.io.IOException
        Throws:
        java.io.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.