-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta2
-
sparc
-
solaris_2.6
Name: dsR10051 Date: 08/07/2001
The constructor of class java.awt.Polygon
public Polygon(int xpoints[], int ypoints[], int npoints)
baselessly throws java.lang.OutOfMemoryError if value of npoints
is greater than the length of xpoints or the length of ypoints
and large enough. In this case constructor should throw
documented IndexOutOfBoundsException and keeps out
the memory allocation.
Here is minimized test:
import java.awt.*;
public class PolygonTest01 {
public static void main (String args[]) {
int[] xpoints = {1,2,3};
int[] ypoints = {1,2,3};
int npoints = Integer.MAX_VALUE;
try {
Polygon p = new Polygon(xpoints, ypoints, npoints);
} catch (IndexOutOfBoundsException e) {
System.out.println("OKAY");
return;
}
System.out.println("FAILED: IndexOutOfBoundsException expected");
}
}
--- Output ---
%/set/jdk-builds/JDK1.4.0beta-b74/solaris/bin/java PolygonTest01
Exception in thread "main" java.lang.OutOfMemoryError
======================================================================