Class CodeException

  • All Implemented Interfaces:
    java.lang.Cloneable, Node, Constants

    public final class CodeException
    extends java.lang.Object
    implements java.lang.Cloneable, Node, Constants
    This class represents an entry in the exception table of the Code attribute and is used only there. It contains a range in which a particular exception handler is active.
    See Also:
    Code
    • Constructor Detail

      • CodeException

        public CodeException​(CodeException c)
        Initialize from another object.
      • CodeException

        public CodeException​(int startPc,
                             int endPc,
                             int handlerPc,
                             int catchType)
        Parameters:
        startPc - Range in the code the exception handler is active, startPc is inclusive while
        endPc - is exclusive
        handlerPc - Starting address of exception handler, i.e., an offset from start of code.
        catchType - If zero the handler catches any exception, otherwise it points to the exception class which is to be caught.
    • Method Detail

      • accept

        public void accept​(Visitor v)
        Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
        Specified by:
        accept in interface Node
        Parameters:
        v - Visitor object
      • dump

        public void dump​(java.io.DataOutputStream file)
                  throws java.io.IOException
        Dump code exception to file stream in binary format.
        Parameters:
        file - Output file stream
        Throws:
        java.io.IOException
      • getCatchType

        public int getCatchType()
        Returns:
        0, if the handler catches any exception, otherwise it points to the exception class which is to be caught.
      • getEndPC

        public int getEndPC()
        Returns:
        Exclusive end index of the region where the handler is active.
      • getHandlerPC

        public int getHandlerPC()
        Returns:
        Starting address of exception handler, relative to the code.
      • getStartPC

        public int getStartPC()
        Returns:
        Inclusive start index of the region where the handler is active.
      • setCatchType

        public void setCatchType​(int catchType)
        Parameters:
        catchType - the type of exception that is caught
      • setEndPC

        public void setEndPC​(int endPc)
        Parameters:
        endPc - end of handled block
      • setHandlerPC

        public void setHandlerPC​(int handlerPc)
        Parameters:
        handlerPc - where the actual code is
      • setStartPC

        public void setStartPC​(int startPc)
        Parameters:
        startPc - start of handled block
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        String representation.
      • toString

        public java.lang.String toString​(ConstantPool cp,
                                         boolean verbose)
        Returns:
        String representation.
      • toString

        public java.lang.String toString​(ConstantPool cp)
      • copy

        public CodeException copy()
        Returns:
        deep copy of this object