Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4489009

Constructor java.awt.Polygon(int[], int[], int) works incorrectly.

XMLWordPrintable

    • 2d
    • 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

      ======================================================================

            duke J. Duke
            sdasunw Sda Sda (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: