Program: 9558
Project: 9558
Buggy source:
@SuppressWarnings({"String_Node_Str"}) public Set<Description> refine(Description description,int maxLength,List<Description> knownRefinements,Description currDomain){
  if (!(currDomain instanceof Thing) && !topARefinementsLength.containsKey(currDomain))   topARefinementsLength.put((NamedClass)currDomain,0);
  Set<Description> refinements=new TreeSet<Description>(conceptComparator);
  Set<Description> tmp=new HashSet<Description>();
  if (description instanceof Thing) {
    if (currDomain instanceof Thing) {
      if (maxLength > topRefinementsLength)       computeTopRefinements(maxLength);
      refinements=(TreeSet<Description>)topRefinementsCumulative.get(maxLength).clone();
    }
 else {
      if (maxLength > topARefinementsLength.get(currDomain)) {
        computeTopRefinements(maxLength,(NamedClass)currDomain);
      }
      refinements=(TreeSet<Description>)topARefinementsCumulative.get(currDomain).get(maxLength).clone();
    }
  }
 else   if (description instanceof Nothing) {
  }
 else   if (description instanceof NamedClass) {
    refinements.addAll(subHierarchy.getSubClasses(description));
    refinements.remove(new Nothing());
  }
 else   if (description instanceof Negation && description.getChild(0) instanceof NamedClass) {
    tmp=subHierarchy.getSuperClasses(description.getChild(0));
    for (    Description c : tmp) {
      if (!(c instanceof Thing))       refinements.add(new Negation(c));
    }
  }
 else   if (description instanceof Intersection) {
    for (    Description child : description.getChildren()) {
      tmp=refine(child,maxLength - description.getLength() + child.getLength(),null,currDomain);
      for (      Description c : tmp) {
        List<Description> newChildren=(List<Description>)((LinkedList<Description>)description.getChildren()).clone();
        newChildren.add(c);
        newChildren.remove(child);
        Intersection mc=new Intersection(newChildren);
        ConceptTransformation.cleanConceptNonRecursive(mc);
        ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc,conceptComparator);
        if (checkIntersection(mc))         refinements.add(mc);
      }
    }
  }
 else   if (description instanceof Union) {
    for (    Description child : description.getChildren()) {
      tmp=refine(child,maxLength - description.getLength() + child.getLength(),null,currDomain);
      for (      Description c : tmp) {
        List<Description> newChildren=new LinkedList<Description>(description.getChildren());
        newChildren.remove(child);
        newChildren.add(c);
        Union md=new Union(newChildren);
        ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(md,conceptComparator);
        refinements.add(md);
      }
    }
    if (dropDisjuncts) {
      if (description.getChildren().size() == 2) {
        refinements.add(description.getChild(0));
        refinements.add(description.getChild(1));
      }
 else {
        for (int i=0; i < description.getChildren().size(); i++) {
          List<Description> newChildren=new LinkedList<Description>(description.getChildren());
          newChildren.remove(i);
          Union md=new Union(newChildren);
          refinements.add(md);
        }
      }
    }
  }
 else   if (description instanceof ObjectSomeRestriction) {
    ObjectPropertyExpression role=((ObjectQuantorRestriction)description).getRole();
    Description range=opRanges.get(role);
    tmp=refine(description.getChild(0),maxLength - 2,null,range);
    for (    Description c : tmp)     refinements.add(new ObjectSomeRestriction(((ObjectQuantorRestriction)description).getRole(),c));
    ObjectProperty ar=(ObjectProperty)role;
    Set<ObjectProperty> moreSpecialRoles=reasoner.getSubProperties(ar);
    for (    ObjectProperty moreSpecialRole : moreSpecialRoles)     refinements.add(new ObjectSomeRestriction(moreSpecialRole,description.getChild(0)));
    if (useCardinalityRestrictions) {
      if (maxLength > description.getLength() && maxNrOfFillers.get(ar) > 1) {
        ObjectMinCardinalityRestriction min=new ObjectMinCardinalityRestriction(2,role,description.getChild(0));
        refinements.add(min);
      }
    }
    if (useHasValueConstructor && description.getChild(0) instanceof Thing) {
      Set<Individual> frequentInds=frequentValues.get(role);
      if (frequentInds != null) {
        for (        Individual ind : frequentInds) {
          ObjectValueRestriction ovr=new ObjectValueRestriction((ObjectProperty)role,ind);
          refinements.add(ovr);
        }
      }
    }
  }
 else   if (description instanceof ObjectAllRestriction) {
    ObjectPropertyExpression role=((ObjectQuantorRestriction)description).getRole();
    Description range=opRanges.get(role);
    tmp=refine(description.getChild(0),maxLength - 2,null,range);
    for (    Description c : tmp) {
      refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)description).getRole(),c));
    }
    if (description.getChild(0) instanceof NamedClass && tmp.size() == 0) {
      refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)description).getRole(),new Nothing()));
    }
    ObjectProperty ar=(ObjectProperty)role;
    Set<ObjectProperty> moreSpecialRoles=reasoner.getSubProperties(ar);
    for (    ObjectProperty moreSpecialRole : moreSpecialRoles) {
      refinements.add(new ObjectAllRestriction(moreSpecialRole,description.getChild(0)));
    }
  }
 else   if (description instanceof ObjectCardinalityRestriction) {
    ObjectPropertyExpression role=((ObjectCardinalityRestriction)description).getRole();
    Description range=opRanges.get(role);
    int number=((ObjectCardinalityRestriction)description).getCardinality();
    if (description instanceof ObjectMaxCardinalityRestriction) {
      tmp=refine(description.getChild(0),maxLength - 3,null,range);
      for (      Description d : tmp) {
        refinements.add(new ObjectMaxCardinalityRestriction(number,role,d));
      }
      ObjectMaxCardinalityRestriction max=(ObjectMaxCardinalityRestriction)description;
      if (number > 1)       refinements.add(new ObjectMaxCardinalityRestriction(number - 1,max.getRole(),max.getChild(0)));
    }
 else     if (description instanceof ObjectMinCardinalityRestriction) {
      tmp=refine(description.getChild(0),maxLength - 3,null,range);
      for (      Description d : tmp) {
        refinements.add(new ObjectMinCardinalityRestriction(number,role,d));
      }
      ObjectMinCardinalityRestriction min=(ObjectMinCardinalityRestriction)description;
      if (number < maxNrOfFillers.get(min.getRole()))       refinements.add(new ObjectMinCardinalityRestriction(number + 1,min.getRole(),min.getChild(0)));
    }
  }
 else   if (description instanceof DatatypeSomeRestriction) {
    DatatypeSomeRestriction dsr=(DatatypeSomeRestriction)description;
    DatatypeProperty dp=(DatatypeProperty)dsr.getRestrictedPropertyExpression();
    DataRange dr=dsr.getDataRange();
    if (dr instanceof DoubleMaxValue) {
      double value=((DoubleMaxValue)dr).getValue();
      int splitIndex=splits.get(dp).lastIndexOf(value);
      if (splitIndex == -1)       throw new Error("String_Node_Str");
      int newSplitIndex=splitIndex - 1;
      if (newSplitIndex >= 0) {
        DoubleMaxValue max=new DoubleMaxValue(splits.get(dp).get(newSplitIndex));
        DatatypeSomeRestriction newDSR=new DatatypeSomeRestriction(dp,max);
        refinements.add(newDSR);
      }
    }
 else     if (dr instanceof DoubleMinValue) {
      double value=((DoubleMinValue)dr).getValue();
      int splitIndex=splits.get(dp).lastIndexOf(value);
      if (splitIndex == -1)       throw new Error("String_Node_Str");
      int newSplitIndex=splitIndex + 1;
      if (newSplitIndex < splits.get(dp).size()) {
        DoubleMinValue min=new DoubleMinValue(splits.get(dp).get(newSplitIndex));
        DatatypeSomeRestriction newDSR=new DatatypeSomeRestriction(dp,min);
        refinements.add(newDSR);
      }
    }
  }
 else   if (description instanceof StringValueRestriction) {
    StringValueRestriction svr=(StringValueRestriction)description;
    DatatypeProperty dp=svr.getRestrictedPropertyExpression();
    Set<DatatypeProperty> subDPs=reasoner.getSubProperties(dp);
    for (    DatatypeProperty subDP : subDPs) {
      refinements.add(new StringValueRestriction(subDP,svr.getStringValue()));
    }
  }
  if (!(description instanceof Thing) && !(description instanceof Nothing) && !(description instanceof ObjectAllRestriction && description.getChild(0) instanceof Nothing)) {
    int topRefLength=maxLength - description.getLength() - 1;
    if (currDomain instanceof Thing) {
      if (topRefLength > topRefinementsLength)       computeTopRefinements(topRefLength);
    }
 else     if (topRefLength > topARefinementsLength.get(currDomain))     computeTopRefinements(topRefLength,(NamedClass)currDomain);
    if (topRefLength > 0) {
      Set<Description> topRefs;
      if (currDomain instanceof Thing)       topRefs=topRefinementsCumulative.get(topRefLength);
 else       topRefs=topARefinementsCumulative.get(currDomain).get(topRefLength);
      for (      Description c : topRefs) {
        boolean skip=false;
        if (applyAllFilter) {
          if (c instanceof ObjectAllRestriction) {
            for (            Description child : description.getChildren()) {
              if (child instanceof ObjectAllRestriction) {
                ObjectPropertyExpression r1=((ObjectAllRestriction)c).getRole();
                ObjectPropertyExpression r2=((ObjectAllRestriction)child).getRole();
                if (r1.toString().equals(r2.toString()))                 skip=true;
              }
            }
          }
        }
        if (disjointChecks && c instanceof NamedClass && description instanceof NamedClass&& isDisjoint(description,c)) {
          skip=true;
        }
        if (!skip) {
          Intersection mc=new Intersection();
          mc.addChild(description);
          mc.addChild(c);
          ConceptTransformation.cleanConceptNonRecursive(mc);
          ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc,conceptComparator);
          if (checkIntersection(mc))           refinements.add(mc);
        }
      }
    }
  }
  return refinements;
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str"}) public Set<Description> refine(Description description,int maxLength,List<Description> knownRefinements,Description currDomain){
  if (!(currDomain instanceof Thing) && !topARefinementsLength.containsKey(currDomain))   topARefinementsLength.put((NamedClass)currDomain,0);
  Set<Description> refinements=new TreeSet<Description>(conceptComparator);
  Set<Description> tmp=new HashSet<Description>();
  if (description instanceof Thing) {
    if (currDomain instanceof Thing) {
      if (maxLength > topRefinementsLength)       computeTopRefinements(maxLength);
      refinements=(TreeSet<Description>)topRefinementsCumulative.get(maxLength).clone();
    }
 else {
      if (maxLength > topARefinementsLength.get(currDomain)) {
        computeTopRefinements(maxLength,(NamedClass)currDomain);
      }
      refinements=(TreeSet<Description>)topARefinementsCumulative.get(currDomain).get(maxLength).clone();
    }
  }
 else   if (description instanceof Nothing) {
  }
 else   if (description instanceof NamedClass) {
    refinements.addAll(subHierarchy.getSubClasses(description));
    refinements.remove(new Nothing());
  }
 else   if (description instanceof Negation && description.getChild(0) instanceof NamedClass) {
    tmp=subHierarchy.getSuperClasses(description.getChild(0));
    for (    Description c : tmp) {
      if (!(c instanceof Thing))       refinements.add(new Negation(c));
    }
  }
 else   if (description instanceof Intersection) {
    for (    Description child : description.getChildren()) {
      tmp=refine(child,maxLength - description.getLength() + child.getLength(),null,currDomain);
      for (      Description c : tmp) {
        List<Description> newChildren=(List<Description>)((LinkedList<Description>)description.getChildren()).clone();
        newChildren.add(c);
        newChildren.remove(child);
        Intersection mc=new Intersection(newChildren);
        ConceptTransformation.cleanConceptNonRecursive(mc);
        ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc,conceptComparator);
        if (checkIntersection(mc))         refinements.add(mc);
      }
    }
  }
 else   if (description instanceof Union) {
    for (    Description child : description.getChildren()) {
      tmp=refine(child,maxLength - description.getLength() + child.getLength(),null,currDomain);
      for (      Description c : tmp) {
        List<Description> newChildren=new LinkedList<Description>(description.getChildren());
        newChildren.remove(child);
        newChildren.add(c);
        Union md=new Union(newChildren);
        ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(md,conceptComparator);
        refinements.add(md);
      }
    }
    if (dropDisjuncts) {
      if (description.getChildren().size() == 2) {
        refinements.add(description.getChild(0));
        refinements.add(description.getChild(1));
      }
 else {
        for (int i=0; i < description.getChildren().size(); i++) {
          List<Description> newChildren=new LinkedList<Description>(description.getChildren());
          newChildren.remove(i);
          Union md=new Union(newChildren);
          refinements.add(md);
        }
      }
    }
  }
 else   if (description instanceof ObjectSomeRestriction) {
    ObjectPropertyExpression role=((ObjectQuantorRestriction)description).getRole();
    Description range=opRanges.get(role);
    tmp=refine(description.getChild(0),maxLength - 2,null,range);
    for (    Description c : tmp)     refinements.add(new ObjectSomeRestriction(((ObjectQuantorRestriction)description).getRole(),c));
    ObjectProperty ar=(ObjectProperty)role;
    Set<ObjectProperty> moreSpecialRoles=objectPropertyHierarchy.getMoreSpecialRoles(ar);
    for (    ObjectProperty moreSpecialRole : moreSpecialRoles)     refinements.add(new ObjectSomeRestriction(moreSpecialRole,description.getChild(0)));
    if (useCardinalityRestrictions) {
      if (maxLength > description.getLength() && maxNrOfFillers.get(ar) > 1) {
        ObjectMinCardinalityRestriction min=new ObjectMinCardinalityRestriction(2,role,description.getChild(0));
        refinements.add(min);
      }
    }
    if (useHasValueConstructor && description.getChild(0) instanceof Thing) {
      Set<Individual> frequentInds=frequentValues.get(role);
      if (frequentInds != null) {
        for (        Individual ind : frequentInds) {
          ObjectValueRestriction ovr=new ObjectValueRestriction((ObjectProperty)role,ind);
          refinements.add(ovr);
        }
      }
    }
  }
 else   if (description instanceof ObjectAllRestriction) {
    ObjectPropertyExpression role=((ObjectQuantorRestriction)description).getRole();
    Description range=opRanges.get(role);
    tmp=refine(description.getChild(0),maxLength - 2,null,range);
    for (    Description c : tmp) {
      refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)description).getRole(),c));
    }
    if (description.getChild(0) instanceof NamedClass && tmp.size() == 0) {
      refinements.add(new ObjectAllRestriction(((ObjectQuantorRestriction)description).getRole(),new Nothing()));
    }
    ObjectProperty ar=(ObjectProperty)role;
    Set<ObjectProperty> moreSpecialRoles=objectPropertyHierarchy.getMoreSpecialRoles(ar);
    for (    ObjectProperty moreSpecialRole : moreSpecialRoles) {
      refinements.add(new ObjectAllRestriction(moreSpecialRole,description.getChild(0)));
    }
  }
 else   if (description instanceof ObjectCardinalityRestriction) {
    ObjectPropertyExpression role=((ObjectCardinalityRestriction)description).getRole();
    Description range=opRanges.get(role);
    int number=((ObjectCardinalityRestriction)description).getCardinality();
    if (description instanceof ObjectMaxCardinalityRestriction) {
      tmp=refine(description.getChild(0),maxLength - 3,null,range);
      for (      Description d : tmp) {
        refinements.add(new ObjectMaxCardinalityRestriction(number,role,d));
      }
      ObjectMaxCardinalityRestriction max=(ObjectMaxCardinalityRestriction)description;
      if (number > 1)       refinements.add(new ObjectMaxCardinalityRestriction(number - 1,max.getRole(),max.getChild(0)));
    }
 else     if (description instanceof ObjectMinCardinalityRestriction) {
      tmp=refine(description.getChild(0),maxLength - 3,null,range);
      for (      Description d : tmp) {
        refinements.add(new ObjectMinCardinalityRestriction(number,role,d));
      }
      ObjectMinCardinalityRestriction min=(ObjectMinCardinalityRestriction)description;
      if (number < maxNrOfFillers.get(min.getRole()))       refinements.add(new ObjectMinCardinalityRestriction(number + 1,min.getRole(),min.getChild(0)));
    }
  }
 else   if (description instanceof DatatypeSomeRestriction) {
    DatatypeSomeRestriction dsr=(DatatypeSomeRestriction)description;
    DatatypeProperty dp=(DatatypeProperty)dsr.getRestrictedPropertyExpression();
    DataRange dr=dsr.getDataRange();
    if (dr instanceof DoubleMaxValue) {
      double value=((DoubleMaxValue)dr).getValue();
      int splitIndex=splits.get(dp).lastIndexOf(value);
      if (splitIndex == -1)       throw new Error("String_Node_Str");
      int newSplitIndex=splitIndex - 1;
      if (newSplitIndex >= 0) {
        DoubleMaxValue max=new DoubleMaxValue(splits.get(dp).get(newSplitIndex));
        DatatypeSomeRestriction newDSR=new DatatypeSomeRestriction(dp,max);
        refinements.add(newDSR);
      }
    }
 else     if (dr instanceof DoubleMinValue) {
      double value=((DoubleMinValue)dr).getValue();
      int splitIndex=splits.get(dp).lastIndexOf(value);
      if (splitIndex == -1)       throw new Error("String_Node_Str");
      int newSplitIndex=splitIndex + 1;
      if (newSplitIndex < splits.get(dp).size()) {
        DoubleMinValue min=new DoubleMinValue(splits.get(dp).get(newSplitIndex));
        DatatypeSomeRestriction newDSR=new DatatypeSomeRestriction(dp,min);
        refinements.add(newDSR);
      }
    }
  }
 else   if (description instanceof StringValueRestriction) {
    StringValueRestriction svr=(StringValueRestriction)description;
    DatatypeProperty dp=svr.getRestrictedPropertyExpression();
    Set<DatatypeProperty> subDPs=reasoner.getSubProperties(dp);
    for (    DatatypeProperty subDP : subDPs) {
      refinements.add(new StringValueRestriction(subDP,svr.getStringValue()));
    }
  }
  if (!(description instanceof Thing) && !(description instanceof Nothing) && !(description instanceof ObjectAllRestriction && description.getChild(0) instanceof Nothing)) {
    int topRefLength=maxLength - description.getLength() - 1;
    if (currDomain instanceof Thing) {
      if (topRefLength > topRefinementsLength)       computeTopRefinements(topRefLength);
    }
 else     if (topRefLength > topARefinementsLength.get(currDomain))     computeTopRefinements(topRefLength,(NamedClass)currDomain);
    if (topRefLength > 0) {
      Set<Description> topRefs;
      if (currDomain instanceof Thing)       topRefs=topRefinementsCumulative.get(topRefLength);
 else       topRefs=topARefinementsCumulative.get(currDomain).get(topRefLength);
      for (      Description c : topRefs) {
        boolean skip=false;
        if (applyAllFilter) {
          if (c instanceof ObjectAllRestriction) {
            for (            Description child : description.getChildren()) {
              if (child instanceof ObjectAllRestriction) {
                ObjectPropertyExpression r1=((ObjectAllRestriction)c).getRole();
                ObjectPropertyExpression r2=((ObjectAllRestriction)child).getRole();
                if (r1.toString().equals(r2.toString()))                 skip=true;
              }
            }
          }
        }
        if (disjointChecks && c instanceof NamedClass && description instanceof NamedClass&& isDisjoint(description,c)) {
          skip=true;
        }
        if (!skip) {
          Intersection mc=new Intersection();
          mc.addChild(description);
          mc.addChild(c);
          ConceptTransformation.cleanConceptNonRecursive(mc);
          ConceptTransformation.transformToOrderedNegationNormalFormNonRecursive(mc,conceptComparator);
          if (checkIntersection(mc))           refinements.add(mc);
        }
      }
    }
  }
  return refinements;
}