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

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

    XMLWordPrintable

    Details

    • Subcomponent:
      2d
    • Resolved In Build:
      beta2
    • CPU:
      sparc
    • OS:
      solaris_2.6

      Description



      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

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

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: