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

ArrayIndexOutOfBoundsException when path.append() to itself

XMLWordPrintable

    • 2d
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10.0.19043.1415

      A DESCRIPTION OF THE PROBLEM :
      When (unintentionally) running path.append() to itself, I get an undocumented ArrayIndexOutOfBoundsException. This behavior should either be documented in the javadoc, or avoided.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      nothing
      ACTUAL -
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
      at java.lang.System.arraycopy(Native Method)
      at java.awt.geom.Path2D$Float$CopyIterator.currentSegment(Path2D.java:1001)
      at java.awt.geom.Path2D$Float.append(Path2D.java:730)
      at NewClass.main(NewClass.java:19)

      ---------- BEGIN SOURCE ----------

      import java.awt.geom.GeneralPath;

      public class NewClass
      {

          public static void main(String[] args)
          {
              GeneralPath path = createPath();
              path.append(path.getPathIterator(null), true);
          }

          static GeneralPath createPath()
          {
              GeneralPath path = new GeneralPath();
              path.moveTo(150.0, 524.0);
              path.lineTo(67.0, 524.0);
              path.closePath();
              return path;
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      avoid appending path to itself

      FREQUENCY : always


            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: