Program: 72686
Project: 72686
Buggy source:
/** 
 * @param g
 * @param rowIndex
 * @param colIndex
 * @param data [style][width][color][rowIndex][colIndex].
 */
private void drawTop(Graphics g,int rowIndex,int colIndex,int x,int y,int w,int h,int[] data){
  if (data[0] == 0 && data[1] == 0) {
    return;
  }
  int nLeftWidth=0;
  int nLeftStyle=0;
  int nLeftX=-1;
  int nLeftY=-1;
  if (colIndex > 0) {
    int[] nLeft=borderData[(rowIndex) * (2 * colCount + 1) + colIndex - 1];
    nLeftWidth=nLeft[1];
    nLeftStyle=nLeft[0];
    nLeftX=nLeft[3];
    nLeftY=nLeft[4];
  }
  int nRightWidth=0;
  int nRightStyle=0;
  int nRightX=-1;
  int nRightY=-1;
  if (colIndex < colCount - 1) {
    int[] nRight=borderData[(rowIndex) * (2 * colCount + 1) + colIndex + 1];
    nRightWidth=nRight[1];
    nRightStyle=nRight[0];
    nRightX=nRight[3];
    nRightY=nRight[4];
  }
  int nLeftTopWidth=0;
  int nLeftTopStyle=0;
  int nLeftTopX=-1;
  int nLeftTopY=-1;
  if (rowIndex > 0 && colIndex >= 0) {
    int[] nLeftTop=borderData[(rowIndex - 1) * (2 * colCount + 1) + colCount + colIndex];
    nLeftTopWidth=nLeftTop[1];
    nLeftTopStyle=nLeftTop[0];
    nLeftTopX=nLeftTop[3];
    nLeftTopY=nLeftTop[4];
  }
  int nLeftBottomWidth=0;
  int nLeftBottomStyle=0;
  int nLeftBottomX=-1;
  int nLeftBottomY=-1;
  if (rowIndex <= rowCount - 1 && colIndex >= 0) {
    int[] nLeftBottom=borderData[(rowIndex) * (2 * colCount + 1) + colCount + colIndex];
    nLeftBottomWidth=nLeftBottom[1];
    nLeftBottomStyle=nLeftBottom[0];
    nLeftBottomX=nLeftBottom[3];
    nLeftBottomY=nLeftBottom[4];
  }
  int nRightTopWidth=0;
  int nRightTopStyle=0;
  int nRightTopX=-1;
  int nRightTopY=-1;
  if (rowIndex > 0 && colIndex <= colCount - 1) {
    int[] nRightTop=borderData[(rowIndex - 1) * (2 * colCount + 1) + colCount + colIndex + 1];
    nRightTopWidth=nRightTop[1];
    nRightTopStyle=nRightTop[0];
    nRightTopX=nRightTop[3];
    nRightTopY=nRightTop[4];
  }
  int nRightBottomWidth=0;
  int nRightBottomStyle=0;
  int nRightBottomX=-1;
  int nRightBottomY=-1;
  if (rowIndex <= rowCount - 1 && colIndex <= colCount - 1) {
    int[] nRightBottom=borderData[(rowIndex) * (2 * colCount + 1) + colCount + colIndex + 1];
    nRightBottomWidth=nRightBottom[1];
    nRightBottomStyle=nRightBottom[0];
    nRightBottomX=nRightBottom[3];
    nRightBottomY=nRightBottom[4];
  }
  int nlexWidth=Math.max(nLeftTopWidth,nLeftBottomWidth);
  boolean exLeft=false;
  boolean exRight=false;
  int rx=(colIndex == 0) ? (x + nlexWidth) : (x + nlexWidth / 2);
  int rw=(colIndex == 0) ? (w - nlexWidth) : (w - nlexWidth / 2);
  if (TableBorderCollisionArbiter.canExtend(data,nLeftWidth,nLeftStyle,nLeftBottomWidth,nLeftBottomStyle,nLeftBottomX,nLeftBottomY,nLeftTopWidth,nLeftTopStyle,nLeftTopX,nLeftTopY,true,false) || TableBorderCollisionArbiter.isBrotherWin(data,nLeftWidth,nLeftStyle,nLeftX,nLeftY,nLeftBottomWidth,nLeftBottomStyle,nLeftBottomX,nLeftBottomY,nLeftTopWidth,nLeftTopStyle,nLeftTopX,nLeftTopY,true,false) || (data[3] == -2)) {
    rx=(colIndex == 0) ? (x) : (x - nlexWidth / 2 - nlexWidth % 2);
    rw=(colIndex == 0) ? (w) : (w + nlexWidth / 2 + nlexWidth % 2);
    exLeft=true;
  }
  int nrexWidth=Math.max(nRightTopWidth,nRightBottomWidth);
  if (TableBorderCollisionArbiter.canExtend(data,nRightWidth,nRightStyle,nRightTopWidth,nRightTopStyle,nRightTopX,nRightTopY,nRightBottomWidth,nRightBottomStyle,nRightBottomX,nRightBottomY,false,false) || TableBorderCollisionArbiter.isBrotherWin(data,nRightWidth,nRightStyle,nRightX,nRightY,nRightTopWidth,nRightTopStyle,nRightTopX,nRightTopY,nRightBottomWidth,nRightBottomStyle,nRightBottomX,nRightBottomY,false,false) || (data[3] == -2 && rowIndex == colCount - 1)) {
    rw+=((colIndex == colCount - 1) ? (0) : (nrexWidth / 2));
    exRight=true;
  }
 else {
    rw-=((colIndex == colCount - 1) ? (nrexWidth) : (nrexWidth / 2 + nrexWidth % 2));
  }
  int direction=BorderUtil.TOP;
  int[] widths=new int[]{data[1],0,0,0};
  if (data[3] == nLeftTopX && data[4] == nLeftTopY && data[3] == nRightTopX && data[4] == nRightTopY) {
    direction=BorderUtil.BOTTOM;
    widths[0]=0;
    widths[1]=data[1];
    widths[2]=exLeft ? nLeftTopWidth : 0;
    widths[3]=exRight ? nRightTopWidth : 0;
  }
 else   if (data[3] == nLeftTopX && data[4] == nLeftTopY) {
    direction=BorderUtil.BOTTOM;
    widths[0]=0;
    widths[1]=data[1];
    widths[2]=exLeft ? nLeftTopWidth : 0;
    widths[3]=0;
  }
 else   if (data[3] == nRightTopX && data[4] == nRightTopY) {
    direction=BorderUtil.BOTTOM;
    widths[0]=0;
    widths[1]=data[1];
    widths[2]=0;
    widths[3]=exRight ? nRightTopWidth : 0;
  }
 else   if (data[3] == nLeftBottomX && data[4] == nLeftBottomY && data[3] == nRightBottomX && data[4] == nRightBottomY) {
    widths[0]=data[1];
    widths[1]=0;
    widths[2]=exLeft ? nLeftBottomWidth : 0;
    widths[3]=exRight ? nRightBottomWidth : 0;
  }
 else   if (data[3] == nLeftBottomX && data[4] == nLeftBottomY) {
    widths[0]=data[1];
    widths[1]=0;
    widths[2]=exLeft ? nLeftBottomWidth : 0;
    widths[3]=0;
  }
 else   if (data[3] == nRightBottomX && data[4] == nRightBottomY) {
    widths[0]=data[1];
    widths[1]=0;
    widths[2]=0;
    widths[3]=exRight ? nRightBottomWidth : 0;
  }
 else   if (data[3] != rowIndex || data[4] != colIndex) {
    direction=BorderUtil.TOP;
    widths[0]=data[1];
    widths[1]=0;
    widths[2]=0;
    widths[3]=0;
  }
  Rectangle r=new Rectangle(rx,y + h - data[1] / 2 - data[1] % 2,rw,data[1]);
  if (rowIndex == 0) {
    r.y=y;
  }
  if (data[0] != 0) {
    g.setForegroundColor(ColorManager.getColor(data[2]));
    if (data[0] == -2) {
      BorderUtil.drawDoubleLine(g,direction,widths,r);
    }
 else {
      BorderUtil.drawSingleLine(g,direction,data[0],widths,r);
    }
  }
 else   if (data[1] > 0) {
    g.setForegroundColor(ReportColorConstants.ShadowLineColor);
    BorderUtil.drawDefaultLine(g,direction,r);
  }
}

