Program: 66695
Project: 66695
Buggy source:
/** 
 * Specify the item that is to be returned in the query result. Replaces the previously specified selection, if any.
 * @param selection selection specifying the item that is to be returned in the query result
 * @return the modified query
 */
public CriteriaQuery<T> select(Selection<? extends T> selection){
  findRootAndParameters(selection);
  this.selection=(SelectionImpl)selection;
  if (selection.isCompoundSelection()) {
    for (    Selection select : selection.getCompoundSelectionItems()) {
      if (((InternalSelection)select).isFrom()) {
        ((FromImpl)select).isLeaf=false;
      }
    }
    if (selection.getJavaType().equals(Tuple.class)) {
      this.queryResult=ResultType.TUPLE;
      this.queryType=Tuple.class;
    }
 else     if (((InternalSelection)selection).isConstructor()) {
      if (!findConstructor(this.selection.getJavaType(),selection.getCompoundSelectionItems().toArray(new Selection[selection.getCompoundSelectionItems().size()]))) {
        Object[] selections=new Object[selection.getCompoundSelectionItems().size()];
        Object[] params=new Object[2];
        params[0]=this.queryType;
        int count=0;
        for (        Selection select : selection.getCompoundSelectionItems()) {
          selections[++count]=select.getJavaType();
        }
        params[1]=params;
        throw new IllegalArgumentException(ExceptionLocalization.buildMessage("String_Node_Str",params));
      }
      this.queryResult=ResultType.CONSTRUCTOR;
      this.queryType=selection.getJavaType();
    }
 else {
      this.queryResult=ResultType.OBJECT_ARRAY;
      this.queryType=ClassConstants.AOBJECT;
    }
  }
 else {
    this.queryType=selection.getJavaType();
    TypeImpl type=((MetamodelImpl)this.metamodel).getType(this.queryType);
    if (type != null && type.getPersistenceType().equals(PersistenceType.ENTITY)) {
      this.queryResult=ResultType.ENTITY;
      ((FromImpl)selection).isLeaf=false;
    }
 else {
      this.queryResult=ResultType.OTHER;
    }
  }
  return this;
}

Fixed version (ground truth):
/** 
 * Specify the item that is to be returned in the query result. Replaces the previously specified selection, if any.
 * @param selection selection specifying the item that is to be returned in the query result
 * @return the modified query
 */
public CriteriaQuery<T> select(Selection<? extends T> selection){
  findRootAndParameters(selection);
  this.selection=(SelectionImpl)selection;
  if (selection.isCompoundSelection()) {
    for (    Selection select : selection.getCompoundSelectionItems()) {
      if (((InternalSelection)select).isFrom()) {
        ((FromImpl)select).isLeaf=false;
      }
    }
    if (selection.getJavaType().equals(Tuple.class)) {
      this.queryResult=ResultType.TUPLE;
      this.queryType=Tuple.class;
    }
 else     if (((InternalSelection)selection).isConstructor()) {
      Selection[] selectArray=selection.getCompoundSelectionItems().toArray(new Selection[selection.getCompoundSelectionItems().size()]);
      populateAndSetConstructorSelection((ConstructorSelectionImpl)selection,this.selection.getJavaType(),selectArray);
      this.queryType=selection.getJavaType();
    }
 else {
      this.queryResult=ResultType.OBJECT_ARRAY;
      this.queryType=ClassConstants.AOBJECT;
    }
  }
 else {
    this.queryType=selection.getJavaType();
    TypeImpl type=((MetamodelImpl)this.metamodel).getType(this.queryType);
    if (type != null && type.getPersistenceType().equals(PersistenceType.ENTITY)) {
      this.queryResult=ResultType.ENTITY;
      ((FromImpl)selection).isLeaf=false;
    }
 else {
      this.queryResult=ResultType.OTHER;
    }
  }
  return this;
}