--- old/src/java.desktop/share/classes/java/awt/geom/Path2D.java 2017-04-20 23:16:04.406039845 +0200 +++ new/src/java.desktop/share/classes/java/awt/geom/Path2D.java 2017-04-20 23:16:04.294038746 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2017, 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 @@ -276,6 +276,17 @@ } @Override + public final void trimToSize() { + // trim arrays: + if (numTypes < pointTypes.length) { + this.pointTypes = Arrays.copyOf(pointTypes, numTypes); + } + if (numCoords < floatCoords.length) { + this.floatCoords = Arrays.copyOf(floatCoords, numCoords); + } + } + + @Override float[] cloneCoordsFloat(AffineTransform at) { // trim arrays: float ret[]; @@ -1145,6 +1156,17 @@ } @Override + public final void trimToSize() { + // trim arrays: + if (numTypes < pointTypes.length) { + this.pointTypes = Arrays.copyOf(pointTypes, numTypes); + } + if (numCoords < doubleCoords.length) { + this.doubleCoords = Arrays.copyOf(doubleCoords, numCoords); + } + } + + @Override float[] cloneCoordsFloat(AffineTransform at) { // trim arrays: float ret[] = new float[numCoords]; @@ -2470,6 +2492,15 @@ // compatibility so we cannot restrict it further. // REMIND: Can we do both somehow? + /** + * Trims the capacity of this Path2D instance to its current + * size. An application can use this operation to minimize the + * storage of a path. + * + * @since 10 + */ + public abstract void trimToSize(); + /* * Support fields and methods for serializing the subclasses. */