Fixed version (ground truth):
/** 
 * @param g
 * @param rowIndex
 * @param colIndex
 * @param data [style][width][color][rowIndex][colIndex].
 */
private void drawTop(Graphics g,int rowIndex,int colIndex,int x,int y,int w,int h,int[] data){
  if (data[0] == 0 && data[1] == 0) {
    return;
  }
  int nLeftWidth=0;
  int nLeftStyle=0;
  int nLeftX=-1;
  int nLeftY=-1;
  if (colIndex > 0) {
    int[] nLeft=borderData[(rowIndex) * (2 * colCount + 1) + colIndex - 1];
    nLeftWidth=nLeft[1];
    nLeftStyle=nLeft[0];
    nLeftX=nLeft[3];
    nLeftY=nLeft[4];
  }
  int nRightWidth=0;
  int nRightStyle=0;
  int nRightX=-1;
  int nRightY=-1;
  if (colIndex < colCount - 1) {
    int[] nRight=borderData[(rowIndex) * (2 * colCount + 1) + colIndex + 1];
    nRightWidth=nRight[1];
    nRightStyle=nRight[0];
    nRightX=nRight[3];
    nRightY=nRight[4];
  }
  int nLeftTopWidth=0;
  int nLeftTopStyle=0;
  int nLeftTopX=-1;
  int nLeftTopY=-1;
  if (rowIndex > 0 && colIndex >= 0) {
    int[] nLeftTop=borderData[(rowIndex - 1) * (2 * colCount + 1) + colCount + colIndex];
    nLeftTopWidth=nLeftTop[1];
    nLeftTopStyle=nLeftTop[0];
    nLeftTopX=nLeftTop[3];
    nLeftTopY=nLeftTop[4];
  }
  int nLeftBottomWidth=0;
  int nLeftBottomStyle=0;
  int nLeftBottomX=-1;
  int nLeftBottomY=-1;
  if (rowIndex <= rowCount - 1 && colIndex >= 0) {
    int[] nLeftBottom=borderData[(rowIndex) * (2 * colCount + 1) + colCount + colIndex];
    nLeftBottomWidth=nLeftBottom[1];
    nLeftBottomStyle=nLeftBottom[0];
    nLeftBottomX=nLeftBottom[3];
    nLeftBottomY=nLeftBottom[4];
  }
  int nRightTopWidth=0;
  int nRightTopStyle=0;
  int nRightTopX=-1;
  int nRightTopY=-1;
  if (rowIndex > 0 && colIndex <= colCount - 1) {
    int[] nRightTop=borderData[(rowIndex - 1) * (2 * colCount + 1) + colCount + colIndex + 1];
    nRightTopWidth=nRightTop[1];
    nRightTopStyle=nRightTop[0];
    nRightTopX=nRightTop[3];
    nRightTopY=nRightTop[4];
  }
  int nRightBottomWidth=0;
  int nRightBottomStyle=0;
  int nRightBottomX=-1;
  int nRightBottomY=-1;
  if (rowIndex <= rowCount - 1 && colIndex <= colCount - 1) {
    int[] nRightBottom=borderData[(rowIndex) * (2 * colCount + 1) + colCount + colIndex + 1];
    nRightBottomWidth=nRightBottom[1];
    nRightBottomStyle=nRightBottom[0];
    nRightBottomX=nRightBottom[3];
    nRightBottomY=nRightBottom[4];
  }
  int nlexWidth=Math.max(nLeftTopWidth,nLeftBottomWidth);
  boolean exLeft=false;
  boolean exRight=false;
  int rx=(colIndex == 0) ? (x + nlexWidth) : (x + nlexWidth / 2);
  int rw=(colIndex == 0) ? (w - nlexWidth) : (w - nlexWidth / 2);
  if (TableBorderCollisionArbiter.canExtend(data,nLeftWidth,nLeftStyle,nLeftBottomWidth,nLeftBottomStyle,nLeftBottomX,nLeftBottomY,nLeftTopWidth,nLeftTopStyle,nLeftTopX,nLeftTopY,true,false) || TableBorderCollisionArbiter.isBrotherWin(data,nLeftWidth,nLeftStyle,nLeftX,nLeftY,nLeftBottomWidth,nLeftBottomStyle,nLeftBottomX,nLeftBottomY,nLeftTopWidth,nLeftTopStyle,nLeftTopX,nLeftTopY,true,false) || (data[3] == -2)) {
    rx=(colIndex == 0) ? (x) : (x - nlexWidth / 2 - nlexWidth % 2);
    rw=(colIndex == 0) ? (w) : (w + nlexWidth / 2 + nlexWidth % 2);
    exLeft=true;
  }
  int nrexWidth=Math.max(nRightTopWidth,nRightBottomWidth);
  if (TableBorderCollisionArbiter.canExtend(data,nRightWidth,nRightStyle,nRightTopWidth,nRightTopStyle,nRightTopX,nRightTopY,nRightBottomWidth,nRightBottomStyle,nRightBottomX,nRightBottomY,false,false) || TableBorderCollisionArbiter.isBrotherWin(data,nRightWidth,nRightStyle,nRightX,nRightY,nRightTopWidth,nRightTopStyle,nRightTopX,nRightTopY,nRightBottomWidth,nRightBottomStyle,nRightBottomX,nRightBottomY,false,false) || (data[3] == -2 && rowIndex == colCount - 1)) {
    rw+=((colIndex == colCount - 1) ? (0) : (nrexWidth / 2));
    exRight=true;
  }
 else {
    rw-=((colIndex == colCount - 1) ? (nrexWidth) : (nrexWidth / 2 + nrexWidth % 2));
  }
  int direction=BorderUtil.TOP;
  int[] widths=new int[]{data[1],0,0,0};
  if (data[3] == nLeftTopX && data[4] == nLeftTopY && data[3] == nRightTopX && data[4] == nRightTopY) {
    direction=BorderUtil.BOTTOM;
    widths[0]=0;
    widths[1]=data[1];
    widths[2]=exLeft ? nLeftTopWidth : 0;
    widths[3]=exRight ? nRightTopWidth : 0;
  }
 else   if (data[3] == nLeftTopX && data[4] == nLeftTopY) {
    direction=BorderUtil.BOTTOM;
    widths[0]=0;
    widths[1]=data[1];
    widths[2]=exLeft ? nLeftTopWidth : 0;
    widths[3]=0;
  }
 else   if (data[3] == nRightTopX && data[4] == nRightTopY) {
    direction=BorderUtil.BOTTOM;
    widths[0]=0;
    widths[1]=data[1];
    widths[2]=0;
    widths[3]=exRight ? nRightTopWidth : 0;
  }
 else   if (data[3] == nLeftBottomX && data[4] == nLeftBottomY && data[3] == nRightBottomX && data[4] == nRightBottomY) {
    widths[0]=data[1];
    widths[1]=0;
    widths[2]=exLeft ? nLeftBottomWidth : 0;
    widths[3]=exRight ? nRightBottomWidth : 0;
  }
 else   if (data[3] == nLeftBottomX && data[4] == nLeftBottomY) {
    widths[0]=data[1];
    widths[1]=0;
    widths[2]=exLeft ? nLeftBottomWidth : 0;
    widths[3]=0;
  }
 else   if (data[3] == nRightBottomX && data[4] == nRightBottomY) {
    widths[0]=data[1];
    widths[1]=0;
    widths[2]=0;
    widths[3]=exRight ? nRightBottomWidth : 0;
  }
 else   if (data[3] != rowIndex || data[4] != colIndex) {
    direction=BorderUtil.TOP;
    widths[0]=data[1];
    widths[1]=0;
    widths[2]=0;
    widths[3]=0;
  }
  Rectangle r=new Rectangle(rx,y + h - data[1] / 2 - data[1] % 2,rw,data[1]);
  if (rowIndex == 0) {
    r.y=y;
  }
  if (data[0] != 0) {
    g.setForegroundColor(ColorManager.getColor(data[2]));
    BorderUtil.drawBorderLine(g,direction,data[0],widths,r);
  }
 else   if (data[1] > 0) {
    g.setForegroundColor(ReportColorConstants.ShadowLineColor);
    BorderUtil.drawDefaultLine(g,direction,r);
  }
}