Program: 99828
Project: 99828
Buggy source:
/** 
 * @param n
 * @param bodyDecls
 * @param enumConstants
 * @param typeBinding
 * @param name Used in creating default constructor, and passed into new ClassEntity()
 * @param context
 * @return
 */
private CAstEntity createClassDeclaration(ASTNode n,List bodyDecls,List enumConstants,ITypeBinding typeBinding,String name,int modifiers,boolean isInterface,boolean isAnnotation,WalkContext context){
  final List<CAstEntity> memberEntities=new ArrayList<CAstEntity>();
  ArrayList<ASTNode> inits=new ArrayList<ASTNode>();
  ArrayList<ASTNode> staticInits=new ArrayList<ASTNode>();
  if (enumConstants != null) {
    for (    Object decl : enumConstants) {
      EnumConstantDeclaration ecd=(EnumConstantDeclaration)decl;
      staticInits.add(ecd);
    }
  }
  for (  Object decl : bodyDecls) {
    if (decl instanceof Initializer) {
      Initializer initializer=(Initializer)decl;
      boolean isStatic=((initializer.getModifiers() & Modifier.STATIC) != 0);
      (isStatic ? staticInits : inits).add(initializer);
    }
 else     if (decl instanceof FieldDeclaration) {
      FieldDeclaration fd=(FieldDeclaration)decl;
      for (      Object f : fd.fragments()) {
        VariableDeclarationFragment frag=(VariableDeclarationFragment)f;
        if (frag.getInitializer() != null) {
          boolean isStatic=((fd.getModifiers() & Modifier.STATIC) != 0);
          (isStatic ? staticInits : inits).add(frag);
        }
      }
    }
  }
  if (enumConstants != null) {
    for (    Object decl : enumConstants) {
      memberEntities.add(visit((EnumConstantDeclaration)decl,context));
    }
  }
  for (  Object d : bodyDecls) {
    BodyDeclaration decl=(BodyDeclaration)d;
    if (decl instanceof FieldDeclaration) {
      FieldDeclaration fieldDecl=(FieldDeclaration)decl;
      Collection<CAstQualifier> quals=JDT2CAstUtils.mapModifiersToQualifiers(fieldDecl.getModifiers(),false,false);
      for (      Object f : fieldDecl.fragments()) {
        VariableDeclarationFragment fieldFrag=(VariableDeclarationFragment)f;
        memberEntities.add(new FieldEntity(fieldFrag.getName().getIdentifier(),fieldFrag.resolveBinding().getType(),quals,makePosition(fieldFrag.getStartPosition(),fieldFrag.getStartPosition() + fieldFrag.getLength())));
      }
    }
 else     if (decl instanceof Initializer) {
    }
 else     if (decl instanceof MethodDeclaration) {
      MethodDeclaration metDecl=(MethodDeclaration)decl;
      if (typeBinding.isEnum() && metDecl.isConstructor())       memberEntities.add(createEnumConstructorWithParameters(metDecl.resolveBinding(),metDecl,context,inits,metDecl));
 else {
        memberEntities.add(visit(metDecl,typeBinding,context,inits));
        Collection<IMethodBinding> overriddenMets=JDT2CAstUtils.getOverriddenMethod(metDecl.resolveBinding());
        if (overriddenMets != null) {
          for (          IMethodBinding overridden : overriddenMets)           if (!JDT2CAstUtils.sameSignatureAndReturnType(metDecl.resolveBinding(),overridden))           memberEntities.add(makeSyntheticCovariantRedirect(metDecl,metDecl.resolveBinding(),overridden,context));
        }
      }
    }
 else     if (decl instanceof AbstractTypeDeclaration) {
      memberEntities.add(visit((AbstractTypeDeclaration)decl,context));
    }
 else     if (decl instanceof AnnotationTypeMemberDeclaration) {
    }
 else {
      Assertions.UNREACHABLE("String_Node_Str");
    }
  }
  for (  Object m : typeBinding.getDeclaredMethods()) {
    IMethodBinding met=(IMethodBinding)m;
    if (met.isDefaultConstructor()) {
      if (typeBinding.isEnum())       memberEntities.add(createEnumConstructorWithParameters(met,n,context,inits,null));
 else       if (met.getParameterTypes().length > 0)       memberEntities.add(createDefaultConstructorWithParameters(met,n,context,inits));
 else       memberEntities.add(createDefaultConstructor(name,typeBinding,context,inits,n));
    }
  }
  if (typeBinding.isEnum() && !typeBinding.isAnonymous())   doEnumHiddenEntities(typeBinding,staticInits,memberEntities,context);
  if (!staticInits.isEmpty()) {
    Map<CAstNode,CAstEntity> childEntities=HashMapFactory.make();
    final MethodContext newContext=new MethodContext(context,childEntities);
    CAstNode[] bodyNodes=new CAstNode[staticInits.size()];
    for (int i=0; i < staticInits.size(); i++)     bodyNodes[i]=visitFieldInitNode(staticInits.get(i),newContext);
    CAstNode staticInitAst=makeNode(newContext,fFactory,n,CAstNode.BLOCK_STMT,bodyNodes);
    memberEntities.add(new ProcedureEntity(staticInitAst,typeBinding,childEntities,newContext));
  }
  Collection<CAstQualifier> quals=JDT2CAstUtils.mapModifiersToQualifiers(modifiers,isInterface,isAnnotation);
  return new ClassEntity(typeBinding,name,quals,memberEntities,makePosition(n));
}

