--- old/src/java.desktop/share/classes/java/awt/geom/Path2D.java 2017-04-18 23:25:56.003937825 +0200 +++ new/src/java.desktop/share/classes/java/awt/geom/Path2D.java 2017-04-18 23:25:55.851938259 +0200 @@ -274,6 +274,18 @@ append(pi, false); } } + + @Override + public final Path2D trimToSize() { + // trim arrays: + if (numTypes < pointTypes.length) { + this.pointTypes = Arrays.copyOf(pointTypes, numTypes); + } + if (numCoords < floatCoords.length) { + this.floatCoords = Arrays.copyOf(floatCoords, numCoords); + } + return this; + } @Override float[] cloneCoordsFloat(AffineTransform at) { @@ -1143,6 +1155,18 @@ append(pi, false); } } + + @Override + public final Path2D trimToSize() { + // trim arrays: + if (numTypes < pointTypes.length) { + this.pointTypes = Arrays.copyOf(pointTypes, numTypes); + } + if (numCoords < doubleCoords.length) { + this.doubleCoords = Arrays.copyOf(doubleCoords, numCoords); + } + return this; + } @Override float[] cloneCoordsFloat(AffineTransform at) { @@ -2470,6 +2494,17 @@ // compatibility so we cannot restrict it further. // REMIND: Can we do both somehow? + /** + * Trims the capacity of this Path2D instance to its current + * size. If the capacity of this path is larger than its current + * size, then the capacity is changed to equal the size by replacing + * its internal data array. An application can use this operation to + * minimize the storage of a path. + * @return this Path2D instance + * @Since 10 + */ + public abstract Path2D trimToSize(); + /* * Support fields and methods for serializing the subclasses. */