jaxp/src/com/sun/org/apache/bcel/internal/generic/CodeExceptionGen.java
changeset 17538 d8d911c4e5d4
parent 12457 c348e06f0e82
equal deleted inserted replaced
17537:50528ec0ea37 17538:d8d911c4e5d4
    56  * individuals on behalf of the Apache Software Foundation.  For more
    56  * individuals on behalf of the Apache Software Foundation.  For more
    57  * information on the Apache Software Foundation, please see
    57  * information on the Apache Software Foundation, please see
    58  * <http://www.apache.org/>.
    58  * <http://www.apache.org/>.
    59  */
    59  */
    60 
    60 
    61 import com.sun.org.apache.bcel.internal.Constants;
       
    62 import com.sun.org.apache.bcel.internal.classfile.*;
    61 import com.sun.org.apache.bcel.internal.classfile.*;
    63 
    62 
    64 /**
    63 /**
    65  * This class represents an exception handler, i.e., specifies the  region where
    64  * This class represents an exception handler, i.e., specifies the  region where
    66  * a handler is active and an instruction where the actual handling is done.
    65  * a handler is active and an instruction where the actual handling is done.
   116   }
   115   }
   117 
   116 
   118   /* Set start of handler
   117   /* Set start of handler
   119    * @param start_pc Start of handled region (inclusive)
   118    * @param start_pc Start of handled region (inclusive)
   120    */
   119    */
   121   public void setStartPC(InstructionHandle start_pc) {
   120   public final void setStartPC(InstructionHandle start_pc) {
   122     BranchInstruction.notifyTarget(this.start_pc, start_pc, this);
   121     BranchInstruction.notifyTargetChanging(this.start_pc, this);
   123     this.start_pc = start_pc;
   122     this.start_pc = start_pc;
       
   123     BranchInstruction.notifyTargetChanged(this.start_pc, this);
   124   }
   124   }
   125 
   125 
   126   /* Set end of handler
   126   /* Set end of handler
   127    * @param end_pc End of handled region (inclusive)
   127    * @param end_pc End of handled region (inclusive)
   128    */
   128    */
   129   public void setEndPC(InstructionHandle end_pc) {
   129   public final void setEndPC(InstructionHandle end_pc) {
   130     BranchInstruction.notifyTarget(this.end_pc, end_pc, this);
   130     BranchInstruction.notifyTargetChanging(this.end_pc, this);
   131     this.end_pc = end_pc;
   131     this.end_pc = end_pc;
       
   132     BranchInstruction.notifyTargetChanged(this.end_pc, this);
   132   }
   133   }
   133 
   134 
   134   /* Set handler code
   135   /* Set handler code
   135    * @param handler_pc Start of handler
   136    * @param handler_pc Start of handler
   136    */
   137    */
   137   public void setHandlerPC(InstructionHandle handler_pc) {
   138   public final void setHandlerPC(InstructionHandle handler_pc) {
   138     BranchInstruction.notifyTarget(this.handler_pc, handler_pc, this);
   139     BranchInstruction.notifyTargetChanging(this.handler_pc, this);
   139     this.handler_pc = handler_pc;
   140     this.handler_pc = handler_pc;
       
   141     BranchInstruction.notifyTargetChanged(this.handler_pc, this);
   140   }
   142   }
   141 
   143 
   142   /**
   144   /**
   143    * @param old_ih old target, either start or end
   145    * @param old_ih old target, either start or end
   144    * @param new_ih new target
   146    * @param new_ih new target
   145    */
   147    */
       
   148   @Override
   146   public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
   149   public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih) {
   147     boolean targeted = false;
   150     boolean targeted = false;
   148 
   151 
   149     if(start_pc == old_ih) {
   152     if(start_pc == old_ih) {
   150       targeted = true;
   153       targeted = true;
   167   }
   170   }
   168 
   171 
   169   /**
   172   /**
   170    * @return true, if ih is target of this handler
   173    * @return true, if ih is target of this handler
   171    */
   174    */
       
   175   @Override
   172   public boolean containsTarget(InstructionHandle ih) {
   176   public boolean containsTarget(InstructionHandle ih) {
   173     return (start_pc == ih) || (end_pc == ih) || (handler_pc == ih);
   177     return (start_pc == ih) || (end_pc == ih) || (handler_pc == ih);
   174   }
   178   }
   175 
   179 
   176   /** Sets the type of the Exception to catch. Set 'null' for ANY. */
   180   /** Sets the type of the Exception to catch. Set 'null' for ANY. */
   188 
   192 
   189   /** @return start of handler
   193   /** @return start of handler
   190    */
   194    */
   191   public InstructionHandle getHandlerPC()                             { return handler_pc; }
   195   public InstructionHandle getHandlerPC()                             { return handler_pc; }
   192 
   196 
       
   197   @Override
   193   public String toString() {
   198   public String toString() {
   194     return "CodeExceptionGen(" + start_pc + ", " + end_pc + ", " + handler_pc + ")";
   199     return "CodeExceptionGen(" + start_pc + ", " + end_pc + ", " + handler_pc + ")";
   195   }
   200   }
   196 
   201 
       
   202   @Override
   197   public Object clone() {
   203   public Object clone() {
   198     try {
   204     try {
   199       return super.clone();
   205       return super.clone();
   200     } catch(CloneNotSupportedException e) {
   206     } catch(CloneNotSupportedException e) {
   201       System.err.println(e);
   207       System.err.println(e);