Program: 66692
Project: 66692
Buggy source:
/** 
 * INTERNAL: Looks up mapping for attribute during preExecute of ReportQuery
 */
public void initialize(ReportQuery query) throws QueryException {
  int size=getReportItems().size();
  List mappings=new ArrayList();
  for (int index=0; index < size; index++) {
    ReportItem item=(ReportItem)reportItems.get(index);
    item.initialize(query);
    mappings.add(item.getMapping());
  }
  setConstructorMappings(mappings);
  int numberOfItems=getReportItems().size();
  if (getConstructorArgTypes() == null) {
    setConstructorArgTypes(new Class[numberOfItems]);
  }
  Class[] constructorArgTypes=getConstructorArgTypes();
  for (int index=0; index < numberOfItems; index++) {
    if (constructorArgTypes[index] == null) {
      ReportItem argumentItem=(ReportItem)getReportItems().get(index);
      if (mappings.get(index) != null) {
        DatabaseMapping mapping=(DatabaseMapping)constructorMappings.get(index);
        if (argumentItem.getAttributeExpression() != null && argumentItem.getAttributeExpression().isMapEntryExpression()) {
          if (((MapEntryExpression)argumentItem.getAttributeExpression()).shouldReturnMapEntry()) {
            constructorArgTypes[index]=Map.Entry.class;
          }
 else {
            constructorArgTypes[index]=(Class)((CollectionMapping)mapping).getContainerPolicy().getKeyType();
          }
        }
 else {
          constructorArgTypes[index]=mapping.getAttributeClassification();
        }
      }
 else       if (argumentItem.getResultType() != null) {
        constructorArgTypes[index]=argumentItem.getResultType();
      }
 else       if (argumentItem.getDescriptor() != null) {
        constructorArgTypes[index]=argumentItem.getDescriptor().getJavaClass();
      }
 else       if (argumentItem.getAttributeExpression() != null && argumentItem.getAttributeExpression().isConstantExpression()) {
        constructorArgTypes[index]=((ConstantExpression)argumentItem.getAttributeExpression()).getValue().getClass();
      }
 else {
        constructorArgTypes[index]=ClassConstants.OBJECT;
      }
    }
  }
  try {
    Constructor constructor=null;
    if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
      try {
        constructor=(Constructor)AccessController.doPrivileged(new PrivilegedGetConstructorFor(getResultType(),constructorArgTypes,true));
      }
 catch (      PrivilegedActionException exception) {
        throw QueryException.exceptionWhileUsingConstructorExpression(exception.getException(),query);
      }
    }
 else {
      constructor=PrivilegedAccessHelper.getConstructorFor(getResultType(),constructorArgTypes,true);
    }
    setConstructor(constructor);
  }
 catch (  NoSuchMethodException exception) {
    throw QueryException.exceptionWhileUsingConstructorExpression(exception,query);
  }
}

Fixed version (ground truth):
/** 
 * INTERNAL: Looks up mapping for attribute during preExecute of ReportQuery
 */
public void initialize(ReportQuery query) throws QueryException {
  int size=getReportItems().size();
  List mappings=new ArrayList();
  for (int index=0; index < size; index++) {
    ReportItem item=(ReportItem)reportItems.get(index);
    item.initialize(query);
    mappings.add(item.getMapping());
  }
  setConstructorMappings(mappings);
  int numberOfItems=getReportItems().size();
  if (getConstructorArgTypes() == null) {
    setConstructorArgTypes(new Class[numberOfItems]);
  }
  Class[] constructorArgTypes=getConstructorArgTypes();
  for (int index=0; index < numberOfItems; index++) {
    if (constructorArgTypes[index] == null) {
      ReportItem argumentItem=(ReportItem)getReportItems().get(index);
      if (mappings.get(index) != null) {
        DatabaseMapping mapping=(DatabaseMapping)constructorMappings.get(index);
        if (argumentItem.getAttributeExpression() != null && argumentItem.getAttributeExpression().isMapEntryExpression()) {
          if (((MapEntryExpression)argumentItem.getAttributeExpression()).shouldReturnMapEntry()) {
            constructorArgTypes[index]=Map.Entry.class;
          }
 else {
            constructorArgTypes[index]=(Class)((CollectionMapping)mapping).getContainerPolicy().getKeyType();
          }
        }
 else {
          constructorArgTypes[index]=mapping.getAttributeClassification();
        }
      }
 else       if (argumentItem.getResultType() != null) {
        constructorArgTypes[index]=argumentItem.getResultType();
      }
 else       if (argumentItem.getDescriptor() != null) {
        constructorArgTypes[index]=argumentItem.getDescriptor().getJavaClass();
      }
 else       if (argumentItem.getAttributeExpression() != null && argumentItem.getAttributeExpression().isConstantExpression()) {
        constructorArgTypes[index]=((ConstantExpression)argumentItem.getAttributeExpression()).getValue().getClass();
      }
 else {
        constructorArgTypes[index]=ClassConstants.OBJECT;
      }
    }
  }
  if (getConstructor() == null) {
    try {
      Constructor constructor=null;
      if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
        try {
          constructor=(Constructor)AccessController.doPrivileged(new PrivilegedGetConstructorFor(getResultType(),constructorArgTypes,true));
        }
 catch (        PrivilegedActionException exception) {
          throw QueryException.exceptionWhileUsingConstructorExpression(exception.getException(),query);
        }
      }
 else {
        constructor=PrivilegedAccessHelper.getConstructorFor(getResultType(),constructorArgTypes,true);
      }
      setConstructor(constructor);
    }
 catch (    NoSuchMethodException exception) {
      throw QueryException.exceptionWhileUsingConstructorExpression(exception,query);
    }
  }
}