Program: 75074
Project: 75074
Buggy source:
/** 
 * Fix the refactoring when the set of cross-analyzed types changes.
 * @param state The current state of the type analyzer.
 */
public void handle(TypeAnalyzerState state){
  Set crossAnalyzedTypes=state.getCrossAnalyzedTypes();
  Iterator crossAnalysisIter=crossAnalyzedTypes.iterator();
  while (crossAnalysisIter.hasNext()) {
    String nextClassName=(String)crossAnalysisIter.next();
    List list=(List)_checkParentFields.get(nextClassName);
    if (list != null) {
      Iterator nodesIter=list.iterator();
      while (nodesIter.hasNext()) {
        removeNode((ASTNode)nodesIter.next());
        nodesIter.remove();
      }
    }
    list=(List)_checkParentMethods.get(nextClassName);
    if (list != null) {
      Iterator nodesIter=list.iterator();
      while (nodesIter.hasNext()) {
        removeNode((ASTNode)nodesIter.next());
        nodesIter.remove();
      }
    }
    list=(List)_fixParentRestoreMethods.get(nextClassName);
    if (list != null) {
      Iterator nodesIter=list.iterator();
      while (nodesIter.hasNext()) {
        Block body=(Block)nodesIter.next();
        AST ast=body.getAST();
        String methodName=_getRestoreMethodName(false);
        SuperMethodInvocation superRestore=ast.newSuperMethodInvocation();
        superRestore.setName(ast.newSimpleName(methodName));
        superRestore.arguments().add(ast.newSimpleName("String_Node_Str"));
        superRestore.arguments().add(ast.newSimpleName("String_Node_Str"));
        List statements=body.statements();
        statements.remove(statements.size() - 1);
        statements.add(ast.newExpressionStatement(superRestore));
        nodesIter.remove();
      }
    }
    list=(List)_fixSetCheckpoint.get(nextClassName);
    if (list != null) {
      Iterator nodesIter=list.iterator();
      while (nodesIter.hasNext()) {
        Block body=(Block)nodesIter.next();
        AST ast=body.getAST();
        Statement invocation=_createSetCheckpointInvocation(ast);
        List statements=body.statements();
        statements.add(statements.size() - 2,invocation);
        nodesIter.remove();
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Fix the refactoring when the set of cross-analyzed types changes.
 * @param state The current state of the type analyzer.
 */
public void handle(TypeAnalyzerState state){
  Set crossAnalyzedTypes=state.getCrossAnalyzedTypes();
  Iterator crossAnalysisIter=crossAnalyzedTypes.iterator();
  while (crossAnalysisIter.hasNext()) {
    String nextClassName=(String)crossAnalysisIter.next();
    List list=(List)_checkParentFields.get(nextClassName);
    if (list != null) {
      Iterator nodesIter=list.iterator();
      while (nodesIter.hasNext()) {
        removeNode((ASTNode)nodesIter.next());
        nodesIter.remove();
      }
    }
    list=(List)_checkParentMethods.get(nextClassName);
    if (list != null) {
      Iterator nodesIter=list.iterator();
      while (nodesIter.hasNext()) {
        removeNode((ASTNode)nodesIter.next());
        nodesIter.remove();
      }
    }
    list=(List)_fixParentRestoreMethods.get(nextClassName);
    if (list != null) {
      Iterator nodesIter=list.iterator();
      while (nodesIter.hasNext()) {
        Block body=(Block)nodesIter.next();
        AST ast=body.getAST();
        String methodName=_getRestoreMethodName(false);
        SuperMethodInvocation superRestore=ast.newSuperMethodInvocation();
        superRestore.setName(ast.newSimpleName(methodName));
        superRestore.arguments().add(ast.newSimpleName("String_Node_Str"));
        superRestore.arguments().add(ast.newSimpleName("String_Node_Str"));
        List statements=body.statements();
        statements.remove(statements.size() - 1);
        statements.add(ast.newExpressionStatement(superRestore));
        nodesIter.remove();
      }
    }
    list=(List)_fixSetCheckpoint.get(nextClassName);
    if (list != null) {
      Iterator nodesIter=list.iterator();
      while (nodesIter.hasNext()) {
        Block body=(Block)nodesIter.next();
        AST ast=body.getAST();
        Statement invocation=_createSetCheckpointInvocation(ast);
        List statements=body.statements();
        statements.add(statements.size() - 2,invocation);
        nodesIter.remove();
      }
    }
    list=(List)_rehandleDeclaration.get(nextClassName);
    if (list != null) {
      Iterator recordsIter=list.iterator();
      while (recordsIter.hasNext()) {
        RehandleDeclarationRecord record=(RehandleDeclarationRecord)recordsIter.next();
        Iterator extendedIter=record._getExtendedDeclarations().iterator();
        while (extendedIter.hasNext()) {
          ASTNode declaration=(ASTNode)extendedIter.next();
          if (declaration != null)           removeNode(declaration);
        }
        Iterator fixedIter=record._getFixedDeclarations().iterator();
        while (fixedIter.hasNext()) {
          ASTNode declaration=(ASTNode)fixedIter.next();
          if (declaration != null)           record._getBodyDeclarations().add(declaration);
        }
        recordsIter.remove();
      }
    }
  }
}