Program: 9758
Project: 9758
Buggy source:
/** 
 * fill the newly created method gen with our body,  inspired by InstructionList.copy()
 */
public void packBody(MethodGen gen){
  HashMap map=new HashMap();
  InstructionList fresh=gen.getInstructionList();
  for (InstructionHandle ih=getBody().getStart(); ih != null; ih=ih.getNext()) {
    if (Range.isRangeHandle(ih)) {
      continue;
    }
    Instruction i=ih.getInstruction();
    Instruction c=i.copy();
    if (c instanceof BranchInstruction)     map.put(ih,fresh.append((BranchInstruction)c));
 else     map.put(ih,fresh.append(c));
  }
  InstructionHandle ih=getBody().getStart();
  InstructionHandle jh=fresh.getStart();
  LinkedList exnList=new LinkedList();
  Map localVariableStarts=new HashMap();
  Map localVariableEnds=new HashMap();
  int currLine=-1;
  while (ih != null) {
    if (map.get(ih) == null) {
      Range r=Range.getRange(ih);
      if (r instanceof ExceptionRange) {
        ExceptionRange er=(ExceptionRange)r;
        if (er.getStart() == ih) {
          insertHandler(er,exnList);
        }
      }
 else {
      }
      ih=ih.getNext();
    }
 else {
      Instruction i=ih.getInstruction();
      Instruction j=jh.getInstruction();
      if (i instanceof BranchInstruction) {
        BranchInstruction bi=(BranchInstruction)i;
        BranchInstruction bj=(BranchInstruction)j;
        InstructionHandle itarget=bi.getTarget();
        bj.setTarget(remap(itarget,map));
        if (bi instanceof Select) {
          InstructionHandle[] itargets=((Select)bi).getTargets();
          InstructionHandle[] jtargets=((Select)bj).getTargets();
          for (int k=itargets.length - 1; k >= 0; k--) {
            jtargets[k]=remap(itargets[k],map);
            jtargets[k].addTargeter(bj);
          }
        }
      }
      InstructionTargeter[] targeters=ih.getTargeters();
      if (targeters != null) {
        for (int k=targeters.length - 1; k >= 0; k--) {
          InstructionTargeter targeter=targeters[k];
          if (targeter instanceof LineNumberTag) {
            int line=((LineNumberTag)targeter).getLineNumber();
            if (line != currLine) {
              gen.addLineNumber(jh,line);
              currLine=line;
            }
          }
 else           if (targeter instanceof LocalVariableTag) {
            LocalVariableTag lvt=(LocalVariableTag)targeter;
            if (i instanceof LocalVariableInstruction) {
              int index=((LocalVariableInstruction)i).getIndex();
              if (lvt.getSlot() == index) {
                if (localVariableStarts.get(lvt) == null) {
                  localVariableStarts.put(lvt,jh);
                }
                localVariableEnds.put(lvt,jh);
              }
            }
          }
        }
      }
      ih=ih.getNext();
      jh=jh.getNext();
    }
  }
  for (Iterator iter=exnList.iterator(); iter.hasNext(); ) {
    ExceptionRange r=(ExceptionRange)iter.next();
    if (r.isEmpty())     continue;
    gen.addExceptionHandler(remap(r.getRealStart(),map),remap(r.getRealEnd(),map),remap(r.getHandler(),map),(r.getCatchType() == null) ? null : (ObjectType)BcelWorld.makeBcelType(r.getCatchType()));
  }
  gen.removeLocalVariables();
  for (Iterator iter=localVariableStarts.keySet().iterator(); iter.hasNext(); ) {
    LocalVariableTag tag=(LocalVariableTag)iter.next();
    gen.addLocalVariable(tag.getName(),BcelWorld.makeBcelType(tag.getType()),tag.getSlot(),(InstructionHandle)localVariableStarts.get(tag),(InstructionHandle)localVariableEnds.get(tag));
  }
}

