Program: 29917
Project: 29917
Buggy source:
public Query visit(Stack<String> links,Query query){
  if (query instanceof BinaryQuery) {
    BinaryQuery bq=(BinaryQuery)query;
    if (bq.field != null) {
      if (bq.field.equals("String_Node_Str")) {
        if (bq.operation.equals(BinaryQuery.CONTAINS)) {
          throw new IllegalArgumentException("String_Node_Str");
        }
        IdQuery id=new IdQuery(bq.value);
        return id;
      }
      if (BinaryQuery.EQUALS.equals(bq.operation)) {
        if (tableDefinition != null) {
          if (!links.empty()) {
            ArrayList<String> path=QueryUtils.GetLinkPath(links);
            path.add(bq.field);
            if (QueryUtils.IsLink(path,tableDefinition)) {
              LinkIdQuery li=new LinkIdQuery(LinkQuery.ANY,bq.field,bq.value);
              return li;
            }
          }
 else {
            if (tableDefinition.isLinkField(bq.field)) {
              LinkIdQuery li=new LinkIdQuery(LinkQuery.ANY,bq.field,bq.value);
              return li;
            }
          }
        }
      }
    }
  }
  if (query instanceof LinkQuery || query instanceof TransitiveLinkQuery) {
    if (tableDefinition != null) {
      ArrayList<String> path=new ArrayList<String>();
      if (!links.empty()) {
        path=QueryUtils.GetLinkPath(links);
      }
      String linkName="String_Node_Str";
      if (query instanceof LinkQuery) {
        linkName=((LinkQuery)query).link;
      }
 else {
        linkName=((TransitiveLinkQuery)query).link;
      }
      path.add(linkName);
switch (QueryUtils.GetFieldType(path,tableDefinition)) {
case Link:
        break;
case Group:
      FieldDefinition groupfield=QueryUtils.GetField(path,tableDefinition);
    ArrayList<String> nestedLinks=QueryUtils.GetNestedFields(groupfield);
  if (nestedLinks.size() == 0) {
    throw new IllegalArgumentException("String_Node_Str" + groupfield.getName() + "String_Node_Str"+ QueryUtils.LinkName(path)+ "String_Node_Str");
  }
break;
default :
throw new IllegalArgumentException("String_Node_Str" + linkName + "String_Node_Str"+ QueryUtils.LinkName(path)+ "String_Node_Str");
}
}
}
if (query instanceof LinkIdQuery) {
if (tableDefinition != null) {
LinkIdQuery q=(LinkIdQuery)query;
ArrayList<String> path=new ArrayList<String>();
if (!links.empty()) {
path=QueryUtils.GetLinkPath(links);
}
path.add(q.link);
if (!QueryUtils.IsLink(path,tableDefinition)) {
BinaryQuery bq=new BinaryQuery(BinaryQuery.EQUALS,q.link,q.id);
return bq;
}
}
}
return query;
}

Fixed version (ground truth):
public Query visit(Stack<String> links,Query query){
  if (query instanceof BinaryQuery) {
    BinaryQuery bq=(BinaryQuery)query;
    if (bq.field != null) {
      if (bq.field.equals("String_Node_Str")) {
        if (bq.operation.equals(BinaryQuery.CONTAINS)) {
          throw new IllegalArgumentException("String_Node_Str");
        }
        IdQuery id=new IdQuery(bq.value);
        return id;
      }
      if (BinaryQuery.EQUALS.equals(bq.operation)) {
        if (tableDefinition != null) {
          if (!links.empty()) {
            ArrayList<String> path=QueryUtils.GetLinkPath(links);
            path.add(bq.field);
            if (QueryUtils.IsLink(path,tableDefinition)) {
              LinkIdQuery li=new LinkIdQuery(LinkQuery.ANY,bq.field,bq.value);
              return li;
            }
          }
 else {
            FieldDefinition fd=tableDefinition.getFieldDef(bq.field);
            if (tableDefinition.isLinkField(bq.field) || (fd != null && fd.isXLinkField())) {
              LinkIdQuery li=new LinkIdQuery(LinkQuery.ANY,bq.field,bq.value);
              return li;
            }
          }
        }
      }
    }
  }
  if (query instanceof LinkQuery || query instanceof TransitiveLinkQuery) {
    if (tableDefinition != null) {
      ArrayList<String> path=new ArrayList<String>();
      if (!links.empty()) {
        path=QueryUtils.GetLinkPath(links);
      }
      String linkName="String_Node_Str";
      if (query instanceof LinkQuery) {
        linkName=((LinkQuery)query).link;
      }
 else {
        linkName=((TransitiveLinkQuery)query).link;
      }
      path.add(linkName);
switch (QueryUtils.GetFieldType(path,tableDefinition)) {
case Link:
        break;
case Group:
      FieldDefinition groupfield=QueryUtils.GetField(path,tableDefinition);
    ArrayList<String> nestedLinks=QueryUtils.GetNestedFields(groupfield);
  if (nestedLinks.size() == 0) {
    throw new IllegalArgumentException("String_Node_Str" + groupfield.getName() + "String_Node_Str"+ QueryUtils.LinkName(path)+ "String_Node_Str");
  }
break;
default :
throw new IllegalArgumentException("String_Node_Str" + linkName + "String_Node_Str"+ QueryUtils.LinkName(path)+ "String_Node_Str");
}
}
}
if (query instanceof LinkIdQuery) {
if (tableDefinition != null) {
LinkIdQuery q=(LinkIdQuery)query;
ArrayList<String> path=new ArrayList<String>();
if (!links.empty()) {
path=QueryUtils.GetLinkPath(links);
}
path.add(q.link);
if (!QueryUtils.IsLink(path,tableDefinition)) {
BinaryQuery bq=new BinaryQuery(BinaryQuery.EQUALS,q.link,q.id);
return bq;
}
}
}
return query;
}