Program: 76123
Project: 76123
Buggy source:
private List buildMeasures(){
  List retValue=new ArrayList();
  CrosstabReportItemHandle crosstab=getCrosstabReportItemHandle();
  int count=crosstab.getMeasureCount();
  for (int i=0; i < count; i++) {
    MeasureViewHandle measureHandle=crosstab.getMeasure(i);
    CrosstabCellHandle handle=measureHandle.getCell();
    CrosstabCellAdapter adapter=factory.createCrosstabCellAdapter(ICrosstabCellAdapterFactory.CELL_MEASURE,handle,1,-1,i + 1,-1,isVertical());
    retValue.add(adapter);
    int addregationCellCount=measureHandle.getAggregationCount();
    for (int j=0; j < addregationCellCount; j++) {
      AggregationCellHandle cell=measureHandle.getAggregationCell(j);
      LevelViewHandle levelViewHandle=cell.getLevelView(getWorkArea(ICrosstabConstants.COLUMN_AXIS_TYPE));
      int measureCount=count;
      Integer temp;
      List measuresHandles;
      int position;
      if (levelViewHandle == null) {
        temp=(Integer)map.get(getWorkArea(COLUMNAREA_COLUMN));
        measuresHandles=crosstab.getAggregationMeasures(getWorkArea(ICrosstabConstants.COLUMN_AXIS_TYPE));
      }
 else {
        temp=(Integer)map.get(levelViewHandle);
        measuresHandles=levelViewHandle.getAggregationMeasures();
      }
      if (temp == null) {
        throw new RuntimeException("String_Node_Str");
      }
      measureCount=measuresHandles.size();
      position=measuresHandles.indexOf(measureHandle);
      if (temp.intValue() <= count) {
        measureCount=count;
        position=i;
      }
      int column=temp.intValue() - (measureCount - position) + 1;
      levelViewHandle=cell.getLevelView(getWorkArea(ICrosstabConstants.ROW_AXIS_TYPE));
      if (levelViewHandle == null) {
        temp=(Integer)map.get(getWorkArea(ROWAREA_ROW));
      }
 else {
        temp=(Integer)map.get(levelViewHandle);
      }
      if (temp == null) {
        throw new RuntimeException("String_Node_Str");
      }
      int row=temp.intValue();
      CrosstabCellAdapter aggregationCell=factory.createCrosstabCellAdapter(ICrosstabCellAdapterFactory.CELL_MEASURE_AGGREGATION,cell,row,1,column,1,isVertical());
      retValue.add(aggregationCell);
    }
  }
  if (retValue.isEmpty()) {
    CrosstabCellAdapter first=factory.createCrosstabCellAdapter(ICrosstabCellAdapterFactory.CELL_MEASURE_VIRTUAL,null,1,-1,1,-1,false);
    retValue.add(first);
  }
  return retValue;
}

Fixed version (ground truth):
private List buildMeasures(){
  List retValue=new ArrayList();
  CrosstabReportItemHandle crosstab=getCrosstabReportItemHandle();
  int count=crosstab.getMeasureCount();
  for (int i=0; i < count; i++) {
    MeasureViewHandle measureHandle=crosstab.getMeasure(i);
    CrosstabCellHandle handle=measureHandle.getCell();
    CrosstabCellAdapter adapter=factory.createCrosstabCellAdapter(ICrosstabCellAdapterFactory.CELL_MEASURE,handle,1,-1,i + 1,-1,isVertical());
    retValue.add(adapter);
    int addregationCellCount=measureHandle.getAggregationCount();
    for (int j=0; j < addregationCellCount; j++) {
      AggregationCellHandle cell=measureHandle.getAggregationCell(j);
      LevelViewHandle levelViewHandle=cell.getLevelView(getWorkArea(ICrosstabConstants.COLUMN_AXIS_TYPE));
      int measureCount=count;
      Integer temp;
      List measuresHandles;
      int position;
      if (levelViewHandle == null) {
        temp=(Integer)map.get(getWorkArea(COLUMNAREA_COLUMN));
        measuresHandles=crosstab.getAggregationMeasures(getWorkArea(ICrosstabConstants.COLUMN_AXIS_TYPE));
      }
 else {
        temp=(Integer)map.get(levelViewHandle);
        measuresHandles=levelViewHandle.getAggregationMeasures();
      }
      if (temp == null) {
        throw new RuntimeException("String_Node_Str");
      }
      measureCount=measuresHandles.size();
      position=measuresHandles.indexOf(measureHandle);
      if (temp.intValue() <= count) {
        measureCount=count;
        position=i;
      }
      int tempPosition=temp.intValue() >= measureCount ? temp.intValue() : measureCount;
      int column=tempPosition - (measureCount - position) + 1;
      levelViewHandle=cell.getLevelView(getWorkArea(ICrosstabConstants.ROW_AXIS_TYPE));
      if (levelViewHandle == null) {
        temp=(Integer)map.get(getWorkArea(ROWAREA_ROW));
      }
 else {
        temp=(Integer)map.get(levelViewHandle);
      }
      if (temp == null) {
        throw new RuntimeException("String_Node_Str");
      }
      int row=temp.intValue();
      CrosstabCellAdapter aggregationCell=factory.createCrosstabCellAdapter(ICrosstabCellAdapterFactory.CELL_MEASURE_AGGREGATION,cell,row,1,column,1,isVertical());
      retValue.add(aggregationCell);
    }
  }
  if (retValue.isEmpty()) {
    CrosstabCellAdapter first=factory.createCrosstabCellAdapter(ICrosstabCellAdapterFactory.CELL_MEASURE_VIRTUAL,null,1,-1,1,-1,false);
    retValue.add(first);
  }
  return retValue;
}