Fixed version (ground truth):
/** 
 * fill the newly created method gen with our body,  inspired by InstructionList.copy()
 */
public void packBody(MethodGen gen){
  HashMap map=new HashMap();
  InstructionList fresh=gen.getInstructionList();
  for (InstructionHandle ih=getBody().getStart(); ih != null; ih=ih.getNext()) {
    if (Range.isRangeHandle(ih)) {
      continue;
    }
    Instruction i=ih.getInstruction();
    Instruction c=i.copy();
    if (c instanceof BranchInstruction)     map.put(ih,fresh.append((BranchInstruction)c));
 else     map.put(ih,fresh.append(c));
  }
  InstructionHandle ih=getBody().getStart();
  InstructionHandle jh=fresh.getStart();
  LinkedList exnList=new LinkedList();
  Map localVariableStarts=new HashMap();
  Map localVariableEnds=new HashMap();
  int currLine=-1;
  while (ih != null) {
    if (map.get(ih) == null) {
      Range r=Range.getRange(ih);
      if (r instanceof ExceptionRange) {
        ExceptionRange er=(ExceptionRange)r;
        if (er.getStart() == ih) {
          if (!er.isEmpty()) {
            insertHandler(er,exnList);
          }
        }
      }
 else {
      }
      ih=ih.getNext();
    }
 else {
      Instruction i=ih.getInstruction();
      Instruction j=jh.getInstruction();
      if (i instanceof BranchInstruction) {
        BranchInstruction bi=(BranchInstruction)i;
        BranchInstruction bj=(BranchInstruction)j;
        InstructionHandle itarget=bi.getTarget();
        bj.setTarget(remap(itarget,map));
        if (bi instanceof Select) {
          InstructionHandle[] itargets=((Select)bi).getTargets();
          InstructionHandle[] jtargets=((Select)bj).getTargets();
          for (int k=itargets.length - 1; k >= 0; k--) {
            jtargets[k]=remap(itargets[k],map);
            jtargets[k].addTargeter(bj);
          }
        }
      }
      InstructionTargeter[] targeters=ih.getTargeters();
      if (targeters != null) {
        for (int k=targeters.length - 1; k >= 0; k--) {
          InstructionTargeter targeter=targeters[k];
          if (targeter instanceof LineNumberTag) {
            int line=((LineNumberTag)targeter).getLineNumber();
            if (line != currLine) {
              gen.addLineNumber(jh,line);
              currLine=line;
            }
          }
 else           if (targeter instanceof LocalVariableTag) {
            LocalVariableTag lvt=(LocalVariableTag)targeter;
            if (i instanceof LocalVariableInstruction) {
              int index=((LocalVariableInstruction)i).getIndex();
              if (lvt.getSlot() == index) {
                if (localVariableStarts.get(lvt) == null) {
                  localVariableStarts.put(lvt,jh);
                }
                localVariableEnds.put(lvt,jh);
              }
            }
          }
        }
      }
      ih=ih.getNext();
      jh=jh.getNext();
    }
  }
  for (Iterator iter=exnList.iterator(); iter.hasNext(); ) {
    ExceptionRange r=(ExceptionRange)iter.next();
    if (r.isEmpty())     continue;
    gen.addExceptionHandler(remap(r.getRealStart(),map),remap(r.getRealEnd(),map),remap(r.getHandler(),map),(r.getCatchType() == null) ? null : (ObjectType)BcelWorld.makeBcelType(r.getCatchType()));
  }
  gen.removeLocalVariables();
  for (Iterator iter=localVariableStarts.keySet().iterator(); iter.hasNext(); ) {
    LocalVariableTag tag=(LocalVariableTag)iter.next();
    gen.addLocalVariable(tag.getName(),BcelWorld.makeBcelType(tag.getType()),tag.getSlot(),(InstructionHandle)localVariableStarts.get(tag),(InstructionHandle)localVariableEnds.get(tag));
  }
}