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

java.awt.Polygon.Polygon(int[], int[], int) out of memory error

XMLWordPrintable

    • sparc
    • solaris_2.5



      Name: saC57035 Date: 03/19/99


      java.awt.Polygon.Polygon(int[] xpoints, int[] ypoints, int npoints) throws
      OutOfMemoryError exeption being given huge npoints value.
      The valid response in this case should be ArrayIndexOutOfBoundsException,
      as npoints evidently exceeds the capacity of array parameters.

      Here is the test demonstrating the bug:

      -----------------Test.java------------------------
      import java.awt.*;
       
      public class Test {

          public static void main(String[] args) {
              int[] x={-10,10,10,-10};
              int[] y={-10,-10,10,10};
              try {
                  Polygon p = new Polygon(x, y, Integer.MAX_VALUE);
              } catch(ArrayIndexOutOfBoundsException e) {
                  System.out.println("PASSED. " + e + " is thrown");
              } catch (Throwable e) {
                  System.out.println("FAILED. " + e + " is thrown");
                  e.printStackTrace();
              }
          }

      }
      ---------Output from the test---------------------

      FAILED. java.lang.OutOfMemoryError is thrown
      java.lang.OutOfMemoryError
      at Test.main(Test.java, Compiled Code)

      --------------------------------------------------

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

            ehawkessunw Eric Hawkes (Inactive)
            savzan Stanislav Avzan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: