Program: 168872
Project: 168872
Buggy source:
public ObjectBuilder<?> createObjectBuilder(ViewType<?> viewType,MappingConstructor<?> mappingConstructor,String viewName,String entityViewRoot,FullQueryBuilder<?,?> criteriaBuilder,EntityViewConfiguration configuration,int offset,boolean registerMacro){
  Class<?> entityClazz;
  Set<Root> roots=criteriaBuilder.getRoots();
  Map.Entry<Root,String> rootEntry=findRoot(roots,entityViewRoot);
  Root root=rootEntry.getKey();
  entityViewRoot=rootEntry.getValue();
  ExpressionFactory ef=criteriaBuilder.getService(ExpressionFactory.class);
  if (entityViewRoot != null) {
    if (root.getAlias().equals(entityViewRoot)) {
      entityClazz=root.getType();
    }
 else {
      PathTargetResolvingExpressionVisitor visitor=new PathTargetResolvingExpressionVisitor(metamodel.getEntityMetamodel(),root.getType());
      ef.createPathExpression(entityViewRoot.substring(root.getAlias().length() + 1)).accept(visitor);
      Collection<Class<?>> possibleTypes=visitor.getPossibleTargets().values();
      if (possibleTypes.size() > 1) {
        throw new IllegalArgumentException("String_Node_Str" + entityViewRoot + "String_Node_Str"+ root.getType()+ "String_Node_Str");
      }
      entityClazz=possibleTypes.iterator().next();
      if (entityClazz == null) {
        throw new IllegalArgumentException("String_Node_Str" + entityViewRoot + "String_Node_Str"+ root.getType()+ "String_Node_Str");
      }
    }
  }
 else {
    entityClazz=root.getType();
    entityViewRoot=root.getAlias();
  }
  if (!viewType.getEntityClass().isAssignableFrom(entityClazz)) {
    throw new IllegalArgumentException("String_Node_Str" + viewType.getEntityClass().getName() + "String_Node_Str"+ criteriaBuilder.getResultType().getName()+ "String_Node_Str");
  }
  if (registerMacro) {
    criteriaBuilder.registerMacro("String_Node_Str",new ViewRootJpqlMacro(entityViewRoot));
  }
  return getTemplate(ef,viewType,mappingConstructor,viewName,entityViewRoot,offset).createObjectBuilder(criteriaBuilder,configuration.getOptionalParameters(),configuration);
}

Fixed version (ground truth):
public ObjectBuilder<?> createObjectBuilder(ViewType<?> viewType,MappingConstructor<?> mappingConstructor,String viewName,String entityViewRoot,FullQueryBuilder<?,?> criteriaBuilder,EntityViewConfiguration configuration,int offset,boolean registerMacro){
  Class<?> entityClazz;
  Map.Entry<From,String> rootEntry=findRoot(criteriaBuilder,entityViewRoot);
  From root=rootEntry.getKey();
  entityViewRoot=rootEntry.getValue();
  ExpressionFactory ef=criteriaBuilder.getService(ExpressionFactory.class);
  if (entityViewRoot != null) {
    if (root.getAlias().equals(entityViewRoot)) {
      entityClazz=root.getType();
    }
 else {
      PathTargetResolvingExpressionVisitor visitor=new PathTargetResolvingExpressionVisitor(metamodel.getEntityMetamodel(),root.getType());
      ef.createPathExpression(entityViewRoot.substring(root.getAlias().length() + 1)).accept(visitor);
      Collection<Class<?>> possibleTypes=visitor.getPossibleTargets().values();
      if (possibleTypes.size() > 1) {
        throw new IllegalArgumentException("String_Node_Str" + entityViewRoot + "String_Node_Str"+ root.getType()+ "String_Node_Str");
      }
      entityClazz=possibleTypes.iterator().next();
      if (entityClazz == null) {
        throw new IllegalArgumentException("String_Node_Str" + entityViewRoot + "String_Node_Str"+ root.getType()+ "String_Node_Str");
      }
    }
  }
 else {
    entityClazz=root.getType();
    entityViewRoot=root.getAlias();
  }
  if (!viewType.getEntityClass().isAssignableFrom(entityClazz)) {
    throw new IllegalArgumentException("String_Node_Str" + viewType.getEntityClass().getName() + "String_Node_Str"+ criteriaBuilder.getResultType().getName()+ "String_Node_Str");
  }
  if (registerMacro) {
    criteriaBuilder.registerMacro("String_Node_Str",new ViewRootJpqlMacro(entityViewRoot));
  }
  return getTemplate(ef,viewType,mappingConstructor,viewName,entityViewRoot,offset).createObjectBuilder(criteriaBuilder,configuration.getOptionalParameters(),configuration);
}