Class CodeException

java.lang.Object
org.apache.bcel.classfile.CodeException
All Implemented Interfaces:
Cloneable, Node, Constants

public final class CodeException extends Object implements 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.
 Code_attribute {
   u2 attribute_name_index;
   u4 attribute_length;
   u2 max_stack;
   u2 max_locals;
   u4 code_length;
   u1 code[code_length];
   u2 exception_table_length;
   {
     u2 start_pc;
     u2 end_pc;
     u2 handler_pc;
     u2 catch_type;
   } exception_table[exception_table_length];
   u2 attributes_count;
   attribute_info attributes[attributes_count];
 }
 
See Also:
  • Constructor Details

    • CodeException

      Constructs a new instance from another instance.
      Parameters:
      c - Source for copying.
    • CodeException

      public CodeException(int startPc, int endPc, int handlerPc, int catchType)
      Constructs a new instance.
      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 Details

    • accept

      public void accept(Visitor v)
      Called by objects that are traversing the nodes of the tree implicitly 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
    • copy

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

      public void dump(DataOutputStream file) throws IOException
      Dumps code exception to file stream in binary format.
      Parameters:
      file - Output file stream
      Throws:
      IOException - if an I/O error occurs.
    • 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 String toString()
      Overrides:
      toString in class Object
      Returns:
      String representation.
    • toString

    • toString

      public String toString(ConstantPool cp, boolean verbose)
      Parameters:
      cp - constant pool source.
      verbose - Output more if true.
      Returns:
      String representation.