Blame jdk8075942-pr3602-rh1582032-arrayindexoutOfboundsException_in_sun_java2d_pisces_Dasher_goto.patch

baf0cab
# HG changeset patch
baf0cab
# User prr
baf0cab
# Date 1429299166 25200
baf0cab
#      Fri Apr 17 12:32:46 2015 -0700
baf0cab
# Node ID 1f4b038b9550afaf88a70cee4cf9c1422ecd86d6
baf0cab
# Parent  533117ae5b7587c8d9c0612581682ab984475430
baf0cab
8075942, PR3602: ArrayIndexOutOfBoundsException in sun.java2d.pisces.Dasher.goTo
baf0cab
Reviewed-by: flar, lbourges
baf0cab
baf0cab
diff --git openjdk.orig/jdk/src/share/classes/sun/java2d/pisces/Dasher.java openjdk/jdk/src/share/classes/sun/java2d/pisces/Dasher.java
baf0cab
--- openjdk.orig/jdk/src/share/classes/sun/java2d/pisces/Dasher.java
baf0cab
+++ openjdk/jdk/src/share/classes/sun/java2d/pisces/Dasher.java
baf0cab
@@ -146,7 +146,7 @@
baf0cab
         if (dashOn) {
baf0cab
             if (starting) {
baf0cab
                 firstSegmentsBuffer = Helpers.widenArray(firstSegmentsBuffer,
baf0cab
-                                      firstSegidx, type - 2);
baf0cab
+                                      firstSegidx, type - 2 + 1);
baf0cab
                 firstSegmentsBuffer[firstSegidx++] = type;
baf0cab
                 System.arraycopy(pts, off, firstSegmentsBuffer, firstSegidx, type - 2);
baf0cab
                 firstSegidx += type - 2;
baf0cab
diff --git a/test/javopenjdk.orig/jdk/awt/BasicStroke/DashStrokeTest.java openjdk/jdk/test/java/awt/BasicStroke/DashStrokeTest.java
baf0cab
new file mode 100644
baf0cab
--- /dev/null
baf0cab
+++ openjdk/jdk/test/java/awt/BasicStroke/DashStrokeTest.java
baf0cab
@@ -0,0 +1,69 @@
baf0cab
+/*
baf0cab
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
baf0cab
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
baf0cab
+ *
baf0cab
+ * This code is free software; you can redistribute it and/or modify it
baf0cab
+ * under the terms of the GNU General Public License version 2 only, as
baf0cab
+ * published by the Free Software Foundation.
baf0cab
+ *
baf0cab
+ * This code is distributed in the hope that it will be useful, but WITHOUT
baf0cab
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
baf0cab
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
baf0cab
+ * version 2 for more details (a copy is included in the LICENSE file that
baf0cab
+ * accompanied this code).
baf0cab
+ *
baf0cab
+ * You should have received a copy of the GNU General Public License version
baf0cab
+ * 2 along with this work; if not, write to the Free Software Foundation,
baf0cab
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
baf0cab
+ *
baf0cab
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
baf0cab
+ * or visit www.oracle.com if you need additional information or have any
baf0cab
+ * questions.
baf0cab
+ *
baf0cab
+ * @test
baf0cab
+ * @bug 8075942
baf0cab
+ * @summary test there is no exception rendering a dashed stroke
baf0cab
+ * @run DashStrokeTest
baf0cab
+ * @run -Dsun.java2d.renderer=sun.java2d.pisces.PiscesRenderingEngine
baf0cab
+ */
baf0cab
+
baf0cab
+import java.awt.BasicStroke;
baf0cab
+import java.awt.Color;
baf0cab
+import java.awt.Graphics2D;
baf0cab
+import java.awt.Stroke;
baf0cab
+import java.awt.geom.GeneralPath;
baf0cab
+import java.awt.image.BufferedImage;
baf0cab
+
baf0cab
+
baf0cab
+public class DashStrokeTest {
baf0cab
+
baf0cab
+    public static void main(String[] args) {
baf0cab
+
baf0cab
+        GeneralPath shape = new GeneralPath();
baf0cab
+        int[] pointTypes = {0, 0, 1, 1, 0, 1, 1, 0};
baf0cab
+        double[] xpoints = {428, 420, 400, 400, 400, 400, 420, 733};
baf0cab
+        double[] ypoints = {180, 180, 180, 160, 30, 10, 10, 10};
baf0cab
+        shape.moveTo(xpoints[0], ypoints[0]);
baf0cab
+        for (int i = 1; i < pointTypes.length; i++) {
baf0cab
+            if (pointTypes[i] == 1 && i < pointTypes.length - 1) {
baf0cab
+                shape.quadTo(xpoints[i], ypoints[i],
baf0cab
+                             xpoints[i + 1], ypoints[i + 1]);
baf0cab
+            } else {
baf0cab
+                shape.lineTo(xpoints[i], ypoints[i]);
baf0cab
+            }
baf0cab
+        }
baf0cab
+
baf0cab
+        BufferedImage image = new
baf0cab
+            BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
baf0cab
+        Graphics2D g2 = image.createGraphics();
baf0cab
+
baf0cab
+        Color color = new Color(124, 0, 124, 255);
baf0cab
+        g2.setColor(color);
baf0cab
+        Stroke stroke = new BasicStroke(1.0f,
baf0cab
+                                        BasicStroke.CAP_BUTT,
baf0cab
+                                        BasicStroke.JOIN_BEVEL,
baf0cab
+                                        10.0f, new float[] {9, 6}, 0.0f);
baf0cab
+        g2.setStroke(stroke);
baf0cab
+        g2.draw(shape);
baf0cab
+    }
baf0cab
+}