There are 1 code examples for org.apache.bcel.generic.CodeExceptionGen.

The API names are highlighted below. You can use suckoo button to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.

Project Name: randoop Package: randoop.instrument

Source Code: Instrument.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Replace instruction ih in list il with the instructions in new_il.  If
 * new_il is null, do nothing
 */
protected static void replace_instructions(InstructionList il,InstructionHandle ih,InstructionList new_il){
  if ((new_il == null) || new_il.isEmpty())   return;
  if (new_il.getLength() == 1) {
    ih.setInstruction(new_il.getEnd().getInstruction());
    return;
  }
  InstructionHandle new_end=new_il.getEnd();
  InstructionHandle new_start=il.insert(ih,new_il);
  il.redirectBranches(ih,new_start);
  if (ih.hasTargeters()) {
    for (    InstructionTargeter it : ih.getTargeters()) {
      if (it instanceof LineNumberGen) {
        it.updateTarget(ih,new_start);
      }
 else       if (it instanceof LocalVariableGen) {
        it.updateTarget(ih,new_end);
      }
 else       if (it instanceof CodeExceptionGen) {
        CodeExceptionGen exc=(CodeExceptionGen)it;
        if (exc.getStartPC() == ih)         exc.updateTarget(ih,new_start);
 else         if (exc.getEndPC() == ih)         exc.updateTarget(ih,new_end);
 else         if (exc.getHandlerPC() == ih)         exc.setHandlerPC(new_start);
 else         System.out.printf("Malformed CodeException: %s%n",exc);
      }
 else {
        System.out.printf("unexpected target %s%n",it);
      }
    }
  }
  try {
    il.delete(ih);
  }
 catch (  Exception e) {
    throw new Error("Can't delete instruction",e);
  }
}