--- old/src/share/classes/java/awt/geom/Path2D.java 2015-05-15 12:51:07.282847499 -0700 +++ new/src/share/classes/java/awt/geom/Path2D.java 2015-05-15 12:51:07.142847495 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -224,8 +224,8 @@ Path2D p2d = (Path2D) s; setWindingRule(p2d.windingRule); this.numTypes = p2d.numTypes; - this.pointTypes = Arrays.copyOf(p2d.pointTypes, - p2d.pointTypes.length); + // trim arrays: + this.pointTypes = Arrays.copyOf(p2d.pointTypes, p2d.numTypes); this.numCoords = p2d.numCoords; this.floatCoords = p2d.cloneCoordsFloat(at); } else { @@ -237,19 +237,23 @@ } } + @Override float[] cloneCoordsFloat(AffineTransform at) { + // trim arrays: float ret[]; if (at == null) { - ret = Arrays.copyOf(this.floatCoords, this.floatCoords.length); + ret = Arrays.copyOf(floatCoords, numCoords); } else { - ret = new float[floatCoords.length]; + ret = new float[numCoords]; at.transform(floatCoords, 0, ret, 0, numCoords / 2); } return ret; } + @Override double[] cloneCoordsDouble(AffineTransform at) { - double ret[] = new double[floatCoords.length]; + // trim arrays: + double ret[] = new double[numCoords]; if (at == null) { for (int i = 0; i < numCoords; i++) { ret[i] = floatCoords[i]; @@ -475,6 +479,9 @@ } int pointCrossings(double px, double py) { + if (numTypes == 0) { + return 0; + } double movx, movy, curx, cury, endx, endy; float coords[] = floatCoords; curx = movx = coords[0]; @@ -552,6 +559,9 @@ int rectCrossings(double rxmin, double rymin, double rxmax, double rymax) { + if (numTypes == 0) { + return 0; + } float coords[] = floatCoords; double curx, cury, movx, movy, endx, endy; curx = movx = coords[0]; @@ -1061,8 +1071,8 @@ Path2D p2d = (Path2D) s; setWindingRule(p2d.windingRule); this.numTypes = p2d.numTypes; - this.pointTypes = Arrays.copyOf(p2d.pointTypes, - p2d.pointTypes.length); + // trim arrays: + this.pointTypes = Arrays.copyOf(p2d.pointTypes, p2d.numTypes); this.numCoords = p2d.numCoords; this.doubleCoords = p2d.cloneCoordsDouble(at); } else { @@ -1074,8 +1084,10 @@ } } + @Override float[] cloneCoordsFloat(AffineTransform at) { - float ret[] = new float[doubleCoords.length]; + // trim arrays: + float ret[] = new float[numCoords]; if (at == null) { for (int i = 0; i < numCoords; i++) { ret[i] = (float) doubleCoords[i]; @@ -1086,13 +1098,14 @@ return ret; } + @Override double[] cloneCoordsDouble(AffineTransform at) { + // trim arrays: double ret[]; if (at == null) { - ret = Arrays.copyOf(this.doubleCoords, - this.doubleCoords.length); + ret = Arrays.copyOf(doubleCoords, numCoords); } else { - ret = new double[doubleCoords.length]; + ret = new double[numCoords]; at.transform(doubleCoords, 0, ret, 0, numCoords / 2); } return ret; @@ -1202,6 +1215,9 @@ } int pointCrossings(double px, double py) { + if (numTypes == 0) { + return 0; + } double movx, movy, curx, cury, endx, endy; double coords[] = doubleCoords; curx = movx = coords[0]; @@ -1279,6 +1295,9 @@ int rectCrossings(double rxmin, double rymin, double rxmax, double rymax) { + if (numTypes == 0) { + return 0; + } double coords[] = doubleCoords; double curx, cury, movx, movy, endx, endy; curx = movx = coords[0];