Program: 186635
Project: 186635
Buggy source:
private void optimizeMethods(AnalysisManager analyses,CandidateSelector selector,Set<MethodInfo> methods){
  Map<MethodInfo,MethodData> methodData=new HashMap<MethodInfo,MethodData>(methods.size());
  selector.clear();
  for (  MethodInfo method : methods) {
    if (method.isNative())     continue;
    method.getCode().compile();
    StacksizeAnalysis stacksize=analyses.getStacksizeAnalysis(method);
    int locals=method.getCode().getMaxLocals();
    for (    CodeOptimizer optimizer : optimizers) {
      Collection<Candidate> found;
      found=optimizer.findCandidates(method,analyses,stacksize,locals);
      selector.addCandidates(method,found);
      countCandidates+=found.size();
    }
    methodData.put(method,new MethodData(locals));
  }
  selector.sortCandidates();
  Set<MethodInfo> optimizedMethods=new HashSet<MethodInfo>();
  Set<MethodInfo> candidateChanges=new HashSet<MethodInfo>();
  Collection<Candidate> candidates=selector.selectNextCandidates();
  while (candidates != null) {
    optimizedMethods.clear();
    candidateChanges.clear();
    analyses.clearChangeSets();
    for (    Candidate c : candidates) {
      MethodInfo method=c.getMethod();
      StacksizeAnalysis stacksize=analyses.getStacksizeAnalysis(method);
      logger.info("String_Node_Str" + c.toString());
      if (!c.optimize(analyses,stacksize))       continue;
      countOptimized++;
      method.getCode().compile();
      stacksize.analyze(c.getStart(),c.getEnd());
      int locals=c.getMaxLocalsInRegion();
      List<Candidate> newCandidates=new ArrayList<Candidate>();
      for (      CodeOptimizer optimizer : optimizers) {
        Collection<Candidate> found;
        found=optimizer.findCandidates(method,analyses,stacksize,locals,c.getStart(),c.getEnd());
        newCandidates.addAll(found);
      }
      selector.onSuccessfulOptimize(c,newCandidates);
      countCandidates+=newCandidates.size();
      optimizedMethods.add(method);
    }
    candidateChanges.addAll(optimizedMethods);
    if (methods.size() > 1) {
      for (      MethodInfo method : optimizedMethods) {
        candidateChanges.addAll(appInfo.getCallGraph().getDirectInvokers(method));
      }
      candidateChanges.addAll(analyses.getMethodCacheAnalysis().getClassificationChangeSet());
    }
    Set<MethodInfo> changeSet=selector.updateChangeSet(optimizedMethods,candidateChanges);
    for (    MethodInfo method : candidateChanges) {
      if (!methodData.containsKey(method))       continue;
      selector.updateCandidates(method,analyses.getStacksizeAnalysis(method));
    }
    if (methods.size() == 1) {
      selector.sortCandidates(methods);
    }
 else {
      logger.info("String_Node_Str" + changeSet.size());
      selector.sortCandidates(changeSet);
    }
    candidates=selector.selectNextCandidates();
  }
}

Fixed version (ground truth):
private void optimizeMethods(AnalysisManager analyses,ExecCountProvider ecp,CandidateSelector selector,Set<MethodInfo> methods){
  Map<MethodInfo,MethodData> methodData=new HashMap<MethodInfo,MethodData>(methods.size());
  selector.clear();
  for (  MethodInfo method : methods) {
    if (method.isNative())     continue;
    method.getCode().compile();
    StacksizeAnalysis stacksize=analyses.getStacksizeAnalysis(method);
    int locals=method.getCode().getMaxLocals();
    for (    CodeOptimizer optimizer : optimizers) {
      Collection<Candidate> found;
      found=optimizer.findCandidates(method,analyses,stacksize,locals);
      selector.addCandidates(method,found);
      countCandidates+=found.size();
    }
    methodData.put(method,new MethodData(locals));
  }
  selector.sortCandidates();
  Set<MethodInfo> optimizedMethods=new HashSet<MethodInfo>();
  Set<MethodInfo> candidateChanges=new HashSet<MethodInfo>();
  Collection<Candidate> candidates=selector.selectNextCandidates();
  while (candidates != null) {
    optimizedMethods.clear();
    candidateChanges.clear();
    analyses.clearChangeSets();
    for (    Candidate c : candidates) {
      MethodInfo method=c.getMethod();
      StacksizeAnalysis stacksize=analyses.getStacksizeAnalysis(method);
      logger.info("String_Node_Str" + c.toString());
      if (!c.optimize(analyses,stacksize))       continue;
      countOptimized++;
      method.getCode().compile();
      stacksize.analyze(c.getStart(),c.getEnd());
      int locals=c.getMaxLocalsInRegion();
      List<Candidate> newCandidates=new ArrayList<Candidate>();
      for (      CodeOptimizer optimizer : optimizers) {
        Collection<Candidate> found;
        found=optimizer.findCandidates(method,analyses,stacksize,locals,c.getStart(),c.getEnd());
        newCandidates.addAll(found);
      }
      selector.onSuccessfulOptimize(c,newCandidates);
      countCandidates+=newCandidates.size();
      optimizedMethods.add(method);
    }
    candidateChanges.addAll(optimizedMethods);
    if (methods.size() > 1) {
      for (      MethodInfo method : optimizedMethods) {
        candidateChanges.addAll(appInfo.getCallGraph().getDirectInvokers(method));
      }
      candidateChanges.addAll(analyses.getMethodCacheAnalysis().getClassificationChangeSet());
    }
    Set<MethodInfo> changeSet=selector.updateChangeSet(optimizedMethods,candidateChanges);
    for (    MethodInfo method : candidateChanges) {
      if (!methodData.containsKey(method))       continue;
      selector.updateCandidates(method,analyses.getStacksizeAnalysis(method));
    }
    if (methods.size() == 1) {
      selector.sortCandidates(methods);
    }
 else {
      logger.info("String_Node_Str" + changeSet.size());
      selector.sortCandidates(changeSet);
    }
    candidates=selector.selectNextCandidates();
  }
}