Program: 37090
Project: 37090
Buggy source:
/** 
 * Instantiate from existing method.
 * @param m method
 * @param class_name class name containing this method
 * @param cp constant pool
 */
public MethodGen(Method m,String class_name,ConstantPoolGen cp){
  this(m.getAccessFlags(),Type.getReturnType(m.getSignature()),Type.getArgumentTypes(m.getSignature()),null,m.getName(),class_name,((m.getAccessFlags() & (Constants.ACC_ABSTRACT | Constants.ACC_NATIVE)) == 0) ? new InstructionList(m.getCode().getCode()) : null,cp);
  Attribute[] attributes=m.getAttributes();
  for (int i=0; i < attributes.length; i++) {
    Attribute a=attributes[i];
    if (a instanceof Code) {
      Code c=(Code)a;
      setMaxStack(c.getMaxStack());
      setMaxLocals(c.getMaxLocals());
      CodeException[] ces=c.getExceptionTable();
      if (ces != null) {
        for (int j=0; j < ces.length; j++) {
          CodeException ce=ces[j];
          int type=ce.getCatchType();
          ObjectType c_type=null;
          if (type > 0) {
            String cen=m.getConstantPool().getConstantString(type,Constants.CONSTANT_Class);
            c_type=new ObjectType(cen);
          }
          int end_pc=ce.getEndPC();
          int length=m.getCode().getCode().length;
          InstructionHandle end;
          if (length == end_pc) {
            end=il.getEnd();
          }
 else {
            end=il.findHandle(end_pc);
            end=end.getPrev();
          }
          addExceptionHandler(il.findHandle(ce.getStartPC()),end,il.findHandle(ce.getHandlerPC()),c_type);
        }
      }
      Attribute[] c_attributes=c.getAttributes();
      for (int j=0; j < c_attributes.length; j++) {
        a=c_attributes[j];
        if (a instanceof LineNumberTable) {
          LineNumber[] ln=((LineNumberTable)a).getLineNumberTable();
          for (int k=0; k < ln.length; k++) {
            LineNumber l=ln[k];
            addLineNumber(il.findHandle(l.getStartPC()),l.getLineNumber());
          }
        }
 else         if (a instanceof LocalVariableTable) {
          LocalVariable[] lv=((LocalVariableTable)a).getLocalVariableTable();
          removeLocalVariables();
          for (int k=0; k < lv.length; k++) {
            LocalVariable l=lv[k];
            InstructionHandle start=il.findHandle(l.getStartPC());
            InstructionHandle end=il.findHandle(l.getStartPC() + l.getLength());
            if (null == start) {
              start=il.getStart();
            }
            if (null == end) {
              end=il.getEnd();
            }
            addLocalVariable(l.getName(),Type.getType(l.getSignature()),l.getIndex(),start,end);
          }
        }
 else         addCodeAttribute(a);
      }
    }
 else     if (a instanceof ExceptionTable) {
      String[] names=((ExceptionTable)a).getExceptionNames();
      for (int j=0; j < names.length; j++)       addException(names[j]);
    }
 else     addAttribute(a);
  }
}

Fixed version (ground truth):
/** 
 * Instantiate from existing method.
 * @param m method
 * @param class_name class name containing this method
 * @param cp constant pool
 */
public MethodGen(Method m,String class_name,ConstantPoolGen cp){
  this(m.getAccessFlags(),Type.getReturnType(m.getSignature()),Type.getArgumentTypes(m.getSignature()),null,m.getName(),class_name,((m.getAccessFlags() & (Constants.ACC_ABSTRACT | Constants.ACC_NATIVE)) == 0) ? new InstructionList(m.getCode().getCode()) : null,cp);
  Attribute[] attributes=m.getAttributes();
  for (int i=0; i < attributes.length; i++) {
    Attribute a=attributes[i];
    if (a instanceof Code) {
      Code c=(Code)a;
      setMaxStack(c.getMaxStack());
      setMaxLocals(c.getMaxLocals());
      CodeException[] ces=c.getExceptionTable();
      if (ces != null) {
        for (int j=0; j < ces.length; j++) {
          CodeException ce=ces[j];
          int type=ce.getCatchType();
          ObjectType c_type=null;
          if (type > 0) {
            String cen=m.getConstantPool().getConstantString(type,Constants.CONSTANT_Class);
            c_type=new ObjectType(cen);
          }
          int end_pc=ce.getEndPC();
          int length=m.getCode().getCode().length;
          InstructionHandle end;
          if (length == end_pc) {
            end=il.getEnd();
          }
 else {
            end=il.findHandle(end_pc);
            end=end.getPrev();
          }
          addExceptionHandler(il.findHandle(ce.getStartPC()),end,il.findHandle(ce.getHandlerPC()),c_type);
        }
      }
      Attribute[] c_attributes=c.getAttributes();
      for (int j=0; j < c_attributes.length; j++) {
        a=c_attributes[j];
        if (a instanceof LineNumberTable) {
          LineNumber[] ln=((LineNumberTable)a).getLineNumberTable();
          for (int k=0; k < ln.length; k++) {
            LineNumber l=ln[k];
            addLineNumber(il.findHandle(l.getStartPC()),l.getLineNumber());
          }
        }
 else         if (a instanceof LocalVariableTable) {
          LocalVariable[] lv=((LocalVariableTable)a).getLocalVariableTable();
          removeLocalVariables();
          for (int k=0; k < lv.length; k++) {
            LocalVariable l=lv[k];
            InstructionHandle start=il.findHandle(l.getStartPC());
            InstructionHandle end=il.findHandle(l.getStartPC() + l.getLength());
            if (null == start) {
              start=il.getStart();
            }
            if (null == end) {
              end=il.getEnd();
            }
            addLocalVariable(l.getName(),Type.getType(l.getSignature()),l.getIndex(),start,end);
          }
        }
 else         if (a instanceof LocalVariableTypeTable) {
          LocalVariable[] lv=((LocalVariableTypeTable)a).getLocalVariableTypeTable();
          removeLocalVariables();
          for (int k=0; k < lv.length; k++) {
            LocalVariable l=lv[k];
            InstructionHandle start=il.findHandle(l.getStartPC());
            InstructionHandle end=il.findHandle(l.getStartPC() + l.getLength());
            if (null == start) {
              start=il.getStart();
            }
            if (null == end) {
              end=il.getEnd();
            }
            addLocalVariable(l.getName(),Type.getType(l.getSignature()),l.getIndex(),start,end);
          }
        }
 else         addCodeAttribute(a);
      }
    }
 else     if (a instanceof ExceptionTable) {
      String[] names=((ExceptionTable)a).getExceptionNames();
      for (int j=0; j < names.length; j++)       addException(names[j]);
    }
 else     addAttribute(a);
  }
}