Program: 187066
Project: 187066
Buggy source:
public Method compile(ControlFlowGraph graph,MethodGen method) throws GraphException {
  if (!graph.getFeatures().hasFeature(Features.FEATURE_VAR_ALLOC)) {
    throw new GraphException("String_Node_Str");
  }
  if (graph.getExceptionTable().getExceptionHandlers().size() > 0) {
    throw new GraphException("String_Node_Str");
  }
  InstructionList il=new InstructionList();
  method.setInstructionList(il);
  List targetList=buildTargetList(graph,il);
  BcelStmtFactory factory=new BcelStmtFactory(classInfo.getAppStruct(),classInfo.getConstantPoolInfo());
  for (Iterator it=graph.getBlocks().iterator(); it.hasNext(); ) {
    BasicBlock block=(BasicBlock)it.next();
    InstructionHandle ih=((InstructionHandle)targetList.get(block.getBlockIndex()));
    try {
      appendCode(factory,block,il,ih,targetList);
    }
 catch (    TypeException e) {
      throw new GraphException("String_Node_Str",e);
    }
  }
  method.removeNOPs();
  method.setMaxLocals();
  method.setMaxStack();
  method.stripAttributes(true);
  Method newMethod=method.getMethod();
  newMethod.setModifiers(method.getModifiers());
  il.dispose();
  return newMethod;
}

Fixed version (ground truth):
public Method compile(ControlFlowGraph graph,MethodGen method) throws GraphException {
  if (!graph.getFeatures().hasFeature(Features.FEATURE_VAR_ALLOC)) {
    throw new GraphException("String_Node_Str");
  }
  InstructionList il=new InstructionList();
  method.setInstructionList(il);
  List targetList=buildTargetList(graph,il);
  BcelStmtFactory factory=new BcelStmtFactory(classInfo.getAppStruct(),classInfo.getConstantPoolInfo());
  for (Iterator it=graph.getBlocks().iterator(); it.hasNext(); ) {
    BasicBlock block=(BasicBlock)it.next();
    InstructionHandle ih=((InstructionHandle)targetList.get(block.getBlockIndex()));
    try {
      appendCode(factory,block,il,ih,targetList);
    }
 catch (    TypeException e) {
      throw new GraphException("String_Node_Str",e);
    }
  }
  ExceptionTable exceptionTable=graph.getExceptionTable();
  List exceptionHandlers=exceptionTable.getExceptionHandlers();
  for (Iterator it=exceptionHandlers.iterator(); it.hasNext(); ) {
    BasicBlock.ExceptionHandler eh=(BasicBlock.ExceptionHandler)it.next();
    for (Iterator k=eh.getHandledBlocks().iterator(); k.hasNext(); ) {
      BasicBlock bb=(BasicBlock)k.next();
      int srcIndex=bb.getBlockIndex();
      InstructionHandle srcStart=(InstructionHandle)bbStarts.get(srcIndex);
      InstructionHandle srcEnd=(InstructionHandle)bbEnds.get(srcIndex);
      int dstIndex=eh.getExceptionBlock().getBlockIndex();
      InstructionHandle dstStart=(InstructionHandle)bbStarts.get(dstIndex);
      ObjectType type;
      if (eh.getExceptionClass() == null) {
        type=null;
      }
 else {
        type=new ObjectType(eh.getExceptionClass().getClassName());
      }
      method.addExceptionHandler(srcStart,srcEnd,dstStart,type);
    }
  }
  CodeExceptionGen[] cg=method.getExceptionHandlers();
  for (int i=0; i < cg.length - 1; i++) {
    if (cg[i].getEndPC().getNext() == cg[i + 1].getStartPC() && cg[i].getHandlerPC() == cg[i + 1].getHandlerPC() && cg[i].getCatchType() == cg[i + 1].getCatchType()) {
      InstructionHandle srcStart=cg[i].getStartPC();
      InstructionHandle srcEnd=cg[i + 1].getEndPC();
      InstructionHandle dstStart=cg[i].getHandlerPC();
      ObjectType type=cg[i].getCatchType();
      method.removeExceptionHandler(cg[i]);
      method.removeExceptionHandler(cg[i + 1]);
      method.addExceptionHandler(srcStart,srcEnd,dstStart,type);
    }
  }
  method.removeNOPs();
  method.setMaxLocals();
  method.setMaxStack();
  method.stripAttributes(true);
  Method newMethod=method.getMethod();
  newMethod.setModifiers(method.getModifiers());
  il.dispose();
  return newMethod;
}