Class ExceptionTable

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class ExceptionTable
    extends java.lang.Object
    implements java.lang.Cloneable
    exception_table[] of Code_attribute.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private ConstPool constPool  
      private java.util.ArrayList entries  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int start, int end, int handler, int type)
      Appends a new entry at the end of the table.
      void add​(int index, int start, int end, int handler, int type)
      Adds a new entry at the specified position in the table.
      void add​(int index, ExceptionTable table, int offset)
      Copies the given exception table at the specified position in the table.
      int catchType​(int nth)
      Returns catchType of the n-th entry.
      java.lang.Object clone()
      Creates and returns a copy of this object.
      ExceptionTable copy​(ConstPool newCp, java.util.Map classnames)
      Makes a copy of this exception_table[].
      int endPc​(int nth)
      Returns endPc of the n-th entry.
      int handlerPc​(int nth)
      Returns handlerPc of the n-th entry.
      void remove​(int index)
      Removes the entry at the specified position in the table.
      void setCatchType​(int nth, int value)
      Sets catchType of the n-th entry.
      void setEndPc​(int nth, int value)
      Sets endPc of the n-th entry.
      void setHandlerPc​(int nth, int value)
      Sets handlerPc of the n-th entry.
      void setStartPc​(int nth, int value)
      Sets startPc of the n-th entry.
      (package private) void shiftPc​(int where, int gapLength, boolean exclusive)  
      private static int shiftPc​(int pc, int where, int gapLength, boolean exclusive)  
      int size()
      Returns exception_table_length, which is the number of entries in the exception_table[].
      int startPc​(int nth)
      Returns startPc of the n-th entry.
      (package private) void write​(java.io.DataOutputStream out)  
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • entries

        private java.util.ArrayList entries
    • Constructor Detail

      • ExceptionTable

        public ExceptionTable​(ConstPool cp)
        Constructs an exception_table[].
        Parameters:
        cp - constant pool table.
      • ExceptionTable

        ExceptionTable​(ConstPool cp,
                       java.io.DataInputStream in)
                throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Creates and returns a copy of this object. The constant pool object is shared between this object and the cloned object.
        Overrides:
        clone in class java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
      • size

        public int size()
        Returns exception_table_length, which is the number of entries in the exception_table[].
      • startPc

        public int startPc​(int nth)
        Returns startPc of the n-th entry.
        Parameters:
        nth - the n-th (>= 0).
      • setStartPc

        public void setStartPc​(int nth,
                               int value)
        Sets startPc of the n-th entry.
        Parameters:
        nth - the n-th (>= 0).
        value - new value.
      • endPc

        public int endPc​(int nth)
        Returns endPc of the n-th entry.
        Parameters:
        nth - the n-th (>= 0).
      • setEndPc

        public void setEndPc​(int nth,
                             int value)
        Sets endPc of the n-th entry.
        Parameters:
        nth - the n-th (>= 0).
        value - new value.
      • handlerPc

        public int handlerPc​(int nth)
        Returns handlerPc of the n-th entry.
        Parameters:
        nth - the n-th (>= 0).
      • setHandlerPc

        public void setHandlerPc​(int nth,
                                 int value)
        Sets handlerPc of the n-th entry.
        Parameters:
        nth - the n-th (>= 0).
        value - new value.
      • catchType

        public int catchType​(int nth)
        Returns catchType of the n-th entry.
        Parameters:
        nth - the n-th (>= 0).
        Returns:
        an index into the constant_pool table, or zero if this exception handler is for all exceptions.
      • setCatchType

        public void setCatchType​(int nth,
                                 int value)
        Sets catchType of the n-th entry.
        Parameters:
        nth - the n-th (>= 0).
        value - new value.
      • add

        public void add​(int index,
                        ExceptionTable table,
                        int offset)
        Copies the given exception table at the specified position in the table.
        Parameters:
        index - index (>= 0) at which the entry is to be inserted.
        offset - the offset added to the code position.
      • add

        public void add​(int index,
                        int start,
                        int end,
                        int handler,
                        int type)
        Adds a new entry at the specified position in the table.
        Parameters:
        index - index (>= 0) at which the entry is to be inserted.
        start - startPc
        end - endPc
        handler - handlerPc
        type - catchType
      • add

        public void add​(int start,
                        int end,
                        int handler,
                        int type)
        Appends a new entry at the end of the table.
        Parameters:
        start - startPc
        end - endPc
        handler - handlerPc
        type - catchType
      • remove

        public void remove​(int index)
        Removes the entry at the specified position in the table.
        Parameters:
        index - the index of the removed entry.
      • copy

        public ExceptionTable copy​(ConstPool newCp,
                                   java.util.Map classnames)
        Makes a copy of this exception_table[]. Class names are replaced according to the given Map object.
        Parameters:
        newCp - the constant pool table used by the new copy.
        classnames - pairs of replaced and substituted class names.
      • shiftPc

        void shiftPc​(int where,
                     int gapLength,
                     boolean exclusive)
      • shiftPc

        private static int shiftPc​(int pc,
                                   int where,
                                   int gapLength,
                                   boolean exclusive)
      • write

        void write​(java.io.DataOutputStream out)
            throws java.io.IOException
        Throws:
        java.io.IOException