Program: 9757
Project: 9757
Buggy source:
/** 
 * The method computes a new class hierarchy, which is a copy of this one, but only the specified classes are allowed to occur. For instance, if we have subclass relationships between 1sYearStudent, Student, and Person, but Student is not allowed, then there a is a subclass relationship between 1stYearStudent and Person. Currently, owl:Thing and owl:Nothing are always allowed for technical reasons.
 * @param allowedClasses The classes, which are allowed to occur in the newclass hierarchy.
 * @return A copy of this hierarchy, which is restricted to a certain setof classes.
 */
public ClassHierarchy cloneAndRestrict(Set<NamedClass> allowedClasses){
  Set<Description> allowed=new TreeSet<Description>(conceptComparator);
  allowed.addAll(allowedClasses);
  allowed.add(Thing.instance);
  allowed.add(Nothing.instance);
  TreeMap<Description,SortedSet<Description>> subsumptionHierarchyUpNew=new TreeMap<Description,SortedSet<Description>>(conceptComparator);
  TreeMap<Description,SortedSet<Description>> subsumptionHierarchyDownNew=new TreeMap<Description,SortedSet<Description>>(conceptComparator);
  for (  Entry<Description,SortedSet<Description>> entry : subsumptionHierarchyUp.entrySet()) {
    Description key=entry.getKey();
    if (allowed.contains(key)) {
      TreeSet<Description> superClasses=new TreeSet<Description>(entry.getValue());
      TreeSet<Description> newSuperClasses=new TreeSet<Description>(conceptComparator);
      while (!superClasses.isEmpty()) {
        Description d=superClasses.pollFirst();
        if (allowed.contains(d)) {
          newSuperClasses.add(d);
        }
 else {
          Set<Description> tmp=subsumptionHierarchyUp.get(d);
          superClasses.addAll(tmp);
        }
      }
      subsumptionHierarchyUpNew.put(key,newSuperClasses);
    }
  }
  for (  Entry<Description,SortedSet<Description>> entry : subsumptionHierarchyDown.entrySet()) {
    Description key=entry.getKey();
    if (allowed.contains(key)) {
      TreeSet<Description> subClasses=new TreeSet<Description>(entry.getValue());
      TreeSet<Description> newSubClasses=new TreeSet<Description>(entry.getValue());
      while (!subClasses.isEmpty()) {
        Description d=subClasses.pollFirst();
        if (allowed.contains(d)) {
          newSubClasses.add(d);
        }
 else {
          subClasses.addAll(subsumptionHierarchyDown.get(d));
        }
      }
      subsumptionHierarchyDownNew.put(key,newSubClasses);
    }
  }
  return new ClassHierarchy(subsumptionHierarchyUpNew,subsumptionHierarchyDownNew);
}

Fixed version (ground truth):
/** 
 * The method computes a new class hierarchy, which is a copy of this one, but only the specified classes are allowed to occur. For instance, if we have subclass relationships between 1sYearStudent, Student, and Person, but Student is not allowed, then there a is a subclass relationship between 1stYearStudent and Person. Currently, owl:Thing and owl:Nothing are always allowed for technical reasons.
 * @param allowedClasses The classes, which are allowed to occur in the newclass hierarchy.
 * @return A copy of this hierarchy, which is restricted to a certain setof classes.
 */
public ClassHierarchy cloneAndRestrict(Set<NamedClass> allowedClasses){
  Set<Description> allowed=new TreeSet<Description>(conceptComparator);
  allowed.addAll(allowedClasses);
  allowed.add(Thing.instance);
  allowed.add(Nothing.instance);
  TreeMap<Description,SortedSet<Description>> subsumptionHierarchyUpNew=new TreeMap<Description,SortedSet<Description>>(conceptComparator);
  TreeMap<Description,SortedSet<Description>> subsumptionHierarchyDownNew=new TreeMap<Description,SortedSet<Description>>(conceptComparator);
  for (  Entry<Description,SortedSet<Description>> entry : subsumptionHierarchyUp.entrySet()) {
    Description key=entry.getKey();
    if (allowed.contains(key)) {
      TreeSet<Description> superClasses=new TreeSet<Description>(entry.getValue());
      TreeSet<Description> newSuperClasses=new TreeSet<Description>(conceptComparator);
      while (!superClasses.isEmpty()) {
        Description d=superClasses.pollFirst();
        if (allowed.contains(d)) {
          newSuperClasses.add(d);
        }
 else {
          Set<Description> tmp=subsumptionHierarchyUp.get(d);
          superClasses.addAll(tmp);
        }
      }
      subsumptionHierarchyUpNew.put(key,newSuperClasses);
    }
  }
  for (  Entry<Description,SortedSet<Description>> entry : subsumptionHierarchyDown.entrySet()) {
    Description key=entry.getKey();
    if (allowed.contains(key)) {
      TreeSet<Description> subClasses=new TreeSet<Description>(entry.getValue());
      TreeSet<Description> newSubClasses=new TreeSet<Description>(conceptComparator);
      while (!subClasses.isEmpty()) {
        Description d=subClasses.pollFirst();
        if (allowed.contains(d)) {
          newSubClasses.add(d);
        }
 else {
          subClasses.addAll(subsumptionHierarchyDown.get(d));
        }
      }
      subsumptionHierarchyDownNew.put(key,newSubClasses);
    }
  }
  return new ClassHierarchy(subsumptionHierarchyUpNew,subsumptionHierarchyDownNew);
}