Program: 177677
Project: 177677
Buggy source:
/** 
 * Builds a serial schedule of building of entities into existing node list. Worst time complexity is <code>O(N!)</code> but the average time complexity converges to <code>O(N^2)</code>. Postcondition: <code>EntityDependencyGraph.nodes</code> is ordered list  of serializable schedule.
 */
private void buildSerialDependencyGraph(){
  for (  Entity e : this.entityList) {
    for (    Field f : e.getFields()) {
      if (!f.isList() && getEntityOfType(f.getClazz()) != null) {
        Entity requirement=getEntityOfType(f.getClazz());
        entityMap.get(e).requires.add(requirement);
      }
    }
  }
  Collections.sort(nodes);
  LinkedList<Node> orderedList=new LinkedList<Node>();
  for (  Node n : nodes)   orderedList.add(n);
  while (true) {
    Node unchecked=null;
    int pos=0;
    for (    Node n : orderedList) {
      if (!n.checked) {
        unchecked=n;
        break;
      }
      pos++;
    }
    if (unchecked == null)     break;
    boolean dependenciesSatisfied=true;
    do {
      dependenciesSatisfied=true;
      for (      Entity dependency : unchecked.requires) {
        boolean satisfied=false;
        for (int i=0; i < pos; i++) {
          if (orderedList.get(i).entity == dependency) {
            satisfied=true;
            break;
          }
        }
        dependenciesSatisfied&=satisfied;
      }
      if (dependenciesSatisfied) {
        unchecked.checked=true;
        break;
      }
 else {
        if (pos >= orderedList.size() - 1) {
          throw new UnsolvableDependencyOrderException();
        }
 else {
          orderedList.remove(pos);
          orderedList.add(pos + 1,unchecked);
          pos++;
        }
      }
    }
 while (!dependenciesSatisfied);
  }
  nodes=orderedList;
}

Fixed version (ground truth):
/** 
 * Builds a serial schedule of building of entities into existing node list. Worst time complexity is <code>O(N!)</code> but the average time complexity converges to <code>O(N^2)</code>. Postcondition: <code>EntityDependencyGraph.nodes</code> is ordered list  of serializable schedule.
 */
private void buildSerialDependencyGraph(){
  for (  Entity e : this.entityList) {
    for (    Field f : e.getFields()) {
      if (!f.isList() && getEntityOfType(f.getClazz()) != null && !f.getClazz().equals(e.getType())) {
        Entity requirement=getEntityOfType(f.getClazz());
        entityMap.get(e).requires.add(requirement);
      }
    }
  }
  Collections.sort(nodes);
  LinkedList<Node> orderedList=new LinkedList<Node>();
  for (  Node n : nodes)   orderedList.add(n);
  while (true) {
    Node unchecked=null;
    int pos=0;
    for (    Node n : orderedList) {
      if (!n.checked) {
        unchecked=n;
        break;
      }
      pos++;
    }
    if (unchecked == null)     break;
    boolean dependenciesSatisfied=true;
    do {
      dependenciesSatisfied=true;
      for (      Entity dependency : unchecked.requires) {
        boolean satisfied=false;
        for (int i=0; i < pos; i++) {
          if (orderedList.get(i).entity == dependency) {
            satisfied=true;
            break;
          }
        }
        dependenciesSatisfied&=satisfied;
      }
      if (dependenciesSatisfied) {
        unchecked.checked=true;
        break;
      }
 else {
        if (pos >= orderedList.size() - 1) {
          throw new UnsolvableDependencyOrderException();
        }
 else {
          orderedList.remove(pos);
          orderedList.add(pos + 1,unchecked);
          pos++;
        }
      }
    }
 while (!dependenciesSatisfied);
  }
  nodes=orderedList;
}