Program: 3663
Project: 3663
Buggy source:
/** 
 * Find the upwards and downwards transitive closure for each node in a graph. Assumes the graph is a DAG in general, but handles cycles (which may occur in the case of meta-annotations).
 */
private static void findTransitiveClosure(Collection<? extends DAGNode> nodes){
  HashSet<DAGNode> activeTopDownNodes=new HashSet<>();
  for (  DAGNode node : nodes) {
    if (node.directSuperNodes.isEmpty()) {
      activeTopDownNodes.add(node);
    }
  }
  while (!activeTopDownNodes.isEmpty()) {
    HashSet<DAGNode> activeTopDownNodesNext=new HashSet<>(activeTopDownNodes.size());
    for (    DAGNode node : activeTopDownNodes) {
      boolean changed=node.allSuperNodes.addAll(node.directSuperNodes);
      for (      DAGNode superNode : node.directSuperNodes) {
        changed|=node.allSuperNodes.addAll(superNode.allSuperNodes);
      }
      if (changed) {
        for (        DAGNode subNode : node.directSubNodes) {
          activeTopDownNodesNext.add(subNode);
        }
      }
    }
    activeTopDownNodes=activeTopDownNodesNext;
  }
  HashSet<DAGNode> activeBottomUpNodes=new HashSet<>();
  for (  DAGNode node : nodes) {
    if (node.directSubNodes.isEmpty()) {
      activeBottomUpNodes.add(node);
    }
  }
  while (!activeBottomUpNodes.isEmpty()) {
    HashSet<DAGNode> activeBottomUpNodesNext=new HashSet<>(activeBottomUpNodes.size());
    for (    DAGNode node : activeBottomUpNodes) {
      boolean changed=node.allSubNodes.addAll(node.directSubNodes);
      for (      DAGNode subNode : node.directSubNodes) {
        changed|=node.allSubNodes.addAll(subNode.allSubNodes);
      }
      if (changed) {
        for (        DAGNode superNode : node.directSuperNodes) {
          activeBottomUpNodesNext.add(superNode);
        }
      }
    }
    activeBottomUpNodes=activeBottomUpNodesNext;
  }
}

Fixed version (ground truth):
/** 
 * Find the upwards and downwards transitive closure for each node in a graph. Assumes the graph is a DAG in general, but handles cycles (which may occur in the case of meta-annotations).
 */
private static void findTransitiveClosure(Collection<? extends DAGNode> nodes){
  HashSet<DAGNode> activeTopDownNodes=new HashSet<>();
  for (  DAGNode node : nodes) {
    if (node.directSuperNodes.isEmpty()) {
      for (      DAGNode sub : node.directSubNodes) {
        activeTopDownNodes.add(sub);
      }
    }
  }
  while (!activeTopDownNodes.isEmpty()) {
    HashSet<DAGNode> activeTopDownNodesNext=new HashSet<>(activeTopDownNodes.size());
    for (    DAGNode node : activeTopDownNodes) {
      boolean changed=node.allSuperNodes.addAll(node.directSuperNodes);
      for (      DAGNode superNode : node.directSuperNodes) {
        changed|=node.allSuperNodes.addAll(superNode.allSuperNodes);
      }
      if (changed) {
        for (        DAGNode subNode : node.directSubNodes) {
          activeTopDownNodesNext.add(subNode);
        }
      }
    }
    activeTopDownNodes=activeTopDownNodesNext;
  }
  HashSet<DAGNode> activeBottomUpNodes=new HashSet<>();
  for (  DAGNode node : nodes) {
    if (node.directSubNodes.isEmpty()) {
      for (      DAGNode sup : node.directSuperNodes) {
        activeBottomUpNodes.add(sup);
      }
    }
  }
  while (!activeBottomUpNodes.isEmpty()) {
    HashSet<DAGNode> activeBottomUpNodesNext=new HashSet<>(activeBottomUpNodes.size());
    for (    DAGNode node : activeBottomUpNodes) {
      boolean changed=node.allSubNodes.addAll(node.directSubNodes);
      for (      DAGNode subNode : node.directSubNodes) {
        changed|=node.allSubNodes.addAll(subNode.allSubNodes);
      }
      if (changed) {
        for (        DAGNode superNode : node.directSuperNodes) {
          activeBottomUpNodesNext.add(superNode);
        }
      }
    }
    activeBottomUpNodes=activeBottomUpNodesNext;
  }
}