Program: 40547
Project: 40547
Buggy source:
/** 
 * TODO: clean this up.
 */
private IR makeIR(IMethod method,IMethod target,ReceiverInstanceContext context){
  SpecializedMethod m=new SpecializedMethod(method,method.getDeclaringClass(),method.isStatic(),false);
  Map<Integer,ConstantValue> constants=HashMapFactory.make();
  int nextLocal=method.getNumberOfParameters() + 1;
  int nargs=target.getNumberOfParameters();
  int args[]=new int[nargs];
  int i=0;
  int pc=0;
  int parametersVn=-1;
  if (method.getReference().equals(CTOR_NEW_INSTANCE)) {
    TypeReference allocatedType=target.getDeclaringClass().getReference();
    m.addInstruction(allocatedType,new SSANewInstruction(args[i++]=nextLocal++,NewSiteReference.make(pc++,allocatedType)),true);
    parametersVn=2;
  }
 else {
    args[i++]=2;
    parametersVn=3;
  }
  for (int j=1; j < nargs; j++) {
    int indexConst=nextLocal++;
    m.addInstruction(null,new SSAArrayLoadInstruction(args[i++]=nextLocal++,parametersVn,indexConst,TypeReference.JavaLangObject),false);
    constants.put(new Integer(indexConst),new ConstantValue(j - 1));
    pc++;
  }
  int exceptions=nextLocal++;
  int result=-1;
  if (method.getReference().equals(CTOR_NEW_INSTANCE)) {
    m.addInstruction(null,new SSAInvokeInstruction(args,exceptions,CallSiteReference.make(pc++,target.getReference(),IInvokeInstruction.Dispatch.SPECIAL)),false);
    m.addInstruction(null,new SSAReturnInstruction(args[0],false),false);
  }
 else {
    Dispatch d=target.isStatic() ? Dispatch.STATIC : Dispatch.VIRTUAL;
    if (target.getReturnType().equals(TypeReference.Void)) {
      m.addInstruction(null,new SSAInvokeInstruction(args,exceptions,CallSiteReference.make(pc++,target.getReference(),d)),false);
    }
 else {
      result=nextLocal++;
      m.addInstruction(null,new SSAInvokeInstruction(result,args,exceptions,CallSiteReference.make(pc++,target.getReference(),d)),false);
      m.addInstruction(null,new SSAReturnInstruction(result,false),false);
    }
  }
  SSAInstruction[] instrs=new SSAInstruction[m.allInstructions.size()];
  m.allInstructions.<SSAInstruction>toArray(instrs);
  return new SyntheticIR(method,context,new InducedCFG(instrs,method,context),instrs,SSAOptions.defaultOptions(),constants);
}

Fixed version (ground truth):
/** 
 * TODO: clean this up. Create the IR for the synthetic method (e.g. Method.invoke)
 * @param method is something like Method.invoke or Construction.newInstance
 * @param target is the method being called reflectively
 */
private IR makeIR(IMethod method,IMethod target,ReceiverInstanceContext context){
  SpecializedMethod m=new SpecializedMethod(method,method.getDeclaringClass(),method.isStatic(),false);
  Map<Integer,ConstantValue> constants=HashMapFactory.make();
  int nextLocal=method.getNumberOfParameters() + 1;
  int nargs=target.getNumberOfParameters();
  int args[]=new int[nargs];
  int i=0;
  int pc=0;
  int parametersVn=-1;
  if (method.getReference().equals(CTOR_NEW_INSTANCE)) {
    TypeReference allocatedType=target.getDeclaringClass().getReference();
    m.addInstruction(allocatedType,new SSANewInstruction(args[i++]=nextLocal++,NewSiteReference.make(pc++,allocatedType)),true);
    parametersVn=2;
  }
 else {
    parametersVn=3;
    if (target.isStatic()) {
    }
 else {
      args[i++]=2;
    }
  }
  for (int j=i; j < nargs; j++) {
    int indexConst=nextLocal++;
    m.addInstruction(null,new SSAArrayLoadInstruction(args[i++]=nextLocal++,parametersVn,indexConst,TypeReference.JavaLangObject),false);
    constants.put(new Integer(indexConst),new ConstantValue(j - 1));
    pc++;
  }
  int exceptions=nextLocal++;
  int result=-1;
  if (method.getReference().equals(CTOR_NEW_INSTANCE)) {
    m.addInstruction(null,new SSAInvokeInstruction(args,exceptions,CallSiteReference.make(pc++,target.getReference(),IInvokeInstruction.Dispatch.SPECIAL)),false);
    m.addInstruction(null,new SSAReturnInstruction(args[0],false),false);
  }
 else {
    Dispatch d=target.isStatic() ? Dispatch.STATIC : Dispatch.VIRTUAL;
    if (target.getReturnType().equals(TypeReference.Void)) {
      m.addInstruction(null,new SSAInvokeInstruction(args,exceptions,CallSiteReference.make(pc++,target.getReference(),d)),false);
    }
 else {
      result=nextLocal++;
      m.addInstruction(null,new SSAInvokeInstruction(result,args,exceptions,CallSiteReference.make(pc++,target.getReference(),d)),false);
      m.addInstruction(null,new SSAReturnInstruction(result,false),false);
    }
  }
  SSAInstruction[] instrs=new SSAInstruction[m.allInstructions.size()];
  m.allInstructions.<SSAInstruction>toArray(instrs);
  return new SyntheticIR(method,context,new InducedCFG(instrs,method,context),instrs,SSAOptions.defaultOptions(),constants);
}