Program: 71383
Project: 71383
Buggy source:
public boolean intersects(Polygon poly){
  if (poly == null) {
    return false;
  }
  if (points.size() > 2 && poly.points.size() > 2) {
    boolean started=false;
    boolean diff=false, oldDiff=false;
    int count=points.size();
    double[] xa=new double[count];
    double[] ya=new double[count];
    for (int i=0; i < count; i++) {
      Point pt=getPoint(i);
      xa[i]=pt.getX();
      ya[i]=pt.getY();
    }
    for (Iterator itr=poly.getPoints().iterator(); itr.hasNext(); ) {
      Point pt=(Point)itr.next();
      diff=testInside(count,xa,ya,pt.getX(),pt.getY());
      if (!started) {
        started=true;
        oldDiff=diff;
      }
      if (diff != oldDiff) {
        return true;
      }
      oldDiff=diff;
    }
    if (diff) {
      return true;
    }
    if (getPoints().size() > 0) {
      count=poly.getPoints().size();
      xa=new double[count];
      ya=new double[count];
      for (int i=0; i < count; i++) {
        Point pt=poly.getPoint(i);
        xa[i]=pt.getX();
        ya[i]=pt.getY();
      }
      for (Iterator itr=points.iterator(); itr.hasNext(); ) {
        Point pt=(Point)itr.next();
        if (testInside(count,xa,ya,pt.getX(),pt.getY())) {
          return true;
        }
      }
    }
  }
 else   if (points.size() == 2 || poly.points.size() == 2) {
    List line=points;
    List pg=poly.points;
    if (line.size() > 2) {
      line=poly.points;
      pg=points;
    }
    Point lp1=(Point)line.get(0);
    Point lp2=(Point)line.get(1);
    for (int i=0; i < pg.size(); i++) {
      if (i == pg.size() - 1) {
        if (testLineIntersect(lp1,lp2,(Point)pg.get(i),(Point)pg.get(0))) {
          return true;
        }
      }
 else {
        if (testLineIntersect(lp1,lp2,(Point)pg.get(i),(Point)pg.get(i + 1))) {
          return true;
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
public boolean intersects(Polygon poly){
  if (poly == null) {
    return false;
  }
  if (points.size() > 2 && poly.points.size() > 2) {
    boolean started=false;
    boolean diff=false, oldDiff=false;
    int count=points.size();
    double[] xa=new double[count];
    double[] ya=new double[count];
    for (int i=0; i < count; i++) {
      Point pt=getPoint(i);
      xa[i]=pt.getX();
      ya[i]=pt.getY();
    }
    for (Iterator<Point> itr=poly.getPoints().iterator(); itr.hasNext(); ) {
      Point pt=itr.next();
      diff=testInside(count,xa,ya,pt.getX(),pt.getY());
      if (!started) {
        started=true;
        oldDiff=diff;
      }
      if (diff != oldDiff) {
        return true;
      }
      oldDiff=diff;
    }
    if (diff) {
      return true;
    }
    if (getPoints().size() > 0) {
      count=poly.getPoints().size();
      xa=new double[count];
      ya=new double[count];
      for (int i=0; i < count; i++) {
        Point pt=poly.getPoint(i);
        xa[i]=pt.getX();
        ya[i]=pt.getY();
      }
      for (Iterator<Point> itr=points.iterator(); itr.hasNext(); ) {
        Point pt=itr.next();
        if (testInside(count,xa,ya,pt.getX(),pt.getY())) {
          return true;
        }
      }
    }
  }
 else   if (points.size() == 2 || poly.points.size() == 2) {
    List<Point> line=points;
    List<Point> pg=poly.points;
    if (line.size() > 2) {
      line=poly.points;
      pg=points;
    }
    Point lp1=line.get(0);
    Point lp2=line.get(1);
    for (int i=0; i < pg.size(); i++) {
      if (i == pg.size() - 1) {
        if (testLineIntersect(lp1,lp2,pg.get(i),pg.get(0))) {
          return true;
        }
      }
 else {
        if (testLineIntersect(lp1,lp2,pg.get(i),pg.get(i + 1))) {
          return true;
        }
      }
    }
  }
  return false;
}