Program: 75119
Project: 75119
Buggy source:
/** 
 * Handle a class declaration or anonymous class declaration. Records and assignment methods are added to the declaration.
 * @param node The AST node of class declaration or anonymous classdeclaration.
 * @param bodyDeclarations The list of body declarations in the class.
 * @param state The current state of the type analyzer.
 */
private void _handleDeclaration(ASTNode node,List bodyDeclarations,TypeAnalyzerState state){
  Class currentClass=state.getCurrentClass();
  Class parent=currentClass.getSuperclass();
  List newMethods=new LinkedList();
  List newFields=new LinkedList();
  AST ast=node.getAST();
  CompilationUnit root=(CompilationUnit)node.getRoot();
  List fieldNames=new LinkedList();
  List fieldTypes=new LinkedList();
  Iterator bodyIter=bodyDeclarations.iterator();
  while (bodyIter.hasNext()) {
    Object nextDeclaration=bodyIter.next();
    if (nextDeclaration instanceof FieldDeclaration) {
      FieldDeclaration fieldDecl=(FieldDeclaration)nextDeclaration;
      boolean isStatic=Modifier.isStatic(fieldDecl.getModifiers());
      if (isStatic && HANDLE_STATIC_FIELDS != true)       continue;
      if (Modifier.isPrivate(fieldDecl.getModifiers())) {
        Type type=Type.getType(fieldDecl);
        Iterator fragmentIter=fieldDecl.fragments().iterator();
        while (fragmentIter.hasNext()) {
          VariableDeclarationFragment fragment=(VariableDeclarationFragment)fragmentIter.next();
          String fieldName=fragment.getName().getIdentifier();
          List indicesList=_getAccessedField(currentClass.getName(),fieldName);
          if (indicesList == null)           continue;
          Iterator indicesIter=indicesList.iterator();
          while (indicesIter.hasNext()) {
            int indices=((Integer)indicesIter.next()).intValue();
            newMethods.add(_createAssignMethod(ast,root,state,fieldName,type,indices,isStatic));
          }
          fieldNames.add(fieldName);
          fieldTypes.add(type);
          newFields.add(_createFieldRecord(ast,root,state,fieldName,type.dimensions(),isStatic));
        }
      }
    }
  }
  newFields.add(_createRecordArray(ast,root,state,fieldNames));
  newMethods.add(_createRestoreMethod(ast,root,state,fieldNames,fieldTypes,node instanceof AnonymousClassDeclaration));
  MethodDeclaration getCheckpoint=_createGetCheckpointMethod(ast,root,state,node instanceof AnonymousClassDeclaration);
  if (getCheckpoint != null)   newMethods.add(getCheckpoint);
  MethodDeclaration setCheckpoint=_createSetCheckpointMethod(ast,root,state,node instanceof AnonymousClassDeclaration);
  if (setCheckpoint != null)   newMethods.add(setCheckpoint);
  if (!(node instanceof AnonymousClassDeclaration))   newMethods.add(_createStateSetCheckpointMethod(ast,root,state));
  if (node instanceof AnonymousClassDeclaration)   bodyDeclarations.add(_createProxyClass(ast,root,state));
 else {
    FieldDeclaration checkpointField=_createCheckpointField(ast,root,state);
    if (checkpointField != null)     bodyDeclarations.add(0,checkpointField);
    FieldDeclaration record=_createCheckpointRecord(ast,root,state);
    if (record != null)     newFields.add(0,record);
    String rollbackType=getClassName(Rollbackable.class,state,root);
    ((TypeDeclaration)node).superInterfaces().add(createName(ast,rollbackType));
  }
  bodyDeclarations.addAll(newMethods);
  bodyDeclarations.addAll(newFields);
  if (node instanceof AnonymousClassDeclaration) {
    Initializer initializer=ast.newInitializer();
    Block body=ast.newBlock();
    initializer.setBody(body);
    MethodInvocation addInvocation=ast.newMethodInvocation();
    addInvocation.setExpression(ast.newSimpleName(CHECKPOINT_NAME));
    addInvocation.setName(ast.newSimpleName("String_Node_Str"));
    ClassInstanceCreation proxy=ast.newClassInstanceCreation();
    proxy.setName(ast.newSimpleName(_getProxyName()));
    addInvocation.arguments().add(proxy);
    body.statements().add(ast.newExpressionStatement(addInvocation));
    bodyDeclarations.add(initializer);
  }
}

Fixed version (ground truth):
/** 
 * Handle a class declaration or anonymous class declaration. Records and assignment methods are added to the declaration.
 * @param node The AST node of class declaration or anonymous classdeclaration.
 * @param bodyDeclarations The list of body declarations in the class.
 * @param state The current state of the type analyzer.
 */
private void _handleDeclaration(ASTNode node,List bodyDeclarations,TypeAnalyzerState state){
  Class currentClass=state.getCurrentClass();
  Class parent=currentClass.getSuperclass();
  List newMethods=new LinkedList();
  List newFields=new LinkedList();
  AST ast=node.getAST();
  CompilationUnit root=(CompilationUnit)node.getRoot();
  List fieldNames=new LinkedList();
  List fieldTypes=new LinkedList();
  Iterator bodyIter=bodyDeclarations.iterator();
  while (bodyIter.hasNext()) {
    Object nextDeclaration=bodyIter.next();
    if (nextDeclaration instanceof FieldDeclaration) {
      FieldDeclaration fieldDecl=(FieldDeclaration)nextDeclaration;
      boolean isStatic=Modifier.isStatic(fieldDecl.getModifiers());
      if (isStatic && HANDLE_STATIC_FIELDS != true)       continue;
      if (Modifier.isPrivate(fieldDecl.getModifiers())) {
        Type type=Type.getType(fieldDecl);
        Iterator fragmentIter=fieldDecl.fragments().iterator();
        while (fragmentIter.hasNext()) {
          VariableDeclarationFragment fragment=(VariableDeclarationFragment)fragmentIter.next();
          String fieldName=fragment.getName().getIdentifier();
          List indicesList=_getAccessedField(currentClass.getName(),fieldName);
          if (indicesList == null)           continue;
          Iterator indicesIter=indicesList.iterator();
          while (indicesIter.hasNext()) {
            int indices=((Integer)indicesIter.next()).intValue();
            newMethods.add(_createAssignMethod(ast,root,state,fieldName,type,indices,isStatic));
          }
          fieldNames.add(fieldName);
          fieldTypes.add(type);
          newFields.add(_createFieldRecord(ast,root,state,fieldName,type.dimensions(),isStatic));
        }
      }
    }
  }
  newFields.add(_createRecordArray(ast,root,state,fieldNames));
  newMethods.add(_createRestoreMethod(ast,root,state,fieldNames,fieldTypes,node instanceof AnonymousClassDeclaration));
  MethodDeclaration getCheckpoint=_createGetCheckpointMethod(ast,root,state,node instanceof AnonymousClassDeclaration);
  if (getCheckpoint != null)   newMethods.add(getCheckpoint);
  MethodDeclaration setCheckpoint=_createSetCheckpointMethod(ast,root,state,node instanceof AnonymousClassDeclaration);
  if (setCheckpoint != null)   newMethods.add(setCheckpoint);
  if (!(node instanceof AnonymousClassDeclaration))   newMethods.add(_createExtraSetCheckpointMethod(ast,root,state));
  if (node instanceof AnonymousClassDeclaration)   bodyDeclarations.add(_createProxyClass(ast,root,state));
 else {
    FieldDeclaration checkpointField=_createCheckpointField(ast,root,state);
    if (checkpointField != null)     bodyDeclarations.add(0,checkpointField);
    FieldDeclaration record=_createCheckpointRecord(ast,root,state);
    if (record != null)     newFields.add(0,record);
    String rollbackType=getClassName(Rollbackable.class,state,root);
    ((TypeDeclaration)node).superInterfaces().add(createName(ast,rollbackType));
  }
  bodyDeclarations.addAll(newMethods);
  bodyDeclarations.addAll(newFields);
  if (node instanceof AnonymousClassDeclaration) {
    Initializer initializer=ast.newInitializer();
    Block body=ast.newBlock();
    initializer.setBody(body);
    MethodInvocation addInvocation=ast.newMethodInvocation();
    addInvocation.setExpression(ast.newSimpleName(CHECKPOINT_NAME));
    addInvocation.setName(ast.newSimpleName("String_Node_Str"));
    ClassInstanceCreation proxy=ast.newClassInstanceCreation();
    proxy.setName(ast.newSimpleName(_getProxyName()));
    addInvocation.arguments().add(proxy);
    body.statements().add(ast.newExpressionStatement(addInvocation));
    bodyDeclarations.add(initializer);
  }
}