Program: 187058
Project: 187058
Buggy source:
/** 
 * Do the actual inlining.
 * @param stmt the invoke statement. This must be a handle of an {@link InvokeStmt}.
 * @param srcGraph the graph of the invoked method which will be inlined.
 * @param offset the variable offset to use for new variables of the inlined method.
 * @param unsafeInline true if checkcode should be created if enabled.
 * @return an inlineresult containing informations about the new code.
 * @throws GraphException if anything goes wrong.
 */
public InlineResult doInline(StmtHandle stmt,ControlFlowGraph srcGraph,int offset,boolean unsafeInline) throws GraphException {
  BasicBlock block=stmt.getBlock();
  InvokeStmt invokeStmt=(InvokeStmt)stmt.getStatement();
  ControlFlowGraph graph=block.getGraph();
  int newBlocks=0;
  Collection checkBlocks=new ArrayList();
  BasicBlock next=stmt.splitBefore();
  next.getCodeBlock().deleteStatement(0);
  int firstBlock=block.getBlockIndex() + 1;
  BlockCloner cloner=new BlockCloner(srcGraph,new OffsetVariableMapper(offset));
  newBlocks+=cloner.copyBlocks(graph,firstBlock);
  checkBlocks.addAll(linkFirstBlock(block,graph.getBlock(firstBlock),invokeStmt,offset));
  linkBlocks(graph,firstBlock,next,invokeStmt);
  if (insertCheckCode && unsafeInline) {
    checkBlocks.addAll(createCheckCode(block,next,invokeStmt));
  }
  int diff=getDeltaBytecode(invokeStmt,unsafeInline);
  int maxLocals=offset + srcGraph.getVariableTable().size();
  int[] checkBlockIds=new int[checkBlocks.size()];
  newBlocks+=checkBlocks.size();
  int i=0;
  for (Iterator it=checkBlocks.iterator(); it.hasNext(); ) {
    BasicBlock checkBlock=(BasicBlock)it.next();
    checkBlockIds[i]=checkBlock.getBlockIndex();
    i++;
  }
  Arrays.sort(checkBlockIds);
  return new InlineResult(firstBlock,newBlocks,checkBlockIds,diff,maxLocals);
}

Fixed version (ground truth):
/** 
 * Do the actual inlining.
 * @param stmt the invoke statement. This must be a handle of an {@link InvokeStmt}.
 * @param srcGraph the graph of the invoked method which will be inlined.
 * @param offset the variable offset to use for new variables of the inlined method.
 * @param unsafeInline true if checkcode should be created if enabled.
 * @return an inlineresult containing informations about the new code.
 * @throws GraphException if anything goes wrong.
 */
public InlineResult doInline(StmtHandle stmt,ControlFlowGraph srcGraph,int offset,boolean unsafeInline) throws GraphException {
  BasicBlock block=stmt.getBlock();
  InvokeStmt invokeStmt=(InvokeStmt)stmt.getStatement();
  ControlFlowGraph graph=block.getGraph();
  int newBlocks=0;
  Collection checkBlocks=new ArrayList();
  BasicBlock next=stmt.splitBefore();
  next.getCodeBlock().deleteStatement(0);
  int firstBlock=block.getBlockIndex() + 1;
  BlockCloner cloner=new BlockCloner(srcGraph,new OffsetVariableMapper(offset));
  newBlocks+=cloner.copyBlocks(graph,firstBlock);
  checkBlocks.addAll(linkFirstBlock(block,graph.getBlock(firstBlock),invokeStmt,offset));
  linkBlocks(graph,firstBlock,next,invokeStmt,offset);
  if (insertCheckCode && unsafeInline) {
    checkBlocks.addAll(createCheckCode(block,next,invokeStmt));
  }
  int diff=getDeltaBytecode(invokeStmt,unsafeInline);
  int maxLocals=offset + srcGraph.getVariableTable().size();
  int[] checkBlockIds=new int[checkBlocks.size()];
  newBlocks+=checkBlocks.size();
  int i=0;
  for (Iterator it=checkBlocks.iterator(); it.hasNext(); ) {
    BasicBlock checkBlock=(BasicBlock)it.next();
    checkBlockIds[i]=checkBlock.getBlockIndex();
    i++;
  }
  Arrays.sort(checkBlockIds);
  return new InlineResult(firstBlock,newBlocks,checkBlockIds,diff,maxLocals);
}