Fixed version (ground truth):
/** 
 * @param n
 * @param bodyDecls
 * @param enumConstants
 * @param typeBinding
 * @param name Used in creating default constructor, and passed into new ClassEntity()
 * @param context
 * @return
 */
private CAstEntity createClassDeclaration(ASTNode n,List bodyDecls,List enumConstants,ITypeBinding typeBinding,String name,int modifiers,boolean isInterface,boolean isAnnotation,WalkContext context){
  final List<CAstEntity> memberEntities=new ArrayList<CAstEntity>();
  ArrayList<ASTNode> inits=new ArrayList<ASTNode>();
  ArrayList<ASTNode> staticInits=new ArrayList<ASTNode>();
  if (enumConstants != null) {
    for (    Object decl : enumConstants) {
      EnumConstantDeclaration ecd=(EnumConstantDeclaration)decl;
      staticInits.add(ecd);
    }
  }
  for (  Object decl : bodyDecls) {
    if (decl instanceof Initializer) {
      Initializer initializer=(Initializer)decl;
      boolean isStatic=((initializer.getModifiers() & Modifier.STATIC) != 0);
      (isStatic ? staticInits : inits).add(initializer);
    }
 else     if (decl instanceof FieldDeclaration) {
      FieldDeclaration fd=(FieldDeclaration)decl;
      for (      Object f : fd.fragments()) {
        VariableDeclarationFragment frag=(VariableDeclarationFragment)f;
        if (frag.getInitializer() != null) {
          boolean isStatic=((fd.getModifiers() & Modifier.STATIC) != 0);
          (isStatic ? staticInits : inits).add(frag);
        }
      }
    }
  }
  if (enumConstants != null) {
    for (    Object decl : enumConstants) {
      memberEntities.add(visit((EnumConstantDeclaration)decl,context));
    }
  }
  for (  Object d : bodyDecls) {
    BodyDeclaration decl=(BodyDeclaration)d;
    if (decl instanceof FieldDeclaration) {
      FieldDeclaration fieldDecl=(FieldDeclaration)decl;
      Collection<CAstQualifier> quals=JDT2CAstUtils.mapModifiersToQualifiers(fieldDecl.getModifiers(),false,false);
      for (      Object f : fieldDecl.fragments()) {
        VariableDeclarationFragment fieldFrag=(VariableDeclarationFragment)f;
        memberEntities.add(new FieldEntity(fieldFrag.getName().getIdentifier(),fieldFrag.resolveBinding().getType(),quals,makePosition(fieldFrag.getStartPosition(),fieldFrag.getStartPosition() + fieldFrag.getLength())));
      }
    }
 else     if (decl instanceof Initializer) {
    }
 else     if (decl instanceof MethodDeclaration) {
      MethodDeclaration metDecl=(MethodDeclaration)decl;
      if (typeBinding.isEnum() && metDecl.isConstructor())       memberEntities.add(createEnumConstructorWithParameters(metDecl.resolveBinding(),metDecl,context,inits,metDecl));
 else {
        memberEntities.add(visit(metDecl,typeBinding,context,inits));
        Collection<IMethodBinding> overriddenMets=JDT2CAstUtils.getOverriddenMethod(metDecl.resolveBinding());
        if (overriddenMets != null) {
          for (          IMethodBinding overridden : overriddenMets)           if (!JDT2CAstUtils.sameErasedSignatureAndReturnType(metDecl.resolveBinding(),overridden))           memberEntities.add(makeSyntheticCovariantRedirect(metDecl,metDecl.resolveBinding(),overridden,context));
        }
      }
    }
 else     if (decl instanceof AbstractTypeDeclaration) {
      memberEntities.add(visit((AbstractTypeDeclaration)decl,context));
    }
 else     if (decl instanceof AnnotationTypeMemberDeclaration) {
    }
 else {
      Assertions.UNREACHABLE("String_Node_Str");
    }
  }
  for (  Object m : typeBinding.getDeclaredMethods()) {
    IMethodBinding met=(IMethodBinding)m;
    if (met.isDefaultConstructor()) {
      if (typeBinding.isEnum())       memberEntities.add(createEnumConstructorWithParameters(met,n,context,inits,null));
 else       if (met.getParameterTypes().length > 0)       memberEntities.add(createDefaultConstructorWithParameters(met,n,context,inits));
 else       memberEntities.add(createDefaultConstructor(name,typeBinding,context,inits,n));
    }
  }
  if (typeBinding.isEnum() && !typeBinding.isAnonymous())   doEnumHiddenEntities(typeBinding,staticInits,memberEntities,context);
  if (!staticInits.isEmpty()) {
    Map<CAstNode,CAstEntity> childEntities=HashMapFactory.make();
    final MethodContext newContext=new MethodContext(context,childEntities);
    CAstNode[] bodyNodes=new CAstNode[staticInits.size()];
    for (int i=0; i < staticInits.size(); i++)     bodyNodes[i]=visitFieldInitNode(staticInits.get(i),newContext);
    CAstNode staticInitAst=makeNode(newContext,fFactory,n,CAstNode.BLOCK_STMT,bodyNodes);
    memberEntities.add(new ProcedureEntity(staticInitAst,typeBinding,childEntities,newContext));
  }
  Collection<CAstQualifier> quals=JDT2CAstUtils.mapModifiersToQualifiers(modifiers,isInterface,isAnnotation);
  return new ClassEntity(typeBinding,name,quals,memberEntities,makePosition(n));
}