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

Path2D.Double, Path2D.Float and GeneralPath ctors throw exception when initialCapacity is negative

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 17
    • 6
    • client-libs
    • None
    • 2d
    • b07
    • generic
    • generic

      Filed By : JCK team
      JDK : java full version "1.6.0-fcs"
      Platform[s] : solaris
      switch/Mode : default
      JCK test owner : http://javaweb.sfbay/jcce/tcks/jck/docs/others/owners.jto
      Failed tests : NONE.

      Problem description
      ===================
      The javadoc specification for constructors of java.awt.geom.GeneralPath, java.awt.geom.Path2D.Double
      and java.awt.geom.Path2D.Float classes do not describe any exceptions to be thrown.
      However, the following constructors which take initialCapacity as second argument:
        public GeneralPath(int rule, int initialCapacity)
        public Path2D.Double(int rule, int initialCapacity)
        public Path2D.Float(int rule, int initialCapacity)
      throw java.lang.NegativeArraySizeException if initialCapacity is negative.

      Please see minimized test to reproduce this failure.

      Minimized test:
      ===============
      ---Test.java---
      import java.awt.geom.GeneralPath;
      import java.awt.geom.Path2D;

      public class Test {
          public static void main(String[] args) {
              try {
                  GeneralPath obj = new GeneralPath(Path2D.WIND_EVEN_ODD, -1);
              } catch (Throwable e) {
                  e.printStackTrace();
                  System.out.println("GeneralPath FAILED: " + e);
              }

              try {
                  Path2D.Double obj = new Path2D.Double(Path2D.WIND_EVEN_ODD, -1);
              } catch (Throwable e) {
                  e.printStackTrace();
                  System.out.println("Path2D.Double FAILED: " + e);
              }

              try {
                  Path2D.Float obj = new Path2D.Float(Path2D.WIND_EVEN_ODD, -1);
              } catch (Throwable e) {
                  e.printStackTrace();
                  System.out.println("Path2D.Float FAILED: " + e);
              }
          }
      }
      ---End-of-Test.java---

      Minimized test output:
      ======================
      bash-3.00$ javac Test.java
      bash-3.00$ java Test
      java.lang.NegativeArraySizeException
              at java.awt.geom.Path2D.<init>(Path2D.java:114)
              at java.awt.geom.Path2D$Float.<init>(Path2D.java:176)
              at java.awt.geom.GeneralPath.<init>(GeneralPath.java:75)
              at Test.main(Test.java:7)
      GeneralPath FAILED: java.lang.NegativeArraySizeException
      java.lang.NegativeArraySizeException
              at java.awt.geom.Path2D.<init>(Path2D.java:114)
              at java.awt.geom.Path2D$Double.<init>(Path2D.java:1010)
              at Test.main(Test.java:14)
      Path2D.Double FAILED: java.lang.NegativeArraySizeException
      java.lang.NegativeArraySizeException
              at java.awt.geom.Path2D.<init>(Path2D.java:114)
              at java.awt.geom.Path2D$Float.<init>(Path2D.java:176)
              at Test.main(Test.java:21)
      Path2D.Float FAILED: java.lang.NegativeArraySizeException
      ======================

            serb Sergey Bylokhov
            ygaevsky Yuri Gaevsky (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: