Blame jdk8075942-pr3602-rh1582032-arrayindexoutOfboundsException_in_sun_java2d_pisces_Dasher_goto.patch

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