Program: 187071
Project: 187071
Buggy source:
private Method replace(Method method){
  MethodGen mg=new MethodGen(method,clazz.getClassName(),cpoolgen);
  InstructionList il=mg.getInstructionList();
  InstructionFinder f=new InstructionFinder(il);
  String methodId=method.getName() + method.getSignature();
  MethodInfo mi=cli.getMethodInfo(methodId);
  String invokeStr="String_Node_Str";
  for (Iterator i=f.search(invokeStr); i.hasNext(); ) {
    InstructionHandle[] match=(InstructionHandle[])i.next();
    InstructionHandle first=match[0];
    InvokeInstruction ii=(InvokeInstruction)first.getInstruction();
    if (ii.getClassName(cpoolgen).equals(JOPizer.nativeClass)) {
      short opid=(short)JopInstr.getNative(ii.getMethodName(cpoolgen));
      if (opid == -1) {
        System.err.println(method.getName() + "String_Node_Str" + ii.getMethodName(cpoolgen)+ "String_Node_Str");
        first.setInstruction(new NOP());
      }
 else {
        first.setInstruction(new NativeInstruction(opid,(short)1));
        jz.outTxt.println("String_Node_Str" + first.getPosition());
        if (JOPizer.dumpMgci) {
          il.setPositions();
          int pc=first.getPosition();
          GCRTMethodInfo.removePC(pc + 2,mi);
          GCRTMethodInfo.removePC(pc + 1,mi);
        }
      }
    }
    if (ii instanceof INVOKESPECIAL) {
      if (!ii.getMethodName(cpoolgen).equals("String_Node_Str")) {
        if (!cli.clazz.getClassName().equals(ii.getClassName(cpoolgen))) {
          first.setInstruction(new JOPSYS_INVOKESUPER((short)ii.getIndex()));
        }
      }
    }
  }
  f=new InstructionFinder(il);
  String cpInstr="String_Node_Str";
  for (Iterator it=f.search(cpInstr); it.hasNext(); ) {
    InstructionHandle[] match=(InstructionHandle[])it.next();
    InstructionHandle ih=match[0];
    CPInstruction cpii=(CPInstruction)ih.getInstruction();
    int index=cpii.getIndex();
    FieldInstruction fi=null;
    Type ft=null;
    if (cpii instanceof FieldInstruction) {
      fi=(FieldInstruction)ih.getInstruction();
      ft=fi.getFieldType(cpoolgen);
    }
    Integer idx=new Integer(index);
    int pos=cli.cpoolUsed.indexOf(idx);
    int new_index=pos + 1;
    if (pos == -1) {
      System.out.println("String_Node_Str" + index + "String_Node_Str"+ cpoolgen.getConstant(index)+ "String_Node_Str");
      System.out.println("String_Node_Str" + cli.cpoolUsed);
      System.out.println("String_Node_Str" + cpoolgen);
      System.exit(-1);
    }
 else {
      if (cpii instanceof GETFIELD || cpii instanceof PUTFIELD) {
        int offset=getFieldOffset(cp,index);
        new_index=offset;
      }
      cpii.setIndex(new_index);
    }
    if (cpii instanceof FieldInstruction) {
      boolean isRef=ft instanceof ReferenceType;
      boolean isLong=ft == BasicType.LONG || ft == BasicType.DOUBLE;
      if (fi instanceof GETSTATIC) {
        if (isRef) {
          ih.setInstruction(new GETSTATIC_REF((short)new_index));
        }
 else         if (isLong) {
          ih.setInstruction(new GETSTATIC_LONG((short)new_index));
        }
      }
 else       if (fi instanceof PUTSTATIC) {
        if (isRef) {
          ih.setInstruction(new PUTSTATIC_REF((short)new_index));
        }
 else         if (isLong) {
          ih.setInstruction(new PUTSTATIC_LONG((short)new_index));
        }
      }
 else       if (fi instanceof GETFIELD) {
        if (isRef) {
          ih.setInstruction(new GETFIELD_REF((short)new_index));
        }
 else         if (isLong) {
          ih.setInstruction(new GETFIELD_LONG((short)new_index));
        }
      }
 else       if (fi instanceof PUTFIELD) {
        if (isRef) {
          ih.setInstruction(new PUTFIELD_REF((short)new_index));
        }
 else         if (isLong) {
          ih.setInstruction(new PUTFIELD_LONG((short)new_index));
        }
      }
    }
  }
  Method m=mg.getMethod();
  il.dispose();
  return m;
}

Fixed version (ground truth):
private Method replace(Method method){
  MethodGen mg=new MethodGen(method,clazz.getClassName(),cpoolgen);
  InstructionList il=mg.getInstructionList();
  InstructionFinder f=new InstructionFinder(il);
  String methodId=method.getName() + method.getSignature();
  MethodInfo mi=cli.getMethodInfo(methodId);
  String invokeStr="String_Node_Str";
  for (Iterator i=f.search(invokeStr); i.hasNext(); ) {
    InstructionHandle[] match=(InstructionHandle[])i.next();
    InstructionHandle first=match[0];
    InvokeInstruction ii=(InvokeInstruction)first.getInstruction();
    if (ii.getClassName(cpoolgen).equals(JOPizer.nativeClass)) {
      short opid=(short)JopInstr.getNative(ii.getMethodName(cpoolgen));
      if (opid == -1) {
        System.err.println(method.getName() + "String_Node_Str" + ii.getMethodName(cpoolgen)+ "String_Node_Str");
        first.setInstruction(new NOP());
      }
 else {
        first.setInstruction(new NativeInstruction(opid,(short)1));
        jz.outTxt.println("String_Node_Str" + first.getPosition());
        if (JOPizer.dumpMgci) {
          il.setPositions();
          int pc=first.getPosition();
          GCRTMethodInfo.removePC(pc + 2,mi);
          GCRTMethodInfo.removePC(pc + 1,mi);
        }
      }
    }
    if (ii instanceof INVOKESPECIAL) {
      if (!ii.getMethodName(cpoolgen).equals("String_Node_Str")) {
        if (!cli.clazz.getClassName().equals(ii.getClassName(cpoolgen))) {
          Integer idx=new Integer(ii.getIndex());
          int new_index=cli.cpoolUsed.indexOf(idx) + 1;
          first.setInstruction(new JOPSYS_INVOKESUPER((short)new_index));
        }
      }
    }
  }
  f=new InstructionFinder(il);
  String cpInstr="String_Node_Str";
  for (Iterator it=f.search(cpInstr); it.hasNext(); ) {
    InstructionHandle[] match=(InstructionHandle[])it.next();
    InstructionHandle ih=match[0];
    CPInstruction cpii=(CPInstruction)ih.getInstruction();
    int index=cpii.getIndex();
    FieldInstruction fi=null;
    Type ft=null;
    if (cpii instanceof FieldInstruction) {
      fi=(FieldInstruction)ih.getInstruction();
      ft=fi.getFieldType(cpoolgen);
    }
    Integer idx=new Integer(index);
    int pos=cli.cpoolUsed.indexOf(idx);
    int new_index=pos + 1;
    if (pos == -1) {
      System.out.println("String_Node_Str" + index + "String_Node_Str"+ cpoolgen.getConstant(index)+ "String_Node_Str");
      System.out.println("String_Node_Str" + cli.cpoolUsed);
      System.out.println("String_Node_Str" + cpoolgen);
      System.exit(-1);
    }
 else {
      if (cpii instanceof GETFIELD || cpii instanceof PUTFIELD) {
        int offset=getFieldOffset(cp,index);
        new_index=offset;
      }
      cpii.setIndex(new_index);
    }
    if (cpii instanceof FieldInstruction) {
      boolean isRef=ft instanceof ReferenceType;
      boolean isLong=ft == BasicType.LONG || ft == BasicType.DOUBLE;
      if (fi instanceof GETSTATIC) {
        if (isRef) {
          ih.setInstruction(new GETSTATIC_REF((short)new_index));
        }
 else         if (isLong) {
          ih.setInstruction(new GETSTATIC_LONG((short)new_index));
        }
      }
 else       if (fi instanceof PUTSTATIC) {
        if (isRef) {
          ih.setInstruction(new PUTSTATIC_REF((short)new_index));
        }
 else         if (isLong) {
          ih.setInstruction(new PUTSTATIC_LONG((short)new_index));
        }
      }
 else       if (fi instanceof GETFIELD) {
        if (isRef) {
          ih.setInstruction(new GETFIELD_REF((short)new_index));
        }
 else         if (isLong) {
          ih.setInstruction(new GETFIELD_LONG((short)new_index));
        }
      }
 else       if (fi instanceof PUTFIELD) {
        if (isRef) {
          ih.setInstruction(new PUTFIELD_REF((short)new_index));
        }
 else         if (isLong) {
          ih.setInstruction(new PUTFIELD_LONG((short)new_index));
        }
      }
    }
  }
  Method m=mg.getMethod();
  il.dispose();
  return m;
}