Program: 72079
Project: 72079
Buggy source:
protected void formalize(DimensionType[] columns,int tableWidth){
  ArrayList percentageList=new ArrayList();
  ArrayList unsetList=new ArrayList();
  double total=0.0f;
  int fixedLength=0;
  for (int i=0; i < columns.length; i++) {
    if (columns[i] == null) {
      unsetList.add(new Integer(i));
    }
 else     if (EngineIRConstants.UNITS_PERCENTAGE.equals(columns[i].getUnits())) {
      percentageList.add(new Integer(i));
      total+=columns[i].getMeasure();
    }
 else     if (EngineIRConstants.UNITS_EM.equals(columns[i].getUnits()) || EngineIRConstants.UNITS_EX.equals(columns[i].getUnits())) {
      int len=TableLayout.this.getDimensionValue(columns[i],PropertyUtil.getDimensionValue(table.getComputedStyle().getProperty(StyleConstants.STYLE_FONT_SIZE)));
      fixedLength+=len;
    }
 else {
      int len=TableLayout.this.getDimensionValue(columns[i],tableWidth);
      fixedLength+=len;
    }
  }
  if (fixedLength >= tableWidth) {
    for (int i=0; i < unsetList.size(); i++) {
      Integer index=(Integer)unsetList.get(i);
      columns[index.intValue()]=new DimensionType(0d,EngineIRConstants.UNITS_PT);
    }
    for (int i=0; i < percentageList.size(); i++) {
      Integer index=(Integer)percentageList.get(i);
      columns[index.intValue()]=new DimensionType(0d,EngineIRConstants.UNITS_PT);
    }
  }
 else {
    float leftPercentage=(((float)(tableWidth - fixedLength)) / tableWidth) * 100.0f;
    if (unsetList.isEmpty()) {
      double ratio=leftPercentage / total;
      for (int i=0; i < percentageList.size(); i++) {
        Integer index=(Integer)percentageList.get(i);
        columns[index.intValue()]=new DimensionType(columns[index.intValue()].getMeasure() * ratio,columns[index.intValue()].getUnits());
      }
    }
 else {
      if (total < leftPercentage) {
        double delta=leftPercentage - total;
        for (int i=0; i < unsetList.size(); i++) {
          Integer index=(Integer)unsetList.get(i);
          columns[index.intValue()]=new DimensionType(delta / (double)unsetList.size(),EngineIRConstants.UNITS_PERCENTAGE);
        }
      }
 else {
        double ratio=leftPercentage / total;
        for (int i=0; i < unsetList.size(); i++) {
          Integer index=(Integer)unsetList.get(i);
          columns[index.intValue()]=new DimensionType(0d,EngineIRConstants.UNITS_PT);
        }
        for (int i=0; i < percentageList.size(); i++) {
          Integer index=(Integer)percentageList.get(i);
          columns[index.intValue()]=new DimensionType(columns[index.intValue()].getMeasure() * ratio,columns[index.intValue()].getUnits());
        }
      }
    }
  }
}

Fixed version (ground truth):
protected int[] formalize(DimensionType[] columns,int tableWidth){
  ArrayList percentageList=new ArrayList();
  ArrayList unsetList=new ArrayList();
  int[] resolvedColumnWidth=new int[columns.length];
  double total=0.0f;
  int fixedLength=0;
  for (int i=0; i < columns.length; i++) {
    if (columns[i] == null) {
      unsetList.add(new Integer(i));
    }
 else     if (EngineIRConstants.UNITS_PERCENTAGE.equals(columns[i].getUnits())) {
      percentageList.add(new Integer(i));
      total+=columns[i].getMeasure();
    }
 else     if (EngineIRConstants.UNITS_EM.equals(columns[i].getUnits()) || EngineIRConstants.UNITS_EX.equals(columns[i].getUnits())) {
      int len=TableLayout.this.getDimensionValue(columns[i],PropertyUtil.getDimensionValue(table.getComputedStyle().getProperty(StyleConstants.STYLE_FONT_SIZE)));
      resolvedColumnWidth[i]=len;
      fixedLength+=len;
    }
 else {
      int len=TableLayout.this.getDimensionValue(columns[i],tableWidth);
      resolvedColumnWidth[i]=len;
      fixedLength+=len;
    }
  }
  if (unsetList.isEmpty() && percentageList.isEmpty()) {
    return resolvedColumnWidth;
  }
  if (fixedLength >= tableWidth) {
    for (int i=0; i < unsetList.size(); i++) {
      Integer index=(Integer)unsetList.get(i);
      columns[index.intValue()]=new DimensionType(0d,EngineIRConstants.UNITS_PT);
      resolvedColumnWidth[index.intValue()]=0;
    }
    for (int i=0; i < percentageList.size(); i++) {
      Integer index=(Integer)percentageList.get(i);
      columns[index.intValue()]=new DimensionType(0d,EngineIRConstants.UNITS_PT);
      resolvedColumnWidth[index.intValue()]=0;
    }
  }
 else {
    float leftPercentage=(((float)(tableWidth - fixedLength)) / tableWidth) * 100.0f;
    if (unsetList.isEmpty()) {
      double ratio=leftPercentage / total;
      for (int i=0; i < percentageList.size(); i++) {
        Integer index=(Integer)percentageList.get(i);
        columns[index.intValue()]=new DimensionType(columns[index.intValue()].getMeasure() * ratio,columns[index.intValue()].getUnits());
        resolvedColumnWidth[index.intValue()]=TableLayout.this.getDimensionValue(columns[index.intValue()],tableWidth);
      }
    }
 else {
      if (total < leftPercentage) {
        double delta=leftPercentage - total;
        for (int i=0; i < unsetList.size(); i++) {
          Integer index=(Integer)unsetList.get(i);
          columns[index.intValue()]=new DimensionType(delta / (double)unsetList.size(),EngineIRConstants.UNITS_PERCENTAGE);
          resolvedColumnWidth[index.intValue()]=TableLayout.this.getDimensionValue(columns[index.intValue()],tableWidth);
        }
      }
 else {
        double ratio=leftPercentage / total;
        for (int i=0; i < unsetList.size(); i++) {
          Integer index=(Integer)unsetList.get(i);
          columns[index.intValue()]=new DimensionType(0d,EngineIRConstants.UNITS_PT);
          resolvedColumnWidth[index.intValue()]=TableLayout.this.getDimensionValue(columns[index.intValue()]);
        }
        for (int i=0; i < percentageList.size(); i++) {
          Integer index=(Integer)percentageList.get(i);
          columns[index.intValue()]=new DimensionType(columns[index.intValue()].getMeasure() * ratio,columns[index.intValue()].getUnits());
          resolvedColumnWidth[index.intValue()]=TableLayout.this.getDimensionValue(columns[index.intValue()],tableWidth);
        }
      }
    }
  }
  return resolvedColumnWidth;
}