Program: 51467
Project: 51467
Buggy source:
List crossJoin(List list1,List list2,Evaluator evaluator){
  if (list1.isEmpty() || list2.isEmpty()) {
    return Collections.EMPTY_LIST;
  }
  long size=(long)list1.size() * (long)list2.size();
  int resultLimit=MondrianProperties.instance().ResultLimit.get();
  if (size > 1000 && evaluator.isNonEmpty()) {
    final int missCount=evaluator.getMissCount();
    list1=nonEmptyList(evaluator,list1);
    list2=nonEmptyList(evaluator,list2);
    size=(long)list1.size() * (long)list2.size();
    final int missCount2=evaluator.getMissCount();
    if (missCount2 > missCount && size > 1000) {
      return Collections.EMPTY_LIST;
    }
  }
  if (resultLimit > 0 && resultLimit < size) {
    throw MondrianResource.instance().LimitExceededDuringCrossjoin.ex(new Long(size),new Long(resultLimit));
  }
  boolean neitherSideIsTuple=true;
  int arity0=1;
  int arity1=1;
  if (list1.get(0) instanceof Member[]) {
    arity0=((Member[])list1.get(0)).length;
    neitherSideIsTuple=false;
  }
  if (list2.get(0) instanceof Member[]) {
    arity1=((Member[])list2.get(0)).length;
    neitherSideIsTuple=false;
  }
  List result=new ArrayList();
  if (neitherSideIsTuple) {
    for (int i=0, m=list1.size(); i < m; i++) {
      Member o0=(Member)list1.get(i);
      for (int j=0, n=list2.size(); j < n; j++) {
        Member o1=(Member)list2.get(j);
        result.add(new Member[]{o0,o1});
      }
    }
  }
 else {
    Member[] row=new Member[arity0 + arity1];
    for (int i=0, m=list1.size(); i < m; i++) {
      int x=0;
      Object o0=list1.get(i);
      if (o0 instanceof Member) {
        row[x++]=(Member)o0;
      }
 else {
        assertTrue(o0 instanceof Member[]);
        final Member[] members=(Member[])o0;
        for (int k=0; k < members.length; k++) {
          row[x++]=members[k];
        }
      }
      for (int j=0, n=list2.size(); j < n; j++) {
        Object o1=list2.get(j);
        if (o1 instanceof Member) {
          row[x++]=(Member)o1;
        }
 else {
          assertTrue(o1 instanceof Member[]);
          final Member[] members=(Member[])o1;
          for (int k=0; k < members.length; k++) {
            row[x++]=members[k];
          }
        }
        result.add(row.clone());
        x=arity0;
      }
    }
  }
  return result;
}

Fixed version (ground truth):
List crossJoin(List list1,List list2,Evaluator evaluator){
  if (list1.isEmpty() || list2.isEmpty()) {
    return Collections.EMPTY_LIST;
  }
  long size=(long)list1.size() * (long)list2.size();
  int resultLimit=MondrianProperties.instance().ResultLimit.get();
  if (size > 1000 && evaluator.isNonEmpty()) {
    final int missCount=evaluator.getMissCount();
    list1=nonEmptyList(evaluator,list1);
    list2=nonEmptyList(evaluator,list2);
    size=(long)list1.size() * (long)list2.size();
    if (size == 0)     return Collections.EMPTY_LIST;
    final int missCount2=evaluator.getMissCount();
    if (missCount2 > missCount && size > 1000) {
      return Collections.EMPTY_LIST;
    }
  }
  if (resultLimit > 0 && resultLimit < size) {
    throw MondrianResource.instance().LimitExceededDuringCrossjoin.ex(new Long(size),new Long(resultLimit));
  }
  boolean neitherSideIsTuple=true;
  int arity0=1;
  int arity1=1;
  if (list1.get(0) instanceof Member[]) {
    arity0=((Member[])list1.get(0)).length;
    neitherSideIsTuple=false;
  }
  if (list2.get(0) instanceof Member[]) {
    arity1=((Member[])list2.get(0)).length;
    neitherSideIsTuple=false;
  }
  List result=new ArrayList();
  if (neitherSideIsTuple) {
    for (int i=0, m=list1.size(); i < m; i++) {
      Member o0=(Member)list1.get(i);
      for (int j=0, n=list2.size(); j < n; j++) {
        Member o1=(Member)list2.get(j);
        result.add(new Member[]{o0,o1});
      }
    }
  }
 else {
    Member[] row=new Member[arity0 + arity1];
    for (int i=0, m=list1.size(); i < m; i++) {
      int x=0;
      Object o0=list1.get(i);
      if (o0 instanceof Member) {
        row[x++]=(Member)o0;
      }
 else {
        assertTrue(o0 instanceof Member[]);
        final Member[] members=(Member[])o0;
        for (int k=0; k < members.length; k++) {
          row[x++]=members[k];
        }
      }
      for (int j=0, n=list2.size(); j < n; j++) {
        Object o1=list2.get(j);
        if (o1 instanceof Member) {
          row[x++]=(Member)o1;
        }
 else {
          assertTrue(o1 instanceof Member[]);
          final Member[] members=(Member[])o1;
          for (int k=0; k < members.length; k++) {
            row[x++]=members[k];
          }
        }
        result.add(row.clone());
        x=arity0;
      }
    }
  }
  return result;
}