From 80581a0c13b2436844da4ccbc37156e096420981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Bourg=C3=A8s?= Date: Wed, 17 May 2017 22:05:11 +0200 Subject: [PATCH 01/98] 8180055: Upgrade the Marlin renderer in Java2D Added the double-precision variant + MarlinFX backports + Improved MarlinTileGenerator + higher precision of the cubic / quadratic curve Reviewed-by: flar, pnarayanan --- .../sun/java2d/marlin/ArrayCacheConst.java | 4 +- .../sun/java2d/marlin/ByteArrayCache.java | 14 +- .../java2d/marlin/CollinearSimplifier.java | 4 +- .../classes/sun/java2d/marlin/Curve.java | 123 +- .../java2d/marlin/DCollinearSimplifier.java | 154 ++ .../classes/sun/java2d/marlin/DCurve.java | 237 +++ .../classes/sun/java2d/marlin/DDasher.java | 746 ++++++++ .../classes/sun/java2d/marlin/DHelpers.java | 436 +++++ .../java2d/marlin/DMarlinRenderingEngine.java | 1111 ++++++++++++ .../sun/java2d/marlin/DPathConsumer2D.java | 78 + .../classes/sun/java2d/marlin/DRenderer.java | 1526 +++++++++++++++++ .../sun/java2d/marlin/DRendererContext.java | 260 +++ .../classes/sun/java2d/marlin/DStroker.java | 1325 ++++++++++++++ .../marlin/DTransformingPathConsumer2D.java | 277 +++ .../classes/sun/java2d/marlin/Dasher.java | 165 +- .../sun/java2d/marlin/DoubleArrayCache.java | 273 +++ .../sun/java2d/marlin/FloatArrayCache.java | 16 +- .../classes/sun/java2d/marlin/FloatMath.java | 79 +- .../classes/sun/java2d/marlin/Helpers.java | 94 +- .../sun/java2d/marlin/IRendererContext.java | 36 + .../sun/java2d/marlin/IntArrayCache.java | 14 +- .../sun/java2d/marlin/MarlinCache.java | 126 +- .../sun/java2d/marlin/MarlinConst.java | 19 +- .../sun/java2d/marlin/MarlinProperties.java | 68 +- .../sun/java2d/marlin/MarlinRenderer.java | 30 + .../java2d/marlin/MarlinRenderingEngine.java | 75 +- .../java2d/marlin/MarlinTileGenerator.java | 587 +++++-- .../sun/java2d/marlin/OffHeapArray.java | 3 +- .../classes/sun/java2d/marlin/Renderer.java | 229 +-- .../sun/java2d/marlin/RendererContext.java | 17 +- .../classes/sun/java2d/marlin/Stroker.java | 445 ++--- .../marlin/TransformingPathConsumer2D.java | 10 +- .../classes/sun/java2d/marlin/Version.java | 4 +- .../sun/java2d/pipe/RenderingEngine.java | 4 +- 34 files changed, 7695 insertions(+), 894 deletions(-) create mode 100644 jdk/src/java.desktop/share/classes/sun/java2d/marlin/DCollinearSimplifier.java create mode 100644 jdk/src/java.desktop/share/classes/sun/java2d/marlin/DCurve.java create mode 100644 jdk/src/java.desktop/share/classes/sun/java2d/marlin/DDasher.java create mode 100644 jdk/src/java.desktop/share/classes/sun/java2d/marlin/DHelpers.java create mode 100644 jdk/src/java.desktop/share/classes/sun/java2d/marlin/DMarlinRenderingEngine.java create mode 100644 jdk/src/java.desktop/share/classes/sun/java2d/marlin/DPathConsumer2D.java create mode 100644 jdk/src/java.desktop/share/classes/sun/java2d/marlin/DRenderer.java create mode 100644 jdk/src/java.desktop/share/classes/sun/java2d/marlin/DRendererContext.java create mode 100644 jdk/src/java.desktop/share/classes/sun/java2d/marlin/DStroker.java create mode 100644 jdk/src/java.desktop/share/classes/sun/java2d/marlin/DTransformingPathConsumer2D.java create mode 100644 jdk/src/java.desktop/share/classes/sun/java2d/marlin/DoubleArrayCache.java create mode 100644 jdk/src/java.desktop/share/classes/sun/java2d/marlin/IRendererContext.java create mode 100644 jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinRenderer.java diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/ArrayCacheConst.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/ArrayCacheConst.java index 5cc9cf84ed5..2c0cfe24606 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/ArrayCacheConst.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/ArrayCacheConst.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -242,6 +242,8 @@ public final class ArrayCacheConst implements MarlinConst { int factor = 1; if (name.contains("Int") || name.contains("Float")) { factor = 4; + } else if (name.contains("Double")) { + factor = 8; } return factor; } diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/ByteArrayCache.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/ByteArrayCache.java index 869b050098f..8bdf3a2e9bf 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/ByteArrayCache.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/ByteArrayCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package sun.java2d.marlin; import static sun.java2d.marlin.ArrayCacheConst.ARRAY_SIZES; @@ -37,13 +38,14 @@ import sun.java2d.marlin.ArrayCacheConst.BucketStats; import sun.java2d.marlin.ArrayCacheConst.CacheStats; /* - * Note that the [BYTE/INT/FLOAT]ArrayCache files are nearly identical except + * Note that the [BYTE/INT/FLOAT/DOUBLE]ArrayCache files are nearly identical except * for a few type and name differences. Typically, the [BYTE]ArrayCache.java file - * is edited manually and then [INT]ArrayCache.java and [FLOAT]ArrayCache.java + * is edited manually and then [INT/FLOAT/DOUBLE]ArrayCache.java * files are generated with the following command lines: */ // % sed -e 's/(b\yte)[ ]*//g' -e 's/b\yte/int/g' -e 's/B\yte/Int/g' < B\yteArrayCache.java > IntArrayCache.java -// % sed -e 's/(b\yte)[ ]*/(float) /g' -e 's/b\yte/float/g' -e 's/B\yte/Float/g' < B\yteArrayCache.java > FloatArrayCache.java +// % sed -e 's/(b\yte)[ ]*0/0.0f/g' -e 's/(b\yte)[ ]*/(float) /g' -e 's/b\yte/float/g' -e 's/B\yte/Float/g' < B\yteArrayCache.java > FloatArrayCache.java +// % sed -e 's/(b\yte)[ ]*0/0.0d/g' -e 's/(b\yte)[ ]*/(double) /g' -e 's/b\yte/double/g' -e 's/B\yte/Double/g' < B\yteArrayCache.java > DoubleArrayCache.java final class ByteArrayCache implements MarlinConst { @@ -231,8 +233,8 @@ final class ByteArrayCache implements MarlinConst { if (clean) { return new byte[length]; } - // use JDK9 Unsafe.allocateUninitializedArray(class, length): - return (byte[]) OffHeapArray.UNSAFE.allocateUninitializedArray(byte.class, length); + // use JDK9 Unsafe.allocateUninitializedArray(class, length): + return (byte[]) OffHeapArray.UNSAFE.allocateUninitializedArray(byte.class, length); } static void fill(final byte[] array, final int fromIndex, diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/CollinearSimplifier.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/CollinearSimplifier.java index dbe9c2cc8ab..5ce39ac3e4d 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/CollinearSimplifier.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/CollinearSimplifier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -146,7 +146,7 @@ final class CollinearSimplifier implements PathConsumer2D { private static float getSlope(float x1, float y1, float x2, float y2) { float dy = y2 - y1; - if (dy == 0f) { + if (dy == 0.0f) { return (x2 > x1) ? Float.POSITIVE_INFINITY : Float.NEGATIVE_INFINITY; } diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Curve.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Curve.java index 092a38ef1cc..675a1d84441 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Curve.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Curve.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -29,8 +29,6 @@ final class Curve { float ax, ay, bx, by, cx, cy, dx, dy; float dax, day, dbx, dby; - // shared iterator instance - private final BreakPtrIterator iterator = new BreakPtrIterator(); Curve() { } @@ -58,31 +56,31 @@ final class Curve { float x3, float y3, float x4, float y4) { - ax = 3f * (x2 - x3) + x4 - x1; - ay = 3f * (y2 - y3) + y4 - y1; - bx = 3f * (x1 - 2f * x2 + x3); - by = 3f * (y1 - 2f * y2 + y3); - cx = 3f * (x2 - x1); - cy = 3f * (y2 - y1); + ax = 3.0f * (x2 - x3) + x4 - x1; + ay = 3.0f * (y2 - y3) + y4 - y1; + bx = 3.0f * (x1 - 2.0f * x2 + x3); + by = 3.0f * (y1 - 2.0f * y2 + y3); + cx = 3.0f * (x2 - x1); + cy = 3.0f * (y2 - y1); dx = x1; dy = y1; - dax = 3f * ax; day = 3f * ay; - dbx = 2f * bx; dby = 2f * by; + dax = 3.0f * ax; day = 3.0f * ay; + dbx = 2.0f * bx; dby = 2.0f * by; } void set(float x1, float y1, float x2, float y2, float x3, float y3) { - ax = 0f; ay = 0f; - bx = x1 - 2f * x2 + x3; - by = y1 - 2f * y2 + y3; - cx = 2f * (x2 - x1); - cy = 2f * (y2 - y1); + ax = 0.0f; ay = 0.0f; + bx = x1 - 2.0f * x2 + x3; + by = y1 - 2.0f * y2 + y3; + cx = 2.0f * (x2 - x1); + cy = 2.0f * (y2 - y1); dx = x1; dy = y1; - dax = 0f; day = 0f; - dbx = 2f * bx; dby = 2f * by; + dax = 0.0f; day = 0.0f; + dbx = 2.0f * bx; dby = 2.0f * by; } float xat(float t) { @@ -113,7 +111,7 @@ final class Curve { // Fortunately, this turns out to be quadratic, so there are at // most 2 inflection points. final float a = dax * dby - dbx * day; - final float b = 2f * (cy * dax - day * cx); + final float b = 2.0f * (cy * dax - day * cx); final float c = cy * dbx - cx * dby; return Helpers.quadraticRoots(a, b, c, pts, off); @@ -128,11 +126,11 @@ final class Curve { // these are the coefficients of some multiple of g(t) (not g(t), // because the roots of a polynomial are not changed after multiplication // by a constant, and this way we save a few multiplications). - final float a = 2f * (dax*dax + day*day); - final float b = 3f * (dax*dbx + day*dby); - final float c = 2f * (dax*cx + day*cy) + dbx*dbx + dby*dby; + final float a = 2.0f * (dax*dax + day*day); + final float b = 3.0f * (dax*dbx + day*dby); + final float c = 2.0f * (dax*cx + day*cy) + dbx*dbx + dby*dby; final float d = dbx*cx + dby*cy; - return Helpers.cubicRootsInAB(a, b, c, d, pts, off, 0f, 1f); + return Helpers.cubicRootsInAB(a, b, c, d, pts, off, 0.0f, 1.0f); } // Tries to find the roots of the function ROC(t)-w in [0, 1). It uses @@ -153,14 +151,14 @@ final class Curve { assert off <= 6 && roots.length >= 10; int ret = off; int numPerpdfddf = perpendiculardfddf(roots, off); - float t0 = 0, ft0 = ROCsq(t0) - w*w; - roots[off + numPerpdfddf] = 1f; // always check interval end points + float t0 = 0.0f, ft0 = ROCsq(t0) - w*w; + roots[off + numPerpdfddf] = 1.0f; // always check interval end points numPerpdfddf++; for (int i = off; i < off + numPerpdfddf; i++) { float t1 = roots[i], ft1 = ROCsq(t1) - w*w; - if (ft0 == 0f) { + if (ft0 == 0.0f) { roots[ret++] = t0; - } else if (ft1 * ft0 < 0f) { // have opposite signs + } else if (ft1 * ft0 < 0.0f) { // have opposite signs // (ROC(t)^2 == w^2) == (ROC(t) == w) is true because // ROC(t) >= 0 for all t. roots[ret++] = falsePositionROCsqMinusX(t0, t1, w*w, err); @@ -220,7 +218,7 @@ final class Curve { private static boolean sameSign(float x, float y) { // another way is to test if x*y > 0. This is bad for small x, y. - return (x < 0f && y < 0f) || (x > 0f && y > 0f); + return (x < 0.0f && y < 0.0f) || (x > 0.0f && y > 0.0f); } // returns the radius of curvature squared at t of this curve @@ -229,76 +227,11 @@ final class Curve { // dx=xat(t) and dy=yat(t). These calls have been inlined for efficiency final float dx = t * (t * dax + dbx) + cx; final float dy = t * (t * day + dby) + cy; - final float ddx = 2f * dax * t + dbx; - final float ddy = 2f * day * t + dby; + final float ddx = 2.0f * dax * t + dbx; + final float ddy = 2.0f * day * t + dby; final float dx2dy2 = dx*dx + dy*dy; final float ddx2ddy2 = ddx*ddx + ddy*ddy; final float ddxdxddydy = ddx*dx + ddy*dy; return dx2dy2*((dx2dy2*dx2dy2) / (dx2dy2 * ddx2ddy2 - ddxdxddydy*ddxdxddydy)); } - - // curve to be broken should be in pts - // this will change the contents of pts but not Ts - // TODO: There's no reason for Ts to be an array. All we need is a sequence - // of t values at which to subdivide. An array statisfies this condition, - // but is unnecessarily restrictive. Ts should be an Iterator instead. - // Doing this will also make dashing easier, since we could easily make - // LengthIterator an Iterator and feed it to this function to simplify - // the loop in Dasher.somethingTo. - BreakPtrIterator breakPtsAtTs(final float[] pts, final int type, - final float[] Ts, final int numTs) - { - assert pts.length >= 2*type && numTs <= Ts.length; - - // initialize shared iterator: - iterator.init(pts, type, Ts, numTs); - - return iterator; - } - - static final class BreakPtrIterator { - private int nextCurveIdx; - private int curCurveOff; - private float prevT; - private float[] pts; - private int type; - private float[] ts; - private int numTs; - - void init(final float[] pts, final int type, - final float[] ts, final int numTs) { - this.pts = pts; - this.type = type; - this.ts = ts; - this.numTs = numTs; - - nextCurveIdx = 0; - curCurveOff = 0; - prevT = 0f; - } - - public boolean hasNext() { - return nextCurveIdx <= numTs; - } - - public int next() { - int ret; - if (nextCurveIdx < numTs) { - float curT = ts[nextCurveIdx]; - float splitT = (curT - prevT) / (1f - prevT); - Helpers.subdivideAt(splitT, - pts, curCurveOff, - pts, 0, - pts, type, type); - prevT = curT; - ret = 0; - curCurveOff = type; - } else { - ret = curCurveOff; - } - nextCurveIdx++; - return ret; - } - } } - diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DCollinearSimplifier.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DCollinearSimplifier.java new file mode 100644 index 00000000000..d9909ce97ee --- /dev/null +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DCollinearSimplifier.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2015, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.java2d.marlin; + + +final class DCollinearSimplifier implements DPathConsumer2D { + + enum SimplifierState { + + Empty, PreviousPoint, PreviousLine + }; + // slope precision threshold + static final double EPS = 1e-4d; // aaime proposed 1e-3d + + DPathConsumer2D delegate; + SimplifierState state; + double px1, py1, px2, py2; + double pslope; + + DCollinearSimplifier() { + } + + public DCollinearSimplifier init(DPathConsumer2D delegate) { + this.delegate = delegate; + this.state = SimplifierState.Empty; + + return this; // fluent API + } + + @Override + public void pathDone() { + emitStashedLine(); + state = SimplifierState.Empty; + delegate.pathDone(); + } + + @Override + public void closePath() { + emitStashedLine(); + state = SimplifierState.Empty; + delegate.closePath(); + } + + @Override + public long getNativeConsumer() { + return 0; + } + + @Override + public void quadTo(double x1, double y1, double x2, double y2) { + emitStashedLine(); + delegate.quadTo(x1, y1, x2, y2); + // final end point: + state = SimplifierState.PreviousPoint; + px1 = x2; + py1 = y2; + } + + @Override + public void curveTo(double x1, double y1, double x2, double y2, + double x3, double y3) { + emitStashedLine(); + delegate.curveTo(x1, y1, x2, y2, x3, y3); + // final end point: + state = SimplifierState.PreviousPoint; + px1 = x3; + py1 = y3; + } + + @Override + public void moveTo(double x, double y) { + emitStashedLine(); + delegate.moveTo(x, y); + state = SimplifierState.PreviousPoint; + px1 = x; + py1 = y; + } + + @Override + public void lineTo(final double x, final double y) { + switch (state) { + case Empty: + delegate.lineTo(x, y); + state = SimplifierState.PreviousPoint; + px1 = x; + py1 = y; + return; + + case PreviousPoint: + state = SimplifierState.PreviousLine; + px2 = x; + py2 = y; + pslope = getSlope(px1, py1, x, y); + return; + + case PreviousLine: + final double slope = getSlope(px2, py2, x, y); + // test for collinearity + if ((slope == pslope) || (Math.abs(pslope - slope) < EPS)) { + // merge segments + px2 = x; + py2 = y; + return; + } + // emit previous segment + delegate.lineTo(px2, py2); + px1 = px2; + py1 = py2; + px2 = x; + py2 = y; + pslope = slope; + return; + default: + } + } + + private void emitStashedLine() { + if (state == SimplifierState.PreviousLine) { + delegate.lineTo(px2, py2); + } + } + + private static double getSlope(double x1, double y1, double x2, double y2) { + double dy = y2 - y1; + if (dy == 0.0d) { + return (x2 > x1) ? Double.POSITIVE_INFINITY + : Double.NEGATIVE_INFINITY; + } + return (x2 - x1) / dy; + } +} diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DCurve.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DCurve.java new file mode 100644 index 00000000000..7cffcdcf8ae --- /dev/null +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DCurve.java @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2007, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.java2d.marlin; + +final class DCurve { + + double ax, ay, bx, by, cx, cy, dx, dy; + double dax, day, dbx, dby; + + DCurve() { + } + + void set(double[] points, int type) { + switch(type) { + case 8: + set(points[0], points[1], + points[2], points[3], + points[4], points[5], + points[6], points[7]); + return; + case 6: + set(points[0], points[1], + points[2], points[3], + points[4], points[5]); + return; + default: + throw new InternalError("Curves can only be cubic or quadratic"); + } + } + + void set(double x1, double y1, + double x2, double y2, + double x3, double y3, + double x4, double y4) + { + ax = 3.0d * (x2 - x3) + x4 - x1; + ay = 3.0d * (y2 - y3) + y4 - y1; + bx = 3.0d * (x1 - 2.0d * x2 + x3); + by = 3.0d * (y1 - 2.0d * y2 + y3); + cx = 3.0d * (x2 - x1); + cy = 3.0d * (y2 - y1); + dx = x1; + dy = y1; + dax = 3.0d * ax; day = 3.0d * ay; + dbx = 2.0d * bx; dby = 2.0d * by; + } + + void set(double x1, double y1, + double x2, double y2, + double x3, double y3) + { + ax = 0.0d; ay = 0.0d; + bx = x1 - 2.0d * x2 + x3; + by = y1 - 2.0d * y2 + y3; + cx = 2.0d * (x2 - x1); + cy = 2.0d * (y2 - y1); + dx = x1; + dy = y1; + dax = 0.0d; day = 0.0d; + dbx = 2.0d * bx; dby = 2.0d * by; + } + + double xat(double t) { + return t * (t * (t * ax + bx) + cx) + dx; + } + double yat(double t) { + return t * (t * (t * ay + by) + cy) + dy; + } + + double dxat(double t) { + return t * (t * dax + dbx) + cx; + } + + double dyat(double t) { + return t * (t * day + dby) + cy; + } + + int dxRoots(double[] roots, int off) { + return DHelpers.quadraticRoots(dax, dbx, cx, roots, off); + } + + int dyRoots(double[] roots, int off) { + return DHelpers.quadraticRoots(day, dby, cy, roots, off); + } + + int infPoints(double[] pts, int off) { + // inflection point at t if -f'(t)x*f''(t)y + f'(t)y*f''(t)x == 0 + // Fortunately, this turns out to be quadratic, so there are at + // most 2 inflection points. + final double a = dax * dby - dbx * day; + final double b = 2.0d * (cy * dax - day * cx); + final double c = cy * dbx - cx * dby; + + return DHelpers.quadraticRoots(a, b, c, pts, off); + } + + // finds points where the first and second derivative are + // perpendicular. This happens when g(t) = f'(t)*f''(t) == 0 (where + // * is a dot product). Unfortunately, we have to solve a cubic. + private int perpendiculardfddf(double[] pts, int off) { + assert pts.length >= off + 4; + + // these are the coefficients of some multiple of g(t) (not g(t), + // because the roots of a polynomial are not changed after multiplication + // by a constant, and this way we save a few multiplications). + final double a = 2.0d * (dax*dax + day*day); + final double b = 3.0d * (dax*dbx + day*dby); + final double c = 2.0d * (dax*cx + day*cy) + dbx*dbx + dby*dby; + final double d = dbx*cx + dby*cy; + return DHelpers.cubicRootsInAB(a, b, c, d, pts, off, 0.0d, 1.0d); + } + + // Tries to find the roots of the function ROC(t)-w in [0, 1). It uses + // a variant of the false position algorithm to find the roots. False + // position requires that 2 initial values x0,x1 be given, and that the + // function must have opposite signs at those values. To find such + // values, we need the local extrema of the ROC function, for which we + // need the roots of its derivative; however, it's harder to find the + // roots of the derivative in this case than it is to find the roots + // of the original function. So, we find all points where this curve's + // first and second derivative are perpendicular, and we pretend these + // are our local extrema. There are at most 3 of these, so we will check + // at most 4 sub-intervals of (0,1). ROC has asymptotes at inflection + // points, so roc-w can have at least 6 roots. This shouldn't be a + // problem for what we're trying to do (draw a nice looking curve). + int rootsOfROCMinusW(double[] roots, int off, final double w, final double err) { + // no OOB exception, because by now off<=6, and roots.length >= 10 + assert off <= 6 && roots.length >= 10; + int ret = off; + int numPerpdfddf = perpendiculardfddf(roots, off); + double t0 = 0.0d, ft0 = ROCsq(t0) - w*w; + roots[off + numPerpdfddf] = 1.0d; // always check interval end points + numPerpdfddf++; + for (int i = off; i < off + numPerpdfddf; i++) { + double t1 = roots[i], ft1 = ROCsq(t1) - w*w; + if (ft0 == 0.0d) { + roots[ret++] = t0; + } else if (ft1 * ft0 < 0.0d) { // have opposite signs + // (ROC(t)^2 == w^2) == (ROC(t) == w) is true because + // ROC(t) >= 0 for all t. + roots[ret++] = falsePositionROCsqMinusX(t0, t1, w*w, err); + } + t0 = t1; + ft0 = ft1; + } + + return ret - off; + } + + private static double eliminateInf(double x) { + return (x == Double.POSITIVE_INFINITY ? Double.MAX_VALUE : + (x == Double.NEGATIVE_INFINITY ? Double.MIN_VALUE : x)); + } + + // A slight modification of the false position algorithm on wikipedia. + // This only works for the ROCsq-x functions. It might be nice to have + // the function as an argument, but that would be awkward in java6. + // TODO: It is something to consider for java8 (or whenever lambda + // expressions make it into the language), depending on how closures + // and turn out. Same goes for the newton's method + // algorithm in DHelpers.java + private double falsePositionROCsqMinusX(double x0, double x1, + final double x, final double err) + { + final int iterLimit = 100; + int side = 0; + double t = x1, ft = eliminateInf(ROCsq(t) - x); + double s = x0, fs = eliminateInf(ROCsq(s) - x); + double r = s, fr; + for (int i = 0; i < iterLimit && Math.abs(t - s) > err * Math.abs(t + s); i++) { + r = (fs * t - ft * s) / (fs - ft); + fr = ROCsq(r) - x; + if (sameSign(fr, ft)) { + ft = fr; t = r; + if (side < 0) { + fs /= (1 << (-side)); + side--; + } else { + side = -1; + } + } else if (fr * fs > 0) { + fs = fr; s = r; + if (side > 0) { + ft /= (1 << side); + side++; + } else { + side = 1; + } + } else { + break; + } + } + return r; + } + + private static boolean sameSign(double x, double y) { + // another way is to test if x*y > 0. This is bad for small x, y. + return (x < 0.0d && y < 0.0d) || (x > 0.0d && y > 0.0d); + } + + // returns the radius of curvature squared at t of this curve + // see http://en.wikipedia.org/wiki/Radius_of_curvature_(applications) + private double ROCsq(final double t) { + // dx=xat(t) and dy=yat(t). These calls have been inlined for efficiency + final double dx = t * (t * dax + dbx) + cx; + final double dy = t * (t * day + dby) + cy; + final double ddx = 2.0d * dax * t + dbx; + final double ddy = 2.0d * day * t + dby; + final double dx2dy2 = dx*dx + dy*dy; + final double ddx2ddy2 = ddx*ddx + ddy*ddy; + final double ddxdxddydy = ddx*dx + ddy*dy; + return dx2dy2*((dx2dy2*dx2dy2) / (dx2dy2 * ddx2ddy2 - ddxdxddydy*ddxdxddydy)); + } +} diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DDasher.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DDasher.java new file mode 100644 index 00000000000..3999b9e8c6e --- /dev/null +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DDasher.java @@ -0,0 +1,746 @@ +/* + * Copyright (c) 2007, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.java2d.marlin; + +import java.util.Arrays; + +/** + * The DDasher class takes a series of linear commands + * (moveTo, lineTo, close and + * end) and breaks them into smaller segments according to a + * dash pattern array and a starting dash phase. + * + *

Issues: in J2Se, a zero length dash segment as drawn as a very + * short dash, whereas Pisces does not draw anything. The PostScript + * semantics are unclear. + * + */ +final class DDasher implements DPathConsumer2D, MarlinConst { + + static final int REC_LIMIT = 4; + static final double ERR = 0.01d; + static final double MIN_T_INC = 1.0d / (1 << REC_LIMIT); + + // More than 24 bits of mantissa means we can no longer accurately + // measure the number of times cycled through the dash array so we + // punt and override the phase to just be 0 past that point. + static final double MAX_CYCLES = 16000000.0d; + + private DPathConsumer2D out; + private double[] dash; + private int dashLen; + private double startPhase; + private boolean startDashOn; + private int startIdx; + + private boolean starting; + private boolean needsMoveTo; + + private int idx; + private boolean dashOn; + private double phase; + + private double sx, sy; + private double x0, y0; + + // temporary storage for the current curve + private final double[] curCurvepts; + + // per-thread renderer context + final DRendererContext rdrCtx; + + // flag to recycle dash array copy + boolean recycleDashes; + + // dashes ref (dirty) + final DoubleArrayCache.Reference dashes_ref; + // firstSegmentsBuffer ref (dirty) + final DoubleArrayCache.Reference firstSegmentsBuffer_ref; + + /** + * Constructs a DDasher. + * @param rdrCtx per-thread renderer context + */ + DDasher(final DRendererContext rdrCtx) { + this.rdrCtx = rdrCtx; + + dashes_ref = rdrCtx.newDirtyDoubleArrayRef(INITIAL_ARRAY); // 1K + + firstSegmentsBuffer_ref = rdrCtx.newDirtyDoubleArrayRef(INITIAL_ARRAY); // 1K + firstSegmentsBuffer = firstSegmentsBuffer_ref.initial; + + // we need curCurvepts to be able to contain 2 curves because when + // dashing curves, we need to subdivide it + curCurvepts = new double[8 * 2]; + } + + /** + * Initialize the DDasher. + * + * @param out an output DPathConsumer2D. + * @param dash an array of doubles containing the dash pattern + * @param dashLen length of the given dash array + * @param phase a double containing the dash phase + * @param recycleDashes true to indicate to recycle the given dash array + * @return this instance + */ + DDasher init(final DPathConsumer2D out, double[] dash, int dashLen, + double phase, boolean recycleDashes) + { + this.out = out; + + // Normalize so 0 <= phase < dash[0] + int sidx = 0; + dashOn = true; + double sum = 0.0d; + for (double d : dash) { + sum += d; + } + double cycles = phase / sum; + if (phase < 0.0d) { + if (-cycles >= MAX_CYCLES) { + phase = 0.0d; + } else { + int fullcycles = FloatMath.floor_int(-cycles); + if ((fullcycles & dash.length & 1) != 0) { + dashOn = !dashOn; + } + phase += fullcycles * sum; + while (phase < 0.0d) { + if (--sidx < 0) { + sidx = dash.length - 1; + } + phase += dash[sidx]; + dashOn = !dashOn; + } + } + } else if (phase > 0) { + if (cycles >= MAX_CYCLES) { + phase = 0.0d; + } else { + int fullcycles = FloatMath.floor_int(cycles); + if ((fullcycles & dash.length & 1) != 0) { + dashOn = !dashOn; + } + phase -= fullcycles * sum; + double d; + while (phase >= (d = dash[sidx])) { + phase -= d; + sidx = (sidx + 1) % dash.length; + dashOn = !dashOn; + } + } + } + + this.dash = dash; + this.dashLen = dashLen; + this.startPhase = this.phase = phase; + this.startDashOn = dashOn; + this.startIdx = sidx; + this.starting = true; + needsMoveTo = false; + firstSegidx = 0; + + this.recycleDashes = recycleDashes; + + return this; // fluent API + } + + /** + * Disposes this dasher: + * clean up before reusing this instance + */ + void dispose() { + if (DO_CLEAN_DIRTY) { + // Force zero-fill dirty arrays: + Arrays.fill(curCurvepts, 0.0d); + } + // Return arrays: + if (recycleDashes) { + dash = dashes_ref.putArray(dash); + } + firstSegmentsBuffer = firstSegmentsBuffer_ref.putArray(firstSegmentsBuffer); + } + + double[] copyDashArray(final float[] dashes) { + final int len = dashes.length; + final double[] newDashes; + if (len <= MarlinConst.INITIAL_ARRAY) { + newDashes = dashes_ref.initial; + } else { + if (DO_STATS) { + rdrCtx.stats.stat_array_dasher_dasher.add(len); + } + newDashes = dashes_ref.getArray(len); + } + for (int i = 0; i < len; i++) { newDashes[i] = dashes[i]; } + return newDashes; + } + + @Override + public void moveTo(double x0, double y0) { + if (firstSegidx > 0) { + out.moveTo(sx, sy); + emitFirstSegments(); + } + needsMoveTo = true; + this.idx = startIdx; + this.dashOn = this.startDashOn; + this.phase = this.startPhase; + this.sx = this.x0 = x0; + this.sy = this.y0 = y0; + this.starting = true; + } + + private void emitSeg(double[] buf, int off, int type) { + switch (type) { + case 8: + out.curveTo(buf[off+0], buf[off+1], + buf[off+2], buf[off+3], + buf[off+4], buf[off+5]); + return; + case 6: + out.quadTo(buf[off+0], buf[off+1], + buf[off+2], buf[off+3]); + return; + case 4: + out.lineTo(buf[off], buf[off+1]); + return; + default: + } + } + + private void emitFirstSegments() { + final double[] fSegBuf = firstSegmentsBuffer; + + for (int i = 0; i < firstSegidx; ) { + int type = (int)fSegBuf[i]; + emitSeg(fSegBuf, i + 1, type); + i += (type - 1); + } + firstSegidx = 0; + } + // We don't emit the first dash right away. If we did, caps would be + // drawn on it, but we need joins to be drawn if there's a closePath() + // So, we store the path elements that make up the first dash in the + // buffer below. + private double[] firstSegmentsBuffer; // dynamic array + private int firstSegidx; + + // precondition: pts must be in relative coordinates (relative to x0,y0) + private void goTo(double[] pts, int off, final int type) { + double x = pts[off + type - 4]; + double y = pts[off + type - 3]; + if (dashOn) { + if (starting) { + int len = type - 1; // - 2 + 1 + int segIdx = firstSegidx; + double[] buf = firstSegmentsBuffer; + if (segIdx + len > buf.length) { + if (DO_STATS) { + rdrCtx.stats.stat_array_dasher_firstSegmentsBuffer + .add(segIdx + len); + } + firstSegmentsBuffer = buf + = firstSegmentsBuffer_ref.widenArray(buf, segIdx, + segIdx + len); + } + buf[segIdx++] = type; + len--; + // small arraycopy (2, 4 or 6) but with offset: + System.arraycopy(pts, off, buf, segIdx, len); + segIdx += len; + firstSegidx = segIdx; + } else { + if (needsMoveTo) { + out.moveTo(x0, y0); + needsMoveTo = false; + } + emitSeg(pts, off, type); + } + } else { + starting = false; + needsMoveTo = true; + } + this.x0 = x; + this.y0 = y; + } + + @Override + public void lineTo(double x1, double y1) { + double dx = x1 - x0; + double dy = y1 - y0; + + double len = dx*dx + dy*dy; + if (len == 0.0d) { + return; + } + len = Math.sqrt(len); + + // The scaling factors needed to get the dx and dy of the + // transformed dash segments. + final double cx = dx / len; + final double cy = dy / len; + + final double[] _curCurvepts = curCurvepts; + final double[] _dash = dash; + + double leftInThisDashSegment; + double dashdx, dashdy, p; + + while (true) { + leftInThisDashSegment = _dash[idx] - phase; + + if (len <= leftInThisDashSegment) { + _curCurvepts[0] = x1; + _curCurvepts[1] = y1; + goTo(_curCurvepts, 0, 4); + + // Advance phase within current dash segment + phase += len; + // TODO: compare double values using epsilon: + if (len == leftInThisDashSegment) { + phase = 0.0d; + idx = (idx + 1) % dashLen; + dashOn = !dashOn; + } + return; + } + + dashdx = _dash[idx] * cx; + dashdy = _dash[idx] * cy; + + if (phase == 0.0d) { + _curCurvepts[0] = x0 + dashdx; + _curCurvepts[1] = y0 + dashdy; + } else { + p = leftInThisDashSegment / _dash[idx]; + _curCurvepts[0] = x0 + p * dashdx; + _curCurvepts[1] = y0 + p * dashdy; + } + + goTo(_curCurvepts, 0, 4); + + len -= leftInThisDashSegment; + // Advance to next dash segment + idx = (idx + 1) % dashLen; + dashOn = !dashOn; + phase = 0.0d; + } + } + + // shared instance in DDasher + private final LengthIterator li = new LengthIterator(); + + // preconditions: curCurvepts must be an array of length at least 2 * type, + // that contains the curve we want to dash in the first type elements + private void somethingTo(int type) { + if (pointCurve(curCurvepts, type)) { + return; + } + li.initializeIterationOnCurve(curCurvepts, type); + + // initially the current curve is at curCurvepts[0...type] + int curCurveoff = 0; + double lastSplitT = 0.0d; + double t; + double leftInThisDashSegment = dash[idx] - phase; + + while ((t = li.next(leftInThisDashSegment)) < 1.0d) { + if (t != 0.0d) { + DHelpers.subdivideAt((t - lastSplitT) / (1.0d - lastSplitT), + curCurvepts, curCurveoff, + curCurvepts, 0, + curCurvepts, type, type); + lastSplitT = t; + goTo(curCurvepts, 2, type); + curCurveoff = type; + } + // Advance to next dash segment + idx = (idx + 1) % dashLen; + dashOn = !dashOn; + phase = 0.0d; + leftInThisDashSegment = dash[idx]; + } + goTo(curCurvepts, curCurveoff+2, type); + phase += li.lastSegLen(); + if (phase >= dash[idx]) { + phase = 0.0d; + idx = (idx + 1) % dashLen; + dashOn = !dashOn; + } + // reset LengthIterator: + li.reset(); + } + + private static boolean pointCurve(double[] curve, int type) { + for (int i = 2; i < type; i++) { + if (curve[i] != curve[i-2]) { + return false; + } + } + return true; + } + + // Objects of this class are used to iterate through curves. They return + // t values where the left side of the curve has a specified length. + // It does this by subdividing the input curve until a certain error + // condition has been met. A recursive subdivision procedure would + // return as many as 1<= 0; i--) { + Arrays.fill(recCurveStack[i], 0.0d); + } + Arrays.fill(sides, Side.LEFT); + Arrays.fill(curLeafCtrlPolyLengths, 0.0d); + Arrays.fill(nextRoots, 0.0d); + Arrays.fill(flatLeafCoefCache, 0.0d); + flatLeafCoefCache[2] = -1.0d; + } + } + + void initializeIterationOnCurve(double[] pts, int type) { + // optimize arraycopy (8 values faster than 6 = type): + System.arraycopy(pts, 0, recCurveStack[0], 0, 8); + this.curveType = type; + this.recLevel = 0; + this.lastT = 0.0d; + this.lenAtLastT = 0.0d; + this.nextT = 0.0d; + this.lenAtNextT = 0.0d; + goLeft(); // initializes nextT and lenAtNextT properly + this.lenAtLastSplit = 0.0d; + if (recLevel > 0) { + this.sides[0] = Side.LEFT; + this.done = false; + } else { + // the root of the tree is a leaf so we're done. + this.sides[0] = Side.RIGHT; + this.done = true; + } + this.lastSegLen = 0.0d; + } + + // 0 == false, 1 == true, -1 == invalid cached value. + private int cachedHaveLowAcceleration = -1; + + private boolean haveLowAcceleration(double err) { + if (cachedHaveLowAcceleration == -1) { + final double len1 = curLeafCtrlPolyLengths[0]; + final double len2 = curLeafCtrlPolyLengths[1]; + // the test below is equivalent to !within(len1/len2, 1, err). + // It is using a multiplication instead of a division, so it + // should be a bit faster. + if (!DHelpers.within(len1, len2, err * len2)) { + cachedHaveLowAcceleration = 0; + return false; + } + if (curveType == 8) { + final double len3 = curLeafCtrlPolyLengths[2]; + // if len1 is close to 2 and 2 is close to 3, that probably + // means 1 is close to 3 so the second part of this test might + // not be needed, but it doesn't hurt to include it. + final double errLen3 = err * len3; + if (!(DHelpers.within(len2, len3, errLen3) && + DHelpers.within(len1, len3, errLen3))) { + cachedHaveLowAcceleration = 0; + return false; + } + } + cachedHaveLowAcceleration = 1; + return true; + } + + return (cachedHaveLowAcceleration == 1); + } + + // we want to avoid allocations/gc so we keep this array so we + // can put roots in it, + private final double[] nextRoots = new double[4]; + + // caches the coefficients of the current leaf in its flattened + // form (see inside next() for what that means). The cache is + // invalid when it's third element is negative, since in any + // valid flattened curve, this would be >= 0. + private final double[] flatLeafCoefCache = new double[]{0.0d, 0.0d, -1.0d, 0.0d}; + + // returns the t value where the remaining curve should be split in + // order for the left subdivided curve to have length len. If len + // is >= than the length of the uniterated curve, it returns 1. + double next(final double len) { + final double targetLength = lenAtLastSplit + len; + while (lenAtNextT < targetLength) { + if (done) { + lastSegLen = lenAtNextT - lenAtLastSplit; + return 1.0d; + } + goToNextLeaf(); + } + lenAtLastSplit = targetLength; + final double leaflen = lenAtNextT - lenAtLastT; + double t = (targetLength - lenAtLastT) / leaflen; + + // cubicRootsInAB is a fairly expensive call, so we just don't do it + // if the acceleration in this section of the curve is small enough. + if (!haveLowAcceleration(0.05d)) { + // We flatten the current leaf along the x axis, so that we're + // left with a, b, c which define a 1D Bezier curve. We then + // solve this to get the parameter of the original leaf that + // gives us the desired length. + final double[] _flatLeafCoefCache = flatLeafCoefCache; + + if (_flatLeafCoefCache[2] < 0.0d) { + double x = curLeafCtrlPolyLengths[0], + y = x + curLeafCtrlPolyLengths[1]; + if (curveType == 8) { + double z = y + curLeafCtrlPolyLengths[2]; + _flatLeafCoefCache[0] = 3.0d * (x - y) + z; + _flatLeafCoefCache[1] = 3.0d * (y - 2.0d * x); + _flatLeafCoefCache[2] = 3.0d * x; + _flatLeafCoefCache[3] = -z; + } else if (curveType == 6) { + _flatLeafCoefCache[0] = 0.0d; + _flatLeafCoefCache[1] = y - 2.0d * x; + _flatLeafCoefCache[2] = 2.0d * x; + _flatLeafCoefCache[3] = -y; + } + } + double a = _flatLeafCoefCache[0]; + double b = _flatLeafCoefCache[1]; + double c = _flatLeafCoefCache[2]; + double d = t * _flatLeafCoefCache[3]; + + // we use cubicRootsInAB here, because we want only roots in 0, 1, + // and our quadratic root finder doesn't filter, so it's just a + // matter of convenience. + int n = DHelpers.cubicRootsInAB(a, b, c, d, nextRoots, 0, 0.0d, 1.0d); + if (n == 1 && !Double.isNaN(nextRoots[0])) { + t = nextRoots[0]; + } + } + // t is relative to the current leaf, so we must make it a valid parameter + // of the original curve. + t = t * (nextT - lastT) + lastT; + if (t >= 1.0d) { + t = 1.0d; + done = true; + } + // even if done = true, if we're here, that means targetLength + // is equal to, or very, very close to the total length of the + // curve, so lastSegLen won't be too high. In cases where len + // overshoots the curve, this method will exit in the while + // loop, and lastSegLen will still be set to the right value. + lastSegLen = len; + return t; + } + + double lastSegLen() { + return lastSegLen; + } + + // go to the next leaf (in an inorder traversal) in the recursion tree + // preconditions: must be on a leaf, and that leaf must not be the root. + private void goToNextLeaf() { + // We must go to the first ancestor node that has an unvisited + // right child. + int _recLevel = recLevel; + final Side[] _sides = sides; + + _recLevel--; + while(_sides[_recLevel] == Side.RIGHT) { + if (_recLevel == 0) { + recLevel = 0; + done = true; + return; + } + _recLevel--; + } + + _sides[_recLevel] = Side.RIGHT; + // optimize arraycopy (8 values faster than 6 = type): + System.arraycopy(recCurveStack[_recLevel], 0, + recCurveStack[_recLevel+1], 0, 8); + _recLevel++; + + recLevel = _recLevel; + goLeft(); + } + + // go to the leftmost node from the current node. Return its length. + private void goLeft() { + double len = onLeaf(); + if (len >= 0.0d) { + lastT = nextT; + lenAtLastT = lenAtNextT; + nextT += (1 << (REC_LIMIT - recLevel)) * MIN_T_INC; + lenAtNextT += len; + // invalidate caches + flatLeafCoefCache[2] = -1.0d; + cachedHaveLowAcceleration = -1; + } else { + DHelpers.subdivide(recCurveStack[recLevel], 0, + recCurveStack[recLevel+1], 0, + recCurveStack[recLevel], 0, curveType); + sides[recLevel] = Side.LEFT; + recLevel++; + goLeft(); + } + } + + // this is a bit of a hack. It returns -1 if we're not on a leaf, and + // the length of the leaf if we are on a leaf. + private double onLeaf() { + double[] curve = recCurveStack[recLevel]; + double polyLen = 0.0d; + + double x0 = curve[0], y0 = curve[1]; + for (int i = 2; i < curveType; i += 2) { + final double x1 = curve[i], y1 = curve[i+1]; + final double len = DHelpers.linelen(x0, y0, x1, y1); + polyLen += len; + curLeafCtrlPolyLengths[i/2 - 1] = len; + x0 = x1; + y0 = y1; + } + + final double lineLen = DHelpers.linelen(curve[0], curve[1], + curve[curveType-2], + curve[curveType-1]); + if ((polyLen - lineLen) < ERR || recLevel == REC_LIMIT) { + return (polyLen + lineLen) / 2.0d; + } + return -1.0d; + } + } + + @Override + public void curveTo(double x1, double y1, + double x2, double y2, + double x3, double y3) + { + final double[] _curCurvepts = curCurvepts; + _curCurvepts[0] = x0; _curCurvepts[1] = y0; + _curCurvepts[2] = x1; _curCurvepts[3] = y1; + _curCurvepts[4] = x2; _curCurvepts[5] = y2; + _curCurvepts[6] = x3; _curCurvepts[7] = y3; + somethingTo(8); + } + + @Override + public void quadTo(double x1, double y1, double x2, double y2) { + final double[] _curCurvepts = curCurvepts; + _curCurvepts[0] = x0; _curCurvepts[1] = y0; + _curCurvepts[2] = x1; _curCurvepts[3] = y1; + _curCurvepts[4] = x2; _curCurvepts[5] = y2; + somethingTo(6); + } + + @Override + public void closePath() { + lineTo(sx, sy); + if (firstSegidx > 0) { + if (!dashOn || needsMoveTo) { + out.moveTo(sx, sy); + } + emitFirstSegments(); + } + moveTo(sx, sy); + } + + @Override + public void pathDone() { + if (firstSegidx > 0) { + out.moveTo(sx, sy); + emitFirstSegments(); + } + out.pathDone(); + + // Dispose this instance: + dispose(); + } + + @Override + public long getNativeConsumer() { + throw new InternalError("DDasher does not use a native consumer"); + } +} + diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DHelpers.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DHelpers.java new file mode 100644 index 00000000000..78bf4e0616a --- /dev/null +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DHelpers.java @@ -0,0 +1,436 @@ +/* + * Copyright (c) 2007, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.java2d.marlin; + +import static java.lang.Math.PI; +import static java.lang.Math.cos; +import static java.lang.Math.sqrt; +import static java.lang.Math.cbrt; +import static java.lang.Math.acos; + +final class DHelpers implements MarlinConst { + + private DHelpers() { + throw new Error("This is a non instantiable class"); + } + + static boolean within(final double x, final double y, final double err) { + final double d = y - x; + return (d <= err && d >= -err); + } + + static int quadraticRoots(final double a, final double b, + final double c, double[] zeroes, final int off) + { + int ret = off; + double t; + if (a != 0.0d) { + final double dis = b*b - 4*a*c; + if (dis > 0.0d) { + final double sqrtDis = Math.sqrt(dis); + // depending on the sign of b we use a slightly different + // algorithm than the traditional one to find one of the roots + // so we can avoid adding numbers of different signs (which + // might result in loss of precision). + if (b >= 0.0d) { + zeroes[ret++] = (2.0d * c) / (-b - sqrtDis); + zeroes[ret++] = (-b - sqrtDis) / (2.0d * a); + } else { + zeroes[ret++] = (-b + sqrtDis) / (2.0d * a); + zeroes[ret++] = (2.0d * c) / (-b + sqrtDis); + } + } else if (dis == 0.0d) { + t = (-b) / (2.0d * a); + zeroes[ret++] = t; + } + } else { + if (b != 0.0d) { + t = (-c) / b; + zeroes[ret++] = t; + } + } + return ret - off; + } + + // find the roots of g(t) = d*t^3 + a*t^2 + b*t + c in [A,B) + static int cubicRootsInAB(double d, double a, double b, double c, + double[] pts, final int off, + final double A, final double B) + { + if (d == 0.0d) { + int num = quadraticRoots(a, b, c, pts, off); + return filterOutNotInAB(pts, off, num, A, B) - off; + } + // From Graphics Gems: + // http://tog.acm.org/resources/GraphicsGems/gems/Roots3And4.c + // (also from awt.geom.CubicCurve2D. But here we don't need as + // much accuracy and we don't want to create arrays so we use + // our own customized version). + + // normal form: x^3 + ax^2 + bx + c = 0 + a /= d; + b /= d; + c /= d; + + // substitute x = y - A/3 to eliminate quadratic term: + // x^3 +Px + Q = 0 + // + // Since we actually need P/3 and Q/2 for all of the + // calculations that follow, we will calculate + // p = P/3 + // q = Q/2 + // instead and use those values for simplicity of the code. + double sq_A = a * a; + double p = (1.0d/3.0d) * ((-1.0d/3.0d) * sq_A + b); + double q = (1.0d/2.0d) * ((2.0d/27.0d) * a * sq_A - (1.0d/3.0d) * a * b + c); + + // use Cardano's formula + + double cb_p = p * p * p; + double D = q * q + cb_p; + + int num; + if (D < 0.0d) { + // see: http://en.wikipedia.org/wiki/Cubic_function#Trigonometric_.28and_hyperbolic.29_method + final double phi = (1.0d/3.0d) * acos(-q / sqrt(-cb_p)); + final double t = 2.0d * sqrt(-p); + + pts[ off+0 ] = ( t * cos(phi)); + pts[ off+1 ] = (-t * cos(phi + (PI / 3.0d))); + pts[ off+2 ] = (-t * cos(phi - (PI / 3.0d))); + num = 3; + } else { + final double sqrt_D = sqrt(D); + final double u = cbrt(sqrt_D - q); + final double v = - cbrt(sqrt_D + q); + + pts[ off ] = (u + v); + num = 1; + + if (within(D, 0.0d, 1e-8d)) { + pts[off+1] = -(pts[off] / 2.0d); + num = 2; + } + } + + final double sub = (1.0d/3.0d) * a; + + for (int i = 0; i < num; ++i) { + pts[ off+i ] -= sub; + } + + return filterOutNotInAB(pts, off, num, A, B) - off; + } + + static double evalCubic(final double a, final double b, + final double c, final double d, + final double t) + { + return t * (t * (t * a + b) + c) + d; + } + + static double evalQuad(final double a, final double b, + final double c, final double t) + { + return t * (t * a + b) + c; + } + + // returns the index 1 past the last valid element remaining after filtering + static int filterOutNotInAB(double[] nums, final int off, final int len, + final double a, final double b) + { + int ret = off; + for (int i = off, end = off + len; i < end; i++) { + if (nums[i] >= a && nums[i] < b) { + nums[ret++] = nums[i]; + } + } + return ret; + } + + static double polyLineLength(double[] poly, final int off, final int nCoords) { + assert nCoords % 2 == 0 && poly.length >= off + nCoords : ""; + double acc = 0.0d; + for (int i = off + 2; i < off + nCoords; i += 2) { + acc += linelen(poly[i], poly[i+1], poly[i-2], poly[i-1]); + } + return acc; + } + + static double linelen(double x1, double y1, double x2, double y2) { + final double dx = x2 - x1; + final double dy = y2 - y1; + return Math.sqrt(dx*dx + dy*dy); + } + + static void subdivide(double[] src, int srcoff, double[] left, int leftoff, + double[] right, int rightoff, int type) + { + switch(type) { + case 6: + DHelpers.subdivideQuad(src, srcoff, left, leftoff, right, rightoff); + return; + case 8: + DHelpers.subdivideCubic(src, srcoff, left, leftoff, right, rightoff); + return; + default: + throw new InternalError("Unsupported curve type"); + } + } + + static void isort(double[] a, int off, int len) { + for (int i = off + 1, end = off + len; i < end; i++) { + double ai = a[i]; + int j = i - 1; + for (; j >= off && a[j] > ai; j--) { + a[j+1] = a[j]; + } + a[j+1] = ai; + } + } + + // Most of these are copied from classes in java.awt.geom because we need + // both single and double precision variants of these functions, and Line2D, + // CubicCurve2D, QuadCurve2D don't provide them. + /** + * Subdivides the cubic curve specified by the coordinates + * stored in the src array at indices srcoff + * through (srcoff + 7) and stores the + * resulting two subdivided curves into the two result arrays at the + * corresponding indices. + * Either or both of the left and right + * arrays may be null or a reference to the same array + * as the src array. + * Note that the last point in the first subdivided curve is the + * same as the first point in the second subdivided curve. Thus, + * it is possible to pass the same array for left + * and right and to use offsets, such as rightoff + * equals (leftoff + 6), in order + * to avoid allocating extra storage for this common point. + * @param src the array holding the coordinates for the source curve + * @param srcoff the offset into the array of the beginning of the + * the 6 source coordinates + * @param left the array for storing the coordinates for the first + * half of the subdivided curve + * @param leftoff the offset into the array of the beginning of the + * the 6 left coordinates + * @param right the array for storing the coordinates for the second + * half of the subdivided curve + * @param rightoff the offset into the array of the beginning of the + * the 6 right coordinates + * @since 1.7 + */ + static void subdivideCubic(double[] src, int srcoff, + double[] left, int leftoff, + double[] right, int rightoff) + { + double x1 = src[srcoff + 0]; + double y1 = src[srcoff + 1]; + double ctrlx1 = src[srcoff + 2]; + double ctrly1 = src[srcoff + 3]; + double ctrlx2 = src[srcoff + 4]; + double ctrly2 = src[srcoff + 5]; + double x2 = src[srcoff + 6]; + double y2 = src[srcoff + 7]; + if (left != null) { + left[leftoff + 0] = x1; + left[leftoff + 1] = y1; + } + if (right != null) { + right[rightoff + 6] = x2; + right[rightoff + 7] = y2; + } + x1 = (x1 + ctrlx1) / 2.0d; + y1 = (y1 + ctrly1) / 2.0d; + x2 = (x2 + ctrlx2) / 2.0d; + y2 = (y2 + ctrly2) / 2.0d; + double centerx = (ctrlx1 + ctrlx2) / 2.0d; + double centery = (ctrly1 + ctrly2) / 2.0d; + ctrlx1 = (x1 + centerx) / 2.0d; + ctrly1 = (y1 + centery) / 2.0d; + ctrlx2 = (x2 + centerx) / 2.0d; + ctrly2 = (y2 + centery) / 2.0d; + centerx = (ctrlx1 + ctrlx2) / 2.0d; + centery = (ctrly1 + ctrly2) / 2.0d; + if (left != null) { + left[leftoff + 2] = x1; + left[leftoff + 3] = y1; + left[leftoff + 4] = ctrlx1; + left[leftoff + 5] = ctrly1; + left[leftoff + 6] = centerx; + left[leftoff + 7] = centery; + } + if (right != null) { + right[rightoff + 0] = centerx; + right[rightoff + 1] = centery; + right[rightoff + 2] = ctrlx2; + right[rightoff + 3] = ctrly2; + right[rightoff + 4] = x2; + right[rightoff + 5] = y2; + } + } + + + static void subdivideCubicAt(double t, double[] src, int srcoff, + double[] left, int leftoff, + double[] right, int rightoff) + { + double x1 = src[srcoff + 0]; + double y1 = src[srcoff + 1]; + double ctrlx1 = src[srcoff + 2]; + double ctrly1 = src[srcoff + 3]; + double ctrlx2 = src[srcoff + 4]; + double ctrly2 = src[srcoff + 5]; + double x2 = src[srcoff + 6]; + double y2 = src[srcoff + 7]; + if (left != null) { + left[leftoff + 0] = x1; + left[leftoff + 1] = y1; + } + if (right != null) { + right[rightoff + 6] = x2; + right[rightoff + 7] = y2; + } + x1 = x1 + t * (ctrlx1 - x1); + y1 = y1 + t * (ctrly1 - y1); + x2 = ctrlx2 + t * (x2 - ctrlx2); + y2 = ctrly2 + t * (y2 - ctrly2); + double centerx = ctrlx1 + t * (ctrlx2 - ctrlx1); + double centery = ctrly1 + t * (ctrly2 - ctrly1); + ctrlx1 = x1 + t * (centerx - x1); + ctrly1 = y1 + t * (centery - y1); + ctrlx2 = centerx + t * (x2 - centerx); + ctrly2 = centery + t * (y2 - centery); + centerx = ctrlx1 + t * (ctrlx2 - ctrlx1); + centery = ctrly1 + t * (ctrly2 - ctrly1); + if (left != null) { + left[leftoff + 2] = x1; + left[leftoff + 3] = y1; + left[leftoff + 4] = ctrlx1; + left[leftoff + 5] = ctrly1; + left[leftoff + 6] = centerx; + left[leftoff + 7] = centery; + } + if (right != null) { + right[rightoff + 0] = centerx; + right[rightoff + 1] = centery; + right[rightoff + 2] = ctrlx2; + right[rightoff + 3] = ctrly2; + right[rightoff + 4] = x2; + right[rightoff + 5] = y2; + } + } + + static void subdivideQuad(double[] src, int srcoff, + double[] left, int leftoff, + double[] right, int rightoff) + { + double x1 = src[srcoff + 0]; + double y1 = src[srcoff + 1]; + double ctrlx = src[srcoff + 2]; + double ctrly = src[srcoff + 3]; + double x2 = src[srcoff + 4]; + double y2 = src[srcoff + 5]; + if (left != null) { + left[leftoff + 0] = x1; + left[leftoff + 1] = y1; + } + if (right != null) { + right[rightoff + 4] = x2; + right[rightoff + 5] = y2; + } + x1 = (x1 + ctrlx) / 2.0d; + y1 = (y1 + ctrly) / 2.0d; + x2 = (x2 + ctrlx) / 2.0d; + y2 = (y2 + ctrly) / 2.0d; + ctrlx = (x1 + x2) / 2.0d; + ctrly = (y1 + y2) / 2.0d; + if (left != null) { + left[leftoff + 2] = x1; + left[leftoff + 3] = y1; + left[leftoff + 4] = ctrlx; + left[leftoff + 5] = ctrly; + } + if (right != null) { + right[rightoff + 0] = ctrlx; + right[rightoff + 1] = ctrly; + right[rightoff + 2] = x2; + right[rightoff + 3] = y2; + } + } + + static void subdivideQuadAt(double t, double[] src, int srcoff, + double[] left, int leftoff, + double[] right, int rightoff) + { + double x1 = src[srcoff + 0]; + double y1 = src[srcoff + 1]; + double ctrlx = src[srcoff + 2]; + double ctrly = src[srcoff + 3]; + double x2 = src[srcoff + 4]; + double y2 = src[srcoff + 5]; + if (left != null) { + left[leftoff + 0] = x1; + left[leftoff + 1] = y1; + } + if (right != null) { + right[rightoff + 4] = x2; + right[rightoff + 5] = y2; + } + x1 = x1 + t * (ctrlx - x1); + y1 = y1 + t * (ctrly - y1); + x2 = ctrlx + t * (x2 - ctrlx); + y2 = ctrly + t * (y2 - ctrly); + ctrlx = x1 + t * (x2 - x1); + ctrly = y1 + t * (y2 - y1); + if (left != null) { + left[leftoff + 2] = x1; + left[leftoff + 3] = y1; + left[leftoff + 4] = ctrlx; + left[leftoff + 5] = ctrly; + } + if (right != null) { + right[rightoff + 0] = ctrlx; + right[rightoff + 1] = ctrly; + right[rightoff + 2] = x2; + right[rightoff + 3] = y2; + } + } + + static void subdivideAt(double t, double[] src, int srcoff, + double[] left, int leftoff, + double[] right, int rightoff, int size) + { + switch(size) { + case 8: + subdivideCubicAt(t, src, srcoff, left, leftoff, right, rightoff); + return; + case 6: + subdivideQuadAt(t, src, srcoff, left, leftoff, right, rightoff); + return; + } + } +} diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DMarlinRenderingEngine.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DMarlinRenderingEngine.java new file mode 100644 index 00000000000..dcb433cbb30 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DMarlinRenderingEngine.java @@ -0,0 +1,1111 @@ +/* + * Copyright (c) 2007, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.java2d.marlin; + +import java.awt.BasicStroke; +import java.awt.Shape; +import java.awt.geom.AffineTransform; +import java.awt.geom.Path2D; +import java.awt.geom.PathIterator; +import java.security.AccessController; +import static sun.java2d.marlin.MarlinUtils.logInfo; +import sun.java2d.ReentrantContextProvider; +import sun.java2d.ReentrantContextProviderCLQ; +import sun.java2d.ReentrantContextProviderTL; +import sun.java2d.pipe.AATileGenerator; +import sun.java2d.pipe.Region; +import sun.java2d.pipe.RenderingEngine; +import sun.security.action.GetPropertyAction; + +/** + * Marlin RendererEngine implementation (derived from Pisces) + */ +public final class DMarlinRenderingEngine extends RenderingEngine + implements MarlinConst +{ + private static enum NormMode { + ON_WITH_AA { + @Override + PathIterator getNormalizingPathIterator(final DRendererContext rdrCtx, + final PathIterator src) + { + // NormalizingPathIterator NearestPixelCenter: + return rdrCtx.nPCPathIterator.init(src); + } + }, + ON_NO_AA{ + @Override + PathIterator getNormalizingPathIterator(final DRendererContext rdrCtx, + final PathIterator src) + { + // NearestPixel NormalizingPathIterator: + return rdrCtx.nPQPathIterator.init(src); + } + }, + OFF{ + @Override + PathIterator getNormalizingPathIterator(final DRendererContext rdrCtx, + final PathIterator src) + { + // return original path iterator if normalization is disabled: + return src; + } + }; + + abstract PathIterator getNormalizingPathIterator(DRendererContext rdrCtx, + PathIterator src); + } + + private static final float MIN_PEN_SIZE = 1.0f / NORM_SUBPIXELS; + + static final double UPPER_BND = Float.MAX_VALUE / 2.0d; + static final double LOWER_BND = -UPPER_BND; + + /** + * Public constructor + */ + public DMarlinRenderingEngine() { + super(); + logSettings(DMarlinRenderingEngine.class.getName()); + } + + /** + * Create a widened path as specified by the parameters. + *

+ * The specified {@code src} {@link Shape} is widened according + * to the specified attribute parameters as per the + * {@link BasicStroke} specification. + * + * @param src the source path to be widened + * @param width the width of the widened path as per {@code BasicStroke} + * @param caps the end cap decorations as per {@code BasicStroke} + * @param join the segment join decorations as per {@code BasicStroke} + * @param miterlimit the miter limit as per {@code BasicStroke} + * @param dashes the dash length array as per {@code BasicStroke} + * @param dashphase the initial dash phase as per {@code BasicStroke} + * @return the widened path stored in a new {@code Shape} object + * @since 1.7 + */ + @Override + public Shape createStrokedShape(Shape src, + float width, + int caps, + int join, + float miterlimit, + float[] dashes, + float dashphase) + { + final DRendererContext rdrCtx = getRendererContext(); + try { + // initialize a large copyable Path2D to avoid a lot of array growing: + final Path2D.Double p2d = rdrCtx.getPath2D(); + + strokeTo(rdrCtx, + src, + null, + width, + NormMode.OFF, + caps, + join, + miterlimit, + dashes, + dashphase, + rdrCtx.transformerPC2D.wrapPath2d(p2d) + ); + + // Use Path2D copy constructor (trim) + return new Path2D.Double(p2d); + + } finally { + // recycle the DRendererContext instance + returnRendererContext(rdrCtx); + } + } + + /** + * Sends the geometry for a widened path as specified by the parameters + * to the specified consumer. + *

+ * The specified {@code src} {@link Shape} is widened according + * to the parameters specified by the {@link BasicStroke} object. + * Adjustments are made to the path as appropriate for the + * {@link java.awt.RenderingHints#VALUE_STROKE_NORMALIZE} hint if the + * {@code normalize} boolean parameter is true. + * Adjustments are made to the path as appropriate for the + * {@link java.awt.RenderingHints#VALUE_ANTIALIAS_ON} hint if the + * {@code antialias} boolean parameter is true. + *

+ * The geometry of the widened path is forwarded to the indicated + * {@link DPathConsumer2D} object as it is calculated. + * + * @param src the source path to be widened + * @param bs the {@code BasicSroke} object specifying the + * decorations to be applied to the widened path + * @param normalize indicates whether stroke normalization should + * be applied + * @param antialias indicates whether or not adjustments appropriate + * to antialiased rendering should be applied + * @param consumer the {@code DPathConsumer2D} instance to forward + * the widened geometry to + * @since 1.7 + */ + @Override + public void strokeTo(Shape src, + AffineTransform at, + BasicStroke bs, + boolean thin, + boolean normalize, + boolean antialias, + final sun.awt.geom.PathConsumer2D consumer) + { + final NormMode norm = (normalize) ? + ((antialias) ? NormMode.ON_WITH_AA : NormMode.ON_NO_AA) + : NormMode.OFF; + + final DRendererContext rdrCtx = getRendererContext(); + try { + strokeTo(rdrCtx, src, at, bs, thin, norm, antialias, + rdrCtx.p2dAdapter.init(consumer)); + } finally { + // recycle the DRendererContext instance + returnRendererContext(rdrCtx); + } + } + + final void strokeTo(final DRendererContext rdrCtx, + Shape src, + AffineTransform at, + BasicStroke bs, + boolean thin, + NormMode normalize, + boolean antialias, + DPathConsumer2D pc2d) + { + double lw; + if (thin) { + if (antialias) { + lw = userSpaceLineWidth(at, MIN_PEN_SIZE); + } else { + lw = userSpaceLineWidth(at, 1.0d); + } + } else { + lw = bs.getLineWidth(); + } + strokeTo(rdrCtx, + src, + at, + lw, + normalize, + bs.getEndCap(), + bs.getLineJoin(), + bs.getMiterLimit(), + bs.getDashArray(), + bs.getDashPhase(), + pc2d); + } + + private final double userSpaceLineWidth(AffineTransform at, double lw) { + + double widthScale; + + if (at == null) { + widthScale = 1.0d; + } else if ((at.getType() & (AffineTransform.TYPE_GENERAL_TRANSFORM | + AffineTransform.TYPE_GENERAL_SCALE)) != 0) { + widthScale = Math.sqrt(at.getDeterminant()); + } else { + // First calculate the "maximum scale" of this transform. + double A = at.getScaleX(); // m00 + double C = at.getShearX(); // m01 + double B = at.getShearY(); // m10 + double D = at.getScaleY(); // m11 + + /* + * Given a 2 x 2 affine matrix [ A B ] such that + * [ C D ] + * v' = [x' y'] = [Ax + Cy, Bx + Dy], we want to + * find the maximum magnitude (norm) of the vector v' + * with the constraint (x^2 + y^2 = 1). + * The equation to maximize is + * |v'| = sqrt((Ax+Cy)^2+(Bx+Dy)^2) + * or |v'| = sqrt((AA+BB)x^2 + 2(AC+BD)xy + (CC+DD)y^2). + * Since sqrt is monotonic we can maximize |v'|^2 + * instead and plug in the substitution y = sqrt(1 - x^2). + * Trigonometric equalities can then be used to get + * rid of most of the sqrt terms. + */ + + double EA = A*A + B*B; // x^2 coefficient + double EB = 2.0d * (A*C + B*D); // xy coefficient + double EC = C*C + D*D; // y^2 coefficient + + /* + * There is a lot of calculus omitted here. + * + * Conceptually, in the interests of understanding the + * terms that the calculus produced we can consider + * that EA and EC end up providing the lengths along + * the major axes and the hypot term ends up being an + * adjustment for the additional length along the off-axis + * angle of rotated or sheared ellipses as well as an + * adjustment for the fact that the equation below + * averages the two major axis lengths. (Notice that + * the hypot term contains a part which resolves to the + * difference of these two axis lengths in the absence + * of rotation.) + * + * In the calculus, the ratio of the EB and (EA-EC) terms + * ends up being the tangent of 2*theta where theta is + * the angle that the long axis of the ellipse makes + * with the horizontal axis. Thus, this equation is + * calculating the length of the hypotenuse of a triangle + * along that axis. + */ + + double hypot = Math.sqrt(EB*EB + (EA-EC)*(EA-EC)); + // sqrt omitted, compare to squared limits below. + double widthsquared = ((EA + EC + hypot) / 2.0d); + + widthScale = Math.sqrt(widthsquared); + } + + return (lw / widthScale); + } + + final void strokeTo(final DRendererContext rdrCtx, + Shape src, + AffineTransform at, + double width, + NormMode norm, + int caps, + int join, + float miterlimit, + float[] dashes, + float dashphase, + DPathConsumer2D pc2d) + { + // We use strokerat so that in Stroker and Dasher we can work only + // with the pre-transformation coordinates. This will repeat a lot of + // computations done in the path iterator, but the alternative is to + // work with transformed paths and compute untransformed coordinates + // as needed. This would be faster but I do not think the complexity + // of working with both untransformed and transformed coordinates in + // the same code is worth it. + // However, if a path's width is constant after a transformation, + // we can skip all this untransforming. + + // As pathTo() will check transformed coordinates for invalid values + // (NaN / Infinity) to ignore such points, it is necessary to apply the + // transformation before the path processing. + AffineTransform strokerat = null; + + int dashLen = -1; + boolean recycleDashes = false; + double[] dashesD = null; + + // Ensure converting dashes to double precision: + if (dashes != null) { + recycleDashes = true; + dashLen = dashes.length; + dashesD = rdrCtx.dasher.copyDashArray(dashes); + } + + if (at != null && !at.isIdentity()) { + final double a = at.getScaleX(); + final double b = at.getShearX(); + final double c = at.getShearY(); + final double d = at.getScaleY(); + final double det = a * d - c * b; + + if (Math.abs(det) <= (2.0d * Double.MIN_VALUE)) { + // this rendering engine takes one dimensional curves and turns + // them into 2D shapes by giving them width. + // However, if everything is to be passed through a singular + // transformation, these 2D shapes will be squashed down to 1D + // again so, nothing can be drawn. + + // Every path needs an initial moveTo and a pathDone. If these + // are not there this causes a SIGSEGV in libawt.so (at the time + // of writing of this comment (September 16, 2010)). Actually, + // I am not sure if the moveTo is necessary to avoid the SIGSEGV + // but the pathDone is definitely needed. + pc2d.moveTo(0.0d, 0.0d); + pc2d.pathDone(); + return; + } + + // If the transform is a constant multiple of an orthogonal transformation + // then every length is just multiplied by a constant, so we just + // need to transform input paths to stroker and tell stroker + // the scaled width. This condition is satisfied if + // a*b == -c*d && a*a+c*c == b*b+d*d. In the actual check below, we + // leave a bit of room for error. + if (nearZero(a*b + c*d) && nearZero(a*a + c*c - (b*b + d*d))) { + final double scale = Math.sqrt(a*a + c*c); + + if (dashesD != null) { + for (int i = 0; i < dashLen; i++) { + dashesD[i] *= scale; + } + dashphase *= scale; + } + width *= scale; + + // by now strokerat == null. Input paths to + // stroker (and maybe dasher) will have the full transform at + // applied to them and nothing will happen to the output paths. + } else { + strokerat = at; + + // by now strokerat == at. Input paths to + // stroker (and maybe dasher) will have the full transform at + // applied to them, then they will be normalized, and then + // the inverse of *only the non translation part of at* will + // be applied to the normalized paths. This won't cause problems + // in stroker, because, suppose at = T*A, where T is just the + // translation part of at, and A is the rest. T*A has already + // been applied to Stroker/Dasher's input. Then Ainv will be + // applied. Ainv*T*A is not equal to T, but it is a translation, + // which means that none of stroker's assumptions about its + // input will be violated. After all this, A will be applied + // to stroker's output. + } + } else { + // either at is null or it's the identity. In either case + // we don't transform the path. + at = null; + } + + if (USE_SIMPLIFIER) { + // Use simplifier after stroker before Renderer + // to remove collinear segments (notably due to cap square) + pc2d = rdrCtx.simplifier.init(pc2d); + } + + final DTransformingPathConsumer2D transformerPC2D = rdrCtx.transformerPC2D; + pc2d = transformerPC2D.deltaTransformConsumer(pc2d, strokerat); + + pc2d = rdrCtx.stroker.init(pc2d, width, caps, join, miterlimit); + + if (dashesD != null) { + pc2d = rdrCtx.dasher.init(pc2d, dashesD, dashLen, dashphase, + recycleDashes); + } + pc2d = transformerPC2D.inverseDeltaTransformConsumer(pc2d, strokerat); + + final PathIterator pi = norm.getNormalizingPathIterator(rdrCtx, + src.getPathIterator(at)); + + pathTo(rdrCtx, pi, pc2d); + + /* + * Pipeline seems to be: + * shape.getPathIterator(at) + * -> (NormalizingPathIterator) + * -> (inverseDeltaTransformConsumer) + * -> (Dasher) + * -> Stroker + * -> (deltaTransformConsumer) + * + * -> (CollinearSimplifier) to remove redundant segments + * + * -> pc2d = Renderer (bounding box) + */ + } + + private static boolean nearZero(final double num) { + return Math.abs(num) < 2.0d * Math.ulp(num); + } + + abstract static class NormalizingPathIterator implements PathIterator { + + private PathIterator src; + + // the adjustment applied to the current position. + private double curx_adjust, cury_adjust; + // the adjustment applied to the last moveTo position. + private double movx_adjust, movy_adjust; + + private final double[] tmp; + + NormalizingPathIterator(final double[] tmp) { + this.tmp = tmp; + } + + final NormalizingPathIterator init(final PathIterator src) { + this.src = src; + return this; // fluent API + } + + /** + * Disposes this path iterator: + * clean up before reusing this instance + */ + final void dispose() { + // free source PathIterator: + this.src = null; + } + + @Override + public final int currentSegment(final double[] coords) { + int lastCoord; + final int type = src.currentSegment(coords); + + switch(type) { + case PathIterator.SEG_MOVETO: + case PathIterator.SEG_LINETO: + lastCoord = 0; + break; + case PathIterator.SEG_QUADTO: + lastCoord = 2; + break; + case PathIterator.SEG_CUBICTO: + lastCoord = 4; + break; + case PathIterator.SEG_CLOSE: + // we don't want to deal with this case later. We just exit now + curx_adjust = movx_adjust; + cury_adjust = movy_adjust; + return type; + default: + throw new InternalError("Unrecognized curve type"); + } + + // normalize endpoint + double coord, x_adjust, y_adjust; + + coord = coords[lastCoord]; + x_adjust = normCoord(coord); // new coord + coords[lastCoord] = x_adjust; + x_adjust -= coord; + + coord = coords[lastCoord + 1]; + y_adjust = normCoord(coord); // new coord + coords[lastCoord + 1] = y_adjust; + y_adjust -= coord; + + // now that the end points are done, normalize the control points + switch(type) { + case PathIterator.SEG_MOVETO: + movx_adjust = x_adjust; + movy_adjust = y_adjust; + break; + case PathIterator.SEG_LINETO: + break; + case PathIterator.SEG_QUADTO: + coords[0] += (curx_adjust + x_adjust) / 2.0d; + coords[1] += (cury_adjust + y_adjust) / 2.0d; + break; + case PathIterator.SEG_CUBICTO: + coords[0] += curx_adjust; + coords[1] += cury_adjust; + coords[2] += x_adjust; + coords[3] += y_adjust; + break; + case PathIterator.SEG_CLOSE: + // handled earlier + default: + } + curx_adjust = x_adjust; + cury_adjust = y_adjust; + return type; + } + + abstract double normCoord(final double coord); + + @Override + public final int currentSegment(final float[] coords) { + final double[] _tmp = tmp; // dirty + int type = this.currentSegment(_tmp); + for (int i = 0; i < 6; i++) { + coords[i] = (float)_tmp[i]; + } + return type; + } + + @Override + public final int getWindingRule() { + return src.getWindingRule(); + } + + @Override + public final boolean isDone() { + if (src.isDone()) { + // Dispose this instance: + dispose(); + return true; + } + return false; + } + + @Override + public final void next() { + src.next(); + } + + static final class NearestPixelCenter + extends NormalizingPathIterator + { + NearestPixelCenter(final double[] tmp) { + super(tmp); + } + + @Override + double normCoord(final double coord) { + // round to nearest pixel center + return Math.floor(coord) + 0.5d; + } + } + + static final class NearestPixelQuarter + extends NormalizingPathIterator + { + NearestPixelQuarter(final double[] tmp) { + super(tmp); + } + + @Override + double normCoord(final double coord) { + // round to nearest (0.25, 0.25) pixel quarter + return Math.floor(coord + 0.25d) + 0.25d; + } + } + } + + private static void pathTo(final DRendererContext rdrCtx, final PathIterator pi, + final DPathConsumer2D pc2d) + { + // mark context as DIRTY: + rdrCtx.dirty = true; + + final double[] coords = rdrCtx.double6; + + pathToLoop(coords, pi, pc2d); + + // mark context as CLEAN: + rdrCtx.dirty = false; + } + + private static void pathToLoop(final double[] coords, final PathIterator pi, + final DPathConsumer2D pc2d) + { + // ported from DuctusRenderingEngine.feedConsumer() but simplified: + // - removed skip flag = !subpathStarted + // - removed pathClosed (ie subpathStarted not set to false) + boolean subpathStarted = false; + + for (; !pi.isDone(); pi.next()) { + switch (pi.currentSegment(coords)) { + case PathIterator.SEG_MOVETO: + /* Checking SEG_MOVETO coordinates if they are out of the + * [LOWER_BND, UPPER_BND] range. This check also handles NaN + * and Infinity values. Skipping next path segment in case of + * invalid data. + */ + if (coords[0] < UPPER_BND && coords[0] > LOWER_BND && + coords[1] < UPPER_BND && coords[1] > LOWER_BND) + { + pc2d.moveTo(coords[0], coords[1]); + subpathStarted = true; + } + break; + case PathIterator.SEG_LINETO: + /* Checking SEG_LINETO coordinates if they are out of the + * [LOWER_BND, UPPER_BND] range. This check also handles NaN + * and Infinity values. Ignoring current path segment in case + * of invalid data. If segment is skipped its endpoint + * (if valid) is used to begin new subpath. + */ + if (coords[0] < UPPER_BND && coords[0] > LOWER_BND && + coords[1] < UPPER_BND && coords[1] > LOWER_BND) + { + if (subpathStarted) { + pc2d.lineTo(coords[0], coords[1]); + } else { + pc2d.moveTo(coords[0], coords[1]); + subpathStarted = true; + } + } + break; + case PathIterator.SEG_QUADTO: + // Quadratic curves take two points + /* Checking SEG_QUADTO coordinates if they are out of the + * [LOWER_BND, UPPER_BND] range. This check also handles NaN + * and Infinity values. Ignoring current path segment in case + * of invalid endpoints's data. Equivalent to the SEG_LINETO + * if endpoint coordinates are valid but there are invalid data + * among other coordinates + */ + if (coords[2] < UPPER_BND && coords[2] > LOWER_BND && + coords[3] < UPPER_BND && coords[3] > LOWER_BND) + { + if (subpathStarted) { + if (coords[0] < UPPER_BND && coords[0] > LOWER_BND && + coords[1] < UPPER_BND && coords[1] > LOWER_BND) + { + pc2d.quadTo(coords[0], coords[1], + coords[2], coords[3]); + } else { + pc2d.lineTo(coords[2], coords[3]); + } + } else { + pc2d.moveTo(coords[2], coords[3]); + subpathStarted = true; + } + } + break; + case PathIterator.SEG_CUBICTO: + // Cubic curves take three points + /* Checking SEG_CUBICTO coordinates if they are out of the + * [LOWER_BND, UPPER_BND] range. This check also handles NaN + * and Infinity values. Ignoring current path segment in case + * of invalid endpoints's data. Equivalent to the SEG_LINETO + * if endpoint coordinates are valid but there are invalid data + * among other coordinates + */ + if (coords[4] < UPPER_BND && coords[4] > LOWER_BND && + coords[5] < UPPER_BND && coords[5] > LOWER_BND) + { + if (subpathStarted) { + if (coords[0] < UPPER_BND && coords[0] > LOWER_BND && + coords[1] < UPPER_BND && coords[1] > LOWER_BND && + coords[2] < UPPER_BND && coords[2] > LOWER_BND && + coords[3] < UPPER_BND && coords[3] > LOWER_BND) + { + pc2d.curveTo(coords[0], coords[1], + coords[2], coords[3], + coords[4], coords[5]); + } else { + pc2d.lineTo(coords[4], coords[5]); + } + } else { + pc2d.moveTo(coords[4], coords[5]); + subpathStarted = true; + } + } + break; + case PathIterator.SEG_CLOSE: + if (subpathStarted) { + pc2d.closePath(); + // do not set subpathStarted to false + // in case of missing moveTo() after close() + } + break; + default: + } + } + pc2d.pathDone(); + } + + /** + * Construct an antialiased tile generator for the given shape with + * the given rendering attributes and store the bounds of the tile + * iteration in the bbox parameter. + * The {@code at} parameter specifies a transform that should affect + * both the shape and the {@code BasicStroke} attributes. + * The {@code clip} parameter specifies the current clip in effect + * in device coordinates and can be used to prune the data for the + * operation, but the renderer is not required to perform any + * clipping. + * If the {@code BasicStroke} parameter is null then the shape + * should be filled as is, otherwise the attributes of the + * {@code BasicStroke} should be used to specify a draw operation. + * The {@code thin} parameter indicates whether or not the + * transformed {@code BasicStroke} represents coordinates smaller + * than the minimum resolution of the antialiasing rasterizer as + * specified by the {@code getMinimumAAPenWidth()} method. + *

+ * Upon returning, this method will fill the {@code bbox} parameter + * with 4 values indicating the bounds of the iteration of the + * tile generator. + * The iteration order of the tiles will be as specified by the + * pseudo-code: + *

+     *     for (y = bbox[1]; y < bbox[3]; y += tileheight) {
+     *         for (x = bbox[0]; x < bbox[2]; x += tilewidth) {
+     *         }
+     *     }
+     * 
+ * If there is no output to be rendered, this method may return + * null. + * + * @param s the shape to be rendered (fill or draw) + * @param at the transform to be applied to the shape and the + * stroke attributes + * @param clip the current clip in effect in device coordinates + * @param bs if non-null, a {@code BasicStroke} whose attributes + * should be applied to this operation + * @param thin true if the transformed stroke attributes are smaller + * than the minimum dropout pen width + * @param normalize true if the {@code VALUE_STROKE_NORMALIZE} + * {@code RenderingHint} is in effect + * @param bbox returns the bounds of the iteration + * @return the {@code AATileGenerator} instance to be consulted + * for tile coverages, or null if there is no output to render + * @since 1.7 + */ + @Override + public AATileGenerator getAATileGenerator(Shape s, + AffineTransform at, + Region clip, + BasicStroke bs, + boolean thin, + boolean normalize, + int[] bbox) + { + MarlinTileGenerator ptg = null; + DRenderer r = null; + + final DRendererContext rdrCtx = getRendererContext(); + try { + // Test if at is identity: + final AffineTransform _at = (at != null && !at.isIdentity()) ? at + : null; + + final NormMode norm = (normalize) ? NormMode.ON_WITH_AA : NormMode.OFF; + + if (bs == null) { + // fill shape: + final PathIterator pi = norm.getNormalizingPathIterator(rdrCtx, + s.getPathIterator(_at)); + + // note: Winding rule may be EvenOdd ONLY for fill operations ! + r = rdrCtx.renderer.init(clip.getLoX(), clip.getLoY(), + clip.getWidth(), clip.getHeight(), + pi.getWindingRule()); + + // TODO: subdivide quad/cubic curves into monotonic curves ? + pathTo(rdrCtx, pi, r); + } else { + // draw shape with given stroke: + r = rdrCtx.renderer.init(clip.getLoX(), clip.getLoY(), + clip.getWidth(), clip.getHeight(), + PathIterator.WIND_NON_ZERO); + + strokeTo(rdrCtx, s, _at, bs, thin, norm, true, r); + } + if (r.endRendering()) { + ptg = rdrCtx.ptg.init(); + ptg.getBbox(bbox); + // note: do not returnRendererContext(rdrCtx) + // as it will be called later by MarlinTileGenerator.dispose() + r = null; + } + } finally { + if (r != null) { + // dispose renderer and recycle the RendererContext instance: + r.dispose(); + } + } + + // Return null to cancel AA tile generation (nothing to render) + return ptg; + } + + @Override + public final AATileGenerator getAATileGenerator(double x, double y, + double dx1, double dy1, + double dx2, double dy2, + double lw1, double lw2, + Region clip, + int[] bbox) + { + // REMIND: Deal with large coordinates! + double ldx1, ldy1, ldx2, ldy2; + boolean innerpgram = (lw1 > 0.0d && lw2 > 0.0d); + + if (innerpgram) { + ldx1 = dx1 * lw1; + ldy1 = dy1 * lw1; + ldx2 = dx2 * lw2; + ldy2 = dy2 * lw2; + x -= (ldx1 + ldx2) / 2.0d; + y -= (ldy1 + ldy2) / 2.0d; + dx1 += ldx1; + dy1 += ldy1; + dx2 += ldx2; + dy2 += ldy2; + if (lw1 > 1.0d && lw2 > 1.0d) { + // Inner parallelogram was entirely consumed by stroke... + innerpgram = false; + } + } else { + ldx1 = ldy1 = ldx2 = ldy2 = 0.0d; + } + + MarlinTileGenerator ptg = null; + DRenderer r = null; + + final DRendererContext rdrCtx = getRendererContext(); + try { + r = rdrCtx.renderer.init(clip.getLoX(), clip.getLoY(), + clip.getWidth(), clip.getHeight(), + DRenderer.WIND_EVEN_ODD); + + r.moveTo( x, y); + r.lineTo( (x+dx1), (y+dy1)); + r.lineTo( (x+dx1+dx2), (y+dy1+dy2)); + r.lineTo( (x+dx2), (y+dy2)); + r.closePath(); + + if (innerpgram) { + x += ldx1 + ldx2; + y += ldy1 + ldy2; + dx1 -= 2.0d * ldx1; + dy1 -= 2.0d * ldy1; + dx2 -= 2.0d * ldx2; + dy2 -= 2.0d * ldy2; + r.moveTo( x, y); + r.lineTo( (x+dx1), (y+dy1)); + r.lineTo( (x+dx1+dx2), (y+dy1+dy2)); + r.lineTo( (x+dx2), (y+dy2)); + r.closePath(); + } + r.pathDone(); + + if (r.endRendering()) { + ptg = rdrCtx.ptg.init(); + ptg.getBbox(bbox); + // note: do not returnRendererContext(rdrCtx) + // as it will be called later by MarlinTileGenerator.dispose() + r = null; + } + } finally { + if (r != null) { + // dispose renderer and recycle the RendererContext instance: + r.dispose(); + } + } + + // Return null to cancel AA tile generation (nothing to render) + return ptg; + } + + /** + * Returns the minimum pen width that the antialiasing rasterizer + * can represent without dropouts occuring. + * @since 1.7 + */ + @Override + public float getMinimumAAPenSize() { + return MIN_PEN_SIZE; + } + + static { + if (PathIterator.WIND_NON_ZERO != DRenderer.WIND_NON_ZERO || + PathIterator.WIND_EVEN_ODD != DRenderer.WIND_EVEN_ODD || + BasicStroke.JOIN_MITER != DStroker.JOIN_MITER || + BasicStroke.JOIN_ROUND != DStroker.JOIN_ROUND || + BasicStroke.JOIN_BEVEL != DStroker.JOIN_BEVEL || + BasicStroke.CAP_BUTT != DStroker.CAP_BUTT || + BasicStroke.CAP_ROUND != DStroker.CAP_ROUND || + BasicStroke.CAP_SQUARE != DStroker.CAP_SQUARE) + { + throw new InternalError("mismatched renderer constants"); + } + } + + // --- DRendererContext handling --- + // use ThreadLocal or ConcurrentLinkedQueue to get one DRendererContext + private static final boolean USE_THREAD_LOCAL; + + // reference type stored in either TL or CLQ + static final int REF_TYPE; + + // Per-thread DRendererContext + private static final ReentrantContextProvider RDR_CTX_PROVIDER; + + // Static initializer to use TL or CLQ mode + static { + USE_THREAD_LOCAL = MarlinProperties.isUseThreadLocal(); + + // Soft reference by default: + final String refType = AccessController.doPrivileged( + new GetPropertyAction("sun.java2d.renderer.useRef", + "soft")); + + // Java 1.6 does not support strings in switch: + if ("hard".equalsIgnoreCase(refType)) { + REF_TYPE = ReentrantContextProvider.REF_HARD; + } else if ("weak".equalsIgnoreCase(refType)) { + REF_TYPE = ReentrantContextProvider.REF_WEAK; + } else { + REF_TYPE = ReentrantContextProvider.REF_SOFT; + } + + if (USE_THREAD_LOCAL) { + RDR_CTX_PROVIDER = new ReentrantContextProviderTL(REF_TYPE) + { + @Override + protected DRendererContext newContext() { + return DRendererContext.createContext(); + } + }; + } else { + RDR_CTX_PROVIDER = new ReentrantContextProviderCLQ(REF_TYPE) + { + @Override + protected DRendererContext newContext() { + return DRendererContext.createContext(); + } + }; + } + } + + private static boolean SETTINGS_LOGGED = !ENABLE_LOGS; + + private static void logSettings(final String reClass) { + // log information at startup + if (SETTINGS_LOGGED) { + return; + } + SETTINGS_LOGGED = true; + + String refType; + switch (REF_TYPE) { + default: + case ReentrantContextProvider.REF_HARD: + refType = "hard"; + break; + case ReentrantContextProvider.REF_SOFT: + refType = "soft"; + break; + case ReentrantContextProvider.REF_WEAK: + refType = "weak"; + break; + } + + logInfo("==========================================================" + + "====================="); + + logInfo("Marlin software rasterizer = ENABLED"); + logInfo("Version = [" + + Version.getVersion() + "]"); + logInfo("sun.java2d.renderer = " + + reClass); + logInfo("sun.java2d.renderer.useThreadLocal = " + + USE_THREAD_LOCAL); + logInfo("sun.java2d.renderer.useRef = " + + refType); + + logInfo("sun.java2d.renderer.edges = " + + MarlinConst.INITIAL_EDGES_COUNT); + logInfo("sun.java2d.renderer.pixelsize = " + + MarlinConst.INITIAL_PIXEL_DIM); + + logInfo("sun.java2d.renderer.subPixel_log2_X = " + + MarlinConst.SUBPIXEL_LG_POSITIONS_X); + logInfo("sun.java2d.renderer.subPixel_log2_Y = " + + MarlinConst.SUBPIXEL_LG_POSITIONS_Y); + + logInfo("sun.java2d.renderer.tileSize_log2 = " + + MarlinConst.TILE_H_LG); + logInfo("sun.java2d.renderer.tileWidth_log2 = " + + MarlinConst.TILE_W_LG); + logInfo("sun.java2d.renderer.blockSize_log2 = " + + MarlinConst.BLOCK_SIZE_LG); + + // RLE / blockFlags settings + + logInfo("sun.java2d.renderer.forceRLE = " + + MarlinProperties.isForceRLE()); + logInfo("sun.java2d.renderer.forceNoRLE = " + + MarlinProperties.isForceNoRLE()); + logInfo("sun.java2d.renderer.useTileFlags = " + + MarlinProperties.isUseTileFlags()); + logInfo("sun.java2d.renderer.useTileFlags.useHeuristics = " + + MarlinProperties.isUseTileFlagsWithHeuristics()); + logInfo("sun.java2d.renderer.rleMinWidth = " + + MarlinCache.RLE_MIN_WIDTH); + + // optimisation parameters + logInfo("sun.java2d.renderer.useSimplifier = " + + MarlinConst.USE_SIMPLIFIER); + + // debugging parameters + logInfo("sun.java2d.renderer.doStats = " + + MarlinConst.DO_STATS); + logInfo("sun.java2d.renderer.doMonitors = " + + MarlinConst.DO_MONITORS); + logInfo("sun.java2d.renderer.doChecks = " + + MarlinConst.DO_CHECKS); + + // logging parameters + logInfo("sun.java2d.renderer.useLogger = " + + MarlinConst.USE_LOGGER); + logInfo("sun.java2d.renderer.logCreateContext = " + + MarlinConst.LOG_CREATE_CONTEXT); + logInfo("sun.java2d.renderer.logUnsafeMalloc = " + + MarlinConst.LOG_UNSAFE_MALLOC); + + // quality settings + logInfo("sun.java2d.renderer.cubic_dec_d2 = " + + MarlinProperties.getCubicDecD2()); + logInfo("sun.java2d.renderer.cubic_inc_d1 = " + + MarlinProperties.getCubicIncD1()); + logInfo("sun.java2d.renderer.quad_dec_d2 = " + + MarlinProperties.getQuadDecD2()); + + logInfo("Renderer settings:"); + logInfo("CUB_DEC_BND = " + DRenderer.CUB_DEC_BND); + logInfo("CUB_INC_BND = " + DRenderer.CUB_INC_BND); + logInfo("QUAD_DEC_BND = " + DRenderer.QUAD_DEC_BND); + + logInfo("INITIAL_EDGES_CAPACITY = " + + MarlinConst.INITIAL_EDGES_CAPACITY); + logInfo("INITIAL_CROSSING_COUNT = " + + DRenderer.INITIAL_CROSSING_COUNT); + + logInfo("==========================================================" + + "====================="); + } + + /** + * Get the DRendererContext instance dedicated to the current thread + * @return DRendererContext instance + */ + @SuppressWarnings({"unchecked"}) + static DRendererContext getRendererContext() { + final DRendererContext rdrCtx = RDR_CTX_PROVIDER.acquire(); + if (DO_MONITORS) { + rdrCtx.stats.mon_pre_getAATileGenerator.start(); + } + return rdrCtx; + } + + /** + * Reset and return the given DRendererContext instance for reuse + * @param rdrCtx DRendererContext instance + */ + static void returnRendererContext(final DRendererContext rdrCtx) { + rdrCtx.dispose(); + + if (DO_MONITORS) { + rdrCtx.stats.mon_pre_getAATileGenerator.stop(); + } + RDR_CTX_PROVIDER.release(rdrCtx); + } +} diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DPathConsumer2D.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DPathConsumer2D.java new file mode 100644 index 00000000000..9cb3f1c9b3b --- /dev/null +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DPathConsumer2D.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2007, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.java2d.marlin; + +public interface DPathConsumer2D { + /** + * @see java.awt.geom.Path2D.Float#moveTo + */ + public void moveTo(double x, double y); + + /** + * @see java.awt.geom.Path2D.Float#lineTo + */ + public void lineTo(double x, double y); + + /** + * @see java.awt.geom.Path2D.Float#quadTo + */ + public void quadTo(double x1, double y1, + double x2, double y2); + + /** + * @see java.awt.geom.Path2D.Float#curveTo + */ + public void curveTo(double x1, double y1, + double x2, double y2, + double x3, double y3); + + /** + * @see java.awt.geom.Path2D.Float#closePath + */ + public void closePath(); + + /** + * Called after the last segment of the last subpath when the + * iteration of the path segments is completely done. This + * method serves to trigger the end of path processing in the + * consumer that would normally be triggered when a + * {@link java.awt.geom.PathIterator PathIterator} + * returns {@code true} from its {@code done} method. + */ + public void pathDone(); + + /** + * If a given PathConsumer performs all or most of its work + * natively then it can return a (non-zero) pointer to a + * native function vector that defines C functions for all + * of the above methods. + * The specific pointer it returns is a pointer to a + * PathConsumerVec structure as defined in the include file + * src/share/native/sun/java2d/pipe/PathConsumer2D.h + * @return a native pointer to a PathConsumerVec structure. + */ + public long getNativeConsumer(); +} diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DRenderer.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DRenderer.java new file mode 100644 index 00000000000..54d9abaf700 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DRenderer.java @@ -0,0 +1,1526 @@ +/* + * Copyright (c) 2007, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.java2d.marlin; + +import static sun.java2d.marlin.OffHeapArray.SIZE_INT; +import jdk.internal.misc.Unsafe; + +final class DRenderer implements DPathConsumer2D, MarlinRenderer { + + static final boolean DISABLE_RENDER = false; + + static final boolean ENABLE_BLOCK_FLAGS = MarlinProperties.isUseTileFlags(); + static final boolean ENABLE_BLOCK_FLAGS_HEURISTICS = MarlinProperties.isUseTileFlagsWithHeuristics(); + + private static final int ALL_BUT_LSB = 0xFFFFFFFE; + private static final int ERR_STEP_MAX = 0x7FFFFFFF; // = 2^31 - 1 + + private static final double POWER_2_TO_32 = 0x1.0p32d; + + // use double to make tosubpix methods faster (no int to double conversion) + static final double SUBPIXEL_SCALE_X = SUBPIXEL_POSITIONS_X; + static final double SUBPIXEL_SCALE_Y = SUBPIXEL_POSITIONS_Y; + static final int SUBPIXEL_MASK_X = SUBPIXEL_POSITIONS_X - 1; + static final int SUBPIXEL_MASK_Y = SUBPIXEL_POSITIONS_Y - 1; + + // number of subpixels corresponding to a tile line + private static final int SUBPIXEL_TILE + = TILE_H << SUBPIXEL_LG_POSITIONS_Y; + + // 2048 (pixelSize) pixels (height) x 8 subpixels = 64K + static final int INITIAL_BUCKET_ARRAY + = INITIAL_PIXEL_DIM * SUBPIXEL_POSITIONS_Y; + + // crossing capacity = edges count / 4 ~ 1024 + static final int INITIAL_CROSSING_COUNT = INITIAL_EDGES_COUNT >> 2; + + public static final int WIND_EVEN_ODD = 0; + public static final int WIND_NON_ZERO = 1; + + // common to all types of input path segments. + // OFFSET as bytes + // only integer values: + public static final long OFF_CURX_OR = 0; + public static final long OFF_ERROR = OFF_CURX_OR + SIZE_INT; + public static final long OFF_BUMP_X = OFF_ERROR + SIZE_INT; + public static final long OFF_BUMP_ERR = OFF_BUMP_X + SIZE_INT; + public static final long OFF_NEXT = OFF_BUMP_ERR + SIZE_INT; + public static final long OFF_YMAX = OFF_NEXT + SIZE_INT; + + // size of one edge in bytes + public static final int SIZEOF_EDGE_BYTES = (int)(OFF_YMAX + SIZE_INT); + + // curve break into lines + // cubic error in subpixels to decrement step + private static final double CUB_DEC_ERR_SUBPIX + = MarlinProperties.getCubicDecD2() * (NORM_SUBPIXELS / 8.0d); // 1 pixel + // cubic error in subpixels to increment step + private static final double CUB_INC_ERR_SUBPIX + = MarlinProperties.getCubicIncD1() * (NORM_SUBPIXELS / 8.0d); // 0.4 pixel + + // TestNonAARasterization (JDK-8170879): cubics + // bad paths (59294/100000 == 59,29%, 94335 bad pixels (avg = 1,59), 3966 warnings (avg = 0,07) + + // cubic bind length to decrement step + public static final double CUB_DEC_BND + = 8.0d * CUB_DEC_ERR_SUBPIX; + // cubic bind length to increment step + public static final double CUB_INC_BND + = 8.0d * CUB_INC_ERR_SUBPIX; + + // cubic countlg + public static final int CUB_COUNT_LG = 2; + // cubic count = 2^countlg + private static final int CUB_COUNT = 1 << CUB_COUNT_LG; + // cubic count^2 = 4^countlg + private static final int CUB_COUNT_2 = 1 << (2 * CUB_COUNT_LG); + // cubic count^3 = 8^countlg + private static final int CUB_COUNT_3 = 1 << (3 * CUB_COUNT_LG); + // cubic dt = 1 / count + private static final double CUB_INV_COUNT = 1.0d / CUB_COUNT; + // cubic dt^2 = 1 / count^2 = 1 / 4^countlg + private static final double CUB_INV_COUNT_2 = 1.0d / CUB_COUNT_2; + // cubic dt^3 = 1 / count^3 = 1 / 8^countlg + private static final double CUB_INV_COUNT_3 = 1.0d / CUB_COUNT_3; + + // quad break into lines + // quadratic error in subpixels + private static final double QUAD_DEC_ERR_SUBPIX + = MarlinProperties.getQuadDecD2() * (NORM_SUBPIXELS / 8.0d); // 0.5 pixel + + // TestNonAARasterization (JDK-8170879): quads + // bad paths (62916/100000 == 62,92%, 103818 bad pixels (avg = 1,65), 6514 warnings (avg = 0,10) + + // quadratic bind length to decrement step + public static final double QUAD_DEC_BND + = 8.0d * QUAD_DEC_ERR_SUBPIX; + +////////////////////////////////////////////////////////////////////////////// +// SCAN LINE +////////////////////////////////////////////////////////////////////////////// + // crossings ie subpixel edge x coordinates + private int[] crossings; + // auxiliary storage for crossings (merge sort) + private int[] aux_crossings; + + // indices into the segment pointer lists. They indicate the "active" + // sublist in the segment lists (the portion of the list that contains + // all the segments that cross the next scan line). + private int edgeCount; + private int[] edgePtrs; + // auxiliary storage for edge pointers (merge sort) + private int[] aux_edgePtrs; + + // max used for both edgePtrs and crossings (stats only) + private int activeEdgeMaxUsed; + + // crossings ref (dirty) + private final IntArrayCache.Reference crossings_ref; + // edgePtrs ref (dirty) + private final IntArrayCache.Reference edgePtrs_ref; + // merge sort initial arrays (large enough to satisfy most usages) (1024) + // aux_crossings ref (dirty) + private final IntArrayCache.Reference aux_crossings_ref; + // aux_edgePtrs ref (dirty) + private final IntArrayCache.Reference aux_edgePtrs_ref; + +////////////////////////////////////////////////////////////////////////////// +// EDGE LIST +////////////////////////////////////////////////////////////////////////////// + private int edgeMinY = Integer.MAX_VALUE; + private int edgeMaxY = Integer.MIN_VALUE; + private double edgeMinX = Double.POSITIVE_INFINITY; + private double edgeMaxX = Double.NEGATIVE_INFINITY; + + // edges [ints] stored in off-heap memory + private final OffHeapArray edges; + + private int[] edgeBuckets; + private int[] edgeBucketCounts; // 2*newedges + (1 if pruning needed) + // used range for edgeBuckets / edgeBucketCounts + private int buckets_minY; + private int buckets_maxY; + + // edgeBuckets ref (clean) + private final IntArrayCache.Reference edgeBuckets_ref; + // edgeBucketCounts ref (clean) + private final IntArrayCache.Reference edgeBucketCounts_ref; + + // Flattens using adaptive forward differencing. This only carries out + // one iteration of the AFD loop. All it does is update AFD variables (i.e. + // X0, Y0, D*[X|Y], COUNT; not variables used for computing scanline crossings). + private void quadBreakIntoLinesAndAdd(double x0, double y0, + final DCurve c, + final double x2, final double y2) + { + int count = 1; // dt = 1 / count + + // maximum(ddX|Y) = norm(dbx, dby) * dt^2 (= 1) + double maxDD = Math.abs(c.dbx) + Math.abs(c.dby); + + final double _DEC_BND = QUAD_DEC_BND; + + while (maxDD >= _DEC_BND) { + // divide step by half: + maxDD /= 4.0d; // error divided by 2^2 = 4 + + count <<= 1; + if (DO_STATS) { + rdrCtx.stats.stat_rdr_quadBreak_dec.add(count); + } + } + + int nL = 0; // line count + if (count > 1) { + final double icount = 1.0d / count; // dt + final double icount2 = icount * icount; // dt^2 + + final double ddx = c.dbx * icount2; + final double ddy = c.dby * icount2; + double dx = c.bx * icount2 + c.cx * icount; + double dy = c.by * icount2 + c.cy * icount; + + double x1, y1; + + while (--count > 0) { + x1 = x0 + dx; + dx += ddx; + y1 = y0 + dy; + dy += ddy; + + addLine(x0, y0, x1, y1); + + if (DO_STATS) { nL++; } + x0 = x1; + y0 = y1; + } + } + addLine(x0, y0, x2, y2); + + if (DO_STATS) { + rdrCtx.stats.stat_rdr_quadBreak.add(nL + 1); + } + } + + // x0, y0 and x3,y3 are the endpoints of the curve. We could compute these + // using c.xat(0),c.yat(0) and c.xat(1),c.yat(1), but this might introduce + // numerical errors, and our callers already have the exact values. + // Another alternative would be to pass all the control points, and call + // c.set here, but then too many numbers are passed around. + private void curveBreakIntoLinesAndAdd(double x0, double y0, + final DCurve c, + final double x3, final double y3) + { + int count = CUB_COUNT; + final double icount = CUB_INV_COUNT; // dt + final double icount2 = CUB_INV_COUNT_2; // dt^2 + final double icount3 = CUB_INV_COUNT_3; // dt^3 + + // the dx and dy refer to forward differencing variables, not the last + // coefficients of the "points" polynomial + double dddx, dddy, ddx, ddy, dx, dy; + dddx = 2.0d * c.dax * icount3; + dddy = 2.0d * c.day * icount3; + ddx = dddx + c.dbx * icount2; + ddy = dddy + c.dby * icount2; + dx = c.ax * icount3 + c.bx * icount2 + c.cx * icount; + dy = c.ay * icount3 + c.by * icount2 + c.cy * icount; + + // we use x0, y0 to walk the line + double x1 = x0, y1 = y0; + int nL = 0; // line count + + final double _DEC_BND = CUB_DEC_BND; + final double _INC_BND = CUB_INC_BND; + + while (count > 0) { + // divide step by half: + while (Math.abs(ddx) + Math.abs(ddy) >= _DEC_BND) { + dddx /= 8.0d; + dddy /= 8.0d; + ddx = ddx / 4.0d - dddx; + ddy = ddy / 4.0d - dddy; + dx = (dx - ddx) / 2.0d; + dy = (dy - ddy) / 2.0d; + + count <<= 1; + if (DO_STATS) { + rdrCtx.stats.stat_rdr_curveBreak_dec.add(count); + } + } + + // double step: + // can only do this on even "count" values, because we must divide count by 2 + while (count % 2 == 0 + && Math.abs(dx) + Math.abs(dy) <= _INC_BND) + { + dx = 2.0d * dx + ddx; + dy = 2.0d * dy + ddy; + ddx = 4.0d * (ddx + dddx); + ddy = 4.0d * (ddy + dddy); + dddx *= 8.0d; + dddy *= 8.0d; + + count >>= 1; + if (DO_STATS) { + rdrCtx.stats.stat_rdr_curveBreak_inc.add(count); + } + } + if (--count > 0) { + x1 += dx; + dx += ddx; + ddx += dddx; + y1 += dy; + dy += ddy; + ddy += dddy; + } else { + x1 = x3; + y1 = y3; + } + + addLine(x0, y0, x1, y1); + + if (DO_STATS) { nL++; } + x0 = x1; + y0 = y1; + } + if (DO_STATS) { + rdrCtx.stats.stat_rdr_curveBreak.add(nL); + } + } + + private void addLine(double x1, double y1, double x2, double y2) { + if (DO_MONITORS) { + rdrCtx.stats.mon_rdr_addLine.start(); + } + if (DO_STATS) { + rdrCtx.stats.stat_rdr_addLine.add(1); + } + int or = 1; // orientation of the line. 1 if y increases, 0 otherwise. + if (y2 < y1) { + or = 0; + double tmp = y2; + y2 = y1; + y1 = tmp; + tmp = x2; + x2 = x1; + x1 = tmp; + } + + // convert subpixel coordinates [double] into pixel positions [int] + + // The index of the pixel that holds the next HPC is at ceil(trueY - 0.5) + // Since y1 and y2 are biased by -0.5 in tosubpixy(), this is simply + // ceil(y1) or ceil(y2) + // upper integer (inclusive) + final int firstCrossing = FloatMath.max(FloatMath.ceil_int(y1), boundsMinY); + + // note: use boundsMaxY (last Y exclusive) to compute correct coverage + // upper integer (exclusive) + final int lastCrossing = FloatMath.min(FloatMath.ceil_int(y2), boundsMaxY); + + /* skip horizontal lines in pixel space and clip edges + out of y range [boundsMinY; boundsMaxY] */ + if (firstCrossing >= lastCrossing) { + if (DO_MONITORS) { + rdrCtx.stats.mon_rdr_addLine.stop(); + } + if (DO_STATS) { + rdrCtx.stats.stat_rdr_addLine_skip.add(1); + } + return; + } + + // edge min/max X/Y are in subpixel space (half-open interval): + // note: Use integer crossings to ensure consistent range within + // edgeBuckets / edgeBucketCounts arrays in case of NaN values (int = 0) + if (firstCrossing < edgeMinY) { + edgeMinY = firstCrossing; + } + if (lastCrossing > edgeMaxY) { + edgeMaxY = lastCrossing; + } + + final double slope = (x1 - x2) / (y1 - y2); + + if (slope >= 0.0d) { // <==> x1 < x2 + if (x1 < edgeMinX) { + edgeMinX = x1; + } + if (x2 > edgeMaxX) { + edgeMaxX = x2; + } + } else { + if (x2 < edgeMinX) { + edgeMinX = x2; + } + if (x1 > edgeMaxX) { + edgeMaxX = x1; + } + } + + // local variables for performance: + final int _SIZEOF_EDGE_BYTES = SIZEOF_EDGE_BYTES; + + final OffHeapArray _edges = edges; + + // get free pointer (ie length in bytes) + final int edgePtr = _edges.used; + + // use substraction to avoid integer overflow: + if (_edges.length - edgePtr < _SIZEOF_EDGE_BYTES) { + // suppose _edges.length > _SIZEOF_EDGE_BYTES + // so doubling size is enough to add needed bytes + // note: throw IOOB if neededSize > 2Gb: + final long edgeNewSize = ArrayCacheConst.getNewLargeSize( + _edges.length, + edgePtr + _SIZEOF_EDGE_BYTES); + + if (DO_STATS) { + rdrCtx.stats.stat_rdr_edges_resizes.add(edgeNewSize); + } + _edges.resize(edgeNewSize); + } + + + final Unsafe _unsafe = OffHeapArray.UNSAFE; + final long SIZE_INT = 4L; + long addr = _edges.address + edgePtr; + + // The x value must be bumped up to its position at the next HPC we will evaluate. + // "firstcrossing" is the (sub)pixel number where the next crossing occurs + // thus, the actual coordinate of the next HPC is "firstcrossing + 0.5" + // so the Y distance we cover is "firstcrossing + 0.5 - trueY". + // Note that since y1 (and y2) are already biased by -0.5 in tosubpixy(), we have + // y1 = trueY - 0.5 + // trueY = y1 + 0.5 + // firstcrossing + 0.5 - trueY = firstcrossing + 0.5 - (y1 + 0.5) + // = firstcrossing - y1 + // The x coordinate at that HPC is then: + // x1_intercept = x1 + (firstcrossing - y1) * slope + // The next VPC is then given by: + // VPC index = ceil(x1_intercept - 0.5), or alternately + // VPC index = floor(x1_intercept - 0.5 + 1 - epsilon) + // epsilon is hard to pin down in floating point, but easy in fixed point, so if + // we convert to fixed point then these operations get easier: + // long x1_fixed = x1_intercept * 2^32; (fixed point 32.32 format) + // curx = next VPC = fixed_floor(x1_fixed - 2^31 + 2^32 - 1) + // = fixed_floor(x1_fixed + 2^31 - 1) + // = fixed_floor(x1_fixed + 0x7FFFFFFF) + // and error = fixed_fract(x1_fixed + 0x7FFFFFFF) + final double x1_intercept = x1 + (firstCrossing - y1) * slope; + + // inlined scalb(x1_intercept, 32): + final long x1_fixed_biased = ((long) (POWER_2_TO_32 * x1_intercept)) + + 0x7FFFFFFFL; + // curx: + // last bit corresponds to the orientation + _unsafe.putInt(addr, (((int) (x1_fixed_biased >> 31L)) & ALL_BUT_LSB) | or); + addr += SIZE_INT; + _unsafe.putInt(addr, ((int) x1_fixed_biased) >>> 1); + addr += SIZE_INT; + + // inlined scalb(slope, 32): + final long slope_fixed = (long) (POWER_2_TO_32 * slope); + + // last bit set to 0 to keep orientation: + _unsafe.putInt(addr, (((int) (slope_fixed >> 31L)) & ALL_BUT_LSB)); + addr += SIZE_INT; + _unsafe.putInt(addr, ((int) slope_fixed) >>> 1); + addr += SIZE_INT; + + final int[] _edgeBuckets = edgeBuckets; + final int[] _edgeBucketCounts = edgeBucketCounts; + + final int _boundsMinY = boundsMinY; + + // each bucket is a linked list. this method adds ptr to the + // start of the "bucket"th linked list. + final int bucketIdx = firstCrossing - _boundsMinY; + + // pointer from bucket + _unsafe.putInt(addr, _edgeBuckets[bucketIdx]); + addr += SIZE_INT; + // y max (exclusive) + _unsafe.putInt(addr, lastCrossing); + + // Update buckets: + // directly the edge struct "pointer" + _edgeBuckets[bucketIdx] = edgePtr; + _edgeBucketCounts[bucketIdx] += 2; // 1 << 1 + // last bit means edge end + _edgeBucketCounts[lastCrossing - _boundsMinY] |= 0x1; + + // update free pointer (ie length in bytes) + _edges.used += _SIZEOF_EDGE_BYTES; + + if (DO_MONITORS) { + rdrCtx.stats.mon_rdr_addLine.stop(); + } + } + +// END EDGE LIST +////////////////////////////////////////////////////////////////////////////// + + // Cache to store RLE-encoded coverage mask of the current primitive + final MarlinCache cache; + + // Bounds of the drawing region, at subpixel precision. + private int boundsMinX, boundsMinY, boundsMaxX, boundsMaxY; + + // Current winding rule + private int windingRule; + + // Current drawing position, i.e., final point of last segment + private double x0, y0; + + // Position of most recent 'moveTo' command + private double sx0, sy0; + + // per-thread renderer context + final DRendererContext rdrCtx; + // dirty curve + private final DCurve curve; + + // clean alpha array (zero filled) + private int[] alphaLine; + + // alphaLine ref (clean) + private final IntArrayCache.Reference alphaLine_ref; + + private boolean enableBlkFlags = false; + private boolean prevUseBlkFlags = false; + + /* block flags (0|1) */ + private int[] blkFlags; + + // blkFlags ref (clean) + private final IntArrayCache.Reference blkFlags_ref; + + DRenderer(final DRendererContext rdrCtx) { + this.rdrCtx = rdrCtx; + + this.edges = rdrCtx.newOffHeapArray(INITIAL_EDGES_CAPACITY); // 96K + + this.curve = rdrCtx.curve; + + edgeBuckets_ref = rdrCtx.newCleanIntArrayRef(INITIAL_BUCKET_ARRAY); // 64K + edgeBucketCounts_ref = rdrCtx.newCleanIntArrayRef(INITIAL_BUCKET_ARRAY); // 64K + + edgeBuckets = edgeBuckets_ref.initial; + edgeBucketCounts = edgeBucketCounts_ref.initial; + + // 2048 (pixelsize) pixel large + alphaLine_ref = rdrCtx.newCleanIntArrayRef(INITIAL_AA_ARRAY); // 8K + alphaLine = alphaLine_ref.initial; + + this.cache = rdrCtx.cache; + + crossings_ref = rdrCtx.newDirtyIntArrayRef(INITIAL_CROSSING_COUNT); // 2K + aux_crossings_ref = rdrCtx.newDirtyIntArrayRef(INITIAL_CROSSING_COUNT); // 2K + edgePtrs_ref = rdrCtx.newDirtyIntArrayRef(INITIAL_CROSSING_COUNT); // 2K + aux_edgePtrs_ref = rdrCtx.newDirtyIntArrayRef(INITIAL_CROSSING_COUNT); // 2K + + crossings = crossings_ref.initial; + aux_crossings = aux_crossings_ref.initial; + edgePtrs = edgePtrs_ref.initial; + aux_edgePtrs = aux_edgePtrs_ref.initial; + + blkFlags_ref = rdrCtx.newCleanIntArrayRef(INITIAL_ARRAY); // 1K = 1 tile line + blkFlags = blkFlags_ref.initial; + } + + DRenderer init(final int pix_boundsX, final int pix_boundsY, + final int pix_boundsWidth, final int pix_boundsHeight, + final int windingRule) + { + this.windingRule = windingRule; + + // bounds as half-open intervals: minX <= x < maxX and minY <= y < maxY + this.boundsMinX = pix_boundsX << SUBPIXEL_LG_POSITIONS_X; + this.boundsMaxX = + (pix_boundsX + pix_boundsWidth) << SUBPIXEL_LG_POSITIONS_X; + this.boundsMinY = pix_boundsY << SUBPIXEL_LG_POSITIONS_Y; + this.boundsMaxY = + (pix_boundsY + pix_boundsHeight) << SUBPIXEL_LG_POSITIONS_Y; + + if (DO_LOG_BOUNDS) { + MarlinUtils.logInfo("boundsXY = [" + boundsMinX + " ... " + + boundsMaxX + "[ [" + boundsMinY + " ... " + + boundsMaxY + "["); + } + + // see addLine: ceil(boundsMaxY) => boundsMaxY + 1 + // +1 for edgeBucketCounts + final int edgeBucketsLength = (boundsMaxY - boundsMinY) + 1; + + if (edgeBucketsLength > INITIAL_BUCKET_ARRAY) { + if (DO_STATS) { + rdrCtx.stats.stat_array_renderer_edgeBuckets + .add(edgeBucketsLength); + rdrCtx.stats.stat_array_renderer_edgeBucketCounts + .add(edgeBucketsLength); + } + edgeBuckets = edgeBuckets_ref.getArray(edgeBucketsLength); + edgeBucketCounts = edgeBucketCounts_ref.getArray(edgeBucketsLength); + } + + edgeMinY = Integer.MAX_VALUE; + edgeMaxY = Integer.MIN_VALUE; + edgeMinX = Double.POSITIVE_INFINITY; + edgeMaxX = Double.NEGATIVE_INFINITY; + + // reset used mark: + edgeCount = 0; + activeEdgeMaxUsed = 0; + edges.used = 0; + + return this; // fluent API + } + + /** + * Disposes this renderer and recycle it clean up before reusing this instance + */ + void dispose() { + if (DO_STATS) { + rdrCtx.stats.stat_rdr_activeEdges.add(activeEdgeMaxUsed); + rdrCtx.stats.stat_rdr_edges.add(edges.used); + rdrCtx.stats.stat_rdr_edges_count.add(edges.used / SIZEOF_EDGE_BYTES); + rdrCtx.stats.hist_rdr_edges_count.add(edges.used / SIZEOF_EDGE_BYTES); + rdrCtx.stats.totalOffHeap += edges.length; + } + // Return arrays: + crossings = crossings_ref.putArray(crossings); + aux_crossings = aux_crossings_ref.putArray(aux_crossings); + + edgePtrs = edgePtrs_ref.putArray(edgePtrs); + aux_edgePtrs = aux_edgePtrs_ref.putArray(aux_edgePtrs); + + alphaLine = alphaLine_ref.putArray(alphaLine, 0, 0); // already zero filled + blkFlags = blkFlags_ref.putArray(blkFlags, 0, 0); // already zero filled + + if (edgeMinY != Integer.MAX_VALUE) { + // if context is maked as DIRTY: + if (rdrCtx.dirty) { + // may happen if an exception if thrown in the pipeline processing: + // clear completely buckets arrays: + buckets_minY = 0; + buckets_maxY = boundsMaxY - boundsMinY; + } + // clear only used part + edgeBuckets = edgeBuckets_ref.putArray(edgeBuckets, buckets_minY, + buckets_maxY); + edgeBucketCounts = edgeBucketCounts_ref.putArray(edgeBucketCounts, + buckets_minY, + buckets_maxY + 1); + } else { + // unused arrays + edgeBuckets = edgeBuckets_ref.putArray(edgeBuckets, 0, 0); + edgeBucketCounts = edgeBucketCounts_ref.putArray(edgeBucketCounts, 0, 0); + } + + // At last: resize back off-heap edges to initial size + if (edges.length != INITIAL_EDGES_CAPACITY) { + // note: may throw OOME: + edges.resize(INITIAL_EDGES_CAPACITY); + } + if (DO_CLEAN_DIRTY) { + // Force zero-fill dirty arrays: + edges.fill(BYTE_0); + } + if (DO_MONITORS) { + rdrCtx.stats.mon_rdr_endRendering.stop(); + } + // recycle the RendererContext instance + DMarlinRenderingEngine.returnRendererContext(rdrCtx); + } + + private static double tosubpixx(final double pix_x) { + return SUBPIXEL_SCALE_X * pix_x; + } + + private static double tosubpixy(final double pix_y) { + // shift y by -0.5 for fast ceil(y - 0.5): + return SUBPIXEL_SCALE_Y * pix_y - 0.5d; + } + + @Override + public void moveTo(double pix_x0, double pix_y0) { + closePath(); + final double sx = tosubpixx(pix_x0); + final double sy = tosubpixy(pix_y0); + this.sx0 = sx; + this.sy0 = sy; + this.x0 = sx; + this.y0 = sy; + } + + @Override + public void lineTo(double pix_x1, double pix_y1) { + final double x1 = tosubpixx(pix_x1); + final double y1 = tosubpixy(pix_y1); + addLine(x0, y0, x1, y1); + x0 = x1; + y0 = y1; + } + + @Override + public void curveTo(double x1, double y1, + double x2, double y2, + double x3, double y3) + { + final double xe = tosubpixx(x3); + final double ye = tosubpixy(y3); + curve.set(x0, y0, tosubpixx(x1), tosubpixy(y1), + tosubpixx(x2), tosubpixy(y2), xe, ye); + curveBreakIntoLinesAndAdd(x0, y0, curve, xe, ye); + x0 = xe; + y0 = ye; + } + + @Override + public void quadTo(double x1, double y1, double x2, double y2) { + final double xe = tosubpixx(x2); + final double ye = tosubpixy(y2); + curve.set(x0, y0, tosubpixx(x1), tosubpixy(y1), xe, ye); + quadBreakIntoLinesAndAdd(x0, y0, curve, xe, ye); + x0 = xe; + y0 = ye; + } + + @Override + public void closePath() { + addLine(x0, y0, sx0, sy0); + x0 = sx0; + y0 = sy0; + } + + @Override + public void pathDone() { + closePath(); + } + + @Override + public long getNativeConsumer() { + throw new InternalError("Renderer does not use a native consumer."); + } + + private void _endRendering(final int ymin, final int ymax) { + if (DISABLE_RENDER) { + return; + } + + // Get X bounds as true pixel boundaries to compute correct pixel coverage: + final int bboxx0 = bbox_spminX; + final int bboxx1 = bbox_spmaxX; + + final boolean windingRuleEvenOdd = (windingRule == WIND_EVEN_ODD); + + // Useful when processing tile line by tile line + final int[] _alpha = alphaLine; + + // local vars (performance): + final MarlinCache _cache = cache; + final OffHeapArray _edges = edges; + final int[] _edgeBuckets = edgeBuckets; + final int[] _edgeBucketCounts = edgeBucketCounts; + + int[] _crossings = this.crossings; + int[] _edgePtrs = this.edgePtrs; + + // merge sort auxiliary storage: + int[] _aux_crossings = this.aux_crossings; + int[] _aux_edgePtrs = this.aux_edgePtrs; + + // copy constants: + final long _OFF_ERROR = OFF_ERROR; + final long _OFF_BUMP_X = OFF_BUMP_X; + final long _OFF_BUMP_ERR = OFF_BUMP_ERR; + + final long _OFF_NEXT = OFF_NEXT; + final long _OFF_YMAX = OFF_YMAX; + + final int _ALL_BUT_LSB = ALL_BUT_LSB; + final int _ERR_STEP_MAX = ERR_STEP_MAX; + + // unsafe I/O: + final Unsafe _unsafe = OffHeapArray.UNSAFE; + final long addr0 = _edges.address; + long addr; + final int _SUBPIXEL_LG_POSITIONS_X = SUBPIXEL_LG_POSITIONS_X; + final int _SUBPIXEL_LG_POSITIONS_Y = SUBPIXEL_LG_POSITIONS_Y; + final int _SUBPIXEL_MASK_X = SUBPIXEL_MASK_X; + final int _SUBPIXEL_MASK_Y = SUBPIXEL_MASK_Y; + final int _SUBPIXEL_POSITIONS_X = SUBPIXEL_POSITIONS_X; + + final int _MIN_VALUE = Integer.MIN_VALUE; + final int _MAX_VALUE = Integer.MAX_VALUE; + + // Now we iterate through the scanlines. We must tell emitRow the coord + // of the first non-transparent pixel, so we must keep accumulators for + // the first and last pixels of the section of the current pixel row + // that we will emit. + // We also need to accumulate pix_bbox, but the iterator does it + // for us. We will just get the values from it once this loop is done + int minX = _MAX_VALUE; + int maxX = _MIN_VALUE; + + int y = ymin; + int bucket = y - boundsMinY; + + int numCrossings = this.edgeCount; + int edgePtrsLen = _edgePtrs.length; + int crossingsLen = _crossings.length; + int _arrayMaxUsed = activeEdgeMaxUsed; + int ptrLen = 0, newCount, ptrEnd; + + int bucketcount, i, j, ecur; + int cross, lastCross; + int x0, x1, tmp, sum, prev, curx, curxo, crorientation, err; + int pix_x, pix_xmaxm1, pix_xmax; + + int low, high, mid, prevNumCrossings; + boolean useBinarySearch; + + final int[] _blkFlags = blkFlags; + final int _BLK_SIZE_LG = BLOCK_SIZE_LG; + final int _BLK_SIZE = BLOCK_SIZE; + + final boolean _enableBlkFlagsHeuristics = ENABLE_BLOCK_FLAGS_HEURISTICS && this.enableBlkFlags; + + // Use block flags if large pixel span and few crossings: + // ie mean(distance between crossings) is high + boolean useBlkFlags = this.prevUseBlkFlags; + + final int stroking = rdrCtx.stroking; + + int lastY = -1; // last emited row + + + // Iteration on scanlines + for (; y < ymax; y++, bucket++) { + // --- from former ScanLineIterator.next() + bucketcount = _edgeBucketCounts[bucket]; + + // marker on previously sorted edges: + prevNumCrossings = numCrossings; + + // bucketCount indicates new edge / edge end: + if (bucketcount != 0) { + if (DO_STATS) { + rdrCtx.stats.stat_rdr_activeEdges_updates.add(numCrossings); + } + + // last bit set to 1 means that edges ends + if ((bucketcount & 0x1) != 0) { + // eviction in active edge list + // cache edges[] address + offset + addr = addr0 + _OFF_YMAX; + + for (i = 0, newCount = 0; i < numCrossings; i++) { + // get the pointer to the edge + ecur = _edgePtrs[i]; + // random access so use unsafe: + if (_unsafe.getInt(addr + ecur) > y) { + _edgePtrs[newCount++] = ecur; + } + } + // update marker on sorted edges minus removed edges: + prevNumCrossings = numCrossings = newCount; + } + + ptrLen = bucketcount >> 1; // number of new edge + + if (ptrLen != 0) { + if (DO_STATS) { + rdrCtx.stats.stat_rdr_activeEdges_adds.add(ptrLen); + if (ptrLen > 10) { + rdrCtx.stats.stat_rdr_activeEdges_adds_high.add(ptrLen); + } + } + ptrEnd = numCrossings + ptrLen; + + if (edgePtrsLen < ptrEnd) { + if (DO_STATS) { + rdrCtx.stats.stat_array_renderer_edgePtrs.add(ptrEnd); + } + this.edgePtrs = _edgePtrs + = edgePtrs_ref.widenArray(_edgePtrs, numCrossings, + ptrEnd); + + edgePtrsLen = _edgePtrs.length; + // Get larger auxiliary storage: + aux_edgePtrs_ref.putArray(_aux_edgePtrs); + + // use ArrayCache.getNewSize() to use the same growing + // factor than widenArray(): + if (DO_STATS) { + rdrCtx.stats.stat_array_renderer_aux_edgePtrs.add(ptrEnd); + } + this.aux_edgePtrs = _aux_edgePtrs + = aux_edgePtrs_ref.getArray( + ArrayCacheConst.getNewSize(numCrossings, ptrEnd) + ); + } + + // cache edges[] address + offset + addr = addr0 + _OFF_NEXT; + + // add new edges to active edge list: + for (ecur = _edgeBuckets[bucket]; + numCrossings < ptrEnd; numCrossings++) + { + // store the pointer to the edge + _edgePtrs[numCrossings] = ecur; + // random access so use unsafe: + ecur = _unsafe.getInt(addr + ecur); + } + + if (crossingsLen < numCrossings) { + // Get larger array: + crossings_ref.putArray(_crossings); + + if (DO_STATS) { + rdrCtx.stats.stat_array_renderer_crossings + .add(numCrossings); + } + this.crossings = _crossings + = crossings_ref.getArray(numCrossings); + + // Get larger auxiliary storage: + aux_crossings_ref.putArray(_aux_crossings); + + if (DO_STATS) { + rdrCtx.stats.stat_array_renderer_aux_crossings + .add(numCrossings); + } + this.aux_crossings = _aux_crossings + = aux_crossings_ref.getArray(numCrossings); + + crossingsLen = _crossings.length; + } + if (DO_STATS) { + // update max used mark + if (numCrossings > _arrayMaxUsed) { + _arrayMaxUsed = numCrossings; + } + } + } // ptrLen != 0 + } // bucketCount != 0 + + + if (numCrossings != 0) { + /* + * thresholds to switch to optimized merge sort + * for newly added edges + final merge pass. + */ + if ((ptrLen < 10) || (numCrossings < 40)) { + if (DO_STATS) { + rdrCtx.stats.hist_rdr_crossings.add(numCrossings); + rdrCtx.stats.hist_rdr_crossings_adds.add(ptrLen); + } + + /* + * threshold to use binary insertion sort instead of + * straight insertion sort (to reduce minimize comparisons). + */ + useBinarySearch = (numCrossings >= 20); + + // if small enough: + lastCross = _MIN_VALUE; + + for (i = 0; i < numCrossings; i++) { + // get the pointer to the edge + ecur = _edgePtrs[i]; + + /* convert subpixel coordinates into pixel + positions for coming scanline */ + /* note: it is faster to always update edges even + if it is removed from AEL for coming or last scanline */ + + // random access so use unsafe: + addr = addr0 + ecur; // ecur + OFF_F_CURX + + // get current crossing: + curx = _unsafe.getInt(addr); + + // update crossing with orientation at last bit: + cross = curx; + + // Increment x using DDA (fixed point): + curx += _unsafe.getInt(addr + _OFF_BUMP_X); + + // Increment error: + err = _unsafe.getInt(addr + _OFF_ERROR) + + _unsafe.getInt(addr + _OFF_BUMP_ERR); + + // Manual carry handling: + // keep sign and carry bit only and ignore last bit (preserve orientation): + _unsafe.putInt(addr, curx - ((err >> 30) & _ALL_BUT_LSB)); + _unsafe.putInt(addr + _OFF_ERROR, (err & _ERR_STEP_MAX)); + + if (DO_STATS) { + rdrCtx.stats.stat_rdr_crossings_updates.add(numCrossings); + } + + // insertion sort of crossings: + if (cross < lastCross) { + if (DO_STATS) { + rdrCtx.stats.stat_rdr_crossings_sorts.add(i); + } + + /* use binary search for newly added edges + in crossings if arrays are large enough */ + if (useBinarySearch && (i >= prevNumCrossings)) { + if (DO_STATS) { + rdrCtx.stats.stat_rdr_crossings_bsearch.add(i); + } + low = 0; + high = i - 1; + + do { + // note: use signed shift (not >>>) for performance + // as indices are small enough to exceed Integer.MAX_VALUE + mid = (low + high) >> 1; + + if (_crossings[mid] < cross) { + low = mid + 1; + } else { + high = mid - 1; + } + } while (low <= high); + + for (j = i - 1; j >= low; j--) { + _crossings[j + 1] = _crossings[j]; + _edgePtrs [j + 1] = _edgePtrs[j]; + } + _crossings[low] = cross; + _edgePtrs [low] = ecur; + + } else { + j = i - 1; + _crossings[i] = _crossings[j]; + _edgePtrs[i] = _edgePtrs[j]; + + while ((--j >= 0) && (_crossings[j] > cross)) { + _crossings[j + 1] = _crossings[j]; + _edgePtrs [j + 1] = _edgePtrs[j]; + } + _crossings[j + 1] = cross; + _edgePtrs [j + 1] = ecur; + } + + } else { + _crossings[i] = lastCross = cross; + } + } + } else { + if (DO_STATS) { + rdrCtx.stats.stat_rdr_crossings_msorts.add(numCrossings); + rdrCtx.stats.hist_rdr_crossings_ratio + .add((1000 * ptrLen) / numCrossings); + rdrCtx.stats.hist_rdr_crossings_msorts.add(numCrossings); + rdrCtx.stats.hist_rdr_crossings_msorts_adds.add(ptrLen); + } + + // Copy sorted data in auxiliary arrays + // and perform insertion sort on almost sorted data + // (ie i < prevNumCrossings): + + lastCross = _MIN_VALUE; + + for (i = 0; i < numCrossings; i++) { + // get the pointer to the edge + ecur = _edgePtrs[i]; + + /* convert subpixel coordinates into pixel + positions for coming scanline */ + /* note: it is faster to always update edges even + if it is removed from AEL for coming or last scanline */ + + // random access so use unsafe: + addr = addr0 + ecur; // ecur + OFF_F_CURX + + // get current crossing: + curx = _unsafe.getInt(addr); + + // update crossing with orientation at last bit: + cross = curx; + + // Increment x using DDA (fixed point): + curx += _unsafe.getInt(addr + _OFF_BUMP_X); + + // Increment error: + err = _unsafe.getInt(addr + _OFF_ERROR) + + _unsafe.getInt(addr + _OFF_BUMP_ERR); + + // Manual carry handling: + // keep sign and carry bit only and ignore last bit (preserve orientation): + _unsafe.putInt(addr, curx - ((err >> 30) & _ALL_BUT_LSB)); + _unsafe.putInt(addr + _OFF_ERROR, (err & _ERR_STEP_MAX)); + + if (DO_STATS) { + rdrCtx.stats.stat_rdr_crossings_updates.add(numCrossings); + } + + if (i >= prevNumCrossings) { + // simply store crossing as edgePtrs is in-place: + // will be copied and sorted efficiently by mergesort later: + _crossings[i] = cross; + + } else if (cross < lastCross) { + if (DO_STATS) { + rdrCtx.stats.stat_rdr_crossings_sorts.add(i); + } + + // (straight) insertion sort of crossings: + j = i - 1; + _aux_crossings[i] = _aux_crossings[j]; + _aux_edgePtrs[i] = _aux_edgePtrs[j]; + + while ((--j >= 0) && (_aux_crossings[j] > cross)) { + _aux_crossings[j + 1] = _aux_crossings[j]; + _aux_edgePtrs [j + 1] = _aux_edgePtrs[j]; + } + _aux_crossings[j + 1] = cross; + _aux_edgePtrs [j + 1] = ecur; + + } else { + // auxiliary storage: + _aux_crossings[i] = lastCross = cross; + _aux_edgePtrs [i] = ecur; + } + } + + // use Mergesort using auxiliary arrays (sort only right part) + MergeSort.mergeSortNoCopy(_crossings, _edgePtrs, + _aux_crossings, _aux_edgePtrs, + numCrossings, prevNumCrossings); + } + + // reset ptrLen + ptrLen = 0; + // --- from former ScanLineIterator.next() + + + /* note: bboxx0 and bboxx1 must be pixel boundaries + to have correct coverage computation */ + + // right shift on crossings to get the x-coordinate: + curxo = _crossings[0]; + x0 = curxo >> 1; + if (x0 < minX) { + minX = x0; // subpixel coordinate + } + + x1 = _crossings[numCrossings - 1] >> 1; + if (x1 > maxX) { + maxX = x1; // subpixel coordinate + } + + + // compute pixel coverages + prev = curx = x0; + // to turn {0, 1} into {-1, 1}, multiply by 2 and subtract 1. + // last bit contains orientation (0 or 1) + crorientation = ((curxo & 0x1) << 1) - 1; + + if (windingRuleEvenOdd) { + sum = crorientation; + + // Even Odd winding rule: take care of mask ie sum(orientations) + for (i = 1; i < numCrossings; i++) { + curxo = _crossings[i]; + curx = curxo >> 1; + // to turn {0, 1} into {-1, 1}, multiply by 2 and subtract 1. + // last bit contains orientation (0 or 1) + crorientation = ((curxo & 0x1) << 1) - 1; + + if ((sum & 0x1) != 0) { + // TODO: perform line clipping on left-right sides + // to avoid such bound checks: + x0 = (prev > bboxx0) ? prev : bboxx0; + + if (curx < bboxx1) { + x1 = curx; + } else { + x1 = bboxx1; + // skip right side (fast exit loop): + i = numCrossings; + } + + if (x0 < x1) { + x0 -= bboxx0; // turn x0, x1 from coords to indices + x1 -= bboxx0; // in the alpha array. + + pix_x = x0 >> _SUBPIXEL_LG_POSITIONS_X; + pix_xmaxm1 = (x1 - 1) >> _SUBPIXEL_LG_POSITIONS_X; + + if (pix_x == pix_xmaxm1) { + // Start and end in same pixel + tmp = (x1 - x0); // number of subpixels + _alpha[pix_x ] += tmp; + _alpha[pix_x + 1] -= tmp; + + if (useBlkFlags) { + // flag used blocks: + // note: block processing handles extra pixel: + _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; + } + } else { + tmp = (x0 & _SUBPIXEL_MASK_X); + _alpha[pix_x ] + += (_SUBPIXEL_POSITIONS_X - tmp); + _alpha[pix_x + 1] + += tmp; + + pix_xmax = x1 >> _SUBPIXEL_LG_POSITIONS_X; + + tmp = (x1 & _SUBPIXEL_MASK_X); + _alpha[pix_xmax ] + -= (_SUBPIXEL_POSITIONS_X - tmp); + _alpha[pix_xmax + 1] + -= tmp; + + if (useBlkFlags) { + // flag used blocks: + // note: block processing handles extra pixel: + _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; + _blkFlags[pix_xmax >> _BLK_SIZE_LG] = 1; + } + } + } + } + + sum += crorientation; + prev = curx; + } + } else { + // Non-zero winding rule: optimize that case (default) + // and avoid processing intermediate crossings + for (i = 1, sum = 0;; i++) { + sum += crorientation; + + if (sum != 0) { + // prev = min(curx) + if (prev > curx) { + prev = curx; + } + } else { + // TODO: perform line clipping on left-right sides + // to avoid such bound checks: + x0 = (prev > bboxx0) ? prev : bboxx0; + + if (curx < bboxx1) { + x1 = curx; + } else { + x1 = bboxx1; + // skip right side (fast exit loop): + i = numCrossings; + } + + if (x0 < x1) { + x0 -= bboxx0; // turn x0, x1 from coords to indices + x1 -= bboxx0; // in the alpha array. + + pix_x = x0 >> _SUBPIXEL_LG_POSITIONS_X; + pix_xmaxm1 = (x1 - 1) >> _SUBPIXEL_LG_POSITIONS_X; + + if (pix_x == pix_xmaxm1) { + // Start and end in same pixel + tmp = (x1 - x0); // number of subpixels + _alpha[pix_x ] += tmp; + _alpha[pix_x + 1] -= tmp; + + if (useBlkFlags) { + // flag used blocks: + // note: block processing handles extra pixel: + _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; + } + } else { + tmp = (x0 & _SUBPIXEL_MASK_X); + _alpha[pix_x ] + += (_SUBPIXEL_POSITIONS_X - tmp); + _alpha[pix_x + 1] + += tmp; + + pix_xmax = x1 >> _SUBPIXEL_LG_POSITIONS_X; + + tmp = (x1 & _SUBPIXEL_MASK_X); + _alpha[pix_xmax ] + -= (_SUBPIXEL_POSITIONS_X - tmp); + _alpha[pix_xmax + 1] + -= tmp; + + if (useBlkFlags) { + // flag used blocks: + // note: block processing handles extra pixel: + _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; + _blkFlags[pix_xmax >> _BLK_SIZE_LG] = 1; + } + } + } + prev = _MAX_VALUE; + } + + if (i == numCrossings) { + break; + } + + curxo = _crossings[i]; + curx = curxo >> 1; + // to turn {0, 1} into {-1, 1}, multiply by 2 and subtract 1. + // last bit contains orientation (0 or 1) + crorientation = ((curxo & 0x1) << 1) - 1; + } + } + } // numCrossings > 0 + + // even if this last row had no crossings, alpha will be zeroed + // from the last emitRow call. But this doesn't matter because + // maxX < minX, so no row will be emitted to the MarlinCache. + if ((y & _SUBPIXEL_MASK_Y) == _SUBPIXEL_MASK_Y) { + lastY = y >> _SUBPIXEL_LG_POSITIONS_Y; + + // convert subpixel to pixel coordinate within boundaries: + minX = FloatMath.max(minX, bboxx0) >> _SUBPIXEL_LG_POSITIONS_X; + maxX = FloatMath.min(maxX, bboxx1) >> _SUBPIXEL_LG_POSITIONS_X; + + if (maxX >= minX) { + // note: alpha array will be zeroed by copyAARow() + // +1 because alpha [pix_minX; pix_maxX[ + // fix range [x0; x1[ + // note: if x1=bboxx1, then alpha is written up to bboxx1+1 + // inclusive: alpha[bboxx1] ignored, alpha[bboxx1+1] == 0 + // (normally so never cleared below) + copyAARow(_alpha, lastY, minX, maxX + 1, useBlkFlags); + + // speculative for next pixel row (scanline coherence): + if (_enableBlkFlagsHeuristics) { + // Use block flags if large pixel span and few crossings: + // ie mean(distance between crossings) is larger than + // 1 block size; + + // fast check width: + maxX -= minX; + + // if stroking: numCrossings /= 2 + // => shift numCrossings by 1 + // condition = (width / (numCrossings - 1)) > blockSize + useBlkFlags = (maxX > _BLK_SIZE) && (maxX > + (((numCrossings >> stroking) - 1) << _BLK_SIZE_LG)); + + if (DO_STATS) { + tmp = FloatMath.max(1, + ((numCrossings >> stroking) - 1)); + rdrCtx.stats.hist_tile_generator_encoding_dist + .add(maxX / tmp); + } + } + } else { + _cache.clearAARow(lastY); + } + minX = _MAX_VALUE; + maxX = _MIN_VALUE; + } + } // scan line iterator + + // Emit final row + y--; + y >>= _SUBPIXEL_LG_POSITIONS_Y; + + // convert subpixel to pixel coordinate within boundaries: + minX = FloatMath.max(minX, bboxx0) >> _SUBPIXEL_LG_POSITIONS_X; + maxX = FloatMath.min(maxX, bboxx1) >> _SUBPIXEL_LG_POSITIONS_X; + + if (maxX >= minX) { + // note: alpha array will be zeroed by copyAARow() + // +1 because alpha [pix_minX; pix_maxX[ + // fix range [x0; x1[ + // note: if x1=bboxx1, then alpha is written up to bboxx1+1 + // inclusive: alpha[bboxx1] ignored then cleared and + // alpha[bboxx1+1] == 0 (normally so never cleared after) + copyAARow(_alpha, y, minX, maxX + 1, useBlkFlags); + } else if (y != lastY) { + _cache.clearAARow(y); + } + + // update member: + edgeCount = numCrossings; + prevUseBlkFlags = useBlkFlags; + + if (DO_STATS) { + // update max used mark + activeEdgeMaxUsed = _arrayMaxUsed; + } + } + + boolean endRendering() { + if (DO_MONITORS) { + rdrCtx.stats.mon_rdr_endRendering.start(); + } + if (edgeMinY == Integer.MAX_VALUE) { + return false; // undefined edges bounds + } + + // bounds as half-open intervals + final int spminX = FloatMath.max(FloatMath.ceil_int(edgeMinX - 0.5d), boundsMinX); + final int spmaxX = FloatMath.min(FloatMath.ceil_int(edgeMaxX - 0.5d), boundsMaxX); + + // edge Min/Max Y are already rounded to subpixels within bounds: + final int spminY = edgeMinY; + final int spmaxY = edgeMaxY; + + buckets_minY = spminY - boundsMinY; + buckets_maxY = spmaxY - boundsMinY; + + if (DO_LOG_BOUNDS) { + MarlinUtils.logInfo("edgesXY = [" + edgeMinX + " ... " + edgeMaxX + + "[ [" + edgeMinY + " ... " + edgeMaxY + "["); + MarlinUtils.logInfo("spXY = [" + spminX + " ... " + spmaxX + + "[ [" + spminY + " ... " + spmaxY + "["); + } + + // test clipping for shapes out of bounds + if ((spminX >= spmaxX) || (spminY >= spmaxY)) { + return false; + } + + // half open intervals + // inclusive: + final int pminX = spminX >> SUBPIXEL_LG_POSITIONS_X; + // exclusive: + final int pmaxX = (spmaxX + SUBPIXEL_MASK_X) >> SUBPIXEL_LG_POSITIONS_X; + // inclusive: + final int pminY = spminY >> SUBPIXEL_LG_POSITIONS_Y; + // exclusive: + final int pmaxY = (spmaxY + SUBPIXEL_MASK_Y) >> SUBPIXEL_LG_POSITIONS_Y; + + // store BBox to answer ptg.getBBox(): + this.cache.init(pminX, pminY, pmaxX, pmaxY); + + // Heuristics for using block flags: + if (ENABLE_BLOCK_FLAGS) { + enableBlkFlags = this.cache.useRLE; + prevUseBlkFlags = enableBlkFlags && !ENABLE_BLOCK_FLAGS_HEURISTICS; + + if (enableBlkFlags) { + // ensure blockFlags array is large enough: + // note: +2 to ensure enough space left at end + final int blkLen = ((pmaxX - pminX) >> BLOCK_SIZE_LG) + 2; + if (blkLen > INITIAL_ARRAY) { + blkFlags = blkFlags_ref.getArray(blkLen); + } + } + } + + // memorize the rendering bounding box: + /* note: bbox_spminX and bbox_spmaxX must be pixel boundaries + to have correct coverage computation */ + // inclusive: + bbox_spminX = pminX << SUBPIXEL_LG_POSITIONS_X; + // exclusive: + bbox_spmaxX = pmaxX << SUBPIXEL_LG_POSITIONS_X; + // inclusive: + bbox_spminY = spminY; + // exclusive: + bbox_spmaxY = spmaxY; + + if (DO_LOG_BOUNDS) { + MarlinUtils.logInfo("pXY = [" + pminX + " ... " + pmaxX + + "[ [" + pminY + " ... " + pmaxY + "["); + MarlinUtils.logInfo("bbox_spXY = [" + bbox_spminX + " ... " + + bbox_spmaxX + "[ [" + bbox_spminY + " ... " + + bbox_spmaxY + "["); + } + + // Prepare alpha line: + // add 2 to better deal with the last pixel in a pixel row. + final int width = (pmaxX - pminX) + 2; + + // Useful when processing tile line by tile line + if (width > INITIAL_AA_ARRAY) { + if (DO_STATS) { + rdrCtx.stats.stat_array_renderer_alphaline.add(width); + } + alphaLine = alphaLine_ref.getArray(width); + } + + // process first tile line: + endRendering(pminY); + + return true; + } + + private int bbox_spminX, bbox_spmaxX, bbox_spminY, bbox_spmaxY; + + void endRendering(final int pminY) { + if (DO_MONITORS) { + rdrCtx.stats.mon_rdr_endRendering_Y.start(); + } + + final int spminY = pminY << SUBPIXEL_LG_POSITIONS_Y; + final int fixed_spminY = FloatMath.max(bbox_spminY, spminY); + + // avoid rendering for last call to nextTile() + if (fixed_spminY < bbox_spmaxY) { + // process a complete tile line ie scanlines for 32 rows + final int spmaxY = FloatMath.min(bbox_spmaxY, spminY + SUBPIXEL_TILE); + + // process tile line [0 - 32] + cache.resetTileLine(pminY); + + // Process only one tile line: + _endRendering(fixed_spminY, spmaxY); + } + if (DO_MONITORS) { + rdrCtx.stats.mon_rdr_endRendering_Y.stop(); + } + } + + void copyAARow(final int[] alphaRow, + final int pix_y, final int pix_from, final int pix_to, + final boolean useBlockFlags) + { + if (DO_MONITORS) { + rdrCtx.stats.mon_rdr_copyAARow.start(); + } + if (useBlockFlags) { + if (DO_STATS) { + rdrCtx.stats.hist_tile_generator_encoding.add(1); + } + cache.copyAARowRLE_WithBlockFlags(blkFlags, alphaRow, pix_y, pix_from, pix_to); + } else { + if (DO_STATS) { + rdrCtx.stats.hist_tile_generator_encoding.add(0); + } + cache.copyAARowNoRLE(alphaRow, pix_y, pix_from, pix_to); + } + if (DO_MONITORS) { + rdrCtx.stats.mon_rdr_copyAARow.stop(); + } + } +} diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DRendererContext.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DRendererContext.java new file mode 100644 index 00000000000..dc8971221b5 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DRendererContext.java @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2015, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.java2d.marlin; + +import java.awt.geom.Path2D; +import java.lang.ref.WeakReference; +import java.util.concurrent.atomic.AtomicInteger; +import sun.java2d.ReentrantContext; +import sun.java2d.marlin.ArrayCacheConst.CacheStats; +import sun.java2d.marlin.DMarlinRenderingEngine.NormalizingPathIterator; + +/** + * This class is a renderer context dedicated to a single thread + */ +final class DRendererContext extends ReentrantContext implements IRendererContext { + + // RendererContext creation counter + private static final AtomicInteger CTX_COUNT = new AtomicInteger(1); + + /** + * Create a new renderer context + * + * @return new RendererContext instance + */ + static DRendererContext createContext() { + return new DRendererContext("ctx" + + Integer.toString(CTX_COUNT.getAndIncrement())); + } + + // Smallest object used as Cleaner's parent reference + private final Object cleanerObj; + // dirty flag indicating an exception occured during pipeline in pathTo() + boolean dirty = false; + // shared data + final double[] double6 = new double[6]; + // shared curve (dirty) (Renderer / Stroker) + final DCurve curve = new DCurve(); + // MarlinRenderingEngine NormalizingPathIterator NearestPixelCenter: + final NormalizingPathIterator nPCPathIterator; + // MarlinRenderingEngine NearestPixelQuarter NormalizingPathIterator: + final NormalizingPathIterator nPQPathIterator; + // MarlinRenderingEngine.TransformingPathConsumer2D + final DTransformingPathConsumer2D transformerPC2D; + // recycled Path2D instance (weak) + private WeakReference refPath2D = null; + final DRenderer renderer; + final DStroker stroker; + // Simplifies out collinear lines + final DCollinearSimplifier simplifier = new DCollinearSimplifier(); + final DDasher dasher; + final MarlinTileGenerator ptg; + final MarlinCache cache; + // flag indicating the shape is stroked (1) or filled (0) + int stroking = 0; + + // Array caches: + /* clean int[] cache (zero-filled) = 5 refs */ + private final IntArrayCache cleanIntCache = new IntArrayCache(true, 5); + /* dirty int[] cache = 4 refs */ + private final IntArrayCache dirtyIntCache = new IntArrayCache(false, 4); + /* dirty double[] cache = 3 refs */ + private final DoubleArrayCache dirtyDoubleCache = new DoubleArrayCache(false, 3); + /* dirty byte[] cache = 1 ref */ + private final ByteArrayCache dirtyByteCache = new ByteArrayCache(false, 1); + + // RendererContext statistics + final RendererStats stats; + + final PathConsumer2DAdapter p2dAdapter = new PathConsumer2DAdapter(); + + + /** + * Constructor + * + * @param name context name (debugging) + */ + DRendererContext(final String name) { + if (LOG_CREATE_CONTEXT) { + MarlinUtils.logInfo("new RendererContext = " + name); + } + this.cleanerObj = new Object(); + + // create first stats (needed by newOffHeapArray): + if (DO_STATS || DO_MONITORS) { + stats = RendererStats.createInstance(cleanerObj, name); + // push cache stats: + stats.cacheStats = new CacheStats[] { cleanIntCache.stats, + dirtyIntCache.stats, dirtyDoubleCache.stats, dirtyByteCache.stats + }; + } else { + stats = null; + } + + // NormalizingPathIterator instances: + nPCPathIterator = new NormalizingPathIterator.NearestPixelCenter(double6); + nPQPathIterator = new NormalizingPathIterator.NearestPixelQuarter(double6); + + // MarlinRenderingEngine.TransformingPathConsumer2D + transformerPC2D = new DTransformingPathConsumer2D(); + + // Renderer: + cache = new MarlinCache(this); + renderer = new DRenderer(this); // needs MarlinCache from rdrCtx.cache + ptg = new MarlinTileGenerator(stats, renderer, cache); + + stroker = new DStroker(this); + dasher = new DDasher(this); + } + + /** + * Disposes this renderer context: + * clean up before reusing this context + */ + void dispose() { + if (DO_STATS) { + if (stats.totalOffHeap > stats.totalOffHeapMax) { + stats.totalOffHeapMax = stats.totalOffHeap; + } + stats.totalOffHeap = 0L; + } + stroking = 0; + // if context is maked as DIRTY: + if (dirty) { + // may happen if an exception if thrown in the pipeline processing: + // force cleanup of all possible pipelined blocks (except Renderer): + + // NormalizingPathIterator instances: + this.nPCPathIterator.dispose(); + this.nPQPathIterator.dispose(); + // Dasher: + this.dasher.dispose(); + // Stroker: + this.stroker.dispose(); + + // mark context as CLEAN: + dirty = false; + } + } + + Path2D.Double getPath2D() { + // resolve reference: + Path2D.Double p2d + = (refPath2D != null) ? refPath2D.get() : null; + + // create a new Path2D ? + if (p2d == null) { + p2d = new Path2D.Double(Path2D.WIND_NON_ZERO, INITIAL_EDGES_COUNT); // 32K + + // update weak reference: + refPath2D = new WeakReference(p2d); + } + // reset the path anyway: + p2d.reset(); + return p2d; + } + + @Override + public RendererStats stats() { + return stats; + } + + @Override + public OffHeapArray newOffHeapArray(final long initialSize) { + if (DO_STATS) { + stats.totalOffHeapInitial += initialSize; + } + return new OffHeapArray(cleanerObj, initialSize); + } + + @Override + public IntArrayCache.Reference newCleanIntArrayRef(final int initialSize) { + return cleanIntCache.createRef(initialSize); + } + + IntArrayCache.Reference newDirtyIntArrayRef(final int initialSize) { + return dirtyIntCache.createRef(initialSize); + } + + DoubleArrayCache.Reference newDirtyDoubleArrayRef(final int initialSize) { + return dirtyDoubleCache.createRef(initialSize); + } + + ByteArrayCache.Reference newDirtyByteArrayRef(final int initialSize) { + return dirtyByteCache.createRef(initialSize); + } + + static final class PathConsumer2DAdapter implements DPathConsumer2D { + private sun.awt.geom.PathConsumer2D out; + + PathConsumer2DAdapter() {} + + PathConsumer2DAdapter init(sun.awt.geom.PathConsumer2D out) { + this.out = out; + return this; + } + + @Override + public void moveTo(double x0, double y0) { + out.moveTo((float)x0, (float)y0); + } + + @Override + public void lineTo(double x1, double y1) { + out.lineTo((float)x1, (float)y1); + } + + @Override + public void closePath() { + out.closePath(); + } + + @Override + public void pathDone() { + out.pathDone(); + } + + @Override + public void curveTo(double x1, double y1, + double x2, double y2, + double x3, double y3) + { + out.curveTo((float)x1, (float)y1, + (float)x2, (float)y2, + (float)x3, (float)y3); + } + + @Override + public void quadTo(double x1, double y1, double x2, double y2) { + out.quadTo((float)x1, (float)y1, (float)x2, (float)y2); + } + + @Override + public long getNativeConsumer() { + throw new InternalError("Not using a native peer"); + } + } +} diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DStroker.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DStroker.java new file mode 100644 index 00000000000..e8524aca0d3 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DStroker.java @@ -0,0 +1,1325 @@ +/* + * Copyright (c) 2007, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.java2d.marlin; + +import java.util.Arrays; + +// TODO: some of the arithmetic here is too verbose and prone to hard to +// debug typos. We should consider making a small Point/Vector class that +// has methods like plus(Point), minus(Point), dot(Point), cross(Point)and such +final class DStroker implements DPathConsumer2D, MarlinConst { + + private static final int MOVE_TO = 0; + private static final int DRAWING_OP_TO = 1; // ie. curve, line, or quad + private static final int CLOSE = 2; + + /** + * Constant value for join style. + */ + public static final int JOIN_MITER = 0; + + /** + * Constant value for join style. + */ + public static final int JOIN_ROUND = 1; + + /** + * Constant value for join style. + */ + public static final int JOIN_BEVEL = 2; + + /** + * Constant value for end cap style. + */ + public static final int CAP_BUTT = 0; + + /** + * Constant value for end cap style. + */ + public static final int CAP_ROUND = 1; + + /** + * Constant value for end cap style. + */ + public static final int CAP_SQUARE = 2; + + // pisces used to use fixed point arithmetic with 16 decimal digits. I + // didn't want to change the values of the constant below when I converted + // it to floating point, so that's why the divisions by 2^16 are there. + private static final double ROUND_JOIN_THRESHOLD = 1000.0d/65536.0d; + + private static final double C = 0.5522847498307933d; + + private static final int MAX_N_CURVES = 11; + + private DPathConsumer2D out; + + private int capStyle; + private int joinStyle; + + private double lineWidth2; + private double invHalfLineWidth2Sq; + + private final double[] offset0 = new double[2]; + private final double[] offset1 = new double[2]; + private final double[] offset2 = new double[2]; + private final double[] miter = new double[2]; + private double miterLimitSq; + + private int prev; + + // The starting point of the path, and the slope there. + private double sx0, sy0, sdx, sdy; + // the current point and the slope there. + private double cx0, cy0, cdx, cdy; // c stands for current + // vectors that when added to (sx0,sy0) and (cx0,cy0) respectively yield the + // first and last points on the left parallel path. Since this path is + // parallel, it's slope at any point is parallel to the slope of the + // original path (thought they may have different directions), so these + // could be computed from sdx,sdy and cdx,cdy (and vice versa), but that + // would be error prone and hard to read, so we keep these anyway. + private double smx, smy, cmx, cmy; + + private final PolyStack reverse; + + // This is where the curve to be processed is put. We give it + // enough room to store all curves. + private final double[] middle = new double[MAX_N_CURVES * 6 + 2]; + private final double[] lp = new double[8]; + private final double[] rp = new double[8]; + private final double[] subdivTs = new double[MAX_N_CURVES - 1]; + + // per-thread renderer context + final DRendererContext rdrCtx; + + // dirty curve + final DCurve curve; + + /** + * Constructs a DStroker. + * @param rdrCtx per-thread renderer context + */ + DStroker(final DRendererContext rdrCtx) { + this.rdrCtx = rdrCtx; + + this.reverse = new PolyStack(rdrCtx); + this.curve = rdrCtx.curve; + } + + /** + * Inits the DStroker. + * + * @param pc2d an output DPathConsumer2D. + * @param lineWidth the desired line width in pixels + * @param capStyle the desired end cap style, one of + * CAP_BUTT, CAP_ROUND or + * CAP_SQUARE. + * @param joinStyle the desired line join style, one of + * JOIN_MITER, JOIN_ROUND or + * JOIN_BEVEL. + * @param miterLimit the desired miter limit + * @return this instance + */ + DStroker init(DPathConsumer2D pc2d, + double lineWidth, + int capStyle, + int joinStyle, + double miterLimit) + { + this.out = pc2d; + + this.lineWidth2 = lineWidth / 2.0d; + this.invHalfLineWidth2Sq = 1.0d / (2.0d * lineWidth2 * lineWidth2); + this.capStyle = capStyle; + this.joinStyle = joinStyle; + + double limit = miterLimit * lineWidth2; + this.miterLimitSq = limit * limit; + + this.prev = CLOSE; + + rdrCtx.stroking = 1; + + return this; // fluent API + } + + /** + * Disposes this stroker: + * clean up before reusing this instance + */ + void dispose() { + reverse.dispose(); + + if (DO_CLEAN_DIRTY) { + // Force zero-fill dirty arrays: + Arrays.fill(offset0, 0.0d); + Arrays.fill(offset1, 0.0d); + Arrays.fill(offset2, 0.0d); + Arrays.fill(miter, 0.0d); + Arrays.fill(middle, 0.0d); + Arrays.fill(lp, 0.0d); + Arrays.fill(rp, 0.0d); + Arrays.fill(subdivTs, 0.0d); + } + } + + private static void computeOffset(final double lx, final double ly, + final double w, final double[] m) + { + double len = lx*lx + ly*ly; + if (len == 0.0d) { + m[0] = 0.0d; + m[1] = 0.0d; + } else { + len = Math.sqrt(len); + m[0] = (ly * w) / len; + m[1] = -(lx * w) / len; + } + } + + // Returns true if the vectors (dx1, dy1) and (dx2, dy2) are + // clockwise (if dx1,dy1 needs to be rotated clockwise to close + // the smallest angle between it and dx2,dy2). + // This is equivalent to detecting whether a point q is on the right side + // of a line passing through points p1, p2 where p2 = p1+(dx1,dy1) and + // q = p2+(dx2,dy2), which is the same as saying p1, p2, q are in a + // clockwise order. + // NOTE: "clockwise" here assumes coordinates with 0,0 at the bottom left. + private static boolean isCW(final double dx1, final double dy1, + final double dx2, final double dy2) + { + return dx1 * dy2 <= dy1 * dx2; + } + + private void drawRoundJoin(double x, double y, + double omx, double omy, double mx, double my, + boolean rev, + double threshold) + { + if ((omx == 0.0d && omy == 0.0d) || (mx == 0.0d && my == 0.0d)) { + return; + } + + double domx = omx - mx; + double domy = omy - my; + double len = domx*domx + domy*domy; + if (len < threshold) { + return; + } + + if (rev) { + omx = -omx; + omy = -omy; + mx = -mx; + my = -my; + } + drawRoundJoin(x, y, omx, omy, mx, my, rev); + } + + private void drawRoundJoin(double cx, double cy, + double omx, double omy, + double mx, double my, + boolean rev) + { + // The sign of the dot product of mx,my and omx,omy is equal to the + // the sign of the cosine of ext + // (ext is the angle between omx,omy and mx,my). + final double cosext = omx * mx + omy * my; + // If it is >=0, we know that abs(ext) is <= 90 degrees, so we only + // need 1 curve to approximate the circle section that joins omx,omy + // and mx,my. + final int numCurves = (cosext >= 0.0d) ? 1 : 2; + + switch (numCurves) { + case 1: + drawBezApproxForArc(cx, cy, omx, omy, mx, my, rev); + break; + case 2: + // we need to split the arc into 2 arcs spanning the same angle. + // The point we want will be one of the 2 intersections of the + // perpendicular bisector of the chord (omx,omy)->(mx,my) and the + // circle. We could find this by scaling the vector + // (omx+mx, omy+my)/2 so that it has length=lineWidth2 (and thus lies + // on the circle), but that can have numerical problems when the angle + // between omx,omy and mx,my is close to 180 degrees. So we compute a + // normal of (omx,omy)-(mx,my). This will be the direction of the + // perpendicular bisector. To get one of the intersections, we just scale + // this vector that its length is lineWidth2 (this works because the + // perpendicular bisector goes through the origin). This scaling doesn't + // have numerical problems because we know that lineWidth2 divided by + // this normal's length is at least 0.5 and at most sqrt(2)/2 (because + // we know the angle of the arc is > 90 degrees). + double nx = my - omy, ny = omx - mx; + double nlen = Math.sqrt(nx*nx + ny*ny); + double scale = lineWidth2/nlen; + double mmx = nx * scale, mmy = ny * scale; + + // if (isCW(omx, omy, mx, my) != isCW(mmx, mmy, mx, my)) then we've + // computed the wrong intersection so we get the other one. + // The test above is equivalent to if (rev). + if (rev) { + mmx = -mmx; + mmy = -mmy; + } + drawBezApproxForArc(cx, cy, omx, omy, mmx, mmy, rev); + drawBezApproxForArc(cx, cy, mmx, mmy, mx, my, rev); + break; + default: + } + } + + // the input arc defined by omx,omy and mx,my must span <= 90 degrees. + private void drawBezApproxForArc(final double cx, final double cy, + final double omx, final double omy, + final double mx, final double my, + boolean rev) + { + final double cosext2 = (omx * mx + omy * my) * invHalfLineWidth2Sq; + + // check round off errors producing cos(ext) > 1 and a NaN below + // cos(ext) == 1 implies colinear segments and an empty join anyway + if (cosext2 >= 0.5d) { + // just return to avoid generating a flat curve: + return; + } + + // cv is the length of P1-P0 and P2-P3 divided by the radius of the arc + // (so, cv assumes the arc has radius 1). P0, P1, P2, P3 are the points that + // define the bezier curve we're computing. + // It is computed using the constraints that P1-P0 and P3-P2 are parallel + // to the arc tangents at the endpoints, and that |P1-P0|=|P3-P2|. + double cv = ((4.0d / 3.0d) * Math.sqrt(0.5d - cosext2) / + (1.0d + Math.sqrt(cosext2 + 0.5d))); + // if clockwise, we need to negate cv. + if (rev) { // rev is equivalent to isCW(omx, omy, mx, my) + cv = -cv; + } + final double x1 = cx + omx; + final double y1 = cy + omy; + final double x2 = x1 - cv * omy; + final double y2 = y1 + cv * omx; + + final double x4 = cx + mx; + final double y4 = cy + my; + final double x3 = x4 + cv * my; + final double y3 = y4 - cv * mx; + + emitCurveTo(x1, y1, x2, y2, x3, y3, x4, y4, rev); + } + + private void drawRoundCap(double cx, double cy, double mx, double my) { + final double Cmx = C * mx; + final double Cmy = C * my; + emitCurveTo(cx + mx - Cmy, cy + my + Cmx, + cx - my + Cmx, cy + mx + Cmy, + cx - my, cy + mx); + emitCurveTo(cx - my - Cmx, cy + mx - Cmy, + cx - mx - Cmy, cy - my + Cmx, + cx - mx, cy - my); + } + + // Return the intersection point of the lines (x0, y0) -> (x1, y1) + // and (x0p, y0p) -> (x1p, y1p) in m[off] and m[off+1] + private static void computeMiter(final double x0, final double y0, + final double x1, final double y1, + final double x0p, final double y0p, + final double x1p, final double y1p, + final double[] m, int off) + { + double x10 = x1 - x0; + double y10 = y1 - y0; + double x10p = x1p - x0p; + double y10p = y1p - y0p; + + // if this is 0, the lines are parallel. If they go in the + // same direction, there is no intersection so m[off] and + // m[off+1] will contain infinity, so no miter will be drawn. + // If they go in the same direction that means that the start of the + // current segment and the end of the previous segment have the same + // tangent, in which case this method won't even be involved in + // miter drawing because it won't be called by drawMiter (because + // (mx == omx && my == omy) will be true, and drawMiter will return + // immediately). + double den = x10*y10p - x10p*y10; + double t = x10p*(y0-y0p) - y10p*(x0-x0p); + t /= den; + m[off++] = x0 + t*x10; + m[off] = y0 + t*y10; + } + + // Return the intersection point of the lines (x0, y0) -> (x1, y1) + // and (x0p, y0p) -> (x1p, y1p) in m[off] and m[off+1] + private static void safeComputeMiter(final double x0, final double y0, + final double x1, final double y1, + final double x0p, final double y0p, + final double x1p, final double y1p, + final double[] m, int off) + { + double x10 = x1 - x0; + double y10 = y1 - y0; + double x10p = x1p - x0p; + double y10p = y1p - y0p; + + // if this is 0, the lines are parallel. If they go in the + // same direction, there is no intersection so m[off] and + // m[off+1] will contain infinity, so no miter will be drawn. + // If they go in the same direction that means that the start of the + // current segment and the end of the previous segment have the same + // tangent, in which case this method won't even be involved in + // miter drawing because it won't be called by drawMiter (because + // (mx == omx && my == omy) will be true, and drawMiter will return + // immediately). + double den = x10*y10p - x10p*y10; + if (den == 0.0d) { + m[off++] = (x0 + x0p) / 2.0d; + m[off] = (y0 + y0p) / 2.0d; + return; + } + double t = x10p*(y0-y0p) - y10p*(x0-x0p); + t /= den; + m[off++] = x0 + t*x10; + m[off] = y0 + t*y10; + } + + private void drawMiter(final double pdx, final double pdy, + final double x0, final double y0, + final double dx, final double dy, + double omx, double omy, double mx, double my, + boolean rev) + { + if ((mx == omx && my == omy) || + (pdx == 0.0d && pdy == 0.0d) || + (dx == 0.0d && dy == 0.0d)) + { + return; + } + + if (rev) { + omx = -omx; + omy = -omy; + mx = -mx; + my = -my; + } + + computeMiter((x0 - pdx) + omx, (y0 - pdy) + omy, x0 + omx, y0 + omy, + (dx + x0) + mx, (dy + y0) + my, x0 + mx, y0 + my, + miter, 0); + + final double miterX = miter[0]; + final double miterY = miter[1]; + double lenSq = (miterX-x0)*(miterX-x0) + (miterY-y0)*(miterY-y0); + + // If the lines are parallel, lenSq will be either NaN or +inf + // (actually, I'm not sure if the latter is possible. The important + // thing is that -inf is not possible, because lenSq is a square). + // For both of those values, the comparison below will fail and + // no miter will be drawn, which is correct. + if (lenSq < miterLimitSq) { + emitLineTo(miterX, miterY, rev); + } + } + + @Override + public void moveTo(double x0, double y0) { + if (prev == DRAWING_OP_TO) { + finish(); + } + this.sx0 = this.cx0 = x0; + this.sy0 = this.cy0 = y0; + this.cdx = this.sdx = 1.0d; + this.cdy = this.sdy = 0.0d; + this.prev = MOVE_TO; + } + + @Override + public void lineTo(double x1, double y1) { + double dx = x1 - cx0; + double dy = y1 - cy0; + if (dx == 0.0d && dy == 0.0d) { + dx = 1.0d; + } + computeOffset(dx, dy, lineWidth2, offset0); + final double mx = offset0[0]; + final double my = offset0[1]; + + drawJoin(cdx, cdy, cx0, cy0, dx, dy, cmx, cmy, mx, my); + + emitLineTo(cx0 + mx, cy0 + my); + emitLineTo( x1 + mx, y1 + my); + + emitLineToRev(cx0 - mx, cy0 - my); + emitLineToRev( x1 - mx, y1 - my); + + this.cmx = mx; + this.cmy = my; + this.cdx = dx; + this.cdy = dy; + this.cx0 = x1; + this.cy0 = y1; + this.prev = DRAWING_OP_TO; + } + + @Override + public void closePath() { + if (prev != DRAWING_OP_TO) { + if (prev == CLOSE) { + return; + } + emitMoveTo(cx0, cy0 - lineWidth2); + this.cmx = this.smx = 0.0d; + this.cmy = this.smy = -lineWidth2; + this.cdx = this.sdx = 1.0d; + this.cdy = this.sdy = 0.0d; + finish(); + return; + } + + if (cx0 != sx0 || cy0 != sy0) { + lineTo(sx0, sy0); + } + + drawJoin(cdx, cdy, cx0, cy0, sdx, sdy, cmx, cmy, smx, smy); + + emitLineTo(sx0 + smx, sy0 + smy); + + emitMoveTo(sx0 - smx, sy0 - smy); + emitReverse(); + + this.prev = CLOSE; + emitClose(); + } + + private void emitReverse() { + reverse.popAll(out); + } + + @Override + public void pathDone() { + if (prev == DRAWING_OP_TO) { + finish(); + } + + out.pathDone(); + + // this shouldn't matter since this object won't be used + // after the call to this method. + this.prev = CLOSE; + + // Dispose this instance: + dispose(); + } + + private void finish() { + if (capStyle == CAP_ROUND) { + drawRoundCap(cx0, cy0, cmx, cmy); + } else if (capStyle == CAP_SQUARE) { + emitLineTo(cx0 - cmy + cmx, cy0 + cmx + cmy); + emitLineTo(cx0 - cmy - cmx, cy0 + cmx - cmy); + } + + emitReverse(); + + if (capStyle == CAP_ROUND) { + drawRoundCap(sx0, sy0, -smx, -smy); + } else if (capStyle == CAP_SQUARE) { + emitLineTo(sx0 + smy - smx, sy0 - smx - smy); + emitLineTo(sx0 + smy + smx, sy0 - smx + smy); + } + + emitClose(); + } + + private void emitMoveTo(final double x0, final double y0) { + out.moveTo(x0, y0); + } + + private void emitLineTo(final double x1, final double y1) { + out.lineTo(x1, y1); + } + + private void emitLineToRev(final double x1, final double y1) { + reverse.pushLine(x1, y1); + } + + private void emitLineTo(final double x1, final double y1, + final boolean rev) + { + if (rev) { + emitLineToRev(x1, y1); + } else { + emitLineTo(x1, y1); + } + } + + private void emitQuadTo(final double x1, final double y1, + final double x2, final double y2) + { + out.quadTo(x1, y1, x2, y2); + } + + private void emitQuadToRev(final double x0, final double y0, + final double x1, final double y1) + { + reverse.pushQuad(x0, y0, x1, y1); + } + + private void emitCurveTo(final double x1, final double y1, + final double x2, final double y2, + final double x3, final double y3) + { + out.curveTo(x1, y1, x2, y2, x3, y3); + } + + private void emitCurveToRev(final double x0, final double y0, + final double x1, final double y1, + final double x2, final double y2) + { + reverse.pushCubic(x0, y0, x1, y1, x2, y2); + } + + private void emitCurveTo(final double x0, final double y0, + final double x1, final double y1, + final double x2, final double y2, + final double x3, final double y3, final boolean rev) + { + if (rev) { + reverse.pushCubic(x0, y0, x1, y1, x2, y2); + } else { + out.curveTo(x1, y1, x2, y2, x3, y3); + } + } + + private void emitClose() { + out.closePath(); + } + + private void drawJoin(double pdx, double pdy, + double x0, double y0, + double dx, double dy, + double omx, double omy, + double mx, double my) + { + if (prev != DRAWING_OP_TO) { + emitMoveTo(x0 + mx, y0 + my); + this.sdx = dx; + this.sdy = dy; + this.smx = mx; + this.smy = my; + } else { + boolean cw = isCW(pdx, pdy, dx, dy); + if (joinStyle == JOIN_MITER) { + drawMiter(pdx, pdy, x0, y0, dx, dy, omx, omy, mx, my, cw); + } else if (joinStyle == JOIN_ROUND) { + drawRoundJoin(x0, y0, + omx, omy, + mx, my, cw, + ROUND_JOIN_THRESHOLD); + } + emitLineTo(x0, y0, !cw); + } + prev = DRAWING_OP_TO; + } + + private static boolean within(final double x1, final double y1, + final double x2, final double y2, + final double ERR) + { + assert ERR > 0 : ""; + // compare taxicab distance. ERR will always be small, so using + // true distance won't give much benefit + return (DHelpers.within(x1, x2, ERR) && // we want to avoid calling Math.abs + DHelpers.within(y1, y2, ERR)); // this is just as good. + } + + private void getLineOffsets(double x1, double y1, + double x2, double y2, + double[] left, double[] right) { + computeOffset(x2 - x1, y2 - y1, lineWidth2, offset0); + final double mx = offset0[0]; + final double my = offset0[1]; + left[0] = x1 + mx; + left[1] = y1 + my; + left[2] = x2 + mx; + left[3] = y2 + my; + right[0] = x1 - mx; + right[1] = y1 - my; + right[2] = x2 - mx; + right[3] = y2 - my; + } + + private int computeOffsetCubic(double[] pts, final int off, + double[] leftOff, double[] rightOff) + { + // if p1=p2 or p3=p4 it means that the derivative at the endpoint + // vanishes, which creates problems with computeOffset. Usually + // this happens when this stroker object is trying to widen + // a curve with a cusp. What happens is that curveTo splits + // the input curve at the cusp, and passes it to this function. + // because of inaccuracies in the splitting, we consider points + // equal if they're very close to each other. + final double x1 = pts[off + 0], y1 = pts[off + 1]; + final double x2 = pts[off + 2], y2 = pts[off + 3]; + final double x3 = pts[off + 4], y3 = pts[off + 5]; + final double x4 = pts[off + 6], y4 = pts[off + 7]; + + double dx4 = x4 - x3; + double dy4 = y4 - y3; + double dx1 = x2 - x1; + double dy1 = y2 - y1; + + // if p1 == p2 && p3 == p4: draw line from p1->p4, unless p1 == p4, + // in which case ignore if p1 == p2 + final boolean p1eqp2 = within(x1, y1, x2, y2, 6.0d * Math.ulp(y2)); + final boolean p3eqp4 = within(x3, y3, x4, y4, 6.0d * Math.ulp(y4)); + if (p1eqp2 && p3eqp4) { + getLineOffsets(x1, y1, x4, y4, leftOff, rightOff); + return 4; + } else if (p1eqp2) { + dx1 = x3 - x1; + dy1 = y3 - y1; + } else if (p3eqp4) { + dx4 = x4 - x2; + dy4 = y4 - y2; + } + + // if p2-p1 and p4-p3 are parallel, that must mean this curve is a line + double dotsq = (dx1 * dx4 + dy1 * dy4); + dotsq *= dotsq; + double l1sq = dx1 * dx1 + dy1 * dy1, l4sq = dx4 * dx4 + dy4 * dy4; + if (DHelpers.within(dotsq, l1sq * l4sq, 4.0d * Math.ulp(dotsq))) { + getLineOffsets(x1, y1, x4, y4, leftOff, rightOff); + return 4; + } + +// What we're trying to do in this function is to approximate an ideal +// offset curve (call it I) of the input curve B using a bezier curve Bp. +// The constraints I use to get the equations are: +// +// 1. The computed curve Bp should go through I(0) and I(1). These are +// x1p, y1p, x4p, y4p, which are p1p and p4p. We still need to find +// 4 variables: the x and y components of p2p and p3p (i.e. x2p, y2p, x3p, y3p). +// +// 2. Bp should have slope equal in absolute value to I at the endpoints. So, +// (by the way, the operator || in the comments below means "aligned with". +// It is defined on vectors, so when we say I'(0) || Bp'(0) we mean that +// vectors I'(0) and Bp'(0) are aligned, which is the same as saying +// that the tangent lines of I and Bp at 0 are parallel. Mathematically +// this means (I'(t) || Bp'(t)) <==> (I'(t) = c * Bp'(t)) where c is some +// nonzero constant.) +// I'(0) || Bp'(0) and I'(1) || Bp'(1). Obviously, I'(0) || B'(0) and +// I'(1) || B'(1); therefore, Bp'(0) || B'(0) and Bp'(1) || B'(1). +// We know that Bp'(0) || (p2p-p1p) and Bp'(1) || (p4p-p3p) and the same +// is true for any bezier curve; therefore, we get the equations +// (1) p2p = c1 * (p2-p1) + p1p +// (2) p3p = c2 * (p4-p3) + p4p +// We know p1p, p4p, p2, p1, p3, and p4; therefore, this reduces the number +// of unknowns from 4 to 2 (i.e. just c1 and c2). +// To eliminate these 2 unknowns we use the following constraint: +// +// 3. Bp(0.5) == I(0.5). Bp(0.5)=(x,y) and I(0.5)=(xi,yi), and I should note +// that I(0.5) is *the only* reason for computing dxm,dym. This gives us +// (3) Bp(0.5) = (p1p + 3 * (p2p + p3p) + p4p)/8, which is equivalent to +// (4) p2p + p3p = (Bp(0.5)*8 - p1p - p4p) / 3 +// We can substitute (1) and (2) from above into (4) and we get: +// (5) c1*(p2-p1) + c2*(p4-p3) = (Bp(0.5)*8 - p1p - p4p)/3 - p1p - p4p +// which is equivalent to +// (6) c1*(p2-p1) + c2*(p4-p3) = (4/3) * (Bp(0.5) * 2 - p1p - p4p) +// +// The right side of this is a 2D vector, and we know I(0.5), which gives us +// Bp(0.5), which gives us the value of the right side. +// The left side is just a matrix vector multiplication in disguise. It is +// +// [x2-x1, x4-x3][c1] +// [y2-y1, y4-y3][c2] +// which, is equal to +// [dx1, dx4][c1] +// [dy1, dy4][c2] +// At this point we are left with a simple linear system and we solve it by +// getting the inverse of the matrix above. Then we use [c1,c2] to compute +// p2p and p3p. + + double x = (x1 + 3.0d * (x2 + x3) + x4) / 8.0d; + double y = (y1 + 3.0d * (y2 + y3) + y4) / 8.0d; + // (dxm,dym) is some tangent of B at t=0.5. This means it's equal to + // c*B'(0.5) for some constant c. + double dxm = x3 + x4 - x1 - x2, dym = y3 + y4 - y1 - y2; + + // this computes the offsets at t=0, 0.5, 1, using the property that + // for any bezier curve the vectors p2-p1 and p4-p3 are parallel to + // the (dx/dt, dy/dt) vectors at the endpoints. + computeOffset(dx1, dy1, lineWidth2, offset0); + computeOffset(dxm, dym, lineWidth2, offset1); + computeOffset(dx4, dy4, lineWidth2, offset2); + double x1p = x1 + offset0[0]; // start + double y1p = y1 + offset0[1]; // point + double xi = x + offset1[0]; // interpolation + double yi = y + offset1[1]; // point + double x4p = x4 + offset2[0]; // end + double y4p = y4 + offset2[1]; // point + + double invdet43 = 4.0d / (3.0d * (dx1 * dy4 - dy1 * dx4)); + + double two_pi_m_p1_m_p4x = 2.0d * xi - x1p - x4p; + double two_pi_m_p1_m_p4y = 2.0d * yi - y1p - y4p; + double c1 = invdet43 * (dy4 * two_pi_m_p1_m_p4x - dx4 * two_pi_m_p1_m_p4y); + double c2 = invdet43 * (dx1 * two_pi_m_p1_m_p4y - dy1 * two_pi_m_p1_m_p4x); + + double x2p, y2p, x3p, y3p; + x2p = x1p + c1*dx1; + y2p = y1p + c1*dy1; + x3p = x4p + c2*dx4; + y3p = y4p + c2*dy4; + + leftOff[0] = x1p; leftOff[1] = y1p; + leftOff[2] = x2p; leftOff[3] = y2p; + leftOff[4] = x3p; leftOff[5] = y3p; + leftOff[6] = x4p; leftOff[7] = y4p; + + x1p = x1 - offset0[0]; y1p = y1 - offset0[1]; + xi = xi - 2.0d * offset1[0]; yi = yi - 2.0d * offset1[1]; + x4p = x4 - offset2[0]; y4p = y4 - offset2[1]; + + two_pi_m_p1_m_p4x = 2.0d * xi - x1p - x4p; + two_pi_m_p1_m_p4y = 2.0d * yi - y1p - y4p; + c1 = invdet43 * (dy4 * two_pi_m_p1_m_p4x - dx4 * two_pi_m_p1_m_p4y); + c2 = invdet43 * (dx1 * two_pi_m_p1_m_p4y - dy1 * two_pi_m_p1_m_p4x); + + x2p = x1p + c1*dx1; + y2p = y1p + c1*dy1; + x3p = x4p + c2*dx4; + y3p = y4p + c2*dy4; + + rightOff[0] = x1p; rightOff[1] = y1p; + rightOff[2] = x2p; rightOff[3] = y2p; + rightOff[4] = x3p; rightOff[5] = y3p; + rightOff[6] = x4p; rightOff[7] = y4p; + return 8; + } + + // compute offset curves using bezier spline through t=0.5 (i.e. + // ComputedCurve(0.5) == IdealParallelCurve(0.5)) + // return the kind of curve in the right and left arrays. + private int computeOffsetQuad(double[] pts, final int off, + double[] leftOff, double[] rightOff) + { + final double x1 = pts[off + 0], y1 = pts[off + 1]; + final double x2 = pts[off + 2], y2 = pts[off + 3]; + final double x3 = pts[off + 4], y3 = pts[off + 5]; + + final double dx3 = x3 - x2; + final double dy3 = y3 - y2; + final double dx1 = x2 - x1; + final double dy1 = y2 - y1; + + // if p1=p2 or p3=p4 it means that the derivative at the endpoint + // vanishes, which creates problems with computeOffset. Usually + // this happens when this stroker object is trying to widen + // a curve with a cusp. What happens is that curveTo splits + // the input curve at the cusp, and passes it to this function. + // because of inaccuracies in the splitting, we consider points + // equal if they're very close to each other. + + // if p1 == p2 && p3 == p4: draw line from p1->p4, unless p1 == p4, + // in which case ignore. + final boolean p1eqp2 = within(x1, y1, x2, y2, 6.0d * Math.ulp(y2)); + final boolean p2eqp3 = within(x2, y2, x3, y3, 6.0d * Math.ulp(y3)); + if (p1eqp2 || p2eqp3) { + getLineOffsets(x1, y1, x3, y3, leftOff, rightOff); + return 4; + } + + // if p2-p1 and p4-p3 are parallel, that must mean this curve is a line + double dotsq = (dx1 * dx3 + dy1 * dy3); + dotsq *= dotsq; + double l1sq = dx1 * dx1 + dy1 * dy1, l3sq = dx3 * dx3 + dy3 * dy3; + if (DHelpers.within(dotsq, l1sq * l3sq, 4.0d * Math.ulp(dotsq))) { + getLineOffsets(x1, y1, x3, y3, leftOff, rightOff); + return 4; + } + + // this computes the offsets at t=0, 0.5, 1, using the property that + // for any bezier curve the vectors p2-p1 and p4-p3 are parallel to + // the (dx/dt, dy/dt) vectors at the endpoints. + computeOffset(dx1, dy1, lineWidth2, offset0); + computeOffset(dx3, dy3, lineWidth2, offset1); + + double x1p = x1 + offset0[0]; // start + double y1p = y1 + offset0[1]; // point + double x3p = x3 + offset1[0]; // end + double y3p = y3 + offset1[1]; // point + safeComputeMiter(x1p, y1p, x1p+dx1, y1p+dy1, x3p, y3p, x3p-dx3, y3p-dy3, leftOff, 2); + leftOff[0] = x1p; leftOff[1] = y1p; + leftOff[4] = x3p; leftOff[5] = y3p; + + x1p = x1 - offset0[0]; y1p = y1 - offset0[1]; + x3p = x3 - offset1[0]; y3p = y3 - offset1[1]; + safeComputeMiter(x1p, y1p, x1p+dx1, y1p+dy1, x3p, y3p, x3p-dx3, y3p-dy3, rightOff, 2); + rightOff[0] = x1p; rightOff[1] = y1p; + rightOff[4] = x3p; rightOff[5] = y3p; + return 6; + } + + // finds values of t where the curve in pts should be subdivided in order + // to get good offset curves a distance of w away from the middle curve. + // Stores the points in ts, and returns how many of them there were. + private static int findSubdivPoints(final DCurve c, double[] pts, double[] ts, + final int type, final double w) + { + final double x12 = pts[2] - pts[0]; + final double y12 = pts[3] - pts[1]; + // if the curve is already parallel to either axis we gain nothing + // from rotating it. + if (y12 != 0.0d && x12 != 0.0d) { + // we rotate it so that the first vector in the control polygon is + // parallel to the x-axis. This will ensure that rotated quarter + // circles won't be subdivided. + final double hypot = Math.sqrt(x12 * x12 + y12 * y12); + final double cos = x12 / hypot; + final double sin = y12 / hypot; + final double x1 = cos * pts[0] + sin * pts[1]; + final double y1 = cos * pts[1] - sin * pts[0]; + final double x2 = cos * pts[2] + sin * pts[3]; + final double y2 = cos * pts[3] - sin * pts[2]; + final double x3 = cos * pts[4] + sin * pts[5]; + final double y3 = cos * pts[5] - sin * pts[4]; + + switch(type) { + case 8: + final double x4 = cos * pts[6] + sin * pts[7]; + final double y4 = cos * pts[7] - sin * pts[6]; + c.set(x1, y1, x2, y2, x3, y3, x4, y4); + break; + case 6: + c.set(x1, y1, x2, y2, x3, y3); + break; + default: + } + } else { + c.set(pts, type); + } + + int ret = 0; + // we subdivide at values of t such that the remaining rotated + // curves are monotonic in x and y. + ret += c.dxRoots(ts, ret); + ret += c.dyRoots(ts, ret); + // subdivide at inflection points. + if (type == 8) { + // quadratic curves can't have inflection points + ret += c.infPoints(ts, ret); + } + + // now we must subdivide at points where one of the offset curves will have + // a cusp. This happens at ts where the radius of curvature is equal to w. + ret += c.rootsOfROCMinusW(ts, ret, w, 0.0001d); + + ret = DHelpers.filterOutNotInAB(ts, 0, ret, 0.0001d, 0.9999d); + DHelpers.isort(ts, 0, ret); + return ret; + } + + @Override public void curveTo(double x1, double y1, + double x2, double y2, + double x3, double y3) + { + final double[] mid = middle; + + mid[0] = cx0; mid[1] = cy0; + mid[2] = x1; mid[3] = y1; + mid[4] = x2; mid[5] = y2; + mid[6] = x3; mid[7] = y3; + + // need these so we can update the state at the end of this method + final double xf = mid[6], yf = mid[7]; + double dxs = mid[2] - mid[0]; + double dys = mid[3] - mid[1]; + double dxf = mid[6] - mid[4]; + double dyf = mid[7] - mid[5]; + + boolean p1eqp2 = (dxs == 0.0d && dys == 0.0d); + boolean p3eqp4 = (dxf == 0.0d && dyf == 0.0d); + if (p1eqp2) { + dxs = mid[4] - mid[0]; + dys = mid[5] - mid[1]; + if (dxs == 0.0d && dys == 0.0d) { + dxs = mid[6] - mid[0]; + dys = mid[7] - mid[1]; + } + } + if (p3eqp4) { + dxf = mid[6] - mid[2]; + dyf = mid[7] - mid[3]; + if (dxf == 0.0d && dyf == 0.0d) { + dxf = mid[6] - mid[0]; + dyf = mid[7] - mid[1]; + } + } + if (dxs == 0.0d && dys == 0.0d) { + // this happens if the "curve" is just a point + lineTo(mid[0], mid[1]); + return; + } + + // if these vectors are too small, normalize them, to avoid future + // precision problems. + if (Math.abs(dxs) < 0.1d && Math.abs(dys) < 0.1d) { + double len = Math.sqrt(dxs*dxs + dys*dys); + dxs /= len; + dys /= len; + } + if (Math.abs(dxf) < 0.1d && Math.abs(dyf) < 0.1d) { + double len = Math.sqrt(dxf*dxf + dyf*dyf); + dxf /= len; + dyf /= len; + } + + computeOffset(dxs, dys, lineWidth2, offset0); + drawJoin(cdx, cdy, cx0, cy0, dxs, dys, cmx, cmy, offset0[0], offset0[1]); + + final int nSplits = findSubdivPoints(curve, mid, subdivTs, 8, lineWidth2); + + double prevT = 0.0d; + for (int i = 0, off = 0; i < nSplits; i++, off += 6) { + final double t = subdivTs[i]; + DHelpers.subdivideCubicAt((t - prevT) / (1.0d - prevT), + mid, off, mid, off, mid, off + 6); + prevT = t; + } + + final double[] l = lp; + final double[] r = rp; + + int kind = 0; + for (int i = 0, off = 0; i <= nSplits; i++, off += 6) { + kind = computeOffsetCubic(mid, off, l, r); + + emitLineTo(l[0], l[1]); + + switch(kind) { + case 8: + emitCurveTo(l[2], l[3], l[4], l[5], l[6], l[7]); + emitCurveToRev(r[0], r[1], r[2], r[3], r[4], r[5]); + break; + case 4: + emitLineTo(l[2], l[3]); + emitLineToRev(r[0], r[1]); + break; + default: + } + emitLineToRev(r[kind - 2], r[kind - 1]); + } + + this.cmx = (l[kind - 2] - r[kind - 2]) / 2.0d; + this.cmy = (l[kind - 1] - r[kind - 1]) / 2.0d; + this.cdx = dxf; + this.cdy = dyf; + this.cx0 = xf; + this.cy0 = yf; + this.prev = DRAWING_OP_TO; + } + + @Override public void quadTo(double x1, double y1, double x2, double y2) { + final double[] mid = middle; + + mid[0] = cx0; mid[1] = cy0; + mid[2] = x1; mid[3] = y1; + mid[4] = x2; mid[5] = y2; + + // need these so we can update the state at the end of this method + final double xf = mid[4], yf = mid[5]; + double dxs = mid[2] - mid[0]; + double dys = mid[3] - mid[1]; + double dxf = mid[4] - mid[2]; + double dyf = mid[5] - mid[3]; + if ((dxs == 0.0d && dys == 0.0d) || (dxf == 0.0d && dyf == 0.0d)) { + dxs = dxf = mid[4] - mid[0]; + dys = dyf = mid[5] - mid[1]; + } + if (dxs == 0.0d && dys == 0.0d) { + // this happens if the "curve" is just a point + lineTo(mid[0], mid[1]); + return; + } + // if these vectors are too small, normalize them, to avoid future + // precision problems. + if (Math.abs(dxs) < 0.1d && Math.abs(dys) < 0.1d) { + double len = Math.sqrt(dxs*dxs + dys*dys); + dxs /= len; + dys /= len; + } + if (Math.abs(dxf) < 0.1d && Math.abs(dyf) < 0.1d) { + double len = Math.sqrt(dxf*dxf + dyf*dyf); + dxf /= len; + dyf /= len; + } + + computeOffset(dxs, dys, lineWidth2, offset0); + drawJoin(cdx, cdy, cx0, cy0, dxs, dys, cmx, cmy, offset0[0], offset0[1]); + + int nSplits = findSubdivPoints(curve, mid, subdivTs, 6, lineWidth2); + + double prevt = 0.0d; + for (int i = 0, off = 0; i < nSplits; i++, off += 4) { + final double t = subdivTs[i]; + DHelpers.subdivideQuadAt((t - prevt) / (1.0d - prevt), + mid, off, mid, off, mid, off + 4); + prevt = t; + } + + final double[] l = lp; + final double[] r = rp; + + int kind = 0; + for (int i = 0, off = 0; i <= nSplits; i++, off += 4) { + kind = computeOffsetQuad(mid, off, l, r); + + emitLineTo(l[0], l[1]); + + switch(kind) { + case 6: + emitQuadTo(l[2], l[3], l[4], l[5]); + emitQuadToRev(r[0], r[1], r[2], r[3]); + break; + case 4: + emitLineTo(l[2], l[3]); + emitLineToRev(r[0], r[1]); + break; + default: + } + emitLineToRev(r[kind - 2], r[kind - 1]); + } + + this.cmx = (l[kind - 2] - r[kind - 2]) / 2.0d; + this.cmy = (l[kind - 1] - r[kind - 1]) / 2.0d; + this.cdx = dxf; + this.cdy = dyf; + this.cx0 = xf; + this.cy0 = yf; + this.prev = DRAWING_OP_TO; + } + + @Override public long getNativeConsumer() { + throw new InternalError("Stroker doesn't use a native consumer"); + } + + // a stack of polynomial curves where each curve shares endpoints with + // adjacent ones. + static final class PolyStack { + private static final byte TYPE_LINETO = (byte) 0; + private static final byte TYPE_QUADTO = (byte) 1; + private static final byte TYPE_CUBICTO = (byte) 2; + + // curves capacity = edges count (8192) = edges x 2 (coords) + private static final int INITIAL_CURVES_COUNT = INITIAL_EDGES_COUNT << 1; + + // types capacity = edges count (4096) + private static final int INITIAL_TYPES_COUNT = INITIAL_EDGES_COUNT; + + double[] curves; + int end; + byte[] curveTypes; + int numCurves; + + // per-thread renderer context + final DRendererContext rdrCtx; + + // curves ref (dirty) + final DoubleArrayCache.Reference curves_ref; + // curveTypes ref (dirty) + final ByteArrayCache.Reference curveTypes_ref; + + // used marks (stats only) + int curveTypesUseMark; + int curvesUseMark; + + /** + * Constructor + * @param rdrCtx per-thread renderer context + */ + PolyStack(final DRendererContext rdrCtx) { + this.rdrCtx = rdrCtx; + + curves_ref = rdrCtx.newDirtyDoubleArrayRef(INITIAL_CURVES_COUNT); // 32K + curves = curves_ref.initial; + + curveTypes_ref = rdrCtx.newDirtyByteArrayRef(INITIAL_TYPES_COUNT); // 4K + curveTypes = curveTypes_ref.initial; + numCurves = 0; + end = 0; + + if (DO_STATS) { + curveTypesUseMark = 0; + curvesUseMark = 0; + } + } + + /** + * Disposes this PolyStack: + * clean up before reusing this instance + */ + void dispose() { + end = 0; + numCurves = 0; + + if (DO_STATS) { + rdrCtx.stats.stat_rdr_poly_stack_types.add(curveTypesUseMark); + rdrCtx.stats.stat_rdr_poly_stack_curves.add(curvesUseMark); + rdrCtx.stats.hist_rdr_poly_stack_curves.add(curvesUseMark); + + // reset marks + curveTypesUseMark = 0; + curvesUseMark = 0; + } + + // Return arrays: + // curves and curveTypes are kept dirty + curves = curves_ref.putArray(curves); + curveTypes = curveTypes_ref.putArray(curveTypes); + } + + private void ensureSpace(final int n) { + // use substraction to avoid integer overflow: + if (curves.length - end < n) { + if (DO_STATS) { + rdrCtx.stats.stat_array_stroker_polystack_curves + .add(end + n); + } + curves = curves_ref.widenArray(curves, end, end + n); + } + if (curveTypes.length <= numCurves) { + if (DO_STATS) { + rdrCtx.stats.stat_array_stroker_polystack_curveTypes + .add(numCurves + 1); + } + curveTypes = curveTypes_ref.widenArray(curveTypes, + numCurves, + numCurves + 1); + } + } + + void pushCubic(double x0, double y0, + double x1, double y1, + double x2, double y2) + { + ensureSpace(6); + curveTypes[numCurves++] = TYPE_CUBICTO; + // we reverse the coordinate order to make popping easier + final double[] _curves = curves; + int e = end; + _curves[e++] = x2; _curves[e++] = y2; + _curves[e++] = x1; _curves[e++] = y1; + _curves[e++] = x0; _curves[e++] = y0; + end = e; + } + + void pushQuad(double x0, double y0, + double x1, double y1) + { + ensureSpace(4); + curveTypes[numCurves++] = TYPE_QUADTO; + final double[] _curves = curves; + int e = end; + _curves[e++] = x1; _curves[e++] = y1; + _curves[e++] = x0; _curves[e++] = y0; + end = e; + } + + void pushLine(double x, double y) { + ensureSpace(2); + curveTypes[numCurves++] = TYPE_LINETO; + curves[end++] = x; curves[end++] = y; + } + + void popAll(DPathConsumer2D io) { + if (DO_STATS) { + // update used marks: + if (numCurves > curveTypesUseMark) { + curveTypesUseMark = numCurves; + } + if (end > curvesUseMark) { + curvesUseMark = end; + } + } + final byte[] _curveTypes = curveTypes; + final double[] _curves = curves; + int nc = numCurves; + int e = end; + + while (nc != 0) { + switch(_curveTypes[--nc]) { + case TYPE_LINETO: + e -= 2; + io.lineTo(_curves[e], _curves[e+1]); + continue; + case TYPE_QUADTO: + e -= 4; + io.quadTo(_curves[e+0], _curves[e+1], + _curves[e+2], _curves[e+3]); + continue; + case TYPE_CUBICTO: + e -= 6; + io.curveTo(_curves[e+0], _curves[e+1], + _curves[e+2], _curves[e+3], + _curves[e+4], _curves[e+5]); + continue; + default: + } + } + numCurves = 0; + end = 0; + } + + @Override + public String toString() { + String ret = ""; + int nc = numCurves; + int last = end; + int len; + while (nc != 0) { + switch(curveTypes[--nc]) { + case TYPE_LINETO: + len = 2; + ret += "line: "; + break; + case TYPE_QUADTO: + len = 4; + ret += "quad: "; + break; + case TYPE_CUBICTO: + len = 6; + ret += "cubic: "; + break; + default: + len = 0; + } + last -= len; + ret += Arrays.toString(Arrays.copyOfRange(curves, last, last+len)) + + "\n"; + } + return ret; + } + } +} diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DTransformingPathConsumer2D.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DTransformingPathConsumer2D.java new file mode 100644 index 00000000000..ca36b2833af --- /dev/null +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DTransformingPathConsumer2D.java @@ -0,0 +1,277 @@ +/* + * Copyright (c) 2007, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.java2d.marlin; + +import java.awt.geom.AffineTransform; +import java.awt.geom.Path2D; + +final class DTransformingPathConsumer2D { + + DTransformingPathConsumer2D() { + // used by DRendererContext + } + + // recycled DPathConsumer2D instance from wrapPath2d() + private final Path2DWrapper wp_Path2DWrapper = new Path2DWrapper(); + + DPathConsumer2D wrapPath2d(Path2D.Double p2d) + { + return wp_Path2DWrapper.init(p2d); + } + + // recycled DPathConsumer2D instances from deltaTransformConsumer() + private final DeltaScaleFilter dt_DeltaScaleFilter = new DeltaScaleFilter(); + private final DeltaTransformFilter dt_DeltaTransformFilter = new DeltaTransformFilter(); + + DPathConsumer2D deltaTransformConsumer(DPathConsumer2D out, + AffineTransform at) + { + if (at == null) { + return out; + } + double mxx = at.getScaleX(); + double mxy = at.getShearX(); + double myx = at.getShearY(); + double myy = at.getScaleY(); + + if (mxy == 0.0d && myx == 0.0d) { + if (mxx == 1.0d && myy == 1.0d) { + return out; + } else { + return dt_DeltaScaleFilter.init(out, mxx, myy); + } + } else { + return dt_DeltaTransformFilter.init(out, mxx, mxy, myx, myy); + } + } + + // recycled DPathConsumer2D instances from inverseDeltaTransformConsumer() + private final DeltaScaleFilter iv_DeltaScaleFilter = new DeltaScaleFilter(); + private final DeltaTransformFilter iv_DeltaTransformFilter = new DeltaTransformFilter(); + + DPathConsumer2D inverseDeltaTransformConsumer(DPathConsumer2D out, + AffineTransform at) + { + if (at == null) { + return out; + } + double mxx = at.getScaleX(); + double mxy = at.getShearX(); + double myx = at.getShearY(); + double myy = at.getScaleY(); + + if (mxy == 0.0d && myx == 0.0d) { + if (mxx == 1.0d && myy == 1.0d) { + return out; + } else { + return iv_DeltaScaleFilter.init(out, 1.0d/mxx, 1.0d/myy); + } + } else { + double det = mxx * myy - mxy * myx; + return iv_DeltaTransformFilter.init(out, + myy / det, + -mxy / det, + -myx / det, + mxx / det); + } + } + + + static final class DeltaScaleFilter implements DPathConsumer2D { + private DPathConsumer2D out; + private double sx, sy; + + DeltaScaleFilter() {} + + DeltaScaleFilter init(DPathConsumer2D out, + double mxx, double myy) + { + this.out = out; + sx = mxx; + sy = myy; + return this; // fluent API + } + + @Override + public void moveTo(double x0, double y0) { + out.moveTo(x0 * sx, y0 * sy); + } + + @Override + public void lineTo(double x1, double y1) { + out.lineTo(x1 * sx, y1 * sy); + } + + @Override + public void quadTo(double x1, double y1, + double x2, double y2) + { + out.quadTo(x1 * sx, y1 * sy, + x2 * sx, y2 * sy); + } + + @Override + public void curveTo(double x1, double y1, + double x2, double y2, + double x3, double y3) + { + out.curveTo(x1 * sx, y1 * sy, + x2 * sx, y2 * sy, + x3 * sx, y3 * sy); + } + + @Override + public void closePath() { + out.closePath(); + } + + @Override + public void pathDone() { + out.pathDone(); + } + + @Override + public long getNativeConsumer() { + return 0; + } + } + + static final class DeltaTransformFilter implements DPathConsumer2D { + private DPathConsumer2D out; + private double mxx, mxy, myx, myy; + + DeltaTransformFilter() {} + + DeltaTransformFilter init(DPathConsumer2D out, + double mxx, double mxy, + double myx, double myy) + { + this.out = out; + this.mxx = mxx; + this.mxy = mxy; + this.myx = myx; + this.myy = myy; + return this; // fluent API + } + + @Override + public void moveTo(double x0, double y0) { + out.moveTo(x0 * mxx + y0 * mxy, + x0 * myx + y0 * myy); + } + + @Override + public void lineTo(double x1, double y1) { + out.lineTo(x1 * mxx + y1 * mxy, + x1 * myx + y1 * myy); + } + + @Override + public void quadTo(double x1, double y1, + double x2, double y2) + { + out.quadTo(x1 * mxx + y1 * mxy, + x1 * myx + y1 * myy, + x2 * mxx + y2 * mxy, + x2 * myx + y2 * myy); + } + + @Override + public void curveTo(double x1, double y1, + double x2, double y2, + double x3, double y3) + { + out.curveTo(x1 * mxx + y1 * mxy, + x1 * myx + y1 * myy, + x2 * mxx + y2 * mxy, + x2 * myx + y2 * myy, + x3 * mxx + y3 * mxy, + x3 * myx + y3 * myy); + } + + @Override + public void closePath() { + out.closePath(); + } + + @Override + public void pathDone() { + out.pathDone(); + } + + @Override + public long getNativeConsumer() { + return 0; + } + } + + static final class Path2DWrapper implements DPathConsumer2D { + private Path2D.Double p2d; + + Path2DWrapper() {} + + Path2DWrapper init(Path2D.Double p2d) { + this.p2d = p2d; + return this; + } + + @Override + public void moveTo(double x0, double y0) { + p2d.moveTo(x0, y0); + } + + @Override + public void lineTo(double x1, double y1) { + p2d.lineTo(x1, y1); + } + + @Override + public void closePath() { + p2d.closePath(); + } + + @Override + public void pathDone() {} + + @Override + public void curveTo(double x1, double y1, + double x2, double y2, + double x3, double y3) + { + p2d.curveTo(x1, y1, x2, y2, x3, y3); + } + + @Override + public void quadTo(double x1, double y1, double x2, double y2) { + p2d.quadTo(x1, y1, x2, y2); + } + + @Override + public long getNativeConsumer() { + throw new InternalError("Not using a native peer"); + } + } +} diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Dasher.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Dasher.java index d272293c62d..d8f9c9a1bdc 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Dasher.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Dasher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -39,11 +39,16 @@ import sun.awt.geom.PathConsumer2D; * semantics are unclear. * */ -final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { +final class Dasher implements PathConsumer2D, MarlinConst { static final int REC_LIMIT = 4; static final float ERR = 0.01f; - static final float MIN_T_INC = 1f / (1 << REC_LIMIT); + static final float MIN_T_INC = 1.0f / (1 << REC_LIMIT); + + // More than 24 bits of mantissa means we can no longer accurately + // measure the number of times cycled through the dash array so we + // punt and override the phase to just be 0 past that point. + static final float MAX_CYCLES = 16000000.0f; private PathConsumer2D out; private float[] dash; @@ -106,26 +111,56 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { Dasher init(final PathConsumer2D out, float[] dash, int dashLen, float phase, boolean recycleDashes) { - if (phase < 0f) { - throw new IllegalArgumentException("phase < 0 !"); - } this.out = out; // Normalize so 0 <= phase < dash[0] - int idx = 0; + int sidx = 0; dashOn = true; - float d; - while (phase >= (d = dash[idx])) { - phase -= d; - idx = (idx + 1) % dashLen; - dashOn = !dashOn; + float sum = 0.0f; + for (float d : dash) { + sum += d; + } + float cycles = phase / sum; + if (phase < 0.0f) { + if (-cycles >= MAX_CYCLES) { + phase = 0.0f; + } else { + int fullcycles = FloatMath.floor_int(-cycles); + if ((fullcycles & dash.length & 1) != 0) { + dashOn = !dashOn; + } + phase += fullcycles * sum; + while (phase < 0.0f) { + if (--sidx < 0) { + sidx = dash.length - 1; + } + phase += dash[sidx]; + dashOn = !dashOn; + } + } + } else if (phase > 0) { + if (cycles >= MAX_CYCLES) { + phase = 0.0f; + } else { + int fullcycles = FloatMath.floor_int(cycles); + if ((fullcycles & dash.length & 1) != 0) { + dashOn = !dashOn; + } + phase -= fullcycles * sum; + float d; + while (phase >= (d = dash[sidx])) { + phase -= d; + sidx = (sidx + 1) % dash.length; + dashOn = !dashOn; + } + } } this.dash = dash; this.dashLen = dashLen; this.startPhase = this.phase = phase; this.startDashOn = dashOn; - this.startIdx = idx; + this.startIdx = sidx; this.starting = true; needsMoveTo = false; firstSegidx = 0; @@ -142,7 +177,7 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { void dispose() { if (DO_CLEAN_DIRTY) { // Force zero-fill dirty arrays: - Arrays.fill(curCurvepts, 0f); + Arrays.fill(curCurvepts, 0.0f); } // Return arrays: if (recycleDashes) { @@ -151,6 +186,21 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { firstSegmentsBuffer = firstSegmentsBuffer_ref.putArray(firstSegmentsBuffer); } + float[] copyDashArray(final float[] dashes) { + final int len = dashes.length; + final float[] newDashes; + if (len <= MarlinConst.INITIAL_ARRAY) { + newDashes = dashes_ref.initial; + } else { + if (DO_STATS) { + rdrCtx.stats.stat_array_dasher_dasher.add(len); + } + newDashes = dashes_ref.getArray(len); + } + System.arraycopy(dashes, 0, newDashes, 0, len); + return newDashes; + } + @Override public void moveTo(float x0, float y0) { if (firstSegidx > 0) { @@ -202,13 +252,12 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { private int firstSegidx; // precondition: pts must be in relative coordinates (relative to x0,y0) - // fullCurve is true iff the curve in pts has not been split. private void goTo(float[] pts, int off, final int type) { float x = pts[off + type - 4]; float y = pts[off + type - 3]; if (dashOn) { if (starting) { - int len = type - 2 + 1; + int len = type - 1; // - 2 + 1 int segIdx = firstSegidx; float[] buf = firstSegmentsBuffer; if (segIdx + len > buf.length) { @@ -247,7 +296,7 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { float dy = y1 - y0; float len = dx*dx + dy*dy; - if (len == 0f) { + if (len == 0.0f) { return; } len = (float) Math.sqrt(len); @@ -275,7 +324,7 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { phase += len; // TODO: compare float values using epsilon: if (len == leftInThisDashSegment) { - phase = 0f; + phase = 0.0f; idx = (idx + 1) % dashLen; dashOn = !dashOn; } @@ -285,7 +334,7 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { dashdx = _dash[idx] * cx; dashdy = _dash[idx] * cy; - if (phase == 0f) { + if (phase == 0.0f) { _curCurvepts[0] = x0 + dashdx; _curCurvepts[1] = y0 + dashdy; } else { @@ -300,7 +349,7 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { // Advance to next dash segment idx = (idx + 1) % dashLen; dashOn = !dashOn; - phase = 0f; + phase = 0.0f; } } @@ -317,13 +366,13 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { // initially the current curve is at curCurvepts[0...type] int curCurveoff = 0; - float lastSplitT = 0f; + float lastSplitT = 0.0f; float t; float leftInThisDashSegment = dash[idx] - phase; - while ((t = li.next(leftInThisDashSegment)) < 1f) { - if (t != 0f) { - Helpers.subdivideAt((t - lastSplitT) / (1f - lastSplitT), + while ((t = li.next(leftInThisDashSegment)) < 1.0f) { + if (t != 0.0f) { + Helpers.subdivideAt((t - lastSplitT) / (1.0f - lastSplitT), curCurvepts, curCurveoff, curCurvepts, 0, curCurvepts, type, type); @@ -334,13 +383,13 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { // Advance to next dash segment idx = (idx + 1) % dashLen; dashOn = !dashOn; - phase = 0f; + phase = 0.0f; leftInThisDashSegment = dash[idx]; } goTo(curCurvepts, curCurveoff+2, type); phase += li.lastSegLen(); if (phase >= dash[idx]) { - phase = 0f; + phase = 0.0f; idx = (idx + 1) % dashLen; dashOn = !dashOn; } @@ -395,7 +444,7 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { // the lengths of the lines of the control polygon. Only its first // curveType/2 - 1 elements are valid. This is an optimization. See - // next(float) for more detail. + // next() for more detail. private final float[] curLeafCtrlPolyLengths = new float[3]; LengthIterator() { @@ -420,13 +469,13 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { if (DO_CLEAN_DIRTY) { final int recLimit = recCurveStack.length - 1; for (int i = recLimit; i >= 0; i--) { - Arrays.fill(recCurveStack[i], 0f); + Arrays.fill(recCurveStack[i], 0.0f); } Arrays.fill(sides, Side.LEFT); - Arrays.fill(curLeafCtrlPolyLengths, 0f); - Arrays.fill(nextRoots, 0f); - Arrays.fill(flatLeafCoefCache, 0f); - flatLeafCoefCache[2] = -1f; + Arrays.fill(curLeafCtrlPolyLengths, 0.0f); + Arrays.fill(nextRoots, 0.0f); + Arrays.fill(flatLeafCoefCache, 0.0f); + flatLeafCoefCache[2] = -1.0f; } } @@ -435,12 +484,12 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { System.arraycopy(pts, 0, recCurveStack[0], 0, 8); this.curveType = type; this.recLevel = 0; - this.lastT = 0f; - this.lenAtLastT = 0f; - this.nextT = 0f; - this.lenAtNextT = 0f; + this.lastT = 0.0f; + this.lenAtLastT = 0.0f; + this.nextT = 0.0f; + this.lenAtNextT = 0.0f; goLeft(); // initializes nextT and lenAtNextT properly - this.lenAtLastSplit = 0f; + this.lenAtLastSplit = 0.0f; if (recLevel > 0) { this.sides[0] = Side.LEFT; this.done = false; @@ -449,7 +498,7 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { this.sides[0] = Side.RIGHT; this.done = true; } - this.lastSegLen = 0f; + this.lastSegLen = 0.0f; } // 0 == false, 1 == true, -1 == invalid cached value. @@ -462,7 +511,7 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { // the test below is equivalent to !within(len1/len2, 1, err). // It is using a multiplication instead of a division, so it // should be a bit faster. - if (!Helpers.within(len1, len2, err*len2)) { + if (!Helpers.within(len1, len2, err * len2)) { cachedHaveLowAcceleration = 0; return false; } @@ -493,7 +542,7 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { // form (see inside next() for what that means). The cache is // invalid when it's third element is negative, since in any // valid flattened curve, this would be >= 0. - private final float[] flatLeafCoefCache = new float[]{0f, 0f, -1f, 0f}; + private final float[] flatLeafCoefCache = new float[]{0.0f, 0.0f, -1.0f, 0.0f}; // returns the t value where the remaining curve should be split in // order for the left subdivided curve to have length len. If len @@ -503,7 +552,7 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { while (lenAtNextT < targetLength) { if (done) { lastSegLen = lenAtNextT - lenAtLastSplit; - return 1f; + return 1.0f; } goToNextLeaf(); } @@ -520,19 +569,19 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { // gives us the desired length. final float[] _flatLeafCoefCache = flatLeafCoefCache; - if (_flatLeafCoefCache[2] < 0) { - float x = 0f + curLeafCtrlPolyLengths[0], - y = x + curLeafCtrlPolyLengths[1]; + if (_flatLeafCoefCache[2] < 0.0f) { + float x = curLeafCtrlPolyLengths[0], + y = x + curLeafCtrlPolyLengths[1]; if (curveType == 8) { float z = y + curLeafCtrlPolyLengths[2]; - _flatLeafCoefCache[0] = 3f * (x - y) + z; - _flatLeafCoefCache[1] = 3f * (y - 2f * x); - _flatLeafCoefCache[2] = 3f * x; + _flatLeafCoefCache[0] = 3.0f * (x - y) + z; + _flatLeafCoefCache[1] = 3.0f * (y - 2.0f * x); + _flatLeafCoefCache[2] = 3.0f * x; _flatLeafCoefCache[3] = -z; } else if (curveType == 6) { - _flatLeafCoefCache[0] = 0f; - _flatLeafCoefCache[1] = y - 2f * x; - _flatLeafCoefCache[2] = 2f * x; + _flatLeafCoefCache[0] = 0.0f; + _flatLeafCoefCache[1] = y - 2.0f * x; + _flatLeafCoefCache[2] = 2.0f * x; _flatLeafCoefCache[3] = -y; } } @@ -544,7 +593,7 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { // we use cubicRootsInAB here, because we want only roots in 0, 1, // and our quadratic root finder doesn't filter, so it's just a // matter of convenience. - int n = Helpers.cubicRootsInAB(a, b, c, d, nextRoots, 0, 0, 1); + int n = Helpers.cubicRootsInAB(a, b, c, d, nextRoots, 0, 0.0f, 1.0f); if (n == 1 && !Float.isNaN(nextRoots[0])) { t = nextRoots[0]; } @@ -552,8 +601,8 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { // t is relative to the current leaf, so we must make it a valid parameter // of the original curve. t = t * (nextT - lastT) + lastT; - if (t >= 1f) { - t = 1f; + if (t >= 1.0f) { + t = 1.0f; done = true; } // even if done = true, if we're here, that means targetLength @@ -600,13 +649,13 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { // go to the leftmost node from the current node. Return its length. private void goLeft() { float len = onLeaf(); - if (len >= 0f) { + if (len >= 0.0f) { lastT = nextT; lenAtLastT = lenAtNextT; nextT += (1 << (REC_LIMIT - recLevel)) * MIN_T_INC; lenAtNextT += len; // invalidate caches - flatLeafCoefCache[2] = -1f; + flatLeafCoefCache[2] = -1.0f; cachedHaveLowAcceleration = -1; } else { Helpers.subdivide(recCurveStack[recLevel], 0, @@ -622,7 +671,7 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { // the length of the leaf if we are on a leaf. private float onLeaf() { float[] curve = recCurveStack[recLevel]; - float polyLen = 0f; + float polyLen = 0.0f; float x0 = curve[0], y0 = curve[1]; for (int i = 2; i < curveType; i += 2) { @@ -638,9 +687,9 @@ final class Dasher implements sun.awt.geom.PathConsumer2D, MarlinConst { curve[curveType-2], curve[curveType-1]); if ((polyLen - lineLen) < ERR || recLevel == REC_LIMIT) { - return (polyLen + lineLen) / 2f; + return (polyLen + lineLen) / 2.0f; } - return -1f; + return -1.0f; } } diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DoubleArrayCache.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DoubleArrayCache.java new file mode 100644 index 00000000000..abc470e9c5e --- /dev/null +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/DoubleArrayCache.java @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2015, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.java2d.marlin; + +import static sun.java2d.marlin.ArrayCacheConst.ARRAY_SIZES; +import static sun.java2d.marlin.ArrayCacheConst.BUCKETS; +import static sun.java2d.marlin.ArrayCacheConst.MAX_ARRAY_SIZE; +import static sun.java2d.marlin.MarlinUtils.logInfo; +import static sun.java2d.marlin.MarlinUtils.logException; + +import java.lang.ref.WeakReference; +import java.util.Arrays; + +import sun.java2d.marlin.ArrayCacheConst.BucketStats; +import sun.java2d.marlin.ArrayCacheConst.CacheStats; + +/* + * Note that the [BYTE/INT/FLOAT/DOUBLE]ArrayCache files are nearly identical except + * for a few type and name differences. Typically, the [BYTE]ArrayCache.java file + * is edited manually and then [INT/FLOAT/DOUBLE]ArrayCache.java + * files are generated with the following command lines: + */ +// % sed -e 's/(b\yte)[ ]*//g' -e 's/b\yte/int/g' -e 's/B\yte/Int/g' < B\yteArrayCache.java > IntArrayCache.java +// % sed -e 's/(b\yte)[ ]*0/0.0f/g' -e 's/(b\yte)[ ]*/(float) /g' -e 's/b\yte/float/g' -e 's/B\yte/Float/g' < B\yteArrayCache.java > FloatArrayCache.java +// % sed -e 's/(b\yte)[ ]*0/0.0d/g' -e 's/(b\yte)[ ]*/(double) /g' -e 's/b\yte/double/g' -e 's/B\yte/Double/g' < B\yteArrayCache.java > DoubleArrayCache.java + +final class DoubleArrayCache implements MarlinConst { + + final boolean clean; + private final int bucketCapacity; + private WeakReference refBuckets = null; + final CacheStats stats; + + DoubleArrayCache(final boolean clean, final int bucketCapacity) { + this.clean = clean; + this.bucketCapacity = bucketCapacity; + this.stats = (DO_STATS) ? + new CacheStats(getLogPrefix(clean) + "DoubleArrayCache") : null; + } + + Bucket getCacheBucket(final int length) { + final int bucket = ArrayCacheConst.getBucket(length); + return getBuckets()[bucket]; + } + + private Bucket[] getBuckets() { + // resolve reference: + Bucket[] buckets = (refBuckets != null) ? refBuckets.get() : null; + + // create a new buckets ? + if (buckets == null) { + buckets = new Bucket[BUCKETS]; + + for (int i = 0; i < BUCKETS; i++) { + buckets[i] = new Bucket(clean, ARRAY_SIZES[i], bucketCapacity, + (DO_STATS) ? stats.bucketStats[i] : null); + } + + // update weak reference: + refBuckets = new WeakReference(buckets); + } + return buckets; + } + + Reference createRef(final int initialSize) { + return new Reference(this, initialSize); + } + + static final class Reference { + + // initial array reference (direct access) + final double[] initial; + private final boolean clean; + private final DoubleArrayCache cache; + + Reference(final DoubleArrayCache cache, final int initialSize) { + this.cache = cache; + this.clean = cache.clean; + this.initial = createArray(initialSize, clean); + if (DO_STATS) { + cache.stats.totalInitial += initialSize; + } + } + + double[] getArray(final int length) { + if (length <= MAX_ARRAY_SIZE) { + return cache.getCacheBucket(length).getArray(); + } + if (DO_STATS) { + cache.stats.oversize++; + } + if (DO_LOG_OVERSIZE) { + logInfo(getLogPrefix(clean) + "DoubleArrayCache: " + + "getArray[oversize]: length=\t" + length); + } + return createArray(length, clean); + } + + double[] widenArray(final double[] array, final int usedSize, + final int needSize) + { + final int length = array.length; + if (DO_CHECKS && length >= needSize) { + return array; + } + if (DO_STATS) { + cache.stats.resize++; + } + + // maybe change bucket: + // ensure getNewSize() > newSize: + final double[] res = getArray(ArrayCacheConst.getNewSize(usedSize, needSize)); + + // use wrapper to ensure proper copy: + System.arraycopy(array, 0, res, 0, usedSize); // copy only used elements + + // maybe return current array: + putArray(array, 0, usedSize); // ensure array is cleared + + if (DO_LOG_WIDEN_ARRAY) { + logInfo(getLogPrefix(clean) + "DoubleArrayCache: " + + "widenArray[" + res.length + + "]: usedSize=\t" + usedSize + "\tlength=\t" + length + + "\tneeded length=\t" + needSize); + } + return res; + } + + double[] putArray(final double[] array) + { + // dirty array helper: + return putArray(array, 0, array.length); + } + + double[] putArray(final double[] array, final int fromIndex, + final int toIndex) + { + if (array.length <= MAX_ARRAY_SIZE) { + if ((clean || DO_CLEAN_DIRTY) && (toIndex != 0)) { + // clean-up array of dirty part[fromIndex; toIndex[ + fill(array, fromIndex, toIndex, 0.0d); + } + // ensure to never store initial arrays in cache: + if (array != initial) { + cache.getCacheBucket(array.length).putArray(array); + } + } + return initial; + } + } + + static final class Bucket { + + private int tail = 0; + private final int arraySize; + private final boolean clean; + private final double[][] arrays; + private final BucketStats stats; + + Bucket(final boolean clean, final int arraySize, + final int capacity, final BucketStats stats) + { + this.arraySize = arraySize; + this.clean = clean; + this.stats = stats; + this.arrays = new double[capacity][]; + } + + double[] getArray() { + if (DO_STATS) { + stats.getOp++; + } + // use cache: + if (tail != 0) { + final double[] array = arrays[--tail]; + arrays[tail] = null; + return array; + } + if (DO_STATS) { + stats.createOp++; + } + return createArray(arraySize, clean); + } + + void putArray(final double[] array) + { + if (DO_CHECKS && (array.length != arraySize)) { + logInfo(getLogPrefix(clean) + "DoubleArrayCache: " + + "bad length = " + array.length); + return; + } + if (DO_STATS) { + stats.returnOp++; + } + // fill cache: + if (arrays.length > tail) { + arrays[tail++] = array; + + if (DO_STATS) { + stats.updateMaxSize(tail); + } + } else if (DO_CHECKS) { + logInfo(getLogPrefix(clean) + "DoubleArrayCache: " + + "array capacity exceeded !"); + } + } + } + + static double[] createArray(final int length, final boolean clean) { + if (clean) { + return new double[length]; + } + // use JDK9 Unsafe.allocateUninitializedArray(class, length): + return (double[]) OffHeapArray.UNSAFE.allocateUninitializedArray(double.class, length); + } + + static void fill(final double[] array, final int fromIndex, + final int toIndex, final double value) + { + // clear array data: + Arrays.fill(array, fromIndex, toIndex, value); + if (DO_CHECKS) { + check(array, fromIndex, toIndex, value); + } + } + + static void check(final double[] array, final int fromIndex, + final int toIndex, final double value) + { + if (DO_CHECKS) { + // check zero on full array: + for (int i = 0; i < array.length; i++) { + if (array[i] != value) { + logException("Invalid value at: " + i + " = " + array[i] + + " from: " + fromIndex + " to: " + toIndex + "\n" + + Arrays.toString(array), new Throwable()); + + // ensure array is correctly filled: + Arrays.fill(array, value); + + return; + } + } + } + } + + static String getLogPrefix(final boolean clean) { + return (clean) ? "Clean" : "Dirty"; + } +} diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/FloatArrayCache.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/FloatArrayCache.java index 4a5905d7c39..042c1a3eb96 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/FloatArrayCache.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/FloatArrayCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package sun.java2d.marlin; import static sun.java2d.marlin.ArrayCacheConst.ARRAY_SIZES; @@ -37,13 +38,14 @@ import sun.java2d.marlin.ArrayCacheConst.BucketStats; import sun.java2d.marlin.ArrayCacheConst.CacheStats; /* - * Note that the [BYTE/INT/FLOAT]ArrayCache files are nearly identical except + * Note that the [BYTE/INT/FLOAT/DOUBLE]ArrayCache files are nearly identical except * for a few type and name differences. Typically, the [BYTE]ArrayCache.java file - * is edited manually and then [INT]ArrayCache.java and [FLOAT]ArrayCache.java + * is edited manually and then [INT/FLOAT/DOUBLE]ArrayCache.java * files are generated with the following command lines: */ // % sed -e 's/(b\yte)[ ]*//g' -e 's/b\yte/int/g' -e 's/B\yte/Int/g' < B\yteArrayCache.java > IntArrayCache.java -// % sed -e 's/(b\yte)[ ]*/(float) /g' -e 's/b\yte/float/g' -e 's/B\yte/Float/g' < B\yteArrayCache.java > FloatArrayCache.java +// % sed -e 's/(b\yte)[ ]*0/0.0f/g' -e 's/(b\yte)[ ]*/(float) /g' -e 's/b\yte/float/g' -e 's/B\yte/Float/g' < B\yteArrayCache.java > FloatArrayCache.java +// % sed -e 's/(b\yte)[ ]*0/0.0d/g' -e 's/(b\yte)[ ]*/(double) /g' -e 's/b\yte/double/g' -e 's/B\yte/Double/g' < B\yteArrayCache.java > DoubleArrayCache.java final class FloatArrayCache implements MarlinConst { @@ -159,7 +161,7 @@ final class FloatArrayCache implements MarlinConst { if (array.length <= MAX_ARRAY_SIZE) { if ((clean || DO_CLEAN_DIRTY) && (toIndex != 0)) { // clean-up array of dirty part[fromIndex; toIndex[ - fill(array, fromIndex, toIndex, (float) 0); + fill(array, fromIndex, toIndex, 0.0f); } // ensure to never store initial arrays in cache: if (array != initial) { @@ -231,8 +233,8 @@ final class FloatArrayCache implements MarlinConst { if (clean) { return new float[length]; } - // use JDK9 Unsafe.allocateUninitializedArray(class, length): - return (float[]) OffHeapArray.UNSAFE.allocateUninitializedArray(float.class, length); + // use JDK9 Unsafe.allocateUninitializedArray(class, length): + return (float[]) OffHeapArray.UNSAFE.allocateUninitializedArray(float.class, length); } static void fill(final float[] array, final int fromIndex, diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/FloatMath.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/FloatMath.java index d10a1e03ec7..56e4488f8ee 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/FloatMath.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/FloatMath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -22,9 +22,8 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package sun.java2d.marlin; -import jdk.internal.math.FloatConsts; +package sun.java2d.marlin; /** * Faster Math ceil / floor routines derived from StrictMath @@ -34,17 +33,17 @@ public final class FloatMath implements MarlinConst { // overflow / NaN handling enabled: static final boolean CHECK_OVERFLOW = true; static final boolean CHECK_NAN = true; + // Copied from sun.misc.FloatConsts: + public static final int FLOAT_SIGNIFICAND_WIDTH = 24; // sun.misc.FloatConsts.SIGNIFICAND_WIDTH + public static final int FLOAT_EXP_BIAS = 127; // sun.misc.FloatConsts.EXP_BIAS + public static final int FLOAT_EXP_BIT_MASK = 2139095040;// sun.misc.FloatConsts.EXP_BIT_MASK + public static final int FLOAT_SIGNIF_BIT_MASK = 8388607;// sun.misc.FloatConsts.SIGNIF_BIT_MASK private FloatMath() { // utility class } // faster inlined min/max functions in the branch prediction is high - static float max(final float a, final float b) { - // no NaN handling - return (a >= b) ? a : b; - } - static int max(final int a, final int b) { return (a >= b) ? a : b; } @@ -77,9 +76,9 @@ public final class FloatMath implements MarlinConst { // compute only once Float.floatToRawIntBits(a) final int doppel = Float.floatToRawIntBits(a); - final int exponent = ((doppel & FloatConsts.EXP_BIT_MASK) - >> (FloatConsts.SIGNIFICAND_WIDTH - 1)) - - FloatConsts.EXP_BIAS; + final int exponent = ((doppel & FLOAT_EXP_BIT_MASK) + >> (FLOAT_SIGNIFICAND_WIDTH - 1)) + - FLOAT_EXP_BIAS; if (exponent < 0) { /* @@ -87,8 +86,8 @@ public final class FloatMath implements MarlinConst { * floorOrceil(-0.0) => -0.0 * floorOrceil(+0.0) => +0.0 */ - return ((a == 0) ? a : - ( (a < 0f) ? -0f : 1f) ); + return ((a == 0.0f) ? a : + ( (a < 0.0f) ? -0.0f : 1.0f) ); } if (CHECK_OVERFLOW && (exponent >= 23)) { // 52 for double /* @@ -101,7 +100,7 @@ public final class FloatMath implements MarlinConst { assert exponent >= 0 && exponent <= 22; // 51 for double final int intpart = doppel - & (~(FloatConsts.SIGNIF_BIT_MASK >> exponent)); + & (~(FLOAT_SIGNIF_BIT_MASK >> exponent)); if (intpart == doppel) { return a; // integral value (including 0) @@ -134,9 +133,9 @@ public final class FloatMath implements MarlinConst { // compute only once Float.floatToRawIntBits(a) final int doppel = Float.floatToRawIntBits(a); - final int exponent = ((doppel & FloatConsts.EXP_BIT_MASK) - >> (FloatConsts.SIGNIFICAND_WIDTH - 1)) - - FloatConsts.EXP_BIAS; + final int exponent = ((doppel & FLOAT_EXP_BIT_MASK) + >> (FLOAT_SIGNIFICAND_WIDTH - 1)) + - FLOAT_EXP_BIAS; if (exponent < 0) { /* @@ -144,8 +143,8 @@ public final class FloatMath implements MarlinConst { * floorOrceil(-0.0) => -0.0 * floorOrceil(+0.0) => +0.0 */ - return ((a == 0) ? a : - ( (a < 0f) ? -1f : 0f) ); + return ((a == 0.0f) ? a : + ( (a < 0.0f) ? -1.0f : 0.0f) ); } if (CHECK_OVERFLOW && (exponent >= 23)) { // 52 for double /* @@ -158,7 +157,7 @@ public final class FloatMath implements MarlinConst { assert exponent >= 0 && exponent <= 22; // 51 for double final int intpart = doppel - & (~(FloatConsts.SIGNIF_BIT_MASK >> exponent)); + & (~(FLOAT_SIGNIF_BIT_MASK >> exponent)); if (intpart == doppel) { return a; // integral value (including 0) @@ -190,6 +189,26 @@ public final class FloatMath implements MarlinConst { return intpart + 1; } + /** + * Faster alternative to ceil(double) optimized for the integer domain + * and supporting NaN and +/-Infinity. + * + * @param a a value. + * @return the largest (closest to positive infinity) integer value + * that less than or equal to the argument and is equal to a mathematical + * integer. + */ + public static int ceil_int(final double a) { + final int intpart = (int) a; + + if (a <= intpart + || (CHECK_OVERFLOW && intpart == Integer.MAX_VALUE) + || CHECK_NAN && Double.isNaN(a)) { + return intpart; + } + return intpart + 1; + } + /** * Faster alternative to floor(float) optimized for the integer domain * and supporting NaN and +/-Infinity. @@ -209,4 +228,24 @@ public final class FloatMath implements MarlinConst { } return intpart - 1; } + + /** + * Faster alternative to floor(double) optimized for the integer domain + * and supporting NaN and +/-Infinity. + * + * @param a a value. + * @return the largest (closest to positive infinity) floating-point value + * that less than or equal to the argument and is equal to a mathematical + * integer. + */ + public static int floor_int(final double a) { + final int intpart = (int) a; + + if (a >= intpart + || (CHECK_OVERFLOW && intpart == Integer.MIN_VALUE) + || CHECK_NAN && Double.isNaN(a)) { + return intpart; + } + return intpart - 1; + } } diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Helpers.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Helpers.java index 0b0277dc24f..85b9f363e52 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Helpers.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Helpers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -52,27 +52,27 @@ final class Helpers implements MarlinConst { { int ret = off; float t; - if (a != 0f) { + if (a != 0.0f) { final float dis = b*b - 4*a*c; - if (dis > 0f) { - final float sqrtDis = (float)Math.sqrt(dis); + if (dis > 0.0f) { + final float sqrtDis = (float) Math.sqrt(dis); // depending on the sign of b we use a slightly different // algorithm than the traditional one to find one of the roots // so we can avoid adding numbers of different signs (which // might result in loss of precision). - if (b >= 0f) { - zeroes[ret++] = (2f * c) / (-b - sqrtDis); - zeroes[ret++] = (-b - sqrtDis) / (2f * a); + if (b >= 0.0f) { + zeroes[ret++] = (2.0f * c) / (-b - sqrtDis); + zeroes[ret++] = (-b - sqrtDis) / (2.0f * a); } else { - zeroes[ret++] = (-b + sqrtDis) / (2f * a); - zeroes[ret++] = (2f * c) / (-b + sqrtDis); + zeroes[ret++] = (-b + sqrtDis) / (2.0f * a); + zeroes[ret++] = (2.0f * c) / (-b + sqrtDis); } - } else if (dis == 0f) { - t = (-b) / (2f * a); + } else if (dis == 0.0f) { + t = (-b) / (2.0f * a); zeroes[ret++] = t; } } else { - if (b != 0f) { + if (b != 0.0f) { t = (-c) / b; zeroes[ret++] = t; } @@ -85,7 +85,7 @@ final class Helpers implements MarlinConst { float[] pts, final int off, final float A, final float B) { - if (d == 0f) { + if (d == 0.0f) { int num = quadraticRoots(a, b, c, pts, off); return filterOutNotInAB(pts, off, num, A, B) - off; } @@ -109,8 +109,8 @@ final class Helpers implements MarlinConst { // q = Q/2 // instead and use those values for simplicity of the code. double sq_A = a * a; - double p = (1.0/3.0) * ((-1.0/3.0) * sq_A + b); - double q = (1.0/2.0) * ((2.0/27.0) * a * sq_A - (1.0/3.0) * a * b + c); + double p = (1.0d/3.0d) * ((-1.0d/3.0d) * sq_A + b); + double q = (1.0d/2.0d) * ((2.0d/27.0d) * a * sq_A - (1.0d/3.0d) * a * b + c); // use Cardano's formula @@ -118,30 +118,30 @@ final class Helpers implements MarlinConst { double D = q * q + cb_p; int num; - if (D < 0.0) { + if (D < 0.0d) { // see: http://en.wikipedia.org/wiki/Cubic_function#Trigonometric_.28and_hyperbolic.29_method - final double phi = (1.0/3.0) * acos(-q / sqrt(-cb_p)); - final double t = 2.0 * sqrt(-p); + final double phi = (1.0d/3.0d) * acos(-q / sqrt(-cb_p)); + final double t = 2.0d * sqrt(-p); - pts[ off+0 ] = (float)( t * cos(phi)); - pts[ off+1 ] = (float)(-t * cos(phi + (PI / 3.0))); - pts[ off+2 ] = (float)(-t * cos(phi - (PI / 3.0))); + pts[ off+0 ] = (float) ( t * cos(phi)); + pts[ off+1 ] = (float) (-t * cos(phi + (PI / 3.0d))); + pts[ off+2 ] = (float) (-t * cos(phi - (PI / 3.0d))); num = 3; } else { final double sqrt_D = sqrt(D); final double u = cbrt(sqrt_D - q); final double v = - cbrt(sqrt_D + q); - pts[ off ] = (float)(u + v); + pts[ off ] = (float) (u + v); num = 1; - if (within(D, 0.0, 1e-8)) { - pts[off+1] = -(pts[off] / 2f); + if (within(D, 0.0d, 1e-8d)) { + pts[off+1] = -(pts[off] / 2.0f); num = 2; } } - final float sub = (1f/3f) * a; + final float sub = (1.0f/3.0f) * a; for (int i = 0; i < num; ++i) { pts[ off+i ] -= sub; @@ -178,7 +178,7 @@ final class Helpers implements MarlinConst { static float polyLineLength(float[] poly, final int off, final int nCoords) { assert nCoords % 2 == 0 && poly.length >= off + nCoords : ""; - float acc = 0; + float acc = 0.0f; for (int i = off + 2; i < off + nCoords; i += 2) { acc += linelen(poly[i], poly[i+1], poly[i-2], poly[i-1]); } @@ -188,7 +188,7 @@ final class Helpers implements MarlinConst { static float linelen(float x1, float y1, float x2, float y2) { final float dx = x2 - x1; final float dy = y2 - y1; - return (float)Math.sqrt(dx*dx + dy*dy); + return (float) Math.sqrt(dx*dx + dy*dy); } static void subdivide(float[] src, int srcoff, float[] left, int leftoff, @@ -218,8 +218,8 @@ final class Helpers implements MarlinConst { } // Most of these are copied from classes in java.awt.geom because we need - // float versions of these functions, and Line2D, CubicCurve2D, - // QuadCurve2D don't provide them. + // both single and double precision variants of these functions, and Line2D, + // CubicCurve2D, QuadCurve2D don't provide them. /** * Subdivides the cubic curve specified by the coordinates * stored in the src array at indices srcoff @@ -268,18 +268,18 @@ final class Helpers implements MarlinConst { right[rightoff + 6] = x2; right[rightoff + 7] = y2; } - x1 = (x1 + ctrlx1) / 2f; - y1 = (y1 + ctrly1) / 2f; - x2 = (x2 + ctrlx2) / 2f; - y2 = (y2 + ctrly2) / 2f; - float centerx = (ctrlx1 + ctrlx2) / 2f; - float centery = (ctrly1 + ctrly2) / 2f; - ctrlx1 = (x1 + centerx) / 2f; - ctrly1 = (y1 + centery) / 2f; - ctrlx2 = (x2 + centerx) / 2f; - ctrly2 = (y2 + centery) / 2f; - centerx = (ctrlx1 + ctrlx2) / 2f; - centery = (ctrly1 + ctrly2) / 2f; + x1 = (x1 + ctrlx1) / 2.0f; + y1 = (y1 + ctrly1) / 2.0f; + x2 = (x2 + ctrlx2) / 2.0f; + y2 = (y2 + ctrly2) / 2.0f; + float centerx = (ctrlx1 + ctrlx2) / 2.0f; + float centery = (ctrly1 + ctrly2) / 2.0f; + ctrlx1 = (x1 + centerx) / 2.0f; + ctrly1 = (y1 + centery) / 2.0f; + ctrlx2 = (x2 + centerx) / 2.0f; + ctrly2 = (y2 + centery) / 2.0f; + centerx = (ctrlx1 + ctrlx2) / 2.0f; + centery = (ctrly1 + ctrly2) / 2.0f; if (left != null) { left[leftoff + 2] = x1; left[leftoff + 3] = y1; @@ -367,12 +367,12 @@ final class Helpers implements MarlinConst { right[rightoff + 4] = x2; right[rightoff + 5] = y2; } - x1 = (x1 + ctrlx) / 2f; - y1 = (y1 + ctrly) / 2f; - x2 = (x2 + ctrlx) / 2f; - y2 = (y2 + ctrly) / 2f; - ctrlx = (x1 + x2) / 2f; - ctrly = (y1 + y2) / 2f; + x1 = (x1 + ctrlx) / 2.0f; + y1 = (y1 + ctrly) / 2.0f; + x2 = (x2 + ctrlx) / 2.0f; + y2 = (y2 + ctrly) / 2.0f; + ctrlx = (x1 + x2) / 2.0f; + ctrly = (y1 + y2) / 2.0f; if (left != null) { left[leftoff + 2] = x1; left[leftoff + 3] = y1; diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/IRendererContext.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/IRendererContext.java new file mode 100644 index 00000000000..ceecc9a9709 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/IRendererContext.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.java2d.marlin; + +interface IRendererContext extends MarlinConst { + + public RendererStats stats(); + + public OffHeapArray newOffHeapArray(final long initialSize); + + public IntArrayCache.Reference newCleanIntArrayRef(final int initialSize); + +} diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/IntArrayCache.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/IntArrayCache.java index b6699acf196..248834d8804 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/IntArrayCache.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/IntArrayCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package sun.java2d.marlin; import static sun.java2d.marlin.ArrayCacheConst.ARRAY_SIZES; @@ -37,13 +38,14 @@ import sun.java2d.marlin.ArrayCacheConst.BucketStats; import sun.java2d.marlin.ArrayCacheConst.CacheStats; /* - * Note that the [BYTE/INT/FLOAT]ArrayCache files are nearly identical except + * Note that the [BYTE/INT/FLOAT/DOUBLE]ArrayCache files are nearly identical except * for a few type and name differences. Typically, the [BYTE]ArrayCache.java file - * is edited manually and then [INT]ArrayCache.java and [FLOAT]ArrayCache.java + * is edited manually and then [INT/FLOAT/DOUBLE]ArrayCache.java * files are generated with the following command lines: */ // % sed -e 's/(b\yte)[ ]*//g' -e 's/b\yte/int/g' -e 's/B\yte/Int/g' < B\yteArrayCache.java > IntArrayCache.java -// % sed -e 's/(b\yte)[ ]*/(float) /g' -e 's/b\yte/float/g' -e 's/B\yte/Float/g' < B\yteArrayCache.java > FloatArrayCache.java +// % sed -e 's/(b\yte)[ ]*0/0.0f/g' -e 's/(b\yte)[ ]*/(float) /g' -e 's/b\yte/float/g' -e 's/B\yte/Float/g' < B\yteArrayCache.java > FloatArrayCache.java +// % sed -e 's/(b\yte)[ ]*0/0.0d/g' -e 's/(b\yte)[ ]*/(double) /g' -e 's/b\yte/double/g' -e 's/B\yte/Double/g' < B\yteArrayCache.java > DoubleArrayCache.java final class IntArrayCache implements MarlinConst { @@ -231,8 +233,8 @@ final class IntArrayCache implements MarlinConst { if (clean) { return new int[length]; } - // use JDK9 Unsafe.allocateUninitializedArray(class, length): - return (int[]) OffHeapArray.UNSAFE.allocateUninitializedArray(int.class, length); + // use JDK9 Unsafe.allocateUninitializedArray(class, length): + return (int[]) OffHeapArray.UNSAFE.allocateUninitializedArray(int.class, length); } static void fill(final int[] array, final int fromIndex, diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinCache.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinCache.java index a66f6808aa8..2aad9c79a87 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinCache.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinCache.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -45,7 +45,7 @@ public final class MarlinCache implements MarlinConst { // 2048 (pixelSize) alpha values (width) x 32 rows (tile) = 64K bytes // x1 instead of 4 bytes (RLE) ie 1/4 capacity or average good RLE compression - static final long INITIAL_CHUNK_ARRAY = TILE_SIZE * INITIAL_PIXEL_DIM; // 64K + static final long INITIAL_CHUNK_ARRAY = TILE_H * INITIAL_PIXEL_DIM; // 64K // The alpha map used by this object (taken out of our map cache) to convert // pixel coverage counts gotten from MarlinCache (which are in the range @@ -72,17 +72,17 @@ public final class MarlinCache implements MarlinConst { // 1D dirty arrays // row index in rowAAChunk[] - final long[] rowAAChunkIndex = new long[TILE_SIZE]; + final long[] rowAAChunkIndex = new long[TILE_H]; // first pixel (inclusive) for each row - final int[] rowAAx0 = new int[TILE_SIZE]; + final int[] rowAAx0 = new int[TILE_H]; // last pixel (exclusive) for each row - final int[] rowAAx1 = new int[TILE_SIZE]; + final int[] rowAAx1 = new int[TILE_H]; // encoding mode (0=raw, 1=RLE encoding) for each row - final int[] rowAAEnc = new int[TILE_SIZE]; + final int[] rowAAEnc = new int[TILE_H]; // coded length (RLE encoding) for each row - final long[] rowAALen = new long[TILE_SIZE]; + final long[] rowAALen = new long[TILE_H]; // last position in RLE decoding for each row (getAlpha): - final long[] rowAAPos = new long[TILE_SIZE]; + final long[] rowAAPos = new long[TILE_H]; // dirty off-heap array containing pixel coverages for (32) rows (packed) // if encoding=raw, it contains alpha coverage values (val) as integer @@ -97,8 +97,8 @@ public final class MarlinCache implements MarlinConst { // x=j*TILE_SIZE+bboxX0. int[] touchedTile; - // per-thread renderer context - final RendererContext rdrCtx; + // per-thread renderer stats + final RendererStats rdrStats; // touchedTile ref (clean) private final IntArrayCache.Reference touchedTile_ref; @@ -107,8 +107,8 @@ public final class MarlinCache implements MarlinConst { boolean useRLE = false; - MarlinCache(final RendererContext rdrCtx) { - this.rdrCtx = rdrCtx; + MarlinCache(final IRendererContext rdrCtx) { + this.rdrStats = rdrCtx.stats(); rowAAChunk = rdrCtx.newOffHeapArray(INITIAL_CHUNK_ARRAY); // 64K @@ -120,7 +120,7 @@ public final class MarlinCache implements MarlinConst { tileMax = Integer.MIN_VALUE; } - void init(int minx, int miny, int maxx, int maxy, int edgeSumDeltaY) + void init(int minx, int miny, int maxx, int maxy) { // assert maxy >= miny && maxx >= minx; bboxX0 = minx; @@ -142,47 +142,16 @@ public final class MarlinCache implements MarlinConst { if (width <= RLE_MIN_WIDTH || width >= RLE_MAX_WIDTH) { useRLE = false; } else { - // perimeter approach: how fit the total length into given height: - - // if stroking: meanCrossings /= 2 => divide edgeSumDeltaY by 2 - final int heightSubPixel - = (((maxy - miny) << SUBPIXEL_LG_POSITIONS_Y) << rdrCtx.stroking); - - // check meanDist > block size: - // check width / (meanCrossings - 1) >= RLE_THRESHOLD - - // fast case: (meanCrossingPerPixel <= 2) means 1 span only - useRLE = (edgeSumDeltaY <= (heightSubPixel << 1)) - // note: already checked (meanCrossingPerPixel <= 2) - // rewritten to avoid division: - || (width * heightSubPixel) > - ((edgeSumDeltaY - heightSubPixel) << BLOCK_SIZE_LG); - - if (DO_TRACE && !useRLE) { - final float meanCrossings - = ((float) edgeSumDeltaY) / heightSubPixel; - final float meanDist = width / (meanCrossings - 1); - - System.out.println("High complexity: " - + " for bbox[width = " + width - + " height = " + (maxy - miny) - + "] edgeSumDeltaY = " + edgeSumDeltaY - + " heightSubPixel = " + heightSubPixel - + " meanCrossings = "+ meanCrossings - + " meanDist = " + meanDist - + " width = " + (width * heightSubPixel) - + " <= criteria: " + ((edgeSumDeltaY - heightSubPixel) << BLOCK_SIZE_LG) - ); - } + useRLE = true; } } // the ceiling of (maxy - miny + 1) / TILE_SIZE; - final int nxTiles = (width + TILE_SIZE) >> TILE_SIZE_LG; + final int nxTiles = (width + TILE_W) >> TILE_W_LG; if (nxTiles > INITIAL_ARRAY) { if (DO_STATS) { - rdrCtx.stats.stat_array_marlincache_touchedTile.add(nxTiles); + rdrStats.stat_array_marlincache_touchedTile.add(nxTiles); } touchedTile = touchedTile_ref.getArray(nxTiles); } @@ -197,7 +166,7 @@ public final class MarlinCache implements MarlinConst { resetTileLine(0); if (DO_STATS) { - rdrCtx.stats.totalOffHeap += rowAAChunk.length; + rdrStats.totalOffHeap += rowAAChunk.length; } // Return arrays: @@ -220,14 +189,14 @@ public final class MarlinCache implements MarlinConst { // reset current pos if (DO_STATS) { - rdrCtx.stats.stat_cache_rowAAChunk.add(rowAAChunkPos); + rdrStats.stat_cache_rowAAChunk.add(rowAAChunkPos); } rowAAChunkPos = 0L; // Reset touchedTile: if (tileMin != Integer.MAX_VALUE) { if (DO_STATS) { - rdrCtx.stats.stat_cache_tiles.add(tileMax - tileMin); + rdrStats.stat_cache_tiles.add(tileMax - tileMin); } // clean only dirty touchedTile: if (tileMax == 1) { @@ -269,10 +238,6 @@ public final class MarlinCache implements MarlinConst { void copyAARowNoRLE(final int[] alphaRow, final int y, final int px0, final int px1) { - if (DO_MONITORS) { - rdrCtx.stats.mon_rdr_copyAARow.start(); - } - // skip useless pixels above boundary final int px_bbox1 = FloatMath.min(px1, bboxX1); @@ -308,12 +273,12 @@ public final class MarlinCache implements MarlinConst { expandRowAAChunk(needSize); } if (DO_STATS) { - rdrCtx.stats.stat_cache_rowAA.add(px_bbox1 - px0); + rdrStats.stat_cache_rowAA.add(px_bbox1 - px0); } // rowAA contains only alpha values for range[x0; x1[ final int[] _touchedTile = touchedTile; - final int _TILE_SIZE_LG = TILE_SIZE_LG; + final int _TILE_SIZE_LG = TILE_W_LG; final int from = px0 - bboxX0; // first pixel inclusive final int to = px_bbox1 - bboxX0; // last pixel exclusive @@ -342,9 +307,9 @@ public final class MarlinCache implements MarlinConst { // store alpha sum (as byte): if (val == 0) { - _unsafe.putByte(addr_off, (byte)0); // [0..255] + _unsafe.putByte(addr_off, (byte)0); // [0-255] } else { - _unsafe.putByte(addr_off, _unsafe.getByte(addr_alpha + val)); // [0..255] + _unsafe.putByte(addr_off, _unsafe.getByte(addr_alpha + val)); // [0-255] // update touchedTile _touchedTile[x >> _TILE_SIZE_LG] += val; @@ -368,25 +333,17 @@ public final class MarlinCache implements MarlinConst { } // Clear alpha row for reuse: - IntArrayCache.fill(alphaRow, from, px1 - bboxX0, 0); - - if (DO_MONITORS) { - rdrCtx.stats.mon_rdr_copyAARow.stop(); - } + IntArrayCache.fill(alphaRow, from, px1 + 1 - bboxX0, 0); } void copyAARowRLE_WithBlockFlags(final int[] blkFlags, final int[] alphaRow, final int y, final int px0, final int px1) { - if (DO_MONITORS) { - rdrCtx.stats.mon_rdr_copyAARow.start(); - } - // Copy rowAA data into the piscesCache if one is present final int _bboxX0 = bboxX0; // process tile line [0 - 32] - final int row = y - bboxY0; + final int row = y - bboxY0; final int from = px0 - _bboxX0; // first pixel inclusive // skip useless pixels above boundary @@ -418,12 +375,14 @@ public final class MarlinCache implements MarlinConst { long addr_off = _rowAAChunk.address + initialPos; final int[] _touchedTile = touchedTile; - final int _TILE_SIZE_LG = TILE_SIZE_LG; + final int _TILE_SIZE_LG = TILE_W_LG; final int _BLK_SIZE_LG = BLOCK_SIZE_LG; // traverse flagged blocks: final int blkW = (from >> _BLK_SIZE_LG); final int blkE = (to >> _BLK_SIZE_LG) + 1; + // ensure last block flag = 0 to process final block: + blkFlags[blkE] = 0; // Perform run-length encoding and store results in the piscesCache int val = 0; @@ -481,7 +440,7 @@ public final class MarlinCache implements MarlinConst { } else { _unsafe.putInt(addr_off, ((_bboxX0 + cx) << 8) - | (((int) _unsafe.getByte(addr_alpha + val)) & 0xFF) // [0..255] + | (((int) _unsafe.getByte(addr_alpha + val)) & 0xFF) // [0-255] ); if (runLen == 1) { @@ -493,7 +452,7 @@ public final class MarlinCache implements MarlinConst { addr_off += SIZE_INT; if (DO_STATS) { - rdrCtx.stats.hist_tile_generator_encoding_runLen + rdrStats.hist_tile_generator_encoding_runLen .add(runLen); } cx0 = cx; @@ -544,7 +503,7 @@ public final class MarlinCache implements MarlinConst { } else { _unsafe.putInt(addr_off, ((_bboxX0 + to) << 8) - | (((int) _unsafe.getByte(addr_alpha + val)) & 0xFF) // [0..255] + | (((int) _unsafe.getByte(addr_alpha + val)) & 0xFF) // [0-255] ); if (runLen == 1) { @@ -556,7 +515,7 @@ public final class MarlinCache implements MarlinConst { addr_off += SIZE_INT; if (DO_STATS) { - rdrCtx.stats.hist_tile_generator_encoding_runLen.add(runLen); + rdrStats.hist_tile_generator_encoding_runLen.add(runLen); } long len = (addr_off - _rowAAChunk.address); @@ -568,8 +527,8 @@ public final class MarlinCache implements MarlinConst { rowAAChunkPos = len; if (DO_STATS) { - rdrCtx.stats.stat_cache_rowAA.add(rowAALen[row]); - rdrCtx.stats.hist_tile_generator_encoding_ratio.add( + rdrStats.stat_cache_rowAA.add(rowAALen[row]); + rdrStats.hist_tile_generator_encoding_ratio.add( (100 * skip) / (blkE - blkW) ); } @@ -586,17 +545,10 @@ public final class MarlinCache implements MarlinConst { } // Clear alpha row for reuse: - if (px1 > bboxX1) { - alphaRow[to ] = 0; - alphaRow[to + 1] = 0; - } + alphaRow[to] = 0; if (DO_CHECKS) { IntArrayCache.check(blkFlags, blkW, blkE, 0); - IntArrayCache.check(alphaRow, from, px1 - bboxX0, 0); - } - - if (DO_MONITORS) { - rdrCtx.stats.mon_rdr_copyAARow.stop(); + IntArrayCache.check(alphaRow, from, px1 + 1 - bboxX0, 0); } } @@ -613,7 +565,7 @@ public final class MarlinCache implements MarlinConst { private void expandRowAAChunk(final long needSize) { if (DO_STATS) { - rdrCtx.stats.stat_array_marlincache_rowAAChunk.add(needSize); + rdrStats.stat_array_marlincache_rowAAChunk.add(needSize); } // note: throw IOOB if neededSize > 2Gb: @@ -629,7 +581,7 @@ public final class MarlinCache implements MarlinConst { { // the x and y of the current row, minus bboxX0, bboxY0 // process tile line [0 - 32] - final int _TILE_SIZE_LG = TILE_SIZE_LG; + final int _TILE_SIZE_LG = TILE_W_LG; // update touchedTile int tx = (x0 >> _TILE_SIZE_LG); @@ -666,7 +618,7 @@ public final class MarlinCache implements MarlinConst { } int alphaSumInTile(final int x) { - return touchedTile[(x - bboxX0) >> TILE_SIZE_LG]; + return touchedTile[(x - bboxX0) >> TILE_W_LG]; } @Override diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinConst.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinConst.java index 334989106bb..b46d0fc1540 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinConst.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinConst.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -95,10 +95,10 @@ interface MarlinConst { // 4096 edges for initial capacity static final int INITIAL_EDGES_COUNT = MarlinProperties.getInitialEdges(); - // initial edges = 3/4 * edges count (4096) + // initial edges = edges count (4096) // 6 ints per edges = 24 bytes - // edges capacity = 24 x initial edges = 18 * edges count (4096) = 72K - static final int INITIAL_EDGES_CAPACITY = INITIAL_EDGES_COUNT * 18; + // edges capacity = 24 x initial edges = 24 * edges count (4096) = 96K + static final int INITIAL_EDGES_CAPACITY = INITIAL_EDGES_COUNT * 24; // zero value as byte static final byte BYTE_0 = (byte) 0; @@ -114,14 +114,17 @@ interface MarlinConst { public static final int SUBPIXEL_POSITIONS_Y = 1 << (SUBPIXEL_LG_POSITIONS_Y); public static final float NORM_SUBPIXELS - = (float)Math.sqrt(( SUBPIXEL_POSITIONS_X * SUBPIXEL_POSITIONS_X - + SUBPIXEL_POSITIONS_Y * SUBPIXEL_POSITIONS_Y)/2.0); + = (float) Math.sqrt(( SUBPIXEL_POSITIONS_X * SUBPIXEL_POSITIONS_X + + SUBPIXEL_POSITIONS_Y * SUBPIXEL_POSITIONS_Y) / 2.0d); public static final int MAX_AA_ALPHA = SUBPIXEL_POSITIONS_X * SUBPIXEL_POSITIONS_Y; - public static final int TILE_SIZE_LG = MarlinProperties.getTileSize_Log2(); - public static final int TILE_SIZE = 1 << TILE_SIZE_LG; // 32 by default + public static final int TILE_H_LG = MarlinProperties.getTileSize_Log2(); + public static final int TILE_H = 1 << TILE_H_LG; // 32 by default + + public static final int TILE_W_LG = MarlinProperties.getTileWidth_Log2(); + public static final int TILE_W = 1 << TILE_W_LG; // 32 by default public static final int BLOCK_SIZE_LG = MarlinProperties.getBlockSize_Log2(); public static final int BLOCK_SIZE = 1 << BLOCK_SIZE_LG; diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinProperties.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinProperties.java index 2cf5d65bcd0..78ad352fb46 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinProperties.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinProperties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -68,21 +68,21 @@ public final class MarlinProperties { /** * Return the log(2) corresponding to subpixel on x-axis ( * - * @return 1 (2 subpixels) < initial pixel size < 4 (256 subpixels) + * @return 0 (1 subpixels) < initial pixel size < 8 (256 subpixels) * (3 by default ie 8 subpixels) */ public static int getSubPixel_Log2_X() { - return getInteger("sun.java2d.renderer.subPixel_log2_X", 3, 1, 8); + return getInteger("sun.java2d.renderer.subPixel_log2_X", 3, 0, 8); } /** * Return the log(2) corresponding to subpixel on y-axis ( * - * @return 1 (2 subpixels) < initial pixel size < 8 (256 subpixels) + * @return 0 (1 subpixels) < initial pixel size < 8 (256 subpixels) * (3 by default ie 8 subpixels) */ public static int getSubPixel_Log2_Y() { - return getInteger("sun.java2d.renderer.subPixel_log2_Y", 3, 1, 8); + return getInteger("sun.java2d.renderer.subPixel_log2_Y", 3, 0, 8); } /** @@ -92,7 +92,18 @@ public final class MarlinProperties { * (5 by default ie 32x32 pixels) */ public static int getTileSize_Log2() { - return getInteger("sun.java2d.renderer.tileSize_log2", 5, 3, 8); + return getInteger("sun.java2d.renderer.tileSize_log2", 5, 3, 10); + } + + /** + * Return the log(2) corresponding to the tile width in pixels + * + * @return 3 (8 pixels) < tile with < 8 (256 pixels) + * (by default is given by the square tile size) + */ + public static int getTileWidth_Log2() { + final int tileSize = getTileSize_Log2(); + return getInteger("sun.java2d.renderer.tileWidth_log2", tileSize, 3, 10); } /** @@ -166,6 +177,20 @@ public final class MarlinProperties { return getBoolean("sun.java2d.renderer.logUnsafeMalloc", "false"); } + // quality settings + + public static float getCubicDecD2() { + return getFloat("sun.java2d.renderer.cubic_dec_d2", 1.0f, 0.01f, 4.0f); + } + + public static float getCubicIncD1() { + return getFloat("sun.java2d.renderer.cubic_inc_d1", 0.4f, 0.01f, 2.0f); + } + + public static float getQuadDecD2() { + return getFloat("sun.java2d.renderer.quad_dec_d2", 0.5f, 0.01f, 4.0f); + } + // system property utilities static boolean getBoolean(final String key, final String def) { return Boolean.valueOf(AccessController.doPrivileged( @@ -197,7 +222,36 @@ public final class MarlinProperties { } static int align(final int val, final int norm) { - final int ceil = FloatMath.ceil_int( ((float)val) / norm); + final int ceil = FloatMath.ceil_int( ((float) val) / norm); return ceil * norm; } + + public static double getDouble(final String key, final double def, + final double min, final double max) + { + double value = def; + final String property = AccessController.doPrivileged( + new GetPropertyAction(key)); + + if (property != null) { + try { + value = Double.parseDouble(property); + } catch (NumberFormatException nfe) { + logInfo("Invalid value for " + key + " = " + property + " !"); + } + } + // check for invalid values + if (value < min || value > max) { + logInfo("Invalid value for " + key + " = " + value + + "; expect value in range[" + min + ", " + max + "] !"); + value = def; + } + return value; + } + + public static float getFloat(final String key, final float def, + final float min, final float max) + { + return (float)getDouble(key, def, min, max); + } } diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinRenderer.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinRenderer.java new file mode 100644 index 00000000000..8b4e7518a38 --- /dev/null +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinRenderer.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.java2d.marlin; + +public interface MarlinRenderer extends MarlinConst { + +} diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinRenderingEngine.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinRenderingEngine.java index d578fa89470..5e2bd4c4863 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinRenderingEngine.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinRenderingEngine.java @@ -44,8 +44,8 @@ import sun.security.action.GetPropertyAction; /** * Marlin RendererEngine implementation (derived from Pisces) */ -public class MarlinRenderingEngine extends RenderingEngine - implements MarlinConst +public final class MarlinRenderingEngine extends RenderingEngine + implements MarlinConst { private static enum NormMode { ON_WITH_AA { @@ -80,7 +80,7 @@ public class MarlinRenderingEngine extends RenderingEngine PathIterator src); } - private static final float MIN_PEN_SIZE = 1f / NORM_SUBPIXELS; + private static final float MIN_PEN_SIZE = 1.0f / NORM_SUBPIXELS; static final float UPPER_BND = Float.MAX_VALUE / 2.0f; static final float LOWER_BND = -UPPER_BND; @@ -259,7 +259,7 @@ public class MarlinRenderingEngine extends RenderingEngine */ double EA = A*A + B*B; // x^2 coefficient - double EB = 2.0*(A*C + B*D); // xy coefficient + double EB = 2.0d * (A*C + B*D); // xy coefficient double EC = C*C + D*D; // y^2 coefficient /* @@ -287,7 +287,7 @@ public class MarlinRenderingEngine extends RenderingEngine double hypot = Math.sqrt(EB*EB + (EA-EC)*(EA-EC)); // sqrt omitted, compare to squared limits below. - double widthsquared = ((EA + EC + hypot)/2.0); + double widthsquared = ((EA + EC + hypot) / 2.0d); widthScale = (float)Math.sqrt(widthsquared); } @@ -332,7 +332,7 @@ public class MarlinRenderingEngine extends RenderingEngine final double d = at.getScaleY(); final double det = a * d - c * b; - if (Math.abs(det) <= (2f * Float.MIN_VALUE)) { + if (Math.abs(det) <= (2.0f * Float.MIN_VALUE)) { // this rendering engine takes one dimensional curves and turns // them into 2D shapes by giving them width. // However, if everything is to be passed through a singular @@ -344,7 +344,7 @@ public class MarlinRenderingEngine extends RenderingEngine // of writing of this comment (September 16, 2010)). Actually, // I am not sure if the moveTo is necessary to avoid the SIGSEGV // but the pathDone is definitely needed. - pc2d.moveTo(0f, 0f); + pc2d.moveTo(0.0f, 0.0f); pc2d.pathDone(); return; } @@ -361,17 +361,7 @@ public class MarlinRenderingEngine extends RenderingEngine if (dashes != null) { recycleDashes = true; dashLen = dashes.length; - final float[] newDashes; - if (dashLen <= INITIAL_ARRAY) { - newDashes = rdrCtx.dasher.dashes_ref.initial; - } else { - if (DO_STATS) { - rdrCtx.stats.stat_array_dasher_dasher.add(dashLen); - } - newDashes = rdrCtx.dasher.dashes_ref.getArray(dashLen); - } - System.arraycopy(dashes, 0, newDashes, 0, dashLen); - dashes = newDashes; + dashes = rdrCtx.dasher.copyDashArray(dashes); for (int i = 0; i < dashLen; i++) { dashes[i] *= scale; } @@ -445,7 +435,7 @@ public class MarlinRenderingEngine extends RenderingEngine } private static boolean nearZero(final double num) { - return Math.abs(num) < 2.0 * Math.ulp(num); + return Math.abs(num) < 2.0d * Math.ulp(num); } abstract static class NormalizingPathIterator implements PathIterator { @@ -524,8 +514,8 @@ public class MarlinRenderingEngine extends RenderingEngine case PathIterator.SEG_LINETO: break; case PathIterator.SEG_QUADTO: - coords[0] += (curx_adjust + x_adjust) / 2f; - coords[1] += (cury_adjust + y_adjust) / 2f; + coords[0] += (curx_adjust + x_adjust) / 2.0f; + coords[1] += (cury_adjust + y_adjust) / 2.0f; break; case PathIterator.SEG_CUBICTO: coords[0] += curx_adjust; @@ -824,10 +814,8 @@ public class MarlinRenderingEngine extends RenderingEngine } } finally { if (r != null) { - // dispose renderer: + // dispose renderer and recycle the RendererContext instance: r.dispose(); - // recycle the RendererContext instance - MarlinRenderingEngine.returnRendererContext(rdrCtx); } } @@ -845,25 +833,25 @@ public class MarlinRenderingEngine extends RenderingEngine { // REMIND: Deal with large coordinates! double ldx1, ldy1, ldx2, ldy2; - boolean innerpgram = (lw1 > 0.0 && lw2 > 0.0); + boolean innerpgram = (lw1 > 0.0d && lw2 > 0.0d); if (innerpgram) { ldx1 = dx1 * lw1; ldy1 = dy1 * lw1; ldx2 = dx2 * lw2; ldy2 = dy2 * lw2; - x -= (ldx1 + ldx2) / 2.0; - y -= (ldy1 + ldy2) / 2.0; + x -= (ldx1 + ldx2) / 2.0d; + y -= (ldy1 + ldy2) / 2.0d; dx1 += ldx1; dy1 += ldy1; dx2 += ldx2; dy2 += ldy2; - if (lw1 > 1.0 && lw2 > 1.0) { + if (lw1 > 1.0d && lw2 > 1.0d) { // Inner parallelogram was entirely consumed by stroke... innerpgram = false; } } else { - ldx1 = ldy1 = ldx2 = ldy2 = 0.0; + ldx1 = ldy1 = ldx2 = ldy2 = 0.0d; } MarlinTileGenerator ptg = null; @@ -884,10 +872,10 @@ public class MarlinRenderingEngine extends RenderingEngine if (innerpgram) { x += ldx1 + ldx2; y += ldy1 + ldy2; - dx1 -= 2.0 * ldx1; - dy1 -= 2.0 * ldy1; - dx2 -= 2.0 * ldx2; - dy2 -= 2.0 * ldy2; + dx1 -= 2.0d * ldx1; + dy1 -= 2.0d * ldy1; + dx2 -= 2.0d * ldx2; + dy2 -= 2.0d * ldy2; r.moveTo((float) x, (float) y); r.lineTo((float) (x+dx1), (float) (y+dy1)); r.lineTo((float) (x+dx1+dx2), (float) (y+dy1+dy2)); @@ -905,10 +893,8 @@ public class MarlinRenderingEngine extends RenderingEngine } } finally { if (r != null) { - // dispose renderer: + // dispose renderer and recycle the RendererContext instance: r.dispose(); - // recycle the RendererContext instance - MarlinRenderingEngine.returnRendererContext(rdrCtx); } } @@ -1035,12 +1021,11 @@ public class MarlinRenderingEngine extends RenderingEngine + MarlinConst.SUBPIXEL_LG_POSITIONS_X); logInfo("sun.java2d.renderer.subPixel_log2_Y = " + MarlinConst.SUBPIXEL_LG_POSITIONS_Y); + logInfo("sun.java2d.renderer.tileSize_log2 = " - + MarlinConst.TILE_SIZE_LG); - - logInfo("sun.java2d.renderer.blockSize_log2 = " - + MarlinConst.BLOCK_SIZE_LG); - + + MarlinConst.TILE_H_LG); + logInfo("sun.java2d.renderer.tileWidth_log2 = " + + MarlinConst.TILE_W_LG); logInfo("sun.java2d.renderer.blockSize_log2 = " + MarlinConst.BLOCK_SIZE_LG); @@ -1078,8 +1063,14 @@ public class MarlinRenderingEngine extends RenderingEngine + MarlinConst.LOG_UNSAFE_MALLOC); // quality settings + logInfo("sun.java2d.renderer.cubic_dec_d2 = " + + MarlinProperties.getCubicDecD2()); + logInfo("sun.java2d.renderer.cubic_inc_d1 = " + + MarlinProperties.getCubicIncD1()); + logInfo("sun.java2d.renderer.quad_dec_d2 = " + + MarlinProperties.getQuadDecD2()); + logInfo("Renderer settings:"); - logInfo("CUB_COUNT_LG = " + Renderer.CUB_COUNT_LG); logInfo("CUB_DEC_BND = " + Renderer.CUB_DEC_BND); logInfo("CUB_INC_BND = " + Renderer.CUB_INC_BND); logInfo("QUAD_DEC_BND = " + Renderer.QUAD_DEC_BND); diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinTileGenerator.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinTileGenerator.java index f623d507987..c3504ccfe17 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinTileGenerator.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/MarlinTileGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -25,25 +25,51 @@ package sun.java2d.marlin; +import java.util.Arrays; import sun.java2d.pipe.AATileGenerator; import jdk.internal.misc.Unsafe; final class MarlinTileGenerator implements AATileGenerator, MarlinConst { - private static final int MAX_TILE_ALPHA_SUM = TILE_SIZE * TILE_SIZE - * MAX_AA_ALPHA; + private static final int MAX_TILE_ALPHA_SUM = TILE_W * TILE_H * MAX_AA_ALPHA; - private final Renderer rdr; + private static final int TH_AA_ALPHA_FILL_EMPTY = ((MAX_AA_ALPHA + 1) / 3); // 33% + private static final int TH_AA_ALPHA_FILL_FULL = ((MAX_AA_ALPHA + 1) * 2 / 3); // 66% + + private static final int FILL_TILE_W = TILE_W >> 1; // half tile width + + static { + if (MAX_TILE_ALPHA_SUM <= 0) { + throw new IllegalStateException("Invalid MAX_TILE_ALPHA_SUM: " + MAX_TILE_ALPHA_SUM); + } + if (DO_TRACE) { + System.out.println("MAX_AA_ALPHA : " + MAX_AA_ALPHA); + System.out.println("TH_AA_ALPHA_FILL_EMPTY : " + TH_AA_ALPHA_FILL_EMPTY); + System.out.println("TH_AA_ALPHA_FILL_FULL : " + TH_AA_ALPHA_FILL_FULL); + System.out.println("FILL_TILE_W : " + FILL_TILE_W); + } + } + + private final Renderer rdrF; + private final DRenderer rdrD; private final MarlinCache cache; private int x, y; - // per-thread renderer context - final RendererContext rdrCtx; + // per-thread renderer stats + final RendererStats rdrStats; - MarlinTileGenerator(Renderer r) { - this.rdr = r; - this.cache = r.cache; - this.rdrCtx = r.rdrCtx; + MarlinTileGenerator(final RendererStats stats, final MarlinRenderer r, + final MarlinCache cache) + { + this.rdrStats = stats; + if (r instanceof Renderer) { + this.rdrF = (Renderer)r; + this.rdrD = null; + } else { + this.rdrF = null; + this.rdrD = (DRenderer)r; + } + this.cache = cache; } MarlinTileGenerator init() { @@ -61,14 +87,17 @@ final class MarlinTileGenerator implements AATileGenerator, MarlinConst { public void dispose() { if (DO_MONITORS) { // called from AAShapePipe.renderTiles() (render tiles end): - rdrCtx.stats.mon_pipe_renderTiles.stop(); + rdrStats.mon_pipe_renderTiles.stop(); } // dispose cache: cache.dispose(); - // dispose renderer: - rdr.dispose(); - // recycle the RendererContext instance - MarlinRenderingEngine.returnRendererContext(rdrCtx); + // dispose renderer and recycle the RendererContext instance: + // bimorphic call optimization: + if (rdrF != null) { + rdrF.dispose(); + } else if (rdrD != null) { + rdrD.dispose(); + } } void getBbox(int[] bbox) { @@ -86,9 +115,9 @@ final class MarlinTileGenerator implements AATileGenerator, MarlinConst { public int getTileWidth() { if (DO_MONITORS) { // called from AAShapePipe.renderTiles() (render tiles start): - rdrCtx.stats.mon_pipe_renderTiles.start(); + rdrStats.mon_pipe_renderTiles.start(); } - return TILE_SIZE; + return TILE_W; } /** @@ -97,7 +126,7 @@ final class MarlinTileGenerator implements AATileGenerator, MarlinConst { */ @Override public int getTileHeight() { - return TILE_SIZE; + return TILE_H; } /** @@ -131,7 +160,7 @@ final class MarlinTileGenerator implements AATileGenerator, MarlinConst { final int alpha = (al == 0x00 ? 0x00 : (al == MAX_TILE_ALPHA_SUM ? 0xff : 0x80)); if (DO_STATS) { - rdrCtx.stats.hist_tile_generator_alpha.add(alpha); + rdrStats.hist_tile_generator_alpha.add(alpha); } return alpha; } @@ -143,14 +172,19 @@ final class MarlinTileGenerator implements AATileGenerator, MarlinConst { */ @Override public void nextTile() { - if ((x += TILE_SIZE) >= cache.bboxX1) { + if ((x += TILE_W) >= cache.bboxX1) { x = cache.bboxX0; - y += TILE_SIZE; + y += TILE_H; if (y < cache.bboxY1) { // compute for the tile line // [ y; max(y + TILE_SIZE, bboxY1) ] - this.rdr.endRendering(y); + // bimorphic call optimization: + if (rdrF != null) { + rdrF.endRendering(y); + } else if (rdrD != null) { + rdrD.endRendering(y); + } } } } @@ -180,7 +214,7 @@ final class MarlinTileGenerator implements AATileGenerator, MarlinConst { final int rowstride) { if (DO_MONITORS) { - rdrCtx.stats.mon_ptg_getAlpha.start(); + rdrStats.mon_ptg_getAlpha.start(); } // local vars for performance: @@ -190,11 +224,11 @@ final class MarlinTileGenerator implements AATileGenerator, MarlinConst { final int[] rowAAx1 = _cache.rowAAx1; final int x0 = this.x; - final int x1 = FloatMath.min(x0 + TILE_SIZE, _cache.bboxX1); + final int x1 = FloatMath.min(x0 + TILE_W, _cache.bboxX1); // note: process tile line [0 - 32[ final int y0 = 0; - final int y1 = FloatMath.min(this.y + TILE_SIZE, _cache.bboxY1) - this.y; + final int y1 = FloatMath.min(this.y + TILE_H, _cache.bboxY1) - this.y; if (DO_LOG_BOUNDS) { MarlinUtils.logInfo("getAlpha = [" + x0 + " ... " + x1 @@ -237,14 +271,14 @@ final class MarlinTileGenerator implements AATileGenerator, MarlinConst { } } - // now: cx >= x0 but cx < aax0 (x1 < aax0) + // now: cx >= x0 and cx >= aax0 // Copy AA data (sum alpha data): addr = addr_rowAA + rowAAChunkIndex[cy] + (cx - aax0); for (end = (aax1 <= x1) ? aax1 : x1; cx < end; cx++) { // cx inside tile[x0; x1[ : - tile[idx++] = _unsafe.getByte(addr); // [0..255] + tile[idx++] = _unsafe.getByte(addr); // [0-255] addr += SIZE; } } @@ -269,7 +303,7 @@ final class MarlinTileGenerator implements AATileGenerator, MarlinConst { nextTile(); if (DO_MONITORS) { - rdrCtx.stats.mon_ptg_getAlpha.stop(); + rdrStats.mon_ptg_getAlpha.stop(); } } @@ -282,7 +316,7 @@ final class MarlinTileGenerator implements AATileGenerator, MarlinConst { final int rowstride) { if (DO_MONITORS) { - rdrCtx.stats.mon_ptg_getAlpha.start(); + rdrStats.mon_ptg_getAlpha.start(); } // Decode run-length encoded alpha mask data @@ -300,24 +334,48 @@ final class MarlinTileGenerator implements AATileGenerator, MarlinConst { final long[] rowAAPos = _cache.rowAAPos; final int x0 = this.x; - final int x1 = FloatMath.min(x0 + TILE_SIZE, _cache.bboxX1); + final int x1 = FloatMath.min(x0 + TILE_W, _cache.bboxX1); + final int w = x1 - x0; // note: process tile line [0 - 32[ final int y0 = 0; - final int y1 = FloatMath.min(this.y + TILE_SIZE, _cache.bboxY1) - this.y; + final int y1 = FloatMath.min(this.y + TILE_H, _cache.bboxY1) - this.y; if (DO_LOG_BOUNDS) { MarlinUtils.logInfo("getAlpha = [" + x0 + " ... " + x1 + "[ [" + y0 + " ... " + y1 + "["); } + // avoid too small area: fill is not faster ! + final int clearTile; + final byte refVal; + final int area; + + if ((w >= FILL_TILE_W) && (area = w * y1) > 64) { // 64 / 4 ie 16 words min (faster) + final int alphaSum = cache.alphaSumInTile(x0); + + if (alphaSum < area * TH_AA_ALPHA_FILL_EMPTY) { + clearTile = 1; + refVal = 0; + } else if (alphaSum > area * TH_AA_ALPHA_FILL_FULL) { + clearTile = 2; + refVal = (byte)0xff; + } else { + clearTile = 0; + refVal = 0; + } + } else { + clearTile = 0; + refVal = 0; + } + final Unsafe _unsafe = OffHeapArray.UNSAFE; final long SIZE_BYTE = 1L; final long SIZE_INT = 4L; final long addr_rowAA = _cache.rowAAChunk.address; long addr, addr_row, last_addr, addr_end; - final int skipRowPixels = (rowstride - (x1 - x0)); + final int skipRowPixels = (rowstride - w); int cx, cy, cx1; int rx0, rx1, runLen, end; @@ -325,137 +383,414 @@ final class MarlinTileGenerator implements AATileGenerator, MarlinConst { byte val; int idx = offset; - for (cy = y0; cy < y1; cy++) { - // empty line (default) - cx = x0; + switch (clearTile) { + case 1: // 0x00 + // Clear full tile rows: + Arrays.fill(tile, offset, offset + (y1 * rowstride), refVal); - if (rowAAEnc[cy] == 0) { - // Raw encoding: + for (cy = y0; cy < y1; cy++) { + // empty line (default) + cx = x0; - final int aax1 = rowAAx1[cy]; // exclusive + if (rowAAEnc[cy] == 0) { + // Raw encoding: - // quick check if there is AA data - // corresponding to this tile [x0; x1[ - if (aax1 > x0) { - final int aax0 = rowAAx0[cy]; // inclusive + final int aax1 = rowAAx1[cy]; // exclusive - if (aax0 < x1) { - // note: cx is the cursor pointer in the tile array - // (left to right) - cx = aax0; + // quick check if there is AA data + // corresponding to this tile [x0; x1[ + if (aax1 > x0) { + final int aax0 = rowAAx0[cy]; // inclusive - // ensure cx >= x0 - if (cx <= x0) { - cx = x0; - } else { - // fill line start until first AA pixel rowAA exclusive: - for (end = x0; end < cx; end++) { - tile[idx++] = 0; + if (aax0 < x1) { + // note: cx is the cursor pointer in the tile array + // (left to right) + cx = aax0; + + // ensure cx >= x0 + if (cx <= x0) { + cx = x0; + } else { + // skip line start until first AA pixel rowAA exclusive: + idx += (cx - x0); // > 0 + } + + // now: cx >= x0 and cx >= aax0 + + // Copy AA data (sum alpha data): + addr = addr_rowAA + rowAAChunkIndex[cy] + (cx - aax0); + + for (end = (aax1 <= x1) ? aax1 : x1; cx < end; cx++) { + tile[idx++] = _unsafe.getByte(addr); // [0-255] + addr += SIZE_BYTE; + } + } + } + } else { + // RLE encoding: + + // quick check if there is AA data + // corresponding to this tile [x0; x1[ + if (rowAAx1[cy] > x0) { // last pixel exclusive + + cx = rowAAx0[cy]; // inclusive + if (cx > x1) { + cx = x1; + } + + // skip line start until first AA pixel rowAA exclusive: + if (cx > x0) { + idx += (cx - x0); // > 0 + } + + // get row address: + addr_row = addr_rowAA + rowAAChunkIndex[cy]; + // get row end address: + addr_end = addr_row + rowAALen[cy]; // coded length + + // reuse previous iteration position: + addr = addr_row + rowAAPos[cy]; + + last_addr = 0L; + + while ((cx < x1) && (addr < addr_end)) { + // keep current position: + last_addr = addr; + + // packed value: + packed = _unsafe.getInt(addr); + + // last exclusive pixel x-coordinate: + cx1 = (packed >> 8); + // as bytes: + addr += SIZE_INT; + + rx0 = cx; + if (rx0 < x0) { + rx0 = x0; + } + rx1 = cx = cx1; + if (rx1 > x1) { + rx1 = x1; + cx = x1; // fix last x + } + // adjust runLen: + runLen = rx1 - rx0; + + // ensure rx1 > rx0: + if (runLen > 0) { + packed &= 0xFF; // [0-255] + + if (packed == 0) + { + idx += runLen; + continue; + } + val = (byte) packed; // [0-255] + do { + tile[idx++] = val; + } while (--runLen > 0); } } - // now: cx >= x0 but cx < aax0 (x1 < aax0) - - // Copy AA data (sum alpha data): - addr = addr_rowAA + rowAAChunkIndex[cy] + (cx - aax0); - - for (end = (aax1 <= x1) ? aax1 : x1; cx < end; cx++) { - tile[idx++] = _unsafe.getByte(addr); // [0..255] - addr += SIZE_BYTE; + // Update last position in RLE entries: + if (last_addr != 0L) { + // Fix x0: + rowAAx0[cy] = cx; // inclusive + // Fix position: + rowAAPos[cy] = (last_addr - addr_row); } } } - } else { - // RLE encoding: - // quick check if there is AA data - // corresponding to this tile [x0; x1[ - if (rowAAx1[cy] > x0) { // last pixel exclusive + // skip line end + if (cx < x1) { + idx += (x1 - cx); // > 0 + } - cx = rowAAx0[cy]; // inclusive - if (cx > x1) { - cx = x1; + if (DO_TRACE) { + for (int i = idx - (x1 - x0); i < idx; i++) { + System.out.print(hex(tile[i], 2)); } + System.out.println(); + } - // fill line start until first AA pixel rowAA exclusive: - for (int i = x0; i < cx; i++) { - tile[idx++] = 0; - } + idx += skipRowPixels; + } + break; - // get row address: - addr_row = addr_rowAA + rowAAChunkIndex[cy]; - // get row end address: - addr_end = addr_row + rowAALen[cy]; // coded length + case 0: + default: + for (cy = y0; cy < y1; cy++) { + // empty line (default) + cx = x0; - // reuse previous iteration position: - addr = addr_row + rowAAPos[cy]; + if (rowAAEnc[cy] == 0) { + // Raw encoding: - last_addr = 0L; + final int aax1 = rowAAx1[cy]; // exclusive - while ((cx < x1) && (addr < addr_end)) { - // keep current position: - last_addr = addr; + // quick check if there is AA data + // corresponding to this tile [x0; x1[ + if (aax1 > x0) { + final int aax0 = rowAAx0[cy]; // inclusive - // packed value: - packed = _unsafe.getInt(addr); + if (aax0 < x1) { + // note: cx is the cursor pointer in the tile array + // (left to right) + cx = aax0; - // last exclusive pixel x-coordinate: - cx1 = (packed >> 8); - // as bytes: - addr += SIZE_INT; + // ensure cx >= x0 + if (cx <= x0) { + cx = x0; + } else { + for (end = x0; end < cx; end++) { + tile[idx++] = 0; + } + } - rx0 = cx; - if (rx0 < x0) { - rx0 = x0; - } - rx1 = cx = cx1; - if (rx1 > x1) { - rx1 = x1; - cx = x1; // fix last x - } - // adjust runLen: - runLen = rx1 - rx0; + // now: cx >= x0 and cx >= aax0 - // ensure rx1 > rx0: - if (runLen > 0) { - val = (byte)(packed & 0xFF); // [0..255] + // Copy AA data (sum alpha data): + addr = addr_rowAA + rowAAChunkIndex[cy] + (cx - aax0); - do { - tile[idx++] = val; - } while (--runLen > 0); + for (end = (aax1 <= x1) ? aax1 : x1; cx < end; cx++) { + tile[idx++] = _unsafe.getByte(addr); // [0-255] + addr += SIZE_BYTE; + } } } + } else { + // RLE encoding: - // Update last position in RLE entries: - if (last_addr != 0L) { - // Fix x0: - rowAAx0[cy] = cx; // inclusive - // Fix position: - rowAAPos[cy] = (last_addr - addr_row); + // quick check if there is AA data + // corresponding to this tile [x0; x1[ + if (rowAAx1[cy] > x0) { // last pixel exclusive + + cx = rowAAx0[cy]; // inclusive + if (cx > x1) { + cx = x1; + } + + // fill line start until first AA pixel rowAA exclusive: + for (end = x0; end < cx; end++) { + tile[idx++] = 0; + } + + // get row address: + addr_row = addr_rowAA + rowAAChunkIndex[cy]; + // get row end address: + addr_end = addr_row + rowAALen[cy]; // coded length + + // reuse previous iteration position: + addr = addr_row + rowAAPos[cy]; + + last_addr = 0L; + + while ((cx < x1) && (addr < addr_end)) { + // keep current position: + last_addr = addr; + + // packed value: + packed = _unsafe.getInt(addr); + + // last exclusive pixel x-coordinate: + cx1 = (packed >> 8); + // as bytes: + addr += SIZE_INT; + + rx0 = cx; + if (rx0 < x0) { + rx0 = x0; + } + rx1 = cx = cx1; + if (rx1 > x1) { + rx1 = x1; + cx = x1; // fix last x + } + // adjust runLen: + runLen = rx1 - rx0; + + // ensure rx1 > rx0: + if (runLen > 0) { + packed &= 0xFF; // [0-255] + + val = (byte) packed; // [0-255] + do { + tile[idx++] = val; + } while (--runLen > 0); + } + } + + // Update last position in RLE entries: + if (last_addr != 0L) { + // Fix x0: + rowAAx0[cy] = cx; // inclusive + // Fix position: + rowAAPos[cy] = (last_addr - addr_row); + } } } - } - // fill line end - while (cx < x1) { - tile[idx++] = 0; - cx++; - } - - if (DO_TRACE) { - for (int i = idx - (x1 - x0); i < idx; i++) { - System.out.print(hex(tile[i], 2)); + // fill line end + while (cx < x1) { + tile[idx++] = 0; + cx++; } - System.out.println(); - } - idx += skipRowPixels; + if (DO_TRACE) { + for (int i = idx - (x1 - x0); i < idx; i++) { + System.out.print(hex(tile[i], 2)); + } + System.out.println(); + } + + idx += skipRowPixels; + } + break; + + case 2: // 0xFF + // Fill full tile rows: + Arrays.fill(tile, offset, offset + (y1 * rowstride), refVal); + + for (cy = y0; cy < y1; cy++) { + // empty line (default) + cx = x0; + + if (rowAAEnc[cy] == 0) { + // Raw encoding: + + final int aax1 = rowAAx1[cy]; // exclusive + + // quick check if there is AA data + // corresponding to this tile [x0; x1[ + if (aax1 > x0) { + final int aax0 = rowAAx0[cy]; // inclusive + + if (aax0 < x1) { + // note: cx is the cursor pointer in the tile array + // (left to right) + cx = aax0; + + // ensure cx >= x0 + if (cx <= x0) { + cx = x0; + } else { + // fill line start until first AA pixel rowAA exclusive: + for (end = x0; end < cx; end++) { + tile[idx++] = 0; + } + } + + // now: cx >= x0 and cx >= aax0 + + // Copy AA data (sum alpha data): + addr = addr_rowAA + rowAAChunkIndex[cy] + (cx - aax0); + + for (end = (aax1 <= x1) ? aax1 : x1; cx < end; cx++) { + tile[idx++] = _unsafe.getByte(addr); // [0-255] + addr += SIZE_BYTE; + } + } + } + } else { + // RLE encoding: + + // quick check if there is AA data + // corresponding to this tile [x0; x1[ + if (rowAAx1[cy] > x0) { // last pixel exclusive + + cx = rowAAx0[cy]; // inclusive + if (cx > x1) { + cx = x1; + } + + // fill line start until first AA pixel rowAA exclusive: + for (end = x0; end < cx; end++) { + tile[idx++] = 0; + } + + // get row address: + addr_row = addr_rowAA + rowAAChunkIndex[cy]; + // get row end address: + addr_end = addr_row + rowAALen[cy]; // coded length + + // reuse previous iteration position: + addr = addr_row + rowAAPos[cy]; + + last_addr = 0L; + + while ((cx < x1) && (addr < addr_end)) { + // keep current position: + last_addr = addr; + + // packed value: + packed = _unsafe.getInt(addr); + + // last exclusive pixel x-coordinate: + cx1 = (packed >> 8); + // as bytes: + addr += SIZE_INT; + + rx0 = cx; + if (rx0 < x0) { + rx0 = x0; + } + rx1 = cx = cx1; + if (rx1 > x1) { + rx1 = x1; + cx = x1; // fix last x + } + // adjust runLen: + runLen = rx1 - rx0; + + // ensure rx1 > rx0: + if (runLen > 0) { + packed &= 0xFF; // [0-255] + + if (packed == 0xFF) + { + idx += runLen; + continue; + } + val = (byte) packed; // [0-255] + do { + tile[idx++] = val; + } while (--runLen > 0); + } + } + + // Update last position in RLE entries: + if (last_addr != 0L) { + // Fix x0: + rowAAx0[cy] = cx; // inclusive + // Fix position: + rowAAPos[cy] = (last_addr - addr_row); + } + } + } + + // fill line end + while (cx < x1) { + tile[idx++] = 0; + cx++; + } + + if (DO_TRACE) { + for (int i = idx - (x1 - x0); i < idx; i++) { + System.out.print(hex(tile[i], 2)); + } + System.out.println(); + } + + idx += skipRowPixels; + } } nextTile(); if (DO_MONITORS) { - rdrCtx.stats.mon_ptg_getAlpha.stop(); + rdrStats.mon_ptg_getAlpha.stop(); } } diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/OffHeapArray.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/OffHeapArray.java index d4b1ed28819..676111a0152 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/OffHeapArray.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/OffHeapArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -89,6 +89,7 @@ final class OffHeapArray { + this.length + " at addr = " + this.address); } + this.address = 0L; } void fill(final byte val) { diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Renderer.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Renderer.java index d3b058b59b1..bb7f88a996a 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Renderer.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Renderer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -25,41 +25,38 @@ package sun.java2d.marlin; -import java.util.Arrays; import sun.awt.geom.PathConsumer2D; import static sun.java2d.marlin.OffHeapArray.SIZE_INT; import jdk.internal.misc.Unsafe; -final class Renderer implements PathConsumer2D, MarlinConst { +final class Renderer implements PathConsumer2D, MarlinRenderer { static final boolean DISABLE_RENDER = false; static final boolean ENABLE_BLOCK_FLAGS = MarlinProperties.isUseTileFlags(); static final boolean ENABLE_BLOCK_FLAGS_HEURISTICS = MarlinProperties.isUseTileFlagsWithHeuristics(); - private static final int ALL_BUT_LSB = 0xfffffffe; - private static final int ERR_STEP_MAX = 0x7fffffff; // = 2^31 - 1 + private static final int ALL_BUT_LSB = 0xFFFFFFFE; + private static final int ERR_STEP_MAX = 0x7FFFFFFF; // = 2^31 - 1 - private static final double POWER_2_TO_32 = 0x1.0p32; + private static final double POWER_2_TO_32 = 0x1.0p32d; // use float to make tosubpix methods faster (no int to float conversion) - public static final float F_SUBPIXEL_POSITIONS_X - = (float) SUBPIXEL_POSITIONS_X; - public static final float F_SUBPIXEL_POSITIONS_Y - = (float) SUBPIXEL_POSITIONS_Y; - public static final int SUBPIXEL_MASK_X = SUBPIXEL_POSITIONS_X - 1; - public static final int SUBPIXEL_MASK_Y = SUBPIXEL_POSITIONS_Y - 1; + static final float SUBPIXEL_SCALE_X = (float) SUBPIXEL_POSITIONS_X; + static final float SUBPIXEL_SCALE_Y = (float) SUBPIXEL_POSITIONS_Y; + static final int SUBPIXEL_MASK_X = SUBPIXEL_POSITIONS_X - 1; + static final int SUBPIXEL_MASK_Y = SUBPIXEL_POSITIONS_Y - 1; // number of subpixels corresponding to a tile line private static final int SUBPIXEL_TILE - = TILE_SIZE << SUBPIXEL_LG_POSITIONS_Y; + = TILE_H << SUBPIXEL_LG_POSITIONS_Y; // 2048 (pixelSize) pixels (height) x 8 subpixels = 64K static final int INITIAL_BUCKET_ARRAY = INITIAL_PIXEL_DIM * SUBPIXEL_POSITIONS_Y; - // crossing capacity = edges count / 8 ~ 512 - static final int INITIAL_CROSSING_COUNT = INITIAL_EDGES_COUNT >> 3; + // crossing capacity = edges count / 4 ~ 1024 + static final int INITIAL_CROSSING_COUNT = INITIAL_EDGES_COUNT >> 2; public static final int WIND_EVEN_ODD = 0; public static final int WIND_NON_ZERO = 1; @@ -80,20 +77,20 @@ final class Renderer implements PathConsumer2D, MarlinConst { // curve break into lines // cubic error in subpixels to decrement step private static final float CUB_DEC_ERR_SUBPIX - = 2.5f * (NORM_SUBPIXELS / 8f); // 2.5 subpixel for typical 8x8 subpixels + = MarlinProperties.getCubicDecD2() * (NORM_SUBPIXELS / 8.0f); // 1 pixel // cubic error in subpixels to increment step private static final float CUB_INC_ERR_SUBPIX - = 1f * (NORM_SUBPIXELS / 8f); // 1 subpixel for typical 8x8 subpixels + = MarlinProperties.getCubicIncD1() * (NORM_SUBPIXELS / 8.0f); // 0.4 pixel - // cubic bind length to decrement step = 8 * error in subpixels - // pisces: 20 / 8 - // openjfx pisces: 8 / 3.2 - // multiply by 8 = error scale factor: + // TestNonAARasterization (JDK-8170879): cubics + // bad paths (59294/100000 == 59,29%, 94335 bad pixels (avg = 1,59), 3966 warnings (avg = 0,07) + + // cubic bind length to decrement step public static final float CUB_DEC_BND - = 8f * CUB_DEC_ERR_SUBPIX; // 20f means 2.5 subpixel error - // cubic bind length to increment step = 8 * error in subpixels + = 8.0f * CUB_DEC_ERR_SUBPIX; + // cubic bind length to increment step public static final float CUB_INC_BND - = 8f * CUB_INC_ERR_SUBPIX; // 8f means 1 subpixel error + = 8.0f * CUB_INC_ERR_SUBPIX; // cubic countlg public static final int CUB_COUNT_LG = 2; @@ -104,21 +101,23 @@ final class Renderer implements PathConsumer2D, MarlinConst { // cubic count^3 = 8^countlg private static final int CUB_COUNT_3 = 1 << (3 * CUB_COUNT_LG); // cubic dt = 1 / count - private static final float CUB_INV_COUNT = 1f / CUB_COUNT; + private static final float CUB_INV_COUNT = 1.0f / CUB_COUNT; // cubic dt^2 = 1 / count^2 = 1 / 4^countlg - private static final float CUB_INV_COUNT_2 = 1f / CUB_COUNT_2; + private static final float CUB_INV_COUNT_2 = 1.0f / CUB_COUNT_2; // cubic dt^3 = 1 / count^3 = 1 / 8^countlg - private static final float CUB_INV_COUNT_3 = 1f / CUB_COUNT_3; + private static final float CUB_INV_COUNT_3 = 1.0f / CUB_COUNT_3; // quad break into lines // quadratic error in subpixels private static final float QUAD_DEC_ERR_SUBPIX - = 1f * (NORM_SUBPIXELS / 8f); // 1 subpixel for typical 8x8 subpixels + = MarlinProperties.getQuadDecD2() * (NORM_SUBPIXELS / 8.0f); // 0.5 pixel - // quadratic bind length to decrement step = 8 * error in subpixels - // pisces and openjfx pisces: 32 + // TestNonAARasterization (JDK-8170879): quads + // bad paths (62916/100000 == 62,92%, 103818 bad pixels (avg = 1,65), 6514 warnings (avg = 0,10) + + // quadratic bind length to decrement step public static final float QUAD_DEC_BND - = 8f * QUAD_DEC_ERR_SUBPIX; // 8f means 1 subpixel error + = 8.0f * QUAD_DEC_ERR_SUBPIX; ////////////////////////////////////////////////////////////////////////////// // SCAN LINE @@ -157,7 +156,7 @@ final class Renderer implements PathConsumer2D, MarlinConst { private float edgeMinX = Float.POSITIVE_INFINITY; private float edgeMaxX = Float.NEGATIVE_INFINITY; - // edges [floats|ints] stored in off-heap memory + // edges [ints] stored in off-heap memory private final OffHeapArray edges; private int[] edgeBuckets; @@ -165,8 +164,6 @@ final class Renderer implements PathConsumer2D, MarlinConst { // used range for edgeBuckets / edgeBucketCounts private int buckets_minY; private int buckets_maxY; - // sum of each edge delta Y (subpixels) - private int edgeSumDeltaY; // edgeBuckets ref (clean) private final IntArrayCache.Reference edgeBuckets_ref; @@ -183,13 +180,13 @@ final class Renderer implements PathConsumer2D, MarlinConst { int count = 1; // dt = 1 / count // maximum(ddX|Y) = norm(dbx, dby) * dt^2 (= 1) - float maxDD = FloatMath.max(Math.abs(c.dbx), Math.abs(c.dby)); + float maxDD = Math.abs(c.dbx) + Math.abs(c.dby); final float _DEC_BND = QUAD_DEC_BND; while (maxDD >= _DEC_BND) { // divide step by half: - maxDD /= 4f; // error divided by 2^2 = 4 + maxDD /= 4.0f; // error divided by 2^2 = 4 count <<= 1; if (DO_STATS) { @@ -199,7 +196,7 @@ final class Renderer implements PathConsumer2D, MarlinConst { int nL = 0; // line count if (count > 1) { - final float icount = 1f / count; // dt + final float icount = 1.0f / count; // dt final float icount2 = icount * icount; // dt^2 final float ddx = c.dbx * icount2; @@ -246,8 +243,8 @@ final class Renderer implements PathConsumer2D, MarlinConst { // the dx and dy refer to forward differencing variables, not the last // coefficients of the "points" polynomial float dddx, dddy, ddx, ddy, dx, dy; - dddx = 2f * c.dax * icount3; - dddy = 2f * c.day * icount3; + dddx = 2.0f * c.dax * icount3; + dddy = 2.0f * c.day * icount3; ddx = dddx + c.dbx * icount2; ddy = dddy + c.dby * icount2; dx = c.ax * icount3 + c.bx * icount2 + c.cx * icount; @@ -262,13 +259,13 @@ final class Renderer implements PathConsumer2D, MarlinConst { while (count > 0) { // divide step by half: - while (Math.abs(ddx) >= _DEC_BND || Math.abs(ddy) >= _DEC_BND) { - dddx /= 8f; - dddy /= 8f; - ddx = ddx/4f - dddx; - ddy = ddy/4f - dddy; - dx = (dx - ddx) / 2f; - dy = (dy - ddy) / 2f; + while (Math.abs(ddx) + Math.abs(ddy) >= _DEC_BND) { + dddx /= 8.0f; + dddy /= 8.0f; + ddx = ddx / 4.0f - dddx; + ddy = ddy / 4.0f - dddy; + dx = (dx - ddx) / 2.0f; + dy = (dy - ddy) / 2.0f; count <<= 1; if (DO_STATS) { @@ -277,19 +274,16 @@ final class Renderer implements PathConsumer2D, MarlinConst { } // double step: - // TODO: why use first derivative dX|Y instead of second ddX|Y ? - // both scale changes should use speed or acceleration to have the same metric. - // can only do this on even "count" values, because we must divide count by 2 while (count % 2 == 0 - && Math.abs(dx) <= _INC_BND && Math.abs(dy) <= _INC_BND) + && Math.abs(dx) + Math.abs(dy) <= _INC_BND) { - dx = 2f * dx + ddx; - dy = 2f * dy + ddy; - ddx = 4f * (ddx + dddx); - ddy = 4f * (ddy + dddy); - dddx *= 8f; - dddy *= 8f; + dx = 2.0f * dx + ddx; + dy = 2.0f * dy + ddy; + ddx = 4.0f * (ddx + dddx); + ddy = 4.0f * (ddy + dddy); + dddx *= 8.0f; + dddy *= 8.0f; count >>= 1; if (DO_STATS) { @@ -337,7 +331,7 @@ final class Renderer implements PathConsumer2D, MarlinConst { x1 = tmp; } - // convert subpixel coordinates (float) into pixel positions (int) + // convert subpixel coordinates [float] into pixel positions [int] // The index of the pixel that holds the next HPC is at ceil(trueY - 0.5) // Since y1 and y2 are biased by -0.5 in tosubpixy(), this is simply @@ -361,7 +355,7 @@ final class Renderer implements PathConsumer2D, MarlinConst { return; } - // edge min/max X/Y are in subpixel space (inclusive) within bounds: + // edge min/max X/Y are in subpixel space (half-open interval): // note: Use integer crossings to ensure consistent range within // edgeBuckets / edgeBucketCounts arrays in case of NaN values (int = 0) if (firstCrossing < edgeMinY) { @@ -376,7 +370,7 @@ final class Renderer implements PathConsumer2D, MarlinConst { final double y1d = y1; final double slope = (x1d - x2) / (y1d - y2); - if (slope >= 0.0) { // <==> x1 < x2 + if (slope >= 0.0d) { // <==> x1 < x2 if (x1 < edgeMinX) { edgeMinX = x1; } @@ -439,13 +433,13 @@ final class Renderer implements PathConsumer2D, MarlinConst { // long x1_fixed = x1_intercept * 2^32; (fixed point 32.32 format) // curx = next VPC = fixed_floor(x1_fixed - 2^31 + 2^32 - 1) // = fixed_floor(x1_fixed + 2^31 - 1) - // = fixed_floor(x1_fixed + 0x7fffffff) - // and error = fixed_fract(x1_fixed + 0x7fffffff) + // = fixed_floor(x1_fixed + 0x7FFFFFFF) + // and error = fixed_fract(x1_fixed + 0x7FFFFFFF) final double x1_intercept = x1d + (firstCrossing - y1d) * slope; // inlined scalb(x1_intercept, 32): final long x1_fixed_biased = ((long) (POWER_2_TO_32 * x1_intercept)) - + 0x7fffffffL; + + 0x7FFFFFFFL; // curx: // last bit corresponds to the orientation _unsafe.putInt(addr, (((int) (x1_fixed_biased >> 31L)) & ALL_BUT_LSB) | or); @@ -474,7 +468,7 @@ final class Renderer implements PathConsumer2D, MarlinConst { // pointer from bucket _unsafe.putInt(addr, _edgeBuckets[bucketIdx]); addr += SIZE_INT; - // y max (inclusive) + // y max (exclusive) _unsafe.putInt(addr, lastCrossing); // Update buckets: @@ -484,9 +478,6 @@ final class Renderer implements PathConsumer2D, MarlinConst { // last bit means edge end _edgeBucketCounts[lastCrossing - _boundsMinY] |= 0x1; - // update sum of delta Y (subpixels): - edgeSumDeltaY += (lastCrossing - firstCrossing); - // update free pointer (ie length in bytes) _edges.used += _SIZEOF_EDGE_BYTES; @@ -568,8 +559,8 @@ final class Renderer implements PathConsumer2D, MarlinConst { Renderer init(final int pix_boundsX, final int pix_boundsY, final int pix_boundsWidth, final int pix_boundsHeight, - final int windingRule) { - + final int windingRule) + { this.windingRule = windingRule; // bounds as half-open intervals: minX <= x < maxX and minY <= y < maxY @@ -611,8 +602,6 @@ final class Renderer implements PathConsumer2D, MarlinConst { activeEdgeMaxUsed = 0; edges.used = 0; - edgeSumDeltaY = 0; - return this; // fluent API } @@ -669,15 +658,17 @@ final class Renderer implements PathConsumer2D, MarlinConst { if (DO_MONITORS) { rdrCtx.stats.mon_rdr_endRendering.stop(); } + // recycle the RendererContext instance + MarlinRenderingEngine.returnRendererContext(rdrCtx); } private static float tosubpixx(final float pix_x) { - return F_SUBPIXEL_POSITIONS_X * pix_x; + return SUBPIXEL_SCALE_X * pix_x; } private static float tosubpixy(final float pix_y) { // shift y by -0.5 for fast ceil(y - 0.5): - return F_SUBPIXEL_POSITIONS_Y * pix_y - 0.5f; + return SUBPIXEL_SCALE_Y * pix_y - 0.5f; } @Override @@ -702,8 +693,8 @@ final class Renderer implements PathConsumer2D, MarlinConst { @Override public void curveTo(float x1, float y1, - float x2, float y2, - float x3, float y3) + float x2, float y2, + float x3, float y3) { final float xe = tosubpixx(x3); final float ye = tosubpixy(y3); @@ -969,8 +960,8 @@ final class Renderer implements PathConsumer2D, MarlinConst { // get the pointer to the edge ecur = _edgePtrs[i]; - /* convert subpixel coordinates (float) into pixel - positions (int) for coming scanline */ + /* convert subpixel coordinates into pixel + positions for coming scanline */ /* note: it is faster to always update edges even if it is removed from AEL for coming or last scanline */ @@ -1069,8 +1060,8 @@ final class Renderer implements PathConsumer2D, MarlinConst { // get the pointer to the edge ecur = _edgePtrs[i]; - /* convert subpixel coordinates (float) into pixel - positions (int) for coming scanline */ + /* convert subpixel coordinates into pixel + positions for coming scanline */ /* note: it is faster to always update edges even if it is removed from AEL for coming or last scanline */ @@ -1176,7 +1167,14 @@ final class Renderer implements PathConsumer2D, MarlinConst { // TODO: perform line clipping on left-right sides // to avoid such bound checks: x0 = (prev > bboxx0) ? prev : bboxx0; - x1 = (curx < bboxx1) ? curx : bboxx1; + + if (curx < bboxx1) { + x1 = curx; + } else { + x1 = bboxx1; + // skip right side (fast exit loop): + i = numCrossings; + } if (x0 < x1) { x0 -= bboxx0; // turn x0, x1 from coords to indices @@ -1193,7 +1191,8 @@ final class Renderer implements PathConsumer2D, MarlinConst { if (useBlkFlags) { // flag used blocks: - _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; + // note: block processing handles extra pixel: + _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; } } else { tmp = (x0 & _SUBPIXEL_MASK_X); @@ -1212,6 +1211,7 @@ final class Renderer implements PathConsumer2D, MarlinConst { if (useBlkFlags) { // flag used blocks: + // note: block processing handles extra pixel: _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; _blkFlags[pix_xmax >> _BLK_SIZE_LG] = 1; } @@ -1237,7 +1237,14 @@ final class Renderer implements PathConsumer2D, MarlinConst { // TODO: perform line clipping on left-right sides // to avoid such bound checks: x0 = (prev > bboxx0) ? prev : bboxx0; - x1 = (curx < bboxx1) ? curx : bboxx1; + + if (curx < bboxx1) { + x1 = curx; + } else { + x1 = bboxx1; + // skip right side (fast exit loop): + i = numCrossings; + } if (x0 < x1) { x0 -= bboxx0; // turn x0, x1 from coords to indices @@ -1254,7 +1261,8 @@ final class Renderer implements PathConsumer2D, MarlinConst { if (useBlkFlags) { // flag used blocks: - _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; + // note: block processing handles extra pixel: + _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; } } else { tmp = (x0 & _SUBPIXEL_MASK_X); @@ -1273,6 +1281,7 @@ final class Renderer implements PathConsumer2D, MarlinConst { if (useBlkFlags) { // flag used blocks: + // note: block processing handles extra pixel: _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; _blkFlags[pix_xmax >> _BLK_SIZE_LG] = 1; } @@ -1306,9 +1315,12 @@ final class Renderer implements PathConsumer2D, MarlinConst { if (maxX >= minX) { // note: alpha array will be zeroed by copyAARow() - // +2 because alpha [pix_minX; pix_maxX+1] + // +1 because alpha [pix_minX; pix_maxX[ // fix range [x0; x1[ - copyAARow(_alpha, lastY, minX, maxX + 2, useBlkFlags); + // note: if x1=bboxx1, then alpha is written up to bboxx1+1 + // inclusive: alpha[bboxx1] ignored, alpha[bboxx1+1] == 0 + // (normally so never cleared below) + copyAARow(_alpha, lastY, minX, maxX + 1, useBlkFlags); // speculative for next pixel row (scanline coherence): if (_enableBlkFlagsHeuristics) { @@ -1350,9 +1362,12 @@ final class Renderer implements PathConsumer2D, MarlinConst { if (maxX >= minX) { // note: alpha array will be zeroed by copyAARow() - // +2 because alpha [pix_minX; pix_maxX+1] + // +1 because alpha [pix_minX; pix_maxX[ // fix range [x0; x1[ - copyAARow(_alpha, y, minX, maxX + 2, useBlkFlags); + // note: if x1=bboxx1, then alpha is written up to bboxx1+1 + // inclusive: alpha[bboxx1] ignored then cleared and + // alpha[bboxx1+1] == 0 (normally so never cleared after) + copyAARow(_alpha, y, minX, maxX + 1, useBlkFlags); } else if (y != lastY) { _cache.clearAARow(y); } @@ -1375,36 +1390,26 @@ final class Renderer implements PathConsumer2D, MarlinConst { return false; // undefined edges bounds } - final int _boundsMinY = boundsMinY; - final int _boundsMaxY = boundsMaxY; - - // bounds as inclusive intervals + // bounds as half-open intervals final int spminX = FloatMath.max(FloatMath.ceil_int(edgeMinX - 0.5f), boundsMinX); - final int spmaxX = FloatMath.min(FloatMath.ceil_int(edgeMaxX - 0.5f), boundsMaxX - 1); + final int spmaxX = FloatMath.min(FloatMath.ceil_int(edgeMaxX - 0.5f), boundsMaxX); // edge Min/Max Y are already rounded to subpixels within bounds: final int spminY = edgeMinY; - final int spmaxY; - int maxY = edgeMaxY; + final int spmaxY = edgeMaxY; - if (maxY <= _boundsMaxY - 1) { - spmaxY = maxY; - } else { - spmaxY = _boundsMaxY - 1; - maxY = _boundsMaxY; - } - buckets_minY = spminY - _boundsMinY; - buckets_maxY = maxY - _boundsMinY; + buckets_minY = spminY - boundsMinY; + buckets_maxY = spmaxY - boundsMinY; if (DO_LOG_BOUNDS) { MarlinUtils.logInfo("edgesXY = [" + edgeMinX + " ... " + edgeMaxX - + "][" + edgeMinY + " ... " + edgeMaxY + "]"); + + "[ [" + edgeMinY + " ... " + edgeMaxY + "["); MarlinUtils.logInfo("spXY = [" + spminX + " ... " + spmaxX - + "][" + spminY + " ... " + spmaxY + "]"); + + "[ [" + spminY + " ... " + spmaxY + "["); } // test clipping for shapes out of bounds - if ((spminX > spmaxX) || (spminY > spmaxY)) { + if ((spminX >= spmaxX) || (spminY >= spmaxY)) { return false; } @@ -1419,7 +1424,7 @@ final class Renderer implements PathConsumer2D, MarlinConst { final int pmaxY = (spmaxY + SUBPIXEL_MASK_Y) >> SUBPIXEL_LG_POSITIONS_Y; // store BBox to answer ptg.getBBox(): - this.cache.init(pminX, pminY, pmaxX, pmaxY, edgeSumDeltaY); + this.cache.init(pminX, pminY, pmaxX, pmaxY); // Heuristics for using block flags: if (ENABLE_BLOCK_FLAGS) { @@ -1429,9 +1434,9 @@ final class Renderer implements PathConsumer2D, MarlinConst { if (enableBlkFlags) { // ensure blockFlags array is large enough: // note: +2 to ensure enough space left at end - final int nxTiles = ((pmaxX - pminX) >> TILE_SIZE_LG) + 2; - if (nxTiles > INITIAL_ARRAY) { - blkFlags = blkFlags_ref.getArray(nxTiles); + final int blkLen = ((pmaxX - pminX) >> BLOCK_SIZE_LG) + 2; + if (blkLen > INITIAL_ARRAY) { + blkFlags = blkFlags_ref.getArray(blkLen); } } } @@ -1446,7 +1451,7 @@ final class Renderer implements PathConsumer2D, MarlinConst { // inclusive: bbox_spminY = spminY; // exclusive: - bbox_spmaxY = FloatMath.min(spmaxY + 1, pmaxY << SUBPIXEL_LG_POSITIONS_Y); + bbox_spmaxY = spmaxY; if (DO_LOG_BOUNDS) { MarlinUtils.logInfo("pXY = [" + pminX + " ... " + pmaxX @@ -1504,6 +1509,9 @@ final class Renderer implements PathConsumer2D, MarlinConst { final int pix_y, final int pix_from, final int pix_to, final boolean useBlockFlags) { + if (DO_MONITORS) { + rdrCtx.stats.mon_rdr_copyAARow.start(); + } if (useBlockFlags) { if (DO_STATS) { rdrCtx.stats.hist_tile_generator_encoding.add(1); @@ -1515,5 +1523,8 @@ final class Renderer implements PathConsumer2D, MarlinConst { } cache.copyAARowNoRLE(alphaRow, pix_y, pix_from, pix_to); } + if (DO_MONITORS) { + rdrCtx.stats.mon_rdr_copyAARow.stop(); + } } } diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/RendererContext.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/RendererContext.java index f6290cb8db3..3b2546a4711 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/RendererContext.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/RendererContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -35,7 +35,7 @@ import sun.java2d.marlin.MarlinRenderingEngine.NormalizingPathIterator; /** * This class is a renderer context dedicated to a single thread */ -final class RendererContext extends ReentrantContext implements MarlinConst { +final class RendererContext extends ReentrantContext implements IRendererContext { // RendererContext creation counter private static final AtomicInteger CTX_COUNT = new AtomicInteger(1); @@ -121,7 +121,7 @@ final class RendererContext extends ReentrantContext implements MarlinConst { // Renderer: cache = new MarlinCache(this); renderer = new Renderer(this); // needs MarlinCache from rdrCtx.cache - ptg = new MarlinTileGenerator(renderer); + ptg = new MarlinTileGenerator(stats, renderer, cache); stroker = new Stroker(this); dasher = new Dasher(this); @@ -174,14 +174,21 @@ final class RendererContext extends ReentrantContext implements MarlinConst { return p2d; } - OffHeapArray newOffHeapArray(final long initialSize) { + @Override + public RendererStats stats() { + return stats; + } + + @Override + public OffHeapArray newOffHeapArray(final long initialSize) { if (DO_STATS) { stats.totalOffHeapInitial += initialSize; } return new OffHeapArray(cleanerObj, initialSize); } - IntArrayCache.Reference newCleanIntArrayRef(final int initialSize) { + @Override + public IntArrayCache.Reference newCleanIntArrayRef(final int initialSize) { return cleanIntCache.createRef(initialSize); } diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Stroker.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Stroker.java index 44b9a62e417..c98b3f0d57a 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Stroker.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Stroker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -26,12 +26,8 @@ package sun.java2d.marlin; import java.util.Arrays; -import static java.lang.Math.ulp; -import static java.lang.Math.sqrt; import sun.awt.geom.PathConsumer2D; -import sun.java2d.marlin.Curve.BreakPtrIterator; - // TODO: some of the arithmetic here is too verbose and prone to hard to // debug typos. We should consider making a small Point/Vector class that @@ -75,7 +71,7 @@ final class Stroker implements PathConsumer2D, MarlinConst { // pisces used to use fixed point arithmetic with 16 decimal digits. I // didn't want to change the values of the constant below when I converted // it to floating point, so that's why the divisions by 2^16 are there. - private static final float ROUND_JOIN_THRESHOLD = 1000/65536f; + private static final float ROUND_JOIN_THRESHOLD = 1000.0f/65536.0f; private static final float C = 0.5522847498307933f; @@ -112,9 +108,8 @@ final class Stroker implements PathConsumer2D, MarlinConst { private final PolyStack reverse; // This is where the curve to be processed is put. We give it - // enough room to store 2 curves: one for the current subdivision, the - // other for the rest of the curve. - private final float[] middle = new float[2 * 8]; + // enough room to store all curves. + private final float[] middle = new float[MAX_N_CURVES * 6 + 2]; private final float[] lp = new float[8]; private final float[] rp = new float[8]; private final float[] subdivTs = new float[MAX_N_CURVES - 1]; @@ -158,8 +153,8 @@ final class Stroker implements PathConsumer2D, MarlinConst { { this.out = pc2d; - this.lineWidth2 = lineWidth / 2f; - this.invHalfLineWidth2Sq = 1f / (2f * lineWidth2 * lineWidth2); + this.lineWidth2 = lineWidth / 2.0f; + this.invHalfLineWidth2Sq = 1.0f / (2.0f * lineWidth2 * lineWidth2); this.capStyle = capStyle; this.joinStyle = joinStyle; @@ -182,14 +177,14 @@ final class Stroker implements PathConsumer2D, MarlinConst { if (DO_CLEAN_DIRTY) { // Force zero-fill dirty arrays: - Arrays.fill(offset0, 0f); - Arrays.fill(offset1, 0f); - Arrays.fill(offset2, 0f); - Arrays.fill(miter, 0f); - Arrays.fill(middle, 0f); - Arrays.fill(lp, 0f); - Arrays.fill(rp, 0f); - Arrays.fill(subdivTs, 0f); + Arrays.fill(offset0, 0.0f); + Arrays.fill(offset1, 0.0f); + Arrays.fill(offset2, 0.0f); + Arrays.fill(miter, 0.0f); + Arrays.fill(middle, 0.0f); + Arrays.fill(lp, 0.0f); + Arrays.fill(rp, 0.0f); + Arrays.fill(subdivTs, 0.0f); } } @@ -197,11 +192,11 @@ final class Stroker implements PathConsumer2D, MarlinConst { final float w, final float[] m) { float len = lx*lx + ly*ly; - if (len == 0f) { - m[0] = 0f; - m[1] = 0f; + if (len == 0.0f) { + m[0] = 0.0f; + m[1] = 0.0f; } else { - len = (float) sqrt(len); + len = (float) Math.sqrt(len); m[0] = (ly * w) / len; m[1] = -(lx * w) / len; } @@ -226,7 +221,7 @@ final class Stroker implements PathConsumer2D, MarlinConst { boolean rev, float threshold) { - if ((omx == 0f && omy == 0f) || (mx == 0f && my == 0f)) { + if ((omx == 0.0f && omy == 0.0f) || (mx == 0.0f && my == 0.0f)) { return; } @@ -258,7 +253,7 @@ final class Stroker implements PathConsumer2D, MarlinConst { // If it is >=0, we know that abs(ext) is <= 90 degrees, so we only // need 1 curve to approximate the circle section that joins omx,omy // and mx,my. - final int numCurves = (cosext >= 0f) ? 1 : 2; + final int numCurves = (cosext >= 0.0f) ? 1 : 2; switch (numCurves) { case 1: @@ -280,7 +275,7 @@ final class Stroker implements PathConsumer2D, MarlinConst { // this normal's length is at least 0.5 and at most sqrt(2)/2 (because // we know the angle of the arc is > 90 degrees). float nx = my - omy, ny = omx - mx; - float nlen = (float) sqrt(nx*nx + ny*ny); + float nlen = (float) Math.sqrt(nx*nx + ny*ny); float scale = lineWidth2/nlen; float mmx = nx * scale, mmy = ny * scale; @@ -318,8 +313,8 @@ final class Stroker implements PathConsumer2D, MarlinConst { // define the bezier curve we're computing. // It is computed using the constraints that P1-P0 and P3-P2 are parallel // to the arc tangents at the endpoints, and that |P1-P0|=|P3-P2|. - float cv = (float) ((4.0 / 3.0) * sqrt(0.5 - cosext2) / - (1.0 + sqrt(cosext2 + 0.5))); + float cv = (float) ((4.0d / 3.0d) * Math.sqrt(0.5d - cosext2) / + (1.0d + Math.sqrt(cosext2 + 0.5d))); // if clockwise, we need to negate cv. if (rev) { // rev is equivalent to isCW(omx, omy, mx, my) cv = -cv; @@ -348,20 +343,28 @@ final class Stroker implements PathConsumer2D, MarlinConst { cx - mx, cy - my); } - // Put the intersection point of the lines (x0, y0) -> (x1, y1) - // and (x0p, y0p) -> (x1p, y1p) in m[off] and m[off+1]. - // If the lines are parallel, it will put a non finite number in m. - private static void computeIntersection(final float x0, final float y0, - final float x1, final float y1, - final float x0p, final float y0p, - final float x1p, final float y1p, - final float[] m, int off) + // Return the intersection point of the lines (x0, y0) -> (x1, y1) + // and (x0p, y0p) -> (x1p, y1p) in m[off] and m[off+1] + private static void computeMiter(final float x0, final float y0, + final float x1, final float y1, + final float x0p, final float y0p, + final float x1p, final float y1p, + final float[] m, int off) { float x10 = x1 - x0; float y10 = y1 - y0; float x10p = x1p - x0p; float y10p = y1p - y0p; + // if this is 0, the lines are parallel. If they go in the + // same direction, there is no intersection so m[off] and + // m[off+1] will contain infinity, so no miter will be drawn. + // If they go in the same direction that means that the start of the + // current segment and the end of the previous segment have the same + // tangent, in which case this method won't even be involved in + // miter drawing because it won't be called by drawMiter (because + // (mx == omx && my == omy) will be true, and drawMiter will return + // immediately). float den = x10*y10p - x10p*y10; float t = x10p*(y0-y0p) - y10p*(x0-x0p); t /= den; @@ -369,6 +372,40 @@ final class Stroker implements PathConsumer2D, MarlinConst { m[off] = y0 + t*y10; } + // Return the intersection point of the lines (x0, y0) -> (x1, y1) + // and (x0p, y0p) -> (x1p, y1p) in m[off] and m[off+1] + private static void safeComputeMiter(final float x0, final float y0, + final float x1, final float y1, + final float x0p, final float y0p, + final float x1p, final float y1p, + final float[] m, int off) + { + float x10 = x1 - x0; + float y10 = y1 - y0; + float x10p = x1p - x0p; + float y10p = y1p - y0p; + + // if this is 0, the lines are parallel. If they go in the + // same direction, there is no intersection so m[off] and + // m[off+1] will contain infinity, so no miter will be drawn. + // If they go in the same direction that means that the start of the + // current segment and the end of the previous segment have the same + // tangent, in which case this method won't even be involved in + // miter drawing because it won't be called by drawMiter (because + // (mx == omx && my == omy) will be true, and drawMiter will return + // immediately). + float den = x10*y10p - x10p*y10; + if (den == 0.0f) { + m[off++] = (x0 + x0p) / 2.0f; + m[off] = (y0 + y0p) / 2.0f; + return; + } + float t = x10p*(y0-y0p) - y10p*(x0-x0p); + t /= den; + m[off++] = x0 + t*x10; + m[off] = y0 + t*y10; + } + private void drawMiter(final float pdx, final float pdy, final float x0, final float y0, final float dx, final float dy, @@ -376,8 +413,8 @@ final class Stroker implements PathConsumer2D, MarlinConst { boolean rev) { if ((mx == omx && my == omy) || - (pdx == 0f && pdy == 0f) || - (dx == 0f && dy == 0f)) + (pdx == 0.0f && pdy == 0.0f) || + (dx == 0.0f && dy == 0.0f)) { return; } @@ -389,9 +426,9 @@ final class Stroker implements PathConsumer2D, MarlinConst { my = -my; } - computeIntersection((x0 - pdx) + omx, (y0 - pdy) + omy, x0 + omx, y0 + omy, - (dx + x0) + mx, (dy + y0) + my, x0 + mx, y0 + my, - miter, 0); + computeMiter((x0 - pdx) + omx, (y0 - pdy) + omy, x0 + omx, y0 + omy, + (dx + x0) + mx, (dy + y0) + my, x0 + mx, y0 + my, + miter, 0); final float miterX = miter[0]; final float miterY = miter[1]; @@ -414,8 +451,8 @@ final class Stroker implements PathConsumer2D, MarlinConst { } this.sx0 = this.cx0 = x0; this.sy0 = this.cy0 = y0; - this.cdx = this.sdx = 1f; - this.cdy = this.sdy = 0f; + this.cdx = this.sdx = 1.0f; + this.cdy = this.sdy = 0.0f; this.prev = MOVE_TO; } @@ -423,8 +460,8 @@ final class Stroker implements PathConsumer2D, MarlinConst { public void lineTo(float x1, float y1) { float dx = x1 - cx0; float dy = y1 - cy0; - if (dx == 0f && dy == 0f) { - dx = 1f; + if (dx == 0.0f && dy == 0.0f) { + dx = 1.0f; } computeOffset(dx, dy, lineWidth2, offset0); final float mx = offset0[0]; @@ -454,10 +491,10 @@ final class Stroker implements PathConsumer2D, MarlinConst { return; } emitMoveTo(cx0, cy0 - lineWidth2); - this.cmx = this.smx = 0f; + this.cmx = this.smx = 0.0f; this.cmy = this.smy = -lineWidth2; - this.cdx = this.sdx = 1f; - this.cdy = this.sdy = 0f; + this.cdx = this.sdx = 1.0f; + this.cdy = this.sdy = 0.0f; finish(); return; } @@ -640,7 +677,7 @@ final class Stroker implements PathConsumer2D, MarlinConst { { // if p1=p2 or p3=p4 it means that the derivative at the endpoint // vanishes, which creates problems with computeOffset. Usually - // this happens when this stroker object is trying to winden + // this happens when this stroker object is trying to widen // a curve with a cusp. What happens is that curveTo splits // the input curve at the cusp, and passes it to this function. // because of inaccuracies in the splitting, we consider points @@ -657,8 +694,8 @@ final class Stroker implements PathConsumer2D, MarlinConst { // if p1 == p2 && p3 == p4: draw line from p1->p4, unless p1 == p4, // in which case ignore if p1 == p2 - final boolean p1eqp2 = within(x1,y1,x2,y2, 6f * ulp(y2)); - final boolean p3eqp4 = within(x3,y3,x4,y4, 6f * ulp(y4)); + final boolean p1eqp2 = within(x1, y1, x2, y2, 6.0f * Math.ulp(y2)); + final boolean p3eqp4 = within(x3, y3, x4, y4, 6.0f * Math.ulp(y4)); if (p1eqp2 && p3eqp4) { getLineOffsets(x1, y1, x4, y4, leftOff, rightOff); return 4; @@ -674,7 +711,7 @@ final class Stroker implements PathConsumer2D, MarlinConst { float dotsq = (dx1 * dx4 + dy1 * dy4); dotsq *= dotsq; float l1sq = dx1 * dx1 + dy1 * dy1, l4sq = dx4 * dx4 + dy4 * dy4; - if (Helpers.within(dotsq, l1sq * l4sq, 4f * ulp(dotsq))) { + if (Helpers.within(dotsq, l1sq * l4sq, 4.0f * Math.ulp(dotsq))) { getLineOffsets(x1, y1, x4, y4, leftOff, rightOff); return 4; } @@ -726,8 +763,8 @@ final class Stroker implements PathConsumer2D, MarlinConst { // getting the inverse of the matrix above. Then we use [c1,c2] to compute // p2p and p3p. - float x = (x1 + 3f * (x2 + x3) + x4) / 8f; - float y = (y1 + 3f * (y2 + y3) + y4) / 8f; + float x = (x1 + 3.0f * (x2 + x3) + x4) / 8.0f; + float y = (y1 + 3.0f * (y2 + y3) + y4) / 8.0f; // (dxm,dym) is some tangent of B at t=0.5. This means it's equal to // c*B'(0.5) for some constant c. float dxm = x3 + x4 - x1 - x2, dym = y3 + y4 - y1 - y2; @@ -745,10 +782,10 @@ final class Stroker implements PathConsumer2D, MarlinConst { float x4p = x4 + offset2[0]; // end float y4p = y4 + offset2[1]; // point - float invdet43 = 4f / (3f * (dx1 * dy4 - dy1 * dx4)); + float invdet43 = 4.0f / (3.0f * (dx1 * dy4 - dy1 * dx4)); - float two_pi_m_p1_m_p4x = 2f * xi - x1p - x4p; - float two_pi_m_p1_m_p4y = 2f * yi - y1p - y4p; + float two_pi_m_p1_m_p4x = 2.0f * xi - x1p - x4p; + float two_pi_m_p1_m_p4y = 2.0f * yi - y1p - y4p; float c1 = invdet43 * (dy4 * two_pi_m_p1_m_p4x - dx4 * two_pi_m_p1_m_p4y); float c2 = invdet43 * (dx1 * two_pi_m_p1_m_p4y - dy1 * two_pi_m_p1_m_p4x); @@ -764,11 +801,11 @@ final class Stroker implements PathConsumer2D, MarlinConst { leftOff[6] = x4p; leftOff[7] = y4p; x1p = x1 - offset0[0]; y1p = y1 - offset0[1]; - xi = xi - 2f * offset1[0]; yi = yi - 2f * offset1[1]; + xi = xi - 2.0f * offset1[0]; yi = yi - 2.0f * offset1[1]; x4p = x4 - offset2[0]; y4p = y4 - offset2[1]; - two_pi_m_p1_m_p4x = 2f * xi - x1p - x4p; - two_pi_m_p1_m_p4y = 2f * yi - y1p - y4p; + two_pi_m_p1_m_p4x = 2.0f * xi - x1p - x4p; + two_pi_m_p1_m_p4y = 2.0f * yi - y1p - y4p; c1 = invdet43 * (dy4 * two_pi_m_p1_m_p4x - dx4 * two_pi_m_p1_m_p4y); c2 = invdet43 * (dx1 * two_pi_m_p1_m_p4y - dy1 * two_pi_m_p1_m_p4x); @@ -784,6 +821,8 @@ final class Stroker implements PathConsumer2D, MarlinConst { return 8; } + // compute offset curves using bezier spline through t=0.5 (i.e. + // ComputedCurve(0.5) == IdealParallelCurve(0.5)) // return the kind of curve in the right and left arrays. private int computeOffsetQuad(float[] pts, final int off, float[] leftOff, float[] rightOff) @@ -797,170 +836,54 @@ final class Stroker implements PathConsumer2D, MarlinConst { final float dx1 = x2 - x1; final float dy1 = y2 - y1; - // this computes the offsets at t = 0, 1 + // if p1=p2 or p3=p4 it means that the derivative at the endpoint + // vanishes, which creates problems with computeOffset. Usually + // this happens when this stroker object is trying to widen + // a curve with a cusp. What happens is that curveTo splits + // the input curve at the cusp, and passes it to this function. + // because of inaccuracies in the splitting, we consider points + // equal if they're very close to each other. + + // if p1 == p2 && p3 == p4: draw line from p1->p4, unless p1 == p4, + // in which case ignore. + final boolean p1eqp2 = within(x1, y1, x2, y2, 6.0f * Math.ulp(y2)); + final boolean p2eqp3 = within(x2, y2, x3, y3, 6.0f * Math.ulp(y3)); + if (p1eqp2 || p2eqp3) { + getLineOffsets(x1, y1, x3, y3, leftOff, rightOff); + return 4; + } + + // if p2-p1 and p4-p3 are parallel, that must mean this curve is a line + float dotsq = (dx1 * dx3 + dy1 * dy3); + dotsq *= dotsq; + float l1sq = dx1 * dx1 + dy1 * dy1, l3sq = dx3 * dx3 + dy3 * dy3; + if (Helpers.within(dotsq, l1sq * l3sq, 4.0f * Math.ulp(dotsq))) { + getLineOffsets(x1, y1, x3, y3, leftOff, rightOff); + return 4; + } + + // this computes the offsets at t=0, 0.5, 1, using the property that + // for any bezier curve the vectors p2-p1 and p4-p3 are parallel to + // the (dx/dt, dy/dt) vectors at the endpoints. computeOffset(dx1, dy1, lineWidth2, offset0); computeOffset(dx3, dy3, lineWidth2, offset1); - leftOff[0] = x1 + offset0[0]; leftOff[1] = y1 + offset0[1]; - leftOff[4] = x3 + offset1[0]; leftOff[5] = y3 + offset1[1]; - rightOff[0] = x1 - offset0[0]; rightOff[1] = y1 - offset0[1]; - rightOff[4] = x3 - offset1[0]; rightOff[5] = y3 - offset1[1]; + float x1p = x1 + offset0[0]; // start + float y1p = y1 + offset0[1]; // point + float x3p = x3 + offset1[0]; // end + float y3p = y3 + offset1[1]; // point + safeComputeMiter(x1p, y1p, x1p+dx1, y1p+dy1, x3p, y3p, x3p-dx3, y3p-dy3, leftOff, 2); + leftOff[0] = x1p; leftOff[1] = y1p; + leftOff[4] = x3p; leftOff[5] = y3p; - float x1p = leftOff[0]; // start - float y1p = leftOff[1]; // point - float x3p = leftOff[4]; // end - float y3p = leftOff[5]; // point - - // Corner cases: - // 1. If the two control vectors are parallel, we'll end up with NaN's - // in leftOff (and rightOff in the body of the if below), so we'll - // do getLineOffsets, which is right. - // 2. If the first or second two points are equal, then (dx1,dy1)==(0,0) - // or (dx3,dy3)==(0,0), so (x1p, y1p)==(x1p+dx1, y1p+dy1) - // or (x3p, y3p)==(x3p-dx3, y3p-dy3), which means that - // computeIntersection will put NaN's in leftOff and right off, and - // we will do getLineOffsets, which is right. - computeIntersection(x1p, y1p, x1p+dx1, y1p+dy1, x3p, y3p, x3p-dx3, y3p-dy3, leftOff, 2); - float cx = leftOff[2]; - float cy = leftOff[3]; - - if (!(isFinite(cx) && isFinite(cy))) { - // maybe the right path is not degenerate. - x1p = rightOff[0]; - y1p = rightOff[1]; - x3p = rightOff[4]; - y3p = rightOff[5]; - computeIntersection(x1p, y1p, x1p+dx1, y1p+dy1, x3p, y3p, x3p-dx3, y3p-dy3, rightOff, 2); - cx = rightOff[2]; - cy = rightOff[3]; - if (!(isFinite(cx) && isFinite(cy))) { - // both are degenerate. This curve is a line. - getLineOffsets(x1, y1, x3, y3, leftOff, rightOff); - return 4; - } - // {left,right}Off[0,1,4,5] are already set to the correct values. - leftOff[2] = 2f * x2 - cx; - leftOff[3] = 2f * y2 - cy; - return 6; - } - - // rightOff[2,3] = (x2,y2) - ((left_x2, left_y2) - (x2, y2)) - // == 2*(x2, y2) - (left_x2, left_y2) - rightOff[2] = 2f * x2 - cx; - rightOff[3] = 2f * y2 - cy; + x1p = x1 - offset0[0]; y1p = y1 - offset0[1]; + x3p = x3 - offset1[0]; y3p = y3 - offset1[1]; + safeComputeMiter(x1p, y1p, x1p+dx1, y1p+dy1, x3p, y3p, x3p-dx3, y3p-dy3, rightOff, 2); + rightOff[0] = x1p; rightOff[1] = y1p; + rightOff[4] = x3p; rightOff[5] = y3p; return 6; } - private static boolean isFinite(float x) { - return (Float.NEGATIVE_INFINITY < x && x < Float.POSITIVE_INFINITY); - } - - // If this class is compiled with ecj, then Hotspot crashes when OSR - // compiling this function. See bugs 7004570 and 6675699 - // TODO: until those are fixed, we should work around that by - // manually inlining this into curveTo and quadTo. -/******************************* WORKAROUND ********************************** - private void somethingTo(final int type) { - // need these so we can update the state at the end of this method - final float xf = middle[type-2], yf = middle[type-1]; - float dxs = middle[2] - middle[0]; - float dys = middle[3] - middle[1]; - float dxf = middle[type - 2] - middle[type - 4]; - float dyf = middle[type - 1] - middle[type - 3]; - switch(type) { - case 6: - if ((dxs == 0f && dys == 0f) || - (dxf == 0f && dyf == 0f)) { - dxs = dxf = middle[4] - middle[0]; - dys = dyf = middle[5] - middle[1]; - } - break; - case 8: - boolean p1eqp2 = (dxs == 0f && dys == 0f); - boolean p3eqp4 = (dxf == 0f && dyf == 0f); - if (p1eqp2) { - dxs = middle[4] - middle[0]; - dys = middle[5] - middle[1]; - if (dxs == 0f && dys == 0f) { - dxs = middle[6] - middle[0]; - dys = middle[7] - middle[1]; - } - } - if (p3eqp4) { - dxf = middle[6] - middle[2]; - dyf = middle[7] - middle[3]; - if (dxf == 0f && dyf == 0f) { - dxf = middle[6] - middle[0]; - dyf = middle[7] - middle[1]; - } - } - } - if (dxs == 0f && dys == 0f) { - // this happens iff the "curve" is just a point - lineTo(middle[0], middle[1]); - return; - } - // if these vectors are too small, normalize them, to avoid future - // precision problems. - if (Math.abs(dxs) < 0.1f && Math.abs(dys) < 0.1f) { - float len = (float) sqrt(dxs*dxs + dys*dys); - dxs /= len; - dys /= len; - } - if (Math.abs(dxf) < 0.1f && Math.abs(dyf) < 0.1f) { - float len = (float) sqrt(dxf*dxf + dyf*dyf); - dxf /= len; - dyf /= len; - } - - computeOffset(dxs, dys, lineWidth2, offset0); - final float mx = offset0[0]; - final float my = offset0[1]; - drawJoin(cdx, cdy, cx0, cy0, dxs, dys, cmx, cmy, mx, my); - - int nSplits = findSubdivPoints(curve, middle, subdivTs, type, lineWidth2); - - int kind = 0; - BreakPtrIterator it = curve.breakPtsAtTs(middle, type, subdivTs, nSplits); - while(it.hasNext()) { - int curCurveOff = it.next(); - - switch (type) { - case 8: - kind = computeOffsetCubic(middle, curCurveOff, lp, rp); - break; - case 6: - kind = computeOffsetQuad(middle, curCurveOff, lp, rp); - break; - } - emitLineTo(lp[0], lp[1]); - switch(kind) { - case 8: - emitCurveTo(lp[2], lp[3], lp[4], lp[5], lp[6], lp[7]); - emitCurveToRev(rp[0], rp[1], rp[2], rp[3], rp[4], rp[5]); - break; - case 6: - emitQuadTo(lp[2], lp[3], lp[4], lp[5]); - emitQuadToRev(rp[0], rp[1], rp[2], rp[3]); - break; - case 4: - emitLineTo(lp[2], lp[3]); - emitLineTo(rp[0], rp[1], true); - break; - } - emitLineTo(rp[kind - 2], rp[kind - 1], true); - } - - this.cmx = (lp[kind - 2] - rp[kind - 2]) / 2; - this.cmy = (lp[kind - 1] - rp[kind - 1]) / 2; - this.cdx = dxf; - this.cdy = dyf; - this.cx0 = xf; - this.cy0 = yf; - this.prev = DRAWING_OP_TO; - } -****************************** END WORKAROUND *******************************/ - // finds values of t where the curve in pts should be subdivided in order // to get good offset curves a distance of w away from the middle curve. // Stores the points in ts, and returns how many of them there were. @@ -971,11 +894,11 @@ final class Stroker implements PathConsumer2D, MarlinConst { final float y12 = pts[3] - pts[1]; // if the curve is already parallel to either axis we gain nothing // from rotating it. - if (y12 != 0f && x12 != 0f) { + if (y12 != 0.0f && x12 != 0.0f) { // we rotate it so that the first vector in the control polygon is // parallel to the x-axis. This will ensure that rotated quarter // circles won't be subdivided. - final float hypot = (float) sqrt(x12 * x12 + y12 * y12); + final float hypot = (float) Math.sqrt(x12 * x12 + y12 * y12); final float cos = x12 / hypot; final float sin = y12 / hypot; final float x1 = cos * pts[0] + sin * pts[1]; @@ -1031,9 +954,6 @@ final class Stroker implements PathConsumer2D, MarlinConst { mid[4] = x2; mid[5] = y2; mid[6] = x3; mid[7] = y3; - // inlined version of somethingTo(8); - // See the TODO on somethingTo - // need these so we can update the state at the end of this method final float xf = mid[6], yf = mid[7]; float dxs = mid[2] - mid[0]; @@ -1041,12 +961,12 @@ final class Stroker implements PathConsumer2D, MarlinConst { float dxf = mid[6] - mid[4]; float dyf = mid[7] - mid[5]; - boolean p1eqp2 = (dxs == 0f && dys == 0f); - boolean p3eqp4 = (dxf == 0f && dyf == 0f); + boolean p1eqp2 = (dxs == 0.0f && dys == 0.0f); + boolean p3eqp4 = (dxf == 0.0f && dyf == 0.0f); if (p1eqp2) { dxs = mid[4] - mid[0]; dys = mid[5] - mid[1]; - if (dxs == 0f && dys == 0f) { + if (dxs == 0.0f && dys == 0.0f) { dxs = mid[6] - mid[0]; dys = mid[7] - mid[1]; } @@ -1054,12 +974,12 @@ final class Stroker implements PathConsumer2D, MarlinConst { if (p3eqp4) { dxf = mid[6] - mid[2]; dyf = mid[7] - mid[3]; - if (dxf == 0f && dyf == 0f) { + if (dxf == 0.0f && dyf == 0.0f) { dxf = mid[6] - mid[0]; dyf = mid[7] - mid[1]; } } - if (dxs == 0f && dys == 0f) { + if (dxs == 0.0f && dys == 0.0f) { // this happens if the "curve" is just a point lineTo(mid[0], mid[1]); return; @@ -1068,12 +988,12 @@ final class Stroker implements PathConsumer2D, MarlinConst { // if these vectors are too small, normalize them, to avoid future // precision problems. if (Math.abs(dxs) < 0.1f && Math.abs(dys) < 0.1f) { - float len = (float) sqrt(dxs*dxs + dys*dys); + float len = (float) Math.sqrt(dxs*dxs + dys*dys); dxs /= len; dys /= len; } if (Math.abs(dxf) < 0.1f && Math.abs(dyf) < 0.1f) { - float len = (float) sqrt(dxf*dxf + dyf*dyf); + float len = (float) Math.sqrt(dxf*dxf + dyf*dyf); dxf /= len; dyf /= len; } @@ -1081,17 +1001,23 @@ final class Stroker implements PathConsumer2D, MarlinConst { computeOffset(dxs, dys, lineWidth2, offset0); drawJoin(cdx, cdy, cx0, cy0, dxs, dys, cmx, cmy, offset0[0], offset0[1]); - int nSplits = findSubdivPoints(curve, mid, subdivTs, 8, lineWidth2); + final int nSplits = findSubdivPoints(curve, mid, subdivTs, 8, lineWidth2); + + float prevT = 0.0f; + for (int i = 0, off = 0; i < nSplits; i++, off += 6) { + final float t = subdivTs[i]; + Helpers.subdivideCubicAt((t - prevT) / (1.0f - prevT), + mid, off, mid, off, mid, off + 6); + prevT = t; + } final float[] l = lp; final float[] r = rp; int kind = 0; - BreakPtrIterator it = curve.breakPtsAtTs(mid, 8, subdivTs, nSplits); - while(it.hasNext()) { - int curCurveOff = it.next(); + for (int i = 0, off = 0; i <= nSplits; i++, off += 6) { + kind = computeOffsetCubic(mid, off, l, r); - kind = computeOffsetCubic(mid, curCurveOff, l, r); emitLineTo(l[0], l[1]); switch(kind) { @@ -1108,8 +1034,8 @@ final class Stroker implements PathConsumer2D, MarlinConst { emitLineToRev(r[kind - 2], r[kind - 1]); } - this.cmx = (l[kind - 2] - r[kind - 2]) / 2f; - this.cmy = (l[kind - 1] - r[kind - 1]) / 2f; + this.cmx = (l[kind - 2] - r[kind - 2]) / 2.0f; + this.cmy = (l[kind - 1] - r[kind - 1]) / 2.0f; this.cdx = dxf; this.cdy = dyf; this.cx0 = xf; @@ -1124,20 +1050,17 @@ final class Stroker implements PathConsumer2D, MarlinConst { mid[2] = x1; mid[3] = y1; mid[4] = x2; mid[5] = y2; - // inlined version of somethingTo(8); - // See the TODO on somethingTo - // need these so we can update the state at the end of this method final float xf = mid[4], yf = mid[5]; float dxs = mid[2] - mid[0]; float dys = mid[3] - mid[1]; float dxf = mid[4] - mid[2]; float dyf = mid[5] - mid[3]; - if ((dxs == 0f && dys == 0f) || (dxf == 0f && dyf == 0f)) { + if ((dxs == 0.0f && dys == 0.0f) || (dxf == 0.0f && dyf == 0.0f)) { dxs = dxf = mid[4] - mid[0]; dys = dyf = mid[5] - mid[1]; } - if (dxs == 0f && dys == 0f) { + if (dxs == 0.0f && dys == 0.0f) { // this happens if the "curve" is just a point lineTo(mid[0], mid[1]); return; @@ -1145,12 +1068,12 @@ final class Stroker implements PathConsumer2D, MarlinConst { // if these vectors are too small, normalize them, to avoid future // precision problems. if (Math.abs(dxs) < 0.1f && Math.abs(dys) < 0.1f) { - float len = (float) sqrt(dxs*dxs + dys*dys); + float len = (float) Math.sqrt(dxs*dxs + dys*dys); dxs /= len; dys /= len; } if (Math.abs(dxf) < 0.1f && Math.abs(dyf) < 0.1f) { - float len = (float) sqrt(dxf*dxf + dyf*dyf); + float len = (float) Math.sqrt(dxf*dxf + dyf*dyf); dxf /= len; dyf /= len; } @@ -1160,15 +1083,21 @@ final class Stroker implements PathConsumer2D, MarlinConst { int nSplits = findSubdivPoints(curve, mid, subdivTs, 6, lineWidth2); + float prevt = 0.0f; + for (int i = 0, off = 0; i < nSplits; i++, off += 4) { + final float t = subdivTs[i]; + Helpers.subdivideQuadAt((t - prevt) / (1.0f - prevt), + mid, off, mid, off, mid, off + 4); + prevt = t; + } + final float[] l = lp; final float[] r = rp; int kind = 0; - BreakPtrIterator it = curve.breakPtsAtTs(mid, 6, subdivTs, nSplits); - while(it.hasNext()) { - int curCurveOff = it.next(); + for (int i = 0, off = 0; i <= nSplits; i++, off += 4) { + kind = computeOffsetQuad(mid, off, l, r); - kind = computeOffsetQuad(mid, curCurveOff, l, r); emitLineTo(l[0], l[1]); switch(kind) { @@ -1185,8 +1114,8 @@ final class Stroker implements PathConsumer2D, MarlinConst { emitLineToRev(r[kind - 2], r[kind - 1]); } - this.cmx = (l[kind - 2] - r[kind - 2]) / 2f; - this.cmy = (l[kind - 1] - r[kind - 1]) / 2f; + this.cmx = (l[kind - 2] - r[kind - 2]) / 2.0f; + this.cmy = (l[kind - 1] - r[kind - 1]) / 2.0f; this.cdx = dxf; this.cdy = dyf; this.cx0 = xf; @@ -1205,11 +1134,11 @@ final class Stroker implements PathConsumer2D, MarlinConst { private static final byte TYPE_QUADTO = (byte) 1; private static final byte TYPE_CUBICTO = (byte) 2; - // curves capacity = edges count (4096) = half edges x 2 (coords) - private static final int INITIAL_CURVES_COUNT = INITIAL_EDGES_COUNT; + // curves capacity = edges count (8192) = edges x 2 (coords) + private static final int INITIAL_CURVES_COUNT = INITIAL_EDGES_COUNT << 1; - // types capacity = half edges count (2048) - private static final int INITIAL_TYPES_COUNT = INITIAL_EDGES_COUNT >> 1; + // types capacity = edges count (4096) + private static final int INITIAL_TYPES_COUNT = INITIAL_EDGES_COUNT; float[] curves; int end; @@ -1235,10 +1164,10 @@ final class Stroker implements PathConsumer2D, MarlinConst { PolyStack(final RendererContext rdrCtx) { this.rdrCtx = rdrCtx; - curves_ref = rdrCtx.newDirtyFloatArrayRef(INITIAL_CURVES_COUNT); // 16K + curves_ref = rdrCtx.newDirtyFloatArrayRef(INITIAL_CURVES_COUNT); // 32K curves = curves_ref.initial; - curveTypes_ref = rdrCtx.newDirtyByteArrayRef(INITIAL_TYPES_COUNT); // 2K + curveTypes_ref = rdrCtx.newDirtyByteArrayRef(INITIAL_TYPES_COUNT); // 4K curveTypes = curveTypes_ref.initial; numCurves = 0; end = 0; @@ -1369,7 +1298,7 @@ final class Stroker implements PathConsumer2D, MarlinConst { public String toString() { String ret = ""; int nc = numCurves; - int e = end; + int last = end; int len; while (nc != 0) { switch(curveTypes[--nc]) { @@ -1388,8 +1317,8 @@ final class Stroker implements PathConsumer2D, MarlinConst { default: len = 0; } - e -= len; - ret += Arrays.toString(Arrays.copyOfRange(curves, e, e+len)) + last -= len; + ret += Arrays.toString(Arrays.copyOfRange(curves, last, last+len)) + "\n"; } return ret; diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/TransformingPathConsumer2D.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/TransformingPathConsumer2D.java index db8f8dd6391..65a502b6033 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/TransformingPathConsumer2D.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/TransformingPathConsumer2D.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -58,8 +58,8 @@ final class TransformingPathConsumer2D { float myx = (float) at.getShearY(); float myy = (float) at.getScaleY(); - if (mxy == 0f && myx == 0f) { - if (mxx == 1f && myy == 1f) { + if (mxy == 0.0f && myx == 0.0f) { + if (mxx == 1.0f && myy == 1.0f) { return out; } else { return dt_DeltaScaleFilter.init(out, mxx, myy); @@ -84,8 +84,8 @@ final class TransformingPathConsumer2D { float myx = (float) at.getShearY(); float myy = (float) at.getScaleY(); - if (mxy == 0f && myx == 0f) { - if (mxx == 1f && myy == 1f) { + if (mxy == 0.0f && myx == 0.0f) { + if (mxx == 1.0f && myy == 1.0f) { return out; } else { return iv_DeltaScaleFilter.init(out, 1.0f/mxx, 1.0f/myy); diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Version.java b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Version.java index 572db721c70..7795552a110 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Version.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/marlin/Version.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -27,7 +27,7 @@ package sun.java2d.marlin; public final class Version { - private static final String VERSION = "marlin-0.7.4-Unsafe-OpenJDK"; + private static final String VERSION = "marlin-0.7.5-Unsafe-OpenJDK"; public static String getVersion() { return VERSION; diff --git a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RenderingEngine.java b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RenderingEngine.java index 7896f13d971..c5111487c3b 100644 --- a/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RenderingEngine.java +++ b/jdk/src/java.desktop/share/classes/sun/java2d/pipe/RenderingEngine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -132,7 +132,7 @@ public abstract class RenderingEngine { } } if (reImpl == null) { - final String marlinREClass = "sun.java2d.marlin.MarlinRenderingEngine"; + final String marlinREClass = "sun.java2d.marlin.DMarlinRenderingEngine"; try { Class cls = Class.forName(marlinREClass); reImpl = (RenderingEngine) cls.getConstructor().newInstance(); From ade585e174586e192dd1901b80bc946d60e760a8 Mon Sep 17 00:00:00 2001 From: Semyon Sadetsky Date: Fri, 19 May 2017 07:25:48 -0700 Subject: [PATCH 02/98] 8132299: Shift + Mouse wheel ScrollPane horizontal scrolling doesn't work on Linux but works on Mac Reviewed-by: arapte, azvegint --- .../unix/native/libawt_xawt/xawt/XWindow.c | 4 +- .../ModifierRobotKeyTest.java | 170 ++++++++++-------- 2 files changed, 95 insertions(+), 79 deletions(-) diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XWindow.c b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XWindow.c index 0983f17b9a2..8baa40efaf1 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XWindow.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/xawt/XWindow.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -370,7 +370,7 @@ KeymapEntry keymapTable[] = {java_awt_event_KeyEvent_VK_ROMAN_CHARACTERS, XK_Romaji, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD}, {java_awt_event_KeyEvent_VK_COMPOSE, XK_Multi_key, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD}, - {java_awt_event_KeyEvent_VK_ALT_GRAPH, XK_Mode_switch, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD}, + {java_awt_event_KeyEvent_VK_ALT_GRAPH, XK_ISO_Level3_Shift, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD}, /* Editing block */ {java_awt_event_KeyEvent_VK_AGAIN, XK_Redo, FALSE, java_awt_event_KeyEvent_KEY_LOCATION_STANDARD}, diff --git a/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java b/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java index 43e37ef21f2..0925ce434ac 100644 --- a/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java +++ b/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -32,6 +32,7 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; +import static jdk.testlibrary.Asserts.assertNull; import static jdk.testlibrary.Asserts.assertTrue; /* @@ -57,9 +58,8 @@ public class ModifierRobotKeyTest extends KeyAdapter { private int[] textKeys, modifierKeys, inputMasks; private boolean[] modifierStatus, textStatus; - private final static int waitDelay = 5000; - private Object tempLock = new Object(); - private Object keyLock = new Object(); + private final static int WAIT_DELAY = 5000; + private final Object lock = new Object(); public static void main(String[] args) throws Exception { ModifierRobotKeyTest test = new ModifierRobotKeyTest(); @@ -99,27 +99,28 @@ public class ModifierRobotKeyTest extends KeyAdapter { } public void keyPressed(KeyEvent event) { + synchronized (lock) { + tempPress = true; + lock.notifyAll(); - tempPress = true; - synchronized (tempLock) { tempLock.notifyAll(); } - - if (! startTest) { - return; - } - for (int x = 0; x < inputMasks.length; x++) { - if ((event.getModifiers() & inputMasks[x]) != 0) { - System.out.println("Modifier set: " + event.getKeyModifiersText(inputMasks[x])); - modifierStatus[x] = true; + if (! startTest) { + return; + } + for (int x = 0; x < inputMasks.length; x++) { + if ((event.getModifiers() & inputMasks[x]) != 0) { + System.out.println("Modifier set: " + + event.getKeyModifiersText(inputMasks[x])); + modifierStatus[x] = true; + } + } + for (int x = 0; x < textKeys.length; x++) { + if (event.getKeyCode() == textKeys[x]) { + System.out.println("Text set: " + + event.getKeyText(textKeys[x])); + textStatus[x] = true; + } } } - for (int x = 0; x < textKeys.length; x++) { - if (event.getKeyCode() == textKeys[x]) { - System.out.println("Text set: " + event.getKeyText(textKeys[x])); - textStatus[x] = true; - } - } - - synchronized (keyLock) { keyLock.notifyAll(); } } private void initializeGUI() { @@ -131,100 +132,115 @@ public class ModifierRobotKeyTest extends KeyAdapter { canvas.addKeyListener(this); frame.setLayout(new BorderLayout()); frame.add(canvas); - frame.setSize(200, 200); + frame.setBounds(200, 200, 200, 200); frame.setVisible(true); } public void doTest() throws Exception { robot = new ExtendedRobot(); - - robot.mouseMove((int) frame.getLocationOnScreen().getX() + frame.getSize().width / 2, - (int) frame.getLocationOnScreen().getY() + frame.getSize().height / 2); - robot.click(MouseEvent.BUTTON1_MASK); + robot.setAutoDelay(20); robot.waitForIdle(); + robot.mouseMove((int) frame.getLocationOnScreen().getX() + + frame.getSize().width / 2, + (int) frame.getLocationOnScreen().getY() + + frame.getSize().height / 2); + robot.click(MouseEvent.BUTTON1_MASK); + robot.waitForIdle(); assertTrue(focusGained, "FAIL: Canvas gained focus!"); + String error = null; + exit1: for (int i = 0; i < modifierKeys.length; i++) { for (int j = 0; j < textKeys.length; j++) { - tempPress = false; - robot.keyPress(modifierKeys[i]); - robot.waitForIdle(); - if (! tempPress) { - synchronized (tempLock) { tempLock.wait(waitDelay); } + if (error != null) { + break exit1; } - assertTrue(tempPress, "FAIL: keyPressed triggered for i=" + i); - - resetStatus(); - startTest = true; - robot.keyPress(textKeys[j]); - robot.waitForIdle(); - if (! modifierStatus[i] || ! textStatus[j]) { - synchronized (keyLock) { keyLock.wait(waitDelay); } + robot.waitForIdle(100); + synchronized (lock) { + tempPress = false; + robot.keyPress(modifierKeys[i]); + lock.wait(WAIT_DELAY); + } + if (!tempPress) { + error ="FAIL: keyPressed triggered for i=" + i; } + synchronized (lock) { + resetStatus(); + startTest = true; + robot.keyPress(textKeys[j]); + lock.wait(WAIT_DELAY); + } + + if (!(modifierStatus[i] && textStatus[j])) { + error = "FAIL: KeyEvent not proper!"+ + "Key checked: i=" + i + "; j=" + j+ + "ModifierStatus = " + modifierStatus[i]+ + "TextStatus = " + textStatus[j]; + } - assertTrue(modifierStatus[i] && textStatus[j], - "FAIL: KeyEvent not proper!"+ - "Key checked: i=" + i + "; j=" + j+ - "ModifierStatus = " + modifierStatus[i]+ - "TextStatus = " + textStatus[j]); startTest = false; robot.keyRelease(textKeys[j]); - robot.waitForIdle(); robot.keyRelease(modifierKeys[i]); - robot.waitForIdle(); } } + exit2: for (int i = 0; i < modifierKeys.length; i++) { for (int j = i + 1; j < modifierKeys.length; j++) { for (int k = 0; k < textKeys.length; k++) { - tempPress = false; - robot.keyPress(modifierKeys[i]); - robot.waitForIdle(); - if (! tempPress) { - synchronized (tempLock) { tempLock.wait(waitDelay); } + if (error != null) { + break exit2; + } + robot.waitForIdle(100); + synchronized (lock) { + tempPress = false; + robot.keyPress(modifierKeys[i]); + lock.wait(WAIT_DELAY); } - assertTrue(tempPress, "FAIL: MultiKeyTest: keyPressed triggered for i=" + i); - - tempPress = false; - robot.keyPress(modifierKeys[j]); - robot.waitForIdle(); - if (! tempPress) { - synchronized (tempLock) { tempLock.wait(waitDelay); } + if (!tempPress) { + error = "FAIL: MultiKeyTest: keyPressed " + + "triggered for i=" + i; } - assertTrue(tempPress, "FAIL: MultiKeyTest keyPressed triggered for j=" + j); - resetStatus(); - startTest = true; - robot.keyPress(textKeys[k]); - robot.waitForIdle(); - if (! modifierStatus[i] || ! modifierStatus[j] || ! textStatus[k]) { - synchronized (keyLock) { - keyLock.wait(waitDelay); - } + synchronized (lock) { + tempPress = false; + robot.keyPress(modifierKeys[j]); + lock.wait(WAIT_DELAY); + } + if (!tempPress) { + error = "FAIL: MultiKeyTest keyPressed " + + "triggered for j=" + j; + }; + + synchronized (lock) { + resetStatus(); + startTest = true; + robot.keyPress(textKeys[k]); + lock.wait(WAIT_DELAY); + } + if (!(modifierStatus[i] && modifierStatus[j] + && textStatus[k])) + { + error = "FAIL: KeyEvent not proper!" + + "Key checked: i=" + i + "; j=" + j + "; k=" + k + + "Modifier1Status = " + modifierStatus[i] + + "Modifier2Status = " + modifierStatus[j] + + "TextStatus = " + textStatus[k]; } - assertTrue(modifierStatus[i] && modifierStatus[j] && textStatus[k], - "FAIL: KeyEvent not proper!"+ - "Key checked: i=" + i + "; j=" + j + "; k=" + k+ - "Modifier1Status = " + modifierStatus[i]+ - "Modifier2Status = " + modifierStatus[j]+ - "TextStatus = " + textStatus[k]); startTest = false; robot.keyRelease(textKeys[k]); - robot.waitForIdle(); robot.keyRelease(modifierKeys[j]); - robot.waitForIdle(); robot.keyRelease(modifierKeys[i]); - robot.waitForIdle(); } } } frame.dispose(); + assertNull(error, error); } private void resetStatus() { From 1dafe67147bee1049748565596389e45afc5650d Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Mon, 22 May 2017 11:21:49 +0530 Subject: [PATCH 03/98] 7042497: javax.swing.JOptionPane.showInternalConfirmDialog throws RuntimeException Reviewed-by: ssadetsky, aniyogi --- .../classes/javax/swing/JOptionPane.java | 59 +++++++---- .../7042497/JOptionPaneConfirmDlgTest.java | 100 ++++++++++++++++++ 2 files changed, 138 insertions(+), 21 deletions(-) create mode 100644 jdk/test/javax/swing/JOptionPane/7042497/JOptionPaneConfirmDlgTest.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java b/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java index 1fec8d24b18..7943542a9a9 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java @@ -1228,6 +1228,16 @@ public class JOptionPane extends JComponent implements Accessible messageType, icon, null, null); } + private static boolean checkFrameForComponent(Component parentComponent) { + if (parentComponent == null) { + return false; + } + if (parentComponent instanceof Frame) { + return true; + } + return checkFrameForComponent(parentComponent.getParent()); + } + /** * Brings up an internal dialog panel with a specified icon, where * the initial choice is determined by the initialValue @@ -1288,31 +1298,38 @@ public class JOptionPane extends JComponent implements Accessible getFocusOwner(); pane.setInitialValue(initialValue); + if (checkFrameForComponent(parentComponent)) { + JInternalFrame dialog = + pane.createInternalFrame(parentComponent, title); + pane.selectInitialValue(); + dialog.setVisible(true); - JInternalFrame dialog = - pane.createInternalFrame(parentComponent, title); - pane.selectInitialValue(); - dialog.setVisible(true); - - /* Since all input will be blocked until this dialog is dismissed, - * make sure its parent containers are visible first (this component - * is tested below). This is necessary for JApplets, because - * because an applet normally isn't made visible until after its - * start() method returns -- if this method is called from start(), - * the applet will appear to hang while an invisible modal frame - * waits for input. - */ - if (dialog.isVisible() && !dialog.isShowing()) { - Container parent = dialog.getParent(); - while (parent != null) { - if (parent.isVisible() == false) { - parent.setVisible(true); + /* Since all input will be blocked until this dialog is dismissed, + * make sure its parent containers are visible first (this component + * is tested below). This is necessary for JApplets, because + * because an applet normally isn't made visible until after its + * start() method returns -- if this method is called from start(), + * the applet will appear to hang while an invisible modal frame + * waits for input. + */ + if (dialog.isVisible() && !dialog.isShowing()) { + Container parent = dialog.getParent(); + while (parent != null) { + if (parent.isVisible() == false) { + parent.setVisible(true); + } + parent = parent.getParent(); } - parent = parent.getParent(); } - } - AWTAccessor.getContainerAccessor().startLWModal(dialog); + AWTAccessor.getContainerAccessor().startLWModal(dialog); + } else { + pane.setComponentOrientation(getRootFrame().getComponentOrientation()); + int style = styleFromMessageType(messageType); + JDialog dialog = pane.createDialog(parentComponent, title, style); + pane.selectInitialValue(); + dialog.setVisible(true); + } if (parentComponent instanceof JInternalFrame) { try { diff --git a/jdk/test/javax/swing/JOptionPane/7042497/JOptionPaneConfirmDlgTest.java b/jdk/test/javax/swing/JOptionPane/7042497/JOptionPaneConfirmDlgTest.java new file mode 100644 index 00000000000..9a8da36513b --- /dev/null +++ b/jdk/test/javax/swing/JOptionPane/7042497/JOptionPaneConfirmDlgTest.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 7042497 + * @summary Verifies if JOptionPane.showInternalConfirmDialog + throws RuntimeException if parentComponent argument is null + * @run main/manual JOptionPaneConfirmDlgTest + */ + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; + +public class JOptionPaneConfirmDlgTest { + JInternalFrame textFrame; + JFrame f = null; + + public static void main(String[] args) throws Exception{ + new JOptionPaneConfirmDlgTest(); + } + + public JOptionPaneConfirmDlgTest() throws Exception { + + try { + SwingUtilities.invokeAndWait(()->createGUI()); + Thread.sleep(10000); + } finally { + SwingUtilities.invokeAndWait(()->f.dispose()); + } + + } + + public void createGUI() { + JOptionPane.showMessageDialog( + (Component) null, + "An internalFrame with 2 buttons will be displayed. \n" + + " Press \"Hit me 1\" button. The bug causes a RuntimeException to be thrown here\n" + + " But If a confirmation dialog comes, test has passed\n" + + " Similarly, press \"Hit me 2\" button. The bug will cause a RuntimeException\n" + + " to be thrown here but if a confirmation dialog comes, test has passed.\n" + + " Close the dialog and frame.", + "information", JOptionPane.INFORMATION_MESSAGE); + f = new JFrame(); + + textFrame = new JInternalFrame("Main-Frame", true); + f.setContentPane(textFrame); + + Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); + f.setSize(dim.width/6, dim.height/5); + textFrame.setBounds(10, 10, dim.width/8, dim.height/8); + + textFrame.setVisible(true); + + JButton b1 = new JButton("Hit me 1"); + b1.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JOptionPane.showInternalConfirmDialog(null, "Test?"); + }}); + + JButton b2 = new JButton("Hit me 2"); + b2.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + JOptionPane.showInternalConfirmDialog(new JInternalFrame(), "Test?"); + }}); + + textFrame.setLayout(new FlowLayout()); + textFrame.add(b1); + textFrame.add(b2); + f.setVisible(true); + } +} From 73d1770eafcd772e08f78730fba87a6afaed8f56 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Sat, 27 May 2017 12:52:18 +0530 Subject: [PATCH 04/98] 6461834: Minimize WindowsLookAndFeel classes included with Unix JDKs Reviewed-by: ihse, aniyogi, prr --- make/CompileJavaModules.gmk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk index 73c6a40c822..56da4026a8d 100644 --- a/make/CompileJavaModules.gmk +++ b/make/CompileJavaModules.gmk @@ -199,6 +199,8 @@ endif ifeq ($(OPENJDK_TARGET_OS), windows) java.desktop_EXCLUDES += com/sun/java/swing/plaf/gtk +else + java.desktop_EXCLUDES += com/sun/java/swing/plaf/windows endif ifdef BUILD_HEADLESS_ONLY From feaf413ce36326cb7ba7bd0f2c72308dc603f21f Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Sat, 27 May 2017 12:55:33 +0530 Subject: [PATCH 05/98] 6461834: Minimize WindowsLookAndFeel classes included with Unix JDKs Reviewed-by: ihse, aniyogi, prr --- .../share/classes/module-info.java | 2 -- .../windows/classes/module-info.java.extra | 26 +++++++++++++++++++ .../java/swing/plaf/windows/Test6824600.java | 1 + .../swing/JButton/4796987/bug4796987.java | 1 + .../swing/JComboBox/4199622/bug4199622.java | 1 + .../swing/JComboBox/8015300/Test8015300.java | 1 + .../JFileChooser/8046391/bug8046391.java | 1 + .../JInternalFrame/6725409/bug6725409.java | 1 + .../swing/JSlider/6524424/bug6524424.java | 1 + .../javax/swing/JTree/8004298/bug8004298.java | 1 + jdk/test/javax/swing/border/Test4856008.java | 1 + jdk/test/javax/swing/border/Test6978482.java | 1 + 12 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 jdk/src/java.desktop/windows/classes/module-info.java.extra diff --git a/jdk/src/java.desktop/share/classes/module-info.java b/jdk/src/java.desktop/share/classes/module-info.java index 658becc98c3..127ef275754 100644 --- a/jdk/src/java.desktop/share/classes/module-info.java +++ b/jdk/src/java.desktop/share/classes/module-info.java @@ -93,8 +93,6 @@ module java.desktop { opens javax.swing.plaf.basic to jdk.jconsole; - opens com.sun.java.swing.plaf.windows to - jdk.jconsole; uses java.awt.im.spi.InputMethodDescriptor; uses javax.accessibility.AccessibilityProvider; diff --git a/jdk/src/java.desktop/windows/classes/module-info.java.extra b/jdk/src/java.desktop/windows/classes/module-info.java.extra new file mode 100644 index 00000000000..9cd11e34a91 --- /dev/null +++ b/jdk/src/java.desktop/windows/classes/module-info.java.extra @@ -0,0 +1,26 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +opens com.sun.java.swing.plaf.windows to jdk.jconsole; diff --git a/jdk/test/com/sun/java/swing/plaf/windows/Test6824600.java b/jdk/test/com/sun/java/swing/plaf/windows/Test6824600.java index 74b2890c563..7e07c517a28 100644 --- a/jdk/test/com/sun/java/swing/plaf/windows/Test6824600.java +++ b/jdk/test/com/sun/java/swing/plaf/windows/Test6824600.java @@ -23,6 +23,7 @@ /* @test @bug 6824600 + @requires (os.family == "windows") @summary OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style) @author Pavel Porvatov @modules java.desktop/com.sun.java.swing.plaf.windows diff --git a/jdk/test/javax/swing/JButton/4796987/bug4796987.java b/jdk/test/javax/swing/JButton/4796987/bug4796987.java index 52d2a32120f..65698791bfb 100644 --- a/jdk/test/javax/swing/JButton/4796987/bug4796987.java +++ b/jdk/test/javax/swing/JButton/4796987/bug4796987.java @@ -24,6 +24,7 @@ /* * @test * @bug 4796987 + * @requires (os.family == "windows") * @summary XP Only: JButton.setBorderPainted() does not work with XP L&F * @author Alexander Scherbatiy * @library ../../regtesthelpers diff --git a/jdk/test/javax/swing/JComboBox/4199622/bug4199622.java b/jdk/test/javax/swing/JComboBox/4199622/bug4199622.java index e96e2cd45a8..ffa07264681 100644 --- a/jdk/test/javax/swing/JComboBox/4199622/bug4199622.java +++ b/jdk/test/javax/swing/JComboBox/4199622/bug4199622.java @@ -25,6 +25,7 @@ @test @key headful @bug 4199622 + @requires (os.family == "windows") @summary RFE: JComboBox shouldn't send ActionEvents for keyboard navigation @author Vladislav Karnaukhov @library ../../../../lib/testlibrary diff --git a/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java b/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java index 747418bf7b1..65afea9d60e 100644 --- a/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java +++ b/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java @@ -39,6 +39,7 @@ import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE; * @test * @key headful * @bug 8015300 + * @requires (os.family == "windows") * @summary Tests that editable combobox selects all text. * @author Sergey Malenkov * @library ../../../../lib/testlibrary/ diff --git a/jdk/test/javax/swing/JFileChooser/8046391/bug8046391.java b/jdk/test/javax/swing/JFileChooser/8046391/bug8046391.java index deed68deb17..21b840787e9 100644 --- a/jdk/test/javax/swing/JFileChooser/8046391/bug8046391.java +++ b/jdk/test/javax/swing/JFileChooser/8046391/bug8046391.java @@ -24,6 +24,7 @@ /* * @test * @bug 8046391 + * @requires (os.family == "windows") * @summary JFileChooser hangs if displayed in Windows L&F * @author Alexey Ivanov * @library ../../../../lib/testlibrary diff --git a/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java b/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java index c56eaddc69d..71d52ff2d4f 100644 --- a/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java +++ b/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java @@ -24,6 +24,7 @@ /* @test * @key headful * @bug 6725409 + * @requires (os.family == "windows") * @summary Checks that JInternalFrame's system menu * can be localized during run-time * @author Mikhail Lapshin diff --git a/jdk/test/javax/swing/JSlider/6524424/bug6524424.java b/jdk/test/javax/swing/JSlider/6524424/bug6524424.java index f819d247d96..7e52135c94f 100644 --- a/jdk/test/javax/swing/JSlider/6524424/bug6524424.java +++ b/jdk/test/javax/swing/JSlider/6524424/bug6524424.java @@ -23,6 +23,7 @@ /* @test * @bug 6524424 + * @requires (os.family == "windows") * @summary JSlider Clicking In Tracks Behavior Inconsistent For Different Tick Spacings * @author Pavel Porvatov * @modules java.desktop/com.sun.java.swing.plaf.windows diff --git a/jdk/test/javax/swing/JTree/8004298/bug8004298.java b/jdk/test/javax/swing/JTree/8004298/bug8004298.java index 440dbe4e23b..e0b40d93919 100644 --- a/jdk/test/javax/swing/JTree/8004298/bug8004298.java +++ b/jdk/test/javax/swing/JTree/8004298/bug8004298.java @@ -25,6 +25,7 @@ * @test * @key headful * @bug 8004298 + * @requires (os.family == "windows") * @summary NPE in WindowsTreeUI.ensureRowsAreVisible * @author Alexander Scherbatiy * @library ../../regtesthelpers diff --git a/jdk/test/javax/swing/border/Test4856008.java b/jdk/test/javax/swing/border/Test4856008.java index 398fefb51a1..dd28834cd59 100644 --- a/jdk/test/javax/swing/border/Test4856008.java +++ b/jdk/test/javax/swing/border/Test4856008.java @@ -24,6 +24,7 @@ /* * @test * @bug 4856008 7025987 + * @requires (os.family == "windows") * @summary Tests border insets * @author Sergey Malenkov * @modules java.desktop/com.sun.java.swing.plaf.motif diff --git a/jdk/test/javax/swing/border/Test6978482.java b/jdk/test/javax/swing/border/Test6978482.java index b9f30e531e0..89634055591 100644 --- a/jdk/test/javax/swing/border/Test6978482.java +++ b/jdk/test/javax/swing/border/Test6978482.java @@ -24,6 +24,7 @@ /* * @test * @bug 6978482 7025987 + * @requires (os.family == "windows") * @summary Tests unchecked casts * @author Sergey Malenkov * @modules java.desktop/com.sun.java.swing.plaf.motif From b06519fbad7c2986316ae9874419f664be8d6e8a Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Tue, 6 Jun 2017 10:58:02 +0530 Subject: [PATCH 06/98] 6962725: Regtest javax/swing/JFileChooser/6738668/bug6738668.java fails under Linux Reviewed-by: serb --- .../javax/swing/JFileChooser/6738668/bug6738668.java | 12 ++++++++---- .../javax/swing/JFileChooser/6738668/security.policy | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/jdk/test/javax/swing/JFileChooser/6738668/bug6738668.java b/jdk/test/javax/swing/JFileChooser/6738668/bug6738668.java index 3f97358b009..618fa5a530d 100644 --- a/jdk/test/javax/swing/JFileChooser/6738668/bug6738668.java +++ b/jdk/test/javax/swing/JFileChooser/6738668/bug6738668.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009,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 @@ -22,21 +22,25 @@ */ /* @test - @bug 6738668 + @bug 6738668 6962725 @summary JFileChooser cannot be created under SecurityManager @author Pavel Porvatov @run main/othervm/policy=security.policy bug6738668 */ -import javax.swing.*; import java.io.File; +import javax.swing.JFileChooser; +import javax.swing.UIManager; public class bug6738668 { public static void main(String[] args) throws Exception { for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) { UIManager.setLookAndFeel(lookAndFeelInfo.getClassName()); - new JFileChooser(new File("c:/temp")); + String tmpdir = System.getProperty("java.io.tmpdir"); + System.out.println("tmp dir " + tmpdir); + new JFileChooser(new File(tmpdir+"/temp")); + System.out.println("Test passed for LookAndFeel " + lookAndFeelInfo.getClassName()); } diff --git a/jdk/test/javax/swing/JFileChooser/6738668/security.policy b/jdk/test/javax/swing/JFileChooser/6738668/security.policy index fd3aa757c56..29dc695da4d 100644 --- a/jdk/test/javax/swing/JFileChooser/6738668/security.policy +++ b/jdk/test/javax/swing/JFileChooser/6738668/security.policy @@ -1,5 +1,5 @@ grant { - permission java.io.FilePermission "C:\\temp\\*", "read"; - permission java.io.FilePermission "C:\\temp", "read"; + permission java.io.FilePermission "${java.io.tmpdir}${/}temp${/}*", "read"; + permission java.io.FilePermission "${java.io.tmpdir}${/}temp", "read"; permission java.util.PropertyPermission "*", "read"; }; From 5116cbb2bd520bd2f95b4588e18febbca4aff04e Mon Sep 17 00:00:00 2001 From: Sreeprakash Sreedharan Date: Wed, 7 Jun 2017 16:43:18 +0530 Subject: [PATCH 07/98] 8180370: Characters are skipped on input of Korean text on OS X Reviewed-by: serb, prr --- .../macosx/native/libawt_lwawt/awt/AWTView.m | 7 + .../MissingCharsKorean.java | 331 ++++++++++++++++++ 2 files changed, 338 insertions(+) create mode 100644 jdk/test/javax/swing/JTextField/MissingCharsKorean/MissingCharsKorean.java diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m index 186a002dd5f..1431b98aabf 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m @@ -986,6 +986,13 @@ JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod"); // We also don't want to send the character that triggered the insertText, usually a return. [3337563] fKeyEventsNeeded = NO; } + else { + // Need to set back the fKeyEventsNeeded flag so that the string following the + // marked text is not ignored by keyDown + if ([useString length] > 0) { + fKeyEventsNeeded = YES; + } + } fPAHNeedsToSelect = NO; } diff --git a/jdk/test/javax/swing/JTextField/MissingCharsKorean/MissingCharsKorean.java b/jdk/test/javax/swing/JTextField/MissingCharsKorean/MissingCharsKorean.java new file mode 100644 index 00000000000..bffe07a96ef --- /dev/null +++ b/jdk/test/javax/swing/JTextField/MissingCharsKorean/MissingCharsKorean.java @@ -0,0 +1,331 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 8180370 + * @summary Checks whether non-alpha chars are skipped while entering KoreanText + * @requires (os.family == "mac") + * @run main/manual MissingCharsKorean + */ + +/** + * This test requires a manual intervention as the keyboard layout has to be + * changed to 2-set Korean. Once the keyboard layout has been selected, click on + * Start Test to start the automated tests. Along with testing for non-alpha + * chars, this test also ensures that the MarkedText property is not broken by + * running cases where different glyphs are combined and also cases where + * combined glyphs are broken. + */ + +import java.awt.AWTException; +import java.awt.Font; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Robot; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; +import java.awt.event.KeyEvent; +import java.util.concurrent.CountDownLatch; +import javax.swing.JLabel; +import javax.swing.JTextField; + +public class MissingCharsKorean { + private static boolean testPassed = false; + private static boolean startTest = false; + private static int expectedResults[] = null; + private static int inKeyCodes[][] = null; + + private static JFrame frame = null; + private static JLabel lblTestStatus = null; + private static JTextField textFieldMain = null; + private static String testResult; + + private static final CountDownLatch testStartLatch = new CountDownLatch(1); + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + setupUI(); + }); + + testStartLatch.await(); + + if (startTest) { + glyphTest(); + + frame.dispose(); + + if (testPassed) { + System.out.println(testResult); + } else { + throw new RuntimeException("Korean text missing characters : " + + testResult); + } + } else { + throw new RuntimeException("User has not executed the test"); + } + } + + private static void setupUI() { + String description = " 1. Go to \"System Preferences -> Keyboard -> " + + "Input Sources\" and add \"2-Set Korean\"" + + " from Korean language group \n" + + " 2. Set current IM to \"2-Set Korean\" \n" + + " 3. Try typing in the text field to ensure" + + " that Korean keyboard has been successfully" + + " selected \n" + + " 4. Now click on \"Start Test\" button \n"; + String title = "Missing Characters Korean Test (Mac OS)"; + + frame = new JFrame(title); + + JPanel mainPanel = new JPanel(new BorderLayout()); + + JPanel textEditPanel = new JPanel(new FlowLayout()); + + textFieldMain = new JTextField(20); + Font font = new Font("Source Han Serif K", Font.BOLD,12); + textFieldMain.setFont(font); + + textEditPanel.add(textFieldMain); + + mainPanel.add(textEditPanel, BorderLayout.CENTER); + + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton btnStartTest = new JButton("Start Test"); + final JButton btnCancelTest = new JButton("Cancel Test"); + + btnStartTest.addActionListener((e) -> { + btnStartTest.setEnabled(false); + btnCancelTest.setEnabled(false); + startTest = true; + testStartLatch.countDown(); + }); + + btnCancelTest.addActionListener((e) -> { + frame.dispose(); + testStartLatch.countDown(); + }); + mainPanel.add(textArea, BorderLayout.NORTH); + + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(btnStartTest); + buttonPanel.add(btnCancelTest); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + + lblTestStatus = new JLabel(""); + lblTestStatus.setMinimumSize(new Dimension(150, 20)); + lblTestStatus.setPreferredSize(new Dimension(150, 20)); + lblTestStatus.setVisible(true); + textEditPanel.add(lblTestStatus); + + frame.add(mainPanel); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.pack(); + frame.setLocationRelativeTo(null); + + frame.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + testStartLatch.countDown(); + } + @Override + public void windowOpened( WindowEvent e ){ + textFieldMain.requestFocusInWindow(); + } + }); + + frame.setVisible(true); + } + + private static void glyphTest() { + try { + Robot robotKeySimulator = new Robot(); + performTasks(robotKeySimulator); + } catch (AWTException e) { + System.err.print("Creation Of Robot Failed : " + e.getMessage()); + testPassed = false; + } + } + + public static void performTasks(Robot robotForKeyInput) { + int taskCount = 0; + + lblTestStatus.setText("Running Tests.."); + robotForKeyInput.setAutoDelay(500); + + while (setKeyInput(taskCount)) { + textFieldMain.setText(""); + textFieldMain.requestFocusInWindow(); + enterInput(robotForKeyInput, inKeyCodes); + taskCount++; + + try { + SwingUtilities.invokeAndWait(() -> { + validateInput(); + }); + } catch (Exception e) { + System.err.print("validateInput Failed : " + e.getMessage()); + testPassed = false; + break; + } + + if (!testPassed) { + break; + } + setTaskStatus(false, taskCount); + } + setTaskStatus(true, taskCount); + } + + private static boolean setKeyInput(int iCount) { + boolean inputSet = true; + + switch(iCount) { + case 0: + // Input Korean q (#12610) /(#47) + expectedResults = new int[]{ 12610, 47 }; + inKeyCodes = new int[][] { {KeyEvent.VK_Q}, + {KeyEvent.VK_SLASH} + }; + break; + + case 1: + // Input Korean q (#12610) /(#47) gh (#54840) \(#92) + expectedResults = new int[]{ 12610, 47, 54840, 92 }; + inKeyCodes = new int[][] { {KeyEvent.VK_Q}, + {KeyEvent.VK_SLASH}, + {KeyEvent.VK_G}, + {KeyEvent.VK_H}, + {KeyEvent.VK_BACK_SLASH} + }; + break; + + case 2: + // Input Korean q (#12610) /(#47) ghq (#54857) \(#92) + expectedResults = new int[]{ 12610, 47, 54857, 92 }; + inKeyCodes = new int[][] { {KeyEvent.VK_Q}, + {KeyEvent.VK_SLASH}, + {KeyEvent.VK_G}, + {KeyEvent.VK_H}, + {KeyEvent.VK_Q}, + {KeyEvent.VK_BACK_SLASH} + }; + break; + + case 3: + // Input Korean q (#12610) /(#47) gh (#54840) \(#92) + expectedResults = new int[]{ 12610, 47, 54840, 92 }; + inKeyCodes = new int[][] { {KeyEvent.VK_Q}, + {KeyEvent.VK_SLASH}, + {KeyEvent.VK_G}, + {KeyEvent.VK_H}, + {KeyEvent.VK_Q}, + {KeyEvent.VK_BACK_SPACE}, + {KeyEvent.VK_BACK_SLASH} + }; + break; + + case 4: + // Input Korean q (#12610) /(#47) g (#12622) \(#92) + expectedResults = new int[]{ 12610, 47, 12622, 92 }; + inKeyCodes = new int[][] { {KeyEvent.VK_Q}, + {KeyEvent.VK_SLASH}, + {KeyEvent.VK_G}, + {KeyEvent.VK_H}, + {KeyEvent.VK_Q}, + {KeyEvent.VK_BACK_SPACE}, + {KeyEvent.VK_BACK_SPACE}, + {KeyEvent.VK_BACK_SLASH} + }; + break; + + default: + inputSet = false; + break; + } + + return inputSet; + } + + private static void enterInput(Robot robotKeyInput, int keyInputs[][]) { + for (int i = 0; i < keyInputs.length; i++) { + String strKeyInput = "KeyPress=>"; + final int noOfKeyInputs = keyInputs[i].length; + for (int j = 0; j < noOfKeyInputs; j++) { + robotKeyInput.keyPress(keyInputs[i][j]); + strKeyInput += (Integer.toHexString(keyInputs[i][j])) + ":"; + } + + strKeyInput += "KeyRelease=>"; + for (int j = noOfKeyInputs - 1; j >= 0; j--) { + robotKeyInput.keyRelease(keyInputs[i][j]); + strKeyInput += (Integer.toHexString(keyInputs[i][j])) + ":"; + } + System.out.println(strKeyInput); + } + } + + private static void validateInput() { + testPassed = false; + + if (expectedResults != null) { + String strCurr = textFieldMain.getText(); + if (expectedResults.length == strCurr.length()) { + testPassed = true; + + for (int i = 0; i < strCurr.length(); i++) { + final int charActual = strCurr.charAt(i); + if (charActual != expectedResults[i]) { + System.err.println("<" + i + "> Actual = " + charActual + + " Expected = " + expectedResults[i]); + testPassed = false; + break; + } + } + } + } + } + + public static void setTaskStatus(boolean allTasksPerformed, int taskCount) { + if (testPassed) { + if (allTasksPerformed) { + testResult = "All Tests Passed"; + } else { + testResult = "Test " + Integer.toString(taskCount) + + " Passed"; + } + } else { + testResult = "Test " + Integer.toString(taskCount) + + " Failed"; + } + lblTestStatus.setText(testResult); + } +} From 5abad616701cbaddbcbd0b5b4396ae49bedc503e Mon Sep 17 00:00:00 2001 From: Shashidhara Veerabhadraiah Date: Tue, 13 Jun 2017 14:32:24 +0530 Subject: [PATCH 08/98] 6267105: UIDefaults.getUIError dumps error message to System.err and also throws Error Reviewed-by: prr, ssadetsky --- jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java b/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java index 25f61c03033..2efdd6b1e82 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java @@ -756,9 +756,8 @@ public class UIDefaults extends Hashtable * @see #getUI */ protected void getUIError(String msg) { - System.err.println("UIDefaults.getUI() failed: " + msg); try { - throw new Error(); + throw new Error(msg); } catch (Throwable e) { e.printStackTrace(); From 0c47835ce95f2ec267ff107aeabdd01eb980f2de Mon Sep 17 00:00:00 2001 From: Sreeprakash Sreedharan Date: Thu, 15 Jun 2017 17:13:33 +0530 Subject: [PATCH 09/98] 8181782: [TESTBUG] [Macosx] JTextAreaEmojiTest is not executed Reviewed-by: psadhukhan, aniyogi --- .../JTextArea/8148555/JTextAreaEmojiTest.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/jdk/test/javax/swing/JTextArea/8148555/JTextAreaEmojiTest.java b/jdk/test/javax/swing/JTextArea/8148555/JTextAreaEmojiTest.java index 5b16e3c53e3..d94a3f6c5d1 100644 --- a/jdk/test/javax/swing/JTextArea/8148555/JTextAreaEmojiTest.java +++ b/jdk/test/javax/swing/JTextArea/8148555/JTextAreaEmojiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -33,12 +33,15 @@ import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.SwingUtilities; import static javax.swing.WindowConstants.EXIT_ON_CLOSE; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; /* @test - * @bug 8148555 + * @key headful + * @bug 8148555 8181782 * @summary verifies JTextArea emoji enter exception. Emoji is not supported. * @requires (os.family=="mac") - * @run main JTextAreaEmojiTest + * @run main/manual JTextAreaEmojiTest */ public class JTextAreaEmojiTest implements ActionListener { @@ -55,10 +58,16 @@ public class JTextAreaEmojiTest implements private static JButton failButton; private static JFrame mainFrame; + private static final CountDownLatch testRunLatch = new CountDownLatch(1); public static void main(String[] args) throws Exception { JTextAreaEmojiTest test = new JTextAreaEmojiTest(); + boolean status = testRunLatch.await(5, TimeUnit.MINUTES); + + if (!status) { + throw new RuntimeException("Test timed out"); + } } public JTextAreaEmojiTest() throws Exception { @@ -143,7 +152,6 @@ public class JTextAreaEmojiTest implements public void actionPerformed(ActionEvent evt) { if (evt.getSource() instanceof JButton) { JButton btn = (JButton) evt.getSource(); - cleanUp(); switch (btn.getActionCommand()) { case "Pass": @@ -151,10 +159,13 @@ public class JTextAreaEmojiTest implements case "Fail": throw new AssertionError("Test case has failed!"); } + + cleanUp(); } } private static void cleanUp() { mainFrame.dispose(); + testRunLatch.countDown(); } } From c969610980f1e6981f6d7e9d37b5805c2fa4af0d Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Fri, 16 Jun 2017 11:07:45 +0530 Subject: [PATCH 10/98] 8182031: Swing's ComboBox Popup opens and closes immediately Reviewed-by: azvegint --- .../swing/plaf/basic/BasicComboPopup.java | 2 +- .../JComboBox/8182031/ComboPopupTest.java | 99 +++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 jdk/test/javax/swing/JComboBox/8182031/ComboPopupTest.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java index 91afce1d5f3..67738540f09 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboPopup.java @@ -911,7 +911,7 @@ public class BasicComboPopup extends JPopupMenu implements ComboPopup { // JComboBox mouse listener Component source = (Component)e.getSource(); Dimension size = source.getSize(); - Rectangle bounds = new Rectangle( 0, 0, size.width - 1, size.height - 1 ); + Rectangle bounds = new Rectangle( 0, 0, size.width, size.height); if ( !bounds.contains( e.getPoint() ) ) { MouseEvent newEvent = convertMouseEvent( e ); Point location = newEvent.getPoint(); diff --git a/jdk/test/javax/swing/JComboBox/8182031/ComboPopupTest.java b/jdk/test/javax/swing/JComboBox/8182031/ComboPopupTest.java new file mode 100644 index 00000000000..3e1f9b80040 --- /dev/null +++ b/jdk/test/javax/swing/JComboBox/8182031/ComboPopupTest.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 8182031 + * @summary Verifies if ComboBox Popup opens and closes immediately + * @run main ComboPopupTest + */ +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.SwingUtilities; + +public class ComboPopupTest { + JFrame frame = null; + JComboBox comboBox = null; + private volatile Point p = null; + private volatile Dimension d = null; + + void blockTillDisplayed(JComponent comp) throws Exception { + while (p == null) { + try { + SwingUtilities.invokeAndWait(() -> { + p = comp.getLocationOnScreen(); + d = comboBox.getSize(); + }); + } catch (IllegalStateException e) { + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + } + } + } + } + + public static void main(String[] args) throws Exception { + new ComboPopupTest(); + } + + public ComboPopupTest() throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(200); + SwingUtilities.invokeAndWait(() -> start()); + blockTillDisplayed(comboBox); + robot.waitForIdle(); + robot.mouseMove(p.x + d.width-1, p.y + d.height/2); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.waitForIdle(); + + System.out.println("popmenu visible " + comboBox.isPopupVisible()); + if (!comboBox.isPopupVisible()) { + throw new RuntimeException("combobox popup is not visible"); + } + } finally { + SwingUtilities.invokeAndWait(()->frame.dispose()); + } + } + + public void start() { + frame = new JFrame(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + Container contentPane = frame.getContentPane(); + comboBox = new JComboBox(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }); + contentPane.setLayout(new FlowLayout()); + contentPane.add(comboBox); + frame.setLocationRelativeTo(null); + frame.pack(); + frame.setVisible(true); + } +} + From 4824dc2041218ed245feedbab7d4b355112dcea1 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Sun, 18 Jun 2017 19:52:09 +0530 Subject: [PATCH 11/98] 8177699: Some swing and awt tests are not in TEST.groups Reviewed-by: serb --- jdk/test/TEST.groups | 4 +++- jdk/test/com/apple/laf/TEST.properties | 2 ++ jdk/test/sun/applet/TEST.properties | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 jdk/test/com/apple/laf/TEST.properties create mode 100644 jdk/test/sun/applet/TEST.properties diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index 07f876ce3db..5d24c5a961f 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -318,7 +318,9 @@ jdk_awt = \ java/awt \ com/sun/awt \ com/apple/eawt \ - sun/awt + com/apple/laf \ + sun/awt \ + sun/applet jdk_2d = \ javax/print \ diff --git a/jdk/test/com/apple/laf/TEST.properties b/jdk/test/com/apple/laf/TEST.properties new file mode 100644 index 00000000000..3032a5cf793 --- /dev/null +++ b/jdk/test/com/apple/laf/TEST.properties @@ -0,0 +1,2 @@ +modules=java.desktop + diff --git a/jdk/test/sun/applet/TEST.properties b/jdk/test/sun/applet/TEST.properties new file mode 100644 index 00000000000..3032a5cf793 --- /dev/null +++ b/jdk/test/sun/applet/TEST.properties @@ -0,0 +1,2 @@ +modules=java.desktop + From 3abc91d13d097b5d5140af6a849ca8f982500bfc Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Wed, 21 Jun 2017 10:30:25 +0530 Subject: [PATCH 12/98] 8075918: The regression-swing case failed as the long Tab titles are not clipped with dots at the end with NimbusLookAndFeel Reviewed-by: serb, aniyogi --- .../classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java | 4 ++++ .../classes/javax/swing/plaf/synth/SynthGraphicsUtils.java | 4 ++++ .../classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java | 6 ++++-- jdk/test/javax/swing/JTabbedPane/4310381/bug4310381.java | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java index 80377239e6e..02df5fa9845 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java @@ -1138,7 +1138,11 @@ public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants { int tabIndex, Icon icon, Rectangle iconRect, boolean isSelected ) { if (icon != null) { + // Clip the icon within iconRect bounds + Shape oldClip = g.getClip(); + ((Graphics2D)g).clip(iconRect); icon.paintIcon(tabPane, g, iconRect.x, iconRect.y); + g.setClip(oldClip); } } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java index e91257ed0f0..844120bb3eb 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java @@ -326,7 +326,11 @@ public class SynthGraphicsUtils { */ public void paintText(SynthContext ss, Graphics g, String text, Rectangle bounds, int mnemonicIndex) { + // Clip the text within textRect bounds + Shape oldClip = g.getClip(); + ((Graphics2D)g).clip(bounds); paintText(ss, g, text, bounds.x, bounds.y, mnemonicIndex); + g.setClip(oldClip); } /** diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java index 8e59afe9342..606cf19418c 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java @@ -621,15 +621,17 @@ public class SynthTabbedPaneUI extends BasicTabbedPaneUI if (tabPane.getTabComponentAt(tabIndex) == null) { String title = tabPane.getTitleAt(tabIndex); + String clippedTitle = title; Font font = ss.getStyle().getFont(ss); FontMetrics metrics = SwingUtilities2.getFontMetrics(tabPane, g, font); Icon icon = getIconForTab(tabIndex); layoutLabel(ss, tabPlacement, metrics, tabIndex, title, icon, tabRect, iconRect, textRect, isSelected); - + clippedTitle = SwingUtilities2.clipStringIfNecessary(null, metrics, + title, textRect.width); paintText(ss, g, tabPlacement, font, metrics, - tabIndex, title, textRect, isSelected); + tabIndex, clippedTitle, textRect, isSelected); paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected); } diff --git a/jdk/test/javax/swing/JTabbedPane/4310381/bug4310381.java b/jdk/test/javax/swing/JTabbedPane/4310381/bug4310381.java index ccc3bc094c2..aa41d5c4c03 100644 --- a/jdk/test/javax/swing/JTabbedPane/4310381/bug4310381.java +++ b/jdk/test/javax/swing/JTabbedPane/4310381/bug4310381.java @@ -27,7 +27,7 @@ /* * @test - * @bug 4310381 + * @bug 4310381 8075918 * @summary Text in multi-row/col JTabbedPane tabs can be truncated/clipped * @author Charles Lee @run applet/manual=yesno bug4310381.html From e90f8d4794599363298f1969fd759f6238e325a6 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 22 Jun 2017 19:28:00 +0530 Subject: [PATCH 13/98] 8043315: Nimbus: Setting Nimbus.Overrides property affects custom keymap installation Reviewed-by: serb, azvegint --- .../swing/plaf/synth/SynthEditorPaneUI.java | 19 ++- .../swing/plaf/synth/SynthTextAreaUI.java | 18 ++- .../swing/plaf/synth/SynthTextFieldUI.java | 17 ++- .../swing/plaf/nimbus/TestNimbusOverride.java | 112 ++++++++++++++++++ 4 files changed, 153 insertions(+), 13 deletions(-) create mode 100644 jdk/test/javax/swing/plaf/nimbus/TestNimbusOverride.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java index ffaeece02fb..d6bad1cd2b2 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java @@ -47,6 +47,8 @@ public class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { */ private Boolean localTrue = Boolean.TRUE; + private boolean updateKBAction = true; + /** * Creates a new UI object for the given component. * @@ -70,7 +72,7 @@ public class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { if (clientProperty == null) { c.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, localTrue); } - updateStyle(getComponent()); + updateStyle(getComponent(), true); } /** @@ -106,13 +108,22 @@ public class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { */ @Override protected void propertyChange(PropertyChangeEvent evt) { + + if (evt.getPropertyName().equals("keymap")) { + if (evt.getNewValue() != null) + { + updateKBAction = false; + } else { + updateKBAction = true; + } + } if (SynthLookAndFeel.shouldUpdateStyle(evt)) { - updateStyle((JTextComponent)evt.getSource()); + updateStyle((JTextComponent)evt.getSource(), updateKBAction); } super.propertyChange(evt); } - private void updateStyle(JTextComponent comp) { + private void updateStyle(JTextComponent comp, boolean updateKBAction) { SynthContext context = getContext(comp, ENABLED); SynthStyle oldStyle = style; @@ -121,7 +132,7 @@ public class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI { if (style != oldStyle) { SynthTextFieldUI.updateStyle(comp, context, getPropertyPrefix()); - if (oldStyle != null) { + if (oldStyle != null && updateKBAction) { uninstallKeyboardActions(); installKeyboardActions(); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java index affbb6f4ecd..6d6cbc6804e 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java @@ -55,7 +55,7 @@ import java.beans.PropertyChangeEvent; public class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI { private Handler handler = new Handler(); private SynthStyle style; - + private boolean updateKBAction = true; /** * Creates a UI object for a JTextArea. * @@ -73,7 +73,7 @@ public class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI { protected void installDefaults() { // Installs the text cursor on the component super.installDefaults(); - updateStyle(getComponent()); + updateStyle(getComponent(), true); getComponent().addFocusListener(handler); } @@ -92,7 +92,7 @@ public class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI { super.uninstallDefaults(); } - private void updateStyle(JTextComponent comp) { + private void updateStyle(JTextComponent comp, boolean updateKBAction) { SynthContext context = getContext(comp, ENABLED); SynthStyle oldStyle = style; @@ -101,7 +101,7 @@ public class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI { if (style != oldStyle) { SynthTextFieldUI.updateStyle(comp, context, getPropertyPrefix()); - if (oldStyle != null) { + if (oldStyle != null && updateKBAction) { uninstallKeyboardActions(); installKeyboardActions(); } @@ -184,8 +184,16 @@ public class SynthTextAreaUI extends BasicTextAreaUI implements SynthUI { */ @Override protected void propertyChange(PropertyChangeEvent evt) { + if (evt.getPropertyName().equals("keymap")) { + if (evt.getNewValue() != null) + { + updateKBAction = false; + } else { + updateKBAction = true; + } + } if (SynthLookAndFeel.shouldUpdateStyle(evt)) { - updateStyle((JTextComponent)evt.getSource()); + updateStyle((JTextComponent)evt.getSource(), updateKBAction); } super.propertyChange(evt); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java index cf0e83637ef..f202d9b45e1 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java @@ -54,6 +54,7 @@ import java.beans.PropertyChangeEvent; public class SynthTextFieldUI extends BasicTextFieldUI implements SynthUI { private Handler handler = new Handler(); private SynthStyle style; + private boolean updateKBAction = true; /** * Creates a UI for a JTextField. @@ -65,7 +66,7 @@ public class SynthTextFieldUI extends BasicTextFieldUI implements SynthUI { return new SynthTextFieldUI(); } - private void updateStyle(JTextComponent comp) { + private void updateStyle(JTextComponent comp, boolean updateKBAction) { SynthContext context = getContext(comp, ENABLED); SynthStyle oldStyle = style; @@ -74,7 +75,7 @@ public class SynthTextFieldUI extends BasicTextFieldUI implements SynthUI { if (style != oldStyle) { SynthTextFieldUI.updateStyle(comp, context, getPropertyPrefix()); - if (oldStyle != null) { + if (oldStyle != null && updateKBAction) { uninstallKeyboardActions(); installKeyboardActions(); } @@ -232,8 +233,16 @@ public class SynthTextFieldUI extends BasicTextFieldUI implements SynthUI { */ @Override protected void propertyChange(PropertyChangeEvent evt) { + if (evt.getPropertyName().equals("keymap")) { + if (evt.getNewValue() != null) + { + updateKBAction = false; + } else { + updateKBAction = true; + } + } if (SynthLookAndFeel.shouldUpdateStyle(evt)) { - updateStyle((JTextComponent)evt.getSource()); + updateStyle((JTextComponent)evt.getSource(), updateKBAction); } super.propertyChange(evt); } @@ -245,7 +254,7 @@ public class SynthTextFieldUI extends BasicTextFieldUI implements SynthUI { protected void installDefaults() { // Installs the text cursor on the component super.installDefaults(); - updateStyle(getComponent()); + updateStyle(getComponent(), true); getComponent().addFocusListener(handler); } diff --git a/jdk/test/javax/swing/plaf/nimbus/TestNimbusOverride.java b/jdk/test/javax/swing/plaf/nimbus/TestNimbusOverride.java new file mode 100644 index 00000000000..17a9d10a9d2 --- /dev/null +++ b/jdk/test/javax/swing/plaf/nimbus/TestNimbusOverride.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 8043315 + * @summary Verifies if setting Nimbus.Overrides property affects + * keymap installation + * @run main TestNimbusOverride + */ +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.event.ActionEvent; +import java.awt.Robot; +import java.awt.event.KeyEvent; + +import javax.swing.AbstractAction; +import javax.swing.JEditorPane; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; +import javax.swing.UIDefaults; +import javax.swing.UIManager; +import javax.swing.text.Keymap; + + +public class TestNimbusOverride extends JFrame +{ + private static TestNimbusOverride tf; + private static boolean passed = false; + + public static void main(String [] args) throws Exception { + Robot robot = new Robot(); + SwingUtilities.invokeAndWait(() -> { + try { + UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel"); + } catch (Exception e) { + throw new RuntimeException(e); + } + tf = new TestNimbusOverride(); + tf.pack(); + tf.setVisible(true); + }); + robot.setAutoDelay(100); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_SPACE); + robot.keyRelease(KeyEvent.VK_SPACE); + robot.waitForIdle(); + SwingUtilities.invokeAndWait(() -> tf.dispose()); + if (!passed) { + throw new RuntimeException( + "Setting Nimbus.Overrides property affects custom keymap installation"); + } + } + + public TestNimbusOverride() + { + setDefaultCloseOperation(DISPOSE_ON_CLOSE); + + /* + * Create a frame containing a JEditorPane, and override the action for the space bar to show + * a dialog. + */ + JEditorPane pp = new JEditorPane(); + UIDefaults defaults = new UIDefaults(); + + pp.putClientProperty("Nimbus.Overrides", defaults); + + JPanel contentPanel = new JPanel(); + contentPanel.setLayout(new BorderLayout()); + setContentPane(contentPanel); + + contentPanel.setPreferredSize(new Dimension(400, 300)); + contentPanel.add(pp, BorderLayout.CENTER); + + Keymap origKeymap = pp.getKeymap(); + Keymap km = JEditorPane.addKeymap("Test keymap", origKeymap); + + km.addActionForKeyStroke(KeyStroke.getKeyStroke(' '), new AbstractAction("SHOW_SPACE") { + @Override + public void actionPerformed(ActionEvent e) + { + passed = true; + } + }); + + pp.setKeymap(km); + } +} From e8693a14fbca796945ced8586977d4439f8257ce Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Fri, 30 Jun 2017 11:03:44 +0530 Subject: [PATCH 14/98] 8182402: Tooltip for Desktop button is in English when non-English locale is set Reviewed-by: azvegint --- .../classes/javax/swing/plaf/metal/MetalFileChooserUI.java | 5 ----- .../classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java | 3 --- 2 files changed, 8 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java index 32db72db408..d86732b34f3 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java @@ -281,11 +281,6 @@ public class MetalFileChooserUI extends BasicFileChooserUI { // Home Button File homeDir = fsv.getHomeDirectory(); String toolTipText = homeFolderToolTipText; - if (fsv.isRoot(homeDir)) { - toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop". - } - - JButton b = new JButton(homeFolderIcon); diff --git a/jdk/src/java.desktop/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java b/jdk/src/java.desktop/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java index 3197fd82cd4..ddab1198c3c 100644 --- a/jdk/src/java.desktop/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java +++ b/jdk/src/java.desktop/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java @@ -260,9 +260,6 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI { // Home Button File homeDir = fsv.getHomeDirectory(); String toolTipText = homeFolderToolTipText; - if (fsv.isRoot(homeDir)) { - toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop". - } JButton b = new JButton(homeFolderIcon); b.setToolTipText(toolTipText); From 15fcd07725a131f2f6600583138aa9418b7ed9d7 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Sat, 1 Jul 2017 09:56:02 +0530 Subject: [PATCH 15/98] 8075063: Context menu closes on mouse scroll Reviewed-by: ssadetsky --- .../swing/plaf/basic/BasicPopupMenuUI.java | 9 +- .../unix/classes/sun/awt/X11/XWindowPeer.java | 30 ++- .../8075063/ContextMenuScrollTest.java | 197 ++++++++++++++++++ 3 files changed, 230 insertions(+), 6 deletions(-) create mode 100644 jdk/test/javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java index d98a5c703c8..3dc345b5c87 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicPopupMenuUI.java @@ -917,9 +917,14 @@ public class BasicPopupMenuUI extends PopupMenuUI { processMouseEvent(me); break; case MouseEvent.MOUSE_WHEEL: + // If the scroll is done inside a combobox, menuitem, + // or inside a Popup#HeavyWeightWindow or inside a frame + // popup should not close which is the standard behaviour if (isInPopup(src) - || ((src instanceof JComboBox) && ((JComboBox) src).isPopupVisible())) { - + || ((src instanceof JComboBox) && ((JComboBox) src).isPopupVisible()) + || ((src instanceof JWindow) && ((JWindow)src).isVisible()) + || ((src instanceof JMenuItem) && ((JMenuItem)src).isVisible()) + || (src instanceof JFrame)) { return; } cancelPopupMenu(); diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java index a3865dbcefe..05fe8163e93 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindowPeer.java @@ -2306,7 +2306,11 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, if (grabLog.isLoggable(PlatformLogger.Level.FINE)) { grabLog.fine("Generating UngrabEvent on {0} because not inside of shell", this); } - postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); + // Do not post Ungrab Event for mouse scroll + if ((xbe.get_button() != XConstants.buttons[3]) + && (xbe.get_button() != XConstants.buttons[4])) { + postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); + } return; } } @@ -2327,14 +2331,26 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, if (grabLog.isLoggable(PlatformLogger.Level.FINE)) { grabLog.fine("Generating UngrabEvent on {0} because hierarchy ended", this); } - postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); + // For mouse wheel event, do not send UngrabEvent + if (xbe.get_type() != XConstants.ButtonPress) { + postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); + } else if ((xbe.get_button() != XConstants.buttons[3]) + && (xbe.get_button() != XConstants.buttons[4])) { + postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); + } } } else { // toplevel is null - outside of hierarchy if (grabLog.isLoggable(PlatformLogger.Level.FINE)) { grabLog.fine("Generating UngrabEvent on {0} because toplevel is null", this); } - postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); + // For mouse wheel event, do not send UngrabEvent + if (xbe.get_type() != XConstants.ButtonPress) { + postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); + } else if ((xbe.get_button() != XConstants.buttons[3]) + && (xbe.get_button() != XConstants.buttons[4])) { + postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); + } return; } } else { @@ -2342,7 +2358,13 @@ class XWindowPeer extends XPanelPeer implements WindowPeer, if (grabLog.isLoggable(PlatformLogger.Level.FINE)) { grabLog.fine("Generating UngrabEvent on because target is null {0}", this); } - postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); + // For mouse wheel event, do not send UngrabEvent + if (xbe.get_type() != XConstants.ButtonPress) { + postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); + } else if ((xbe.get_button() != XConstants.buttons[3]) + && (xbe.get_button() != XConstants.buttons[4])) { + postEventToEventQueue(new sun.awt.UngrabEvent(getEventSource())); + } return; } } diff --git a/jdk/test/javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java b/jdk/test/javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java new file mode 100644 index 00000000000..fc38da45962 --- /dev/null +++ b/jdk/test/javax/swing/JPopupMenu/8075063/ContextMenuScrollTest.java @@ -0,0 +1,197 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @key headful + * @bug 8075063 + * @summary Verifies if Context menu closes on mouse scroll + * @run main ContextMenuScrollTest + */ +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.JSeparator; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; + +public class ContextMenuScrollTest extends JPopupMenu +{ + private JMenuItem undo; + private JMenuItem redo; + private JMenuItem cut; + private JMenuItem copy; + private JMenuItem paste; + private JMenuItem delete; + private JMenuItem selectAll; + private final Robot robot; + private JFrame frame; + private JMenuBar menuBar; + private JMenu menu; + private volatile Point p = null; + private volatile Dimension d = null; + + public static void main(String[] args) throws Exception { + new ContextMenuScrollTest(); + } + void blockTillDisplayed(JComponent comp) throws Exception { + while (p == null) { + try { + SwingUtilities.invokeAndWait(() -> { + p = comp.getLocationOnScreen(); + d = menu.getSize(); + }); + } catch (IllegalStateException e) { + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + } + } + } + } + + public ContextMenuScrollTest() throws Exception + { + robot = new Robot(); + robot.setAutoDelay(200); + try { + SwingUtilities.invokeAndWait(()->createGUI()); + blockTillDisplayed(menu); + robot.waitForIdle(); + + robot.mouseMove(p.x + d.width/2, p.y + d.height/2); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.waitForIdle(); + + System.out.println("popmenu visible " + menu.isPopupMenuVisible()); + robot.mouseWheel(1); + robot.waitForIdle(); + System.out.println("popmenu visible " + menu.isPopupMenuVisible()); + if (!menu.isPopupMenuVisible()) { + throw new RuntimeException("Popup closes on mouse scroll"); + } + } finally { + SwingUtilities.invokeAndWait(()->frame.dispose()); + } + } + + public void createGUI() { + frame = new JFrame(); + menuBar = new JMenuBar(); + menu = new JMenu("Menu"); + menuBar.add(menu); + + undo = new JMenuItem("Undo"); + undo.setEnabled(false); + undo.setAccelerator(KeyStroke.getKeyStroke("control Z")); + undo.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent event) { + } + }); + + menu.add(undo); + + redo = new JMenuItem("Redo"); + redo.setEnabled(false); + redo.setAccelerator(KeyStroke.getKeyStroke("control Y")); + redo.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent event) { + } + }); + menu.add(redo); + + menu.add(new JSeparator()); + + cut = new JMenuItem("Cut"); + cut.setEnabled(false); + cut.setAccelerator(KeyStroke.getKeyStroke("control X")); + cut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent event) { + } + }); + + menu.add(cut); + + copy = new JMenuItem("Copy"); + copy.setEnabled(false); + copy.setAccelerator(KeyStroke.getKeyStroke("control C")); + copy.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent event) { + } + }); + + menu.add(copy); + + paste = new JMenuItem("Paste"); + paste.setEnabled(false); + paste.setAccelerator(KeyStroke.getKeyStroke("control V")); + paste.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent event) { + } + }); + + menu.add(paste); + + delete = new JMenuItem("Delete"); + delete.setEnabled(false); + delete.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); + delete.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent event) { + } + }); + + menu.add(delete); + + menu.add(new JSeparator()); + + selectAll = new JMenuItem("Select All"); + selectAll.setEnabled(false); + selectAll.setAccelerator(KeyStroke.getKeyStroke("control A")); + selectAll.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent event) { + } + }); + menu.add(selectAll); + frame.setJMenuBar(menuBar); + + frame.pack(); + frame.setVisible(true); + } +} From f3abf05b31893b9a066a436e2c4a587f8899ab10 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Sat, 1 Jul 2017 10:00:15 +0530 Subject: [PATCH 16/98] 8182577: Exception when Tab key moves focus to a JCheckbox with a custom ButtonModel Reviewed-by: ssadetsky, serb, kcr --- .../classes/javax/swing/ButtonModel.java | 15 ++++ .../classes/javax/swing/JToggleButton.java | 4 +- .../swing/LayoutFocusTraversalPolicy.java | 11 ++- .../DefaultButtonModelCrashTest.java | 85 +++++++++++++++++++ 4 files changed, 107 insertions(+), 8 deletions(-) create mode 100644 jdk/test/javax/swing/DefaultButtonModel/DefaultButtonModelCrashTest.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/ButtonModel.java b/jdk/src/java.desktop/share/classes/javax/swing/ButtonModel.java index 85ba48f6ba2..62aaa265548 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/ButtonModel.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/ButtonModel.java @@ -198,6 +198,21 @@ public interface ButtonModel extends ItemSelectable { */ public void setGroup(ButtonGroup group); + /** + * Returns the group that the button belongs to. + * Normally used with radio buttons, which are mutually + * exclusive within their group. + * + * @implSpec The default implementation of this method returns {@code null}. + * Subclasses should return the group set by setGroup(). + * + * @return the ButtonGroup that the button belongs to + * @since 10 + */ + default ButtonGroup getGroup() { + return null; + } + /** * Adds an ActionListener to the model. * diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JToggleButton.java b/jdk/src/java.desktop/share/classes/javax/swing/JToggleButton.java index b66465d1bd9..e15efaa5d62 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JToggleButton.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JToggleButton.java @@ -219,8 +219,8 @@ public class JToggleButton extends AbstractButton implements Accessible { case TRAVERSAL_BACKWARD: ButtonModel model = getModel(); JToggleButton selection = this; - if (model instanceof DefaultButtonModel) { - ButtonGroup group = ((DefaultButtonModel) model).getGroup(); + if (model != null) { + ButtonGroup group = model.getGroup(); if (group != null && group.getSelection() != null && !group.isSelected(model)) { Iterator iterator = diff --git a/jdk/src/java.desktop/share/classes/javax/swing/LayoutFocusTraversalPolicy.java b/jdk/src/java.desktop/share/classes/javax/swing/LayoutFocusTraversalPolicy.java index c976af640ee..6bc50220a1d 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/LayoutFocusTraversalPolicy.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/LayoutFocusTraversalPolicy.java @@ -238,19 +238,18 @@ public class LayoutFocusTraversalPolicy extends SortingFocusTraversalPolicy } else if (aComponent instanceof JComponent) { if (SunToolkit.isInstanceOf(aComponent, "javax.swing.JToggleButton")) { - JToggleButton.ToggleButtonModel model = - (JToggleButton.ToggleButtonModel) ((JToggleButton) - aComponent).getModel(); + ButtonModel model = ((JToggleButton)aComponent).getModel(); if (model != null) { ButtonGroup group = model.getGroup(); if (group != null) { Enumeration elements = - group.getElements(); + group.getElements(); int idx = 0; while (elements.hasMoreElements()) { AbstractButton member = elements.nextElement(); - if (member.isVisible() && member.isDisplayable() && - member.isEnabled() && member.isFocusable()) { + if (member instanceof JToggleButton && + member.isVisible() && member.isDisplayable() && + member.isEnabled() && member.isFocusable()) { if (member == aComponent) { return idx == 0; } diff --git a/jdk/test/javax/swing/DefaultButtonModel/DefaultButtonModelCrashTest.java b/jdk/test/javax/swing/DefaultButtonModel/DefaultButtonModelCrashTest.java new file mode 100644 index 00000000000..eb68e59650a --- /dev/null +++ b/jdk/test/javax/swing/DefaultButtonModel/DefaultButtonModelCrashTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 8182577 + * @summary Verifies if moving focus via custom ButtonModel causes crash + * @run main DefaultButtonModelCrashTest + */ +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import javax.swing.ButtonModel; +import javax.swing.DefaultButtonModel; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; + +public class DefaultButtonModelCrashTest { + private JFrame frame = null; + private JPanel panel; + private volatile Point p = null; + + public static void main(String[] args) throws Exception { + new DefaultButtonModelCrashTest(); + } + + public DefaultButtonModelCrashTest() throws Exception { + try { + Robot robot = new Robot(); + robot.setAutoDelay(200); + SwingUtilities.invokeAndWait(() -> go()); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); + robot.delay(100); + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); + } finally { + SwingUtilities.invokeAndWait(()->frame .dispose()); + } + } + + private void go() { + + frame = new JFrame(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + Container contentPane = frame.getContentPane(); + ButtonModel model = new DefaultButtonModel(); + + JCheckBox check = new JCheckBox("a bit broken"); + check.setModel(model); + panel = new JPanel(new BorderLayout()); + panel.add(new JTextField("Press Tab (twice?)"), BorderLayout.NORTH); + panel.add(check); + contentPane.add(panel); + frame.setLocationRelativeTo(null); + frame.pack(); + frame.setVisible(true); + } +} From 8143715e7e1c7e1c72b7d209422b399750501335 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Tue, 4 Jul 2017 13:37:02 +0530 Subject: [PATCH 17/98] 7190539: Nimbus LaF: JPopupMenu reacts on Ctrl+Enter Reviewed-by: ssadetsky, azvegint --- .../swing/plaf/motif/MotifLookAndFeel.java | 1 + .../swing/plaf/synth/SynthLookAndFeel.java | 1 + .../swing/JPopupMenu/4870644/bug4870644.java | 162 ++++++++++++++++++ 3 files changed, 164 insertions(+) create mode 100644 jdk/test/javax/swing/JPopupMenu/4870644/bug4870644.java diff --git a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java index dc459e81be5..3b4eeefadaa 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java +++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifLookAndFeel.java @@ -1246,6 +1246,7 @@ public class MotifLookAndFeel extends BasicLookAndFeel "RIGHT", "selectChild", "KP_RIGHT", "selectChild", "ENTER", "return", + "ctrl ENTER", "return", "SPACE", "return" }, diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java index 2cbc01142b3..02150052124 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java @@ -683,6 +683,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel { "RIGHT", "selectChild", "KP_RIGHT", "selectChild", "ENTER", "return", + "ctrl ENTER", "return", "SPACE", "return" }); table.put("PopupMenu.selectedWindowInputMapBindings.RightToLeft", diff --git a/jdk/test/javax/swing/JPopupMenu/4870644/bug4870644.java b/jdk/test/javax/swing/JPopupMenu/4870644/bug4870644.java new file mode 100644 index 00000000000..9357ae1ea3b --- /dev/null +++ b/jdk/test/javax/swing/JPopupMenu/4870644/bug4870644.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @key headful + * @bug 4870644 7190539 + * @summary Default button responds to CTRL-ENTER while popup menu is active. + * @run main bug4870644 + */ +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import javax.swing.AbstractAction; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + + +public class bug4870644 { + JButton b1, b2, b3; + JFrame frame; + JMenu menu; + JPopupMenu popup; + static Robot robot; + static boolean passed = true; + private volatile Point p = null; + private volatile Dimension d = null; + void blockTillDisplayed(JComponent comp) throws Exception { + while (p == null) { + try { + SwingUtilities.invokeAndWait(() -> { + p = comp.getLocationOnScreen(); + d = comp.getSize(); + }); + } catch (IllegalStateException e) { + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + } + } + } + } + + private static void setLookAndFeel(final UIManager.LookAndFeelInfo laf) { + try { + UIManager.setLookAndFeel(laf.getClassName()); + System.out.println("LookAndFeel: " + laf.getClassName()); + } catch (ClassNotFoundException | InstantiationException | + UnsupportedLookAndFeelException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + public static void main(String[] args) throws Exception { + robot = new Robot(); + robot.setAutoDelay(100); + for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { + try { + SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf)); + System.out.println("Test for LookAndFeel " + laf.getClassName()); + new bug4870644(); + System.out.println("Test passed for LookAndFeel " + laf.getClassName()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + public bug4870644() throws Exception { + + SwingUtilities.invokeAndWait(() -> { + JMenuBar menuBar = new JMenuBar(); + menu = new JMenu("Menu"); + menuBar.add(menu); + JMenuItem menuItem = new JMenuItem("Item"); + menu.add(menuItem); + menu.add(new JMenuItem("Item 2")); + frame = new JFrame("test"); + frame.setJMenuBar(menuBar); + + b1 = new JButton("One"); + b2 = new JButton("Two"); + b3 = new JButton("Default"); + b3.addActionListener(new AbstractAction() { + public void actionPerformed(ActionEvent e) { + passed = false; + } + }); + frame.getContentPane().add(b1, BorderLayout.NORTH); + frame.getContentPane().add(b2, BorderLayout.CENTER); + frame.getContentPane().add(b3, BorderLayout.SOUTH); + frame.getRootPane().setDefaultButton(b3); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.pack(); + frame.setVisible(true); + }); + + blockTillDisplayed(b1); + robot.waitForIdle(); + + robot.delay(500); + robot.mouseMove(p.x + d.width-1, p.y + d.height/2); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_F10); + robot.keyRelease(KeyEvent.VK_F10); + robot.keyPress(KeyEvent.VK_DOWN); + robot.keyRelease(KeyEvent.VK_DOWN); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> { + popup = menu.getPopupMenu(); + }); + + blockTillDisplayed(popup); + robot.waitForIdle(); + robot.mouseMove(p.x + d.width-1, p.y + d.height/2); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.keyPress(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_ENTER); + robot.keyRelease(KeyEvent.VK_CONTROL); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> frame.dispose()); + if(!passed) { + String cause = "Default button reacted on \"ctrl ENTER\" while menu is active."; + throw new RuntimeException(cause); + } + } +} From 3730163d9d73fa8544e3daae487bcf3d4244a4ce Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Fri, 30 Jun 2017 16:32:18 +0200 Subject: [PATCH 18/98] 8183286: Some java/awt and javax/swing tests miss headful jtreg keyword Reviewed-by: serb, clanger --- .../awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java | 1 + .../java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java | 1 + jdk/test/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java | 3 ++- jdk/test/java/awt/PopupMenu/PopupMenuLocation.java | 1 + .../java/awt/Robot/HiDPIScreenCapture/ScreenCaptureTest.java | 1 + .../MultiScreenRobotPosition/MultiScreenRobotPosition.java | 1 + .../java/awt/Window/WindowDeadlockTest/WindowDeadlockTest.java | 1 + jdk/test/java/awt/font/TextLayout/ArabicDiacriticTest.java | 3 ++- .../javax/accessibility/JList/AccessibleJListChildNPETest.java | 1 + .../javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java | 1 + .../javax/swing/JFrame/AlwaysOnTop/AlwaysOnTopImeTest.java | 1 + .../swing/JLightweightFrame/JLightweightFrameRoundTest.java | 3 ++- .../JRadioButton/ButtonGroupFocus/ButtonGroupFocusTest.java | 3 ++- jdk/test/javax/swing/JTree/4633594/JTreeFocusTest.java | 1 + .../JComboBoxPopupLocation/JComboBoxPopupLocation.java | 1 + jdk/test/javax/swing/text/html/StyleSheet/bug4936917.java | 3 ++- 16 files changed, 21 insertions(+), 5 deletions(-) diff --git a/jdk/test/java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java b/jdk/test/java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java index 88f01802428..37396a79fa4 100644 --- a/jdk/test/java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java +++ b/jdk/test/java/awt/Choice/ChoicePopupLocation/ChoicePopupLocation.java @@ -36,6 +36,7 @@ import java.awt.event.InputEvent; /** * @test + * @key headful * @bug 8176448 * @run main/timeout=300 ChoicePopupLocation */ diff --git a/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java b/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java index 6f0a6317f1b..1d678c915c9 100644 --- a/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java +++ b/jdk/test/java/awt/Dialog/DialogAboveFrame/DialogAboveFrameTest.java @@ -23,6 +23,7 @@ /* * @test + * @key headful * @bug 8169589 8171909 * @summary Activating a dialog puts to back another dialog owned by the same frame * @author Dmitry Markov diff --git a/jdk/test/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java b/jdk/test/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java index eb20f189a7e..b4acec4c563 100644 --- a/jdk/test/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java +++ b/jdk/test/java/awt/Frame/ObscuredFrame/ObscuredFrameTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -23,6 +23,7 @@ /* * @test + * @key headful * @bug 8171952 * @summary Tests that getMousePosition() returns null for obscured component. * @author Dmitry Markov diff --git a/jdk/test/java/awt/PopupMenu/PopupMenuLocation.java b/jdk/test/java/awt/PopupMenu/PopupMenuLocation.java index ec1714f56ea..713eb1d706a 100644 --- a/jdk/test/java/awt/PopupMenu/PopupMenuLocation.java +++ b/jdk/test/java/awt/PopupMenu/PopupMenuLocation.java @@ -38,6 +38,7 @@ import java.awt.event.*; /** * @test + * @key headful * @bug 8160270 * @run main/timeout=300 PopupMenuLocation */ diff --git a/jdk/test/java/awt/Robot/HiDPIScreenCapture/ScreenCaptureTest.java b/jdk/test/java/awt/Robot/HiDPIScreenCapture/ScreenCaptureTest.java index 7be3a918117..50e01c6376e 100644 --- a/jdk/test/java/awt/Robot/HiDPIScreenCapture/ScreenCaptureTest.java +++ b/jdk/test/java/awt/Robot/HiDPIScreenCapture/ScreenCaptureTest.java @@ -23,6 +23,7 @@ /* * @test + * @key headful * @bug 8162959 * @summary Validate output of createMultiResolutionScreenCapture * new API which returns MultiResolutionImage. diff --git a/jdk/test/java/awt/Robot/MultiScreenRobotPosition/MultiScreenRobotPosition.java b/jdk/test/java/awt/Robot/MultiScreenRobotPosition/MultiScreenRobotPosition.java index eb9d1b2f117..f1ab6078dbc 100644 --- a/jdk/test/java/awt/Robot/MultiScreenRobotPosition/MultiScreenRobotPosition.java +++ b/jdk/test/java/awt/Robot/MultiScreenRobotPosition/MultiScreenRobotPosition.java @@ -31,6 +31,7 @@ import java.awt.event.MouseEvent; /** * @test + * @key headful * @bug 8176009 */ public class MultiScreenRobotPosition { diff --git a/jdk/test/java/awt/Window/WindowDeadlockTest/WindowDeadlockTest.java b/jdk/test/java/awt/Window/WindowDeadlockTest/WindowDeadlockTest.java index 01e4783adc4..a49993d9df0 100644 --- a/jdk/test/java/awt/Window/WindowDeadlockTest/WindowDeadlockTest.java +++ b/jdk/test/java/awt/Window/WindowDeadlockTest/WindowDeadlockTest.java @@ -23,6 +23,7 @@ /* * @test + * @key headful * @bug 8176490 * @summary Tests that there is no hang or deadlock when the visibility * of parent and child windows is changed. diff --git a/jdk/test/java/awt/font/TextLayout/ArabicDiacriticTest.java b/jdk/test/java/awt/font/TextLayout/ArabicDiacriticTest.java index b060707131f..de1fb1373db 100644 --- a/jdk/test/java/awt/font/TextLayout/ArabicDiacriticTest.java +++ b/jdk/test/java/awt/font/TextLayout/ArabicDiacriticTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -22,6 +22,7 @@ */ /* @test + * @key headful * @summary verify Arab Diacritic Positioning * @bug 8168759 */ diff --git a/jdk/test/javax/accessibility/JList/AccessibleJListChildNPETest.java b/jdk/test/javax/accessibility/JList/AccessibleJListChildNPETest.java index 118519565d6..fbdb5c87551 100644 --- a/jdk/test/javax/accessibility/JList/AccessibleJListChildNPETest.java +++ b/jdk/test/javax/accessibility/JList/AccessibleJListChildNPETest.java @@ -35,6 +35,7 @@ import javax.swing.SwingUtilities; import javax.swing.WindowConstants; /* @test + @key headful @bug 8076249 @summary NPE in AccessBridge while editing JList model @author Mikhail Cherkasov diff --git a/jdk/test/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java b/jdk/test/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java index bff91376ad2..12c69288e6a 100644 --- a/jdk/test/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java +++ b/jdk/test/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java @@ -30,6 +30,7 @@ import javax.swing.SwingUtilities; /** * @test + * @key headful * @bug 8175301 * @summary Java GUI hangs on Windows when Display set to 125% * @run main/othervm -Dsun.java2d.uiScale=2 ScaledFrameBackgroundTest diff --git a/jdk/test/javax/swing/JFrame/AlwaysOnTop/AlwaysOnTopImeTest.java b/jdk/test/javax/swing/JFrame/AlwaysOnTop/AlwaysOnTopImeTest.java index a8d375106b9..5197650b382 100644 --- a/jdk/test/javax/swing/JFrame/AlwaysOnTop/AlwaysOnTopImeTest.java +++ b/jdk/test/javax/swing/JFrame/AlwaysOnTop/AlwaysOnTopImeTest.java @@ -23,6 +23,7 @@ /** * @test + * @key headful * @bug 8179665 * @summary [Windows] java.awt.IllegalComponentStateException: component must * be showing on the screen to determine its location diff --git a/jdk/test/javax/swing/JLightweightFrame/JLightweightFrameRoundTest.java b/jdk/test/javax/swing/JLightweightFrame/JLightweightFrameRoundTest.java index f02bcc0e0dd..6a96241dd88 100644 --- a/jdk/test/javax/swing/JLightweightFrame/JLightweightFrameRoundTest.java +++ b/jdk/test/javax/swing/JLightweightFrame/JLightweightFrameRoundTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -23,6 +23,7 @@ /* * @test + * @key headful * @bug 8170387 * @summary JLightweightFrame#syncCopyBuffer() may throw IOOBE * @modules java.desktop/sun.swing diff --git a/jdk/test/javax/swing/JRadioButton/ButtonGroupFocus/ButtonGroupFocusTest.java b/jdk/test/javax/swing/JRadioButton/ButtonGroupFocus/ButtonGroupFocusTest.java index f7118aa3fba..c696b166dd0 100644 --- a/jdk/test/javax/swing/JRadioButton/ButtonGroupFocus/ButtonGroupFocusTest.java +++ b/jdk/test/javax/swing/JRadioButton/ButtonGroupFocus/ButtonGroupFocusTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -22,6 +22,7 @@ */ /* @test + * @key headful * @bug 8074883 * @summary Tab key should move to focused button in a button group * @run main ButtonGroupFocusTest diff --git a/jdk/test/javax/swing/JTree/4633594/JTreeFocusTest.java b/jdk/test/javax/swing/JTree/4633594/JTreeFocusTest.java index 800bf10be4d..1af659362e1 100644 --- a/jdk/test/javax/swing/JTree/4633594/JTreeFocusTest.java +++ b/jdk/test/javax/swing/JTree/4633594/JTreeFocusTest.java @@ -21,6 +21,7 @@ * questions. */ /* @test + @key headful @bug 4633594 8172012 @summary No way to pass focus from a JTree to a GUI placed inside the tree node @run main JTreeFocusTest diff --git a/jdk/test/javax/swing/plaf/basic/BasicComboPopup/JComboBoxPopupLocation/JComboBoxPopupLocation.java b/jdk/test/javax/swing/plaf/basic/BasicComboPopup/JComboBoxPopupLocation/JComboBoxPopupLocation.java index 20db73fa371..588abd90861 100644 --- a/jdk/test/javax/swing/plaf/basic/BasicComboPopup/JComboBoxPopupLocation/JComboBoxPopupLocation.java +++ b/jdk/test/javax/swing/plaf/basic/BasicComboPopup/JComboBoxPopupLocation/JComboBoxPopupLocation.java @@ -39,6 +39,7 @@ import javax.swing.UIManager; /** * @test + * @key headful * @bug 8176448 * @run main/timeout=600 JComboBoxPopupLocation */ diff --git a/jdk/test/javax/swing/text/html/StyleSheet/bug4936917.java b/jdk/test/javax/swing/text/html/StyleSheet/bug4936917.java index e490f93baf0..b81d7ce2cf3 100644 --- a/jdk/test/javax/swing/text/html/StyleSheet/bug4936917.java +++ b/jdk/test/javax/swing/text/html/StyleSheet/bug4936917.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -21,6 +21,7 @@ * questions. */ /* @test + @key headful @bug 4936917 7190578 8174717 @summary Tests if background is correctly painted when has css margins @author Denis Sharypov From ec836d6692f2425785836836fdacf4303c0ff65d Mon Sep 17 00:00:00 2001 From: Shashidhara Veerabhadraiah Date: Thu, 6 Jul 2017 16:45:56 +0530 Subject: [PATCH 19/98] 8165213: [TESTBUG] [PIT] consistent failure of a new regtest for 8163193 Reviewed-by: psadhukhan, serb --- .../8163193/ButtonGradientTest.java | 58 ++++++++++++++----- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/jdk/test/javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java b/jdk/test/javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java index 8860d768a0d..ace98281cb5 100644 --- a/jdk/test/javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java +++ b/jdk/test/javax/swing/plaf/metal/MetalGradient/8163193/ButtonGradientTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -21,13 +21,17 @@ * questions. */ -import java.awt.BorderLayout; +import java.awt.Image; +import java.awt.Robot; +import java.awt.Rectangle; import java.awt.Color; +import java.awt.Point; +import java.awt.Dimension; import java.awt.GradientPaint; import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.Robot; +import java.awt.BorderLayout; import java.awt.image.BufferedImage; +import java.awt.image.MultiResolutionImage; import java.util.List; import javax.swing.JButton; import javax.swing.JFrame; @@ -38,18 +42,20 @@ import javax.swing.plaf.metal.MetalLookAndFeel; /* * @test - * @bug 8163193 + * @bug 8163193 8165213 * @key headful * @summary Metal L&F gradient is lighter on HiDPI display * @run main/othervm -Dsun.java2d.uiScale=2 ButtonGradientTest */ public class ButtonGradientTest { - private static JFrame frame; private static JButton button; + private static List images; + private static Robot robot; public static void main(String[] args) throws Exception { try { + robot = new Robot(); testGradient(); } finally { SwingUtilities.invokeAndWait(() -> { @@ -61,11 +67,10 @@ public class ButtonGradientTest { } private static void testGradient() throws Exception { - Robot robot = new Robot(); - robot.setAutoDelay(50); - + // Create and show the GUI SwingUtilities.invokeAndWait(ButtonGradientTest::createAndShowGUI); robot.waitForIdle(); + robot.delay(500); Rectangle rect = getButtonBounds(); List gradient = (List) UIManager.get("Button.gradient"); @@ -73,11 +78,15 @@ public class ButtonGradientTest { Color c1 = (Color) gradient.get(2); Color c2 = (Color) gradient.get(3); int mid = (int) (ratio * rect.height); - + // Get the expected gradient color Color gradientColor = getGradientColor(rect.width, mid, c1, c2); + + // Get color from robot captured hidpi image of the button + getImageFromRobot(); int x = rect.x + rect.width / 2; int y = rect.y + mid / 2; - Color buttonColor = robot.getPixelColor(x, y); + Color buttonColor = new Color(((BufferedImage)(images.get(1))).getRGB( + (int)(x), (int)(y))); if (!similarColors(buttonColor, gradientColor)) { throw new RuntimeException("Button gradient is changed!"); @@ -103,6 +112,26 @@ public class ButtonGradientTest { frame.setVisible(true); } + private static void getImageFromRobot() { + try { + Point butLoc = button.getLocationOnScreen(); + Dimension butSize = button.getSize(); + MultiResolutionImage multiResolutionImage = + robot.createMultiResolutionScreenCapture( + new Rectangle((int)butLoc.getX(), + (int)butLoc.getY(), (int)butSize.getWidth(), + (int)butSize.getHeight())); + images = multiResolutionImage.getResolutionVariants(); + } catch (Exception e) { + throw new RuntimeException(e); + } + + if(images.size() < 2) { + throw new RuntimeException("HiDpi Image not captured - " + + "Check is this HiDpi display system?"); + } + } + private static Rectangle getButtonBounds() throws Exception { Rectangle[] rectangles = new Rectangle[1]; SwingUtilities.invokeAndWait(() -> { @@ -113,7 +142,8 @@ public class ButtonGradientTest { } private static Color getGradientColor(int w, int h, Color c1, Color c2) { - GradientPaint gradient = new GradientPaint(0, 0, c1, 0, h, c2, true); + GradientPaint gradient = new GradientPaint(0, 0, c1, 0, h, c2, + true); BufferedImage img = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g = img.createGraphics(); g.setPaint(gradient); @@ -129,6 +159,6 @@ public class ButtonGradientTest { } private static boolean similar(int i1, int i2) { - return Math.abs(i2 - i1) < 7; + return Math.abs(i2 - i1) < 6; } -} +} \ No newline at end of file From 54ad5390d068c49d8ce18ddffa213ccfe3200c37 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Thu, 6 Jul 2017 15:54:39 -0700 Subject: [PATCH 20/98] 8178403: DirectAudio in JavaSound may hang and leak Reviewed-by: prr, alitvinov --- .../sun/media/sound/DirectAudioDevice.java | 12 ++++------- jdk/test/ProblemList.txt | 2 -- .../sound/sampled/Clip/ClipCloseLoss.java | 21 +++++++++++-------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java index 414180e6c7f..c1f6b0099b8 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -1351,18 +1351,14 @@ final class DirectAudioDevice extends AbstractMixer { // pre-empted while another thread changes doIO and notifies, // before we wait (so we sleep in wait forever). synchronized(lock) { - if (!doIO) { + while (!doIO && thread == curThread) { try { lock.wait(); - } catch(InterruptedException ie) { - } finally { - if (thread != curThread) { - break; - } + } catch (InterruptedException ignored) { } } } - while (doIO) { + while (doIO && thread == curThread) { if (newFramePosition >= 0) { clipBytePosition = newFramePosition * frameSize; newFramePosition = -1; diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index e063fe759ea..35c2f21f907 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -223,8 +223,6 @@ sun/security/ssl/X509KeyManager/PreferredKey.java 8176354 generic- # jdk_sound javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java 8178401 windows-all -javax/sound/sampled/Clip/ClipCloseLoss.java 8178403 generic-all - javax/sound/sampled/DirectAudio/bug6372428.java 8055097 generic-all javax/sound/sampled/Clip/bug5070081.java 8055097 generic-all javax/sound/sampled/DataLine/LongFramePosition.java 8055097 generic-all diff --git a/jdk/test/javax/sound/sampled/Clip/ClipCloseLoss.java b/jdk/test/javax/sound/sampled/Clip/ClipCloseLoss.java index 56b046163b0..e0adc55afcc 100644 --- a/jdk/test/javax/sound/sampled/Clip/ClipCloseLoss.java +++ b/jdk/test/javax/sound/sampled/Clip/ClipCloseLoss.java @@ -33,10 +33,9 @@ import javax.sound.sampled.Mixer; /** * @test - * @bug 4946913 + * @bug 4946913 8178403 * @summary DirectClip doesn't kill the thread correctly, sometimes * @run main/othervm ClipCloseLoss - * @key intermittent */ public class ClipCloseLoss { static int frameCount = 441000; // lets say 10 seconds @@ -47,7 +46,7 @@ public class ClipCloseLoss { static int success = 0; static boolean failed = false; - public static void run(Mixer m) { + public static void run(Mixer m, long sleep) { Clip clip = null; try { if (m == null) { @@ -69,6 +68,8 @@ public class ClipCloseLoss { clip.open(new AudioInputStream(bais, format, frameCount)); out(" clip.close()"); + // emulates a different delay between open() and close() + Thread.sleep(sleep); //long t = System.currentTimeMillis(); clip.close(); //if (System.currentTimeMillis() - t > 1950) { @@ -107,13 +108,15 @@ public class ClipCloseLoss { public static void main(String[] args) throws Exception { if (isSoundcardInstalled()) { bais.mark(0); - run(null); Mixer.Info[] infos = AudioSystem.getMixerInfo(); - for (int i = 0; i Date: Mon, 10 Jul 2017 14:55:29 +0530 Subject: [PATCH 21/98] 6919529: NPE from MultiUIDefaults.getUIError Reviewed-by: aghaisas, psadhukhan, serb --- .../classes/javax/swing/MultiUIDefaults.java | 2 +- .../NPECheck/MultiUIDefaultsNPECheck.java | 93 +++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 jdk/test/javax/swing/MultiUIDefaults/NPECheck/MultiUIDefaultsNPECheck.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/MultiUIDefaults.java b/jdk/src/java.desktop/share/classes/javax/swing/MultiUIDefaults.java index 8870834a3a5..2429add6a27 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/MultiUIDefaults.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/MultiUIDefaults.java @@ -127,7 +127,7 @@ class MultiUIDefaults extends UIDefaults @Override protected void getUIError(String msg) { - if (tables.length > 0) { + if (tables != null && tables.length > 0 && tables[0] != null) { tables[0].getUIError(msg); } else { super.getUIError(msg); diff --git a/jdk/test/javax/swing/MultiUIDefaults/NPECheck/MultiUIDefaultsNPECheck.java b/jdk/test/javax/swing/MultiUIDefaults/NPECheck/MultiUIDefaultsNPECheck.java new file mode 100644 index 00000000000..0122199a730 --- /dev/null +++ b/jdk/test/javax/swing/MultiUIDefaults/NPECheck/MultiUIDefaultsNPECheck.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6919529 + * @summary Checks if there is a null pointer exception when the component UI + * is null. + * @run main MultiUIDefaultsNPECheck + */ +import javax.swing.LookAndFeel; +import javax.swing.JLabel; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.UIDefaults; +import javax.swing.SwingUtilities; + +public class MultiUIDefaultsNPECheck { + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(() -> { + Test(); + }); + } + + public static void Test() { + JLabel label = new JLabel(); + + try { + UIManager.setLookAndFeel(new LookAndFeel() { + @Override + public String getName() { + return null; + } + + @Override + public String getID() { + return null; + } + + @Override + public String getDescription() { + return null; + } + + @Override + public boolean isNativeLookAndFeel() { + return false; + } + + @Override + public boolean isSupportedLookAndFeel() { + return true; + } + + @Override + public UIDefaults getDefaults() { + return null; + } + }); + } catch (UnsupportedLookAndFeelException e) { + System.err.println("Warning: test not applicable because of " + + "unsupported look and feel"); + return; + } + + try { + UIManager.getDefaults().getUI(label); + } catch (NullPointerException e) { + throw new RuntimeException("Got null pointer exception. Hence " + + "Test Failed"); + } + } +} From 0282e288294593c74572f201c9277a33a201164d Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Mon, 10 Jul 2017 14:41:54 -0700 Subject: [PATCH 22/98] 8183576: Synchronization in BufferedImage.setRGB(int x, int y, int rgb) is not necessary Reviewed-by: prr, flar, pnarayanan --- .../share/classes/java/awt/image/BufferedImage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/java/awt/image/BufferedImage.java b/jdk/src/java.desktop/share/classes/java/awt/image/BufferedImage.java index 0e349a93da6..67b66d39537 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/image/BufferedImage.java +++ b/jdk/src/java.desktop/share/classes/java/awt/image/BufferedImage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -1012,7 +1012,7 @@ public class BufferedImage extends java.awt.Image * @see #getRGB(int, int) * @see #getRGB(int, int, int, int, int[], int, int) */ - public synchronized void setRGB(int x, int y, int rgb) { + public void setRGB(int x, int y, int rgb) { raster.setDataElements(x, y, colorModel.getDataElements(rgb, null)); } From edc1bc68341124853a43a5ed1d196e9906ffaf9a Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 13 Jul 2017 12:14:59 +0530 Subject: [PATCH 23/98] 8184016: Text in native popup is not always updated with Sogou IME Reviewed-by: ssadetsky --- .../windows/native/libawt/windows/awt_Component.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp index cf89de40460..80cd9f9f8fb 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp @@ -3871,12 +3871,14 @@ MsgRouting AwtComponent::WmImeNotify(WPARAM subMsg, LPARAM bitsCandType) { if (!m_useNativeCompWindow) { if (subMsg == IMN_OPENCANDIDATE) { - m_bitsCandType = subMsg; + m_bitsCandType = bitsCandType; InquireCandidatePosition(); } else if (subMsg == IMN_OPENSTATUSWINDOW || subMsg == WM_IME_STARTCOMPOSITION) { m_bitsCandType = 0; InquireCandidatePosition(); + } else if (subMsg == IMN_SETCANDIDATEPOS) { + InquireCandidatePosition(); } return mrConsume; } From f89582b4a71a0ac8550d70f675834280f17772d3 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Fri, 14 Jul 2017 10:30:32 +0530 Subject: [PATCH 24/98] 8183529: FilleChooser in "Detail view" does not change the Language of the column headings Reviewed-by: ssadetsky --- .../classes/sun/awt/shell/ShellFolder.java | 6 +- .../sun/awt/shell/Win32ShellFolder2.java | 4 ++ .../native/libawt/windows/ShellFolder2.cpp | 56 ++++++++++++++++++- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java b/jdk/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java index 779ccafea23..e6a77e78977 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java @@ -42,9 +42,9 @@ import java.util.concurrent.Callable; */ @SuppressWarnings("serial") // JDK-implementation class public abstract class ShellFolder extends File { - private static final String COLUMN_NAME = "FileChooser.fileNameHeaderText"; - private static final String COLUMN_SIZE = "FileChooser.fileSizeHeaderText"; - private static final String COLUMN_DATE = "FileChooser.fileDateHeaderText"; + public static final String COLUMN_NAME = "FileChooser.fileNameHeaderText"; + public static final String COLUMN_SIZE = "FileChooser.fileSizeHeaderText"; + public static final String COLUMN_DATE = "FileChooser.fileDateHeaderText"; protected ShellFolder parent; diff --git a/jdk/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java b/jdk/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java index b2e62b41d27..05ec2b9696a 100644 --- a/jdk/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java +++ b/jdk/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java @@ -240,6 +240,10 @@ final class Win32ShellFolder2 extends ShellFolder { private Image largeIcon = null; private Boolean isDir = null; private final boolean isLib; + private static final String FNAME = COLUMN_NAME; + private static final String FSIZE = COLUMN_SIZE; + private static final String FTYPE = "FileChooser.fileTypeHeaderText"; + private static final String FDATE = COLUMN_DATE; /* * The following is to identify the My Documents folder as being special diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp index 63b9334b576..523305a58a8 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp @@ -109,6 +109,16 @@ static jfieldID FID_folderType; static IMalloc* pMalloc; static IShellFolder* pDesktop; +// locale sensitive folder info +static jfieldID FID_lsName; +static jfieldID FID_lsSize; +static jfieldID FID_lsType; +static jfieldID FID_lsDate; +static jstring lsName; +static jstring lsSize; +static jstring lsType; +static jstring lsDate; + // Some macros from awt.h, because it is not included in release #ifndef IS_WIN2000 #define IS_WIN2000 (LOBYTE(LOWORD(::GetVersion())) >= 5) @@ -246,6 +256,36 @@ JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolder2_initIDs CHECK_NULL(FID_displayName); FID_folderType = env->GetFieldID(cls, "folderType", "Ljava/lang/String;"); CHECK_NULL(FID_folderType); + + FID_lsName = env->GetStaticFieldID(cls, "FNAME", "Ljava/lang/String;"); + CHECK_NULL(FID_lsName); + if (env->ExceptionCheck()) { + env->ExceptionClear(); + return; + } + FID_lsSize = env->GetStaticFieldID(cls, "FSIZE", "Ljava/lang/String;"); + CHECK_NULL(FID_lsSize); + if (env->ExceptionCheck()) { + env->ExceptionClear(); + return; + } + FID_lsType = env->GetStaticFieldID(cls, "FTYPE", "Ljava/lang/String;"); + CHECK_NULL(FID_lsType); + if (env->ExceptionCheck()) { + env->ExceptionClear(); + return; + } + FID_lsDate = env->GetStaticFieldID(cls, "FDATE", "Ljava/lang/String;"); + CHECK_NULL(FID_lsDate); + if (env->ExceptionCheck()) { + env->ExceptionClear(); + return; + } + + lsName = (jstring) (env->NewGlobalRef(env->GetStaticObjectField(cls, FID_lsName))); + lsSize = (jstring) (env->NewGlobalRef(env->GetStaticObjectField(cls, FID_lsSize))); + lsType = (jstring) (env->NewGlobalRef(env->GetStaticObjectField(cls, FID_lsType))); + lsDate = (jstring) (env->NewGlobalRef(env->GetStaticObjectField(cls, FID_lsDate))); } @@ -1105,11 +1145,21 @@ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconResource */ static jobject CreateColumnInfo(JNIEnv *pEnv, jclass *pClass, jmethodID *pConstructor, - SHELLDETAILS *psd, ULONG visible) + int colNum, SHELLDETAILS *psd, ULONG visible) { jstring str = jstringFromSTRRET(pEnv, NULL, &(psd->str)); JNU_CHECK_EXCEPTION_RETURN(pEnv, NULL); + // Convert ShellFolder column names to locale-sensitive names + if (colNum == 0) { + str = lsName; + } else if (colNum == 1) { + str = lsSize; + } else if (colNum == 2) { + str = lsType; + } else if (colNum == 3) { + str = lsDate; + } return pEnv->NewObject(*pClass, *pConstructor, str, (jint)(psd->cxChar * 6), // TODO: is 6 OK for converting chars to pixels? @@ -1178,7 +1228,7 @@ JNIEXPORT jobjectArray JNICALL if(!(csFlags & SHCOLSTATE_HIDDEN)) { jobject column = CreateColumnInfo(env, &columnClass, &columnConstructor, - &sd, csFlags & SHCOLSTATE_ONBYDEFAULT); + colNum, &sd, csFlags & SHCOLSTATE_ONBYDEFAULT); if(!column){ pIShellFolder2->Release(); return NULL; @@ -1222,7 +1272,7 @@ JNIEXPORT jobjectArray JNICALL if (SUCCEEDED (hr)) { jobject column = CreateColumnInfo(env, &columnClass, &columnConstructor, - &sd, 1); + colNum, &sd, 1); if(!column){ pIShellDetails->Release(); return NULL; From 1d886495d26d36cd3574b285ed109b68f46fa8c6 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Sat, 15 Jul 2017 11:15:07 +0530 Subject: [PATCH 25/98] 8184244: UIDefaults.addResourceBundle uses system class loader Reviewed-by: serb, ssadetsky --- jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java b/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java index 2efdd6b1e82..582a853d5c3 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/UIDefaults.java @@ -887,7 +887,7 @@ public class UIDefaults extends Hashtable * Adds a resource bundle to the list of resource bundles that are * searched for localized values. Resource bundles are searched in * the reverse order they were added, using the - * {@linkplain ClassLoader#getSystemClassLoader application class loader}. + * {@linkplain ClassLoader#getSystemClassLoader system class loader}. * In other words, the most recently added bundle is searched first. * * @param bundleName the base name of the resource bundle to be added From a0f472d88036a98421fb6ceb2305e837b26bad70 Mon Sep 17 00:00:00 2001 From: Jayathirth D V Date: Mon, 17 Jul 2017 14:18:35 +0530 Subject: [PATCH 26/98] 8183349: Better cleanup for jdk/test/javax/imageio/plugins/shared/CanWriteSequence.java and WriteAfterAbort.java Reviewed-by: serb, pnarayanan --- .../plugins/shared/CanWriteSequence.java | 52 ++++--- .../plugins/shared/WriteAfterAbort.java | 135 ++++++++++-------- 2 files changed, 108 insertions(+), 79 deletions(-) diff --git a/jdk/test/javax/imageio/plugins/shared/CanWriteSequence.java b/jdk/test/javax/imageio/plugins/shared/CanWriteSequence.java index ef4c8f1912b..f7923d85b58 100644 --- a/jdk/test/javax/imageio/plugins/shared/CanWriteSequence.java +++ b/jdk/test/javax/imageio/plugins/shared/CanWriteSequence.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -23,6 +23,7 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; import java.util.Iterator; import javax.imageio.ImageIO; @@ -34,11 +35,18 @@ import javax.imageio.stream.ImageOutputStream; /** * @test - * @bug 4958064 - * @author Sergey Bylokhov + * @bug 4958064 8183349 + * @summary Test verifies that when we try to forcefully run + * prepareWriteSequence() where it is not supported + * will ImageIO throws an UnsupportedOperationException + * or not. + * @run main CanWriteSequence */ public final class CanWriteSequence { + private static File file; + private static FileOutputStream fos; + public static void main(final String[] args) throws Exception { final IIORegistry registry = IIORegistry.getDefaultInstance(); final Iterator iter = @@ -54,25 +62,33 @@ public final class CanWriteSequence { } private static void test(final ImageWriter writer) throws Exception { - final File file = File.createTempFile("temp", ".img"); - file.deleteOnExit(); - final FileOutputStream fos = new FileOutputStream(file); - final ImageOutputStream ios = ImageIO.createImageOutputStream(fos); - writer.setOutput(ios); - final IIOMetadata data = writer.getDefaultStreamMetadata(null); + try { + file = File.createTempFile("temp", ".img"); + fos = new FileOutputStream(file); + final ImageOutputStream ios = ImageIO.createImageOutputStream(fos); + writer.setOutput(ios); + final IIOMetadata data = writer.getDefaultStreamMetadata(null); - if (writer.canWriteSequence()) { - writer.prepareWriteSequence(data); - } else { - try { + if (writer.canWriteSequence()) { writer.prepareWriteSequence(data); - throw new RuntimeException( - "UnsupportedOperationException was not thrown"); - } catch (final UnsupportedOperationException ignored) { + } else { + try { + writer.prepareWriteSequence(data); + throw new RuntimeException( + "UnsupportedOperationException was not thrown"); + } catch (final UnsupportedOperationException ignored) { // expected + } + } + } finally { + writer.dispose(); + if (file != null) { + if (fos != null) { + fos.close(); + } + Files.delete(file.toPath()); } } - writer.dispose(); - ios.close(); } } + diff --git a/jdk/test/javax/imageio/plugins/shared/WriteAfterAbort.java b/jdk/test/javax/imageio/plugins/shared/WriteAfterAbort.java index f1be068cdfe..93e2e1bf2a5 100644 --- a/jdk/test/javax/imageio/plugins/shared/WriteAfterAbort.java +++ b/jdk/test/javax/imageio/plugins/shared/WriteAfterAbort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -29,6 +29,7 @@ import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Iterator; +import java.nio.file.Files; import javax.imageio.ImageIO; import javax.imageio.ImageWriter; @@ -41,9 +42,9 @@ import static java.awt.image.BufferedImage.TYPE_BYTE_BINARY; /** * @test - * @bug 4952954 + * @bug 4952954 8183349 * @summary abortFlag must be cleared for every ImageWriter.write operation - * @author Sergey Bylokhov + * @run main WriteAfterAbort */ public final class WriteAfterAbort implements IIOWriteProgressListener { @@ -54,73 +55,85 @@ public final class WriteAfterAbort implements IIOWriteProgressListener { private volatile boolean isStartedCalled; private static final int WIDTH = 100; private static final int HEIGHT = 100; + private static FileOutputStream fos; + private static File file; private void test(final ImageWriter writer) throws IOException { - // Image initialization - final BufferedImage imageWrite = new BufferedImage(WIDTH, HEIGHT, - TYPE_BYTE_BINARY); - final Graphics2D g = imageWrite.createGraphics(); - g.setColor(Color.WHITE); - g.fillRect(0, 0, WIDTH, HEIGHT); - g.dispose(); + try { + // Image initialization + final BufferedImage imageWrite = + new BufferedImage(WIDTH, HEIGHT, TYPE_BYTE_BINARY); + final Graphics2D g = imageWrite.createGraphics(); + g.setColor(Color.WHITE); + g.fillRect(0, 0, WIDTH, HEIGHT); + g.dispose(); - // File initialization - final File file = File.createTempFile("temp", ".img"); - file.deleteOnExit(); - final FileOutputStream fos = new SkipWriteOnAbortOutputStream(file); - final ImageOutputStream ios = ImageIO.createImageOutputStream(fos); - writer.setOutput(ios); - writer.addIIOWriteProgressListener(this); + // File initialization + file = File.createTempFile("temp", ".img"); + fos = new SkipWriteOnAbortOutputStream(file); + final ImageOutputStream ios = ImageIO.createImageOutputStream(fos); + writer.setOutput(ios); + writer.addIIOWriteProgressListener(this); - // This write will be aborted, and file will not be touched - writer.write(imageWrite); - if (!isStartedCalled) { - throw new RuntimeException("Started should be called"); - } - if (!isProgressCalled) { - throw new RuntimeException("Progress should be called"); - } - if (!isAbortCalled) { - throw new RuntimeException("Abort should be called"); - } - if (isCompleteCalled) { - throw new RuntimeException("Complete should not be called"); - } - // Flush aborted data - ios.flush(); + // This write will be aborted, and file will not be touched + writer.write(imageWrite); + if (!isStartedCalled) { + throw new RuntimeException("Started should be called"); + } + if (!isProgressCalled) { + throw new RuntimeException("Progress should be called"); + } + if (!isAbortCalled) { + throw new RuntimeException("Abort should be called"); + } + if (isCompleteCalled) { + throw new RuntimeException("Complete should not be called"); + } + // Flush aborted data + ios.flush(); - // This write should be completed successfully and the file should - // contain correct image data. - abortFlag = false; - isAbortCalled = false; - isCompleteCalled = false; - isProgressCalled = false; - isStartedCalled = false; - writer.write(imageWrite); + /* + * This write should be completed successfully and the file should + * contain correct image data. + */ + abortFlag = false; + isAbortCalled = false; + isCompleteCalled = false; + isProgressCalled = false; + isStartedCalled = false; + writer.write(imageWrite); - if (!isStartedCalled) { - throw new RuntimeException("Started should be called"); - } - if (!isProgressCalled) { - throw new RuntimeException("Progress should be called"); - } - if (isAbortCalled) { - throw new RuntimeException("Abort should not be called"); - } - if (!isCompleteCalled) { - throw new RuntimeException("Complete should be called"); - } - writer.dispose(); - ios.close(); + if (!isStartedCalled) { + throw new RuntimeException("Started should be called"); + } + if (!isProgressCalled) { + throw new RuntimeException("Progress should be called"); + } + if (isAbortCalled) { + throw new RuntimeException("Abort should not be called"); + } + if (!isCompleteCalled) { + throw new RuntimeException("Complete should be called"); + } + ios.close(); - // Validates content of the file. - final BufferedImage imageRead = ImageIO.read(file); - for (int x = 0; x < WIDTH; ++x) { - for (int y = 0; y < HEIGHT; ++y) { - if (imageRead.getRGB(x, y) != imageWrite.getRGB(x, y)) { - throw new RuntimeException("Test failed."); + // Validates content of the file. + final BufferedImage imageRead = ImageIO.read(file); + for (int x = 0; x < WIDTH; ++x) { + for (int y = 0; y < HEIGHT; ++y) { + if (imageRead.getRGB(x, y) != imageWrite.getRGB(x, y)) { + throw new RuntimeException("Test failed."); + } } } + } finally { + writer.dispose(); + if (file != null) { + if (fos != null) { + fos.close(); + } + Files.delete(file.toPath()); + } } } From 8f85c81436cbf6e12abc86c67d83ea5dc16c82e8 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Fri, 21 Jul 2017 10:22:17 +0530 Subject: [PATCH 27/98] 8184813: Class javax/swing/plaf/metal/MetalFontDesktopProperty is broken in JDK10 Reviewed-by: prr, serb --- make/CompileJavaModules.gmk | 2 -- 1 file changed, 2 deletions(-) diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk index c7ebaaae87e..090434a1607 100644 --- a/make/CompileJavaModules.gmk +++ b/make/CompileJavaModules.gmk @@ -200,8 +200,6 @@ endif ifeq ($(OPENJDK_TARGET_OS), windows) java.desktop_EXCLUDES += com/sun/java/swing/plaf/gtk -else - java.desktop_EXCLUDES += com/sun/java/swing/plaf/windows endif ifdef BUILD_HEADLESS_ONLY From c0bd091880986e3d9acbac4add850fc6f2acf19a Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Fri, 21 Jul 2017 10:23:37 +0530 Subject: [PATCH 28/98] 8184813: Class javax/swing/plaf/metal/MetalFontDesktopProperty is broken in JDK10 Reviewed-by: prr, serb --- .../share/classes/module-info.java | 2 ++ .../windows/classes/module-info.java.extra | 26 ------------------- .../java/swing/plaf/windows/Test6824600.java | 1 - .../swing/JButton/4796987/bug4796987.java | 1 - .../swing/JComboBox/4199622/bug4199622.java | 1 - .../swing/JComboBox/8015300/Test8015300.java | 1 - .../JFileChooser/8046391/bug8046391.java | 1 - .../JInternalFrame/6725409/bug6725409.java | 1 - .../swing/JSlider/6524424/bug6524424.java | 1 - .../javax/swing/JTree/8004298/bug8004298.java | 1 - jdk/test/javax/swing/border/Test4856008.java | 1 - jdk/test/javax/swing/border/Test6978482.java | 1 - 12 files changed, 2 insertions(+), 36 deletions(-) delete mode 100644 jdk/src/java.desktop/windows/classes/module-info.java.extra diff --git a/jdk/src/java.desktop/share/classes/module-info.java b/jdk/src/java.desktop/share/classes/module-info.java index b001e1a30cd..17bff50f8c7 100644 --- a/jdk/src/java.desktop/share/classes/module-info.java +++ b/jdk/src/java.desktop/share/classes/module-info.java @@ -112,6 +112,8 @@ module java.desktop { opens javax.swing.plaf.basic to jdk.jconsole; + opens com.sun.java.swing.plaf.windows to + jdk.jconsole; uses java.awt.im.spi.InputMethodDescriptor; uses javax.accessibility.AccessibilityProvider; diff --git a/jdk/src/java.desktop/windows/classes/module-info.java.extra b/jdk/src/java.desktop/windows/classes/module-info.java.extra deleted file mode 100644 index 9cd11e34a91..00000000000 --- a/jdk/src/java.desktop/windows/classes/module-info.java.extra +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -opens com.sun.java.swing.plaf.windows to jdk.jconsole; diff --git a/jdk/test/com/sun/java/swing/plaf/windows/Test6824600.java b/jdk/test/com/sun/java/swing/plaf/windows/Test6824600.java index 7e07c517a28..74b2890c563 100644 --- a/jdk/test/com/sun/java/swing/plaf/windows/Test6824600.java +++ b/jdk/test/com/sun/java/swing/plaf/windows/Test6824600.java @@ -23,7 +23,6 @@ /* @test @bug 6824600 - @requires (os.family == "windows") @summary OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style) @author Pavel Porvatov @modules java.desktop/com.sun.java.swing.plaf.windows diff --git a/jdk/test/javax/swing/JButton/4796987/bug4796987.java b/jdk/test/javax/swing/JButton/4796987/bug4796987.java index 65698791bfb..52d2a32120f 100644 --- a/jdk/test/javax/swing/JButton/4796987/bug4796987.java +++ b/jdk/test/javax/swing/JButton/4796987/bug4796987.java @@ -24,7 +24,6 @@ /* * @test * @bug 4796987 - * @requires (os.family == "windows") * @summary XP Only: JButton.setBorderPainted() does not work with XP L&F * @author Alexander Scherbatiy * @library ../../regtesthelpers diff --git a/jdk/test/javax/swing/JComboBox/4199622/bug4199622.java b/jdk/test/javax/swing/JComboBox/4199622/bug4199622.java index ffa07264681..e96e2cd45a8 100644 --- a/jdk/test/javax/swing/JComboBox/4199622/bug4199622.java +++ b/jdk/test/javax/swing/JComboBox/4199622/bug4199622.java @@ -25,7 +25,6 @@ @test @key headful @bug 4199622 - @requires (os.family == "windows") @summary RFE: JComboBox shouldn't send ActionEvents for keyboard navigation @author Vladislav Karnaukhov @library ../../../../lib/testlibrary diff --git a/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java b/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java index 65afea9d60e..747418bf7b1 100644 --- a/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java +++ b/jdk/test/javax/swing/JComboBox/8015300/Test8015300.java @@ -39,7 +39,6 @@ import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE; * @test * @key headful * @bug 8015300 - * @requires (os.family == "windows") * @summary Tests that editable combobox selects all text. * @author Sergey Malenkov * @library ../../../../lib/testlibrary/ diff --git a/jdk/test/javax/swing/JFileChooser/8046391/bug8046391.java b/jdk/test/javax/swing/JFileChooser/8046391/bug8046391.java index 21b840787e9..deed68deb17 100644 --- a/jdk/test/javax/swing/JFileChooser/8046391/bug8046391.java +++ b/jdk/test/javax/swing/JFileChooser/8046391/bug8046391.java @@ -24,7 +24,6 @@ /* * @test * @bug 8046391 - * @requires (os.family == "windows") * @summary JFileChooser hangs if displayed in Windows L&F * @author Alexey Ivanov * @library ../../../../lib/testlibrary diff --git a/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java b/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java index 71d52ff2d4f..c56eaddc69d 100644 --- a/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java +++ b/jdk/test/javax/swing/JInternalFrame/6725409/bug6725409.java @@ -24,7 +24,6 @@ /* @test * @key headful * @bug 6725409 - * @requires (os.family == "windows") * @summary Checks that JInternalFrame's system menu * can be localized during run-time * @author Mikhail Lapshin diff --git a/jdk/test/javax/swing/JSlider/6524424/bug6524424.java b/jdk/test/javax/swing/JSlider/6524424/bug6524424.java index 7e52135c94f..f819d247d96 100644 --- a/jdk/test/javax/swing/JSlider/6524424/bug6524424.java +++ b/jdk/test/javax/swing/JSlider/6524424/bug6524424.java @@ -23,7 +23,6 @@ /* @test * @bug 6524424 - * @requires (os.family == "windows") * @summary JSlider Clicking In Tracks Behavior Inconsistent For Different Tick Spacings * @author Pavel Porvatov * @modules java.desktop/com.sun.java.swing.plaf.windows diff --git a/jdk/test/javax/swing/JTree/8004298/bug8004298.java b/jdk/test/javax/swing/JTree/8004298/bug8004298.java index e0b40d93919..440dbe4e23b 100644 --- a/jdk/test/javax/swing/JTree/8004298/bug8004298.java +++ b/jdk/test/javax/swing/JTree/8004298/bug8004298.java @@ -25,7 +25,6 @@ * @test * @key headful * @bug 8004298 - * @requires (os.family == "windows") * @summary NPE in WindowsTreeUI.ensureRowsAreVisible * @author Alexander Scherbatiy * @library ../../regtesthelpers diff --git a/jdk/test/javax/swing/border/Test4856008.java b/jdk/test/javax/swing/border/Test4856008.java index dd28834cd59..398fefb51a1 100644 --- a/jdk/test/javax/swing/border/Test4856008.java +++ b/jdk/test/javax/swing/border/Test4856008.java @@ -24,7 +24,6 @@ /* * @test * @bug 4856008 7025987 - * @requires (os.family == "windows") * @summary Tests border insets * @author Sergey Malenkov * @modules java.desktop/com.sun.java.swing.plaf.motif diff --git a/jdk/test/javax/swing/border/Test6978482.java b/jdk/test/javax/swing/border/Test6978482.java index 89634055591..b9f30e531e0 100644 --- a/jdk/test/javax/swing/border/Test6978482.java +++ b/jdk/test/javax/swing/border/Test6978482.java @@ -24,7 +24,6 @@ /* * @test * @bug 6978482 7025987 - * @requires (os.family == "windows") * @summary Tests unchecked casts * @author Sergey Malenkov * @modules java.desktop/com.sun.java.swing.plaf.motif From 3a213c4a3d616afa9a0c8d6512d886e5e48beb50 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Fri, 21 Jul 2017 16:27:35 -0700 Subject: [PATCH 29/98] 8134256: copy/paste duplicated tests in some condition statements Reviewed-by: azvegint --- .../plaf/nimbus/AbstractRegionPainter.java | 4 +- .../javax/swing/text/html/StyleSheet.java | 4 +- .../PaintContextScaleValidation.java | 64 ++++++++++ .../BackgroundImagePosition.java | 114 ++++++++++++++++++ 4 files changed, 182 insertions(+), 4 deletions(-) create mode 100644 jdk/test/javax/swing/plaf/nimbus/AbstractRegionPainter/PaintContextScaleValidation.java create mode 100644 jdk/test/javax/swing/text/html/StyleSheet/BackgroundImage/BackgroundImagePosition.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java index acc83c4739f..946573c10f3 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -559,7 +559,7 @@ public abstract class AbstractRegionPainter implements Painter { */ public PaintContext(Insets insets, Dimension canvasSize, boolean inverted, CacheMode cacheMode, double maxH, double maxV) { - if (maxH < 1 || maxH < 1) { + if (maxH < 1 || maxV < 1) { throw new IllegalArgumentException("Both maxH and maxV must be >= 1"); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java b/jdk/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java index 07e18dc8765..9f3208c3fe1 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -2538,7 +2538,7 @@ public class StyleSheet extends StyleContext { if (pos.isHorizontalPositionRelativeToSize()) { flags |= 4; } - else if (pos.isHorizontalPositionRelativeToSize()) { + else if (pos.isHorizontalPositionRelativeToFontSize()) { hPosition *= CSS.getFontSize(a, 12, ss); } if (pos.isVerticalPositionRelativeToSize()) { diff --git a/jdk/test/javax/swing/plaf/nimbus/AbstractRegionPainter/PaintContextScaleValidation.java b/jdk/test/javax/swing/plaf/nimbus/AbstractRegionPainter/PaintContextScaleValidation.java new file mode 100644 index 00000000000..1a665e19c07 --- /dev/null +++ b/jdk/test/javax/swing/plaf/nimbus/AbstractRegionPainter/PaintContextScaleValidation.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.Insets; + +import javax.swing.JComponent; +import javax.swing.plaf.nimbus.AbstractRegionPainter; + +/** + * @test + * @bug 8134256 + */ +public final class PaintContextScaleValidation extends AbstractRegionPainter { + + public static void main(final String[] args) { + final PaintContextScaleValidation t = new PaintContextScaleValidation(); + t.test(0, 0); + t.test(0, 1); + t.test(1, 0); + } + + private void test(final double maxH, final double maxV) { + try { + new PaintContext(new Insets(1, 1, 1, 1), new Dimension(1, 1), false, + null, maxH, maxV); + } catch (final IllegalArgumentException ignored) { + return; // expected exception + } + throw new RuntimeException("IllegalArgumentException was not thrown"); + } + + @Override + protected PaintContext getPaintContext() { + return null; + } + + @Override + protected void doPaint(final Graphics2D g, final JComponent c, + final int width, final int height, + final Object[] extendedCacheKeys) { + } +} diff --git a/jdk/test/javax/swing/text/html/StyleSheet/BackgroundImage/BackgroundImagePosition.java b/jdk/test/javax/swing/text/html/StyleSheet/BackgroundImage/BackgroundImagePosition.java new file mode 100644 index 00000000000..207ac4bafa0 --- /dev/null +++ b/jdk/test/javax/swing/text/html/StyleSheet/BackgroundImage/BackgroundImagePosition.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.util.List; + +import javax.imageio.ImageIO; +import javax.swing.JEditorPane; +import javax.swing.text.html.HTMLEditorKit; + +/** + * @test + * @bug 8134256 + * @summary Different "background-position" should produce different pages + */ +public final class BackgroundImagePosition { + + static final List pos = List.of("", "-2", "-1", "1px", "2px", "3px", + "1em", "2em", "3em", "10%", "55%", + "-1em", "-2em", "-3em", "-10%"); + static final int SIZE = 300; + + public static void main(final String[] args) throws Exception { + // The image which we will place on the page + final BufferedImage bi = new BufferedImage(50, 50, + BufferedImage.TYPE_INT_ARGB); + final Graphics2D g = bi.createGraphics(); + g.setColor(Color.GREEN); + g.fillRect(0, 0, 50, 50); + g.dispose(); + final File file = new File("file.png"); + ImageIO.write(bi, "png", file); + for (final String x : pos) { + final BufferedImage img1 = test(x, x); + for (final String y : pos) { + // Different positions should produce different pages + if (!x.equals(y)) { + compareImages(img1, test(x, y)); + compareImages(img1, test(y, x)); + } + } + } + } + + /** + * Throws an exception if the images are the same. + */ + static void compareImages(final BufferedImage img1, + final BufferedImage img2) throws IOException { + for (int imgX = 0; imgX < SIZE; ++imgX) { + for (int imgY = 0; imgY < SIZE; ++imgY) { + if (img1.getRGB(imgX, imgY) != img2.getRGB(imgX, imgY)) { + return; + } + } + } + ImageIO.write(img1, "png", new File("img1.png")); + ImageIO.write(img2, "png", new File("img2.png")); + throw new RuntimeException("Same images for different size"); + } + + static BufferedImage test(final String x, final String y) throws Exception { + final BufferedImage bi = new BufferedImage(SIZE, SIZE, + BufferedImage.TYPE_INT_ARGB); + EventQueue.invokeAndWait(() -> { + try { + final JEditorPane jep = new JEditorPane(); + + final HTMLEditorKit kit = new HTMLEditorKit(); + jep.setEditorKit(kit); + jep.setText( + ""); + jep.setSize(SIZE, SIZE); + + final Graphics2D graphics = bi.createGraphics(); + jep.paint(graphics); + graphics.dispose(); + } catch (final Exception e) { + throw new RuntimeException(e); + } + }); + return bi; + } +} From bd56ddbad474ebf34d12509e6f4090c414dc19a1 Mon Sep 17 00:00:00 2001 From: Shashidhara Veerabhadraiah Date: Mon, 24 Jul 2017 11:54:57 +0530 Subject: [PATCH 30/98] 8183341: Better cleanup for javax/imageio/AllowSearch.java Reviewed-by: prr, jdv, pnarayanan --- jdk/test/javax/imageio/AllowSearch.java | 36 +++++++++++++++++-------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/jdk/test/javax/imageio/AllowSearch.java b/jdk/test/javax/imageio/AllowSearch.java index ec0d727c9cc..6119b8a4713 100644 --- a/jdk/test/javax/imageio/AllowSearch.java +++ b/jdk/test/javax/imageio/AllowSearch.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4420318 + * @bug 4420318 8183341 * @summary Checks that an IllegalStateException is thrown by getNumImages(true) * when seekForwardOnly is true * @modules java.desktop/com.sun.imageio.plugins.gif @@ -33,6 +33,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; import javax.imageio.ImageIO; import javax.imageio.ImageReader; @@ -43,20 +44,33 @@ import com.sun.imageio.plugins.jpeg.JPEGImageReader; import com.sun.imageio.plugins.png.PNGImageReader; public class AllowSearch { - private static void test(ImageReader reader, String format) throws IOException { - File f = File.createTempFile("imageio", ".tmp"); - ImageInputStream stream = ImageIO.createImageInputStream(f); - reader.setInput(stream, true); - boolean gotISE = false; + File f = null; + ImageInputStream stream = null; try { - int numImages = reader.getNumImages(true); - } catch (IOException ioe) { - gotISE = false; - } catch (IllegalStateException ise) { - gotISE = true; + f = File.createTempFile("imageio", ".tmp"); + stream = ImageIO.createImageInputStream(f); + reader.setInput(stream, true); + + try { + int numImages = reader.getNumImages(true); + } catch (IOException ioe) { + gotISE = false; + } catch (IllegalStateException ise) { + gotISE = true; + } + } finally { + if (stream != null) { + stream.close(); + } + + reader.dispose(); + + if (f != null) { + Files.delete(f.toPath()); + } } if (!gotISE) { From 4b8cfe5a6058cdada1ad6efbb8f81e2f8f53a177 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Wed, 26 Jul 2017 10:47:13 +0530 Subject: [PATCH 31/98] 8173739: JPopupMenu does not disappear on KeyEvent Reviewed-by: serb --- .../classes/javax/swing/JInternalFrame.java | 15 +- .../JPopupMenu/8173739/TestPopupMenu.java | 202 ++++++++++++++++++ 2 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 jdk/test/javax/swing/JPopupMenu/8173739/TestPopupMenu.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JInternalFrame.java b/jdk/src/java.desktop/share/classes/javax/swing/JInternalFrame.java index 6d82ffda5af..b1cc76066df 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JInternalFrame.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JInternalFrame.java @@ -1077,8 +1077,15 @@ public class JInternalFrame extends JComponent implements firePropertyChange(IS_SELECTED_PROPERTY, oldValue, newValue); if (isSelected) fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ACTIVATED); - else + else { fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED); + try { + java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent( + new sun.awt.UngrabEvent(this)); + } catch (SecurityException e) { + this.dispatchEvent(new sun.awt.UngrabEvent(this)); + } + } repaint(); } @@ -1758,6 +1765,12 @@ public class JInternalFrame extends JComponent implements isClosed = true; } fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSED); + try { + java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent( + new sun.awt.UngrabEvent(this)); + } catch (SecurityException e) { + this.dispatchEvent(new sun.awt.UngrabEvent(this)); + } } /** diff --git a/jdk/test/javax/swing/JPopupMenu/8173739/TestPopupMenu.java b/jdk/test/javax/swing/JPopupMenu/8173739/TestPopupMenu.java new file mode 100644 index 00000000000..39a3615206c --- /dev/null +++ b/jdk/test/javax/swing/JPopupMenu/8173739/TestPopupMenu.java @@ -0,0 +1,202 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @key headful + * @bug 8173739 + * @summary Verifies if JPopupMenu disappears on KeyEvent + * @run main TestPopupMenu + */ +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.beans.PropertyVetoException; +import javax.swing.JComponent; +import javax.swing.JDesktopPane; +import javax.swing.JFrame; +import javax.swing.JInternalFrame; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JScrollPane; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; + +public class TestPopupMenu { + private JFrame frame; + private JLabel label; + private volatile Point p = null; + private volatile Dimension d = null; + + public static void main(String[] args) throws Exception { + new TestPopupMenu(); + } + + void blockTillDisplayed(JComponent comp) throws Exception { + while (p == null) { + try { + SwingUtilities.invokeAndWait(() -> { + p = comp.getLocationOnScreen(); + d = comp.getSize(); + }); + } catch (IllegalStateException e) { + try { + Thread.sleep(1000); + } catch (InterruptedException ie) { + } + } + } + } + + public TestPopupMenu() throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(200); + try { + SwingUtilities.invokeAndWait(() -> { + try { + createAndShowUI(); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + }); + blockTillDisplayed(label); + robot.waitForIdle(); + robot.mouseMove(p.x + d.width/2, p.y + d.height/2); + robot.mousePress(InputEvent.BUTTON3_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_CONTROL); + robot.keyPress(KeyEvent.VK_U); + robot.keyRelease(KeyEvent.VK_U); + robot.keyRelease(KeyEvent.VK_CONTROL); + robot.waitForIdle(); + JPopupMenu popup = label.getComponentPopupMenu(); + if (popup != null && popup.isVisible()) { + throw new RuntimeException("Popup is visible in wrong internal frame"); + } + } finally { + SwingUtilities.invokeAndWait(()->frame.dispose()); + } + } + + private void createAndShowUI() throws Exception { + frame = new JFrame(); + frame.setTitle("Test Frame"); + frame.setSize(800, 600); + + JDesktopPane pane = new JDesktopPane(); + TestInternalFrameWPopup testInternalFrame1 = new TestInternalFrameWPopup(); + pane.add(testInternalFrame1); + + testInternalFrame1.setVisible(true); + JScrollPane scrollPane = new JScrollPane(pane); + frame.getContentPane().add(scrollPane); + testInternalFrame1.setMaximum(true); + frame.getRootPane().registerKeyboardAction(e -> { + TestInternalFrame testInternalFrame2 = new TestInternalFrame(); + pane.add(testInternalFrame2); + try { + testInternalFrame2.setMaximum(true); + } catch (PropertyVetoException ex) { + throw new RuntimeException(ex); + } + testInternalFrame2.setVisible(true); + }, KeyStroke.getKeyStroke(KeyEvent.VK_U, KeyEvent.CTRL_MASK), + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + + frame.setVisible(true); + } + + /** + * Background color Cyan + */ + class TestInternalFrameWPopup extends JInternalFrame { + + TestInternalFrameWPopup() { + jbInit(); + } + + private void jbInit() { + setTitle("Test Internal Frame With Popup"); + setContentPane(getContainerPanel()); + setMaximizable(true); + setClosable(true); + setMinimumSize(new Dimension(500, 300)); + setSize(500, 300); + } + + private JPanel getContainerPanel() { + JPanel panel = new JPanel(); + panel.setLayout(new GridBagLayout()); + label = new JLabel("Test Label"); + JPopupMenu popup = new JPopupMenu(); + JMenuItem menuItem1 = new JMenuItem("Item 1"); + JMenuItem menuItem2 = new JMenuItem("Item 2"); + JMenuItem menuItem3 = new JMenuItem("Item 3"); + JMenuItem menuItem4 = new JMenuItem("Item 4"); + JMenuItem menuItem5 = new JMenuItem("Item 5"); + menuItem1.setOpaque(false); + menuItem2.setOpaque(false); + menuItem3.setOpaque(false); + menuItem4.setOpaque(false); + menuItem5.setOpaque(false); + popup.add(menuItem1); + popup.add(menuItem2); + popup.add(menuItem3); + popup.add(menuItem4); + popup.add(menuItem5); + label.setComponentPopupMenu(popup); + popup.setBackground(Color.CYAN); + panel.add(label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, + GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); + panel.setBackground(Color.CYAN); + return panel; + } + } + + /** + * Background color Gray + * + */ + class TestInternalFrame extends JInternalFrame { + public TestInternalFrame() { + jbInit(); + } + + private void jbInit() { + setTitle("Test Internal Frame"); + getContentPane().setBackground(Color.GRAY); + setMaximizable(true); + setClosable(true); + setMinimumSize(new Dimension(500, 300)); + setSize(500, 300); + } + } +} From c6ce1998303dee1665dda84831cb1e0eb15ab9e0 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Fri, 28 Jul 2017 10:26:22 +0530 Subject: [PATCH 32/98] 7190581: Nimbus: PgDn at the bottom causes scrolling Reviewed-by: ssadetsky --- .../javax/swing/text/DefaultEditorKit.java | 9 + .../swing/JTextArea/4697612/bug4697612.java | 180 +++++++++++------- 2 files changed, 115 insertions(+), 74 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultEditorKit.java b/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultEditorKit.java index 355b76c0d16..3e108612371 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultEditorKit.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/DefaultEditorKit.java @@ -1496,6 +1496,15 @@ public class DefaultEditorKit extends EditorKit { target.setCaretPosition(newIndex); } } + } else { + // If the caret index is same as the visible offset + // then correct newVis.y so that it won't cause + // unnecessary scrolling upward/downward when + // page-down/page-up is received after ctrl-END/ctrl-HOME + if (direction == -1 && newVis.y <= initialY || + direction == 1 && newVis.y >= initialY) { + newVis.y = initialY; + } } } catch (BadLocationException ble) { } } else { diff --git a/jdk/test/javax/swing/JTextArea/4697612/bug4697612.java b/jdk/test/javax/swing/JTextArea/4697612/bug4697612.java index 5f4f3e7bf06..ed7f3dba73f 100644 --- a/jdk/test/javax/swing/JTextArea/4697612/bug4697612.java +++ b/jdk/test/javax/swing/JTextArea/4697612/bug4697612.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -24,17 +24,23 @@ /* * @test * @key headful - * @bug 4697612 6244705 - * @author Peter Zhelezniakov - * @library ../../regtesthelpers - * @build Util + * @bug 4697612 6244705 7190581 * @run main bug4697612 */ -import java.io.*; -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; - +import java.awt.Rectangle; +import java.awt.Dimension; +import java.io.InputStream; +import java.awt.Robot; +import java.awt.event.KeyEvent; +import java.io.IOException; +import java.io.InputStreamReader; +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.LookAndFeel; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; import javax.swing.text.BadLocationException; public class bug4697612 { @@ -47,94 +53,120 @@ public class bug4697612 { private static JFrame frame; private static JTextArea text; private static JScrollPane scroller; + private static Robot robot; + + private static void setLookAndFeel(final UIManager.LookAndFeelInfo laf) { + try { + UIManager.setLookAndFeel(laf.getClassName()); + } catch (ClassNotFoundException | InstantiationException | + UnsupportedLookAndFeelException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } public static void main(String[] args) throws Throwable { - Robot robot = new Robot(); + robot = new Robot(); robot.setAutoDelay(100); - - SwingUtilities.invokeAndWait(new Runnable() { - - @Override - public void run() { - createAndShowGUI(); + for (UIManager.LookAndFeelInfo laf : UIManager.getInstalledLookAndFeels()) { + try { + SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf)); + System.out.println("Test for LookAndFeel " + laf.getClassName()); + new bug4697612(); + System.out.println("Test passed for LookAndFeel " + laf.getClassName()); + } catch (Exception e) { + throw new RuntimeException(e); } - }); - - robot.waitForIdle(); - - SwingUtilities.invokeAndWait(new Runnable() { - - @Override - public void run() { - text.requestFocus(); - } - }); - - robot.waitForIdle(); - - // 4697612: pressing PgDn + PgUp should not alter caret position - Util.hitKeys(robot, KeyEvent.VK_HOME); - Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN); - - - int pos0 = getTextCaretPosition(); - int caretHeight = getTextCaretHeight(); - fontHeight = FONT_HEIGHT; - - // iterate two times, for different (even and odd) font height - for (int i = 0; i < 2; i++) { + } + } + public bug4697612() throws Exception { + try { SwingUtilities.invokeAndWait(new Runnable() { - + @Override public void run() { - text.setFont(text.getFont().deriveFont(fontHeight)); + createAndShowGUI(); } }); + robot.waitForIdle(); + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + text.requestFocus(); + } + }); + robot.waitForIdle(); - frameHeight = FRAME_HEIGHT; + // 4697612: pressing PgDn + PgUp should not alter caret position + robot.keyPress(KeyEvent.VK_HOME); + robot.keyRelease(KeyEvent.VK_HOME); + robot.keyPress(KeyEvent.VK_PAGE_DOWN); + robot.keyRelease(KeyEvent.VK_PAGE_DOWN); + robot.waitForIdle(); + + int pos0 = getTextCaretPosition(); + int caretHeight = getTextCaretHeight(); + fontHeight = FONT_HEIGHT; + + // iterate two times, for different (even and odd) font height + for (int i = 0; i < 2; i++) { - for (int j = 0; j < caretHeight; j++) { SwingUtilities.invokeAndWait(new Runnable() { - public void run() { - frame.setSize(FRAME_WIDTH, frameHeight); + text.setFont(text.getFont().deriveFont(fontHeight)); } }); + frameHeight = FRAME_HEIGHT; - robot.waitForIdle(); + for (int j = 0; j < caretHeight; j++) { - Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN); - Util.hitKeys(robot, KeyEvent.VK_PAGE_UP); - robot.waitForIdle(); + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.setSize(FRAME_WIDTH, frameHeight); + } + }); + robot.waitForIdle(); + robot.keyPress(KeyEvent.VK_PAGE_DOWN); + robot.keyRelease(KeyEvent.VK_PAGE_DOWN); + robot.keyPress(KeyEvent.VK_PAGE_UP); + robot.keyRelease(KeyEvent.VK_PAGE_UP); + robot.waitForIdle(); - int pos = getTextCaretPosition(); - if (pos0 != pos) { - throw new RuntimeException("Failed 4697612: PgDn & PgUp keys scroll by different amounts"); + int pos = getTextCaretPosition(); + if (pos0 != pos) { + throw new RuntimeException("Failed 4697612: PgDn & PgUp keys scroll by different amounts"); + } + frameHeight++; } - frameHeight++; + fontHeight++; } - fontHeight++; - } + // 6244705: pressing PgDn at the very bottom should not scroll + LookAndFeel laf = UIManager.getLookAndFeel(); + if (laf.getID().equals("Aqua")) { + robot.keyPress(KeyEvent.VK_END); + robot.keyRelease(KeyEvent.VK_END); + } else { + robot.keyPress(KeyEvent.VK_CONTROL); + robot.keyPress(KeyEvent.VK_END); + robot.keyRelease(KeyEvent.VK_END); + robot.keyRelease(KeyEvent.VK_CONTROL); + } + robot.waitForIdle(); + robot.delay(1000); - // 6244705: pressing PgDn at the very bottom should not scroll - LookAndFeel laf = UIManager.getLookAndFeel(); - if (laf.getID().equals("Aqua")) { - Util.hitKeys(robot, KeyEvent.VK_END); - } else { - Util.hitKeys(robot, KeyEvent.VK_CONTROL, KeyEvent.VK_END); - } + pos0 = getScrollerViewPosition(); + robot.keyPress(KeyEvent.VK_PAGE_DOWN); + robot.keyRelease(KeyEvent.VK_PAGE_DOWN); + robot.waitForIdle(); - robot.waitForIdle(); + int pos = getScrollerViewPosition(); - pos0 = getScrollerViewPosition(); - Util.hitKeys(robot, KeyEvent.VK_PAGE_DOWN); - robot.waitForIdle(); - - int pos = getScrollerViewPosition(); - - if (pos0 != pos) { - throw new RuntimeException("Failed 6244705: PgDn at the bottom causes scrolling"); + if (pos0 != pos) { + System.out.println("pos0 " + pos0 + " pos " + pos); + throw new RuntimeException("Failed 6244705: PgDn at the bottom causes scrolling"); + } + } finally { + SwingUtilities.invokeAndWait(() -> frame.dispose()); } } From e551b06bb7b5622d5af98b19d1ae0c91fe2ebc5f Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Fri, 28 Jul 2017 14:39:48 -0700 Subject: [PATCH 33/98] 8139050: -[AWTView draggingEnded:]: unrecognized selector message during drag and drop Reviewed-by: azvegint --- .../macosx/native/libawt_lwawt/awt/AWTView.m | 74 ++++----- .../MissingEventsOnModalDialogTest.java | 78 ++++++++- .../dnd/8139050/NativeErrorsInTableDnD.java | 153 ++++++++++++++++++ 3 files changed, 254 insertions(+), 51 deletions(-) create mode 100644 jdk/test/javax/swing/dnd/8139050/NativeErrorsInTableDnD.java diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m index 1431b98aabf..01a4b5498aa 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -770,11 +770,9 @@ static BOOL shouldUsePressAndHold() { CDragSource *dragSource = self._dragSource; NSDragOperation dragOp = NSDragOperationNone; - if (dragSource != nil) + if (dragSource != nil) { dragOp = [dragSource draggingSourceOperationMaskForLocal:flag]; - else if ([super respondsToSelector:@selector(draggingSourceOperationMaskForLocal:)]) - dragOp = [super draggingSourceOperationMaskForLocal:flag]; - + } return dragOp; } @@ -784,11 +782,9 @@ static BOOL shouldUsePressAndHold() { CDragSource *dragSource = self._dragSource; NSArray* array = nil; - if (dragSource != nil) + if (dragSource != nil) { array = [dragSource namesOfPromisedFilesDroppedAtDestination:dropDestination]; - else if ([super respondsToSelector:@selector(namesOfPromisedFilesDroppedAtDestination:)]) - array = [super namesOfPromisedFilesDroppedAtDestination:dropDestination]; - + } return array; } @@ -797,10 +793,9 @@ static BOOL shouldUsePressAndHold() { // If draggingSource is nil route the message to the superclass (if responding to the selector): CDragSource *dragSource = self._dragSource; - if (dragSource != nil) + if (dragSource != nil) { [dragSource draggedImage:image beganAt:screenPoint]; - else if ([super respondsToSelector:@selector(draggedImage::)]) - [super draggedImage:image beganAt:screenPoint]; + } } - (void)draggedImage:(NSImage *)image endedAt:(NSPoint)screenPoint operation:(NSDragOperation)operation @@ -808,10 +803,9 @@ static BOOL shouldUsePressAndHold() { // If draggingSource is nil route the message to the superclass (if responding to the selector): CDragSource *dragSource = self._dragSource; - if (dragSource != nil) + if (dragSource != nil) { [dragSource draggedImage:image endedAt:screenPoint operation:operation]; - else if ([super respondsToSelector:@selector(draggedImage:::)]) - [super draggedImage:image endedAt:screenPoint operation:operation]; + } } - (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenPoint @@ -819,10 +813,9 @@ static BOOL shouldUsePressAndHold() { // If draggingSource is nil route the message to the superclass (if responding to the selector): CDragSource *dragSource = self._dragSource; - if (dragSource != nil) + if (dragSource != nil) { [dragSource draggedImage:image movedTo:screenPoint]; - else if ([super respondsToSelector:@selector(draggedImage::)]) - [super draggedImage:image movedTo:screenPoint]; + } } - (BOOL)ignoreModifierKeysWhileDragging @@ -831,11 +824,9 @@ static BOOL shouldUsePressAndHold() { CDragSource *dragSource = self._dragSource; BOOL result = FALSE; - if (dragSource != nil) + if (dragSource != nil) { result = [dragSource ignoreModifierKeysWhileDragging]; - else if ([super respondsToSelector:@selector(ignoreModifierKeysWhileDragging)]) - result = [super ignoreModifierKeysWhileDragging]; - + } return result; } @@ -849,11 +840,9 @@ static BOOL shouldUsePressAndHold() { CDropTarget *dropTarget = self._dropTarget; NSDragOperation dragOp = NSDragOperationNone; - if (dropTarget != nil) + if (dropTarget != nil) { dragOp = [dropTarget draggingEntered:sender]; - else if ([super respondsToSelector:@selector(draggingEntered:)]) - dragOp = [super draggingEntered:sender]; - + } return dragOp; } @@ -863,11 +852,9 @@ static BOOL shouldUsePressAndHold() { CDropTarget *dropTarget = self._dropTarget; NSDragOperation dragOp = NSDragOperationNone; - if (dropTarget != nil) + if (dropTarget != nil) { dragOp = [dropTarget draggingUpdated:sender]; - else if ([super respondsToSelector:@selector(draggingUpdated:)]) - dragOp = [super draggingUpdated:sender]; - + } return dragOp; } @@ -876,10 +863,9 @@ static BOOL shouldUsePressAndHold() { // If draggingDestination is nil route the message to the superclass: CDropTarget *dropTarget = self._dropTarget; - if (dropTarget != nil) + if (dropTarget != nil) { [dropTarget draggingExited:sender]; - else if ([super respondsToSelector:@selector(draggingExited:)]) - [super draggingExited:sender]; + } } - (BOOL)prepareForDragOperation:(id )sender @@ -888,11 +874,9 @@ static BOOL shouldUsePressAndHold() { CDropTarget *dropTarget = self._dropTarget; BOOL result = FALSE; - if (dropTarget != nil) + if (dropTarget != nil) { result = [dropTarget prepareForDragOperation:sender]; - else if ([super respondsToSelector:@selector(prepareForDragOperation:)]) - result = [super prepareForDragOperation:sender]; - + } return result; } @@ -902,11 +886,9 @@ static BOOL shouldUsePressAndHold() { CDropTarget *dropTarget = self._dropTarget; BOOL result = FALSE; - if (dropTarget != nil) + if (dropTarget != nil) { result = [dropTarget performDragOperation:sender]; - else if ([super respondsToSelector:@selector(performDragOperation:)]) - result = [super performDragOperation:sender]; - + } return result; } @@ -915,10 +897,9 @@ static BOOL shouldUsePressAndHold() { // If draggingDestination is nil route the message to the superclass: CDropTarget *dropTarget = self._dropTarget; - if (dropTarget != nil) + if (dropTarget != nil) { [dropTarget concludeDragOperation:sender]; - else if ([super respondsToSelector:@selector(concludeDragOperation:)]) - [super concludeDragOperation:sender]; + } } - (void)draggingEnded:(id )sender @@ -926,10 +907,9 @@ static BOOL shouldUsePressAndHold() { // If draggingDestination is nil route the message to the superclass: CDropTarget *dropTarget = self._dropTarget; - if (dropTarget != nil) + if (dropTarget != nil) { [dropTarget draggingEnded:sender]; - else if ([super respondsToSelector:@selector(draggingEnded:)]) - [super draggingEnded:sender]; + } } /******************************** END NSDraggingDestination Interface ********************************/ diff --git a/jdk/test/java/awt/dnd/MissingEventsOnModalDialog/MissingEventsOnModalDialogTest.java b/jdk/test/java/awt/dnd/MissingEventsOnModalDialog/MissingEventsOnModalDialogTest.java index a9ea6ecedf1..1c98a3ebe59 100644 --- a/jdk/test/java/awt/dnd/MissingEventsOnModalDialog/MissingEventsOnModalDialogTest.java +++ b/jdk/test/java/awt/dnd/MissingEventsOnModalDialog/MissingEventsOnModalDialogTest.java @@ -41,20 +41,44 @@ import java.awt.event.InputEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.concurrent.TimeUnit; + /* * @test * @key headful - * @bug 8134917 + * @bug 8134917 8139050 * @summary [macosx] JOptionPane doesn't receive mouse events when opened from a drop event - * @author Alexandr Scherbatiy + * @run main MissingEventsOnModalDialogTest RUN_PROCESS */ public class MissingEventsOnModalDialogTest { + private static final String RUN_PROCESS = "RUN_PROCESS"; + private static final String RUN_TEST = "RUN_TEST"; + private static boolean exception = false; private static volatile boolean passed = false; public static void main(String[] args) throws Exception { - Frame sourceFrame = createFrame("Source Frame", 0, 0); - Frame targetFrame = createFrame("Target Frame", 250, 250); + String command = args.length < 1 ? RUN_TEST : args[0]; + switch (command) { + case RUN_PROCESS: + runProcess(); + break; + case RUN_TEST: + runTest(); + break; + default: + throw new RuntimeException("Unknown command: " + command); + } + } + + private static void runTest() throws Exception { + Frame sourceFrame = createFrame("Source Frame", 100, 100); + Frame targetFrame = createFrame("Target Frame", 350, 350); DragSource defaultDragSource = DragSource.getDefaultDragSource(); @@ -237,4 +261,50 @@ public class MissingEventsOnModalDialogTest { throw new RuntimeException(e); } } + + private static void runProcess() throws Exception { + String javaPath = System.getProperty("java.home", ""); + String command = javaPath + File.separator + "bin" + File.separator + "java" + + " " + MissingEventsOnModalDialogTest.class.getName() + " " + RUN_TEST; + + Process process = Runtime.getRuntime().exec(command); + boolean processExit = process.waitFor(20, TimeUnit.SECONDS); + + StringBuilder inStream = new StringBuilder(); + StringBuilder errStream = new StringBuilder(); + checkErrors(process.getErrorStream(), errStream); + checkErrors(process.getInputStream(), inStream); + + if (exception) { + System.out.println(inStream); + System.err.println(errStream); + throw new RuntimeException("Exception in the output!"); + } + + if (!processExit) { + process.destroy(); + throw new RuntimeException("" + + "The sub process has not exited!"); + } + } + + private static boolean containsError(String line) { + line = line.toLowerCase(); + return line.contains("exception") || line.contains("error") + || line.contains("selector"); + } + + private static void checkErrors(InputStream in, StringBuilder stream) throws IOException { + try (BufferedReader bufferedReader + = new BufferedReader(new InputStreamReader(in))) { + + String line = null; + while ((line = bufferedReader.readLine()) != null) { + if (!exception) { + exception = containsError(line); + } + stream.append(line).append("\n"); + } + } + } } diff --git a/jdk/test/javax/swing/dnd/8139050/NativeErrorsInTableDnD.java b/jdk/test/javax/swing/dnd/8139050/NativeErrorsInTableDnD.java new file mode 100644 index 00000000000..d31d50e856c --- /dev/null +++ b/jdk/test/javax/swing/dnd/8139050/NativeErrorsInTableDnD.java @@ -0,0 +1,153 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Rectangle; +import java.awt.event.InputEvent; +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JFrame; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + +import static javax.swing.UIManager.getInstalledLookAndFeels; + +/** + * @test + * @bug 8139050 + * @library ../../../../lib/testlibrary + * @build ExtendedRobot + * @run main/othervm/timeout=360 -Xcheck:jni NativeErrorsInTableDnD + */ +public final class NativeErrorsInTableDnD { + + private static JFrame frame; + + private static volatile Rectangle bounds; + + public static void main(final String[] args) throws Exception { + if (args.length == 0) { + createChildProcess(); + return; + } + for (final UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) { + SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf)); + + SwingUtilities.invokeAndWait(() -> { + final JTable table = new JTable(10, 10); + frame = new JFrame(); + frame.setUndecorated(true); + table.setDragEnabled(true); + table.selectAll(); + frame.add(table); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + final ExtendedRobot r = new ExtendedRobot(); + r.waitForIdle(); + SwingUtilities.invokeAndWait(() -> { + bounds = frame.getBounds(); + }); + for (int i = 0; i < 5; ++i) { + int x1 = bounds.x + bounds.width / 4; + int y1 = bounds.y + bounds.height / 4; + r.setAutoDelay(50); + // Special sequence of clicks which reproduce the problem + r.mouseMove(bounds.x + bounds.width / 7, y1); + r.mousePress(InputEvent.BUTTON1_DOWN_MASK); + r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + r.mousePress(InputEvent.BUTTON1_DOWN_MASK); + r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + r.mouseMove(x1, y1); + r.mousePress(InputEvent.BUTTON1_DOWN_MASK); + r.setAutoDelay(0); + r.glide(x1, y1, x1 + bounds.width / 4, y1 + bounds.height / 4); + r.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + } + SwingUtilities.invokeAndWait(() -> { + frame.dispose(); + }); + r.waitForIdle(); + } + } + + static void createChildProcess() throws Exception { + final String javaPath = System.getProperty("java.home"); + final String classPathDir = System.getProperty("java.class.path"); + doExec(javaPath + File.separator + "bin" + File.separator + "java", + "-cp", classPathDir, "NativeErrorsInTableDnD", "start"); + } + + static void doExec(final String... cmds) throws Exception { + Process p; + final ProcessBuilder pb = new ProcessBuilder(cmds); + for (final String cmd : cmds) { + System.out.print(cmd + " "); + } + System.out.println(); + BufferedReader rdr; + final List errorList = new ArrayList<>(); + final List outputList = new ArrayList<>(); + p = pb.start(); + rdr = new BufferedReader(new InputStreamReader(p.getInputStream())); + String in = rdr.readLine(); + while (in != null) { + outputList.add(in); + in = rdr.readLine(); + System.out.println(in); + } + rdr = new BufferedReader(new InputStreamReader(p.getErrorStream())); + in = rdr.readLine(); + while (in != null) { + errorList.add(in); + in = rdr.readLine(); + System.err.println(in); + } + p.waitFor(); + p.destroy(); + + if (!errorList.isEmpty()) { + throw new RuntimeException("Error log is not empty"); + } + final int exit = p.exitValue(); + if (exit != 0) { + throw new RuntimeException("Exit status = " + exit); + } + } + + private static void setLookAndFeel(final UIManager.LookAndFeelInfo laf) { + try { + UIManager.setLookAndFeel(laf.getClassName()); + System.out.println("LookAndFeel: " + laf.getClassName()); + } catch (ClassNotFoundException | InstantiationException | + UnsupportedLookAndFeelException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } +} From 252bdeafe63c308a4b9e31db1c4a5d1578528afe Mon Sep 17 00:00:00 2001 From: Krishna Addepalli Date: Wed, 2 Aug 2017 11:26:57 +0530 Subject: [PATCH 34/98] 8027154: [TESTBUG] Test java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopup.java fails Reviewed-by: serb, arapte --- .../GetMousePositionWithPopup.java | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/jdk/test/java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopup.java b/jdk/test/java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopup.java index 7ff5e0f31d2..28f1faa82ee 100644 --- a/jdk/test/java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopup.java +++ b/jdk/test/java/awt/Mouse/GetMousePositionTest/GetMousePositionWithPopup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -31,7 +31,7 @@ import java.awt.event.MouseMotionAdapter; /** * @test * @key headful - * @bug 8012026 + * @bug 8012026 8027154 * @summary Component.getMousePosition() does not work in an applet on MacOS * @author Petr Pchelko * @library ../../regtesthelpers @@ -80,33 +80,31 @@ public class GetMousePositionWithPopup { frame1.setBounds(100, 100, 100, 100); frame1.addMouseMotionListener(new MouseMotionAdapter() { - private boolean shown = false; - @Override public void mouseMoved(MouseEvent e) { - if (shown) { - return; - } - - shown = true; - frame2 = new Frame(); frame2.setBounds(120, 120, 120, 120); + + frame2.addMouseMotionListener(new MouseMotionAdapter() { + @Override + public void mouseMoved(MouseEvent e) + { + Point positionInFrame2 = frame2.getMousePosition(); + if (positionInFrame2.x != 30 || positionInFrame2.y != 30) { + throw new RuntimeException("Wrong position reported. Should be [30, 30] but was [" + + positionInFrame2.x + ", " + positionInFrame2.y + "]"); + } + + Point positionInFrame1 = frame1.getMousePosition(); + if (positionInFrame1 != null) { + throw new RuntimeException("Wrong position reported. Should be null"); + } + } + }); + frame2.setVisible(true); - - Point positionInFrame2 = frame2.getMousePosition(); - if (positionInFrame2.x != 30 || positionInFrame2.y != 30) { - throw new RuntimeException("Wrong position reported. Should be [30, 30] but was [" + - positionInFrame2.x + ", " + positionInFrame2.y + "]"); - } - - Point positionInFrame1 = frame1.getMousePosition(); - if (positionInFrame1 != null) { - throw new RuntimeException("Wrong position reported. Should be null"); - } - } }); frame1.setVisible(true); } -} +} \ No newline at end of file From 5b641597aee1f75ba8aeaf5bf94a404bbfd45d08 Mon Sep 17 00:00:00 2001 From: Shashidhara Veerabhadraiah Date: Thu, 3 Aug 2017 14:55:48 +0530 Subject: [PATCH 35/98] 8058785: Nimbus disabled tooltip needs border Reviewed-by: serb, pkbalakr --- .../classes/javax/swing/plaf/nimbus/skin.laf | 41 +++- .../nimbus/TestDisabledToolTipBorder.java | 196 ++++++++++++++++++ 2 files changed, 236 insertions(+), 1 deletion(-) create mode 100644 jdk/test/javax/swing/plaf/nimbus/TestDisabledToolTipBorder.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/skin.laf b/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/skin.laf index da41a8ba051..681a0aa785e 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/skin.laf +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/skin.laf @@ -1,7 +1,7 @@ see ArrayKlass::complete_create_array_klass() - k->restore_unshareable_info(ClassLoaderData::the_null_class_loader_data(), Handle(), CHECK); +void InstanceKlass::remove_java_mirror() { + Klass::remove_java_mirror(); + + // do array classes also. + if (array_klasses() != NULL) { + array_klasses()->remove_java_mirror(); + } } void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) { @@ -2114,7 +2122,11 @@ void InstanceKlass::restore_unshareable_info(ClassLoaderData* loader_data, Handl // restore constant pool resolved references constants()->restore_unshareable_info(CHECK); - array_klasses_do(restore_unshareable_in_class, CHECK); + if (array_klasses() != NULL) { + // Array classes have null protection domain. + // --> see ArrayKlass::complete_create_array_klass() + array_klasses()->restore_unshareable_info(ClassLoaderData::the_null_class_loader_data(), Handle(), CHECK); + } } // returns true IFF is_in_error_state() has been changed as a result of this call. diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 138b0345cd9..7bd6122f3aa 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -327,8 +327,6 @@ class InstanceKlass: public Klass { } void set_class_loader_type(s2 loader_type) { - assert(( _misc_flags & loader_type_bits()) == 0, - "Should only be called once for each class."); switch (loader_type) { case ClassLoader::BOOT_LOADER: _misc_flags |= _misc_is_shared_boot_class; @@ -1335,6 +1333,7 @@ private: public: // CDS support - remove and restore oops from metadata. Oops are not shared. virtual void remove_unshareable_info(); + virtual void remove_java_mirror(); virtual void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS); // jvm support diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp index 60c3dc4caab..7d8670f6a06 100644 --- a/hotspot/src/share/vm/oops/klass.cpp +++ b/hotspot/src/share/vm/oops/klass.cpp @@ -512,11 +512,13 @@ void Klass::metaspace_pointers_do(MetaspaceClosure* it) { void Klass::remove_unshareable_info() { assert (DumpSharedSpaces, "only called for DumpSharedSpaces"); TRACE_REMOVE_ID(this); + if (log_is_enabled(Trace, cds, unshareable)) { + ResourceMark rm; + log_trace(cds, unshareable)("remove: %s", external_name()); + } set_subklass(NULL); set_next_sibling(NULL); - // Clear the java mirror - set_java_mirror(NULL); set_next_link(NULL); // Null out class_loader_data because we don't share that yet. @@ -524,10 +526,23 @@ void Klass::remove_unshareable_info() { set_is_shared(); } +void Klass::remove_java_mirror() { + assert (DumpSharedSpaces, "only called for DumpSharedSpaces"); + if (log_is_enabled(Trace, cds, unshareable)) { + ResourceMark rm; + log_trace(cds, unshareable)("remove java_mirror: %s", external_name()); + } + set_java_mirror(NULL); +} + void Klass::restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS) { assert(is_klass(), "ensure C++ vtable is restored"); assert(is_shared(), "must be set"); TRACE_RESTORE_ID(this); + if (log_is_enabled(Trace, cds, unshareable)) { + ResourceMark rm; + log_trace(cds, unshareable)("restore: %s", external_name()); + } // If an exception happened during CDS restore, some of these fields may already be // set. We leave the class on the CLD list, even if incomplete so that we don't diff --git a/hotspot/src/share/vm/oops/klass.hpp b/hotspot/src/share/vm/oops/klass.hpp index db54430825b..5eb4ae201e0 100644 --- a/hotspot/src/share/vm/oops/klass.hpp +++ b/hotspot/src/share/vm/oops/klass.hpp @@ -479,6 +479,7 @@ protected: // CDS support - remove and restore oops from metadata. Oops are not shared. virtual void remove_unshareable_info(); + virtual void remove_java_mirror(); virtual void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS); protected: diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index 313029db8e3..f58e96de06a 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -944,10 +944,6 @@ void Method::unlink_method() { _from_compiled_entry = cds_adapter->get_c2i_entry_trampoline(); assert(*((int*)_from_compiled_entry) == 0, "must be NULL during dump time, to be initialized at run time"); - - // In case of DumpSharedSpaces, _method_data should always be NULL. - assert(_method_data == NULL, "unexpected method data?"); - set_method_data(NULL); clear_method_counters(); } diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index e3c0b3edbb6..578ec010af9 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -1291,13 +1291,11 @@ void Arguments::check_unsupported_dumping_properties() { "jdk.module.limitmods", "jdk.module.path", "jdk.module.upgrade.path", - "jdk.module.addmods.0", "jdk.module.patch.0" }; const char* unsupported_options[] = { "-m", // cannot use at dump time "--limit-modules", // ignored at dump time "--module-path", // ignored at dump time "--upgrade-module-path", // ignored at dump time - "--add-modules", // ignored at dump time "--patch-module" // ignored at dump time }; assert(ARRAY_SIZE(unsupported_properties) == ARRAY_SIZE(unsupported_options), "must be"); @@ -2667,17 +2665,11 @@ jint Arguments::parse_vm_init_args(const JavaVMInitArgs *java_tool_options_args, } // Do final processing now that all arguments have been parsed - result = finalize_vm_init_args(); + result = finalize_vm_init_args(patch_mod_javabase); if (result != JNI_OK) { return result; } -#if INCLUDE_CDS - if (UseSharedSpaces && patch_mod_javabase) { - no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched."); - } -#endif - return JNI_OK; } @@ -3602,7 +3594,7 @@ static int check_non_empty_dirs(const char* path) { return nonEmptyDirs; } -jint Arguments::finalize_vm_init_args() { +jint Arguments::finalize_vm_init_args(bool patch_mod_javabase) { // check if the default lib/endorsed directory exists; if so, error char path[JVM_MAXPATHLEN]; const char* fileSep = os::file_separator(); @@ -3723,6 +3715,17 @@ jint Arguments::finalize_vm_init_args() { } #endif +#if INCLUDE_CDS + if (DumpSharedSpaces) { + // Disable biased locking now as it interferes with the clean up of + // the archived Klasses and Java string objects (at dump time only). + UseBiasedLocking = false; + } + if (UseSharedSpaces && patch_mod_javabase) { + no_shared_spaces("CDS is disabled when " JAVA_BASE_NAME " module is patched."); + } +#endif + return JNI_OK; } diff --git a/hotspot/src/share/vm/runtime/arguments.hpp b/hotspot/src/share/vm/runtime/arguments.hpp index 8925018c95e..56fd5ff4434 100644 --- a/hotspot/src/share/vm/runtime/arguments.hpp +++ b/hotspot/src/share/vm/runtime/arguments.hpp @@ -536,7 +536,7 @@ class Arguments : AllStatic { const JavaVMInitArgs *java_options_args, const JavaVMInitArgs *cmd_line_args); static jint parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_mod_javabase, Flag::Flags origin); - static jint finalize_vm_init_args(); + static jint finalize_vm_init_args(bool patch_mod_javabase); static bool is_bad_option(const JavaVMOption* option, jboolean ignore, const char* option_type); static bool is_bad_option(const JavaVMOption* option, jboolean ignore) { diff --git a/hotspot/src/share/vm/runtime/arguments_ext.hpp b/hotspot/src/share/vm/runtime/arguments_ext.hpp index a43a4b908cc..d1c9f183e8e 100644 --- a/hotspot/src/share/vm/runtime/arguments_ext.hpp +++ b/hotspot/src/share/vm/runtime/arguments_ext.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -36,6 +36,7 @@ public: // Otherwise returns false. static inline bool process_options(const JavaVMOption *option) { return false; } static inline void report_unsupported_options() { } + static inline bool using_AppCDS() { return false; } }; void ArgumentsExt::set_gc_specific_flags() { diff --git a/hotspot/src/share/vm/runtime/javaCalls.cpp b/hotspot/src/share/vm/runtime/javaCalls.cpp index b8da6ed6453..74343a262b9 100644 --- a/hotspot/src/share/vm/runtime/javaCalls.cpp +++ b/hotspot/src/share/vm/runtime/javaCalls.cpp @@ -308,9 +308,6 @@ void JavaCalls::call(JavaValue* result, const methodHandle& method, JavaCallArgu } void JavaCalls::call_helper(JavaValue* result, const methodHandle& method, JavaCallArguments* args, TRAPS) { - // During dumping, Java execution environment is not fully initialized. Also, Java execution - // may cause undesirable side-effects in the class metadata. - assert(!DumpSharedSpaces, "must not execute Java bytecodes when dumping"); JavaThread* thread = (JavaThread*)THREAD; assert(thread->is_Java_thread(), "must be called by a java thread"); diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index 8556fa10cc8..cbcc91c4180 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -3717,14 +3717,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { Thread* THREAD = Thread::current(); - // At this point, the Universe is initialized, but we have not executed - // any byte code. Now is a good time (the only time) to dump out the - // internal state of the JVM for sharing. - if (DumpSharedSpaces) { - MetaspaceShared::preload_and_dump(CHECK_JNI_ERR); - ShouldNotReachHere(); - } - // Always call even when there are not JVMTI environments yet, since environments // may be attached late and JVMTI must track phases of VM execution JvmtiExport::enter_early_start_phase(); @@ -3887,6 +3879,12 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { #ifdef ASSERT _vm_complete = true; #endif + + if (DumpSharedSpaces) { + MetaspaceShared::preload_and_dump(CHECK_JNI_ERR); + ShouldNotReachHere(); + } + return JNI_OK; } diff --git a/hotspot/src/share/vm/utilities/exceptions.cpp b/hotspot/src/share/vm/utilities/exceptions.cpp index 9fce899c93c..cea61a19f9c 100644 --- a/hotspot/src/share/vm/utilities/exceptions.cpp +++ b/hotspot/src/share/vm/utilities/exceptions.cpp @@ -87,13 +87,9 @@ bool Exceptions::special_exception(Thread* thread, const char* file, int line, H #endif // ASSERT if (thread->is_VM_thread() - || !thread->can_call_java() - || DumpSharedSpaces ) { + || !thread->can_call_java()) { // We do not care what kind of exception we get for the vm-thread or a thread which // is compiling. We just install a dummy exception object - // - // We also cannot throw a proper exception when dumping, because we cannot run - // Java bytecodes now. A dummy exception will suffice. thread->set_pending_exception(Universe::vm_exception(), file, line); return true; } @@ -114,13 +110,9 @@ bool Exceptions::special_exception(Thread* thread, const char* file, int line, S } if (thread->is_VM_thread() - || !thread->can_call_java() - || DumpSharedSpaces ) { + || !thread->can_call_java()) { // We do not care what kind of exception we get for the vm-thread or a thread which // is compiling. We just install a dummy exception object - // - // We also cannot throw a proper exception when dumping, because we cannot run - // Java bytecodes now. A dummy exception will suffice. thread->set_pending_exception(Universe::vm_exception(), file, line); return true; } diff --git a/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java b/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java index aadc0f21b6d..c6614fa4d31 100644 --- a/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java +++ b/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java @@ -205,7 +205,11 @@ public class BootAppendTests { OutputAnalyzer out = CDSTestUtils.runWithArchive(opts); CDSTestUtils.checkExec(out, opts, "[class,load] org.omg.CORBA.Context"); if (!CDSTestUtils.isUnableToMap(out)) { - out.shouldMatch(".*\\[class,load\\] org.omg.CORBA.Context source:.*bootAppend.jar"); + if (mode.equals("off")) { + out.shouldMatch(".*\\[class,load\\] org.omg.CORBA.Context source:.*bootAppend.jar"); + } else { + CDSTestUtils.checkExec(out, opts, "[class,load] org.omg.CORBA.Context source: shared objects file"); + } } } } diff --git a/hotspot/test/runtime/SharedArchiveFile/NonBootLoaderClasses.java b/hotspot/test/runtime/SharedArchiveFile/NonBootLoaderClasses.java new file mode 100644 index 00000000000..bf840dd566e --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/NonBootLoaderClasses.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test NonBootLoaderClasses + * @summary Test to ensure platform and app classes are not being archived + * @requires (vm.opt.UseCompressedOops == null) | (vm.opt.UseCompressedOops == true) + * @library /test/lib + * @modules java.base/jdk.internal.misc + * java.management + * @run main NonBootLoaderClasses + */ + +import jdk.test.lib.cds.CDSOptions; +import jdk.test.lib.cds.CDSTestUtils; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; +import java.io.File; + +public class NonBootLoaderClasses { + public static void main(String[] args) throws Exception { + final String PLATFORM_CLASS = "jdk/dynalink/DynamicLinker"; + final String APP_CLASS = "com/sun/tools/javac/Main"; + String[] classes = {PLATFORM_CLASS, APP_CLASS}; + String classList = + CDSTestUtils.makeClassList(classes).getPath(); + String archiveName = "NonBootLoaderClasses.jsa"; + CDSOptions opts = (new CDSOptions()) + .addPrefix("-XX:ExtraSharedClassListFile=" + classList) + .setArchiveName(archiveName); + CDSTestUtils.createArchiveAndCheck(opts); + + // Print the shared dictionary and inspect the output + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./" + archiveName, + "-XX:+PrintSharedArchiveAndExit", "-XX:+PrintSharedDictionary"); + OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "print-shared-archive"); + if (!CDSTestUtils.isUnableToMap(out)) { + out.shouldContain("archive is valid") + .shouldHaveExitValue(0) // Should report success in error code. + .shouldNotContain(PLATFORM_CLASS) + .shouldNotContain(APP_CLASS); + } + } +} diff --git a/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java b/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java index 2ffff49cc78..8321eb6ddb2 100644 --- a/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java +++ b/hotspot/test/runtime/modules/PatchModule/PatchModuleCDS.java @@ -69,7 +69,7 @@ public class PatchModuleCDS { "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=" + filename, "-Xshare:dump", - "--patch-module=java.base=" + System.getProperty("test.classes"), + "--patch-module=java.naming=" + System.getProperty("test.classes"), "-Xlog:class+path=info", "-version"); new OutputAnalyzer(pb.start()) From 13be218cd2556c33b406d67ef77b9d6db90259e1 Mon Sep 17 00:00:00 2001 From: Muthusamy Chinnathambi Date: Tue, 29 Aug 2017 05:33:15 -0400 Subject: [PATCH 58/98] 8185624: G1HeapVerifier's VerifyRootsClosure prints important information on info log level Fix logging of broken oop to error log level instead of info log level Reviewed-by: mgerdin, tschatzl --- hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp b/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp index f7e3b82ffed..8b2e0334333 100644 --- a/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp +++ b/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp @@ -62,7 +62,7 @@ public: oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); if (_g1h->is_obj_dead_cond(obj, _vo)) { Log(gc, verify) log; - log.info("Root location " PTR_FORMAT " points to dead obj " PTR_FORMAT, p2i(p), p2i(obj)); + log.error("Root location " PTR_FORMAT " points to dead obj " PTR_FORMAT, p2i(p), p2i(obj)); if (_vo == VerifyOption_G1UseMarkWord) { log.error(" Mark word: " PTR_FORMAT, p2i(obj->mark())); } From 7e51e7940c0bea47ba2503e8d194d7f583bc7c70 Mon Sep 17 00:00:00 2001 From: John Paul Adrian Glaubitz Date: Tue, 29 Aug 2017 18:34:32 +0200 Subject: [PATCH 59/98] 8186855: Multiple platforms broken after 8186476: Generalize Atomic::add with templates Reviewed-by: stuefe, coleenp --- hotspot/src/os_cpu/aix_ppc/vm/atomic_aix_ppc.hpp | 8 ++++---- hotspot/src/os_cpu/bsd_zero/vm/atomic_bsd_zero.hpp | 12 ++++++------ hotspot/src/os_cpu/linux_ppc/vm/atomic_linux_ppc.hpp | 8 ++++---- .../src/os_cpu/linux_s390/vm/atomic_linux_s390.hpp | 12 ++++++------ .../src/os_cpu/linux_sparc/vm/atomic_linux_sparc.hpp | 9 +++++---- .../src/os_cpu/linux_zero/vm/atomic_linux_zero.hpp | 8 ++++---- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/hotspot/src/os_cpu/aix_ppc/vm/atomic_aix_ppc.hpp b/hotspot/src/os_cpu/aix_ppc/vm/atomic_aix_ppc.hpp index 04e418d9f80..cbf54b82c0b 100644 --- a/hotspot/src/os_cpu/aix_ppc/vm/atomic_aix_ppc.hpp +++ b/hotspot/src/os_cpu/aix_ppc/vm/atomic_aix_ppc.hpp @@ -106,8 +106,8 @@ struct Atomic::PlatformAdd template<> template inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const { - STATIC_CAST(4 == sizeof(I)); - STATIC_CAST(4 == sizeof(D)); + STATIC_ASSERT(4 == sizeof(I)); + STATIC_ASSERT(4 == sizeof(D)); D result; @@ -129,8 +129,8 @@ inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) co template<> template inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const { - STATIC_CAST(8 == sizeof(I)); - STATIC_CAST(8 == sizeof(D)); + STATIC_ASSERT(8 == sizeof(I)); + STATIC_ASSERT(8 == sizeof(D)); D result; diff --git a/hotspot/src/os_cpu/bsd_zero/vm/atomic_bsd_zero.hpp b/hotspot/src/os_cpu/bsd_zero/vm/atomic_bsd_zero.hpp index 8f5072ac60c..7fcaf785f9a 100644 --- a/hotspot/src/os_cpu/bsd_zero/vm/atomic_bsd_zero.hpp +++ b/hotspot/src/os_cpu/bsd_zero/vm/atomic_bsd_zero.hpp @@ -184,8 +184,8 @@ struct Atomic::PlatformAdd template<> template inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const { - STATIC_CAST(4 == sizeof(I)); - STATIC_CAST(4 == sizeof(D)); + STATIC_ASSERT(4 == sizeof(I)); + STATIC_ASSERT(4 == sizeof(D)); #ifdef ARM return add_using_helper(arm_add_and_fetch, add_value, dest); @@ -201,8 +201,8 @@ inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) co template<> template inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const { - STATIC_CAST(8 == sizeof(I)); - STATIC_CAST(8 == sizeof(D)); + STATIC_ASSERT(8 == sizeof(I)); + STATIC_ASSERT(8 == sizeof(D)); return __sync_add_and_fetch(dest, add_value); } @@ -283,7 +283,7 @@ inline T Atomic::PlatformCmpxchg<4>::operator()(T exchange_value, T volatile* dest, T compare_value, cmpxchg_memory_order order) const { - STATIC_CAST(4 == sizeof(T)); + STATIC_ASSERT(4 == sizeof(T)); #ifdef ARM return cmpxchg_using_helper(arm_compare_and_swap, exchange_value, dest, compare_value); #else @@ -301,7 +301,7 @@ inline T Atomic::PlatformCmpxchg<8>::operator()(T exchange_value, T volatile* dest, T compare_value, cmpxchg_memory_order order) const { - STATIC_CAST(8 == sizeof(T)); + STATIC_ASSERT(8 == sizeof(T)); return __sync_val_compare_and_swap(dest, compare_value, exchange_value); } diff --git a/hotspot/src/os_cpu/linux_ppc/vm/atomic_linux_ppc.hpp b/hotspot/src/os_cpu/linux_ppc/vm/atomic_linux_ppc.hpp index 124b126d4af..a5a0f7d3124 100644 --- a/hotspot/src/os_cpu/linux_ppc/vm/atomic_linux_ppc.hpp +++ b/hotspot/src/os_cpu/linux_ppc/vm/atomic_linux_ppc.hpp @@ -104,8 +104,8 @@ struct Atomic::PlatformAdd template<> template inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const { - STATIC_CAST(4 == sizeof(I)); - STATIC_CAST(4 == sizeof(D)); + STATIC_ASSERT(4 == sizeof(I)); + STATIC_ASSERT(4 == sizeof(D)); D result; @@ -127,8 +127,8 @@ inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) co template<> template inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const { - STATIC_CAST(8 == sizeof(I)); - STATIC_CAST(8 == sizeof(D)); + STATIC_ASSERT(8 == sizeof(I)); + STATIC_ASSERT(8 == sizeof(D)); D result; diff --git a/hotspot/src/os_cpu/linux_s390/vm/atomic_linux_s390.hpp b/hotspot/src/os_cpu/linux_s390/vm/atomic_linux_s390.hpp index b7e57e5ccce..e7c436bdd6e 100644 --- a/hotspot/src/os_cpu/linux_s390/vm/atomic_linux_s390.hpp +++ b/hotspot/src/os_cpu/linux_s390/vm/atomic_linux_s390.hpp @@ -92,9 +92,9 @@ struct Atomic::PlatformAdd template<> template -inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const { - STATIC_CAST(4 == sizeof(I)); - STATIC_CAST(4 == sizeof(D)); +inline D Atomic::PlatformAdd<4>::add_and_fetch(I inc, D volatile* dest) const { + STATIC_ASSERT(4 == sizeof(I)); + STATIC_ASSERT(4 == sizeof(D)); D old, upd; @@ -143,9 +143,9 @@ inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) co template<> template -inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const { - STATIC_CAST(8 == sizeof(I)); - STATIC_CAST(8 == sizeof(D)); +inline D Atomic::PlatformAdd<8>::add_and_fetch(I inc, D volatile* dest) const { + STATIC_ASSERT(8 == sizeof(I)); + STATIC_ASSERT(8 == sizeof(D)); D old, upd; diff --git a/hotspot/src/os_cpu/linux_sparc/vm/atomic_linux_sparc.hpp b/hotspot/src/os_cpu/linux_sparc/vm/atomic_linux_sparc.hpp index 0284d488c7f..3ea20f8789d 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/atomic_linux_sparc.hpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/atomic_linux_sparc.hpp @@ -62,8 +62,8 @@ struct Atomic::PlatformAdd template<> template inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const { - STATIC_CAST(4 == sizeof(I)); - STATIC_CAST(4 == sizeof(D)); + STATIC_ASSERT(4 == sizeof(I)); + STATIC_ASSERT(4 == sizeof(D)); D rv; __asm__ volatile( @@ -81,10 +81,11 @@ inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) co return rv; } +template<> template inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const { - STATIC_CAST(8 == sizeof(I)); - STATIC_CAST(8 == sizeof(D)); + STATIC_ASSERT(8 == sizeof(I)); + STATIC_ASSERT(8 == sizeof(D)); D rv; __asm__ volatile( diff --git a/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.hpp b/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.hpp index 80438cca8b3..22af8a7fbb8 100644 --- a/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.hpp +++ b/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.hpp @@ -178,8 +178,8 @@ struct Atomic::PlatformAdd template<> template inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const { - STATIC_CAST(4 == sizeof(I)); - STATIC_CAST(4 == sizeof(D)); + STATIC_ASSERT(4 == sizeof(I)); + STATIC_ASSERT(4 == sizeof(D)); #ifdef ARM return add_using_helper(arm_add_and_fetch, add_value, dest); @@ -195,8 +195,8 @@ inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) co template<> template inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const { - STATIC_CAST(8 == sizeof(I)); - STATIC_CAST(8 == sizeof(D)); + STATIC_ASSERT(8 == sizeof(I)); + STATIC_ASSERT(8 == sizeof(D)); return __sync_add_and_fetch(dest, add_value); } From 897a7b3f673ebc0a681b3028acdedac63312f60d Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Tue, 29 Aug 2017 12:17:02 +0200 Subject: [PATCH 60/98] 8186897: semaphore_posix.hpp should not be included on OSX Reviewed-by: stefank, dholmes --- hotspot/src/os/posix/vm/os_posix.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hotspot/src/os/posix/vm/os_posix.cpp b/hotspot/src/os/posix/vm/os_posix.cpp index 8afd1a4e355..554238313f8 100644 --- a/hotspot/src/os/posix/vm/os_posix.cpp +++ b/hotspot/src/os/posix/vm/os_posix.cpp @@ -24,7 +24,6 @@ #include "utilities/globalDefinitions.hpp" #include "prims/jvm.h" -#include "semaphore_posix.hpp" #include "runtime/frame.inline.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/os.hpp" @@ -32,6 +31,11 @@ #include "utilities/macros.hpp" #include "utilities/vmError.hpp" +#ifndef __APPLE__ +// POSIX unamed semaphores are not supported on OS X. +#include "semaphore_posix.hpp" +#endif + #include #include #include From 82859535c3c9de4e5fde50d962d53395e089ac88 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Tue, 29 Aug 2017 10:24:10 -0700 Subject: [PATCH 61/98] 8186462: [Graal] build Graal regardless AOT build Reviewed-by: twisti, thartmann, erikj --- common/autoconf/generated-configure.sh | 10 +++++++--- common/autoconf/hotspot.m4 | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 0ccae613fd3..eed950c7513 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5151,7 +5151,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1503919695 +DATE_WHEN_GENERATED=1504027321 ############################################################################### # @@ -65798,8 +65798,12 @@ $as_echo "yes, forced" >&6; } fi INCLUDE_GRAAL="true" else - # By default enable graal build where AOT is available - if test "x$ENABLE_AOT" = "xtrue"; then + # By default enable graal build on linux-x64 or where AOT is available. + # graal build requires jvmci. + if test "x$JVM_FEATURES_jvmci" = "xjvmci" && \ + (test "x$OPENJDK_TARGET_CPU" = "xx86_64" && \ + test "x$OPENJDK_TARGET_OS" = "xlinux" || \ + test "x$ENABLE_AOT" = "xtrue") ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } JVM_FEATURES_graal="graal" diff --git a/common/autoconf/hotspot.m4 b/common/autoconf/hotspot.m4 index 99803d1770b..fa361eb7fad 100644 --- a/common/autoconf/hotspot.m4 +++ b/common/autoconf/hotspot.m4 @@ -335,8 +335,12 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES], fi INCLUDE_GRAAL="true" else - # By default enable graal build where AOT is available - if test "x$ENABLE_AOT" = "xtrue"; then + # By default enable graal build on linux-x64 or where AOT is available. + # graal build requires jvmci. + if test "x$JVM_FEATURES_jvmci" = "xjvmci" && \ + (test "x$OPENJDK_TARGET_CPU" = "xx86_64" && \ + test "x$OPENJDK_TARGET_OS" = "xlinux" || \ + test "x$ENABLE_AOT" = "xtrue") ; then AC_MSG_RESULT([yes]) JVM_FEATURES_graal="graal" INCLUDE_GRAAL="true" From d74f4e68576c28f43a78523941f4eeab48434df4 Mon Sep 17 00:00:00 2001 From: Bob Vandette Date: Tue, 29 Aug 2017 15:52:59 -0400 Subject: [PATCH 62/98] 8186248: Allow more flexibility in selecting Heap % of available RAM Reviewed-by: dholmes, drwhite --- make/RunTests.gmk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/make/RunTests.gmk b/make/RunTests.gmk index bdcae9137bf..14329787020 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -328,9 +328,9 @@ define SetupRunJtregTestBody $1_JTREG_JOBS := 50 endif - # Make sure MaxRAMFraction is high enough to not cause OOM or swapping since + # Make sure MaxRAMPercentage is high enough to not cause OOM or swapping since # we may end up with a lot of JVM's - $1_JTREG_MAX_RAM_FRACTION := $$(shell $$(EXPR) $$($1_JTREG_JOBS) \* 4) + $1_JTREG_MAX_RAM_PERCENTAGE := $$(shell $$(EXPR) 25 / $$($1_JTREG_JOBS)) JTREG_TIMEOUT ?= 4 JTREG_VERBOSE ?= fail,error,summary @@ -344,7 +344,7 @@ define SetupRunJtregTestBody $1_JTREG_BASIC_OPTIONS += -$$($1_JTREG_TEST_MODE) \ -verbose:$$(JTREG_VERBOSE) -retain:$$(JTREG_RETAIN) \ -concurrency:$$($1_JTREG_JOBS) -timeoutFactor:$$(JTREG_TIMEOUT) \ - -vmoption:-XX:MaxRAMFraction=$$($1_JTREG_MAX_RAM_FRACTION) + -vmoption:-XX:MaxRAMPercentage=$$($1_JTREG_MAX_RAM_PERCENTAGE) $1_JTREG_BASIC_OPTIONS += -automatic -keywords:\!ignore -ignore:quiet From ed869998ddc56ae199fee0539fd8e3c2bc9fc7a7 Mon Sep 17 00:00:00 2001 From: Bob Vandette Date: Tue, 29 Aug 2017 15:53:04 -0400 Subject: [PATCH 63/98] 8186248: Allow more flexibility in selecting Heap % of available RAM Reviewed-by: dholmes, drwhite --- hotspot/src/share/vm/runtime/arguments.cpp | 26 +++++++++++++++---- hotspot/src/share/vm/runtime/globals.hpp | 24 ++++++++++++++--- hotspot/test/Makefile | 4 +-- .../CommandLine/FlagWithInvalidValue.java | 4 +-- ...onBooleanFlagWithInvalidBooleanPrefix.java | 8 +++--- .../CommandLine/VMDeprecatedOptions.java | 3 +++ 6 files changed, 52 insertions(+), 17 deletions(-) diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index e3c0b3edbb6..3300d86e3af 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -379,6 +379,9 @@ static SpecialFlag const special_jvm_flags[] = { { "MaxGCMinorPauseMillis", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() }, { "UseConcMarkSweepGC", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() }, { "MonitorInUseLists", JDK_Version::jdk(10),JDK_Version::undefined(), JDK_Version::undefined() }, + { "MaxRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() }, + { "MinRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() }, + { "InitialRAMFraction", JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() }, // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in: { "DefaultMaxRAMFraction", JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() }, @@ -2069,20 +2072,33 @@ void Arguments::set_heap_size() { } } + // Convert deprecated flags + if (FLAG_IS_DEFAULT(MaxRAMPercentage) && + !FLAG_IS_DEFAULT(MaxRAMFraction)) + MaxRAMPercentage = 100.0 / MaxRAMFraction; + + if (FLAG_IS_DEFAULT(MinRAMPercentage) && + !FLAG_IS_DEFAULT(MinRAMFraction)) + MinRAMPercentage = 100.0 / MinRAMFraction; + + if (FLAG_IS_DEFAULT(InitialRAMPercentage) && + !FLAG_IS_DEFAULT(InitialRAMFraction)) + InitialRAMPercentage = 100.0 / InitialRAMFraction; + // If the maximum heap size has not been set with -Xmx, // then set it as fraction of the size of physical memory, // respecting the maximum and minimum sizes of the heap. if (FLAG_IS_DEFAULT(MaxHeapSize)) { - julong reasonable_max = phys_mem / MaxRAMFraction; - - if (phys_mem <= MaxHeapSize * MinRAMFraction) { + julong reasonable_max = (julong)((phys_mem * MaxRAMPercentage) / 100); + if (phys_mem <= (julong)((MaxHeapSize * MinRAMPercentage) / 100)) { // Small physical memory, so use a minimum fraction of it for the heap - reasonable_max = phys_mem / MinRAMFraction; + reasonable_max = (julong)((phys_mem * MinRAMPercentage) / 100); } else { // Not-small physical memory, so require a heap at least // as large as MaxHeapSize reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize); } + if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) { // Limit the heap size to ErgoHeapSizeLimit reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit); @@ -2135,7 +2151,7 @@ void Arguments::set_heap_size() { reasonable_minimum = limit_by_allocatable_memory(reasonable_minimum); if (InitialHeapSize == 0) { - julong reasonable_initial = phys_mem / InitialRAMFraction; + julong reasonable_initial = (julong)((phys_mem * InitialRAMPercentage) / 100); reasonable_initial = MAX3(reasonable_initial, reasonable_minimum, (julong)min_heap_size()); reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize); diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 477f6f8e17b..7e9dc8768f3 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -2037,7 +2037,7 @@ public: \ product(size_t, ErgoHeapSizeLimit, 0, \ "Maximum ergonomically set heap size (in bytes); zero means use " \ - "MaxRAM / MaxRAMFraction") \ + "MaxRAM * MaxRAMPercentage / 100") \ range(0, max_uintx) \ \ experimental(bool, UseCGroupMemoryLimitForHeap, false, \ @@ -2046,18 +2046,34 @@ public: \ product(uintx, MaxRAMFraction, 4, \ "Maximum fraction (1/n) of real memory used for maximum heap " \ - "size") \ + "size. " \ + "Deprecated, use MaxRAMPercentage instead") \ range(1, max_uintx) \ \ product(uintx, MinRAMFraction, 2, \ "Minimum fraction (1/n) of real memory used for maximum heap " \ - "size on systems with small physical memory size") \ + "size on systems with small physical memory size. " \ + "Deprecated, use MinRAMPercentage instead") \ range(1, max_uintx) \ \ product(uintx, InitialRAMFraction, 64, \ - "Fraction (1/n) of real memory used for initial heap size") \ + "Fraction (1/n) of real memory used for initial heap size. " \ + "Deprecated, use InitialRAMPercentage instead") \ range(1, max_uintx) \ \ + product(double, MaxRAMPercentage, 25.0, \ + "Maximum percentage of real memory used for maximum heap size") \ + range(0.0, 100.0) \ + \ + product(double, MinRAMPercentage, 50.0, \ + "Minimum percentage of real memory used for maximum heap" \ + "size on systems with small physical memory size") \ + range(0.0, 100.0) \ + \ + product(double, InitialRAMPercentage, 1.5625, \ + "Percentage of real memory used for initial heap size") \ + range(0.0, 100.0) \ + \ develop(uintx, MaxVirtMemFraction, 2, \ "Maximum fraction (1/n) of virtual memory used for ergonomically "\ "determining maximum heap size") \ diff --git a/hotspot/test/Makefile b/hotspot/test/Makefile index e615959c473..77d310d340d 100644 --- a/hotspot/test/Makefile +++ b/hotspot/test/Makefile @@ -70,8 +70,8 @@ else ifeq ($(shell expr $(CONCURRENCY) \> 12), 1) CONCURRENCY := 12 endif -# Make sure MaxRAMFraction is high enough to not cause OOM or swapping since we may end up with a lot of JVM's -JTREG_BASIC_OPTIONS += -vmoption:-XX:MaxRAMFraction=$(shell expr $(CONCURRENCY) \* 4) +# Make sure MaxRAMPercentage is high enough to not cause OOM or swapping since we may end up with a lot of JVM's +JTREG_BASIC_OPTIONS += -vmoption:-XX:MaxRAMPercentage=$(shell expr 25 / $(CONCURRENCY)) # Include the common base file with most of the logic include ../../test/TestCommon.gmk diff --git a/hotspot/test/runtime/CommandLine/FlagWithInvalidValue.java b/hotspot/test/runtime/CommandLine/FlagWithInvalidValue.java index c7b605832c1..be0241c5a13 100644 --- a/hotspot/test/runtime/CommandLine/FlagWithInvalidValue.java +++ b/hotspot/test/runtime/CommandLine/FlagWithInvalidValue.java @@ -36,10 +36,10 @@ import jdk.test.lib.process.OutputAnalyzer; public class FlagWithInvalidValue { public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-XX:MaxRAMFraction=v", "-version"); + "-XX:MaxRAMPercentage=v", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("Improperly specified VM option 'MaxRAMFraction=v'"); + output.shouldContain("Improperly specified VM option 'MaxRAMPercentage=v'"); output.shouldHaveExitValue(1); } } diff --git a/hotspot/test/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java b/hotspot/test/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java index b10f021cbe0..3183e94ddad 100644 --- a/hotspot/test/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java +++ b/hotspot/test/runtime/CommandLine/NonBooleanFlagWithInvalidBooleanPrefix.java @@ -36,17 +36,17 @@ import jdk.test.lib.process.OutputAnalyzer; public class NonBooleanFlagWithInvalidBooleanPrefix { public static void main(String[] args) throws Exception { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-XX:-MaxRAMFraction=16", "-version"); + "-XX:-MaxRAMPercentage=1", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("Unexpected +/- setting in VM option 'MaxRAMFraction=16'"); + output.shouldContain("Unexpected +/- setting in VM option 'MaxRAMPercentage=1'"); output.shouldHaveExitValue(1); pb = ProcessTools.createJavaProcessBuilder( - "-XX:+MaxRAMFraction=16", "-version"); + "-XX:+MaxRAMPercentage=1", "-version"); output = new OutputAnalyzer(pb.start()); - output.shouldContain("Unexpected +/- setting in VM option 'MaxRAMFraction=16'"); + output.shouldContain("Unexpected +/- setting in VM option 'MaxRAMPercentage=1'"); output.shouldHaveExitValue(1); } diff --git a/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java b/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java index 0236b7cc3d8..4e1a6bd9434 100644 --- a/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java +++ b/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java @@ -43,6 +43,9 @@ public class VMDeprecatedOptions { {"MaxGCMinorPauseMillis", "1032"}, {"MustCallLoadClassInternal", "false"}, {"UnsyncloadClass", "false"}, + {"MaxRAMFraction", "8"}, + {"MinRAMFraction", "2"}, + {"InitialRAMFraction", "64"}, // deprecated alias flags (see also aliased_jvm_flags): {"DefaultMaxRAMFraction", "4"}, From 8330d49736c6eacdf15bae611a546431badaddf3 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 30 Aug 2017 07:18:02 -0400 Subject: [PATCH 64/98] 8181170: resolved_references array leaks for RedefineClasses Clear out resolved_reference from ClassLoaderData::_handles Reviewed-by: stefank, jiangli, sspitsyn --- .../share/vm/classfile/classLoaderData.cpp | 22 +++++++++++++++++++ .../share/vm/classfile/classLoaderData.hpp | 1 + hotspot/src/share/vm/oops/constantPool.cpp | 2 -- hotspot/src/share/vm/oops/cpCache.cpp | 9 ++++++++ hotspot/src/share/vm/oops/cpCache.hpp | 4 ++-- hotspot/src/share/vm/oops/oopHandle.hpp | 3 +++ 6 files changed, 37 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index 9ae3269edf6..8aaa0ee5044 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -75,6 +75,9 @@ #include "utilities/growableArray.hpp" #include "utilities/macros.hpp" #include "utilities/ostream.hpp" +#if INCLUDE_ALL_GCS +#include "gc/g1/g1SATBCardTableModRefBS.hpp" +#endif // INCLUDE_ALL_GCS #if INCLUDE_TRACE #include "trace/tracing.hpp" #endif @@ -764,6 +767,25 @@ OopHandle ClassLoaderData::add_handle(Handle h) { return OopHandle(_handles.add(h())); } +void ClassLoaderData::remove_handle(OopHandle h) { + oop* ptr = h.ptr_raw(); + if (ptr != NULL) { + assert(_handles.contains(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr)); +#if INCLUDE_ALL_GCS + // This barrier is used by G1 to remember the old oop values, so + // that we don't forget any objects that were live at the snapshot at + // the beginning. + if (UseG1GC) { + oop obj = *ptr; + if (obj != NULL) { + G1SATBCardTableModRefBS::enqueue(obj); + } + } +#endif + *ptr = NULL; + } +} + void ClassLoaderData::init_handle_locked(OopHandle& dest, Handle h) { MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag); if (dest.resolve() != NULL) { diff --git a/hotspot/src/share/vm/classfile/classLoaderData.hpp b/hotspot/src/share/vm/classfile/classLoaderData.hpp index b6a69f2a3ed..524c985dea2 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp @@ -364,6 +364,7 @@ class ClassLoaderData : public CHeapObj { const char* loader_name(); OopHandle add_handle(Handle h); + void remove_handle(OopHandle h); void init_handle_locked(OopHandle& pd, Handle h); // used for concurrent access to ModuleEntry::_pd field void add_class(Klass* k, bool publicize = true); void remove_class(Klass* k); diff --git a/hotspot/src/share/vm/oops/constantPool.cpp b/hotspot/src/share/vm/oops/constantPool.cpp index 9099e8b239e..f38634e9327 100644 --- a/hotspot/src/share/vm/oops/constantPool.cpp +++ b/hotspot/src/share/vm/oops/constantPool.cpp @@ -89,8 +89,6 @@ ConstantPool::ConstantPool(Array* tags) : void ConstantPool::deallocate_contents(ClassLoaderData* loader_data) { if (cache() != NULL) { - MetadataFactory::free_array(loader_data, reference_map()); - set_reference_map(NULL); MetadataFactory::free_metadata(loader_data, cache()); set_cache(NULL); } diff --git a/hotspot/src/share/vm/oops/cpCache.cpp b/hotspot/src/share/vm/oops/cpCache.cpp index 7eb1a6e568a..d4b2aafb48d 100644 --- a/hotspot/src/share/vm/oops/cpCache.cpp +++ b/hotspot/src/share/vm/oops/cpCache.cpp @@ -26,6 +26,7 @@ #include "interpreter/interpreter.hpp" #include "interpreter/rewriter.hpp" #include "logging/log.hpp" +#include "memory/metadataFactory.hpp" #include "memory/metaspaceClosure.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.inline.hpp" @@ -608,6 +609,14 @@ void ConstantPoolCache::initialize(const intArray& inverse_index_map, } } +void ConstantPoolCache::deallocate_contents(ClassLoaderData* data) { + assert(!is_shared(), "shared caches are not deallocated"); + data->remove_handle(_resolved_references); + set_resolved_references(NULL); + MetadataFactory::free_array(data, _reference_map); + set_reference_map(NULL); +} + #if INCLUDE_CDS_JAVA_HEAP oop ConstantPoolCache::archived_references() { assert(UseSharedSpaces, "UseSharedSpaces expected."); diff --git a/hotspot/src/share/vm/oops/cpCache.hpp b/hotspot/src/share/vm/oops/cpCache.hpp index 5a2b1731b74..b4c9db5b0fe 100644 --- a/hotspot/src/share/vm/oops/cpCache.hpp +++ b/hotspot/src/share/vm/oops/cpCache.hpp @@ -510,9 +510,9 @@ class ConstantPoolCache: public MetaspaceObj { void dump_cache(); #endif // INCLUDE_JVMTI - // Deallocate - no fields to deallocate + // RedefineClasses support DEBUG_ONLY(bool on_stack() { return false; }) - void deallocate_contents(ClassLoaderData* data) {} + void deallocate_contents(ClassLoaderData* data); bool is_klass() const { return false; } // Printing diff --git a/hotspot/src/share/vm/oops/oopHandle.hpp b/hotspot/src/share/vm/oops/oopHandle.hpp index 3afea4ab097..0eb034a31a4 100644 --- a/hotspot/src/share/vm/oops/oopHandle.hpp +++ b/hotspot/src/share/vm/oops/oopHandle.hpp @@ -46,6 +46,9 @@ public: OopHandle(oop* w) : _obj(w) {} oop resolve() const { return (_obj == NULL) ? (oop)NULL : *_obj; } + + // Used only for removing handle. + oop* ptr_raw() { return _obj; } }; #endif // SHARE_VM_OOPS_OOPHANDLE_HPP From f1ff1ca94b98a8b4d228db8a6183aa5200e5734d Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Wed, 30 Aug 2017 15:48:47 +0200 Subject: [PATCH 65/98] 8186797: cardtable_rs in g1CollectedHeap::initialize() defined, but never used Reviewed-by: tschatzl, ehelin --- hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index cb7ef90b7b5..19e2998a50d 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -1719,7 +1719,6 @@ jint G1CollectedHeap::initialize() { G1BlockOffsetTable::compute_size(g1_rs.size() / HeapWordSize), G1BlockOffsetTable::heap_map_factor()); - ReservedSpace cardtable_rs(G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize)); G1RegionToSpaceMapper* cardtable_storage = create_aux_memory_mapper("Card Table", G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize), From de3cc93ca65f076ef1c99ece5b19b7f72cb323a9 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 30 Aug 2017 19:18:22 -0400 Subject: [PATCH 66/98] 8164207: Checking missing load-acquire in relation to _pd_set in dictionary.cpp Use load_acquire for accessing DictionaryEntry::_pd_set since it's accessed outside the SystemDictionary_lock Reviewed-by: zgu, twisti, dholmes, adinn --- hotspot/src/share/vm/classfile/dictionary.cpp | 9 +++++---- hotspot/src/share/vm/classfile/dictionary.hpp | 18 +++++++++++++----- .../share/vm/classfile/systemDictionary.cpp | 9 +++------ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/hotspot/src/share/vm/classfile/dictionary.cpp b/hotspot/src/share/vm/classfile/dictionary.cpp index 3a57eeb8c4e..e5eef1c4ba3 100644 --- a/hotspot/src/share/vm/classfile/dictionary.cpp +++ b/hotspot/src/share/vm/classfile/dictionary.cpp @@ -85,6 +85,7 @@ DictionaryEntry* Dictionary::new_entry(unsigned int hash, InstanceKlass* klass) void Dictionary::free_entry(DictionaryEntry* entry) { // avoid recursion when deleting linked list + // pd_set is accessed during a safepoint. while (entry->pd_set() != NULL) { ProtectionDomainEntry* to_delete = entry->pd_set(); entry->set_pd_set(to_delete->next()); @@ -101,7 +102,7 @@ bool DictionaryEntry::contains_protection_domain(oop protection_domain) const { if (protection_domain == instance_klass()->protection_domain()) { // Ensure this doesn't show up in the pd_set (invariant) bool in_pd_set = false; - for (ProtectionDomainEntry* current = _pd_set; + for (ProtectionDomainEntry* current = pd_set_acquire(); current != NULL; current = current->next()) { if (current->protection_domain() == protection_domain) { @@ -121,7 +122,7 @@ bool DictionaryEntry::contains_protection_domain(oop protection_domain) const { return true; } - for (ProtectionDomainEntry* current = _pd_set; + for (ProtectionDomainEntry* current = pd_set_acquire(); current != NULL; current = current->next()) { if (current->protection_domain() == protection_domain) return true; @@ -135,12 +136,12 @@ void DictionaryEntry::add_protection_domain(Dictionary* dict, Handle protection_ if (!contains_protection_domain(protection_domain())) { ProtectionDomainCacheEntry* entry = SystemDictionary::cache_get(protection_domain); ProtectionDomainEntry* new_head = - new ProtectionDomainEntry(entry, _pd_set); + new ProtectionDomainEntry(entry, pd_set()); // Warning: Preserve store ordering. The SystemDictionary is read // without locks. The new ProtectionDomainEntry must be // complete before other threads can be allowed to see it // via a store to _pd_set. - OrderAccess::release_store_ptr(&_pd_set, new_head); + release_set_pd_set(new_head); } LogTarget(Trace, protectiondomain) lt; if (lt.is_enabled()) { diff --git a/hotspot/src/share/vm/classfile/dictionary.hpp b/hotspot/src/share/vm/classfile/dictionary.hpp index 97c2a8e3a5f..d68e64f1c02 100644 --- a/hotspot/src/share/vm/classfile/dictionary.hpp +++ b/hotspot/src/share/vm/classfile/dictionary.hpp @@ -29,6 +29,7 @@ #include "classfile/systemDictionary.hpp" #include "oops/instanceKlass.hpp" #include "oops/oop.hpp" +#include "runtime/orderAccess.hpp" #include "utilities/hashtable.hpp" #include "utilities/ostream.hpp" @@ -134,7 +135,7 @@ class DictionaryEntry : public HashtableEntry { // It is essentially a cache to avoid repeated Java up-calls to // ClassLoader.checkPackageAccess(). // - ProtectionDomainEntry* _pd_set; + ProtectionDomainEntry* volatile _pd_set; public: // Tells whether a protection is in the approved set. @@ -153,8 +154,15 @@ class DictionaryEntry : public HashtableEntry { return (DictionaryEntry**)HashtableEntry::next_addr(); } - ProtectionDomainEntry* pd_set() const { return _pd_set; } - void set_pd_set(ProtectionDomainEntry* pd_set) { _pd_set = pd_set; } + ProtectionDomainEntry* pd_set() const { return _pd_set; } + void set_pd_set(ProtectionDomainEntry* new_head) { _pd_set = new_head; } + + ProtectionDomainEntry* pd_set_acquire() const { + return (ProtectionDomainEntry*)OrderAccess::load_ptr_acquire(&_pd_set); + } + void release_set_pd_set(ProtectionDomainEntry* new_head) { + OrderAccess::release_store_ptr(&_pd_set, new_head); + } // Tells whether the initiating class' protection domain can access the klass in this entry bool is_valid_protection_domain(Handle protection_domain) { @@ -167,7 +175,7 @@ class DictionaryEntry : public HashtableEntry { } void verify_protection_domain_set() { - for (ProtectionDomainEntry* current = _pd_set; + for (ProtectionDomainEntry* current = pd_set(); // accessed at a safepoint current != NULL; current = current->_next) { current->_pd_cache->protection_domain()->verify(); @@ -181,7 +189,7 @@ class DictionaryEntry : public HashtableEntry { void print_count(outputStream *st) { int count = 0; - for (ProtectionDomainEntry* current = _pd_set; + for (ProtectionDomainEntry* current = pd_set(); // accessed inside SD lock current != NULL; current = current->_next) { count++; diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index 6a5ce5ffa8f..fd207a09303 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -910,12 +910,9 @@ Klass* SystemDictionary::resolve_instance_class_or_null(Symbol* name, if (protection_domain() == NULL) return k; // Check the protection domain has the right access - { - MutexLocker mu(SystemDictionary_lock, THREAD); - if (dictionary->is_valid_protection_domain(d_index, d_hash, name, - protection_domain)) { - return k; - } + if (dictionary->is_valid_protection_domain(d_index, d_hash, name, + protection_domain)) { + return k; } // Verify protection domain. If it fails an exception is thrown From 5ded85f06517c818cc879a79daa5757881a68997 Mon Sep 17 00:00:00 2001 From: Daniel Stewart Date: Thu, 31 Aug 2017 10:28:25 +0800 Subject: [PATCH 67/98] 8187022: AArch64: UBFX instructions have wrong format string Reviewed-by: aph --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 6 +++--- hotspot/src/cpu/aarch64/vm/aarch64_ad.m4 | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index b05b2cdfca1..0b1e086f3a9 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -12614,7 +12614,7 @@ instruct ubfxwI(iRegINoSp dst, iRegIorL2I src, immI rshift, immI_bitmask mask) match(Set dst (AndI (URShiftI src rshift) mask)); ins_cost(INSN_COST); - format %{ "ubfxw $dst, $src, $mask" %} + format %{ "ubfxw $dst, $src, $rshift, $mask" %} ins_encode %{ int rshift = $rshift$$constant; long mask = $mask$$constant; @@ -12629,7 +12629,7 @@ instruct ubfxL(iRegLNoSp dst, iRegL src, immI rshift, immL_bitmask mask) match(Set dst (AndL (URShiftL src rshift) mask)); ins_cost(INSN_COST); - format %{ "ubfx $dst, $src, $mask" %} + format %{ "ubfx $dst, $src, $rshift, $mask" %} ins_encode %{ int rshift = $rshift$$constant; long mask = $mask$$constant; @@ -12647,7 +12647,7 @@ instruct ubfxIConvI2L(iRegLNoSp dst, iRegIorL2I src, immI rshift, immI_bitmask m match(Set dst (ConvI2L (AndI (URShiftI src rshift) mask))); ins_cost(INSN_COST * 2); - format %{ "ubfx $dst, $src, $mask" %} + format %{ "ubfx $dst, $src, $rshift, $mask" %} ins_encode %{ int rshift = $rshift$$constant; long mask = $mask$$constant; diff --git a/hotspot/src/cpu/aarch64/vm/aarch64_ad.m4 b/hotspot/src/cpu/aarch64/vm/aarch64_ad.m4 index 019f646ef5b..0dd69df6579 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64_ad.m4 +++ b/hotspot/src/cpu/aarch64/vm/aarch64_ad.m4 @@ -183,7 +183,7 @@ define(`BFX_INSN', match(Set dst (And$1 ($2$1 src rshift) mask)); ins_cost(INSN_COST); - format %{ "$3 $dst, $src, $mask" %} + format %{ "$3 $dst, $src, $rshift, $mask" %} ins_encode %{ int rshift = $rshift$$constant; long mask = $mask$$constant; @@ -203,7 +203,7 @@ instruct ubfxIConvI2L(iRegLNoSp dst, iRegIorL2I src, immI rshift, immI_bitmask m match(Set dst (ConvI2L (AndI (URShiftI src rshift) mask))); ins_cost(INSN_COST * 2); - format %{ "ubfx $dst, $src, $mask" %} + format %{ "ubfx $dst, $src, $rshift, $mask" %} ins_encode %{ int rshift = $rshift$$constant; long mask = $mask$$constant; From 416b9f9906791301ef3c0a3c221809892e1ded1f Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Thu, 31 Aug 2017 09:28:21 +0530 Subject: [PATCH 68/98] 8181786: Extra runLater causes impossible states to be possible using javafx.embed.singleThread=true Reviewed-by: kcr --- .../classes/java/awt/EventDispatchThread.java | 32 +++++++++++-------- .../share/classes/java/awt/EventQueue.java | 32 +++++++++++++++++-- 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/java/awt/EventDispatchThread.java b/jdk/src/java.desktop/share/classes/java/awt/EventDispatchThread.java index d4bead31360..89de9972094 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/EventDispatchThread.java +++ b/jdk/src/java.desktop/share/classes/java/awt/EventDispatchThread.java @@ -161,6 +161,23 @@ class EventDispatchThread extends Thread { } } + boolean filterAndCheckEvent(AWTEvent event) { + boolean eventOK = true; + synchronized (eventFilters) { + for (int i = eventFilters.size() - 1; i >= 0; i--) { + EventFilter f = eventFilters.get(i); + EventFilter.FilterAction accept = f.acceptEvent(event); + if (accept == EventFilter.FilterAction.REJECT) { + eventOK = false; + break; + } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) { + break; + } + } + } + return eventOK && SunDragSourceContextPeer.checkEvent(event); + } + void pumpOneEventForFilters(int id) { AWTEvent event = null; boolean eventOK = false; @@ -172,20 +189,7 @@ class EventDispatchThread extends Thread { event = (id == ANY_EVENT) ? eq.getNextEvent() : eq.getNextEvent(id); - eventOK = true; - synchronized (eventFilters) { - for (int i = eventFilters.size() - 1; i >= 0; i--) { - EventFilter f = eventFilters.get(i); - EventFilter.FilterAction accept = f.acceptEvent(event); - if (accept == EventFilter.FilterAction.REJECT) { - eventOK = false; - break; - } else if (accept == EventFilter.FilterAction.ACCEPT_IMMEDIATELY) { - break; - } - } - } - eventOK = eventOK && SunDragSourceContextPeer.checkEvent(event); + eventOK = filterAndCheckEvent(event); if (!eventOK) { event.consume(); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/EventQueue.java b/jdk/src/java.desktop/share/classes/java/awt/EventQueue.java index 92bbe9930f1..278b2abaea2 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/EventQueue.java +++ b/jdk/src/java.desktop/share/classes/java/awt/EventQueue.java @@ -719,7 +719,9 @@ public class EventQueue { fwDispatcher.scheduleDispatch(new Runnable() { @Override public void run() { - dispatchEventImpl(event, src); + if (dispatchThread.filterAndCheckEvent(event)) { + dispatchEventImpl(event, src); + } } }); } @@ -1008,6 +1010,32 @@ public class EventQueue { return createSecondaryLoop(null, null, 0); } + private class FwSecondaryLoopWrapper implements SecondaryLoop { + final private SecondaryLoop loop; + final private EventFilter filter; + + public FwSecondaryLoopWrapper(SecondaryLoop loop, EventFilter filter) { + this.loop = loop; + this.filter = filter; + } + + @Override + public boolean enter() { + if (filter != null) { + dispatchThread.addEventFilter(filter); + } + return loop.enter(); + } + + @Override + public boolean exit() { + if (filter != null) { + dispatchThread.removeEventFilter(filter); + } + return loop.exit(); + } + } + SecondaryLoop createSecondaryLoop(Conditional cond, EventFilter filter, long interval) { pushPopLock.lock(); try { @@ -1016,7 +1044,7 @@ public class EventQueue { return nextQueue.createSecondaryLoop(cond, filter, interval); } if (fwDispatcher != null) { - return fwDispatcher.createSecondaryLoop(); + return new FwSecondaryLoopWrapper(fwDispatcher.createSecondaryLoop(), filter); } if (dispatchThread == null) { initDispatchThread(); From d38975f83c4f559ea53ff463159cc4944ade5258 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Thu, 31 Aug 2017 08:18:47 +0200 Subject: [PATCH 69/98] 8186837: Memory ordering nmethod, _state and _stack_traversal_mark Reviewed-by: dholmes, rkennke --- hotspot/src/share/vm/code/nmethod.cpp | 2 +- hotspot/src/share/vm/code/nmethod.hpp | 8 ++++---- hotspot/src/share/vm/runtime/sweeper.cpp | 5 +++-- hotspot/src/share/vm/runtime/vmStructs.cpp | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index a8c72f86be1..1772feedde1 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -1220,7 +1220,7 @@ bool nmethod::make_not_entrant_or_zombie(unsigned int state) { // for stack scanning. if (state == not_entrant) { mark_as_seen_on_stack(); - OrderAccess::storestore(); + OrderAccess::storestore(); // _stack_traversal_mark and _state } // Change state diff --git a/hotspot/src/share/vm/code/nmethod.hpp b/hotspot/src/share/vm/code/nmethod.hpp index 84afbbf7f2d..600c34fcb23 100644 --- a/hotspot/src/share/vm/code/nmethod.hpp +++ b/hotspot/src/share/vm/code/nmethod.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -136,7 +136,7 @@ class nmethod : public CompiledMethod { // stack. An not_entrant method can be removed when there are no // more activations, i.e., when the _stack_traversal_mark is less than // current sweep traversal index. - volatile jlong _stack_traversal_mark; + volatile long _stack_traversal_mark; // The _hotness_counter indicates the hotness of a method. The higher // the value the hotter the method. The hotness counter of a nmethod is @@ -396,8 +396,8 @@ public: public: // Sweeper support - jlong stack_traversal_mark() { return OrderAccess::load_acquire(&_stack_traversal_mark); } - void set_stack_traversal_mark(jlong l) { OrderAccess::release_store(&_stack_traversal_mark, l); } + long stack_traversal_mark() { return _stack_traversal_mark; } + void set_stack_traversal_mark(long l) { _stack_traversal_mark = l; } // implicit exceptions support address continuation_for_implicit_exception(address pc); diff --git a/hotspot/src/share/vm/runtime/sweeper.cpp b/hotspot/src/share/vm/runtime/sweeper.cpp index cd166a93a39..49e49cdb79c 100644 --- a/hotspot/src/share/vm/runtime/sweeper.cpp +++ b/hotspot/src/share/vm/runtime/sweeper.cpp @@ -53,7 +53,7 @@ class SweeperRecord { public: int traversal; int compile_id; - jlong traversal_mark; + long traversal_mark; int state; const char* kind; address vep; @@ -62,7 +62,7 @@ class SweeperRecord { void print() { tty->print_cr("traversal = %d compile_id = %d %s uep = " PTR_FORMAT " vep = " - PTR_FORMAT " state = %d traversal_mark "JLONG_FORMAT" line = %d", + PTR_FORMAT " state = %d traversal_mark %ld line = %d", traversal, compile_id, kind == NULL ? "" : kind, @@ -629,6 +629,7 @@ NMethodSweeper::MethodStateChange NMethodSweeper::process_compiled_method(Compil } else if (cm->is_not_entrant()) { // If there are no current activations of this method on the // stack we can safely convert it to a zombie method + OrderAccess::loadload(); // _stack_traversal_mark and _state if (cm->can_convert_to_zombie()) { // Clear ICStubs to prevent back patching stubs of zombie or flushed // nmethods during the next safepoint (see ICStub::finalize). diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index eb6e97e247c..d9dd0d15b50 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -841,7 +841,7 @@ typedef RehashableHashtable RehashableSymbolHashtable; nonstatic_field(nmethod, _verified_entry_point, address) \ nonstatic_field(nmethod, _osr_entry_point, address) \ volatile_nonstatic_field(nmethod, _lock_count, jint) \ - volatile_nonstatic_field(nmethod, _stack_traversal_mark, jlong) \ + volatile_nonstatic_field(nmethod, _stack_traversal_mark, long) \ nonstatic_field(nmethod, _compile_id, int) \ nonstatic_field(nmethod, _comp_level, int) \ \ From b75420c692ded40c769c40c4a9efa3256595a392 Mon Sep 17 00:00:00 2001 From: Arno Zeller Date: Thu, 31 Aug 2017 18:34:40 +0200 Subject: [PATCH 70/98] 8186982: [aix] Garbage output for CPU info in hs-err file Reviewed-by: goetz, simonis --- hotspot/src/os/aix/vm/os_aix.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp index ba8efd04d3d..9801e373308 100644 --- a/hotspot/src/os/aix/vm/os_aix.cpp +++ b/hotspot/src/os/aix/vm/os_aix.cpp @@ -1437,12 +1437,7 @@ void os::get_summary_cpu_info(char* buf, size_t buflen) { } void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) { - st->print("CPU:"); - st->print("total %d", os::processor_count()); - // It's not safe to query number of active processors after crash. - // st->print("(active %d)", os::active_processor_count()); - st->print(" %s", VM_Version::features()); - st->cr(); + // Nothing to do beyond what os::print_cpu_info() does. } static void print_signal_handler(outputStream* st, int sig, From d744fce2491123db4699b331ac38eb9cdfe60f86 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Thu, 31 Aug 2017 13:09:31 -0700 Subject: [PATCH 71/98] 8183351: Better cleanup for jdk/test/javax/imageio/spi/AppletContextTest/BadPluginConfigurationTest.sh Reviewed-by: serb --- .../BadPluginConfigurationTest.sh | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/jdk/test/javax/imageio/spi/AppletContextTest/BadPluginConfigurationTest.sh b/jdk/test/javax/imageio/spi/AppletContextTest/BadPluginConfigurationTest.sh index b2194c99d35..f70099a1b3d 100644 --- a/jdk/test/javax/imageio/spi/AppletContextTest/BadPluginConfigurationTest.sh +++ b/jdk/test/javax/imageio/spi/AppletContextTest/BadPluginConfigurationTest.sh @@ -22,7 +22,7 @@ # # @test # -# @bug 6342404 7078379 8167503 +# @bug 6342404 7078379 8167503 8183351 # # @summary Test verifies that incorrectly configured ImageIO plugin spi # does not affect registration of other ImageIO plugin in the @@ -57,6 +57,7 @@ fail() { echo "The test failed :-(" echo "$*" 1>&2 echo "exit status was $status" + clean exit $status } #end of fail() @@ -65,9 +66,19 @@ fail() pass() { echo "The test passed!!!" echo "$*" 1>&2 + clean exit 0 } #end of pass() +#Clean up the test_ext directory (PLUGINDST_DIR) before leaving +clean() + { + echo "Removing PLUGINDST_DIR ${PLUGINDST_DIR}" + if [ -n "${PLUGINDST_DIR}" -a -d "${PLUGINDST_DIR}" ] ; then + rm -rf "${PLUGINDST_DIR}" + fi + } + # end of subroutines @@ -169,13 +180,10 @@ echo ------ PREPARE TEST PLUGIN --------- # app have file read permission for all subdirs of the # scratch dir -PLUGINDST_DIR=${TMP}/test_ext -#PLUGINDST_DIR=${TESTJAVA}/lib/ext -TEST_PLUGIN=dummy.jar +PLUGINDST_DIR=$(mktemp -d ${TMP}/iio_test.XXXXXXXX) +echo "Created PLUGINDST_DIR as ${PLUGINDST_DIR}" -if [ ! -d ${PLUGINDST_DIR} ] ; then - mkdir ${PLUGINDST_DIR} -fi +TEST_PLUGIN=dummy.jar # remove old service declaration if [ -d META-INF ] ; then From d80ba8ce05a9b0e511f562c1aa0f1655a6286f5f Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Thu, 31 Aug 2017 13:00:23 -0700 Subject: [PATCH 72/98] 8181566: JavaSound javadoc clarification Reviewed-by: amenkov --- .../sound/midi/InvalidMidiDataException.java | 5 +- .../classes/javax/sound/midi/MetaMessage.java | 6 +- .../classes/javax/sound/midi/MidiDevice.java | 39 +++-- .../javax/sound/midi/MidiDeviceReceiver.java | 8 +- .../sound/midi/MidiDeviceTransmitter.java | 8 +- .../javax/sound/midi/MidiFileFormat.java | 77 +++++---- .../classes/javax/sound/midi/MidiMessage.java | 24 +-- .../classes/javax/sound/midi/MidiSystem.java | 143 +++++++++++++---- .../sound/midi/MidiUnavailableException.java | 5 +- .../classes/javax/sound/midi/Receiver.java | 4 +- .../classes/javax/sound/midi/Sequencer.java | 39 ++--- .../javax/sound/midi/ShortMessage.java | 7 +- .../javax/sound/midi/SoundbankResource.java | 38 ++--- .../classes/javax/sound/midi/Synthesizer.java | 6 +- .../javax/sound/midi/SysexMessage.java | 16 +- .../share/classes/javax/sound/midi/Track.java | 10 +- .../classes/javax/sound/midi/Transmitter.java | 4 +- .../classes/javax/sound/midi/VoiceStatus.java | 4 +- .../javax/sound/midi/package-info.java | 4 +- .../javax/sound/midi/spi/MidiFileReader.java | 35 ++-- .../javax/sound/midi/spi/MidiFileWriter.java | 5 +- .../javax/sound/midi/spi/SoundbankReader.java | 12 +- .../javax/sound/midi/spi/package-info.java | 4 +- .../javax/sound/sampled/AudioFileFormat.java | 79 +++++---- .../javax/sound/sampled/AudioFormat.java | 96 +++++------ .../javax/sound/sampled/AudioInputStream.java | 20 +-- .../javax/sound/sampled/AudioPermission.java | 51 +++--- .../javax/sound/sampled/AudioSystem.java | 151 ++++++++++-------- .../javax/sound/sampled/BooleanControl.java | 6 +- .../classes/javax/sound/sampled/Clip.java | 10 +- .../javax/sound/sampled/CompoundControl.java | 5 +- .../classes/javax/sound/sampled/Control.java | 20 ++- .../classes/javax/sound/sampled/DataLine.java | 36 +++-- .../classes/javax/sound/sampled/Line.java | 23 +-- .../javax/sound/sampled/LineEvent.java | 44 +++-- .../sampled/LineUnavailableException.java | 5 +- .../classes/javax/sound/sampled/Mixer.java | 40 +++-- .../classes/javax/sound/sampled/Port.java | 30 +++- .../javax/sound/sampled/ReverbType.java | 112 ++++++------- .../javax/sound/sampled/SourceDataLine.java | 2 +- .../UnsupportedAudioFileException.java | 9 +- .../javax/sound/sampled/package-info.java | 4 +- .../sound/sampled/spi/AudioFileReader.java | 38 ++--- .../sound/sampled/spi/AudioFileWriter.java | 10 +- .../javax/sound/sampled/spi/package-info.java | 4 +- 45 files changed, 725 insertions(+), 573 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/InvalidMidiDataException.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/InvalidMidiDataException.java index 28a75deefc4..40ca4474732 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/InvalidMidiDataException.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/InvalidMidiDataException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -39,6 +39,9 @@ package javax.sound.midi; */ public class InvalidMidiDataException extends Exception { + /** + * Use serialVersionUID from JDK 1.3 for interoperability. + */ private static final long serialVersionUID = 2780771756789932067L; /** diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaMessage.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaMessage.java index 0fe40e84342..83bf57bf3e1 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaMessage.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -54,8 +54,8 @@ public class MetaMessage extends MidiMessage { /** * Status byte for {@code MetaMessage} (0xFF, or 255), which is used in MIDI - * files. It has the same value as SYSTEM_RESET, which is used in the - * real-time "MIDI wire" protocol. + * files. It has the same value as {@link ShortMessage#SYSTEM_RESET}, which + * is used in the real-time "MIDI wire" protocol. * * @see MidiMessage#getStatus */ diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDevice.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDevice.java index ee889015a88..0c3246aabc5 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDevice.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDevice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -64,11 +64,11 @@ import java.util.List; * {@code MidiDevice} instance, the following rules apply: * *
    - *
  • After an explicit open (either before or after implicit opens), the - * device will not be closed by implicit closing. The only way to close an - * explicitly opened device is an explicit close.
  • - *
  • An explicit close always closes the device, even if it also has been - * opened implicitly. A subsequent implicit close has no further effect.
  • + *
  • After an explicit open (either before or after implicit opens), the + * device will not be closed by implicit closing. The only way to close an + * explicitly opened device is an explicit close. + *
  • An explicit close always closes the device, even if it also has been + * opened implicitly. A subsequent implicit close has no further effect. *
* * To detect if a MidiDevice represents a hardware MIDI port, the following @@ -76,7 +76,7 @@ import java.util.List; * *
{@code
  * MidiDevice device = ...;
- * if ( ! (device instanceof Sequencer) && ! (device instanceof Synthesizer)) {
+ * if (!(device instanceof Sequencer) && !(device instanceof Synthesizer)) {
  *   // we're now sure that device represents a MIDI port
  *   // ...
  * }
@@ -112,7 +112,8 @@ public interface MidiDevice extends AutoCloseable {
      * resources and allow applications to exit cleanly.
      * 

* Note that some devices, once closed, cannot be reopened. Attempts to - * reopen such a device will always result in a MidiUnavailableException. + * reopen such a device will always result in a + * {@code MidiUnavailableException}. * * @throws MidiUnavailableException thrown if the device cannot be opened * due to resource restrictions @@ -198,7 +199,8 @@ public interface MidiDevice extends AutoCloseable { /** * Returns all currently active, non-closed receivers connected with this - * MidiDevice. A receiver can be removed from the device by closing it. + * {@code MidiDevice}. A receiver can be removed from the device by closing + * it. *

* Usually the returned receivers implement the {@code MidiDeviceReceiver} * interface. @@ -231,7 +233,8 @@ public interface MidiDevice extends AutoCloseable { /** * Returns all currently active, non-closed transmitters connected with this - * MidiDevice. A transmitter can be removed from the device by closing it. + * {@code MidiDevice}. A transmitter can be removed from the device by + * closing it. *

* Usually the returned transmitters implement the * {@code MidiDeviceTransmitter} interface. @@ -288,12 +291,12 @@ public interface MidiDevice extends AutoCloseable { } /** - * Reports whether two objects are equal. Returns {@code true} if the - * objects are identical. + * Indicates whether the specified object is equal to this info object, + * returning {@code true} if the objects are the same. * - * @param obj the reference object with which to compare this object - * @return {@code true} if this object is the same as the {@code obj} - * argument; {@code false} otherwise + * @param obj the reference object with which to compare + * @return {@code true} if the specified object is equal to this info + * object; {@code false} otherwise */ @Override public final boolean equals(Object obj) { @@ -301,7 +304,9 @@ public interface MidiDevice extends AutoCloseable { } /** - * Finalizes the hashcode method. + * Returns a hash code value for this info object. + * + * @return a hash code value for this info object */ @Override public final int hashCode() { @@ -353,5 +358,5 @@ public interface MidiDevice extends AutoCloseable { public final String toString() { return name; } - } // class Info + } } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceReceiver.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceReceiver.java index 569850836e1..b542712ae36 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceReceiver.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceReceiver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -35,9 +35,11 @@ package javax.sound.midi; public interface MidiDeviceReceiver extends Receiver { /** - * Obtains a MidiDevice object which is an owner of this Receiver. + * Obtains a {@code MidiDevice} object which is an owner of this + * {@code Receiver}. * - * @return a MidiDevice object which is an owner of this Receiver + * @return a {@code MidiDevice} object which is an owner of this + * {@code Receiver} */ MidiDevice getMidiDevice(); } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceTransmitter.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceTransmitter.java index aaf7aba72d3..fe989bee2c9 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceTransmitter.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiDeviceTransmitter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -35,9 +35,11 @@ package javax.sound.midi; public interface MidiDeviceTransmitter extends Transmitter { /** - * Obtains a MidiDevice object which is an owner of this Transmitter. + * Obtains a {@code MidiDevice} object which is an owner of this + * {@code Transmitter}. * - * @return a MidiDevice object which is an owner of this Transmitter + * @return a {@code MidiDevice} object which is an owner of this + * {@code Transmitter} */ MidiDevice getMidiDevice(); } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiFileFormat.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiFileFormat.java index 0fa5db72ec8..f64f2260da6 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiFileFormat.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiFileFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -44,37 +44,31 @@ import java.util.Map; * implementations: * * - - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + *
MIDI File Format Properties
Property keyValue typeDescription
"author"{@link java.lang.String String}name of the author of this file
"title"{@link java.lang.String String}title of this file
"copyright"{@link java.lang.String String}copyright message
"date"{@link java.util.Date Date}date of the recording or release
"comment"{@link java.lang.String String}an arbitrary text
MIDI File Format Properties
Property key + * Value type + * Description + *
"author" + * {@link String String} + * name of the author of this file + *
"title" + * {@link String String} + * title of this file + *
"copyright" + * {@link String String} + * copyright message + *
"date" + * {@link java.util.Date Date} + * date of the recording or release + *
"comment" + * {@link String String} + * an arbitrary text *
* * @author Kara Kytle @@ -135,10 +129,10 @@ public class MidiFileFormat { * @param divisionType the timing division type (PPQ or one of the SMPTE * types) * @param resolution the timing resolution - * @param bytes the length of the MIDI file in bytes, or UNKNOWN_LENGTH if - * not known + * @param bytes the length of the MIDI file in bytes, or + * {@link #UNKNOWN_LENGTH} if not known * @param microseconds the duration of the file in microseconds, or - * UNKNOWN_LENGTH if not known + * {@link #UNKNOWN_LENGTH} if not known * @see #UNKNOWN_LENGTH * @see Sequence#PPQ * @see Sequence#SMPTE_24 @@ -163,10 +157,10 @@ public class MidiFileFormat { * @param divisionType the timing division type (PPQ or one of the SMPTE * types) * @param resolution the timing resolution - * @param bytes the length of the MIDI file in bytes, or UNKNOWN_LENGTH if - * not known + * @param bytes the length of the MIDI file in bytes, or + * {@code UNKNOWN_LENGTH} if not known * @param microseconds the duration of the file in microseconds, or - * UNKNOWN_LENGTH if not known + * {@code UNKNOWN_LENGTH} if not known * @param properties a {@code Map} object with properties * @see #UNKNOWN_LENGTH * @see Sequence#PPQ @@ -224,7 +218,8 @@ public class MidiFileFormat { /** * Obtains the length of the MIDI file, expressed in 8-bit bytes. * - * @return the number of bytes in the file, or UNKNOWN_LENGTH if not known + * @return the number of bytes in the file, or {@code UNKNOWN_LENGTH} if not + * known * @see #UNKNOWN_LENGTH */ public int getByteLength() { @@ -234,8 +229,8 @@ public class MidiFileFormat { /** * Obtains the length of the MIDI file, expressed in microseconds. * - * @return the file's duration in microseconds, or UNKNOWN_LENGTH if not - * known + * @return the file's duration in microseconds, or {@code UNKNOWN_LENGTH} if + * not known * @see Sequence#getMicrosecondLength() * @see #getByteLength * @see #UNKNOWN_LENGTH diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiMessage.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiMessage.java index 6ca01acb05b..cfe6deccebc 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiMessage.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiMessage.java @@ -38,29 +38,29 @@ package javax.sound.midi; * The base {@code MidiMessage} class provides access to three types of * information about a MIDI message: *

    - *
  • The messages's status byte
  • - *
  • The total length of the message in bytes (the status byte plus any data - * bytes)
  • - *
  • A byte array containing the complete message
  • + *
  • The messages's status byte + *
  • The total length of the message in bytes (the status byte plus any data + * bytes) + *
  • A byte array containing the complete message *
* * {@code MidiMessage} includes methods to get, but not set, these values. * Setting them is a subclass responsibility. *

- * The MIDI standard expresses MIDI data in - * bytes. However, because JavaTM uses signed bytes, the Java Sound - * API uses integers instead of bytes when expressing MIDI data. For example, - * the {@link #getStatus()} method of {@code MidiMessage} returns MIDI status - * bytes as integers. If you are processing MIDI data that originated outside - * Java Sound and now is encoded as signed bytes, the bytes can be - * converted to integers using this conversion: + * The MIDI standard expresses MIDI data in bytes. + * However, because Java™ uses signed bytes, the Java Sound API uses + * integers instead of bytes when expressing MIDI data. For example, the + * {@link #getStatus()} method of {@code MidiMessage} returns MIDI status bytes + * as integers. If you are processing MIDI data that originated outside Java + * Sound and now is encoded as signed bytes, the bytes can be converted to + * integers using this conversion: *

* {@code int i = (int)(byte & 0xFF)} *

* If you simply need to pass a known MIDI byte value as a method parameter, it * can be expressed directly as an integer, using (for example) decimal or * hexadecimal notation. For instance, to pass the "active sensing" status byte - * as the first argument to ShortMessage's + * as the first argument to {@code ShortMessage}'s * {@link ShortMessage#setMessage(int) setMessage(int)} method, you can express * it as 254 or 0xFE. * diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiSystem.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiSystem.java index 0515b71aa2f..686840ff8a4 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiSystem.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiSystem.java @@ -57,7 +57,7 @@ import com.sun.media.sound.ReferenceCountingDevice; * one or more {@code MidiSystem} methods to learn what devices are installed * and to obtain the ones needed in that application. *

- * The class also has methods for reading files, streams, and URLs that contain + * The class also has methods for reading files, streams, and URLs that contain * standard MIDI file data or soundbanks. You can query the {@code MidiSystem} * for the format of a specified MIDI file. *

@@ -77,33 +77,28 @@ import com.sun.media.sound.ReferenceCountingDevice; * * * - * - * - * - * - * + * + * * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * + * + * + * + * *
MIDI System Property Keys
Property KeyInterfaceAffected Method
Property Key + * Interface + * Affected Method *
{@code javax.sound.midi.Receiver}{@link Receiver}{@link #getReceiver}
{@code javax.sound.midi.Sequencer}{@link Sequencer}{@link #getSequencer}
{@code javax.sound.midi.Synthesizer}{@link Synthesizer}{@link #getSynthesizer}
{@code javax.sound.midi.Transmitter}{@link Transmitter}{@link #getTransmitter}
{@code javax.sound.midi.Receiver} + * {@link Receiver} + * {@link #getReceiver} + *
{@code javax.sound.midi.Sequencer} + * {@link Sequencer} + * {@link #getSequencer} + *
{@code javax.sound.midi.Synthesizer} + * {@link Synthesizer} + * {@link #getSynthesizer} + *
{@code javax.sound.midi.Transmitter} + * {@link Transmitter} + * {@link #getTransmitter} *
* @@ -567,8 +562,7 @@ public class MidiSystem { * @return an {@code MidiFileFormat} object describing the MIDI file format * @throws InvalidMidiDataException if the stream does not point to valid * MIDI file data recognized by the system - * @throws IOException if an I/O exception occurs while accessing the - * stream + * @throws IOException if an I/O exception occurs while accessing the stream * @throws NullPointerException if {@code stream} is {@code null} * @see #getMidiFileFormat(URL) * @see #getMidiFileFormat(File) @@ -1027,21 +1021,42 @@ public class MidiSystem { } // HELPER METHODS + + /** + * Obtains the list of MidiDeviceProviders installed on the system. + * + * @return the list of MidiDeviceProviders installed on the system + */ @SuppressWarnings("unchecked") private static List getMidiDeviceProviders() { return (List) getProviders(MidiDeviceProvider.class); } + /** + * Obtains the list of SoundbankReaders installed on the system. + * + * @return the list of SoundbankReaders installed on the system + */ @SuppressWarnings("unchecked") private static List getSoundbankReaders() { return (List) getProviders(SoundbankReader.class); } + /** + * Obtains the list of MidiFileWriters installed on the system. + * + * @return the list of MidiFileWriters installed on the system + */ @SuppressWarnings("unchecked") private static List getMidiFileWriters() { return (List) getProviders(MidiFileWriter.class); } + /** + * Obtains the list of MidiFileReaders installed on the system. + * + * @return the list of MidiFileReaders installed on the system + */ @SuppressWarnings("unchecked") private static List getMidiFileReaders() { return (List) getProviders(MidiFileReader.class); @@ -1056,6 +1071,7 @@ public class MidiSystem { * * @param deviceClass The requested device type, one of Synthesizer.class, * Sequencer.class, Receiver.class or Transmitter.class + * @return default MidiDevice of the specified type * @throws MidiUnavailableException on failure */ private static MidiDevice getDefaultDeviceWrapper(Class deviceClass) @@ -1074,6 +1090,7 @@ public class MidiSystem { * * @param deviceClass The requested device type, one of Synthesizer.class, * Sequencer.class, Receiver.class or Transmitter.class + * @return default MidiDevice of the specified type. * @throws IllegalArgumentException on failure */ private static MidiDevice getDefaultDevice(Class deviceClass) { @@ -1098,9 +1115,12 @@ public class MidiSystem { } } - /* Provider class not specified or cannot be found, or - provider class specified, and no appropriate device available or - provider class and instance specified and instance cannot be found or is not appropriate */ + /* + * - Provider class not specified or cannot be found, or + * - provider class specified, and no appropriate device available, or + * - provider class and instance specified and instance cannot be found + * or is not appropriate + */ if (instanceName != null) { device = getNamedDevice(instanceName, providers, deviceClass); if (device != null) { @@ -1108,8 +1128,10 @@ public class MidiSystem { } } - /* No default are specified, or if something is specified, everything - failed. */ + /* + * No defaults are specified, or if something is specified, everything + * failed + */ device = getFirstDevice(providers, deviceClass); if (device != null) { return device; @@ -1176,6 +1198,17 @@ public class MidiSystem { * @param provider The MidiDeviceProvider to check for MidiDevices * @param deviceClass The requested device type, one of Synthesizer.class, * Sequencer.class, Receiver.class or Transmitter.class + * @param allowSynthesizer if true, Synthesizers are considered + * appropriate. Otherwise only pure MidiDevices are considered + * appropriate (unless allowSequencer is true). This flag only has + * an effect for deviceClass Receiver and Transmitter. For other + * device classes (Sequencer and Synthesizer), this flag has no + * effect. + * @param allowSequencer if true, Sequencers are considered appropriate. + * Otherwise only pure MidiDevices are considered appropriate + * (unless allowSynthesizer is true). This flag only has an effect + * for deviceClass Receiver and Transmitter. For other device + * classes (Sequencer and Synthesizer), this flag has no effect. * @return A MidiDevice matching the requirements, or null if none is found */ private static MidiDevice getNamedDevice(String deviceName, @@ -1237,6 +1270,17 @@ public class MidiSystem { * MidiDevices * @param deviceClass The requested device type, one of Synthesizer.class, * Sequencer.class, Receiver.class or Transmitter.class + * @param allowSynthesizer if true, Synthesizers are considered + * appropriate. Otherwise only pure MidiDevices are considered + * appropriate (unless allowSequencer is true). This flag only has + * an effect for deviceClass Receiver and Transmitter. For other + * device classes (Sequencer and Synthesizer), this flag has no + * effect. + * @param allowSequencer if true, Sequencers are considered appropriate. + * Otherwise only pure MidiDevices are considered appropriate + * (unless allowSynthesizer is true). This flag only has an effect + * for deviceClass Receiver and Transmitter. For other device + * classes (Sequencer and Synthesizer), this flag has no effect. * @return A Mixer matching the requirements, or null if none is found */ private static MidiDevice getNamedDevice(String deviceName, @@ -1294,6 +1338,17 @@ public class MidiSystem { * @param provider The MidiDeviceProvider to check for MidiDevices * @param deviceClass The requested device type, one of Synthesizer.class, * Sequencer.class, Receiver.class or Transmitter.class + * @param allowSynthesizer if true, Synthesizers are considered + * appropriate. Otherwise only pure MidiDevices are considered + * appropriate (unless allowSequencer is true). This flag only has + * an effect for deviceClass Receiver and Transmitter. For other + * device classes (Sequencer and Synthesizer), this flag has no + * effect. + * @param allowSequencer if true, Sequencers are considered appropriate. + * Otherwise only pure MidiDevices are considered appropriate + * (unless allowSynthesizer is true). This flag only has an effect + * for deviceClass Receiver and Transmitter. For other device + * classes (Sequencer and Synthesizer), this flag has no effect. * @return A MidiDevice is considered appropriate, or null if no appropriate * device is found */ @@ -1351,6 +1406,17 @@ public class MidiSystem { * @param providers The List of MidiDeviceProviders to search * @param deviceClass The requested device type, one of Synthesizer.class, * Sequencer.class, Receiver.class or Transmitter.class + * @param allowSynthesizer if true, Synthesizers are considered + * appropriate. Otherwise only pure MidiDevices are considered + * appropriate (unless allowSequencer is true). This flag only has + * an effect for deviceClass Receiver and Transmitter. For other + * device classes (Sequencer and Synthesizer), this flag has no + * effect. + * @param allowSequencer if true, Sequencers are considered appropriate. + * Otherwise only pure MidiDevices are considered appropriate + * (unless allowSynthesizer is true). This flag only has an effect + * for deviceClass Receiver and Transmitter. For other device + * classes (Sequencer and Synthesizer), this flag has no effect. * @return A MidiDevice that is considered appropriate, or null if none is * found */ @@ -1379,6 +1445,8 @@ public class MidiSystem { * respectively. * * @param device the MidiDevice to test + * @param deviceClass The requested device type, one of Synthesizer.class, + * Sequencer.class, Receiver.class or Transmitter.class * @param allowSynthesizer if true, Synthesizers are considered * appropriate. Otherwise only pure MidiDevices are considered * appropriate (unless allowSequencer is true). This flag only has @@ -1429,10 +1497,15 @@ public class MidiSystem { * Obtains the set of services currently installed on the system using the * SPI mechanism in 1.3. * + * @param providerClass The type of providers requested. This should be one + * of AudioFileReader.class, AudioFileWriter.class, + * FormatConversionProvider.class, MixerProvider.class, + * MidiDeviceProvider.class, MidiFileReader.class, + * MidiFileWriter.class or SoundbankReader.class. * @return a List of instances of providers for the requested service. If no * providers are available, a List of length 0 will be returned. */ - private static List getProviders(Class providerClass) { - return JDK13Services.getProviders(providerClass); + private static List getProviders(Class providerClass) { + return JDK13Services.getProviders(providerClass); } } diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiUnavailableException.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiUnavailableException.java index b52fac8d813..80dd7daa312 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiUnavailableException.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiUnavailableException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -39,6 +39,9 @@ package javax.sound.midi; */ public class MidiUnavailableException extends Exception { + /** + * Use serialVersionUID from JDK 1.3 for interoperability. + */ private static final long serialVersionUID = 6093809578628944323L; /** diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Receiver.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Receiver.java index 076f9588efa..9677c4f904c 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Receiver.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Receiver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -64,7 +64,7 @@ public interface Receiver extends AutoCloseable { * closed, too. For a detailed description of open/close behaviour see the * class description of {@link MidiDevice MidiDevice}. * - * @see javax.sound.midi.MidiSystem#getReceiver + * @see MidiSystem#getReceiver */ @Override void close(); diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequencer.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequencer.java index c1e94908602..90e5248a3ad 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequencer.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequencer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -38,22 +38,22 @@ import java.io.InputStream; * The {@code Sequencer} interface includes methods for the following basic MIDI * sequencer operations: *

    - *
  • obtaining a sequence from MIDI file data
  • - *
  • starting and stopping playback
  • - *
  • moving to an arbitrary position in the sequence
  • - *
  • changing the tempo (speed) of playback
  • - *
  • synchronizing playback to an internal clock or to received MIDI - * messages
  • - *
  • controlling the timing of another device
  • + *
  • obtaining a sequence from MIDI file data + *
  • starting and stopping playback + *
  • moving to an arbitrary position in the sequence + *
  • changing the tempo (speed) of playback + *
  • synchronizing playback to an internal clock or to received MIDI + * messages + *
  • controlling the timing of another device *
* In addition, the following operations are supported, either directly, or * indirectly through objects that the {@code Sequencer} has access to: *
    - *
  • editing the data by adding or deleting individual MIDI events or entire - * tracks
  • - *
  • muting or soloing individual tracks in the sequence
  • - *
  • notifying listener objects about any meta-events or control-change events - * encountered while playing back the sequence.
  • + *
  • editing the data by adding or deleting individual MIDI events or entire + * tracks + *
  • muting or soloing individual tracks in the sequence + *
  • notifying listener objects about any meta-events or control-change + * events encountered while playing back the sequence *
* * @author Kara Kytle @@ -694,12 +694,13 @@ public interface Sequencer extends MidiDevice { } /** - * Determines whether two objects are equal. Returns {@code true} if the - * objects are identical. + * Indicates whether the specified object is equal to this + * synchronization mode, returning {@code true} if the objects are the + * same. * * @param obj the reference object with which to compare - * @return {@code true} if this object is the same as the {@code obj} - * argument, {@code false} otherwise + * @return {@code true} if the specified object is equal to this + * synchronization mode; {@code false} otherwise */ @Override public final boolean equals(Object obj) { @@ -708,7 +709,9 @@ public interface Sequencer extends MidiDevice { } /** - * Finalizes the hashcode method. + * Returns a hash code value for this synchronization mode. + * + * @return a hash code value for this synchronization mode */ @Override public final int hashCode() { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/ShortMessage.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/ShortMessage.java index c02deda21bf..45956cf27e9 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/ShortMessage.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/ShortMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -303,9 +303,8 @@ public class ShortMessage extends MidiMessage { * @param status the MIDI status byte * @param data1 the first data byte * @param data2 the second data byte - * @throws InvalidMidiDataException if the status byte, or all data - * bytes belonging to the message, do not specify a valid MIDI - * message + * @throws InvalidMidiDataException if the status byte, or all data bytes + * belonging to the message, do not specify a valid MIDI message * @see #setMessage(int, int, int, int) * @see #setMessage(int) */ diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/SoundbankResource.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/SoundbankResource.java index 8ac530105eb..4aa2fefed2a 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/SoundbankResource.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/SoundbankResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -31,24 +31,24 @@ import javax.sound.sampled.AudioInputStream; * A {@code SoundbankResource} represents any audio resource stored in a * {@link Soundbank}. Common soundbank resources include: *
    - *
  • Instruments. An instrument may be specified in a variety of ways. - * However, all soundbanks have some mechanism for defining instruments. In - * doing so, they may reference other resources stored in the soundbank. Each - * instrument has a {@code Patch} which specifies the MIDI program and bank by - * which it may be referenced in MIDI messages. Instrument information may be - * stored in {@link Instrument} objects.
  • - *
  • Audio samples. A sample typically is a sampled audio waveform which - * contains a short sound recording whose duration is a fraction of a second, or - * at most a few seconds. These audio samples may be used by a - * {@link Synthesizer} to synthesize sound in response to MIDI commands, or - * extracted for use by an application. (The terminology reflects musicians' use - * of the word "sample" to refer collectively to a series of contiguous audio - * samples or frames, rather than to a single, instantaneous sample.) The data - * class for an audio sample will be an object that encapsulates the audio - * sample data itself and information about how to interpret it (the format of - * the audio data), such as an {@link AudioInputStream}.
  • - *
  • Embedded sequences. A sound bank may contain built-in song data stored in - * a data object such as a {@link Sequence}.
  • + *
  • Instruments. An instrument may be specified in a variety of ways. + * However, all soundbanks have some mechanism for defining instruments. In + * doing so, they may reference other resources stored in the soundbank. + * Each instrument has a {@code Patch} which specifies the MIDI program and + * bank by which it may be referenced in MIDI messages. Instrument information + * may be stored in {@link Instrument} objects. + *
  • Audio samples. A sample typically is a sampled audio waveform which + * contains a short sound recording whose duration is a fraction of a + * second, or at most a few seconds. These audio samples may be used by a + * {@link Synthesizer} to synthesize sound in response to MIDI commands, or + * extracted for use by an application. (The terminology reflects musicians' + * use of the word "sample" to refer collectively to a series of contiguous + * audio samples or frames, rather than to a single, instantaneous sample.) + * The data class for an audio sample will be an object that encapsulates + * the audio sample data itself and information about how to interpret it + * (the format of the audio data), such as an {@link AudioInputStream}. + *
  • Embedded sequences. A sound bank may contain built-in song data stored + * in a data object such as a {@link Sequence}. *
* Synthesizers that use wavetable synthesis or related techniques play back the * audio in a sample when synthesizing notes, often when emulating the diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java index bc18df9c13c..c353fb7f390 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -49,8 +49,8 @@ package javax.sound.midi; * be used by every synthesizer, even if the synthesis technique is compatible. * To see whether the instruments from a certain soundbank can be played by a * given synthesizer, invoke the - * {@link #isSoundbankSupported(Soundbank) isSoundbankSupported} - * method of {@code Synthesizer}. + * {@link #isSoundbankSupported(Soundbank) isSoundbankSupported} method of + * {@code Synthesizer}. *

* "Loading" an instrument means that that instrument becomes available for * synthesizing notes. The instrument is loaded into the bank and program diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/SysexMessage.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/SysexMessage.java index b561faad898..7e72a662290 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/SysexMessage.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/SysexMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -40,8 +40,8 @@ package javax.sound.midi; * As dictated by the Standard MIDI Files specification, two status byte values * are legal for a {@code SysexMessage} read from a MIDI file: *

    - *
  • 0xF0: System Exclusive message (same as in MIDI wire protocol)
  • - *
  • 0xF7: Special System Exclusive message
  • + *
  • 0xF0: System Exclusive message (same as in MIDI wire protocol) + *
  • 0xF7: Special System Exclusive message *
* When Java Sound is used to handle system exclusive data that is being * received using MIDI wire protocol, it should place the data in one or more @@ -49,8 +49,8 @@ package javax.sound.midi; * is not known in advance; the end of the system exclusive data is marked by an * end-of-exclusive flag (0xF7) in the MIDI wire byte stream. *
    - *
  • 0xF0: System Exclusive message (same as in MIDI wire protocol)
  • - *
  • 0xF7: End of Exclusive (EOX)
  • + *
  • 0xF0: System Exclusive message (same as in MIDI wire protocol) + *
  • 0xF7: End of Exclusive (EOX) *
* The first {@code SysexMessage} object containing data for a particular system * exclusive message should have the status value 0xF0. If this message contains @@ -148,7 +148,7 @@ public class SysexMessage extends MidiMessage { * should be non-negative and less than or equal to * {@code data.length} * @throws InvalidMidiDataException if the parameter values do not specify a - * valid MIDI meta message + * valid MIDI system exclusive message * @see #setMessage(byte[], int) * @see #setMessage(int, byte[], int) * @see #getData() @@ -178,6 +178,8 @@ public class SysexMessage extends MidiMessage { * @param data the system exclusive message data * @param length the length of the valid message data in the array, * including the status byte + * @throws InvalidMidiDataException if the parameter values do not specify a + * valid MIDI system exclusive message */ @Override public void setMessage(byte[] data, int length) throws InvalidMidiDataException { @@ -195,7 +197,7 @@ public class SysexMessage extends MidiMessage { * @param data the system exclusive message data * @param length the length of the valid message data in the array * @throws InvalidMidiDataException if the status byte is invalid for a - * sysex message + * system exclusive message */ public void setMessage(int status, byte[] data, int length) throws InvalidMidiDataException { if ( (status != 0xF0) && (status != 0xF7) ) { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Track.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Track.java index 45320512334..e5d8eb1a358 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Track.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Track.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -64,10 +64,14 @@ public class Track { // TODO: use arrays for faster access - // the list containing the events + /** + * The list containing the events. + */ private final ArrayList eventsList = new ArrayList<>(); - // use a hashset to detect duplicate events in add(MidiEvent) + /** + * Use a hashset to detect duplicate events in add(MidiEvent). + */ private final HashSet set = new HashSet<>(); private final MidiEvent eotEvent; diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/Transmitter.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/Transmitter.java index 0b1a4507610..47c60330160 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Transmitter.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Transmitter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -67,7 +67,7 @@ public interface Transmitter extends AutoCloseable { * open/close behaviour see the class description of * {@link MidiDevice MidiDevice}. * - * @see javax.sound.midi.MidiSystem#getTransmitter + * @see MidiSystem#getTransmitter */ @Override void close(); diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/VoiceStatus.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/VoiceStatus.java index 0019a74f1b8..62ea76fc61a 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/VoiceStatus.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/VoiceStatus.java @@ -51,8 +51,8 @@ package javax.sound.midi; * given type of {@code Synthesizer} always has a fixed number of voices, equal * to the maximum number of simultaneous notes it is capable of sounding. *

- * If the voice is not currently processing - * a MIDI note, it is considered inactive. A voice is inactive when it has been + * If the voice is not currently processing a + * MIDI note, it is considered inactive. A voice is inactive when it has been * given no note-on commands, or when every note-on command received has been * terminated by a corresponding note-off (or by an "all notes off" message). * For example, this happens when a synthesizer capable of playing 16 diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/package-info.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/package-info.java index fe0bb38f555..994c55b7a05 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/package-info.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/package-info.java @@ -30,8 +30,8 @@ *

Related Documentation

* For more information on using Java Sound see: * * * @since 1.3 diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileReader.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileReader.java index f1c3b6f6ff5..729b3dca1d9 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileReader.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -54,8 +54,8 @@ public abstract class MidiFileReader { * stream's read pointer to its original position. If the input stream does * not support this, this method may fail with an {@code IOException}. * - * @param stream the input stream from which file format information - * should be extracted + * @param stream the input stream from which file format information should + * be extracted * @return a {@code MidiFileFormat} object describing the MIDI file format * @throws InvalidMidiDataException if the stream does not point to valid * MIDI file data recognized by the system @@ -68,14 +68,14 @@ public abstract class MidiFileReader { throws InvalidMidiDataException, IOException; /** - * Obtains the MIDI file format of the URL provided. The URL must point to - * valid MIDI file data. + * Obtains the MIDI file format of the {@code URL} provided. The {@code URL} + * must point to valid MIDI file data. * - * @param url the URL from which file format information should be + * @param url the {@code URL} from which file format information should be * extracted * @return a {@code MidiFileFormat} object describing the MIDI file format - * @throws InvalidMidiDataException if the URL does not point to valid MIDI - * file data recognized by the system + * @throws InvalidMidiDataException if the {@code URL} does not point to + * valid MIDI file data recognized by the system * @throws IOException if an I/O exception occurs * @throws NullPointerException if {@code url} is {@code null} */ @@ -104,10 +104,10 @@ public abstract class MidiFileReader { * it. These parsers must be able to mark the stream, read enough data to * determine whether they support the stream, and, if not, reset the * stream's read pointer to its original position. If the input stream does - * not support this, this method may fail with an IOException. + * not support this, this method may fail with an {@code IOException}. * - * @param stream the input stream from which the {@code Sequence} should - * be constructed + * @param stream the input stream from which the {@code Sequence} should be + * constructed * @return a {@code Sequence} object based on the MIDI file data contained * in the input stream * @throws InvalidMidiDataException if the stream does not point to valid @@ -121,14 +121,15 @@ public abstract class MidiFileReader { throws InvalidMidiDataException, IOException; /** - * Obtains a MIDI sequence from the URL provided. The URL must point to - * valid MIDI file data. + * Obtains a MIDI sequence from the {@code URL} provided. The {@code URL} + * must point to valid MIDI file data. * - * @param url the URL for which the {@code Sequence} should be constructed + * @param url the {@code URL} for which the {@code Sequence} should be + * constructed * @return a {@code Sequence} object based on the MIDI file data pointed to - * by the URL - * @throws InvalidMidiDataException if the URL does not point to valid MIDI - * file data recognized by the system + * by the {@code URL} + * @throws InvalidMidiDataException if the {@code URL} does not point to + * valid MIDI file data recognized by the system * @throws IOException if an I/O exception occurs * @throws NullPointerException if {@code url} is {@code null} */ diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileWriter.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileWriter.java index 9a3fdcbc62e..9d9bcbbfeaa 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileWriter.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/MidiFileWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -54,8 +54,7 @@ public abstract class MidiFileWriter { * Obtains the file types that this file writer can write from the sequence * specified. * - * @param sequence the sequence for which MIDI file type support is - * queried + * @param sequence the sequence for which MIDI file type support is queried * @return array of file types. If no file types are supported, returns an * array of length 0. * @throws NullPointerException if {@code sequence} is {@code null} diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/SoundbankReader.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/SoundbankReader.java index 8690b0d18ed..5fc0136986a 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/SoundbankReader.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/SoundbankReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -39,18 +39,18 @@ import javax.sound.midi.Synthesizer; * subclasses of {@code SoundbankReader} parse a given soundbank file, producing * a {@link Soundbank} object that can be loaded into a {@link Synthesizer}. * - * @since 1.3 * @author Kara Kytle + * @since 1.3 */ public abstract class SoundbankReader { /** - * Obtains a soundbank object from the URL provided. + * Obtains a soundbank object from the {@code URL} provided. * - * @param url URL representing the soundbank + * @param url {@code URL} representing the soundbank * @return soundbank object - * @throws InvalidMidiDataException if the URL does not point to valid MIDI - * soundbank data recognized by this soundbank reader + * @throws InvalidMidiDataException if the {@code URL} does not point to + * valid MIDI soundbank data recognized by this soundbank reader * @throws IOException if an I/O error occurs * @throws NullPointerException if {@code url} is {@code null} */ diff --git a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/package-info.java b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/package-info.java index b843f507b22..2f91c916514 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/package-info.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/spi/package-info.java @@ -30,8 +30,8 @@ *

Related Documentation

* For more information on using Java Sound see: * * * @since 1.3 diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFileFormat.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFileFormat.java index fafddcd0f43..64dc76d0a3a 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFileFormat.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFileFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -51,45 +51,37 @@ import java.util.Objects; * implementations: * * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + *
Audio File Format Properties
Property keyValue typeDescription
"duration"{@link java.lang.Long Long}playback duration of the file in microseconds
"author"{@link java.lang.String String}name of the author of this file
"title"{@link java.lang.String String}title of this file
"copyright"{@link java.lang.String String}copyright message
"date"{@link java.util.Date Date}date of the recording or release
"comment"{@link java.lang.String String}an arbitrary text
Audio File Format Properties
Property key + * Value type + * Description + *
"duration" + * {@link Long Long} + * playback duration of the file in microseconds + *
"author" + * {@link String String} + * name of the author of this file + *
"title" + * {@link String String} + * title of this file + *
"copyright" + * {@link String String} + * copyright message + *
"date" + * {@link java.util.Date Date} + * date of the recording or release + *
"comment" + * {@link String String} + * an arbitrary text *
* - * * @author David Rivas * @author Kara Kytle * @author Florian Bomers @@ -351,7 +343,12 @@ public class AudioFileFormat { } /** - * Finalizes the equals method. + * Indicates whether the specified object is equal to this file type, + * returning {@code true} if the objects are equal. + * + * @param obj the reference object with which to compare + * @return {@code true} if the specified object is equal to this file + * type; {@code false} otherwise */ @Override public final boolean equals(final Object obj) { @@ -365,7 +362,9 @@ public class AudioFileFormat { } /** - * Finalizes the hashCode method. + * Returns a hash code value for this file type. + * + * @return a hash code value for this file type */ @Override public final int hashCode() { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFormat.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFormat.java index 8baf0b68e9e..f5d561f70fd 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFormat.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioFormat.java @@ -40,6 +40,7 @@ import java.util.Objects; * data line expects to receive for output. For a target (capture) data line, * the audio format specifies the kind of the data that can be read from the * line. + *

* Sound files also have audio formats, of course. The {@link AudioFileFormat} * class encapsulates an {@code AudioFormat} in addition to other, file-specific * information. Similarly, an {@link AudioInputStream} has an @@ -92,29 +93,24 @@ import java.util.Objects; * * * - * - * - * - * - * + * + * * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * + * + * + * *
Audio Format Properties
Property keyValue typeDescription
Property key + * Value type + * Description *
"bitrate"{@link java.lang.Integer Integer}average bit rate in bits per second
"vbr"{@link java.lang.Boolean Boolean}{@code true}, if the file is encoded in variable bit - * rate (VBR)
"quality"{@link java.lang.Integer Integer}encoding/conversion quality, 1..100
"bitrate" + * {@link java.lang.Integer Integer} + * average bit rate in bits per second + *
"vbr" + * {@link java.lang.Boolean Boolean} + * {@code true}, if the file is encoded in variable bit rate (VBR) + *
"quality" + * {@link java.lang.Integer Integer} + * encoding/conversion quality, 1..100 *
*

@@ -183,8 +179,8 @@ public class AudioFormat { * @param encoding the audio encoding technique * @param sampleRate the number of samples per second * @param sampleSizeInBits the number of bits in each sample - * @param channels the number of channels (1 for mono, 2 for stereo, - * and so on) + * @param channels the number of channels (1 for mono, 2 for stereo, and so + * on) * @param frameSize the number of bytes in each frame * @param frameRate the number of frames per second * @param bigEndian indicates whether the data for a single sample is @@ -217,7 +213,8 @@ public class AudioFormat { * @param frameSize the number of bytes in each frame * @param frameRate the number of frames per second * @param bigEndian indicates whether the data for a single sample is - * stored in big-endian byte order ({@code false} means little-endian) + * stored in big-endian byte order ({@code false} means + * little-endian) * @param properties a {@code Map} object containing format * properties * @since 1.5 @@ -276,9 +273,10 @@ public class AudioFormat { /** * Obtains the sample rate. For compressed formats, the return value is the - * sample rate of the uncompressed audio data. When this AudioFormat is used - * for queries (e.g. {@link AudioSystem#isConversionSupported(AudioFormat, - * AudioFormat) AudioSystem.isConversionSupported}) or capabilities (e.g. + * sample rate of the uncompressed audio data. When this {@code AudioFormat} + * is used for queries (e.g. + * {@link AudioSystem#isConversionSupported(AudioFormat, AudioFormat) + * AudioSystem.isConversionSupported}) or capabilities (e.g. * {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a sample rate * of {@code AudioSystem.NOT_SPECIFIED} means that any sample rate is * acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the @@ -296,10 +294,10 @@ public class AudioFormat { /** * Obtains the size of a sample. For compressed formats, the return value is - * the sample size of the uncompressed audio data. When this AudioFormat is - * used for queries (e.g. {@link AudioSystem#isConversionSupported( - * AudioFormat,AudioFormat) AudioSystem.isConversionSupported}) or - * capabilities (e.g. + * the sample size of the uncompressed audio data. When this + * {@code AudioFormat} is used for queries (e.g. + * {@link AudioSystem#isConversionSupported(AudioFormat,AudioFormat) + * AudioSystem.isConversionSupported}) or capabilities (e.g. * {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a sample size * of {@code AudioSystem.NOT_SPECIFIED} means that any sample size is * acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the @@ -316,9 +314,9 @@ public class AudioFormat { } /** - * Obtains the number of channels. When this AudioFormat is used for queries - * (e.g. {@link AudioSystem#isConversionSupported(AudioFormat, AudioFormat) - * AudioSystem.isConversionSupported}) or capabilities (e.g. + * Obtains the number of channels. When this {@code AudioFormat} is used for + * queries (e.g. {@link AudioSystem#isConversionSupported(AudioFormat, + * AudioFormat) AudioSystem.isConversionSupported}) or capabilities (e.g. * {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a return * value of {@code AudioSystem.NOT_SPECIFIED} means that any (positive) * number of channels is acceptable. @@ -333,8 +331,8 @@ public class AudioFormat { } /** - * Obtains the frame size in bytes. When this AudioFormat is used for - * queries (e.g. {@link AudioSystem#isConversionSupported(AudioFormat, + * Obtains the frame size in bytes. When this {@code AudioFormat} is used + * for queries (e.g. {@link AudioSystem#isConversionSupported(AudioFormat, * AudioFormat) AudioSystem.isConversionSupported}) or capabilities (e.g. * {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a frame size * of {@code AudioSystem.NOT_SPECIFIED} means that any frame size is @@ -352,10 +350,10 @@ public class AudioFormat { } /** - * Obtains the frame rate in frames per second. When this AudioFormat is - * used for queries (e.g. {@link AudioSystem#isConversionSupported( - * AudioFormat,AudioFormat) AudioSystem.isConversionSupported}) or - * capabilities (e.g. + * Obtains the frame rate in frames per second. When this + * {@code AudioFormat} is used for queries (e.g. + * {@link AudioSystem#isConversionSupported(AudioFormat,AudioFormat) + * AudioSystem.isConversionSupported}) or capabilities (e.g. * {@link DataLine.Info#getFormats DataLine.Info.getFormats}), a frame rate * of {@code AudioSystem.NOT_SPECIFIED} means that any frame rate is * acceptable. {@code AudioSystem.NOT_SPECIFIED} is also returned when the @@ -551,9 +549,10 @@ public class AudioFormat { * the sound amplitude that are often used for recording speech. *

* You can use a predefined encoding by referring to one of the static - * objects created by this class, such as PCM_SIGNED or PCM_UNSIGNED. - * Service providers can create new encodings, such as compressed audio - * formats, and make these available through the {@link AudioSystem} class. + * objects created by this class, such as {@code PCM_SIGNED} or + * {@code PCM_UNSIGNED}. Service providers can create new encodings, such as + * compressed audio formats, and make these available through the + * {@link AudioSystem} class. *

* The {@code Encoding} class is static, so that all {@code AudioFormat} * objects that have the same encoding will refer to the same object (rather @@ -609,7 +608,12 @@ public class AudioFormat { } /** - * Finalizes the equals method. + * Indicates whether the specified object is equal to this encoding, + * returning {@code true} if the objects are equal. + * + * @param obj the reference object with which to compare + * @return {@code true} if the specified object is equal to this + * encoding; {@code false} otherwise */ @Override public final boolean equals(final Object obj) { @@ -623,7 +627,9 @@ public class AudioFormat { } /** - * Finalizes the hashCode method. + * Returns a hash code value for this encoding. + * + * @return a hash code value for this encoding */ @Override public final int hashCode() { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioInputStream.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioInputStream.java index 996a7b2a5a0..6061ec94c6a 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioInputStream.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -28,7 +28,6 @@ package javax.sound.sampled; import java.io.IOException; import java.io.InputStream; - /** * An audio input stream is an input stream with a specified audio format and * length. The length is expressed in sample frames, not bytes. Several methods @@ -42,9 +41,10 @@ import java.io.InputStream; * The {@code AudioSystem} class includes many methods that manipulate * {@code AudioInputStream} objects. For example, the methods let you: *

    - *
  • obtain an audio input stream from an external audio file, stream, or URL - *
  • write an external file from an audio input stream - *
  • convert an audio input stream to a different audio format + *
  • obtain an audio input stream from an external audio file, stream, or + * {@code URL} + *
  • write an external file from an audio input stream + *
  • convert an audio input stream to a different audio format *
* * @author David Rivas @@ -139,7 +139,7 @@ public class AudioInputStream extends InputStream { /** * Constructs an audio input stream that reads its data from the target data * line indicated. The format of the stream is the same as that of the - * target data line, and the length is AudioSystem#NOT_SPECIFIED. + * target data line, and the length is {@code AudioSystem#NOT_SPECIFIED}. * * @param line the target data line from which this stream obtains its data * @see AudioSystem#NOT_SPECIFIED @@ -370,11 +370,11 @@ public class AudioInputStream extends InputStream { /** * Returns the maximum number of bytes that can be read (or skipped over) - * from this audio input stream without blocking. This limit applies only - * to the next invocation of a {@code read} or {@code skip} method for this + * from this audio input stream without blocking. This limit applies only to + * the next invocation of a {@code read} or {@code skip} method for this * audio input stream; the limit can vary each time these methods are - * invoked. Depending on the underlying stream, an IOException may be thrown - * if this stream is closed. + * invoked. Depending on the underlying stream, an {@code IOException} may + * be thrown if this stream is closed. * * @return the number of bytes that can be read from this audio input stream * without blocking diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioPermission.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioPermission.java index 4b67d19f7eb..d2dfa04edf1 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioPermission.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioPermission.java @@ -45,34 +45,30 @@ import java.security.BasicPermission; * Permission target name, what the permission allows, and associated * risks * - * - * Permission Target Name - * What the Permission Allows - * Risks of Allowing this Permission - * + * + * Permission Target Name + * What the Permission Allows + * Risks of Allowing this Permission * * - * - * play - * Audio playback through the audio device or devices on the system. - * Allows the application to obtain and manipulate lines and mixers for - * audio playback (rendering). - * In some cases use of this permission may affect other - * applications because the audio from one line may be mixed with other audio - * being played on the system, or because manipulation of a mixer affects the - * audio for all lines using that mixer. - * - * - * - * record - * Audio recording through the audio device or devices on the system. - * Allows the application to obtain and manipulate lines and mixers for - * audio recording (capture). - * In some cases use of this permission may affect other - * applications because manipulation of a mixer affects the audio for all lines - * using that mixer. - * This permission can enable an applet or application to eavesdrop on a user. - * + * + * play + * Audio playback through the audio device or devices on the system. + * Allows the application to obtain and manipulate lines and mixers for + * audio playback (rendering). + * In some cases use of this permission may affect other + * applications because the audio from one line may be mixed with other + * audio being played on the system, or because manipulation of a mixer + * affects the audio for all lines using that mixer. + * + * record + * Audio recording through the audio device or devices on the system. + * Allows the application to obtain and manipulate lines and mixers for + * audio recording (capture). + * In some cases use of this permission may affect other applications + * because manipulation of a mixer affects the audio for all lines using + * that mixer. This permission can enable an applet or application to + * eavesdrop on a user. * * * @@ -81,6 +77,9 @@ import java.security.BasicPermission; */ public class AudioPermission extends BasicPermission { + /** + * Use serialVersionUID from JDK 1.3 for interoperability. + */ private static final long serialVersionUID = -5518053473477801126L; /** diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioSystem.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioSystem.java index ac3cacb28c9..203c57bad5f 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioSystem.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/AudioSystem.java @@ -25,7 +25,6 @@ package javax.sound.sampled; -import java.io.EOFException; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -75,33 +74,28 @@ import com.sun.media.sound.JDK13Services; * * * - * - * - * - * - * + * + * * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * + * + * + * + * *
Audio System Property Keys
Property KeyInterfaceAffected Method(s)
Property Key + * Interface + * Affected Method(s) *
{@code javax.sound.sampled.Clip}{@link Clip}{@link #getLine}, {@link #getClip}
{@code javax.sound.sampled.Port}{@link Port}{@link #getLine}
{@code javax.sound.sampled.SourceDataLine}{@link SourceDataLine}{@link #getLine}, {@link #getSourceDataLine}
{@code javax.sound.sampled.TargetDataLine}{@link TargetDataLine}{@link #getLine}, {@link #getTargetDataLine}
{@code javax.sound.sampled.Clip} + * {@link Clip} + * {@link #getLine}, {@link #getClip} + *
{@code javax.sound.sampled.Port} + * {@link Port} + * {@link #getLine} + *
{@code javax.sound.sampled.SourceDataLine} + * {@link SourceDataLine} + * {@link #getLine}, {@link #getSourceDataLine} + *
{@code javax.sound.sampled.TargetDataLine} + * {@link TargetDataLine} + * {@link #getLine}, {@link #getTargetDataLine} *
* @@ -125,20 +119,19 @@ import com.sun.media.sound.JDK13Services; * matching {@code Mixer.Info} object is found, or the mixer name is not * specified, the first mixer from the resulting list, which provides the * respective line interface, will be returned. - * + *

* For example, the property {@code javax.sound.sampled.Clip} with a value - * {@code "com.sun.media.sound.MixerProvider#SunClip"} - * will have the following consequences when {@code getLine} is called - * requesting a {@code Clip} instance: if the class - * {@code com.sun.media.sound.MixerProvider} exists in the list of installed - * mixer providers, the first {@code Clip} from the first mixer with name - * {@code "SunClip"} will be returned. If it cannot be found, the - * first {@code Clip} from the first mixer of the specified provider will be + * {@code "com.sun.media.sound.MixerProvider#SunClip"} will have the following + * consequences when {@code getLine} is called requesting a {@code Clip} + * instance: if the class {@code com.sun.media.sound.MixerProvider} exists in + * the list of installed mixer providers, the first {@code Clip} from the first + * mixer with name {@code "SunClip"} will be returned. If it cannot be found, + * the first {@code Clip} from the first mixer of the specified provider will be * returned, regardless of name. If there is none, the first {@code Clip} from - * the first {@code Mixer} with name {@code "SunClip"} in the list of - * all mixers (as returned by {@code getMixerInfo}) will be returned, or, if not - * found, the first {@code Clip} of the first {@code Mixer} that can be found in - * the list of all mixers is returned. If that fails, too, an + * the first {@code Mixer} with name {@code "SunClip"} in the list of all mixers + * (as returned by {@code getMixerInfo}) will be returned, or, if not found, the + * first {@code Clip} of the first {@code Mixer} that can be found in the list + * of all mixers is returned. If that fails, too, an * {@code IllegalArgumentException} is thrown. * * @author Kara Kytle @@ -479,7 +472,6 @@ public class AudioSystem { * @param mixerInfo a {@code Mixer.Info} object representing the desired * mixer, or {@code null} for the system default mixer * @return a clip object from the specified mixer - * * @throws LineUnavailableException if a clip is not available from this * mixer due to resource restrictions * @throws SecurityException if a clip is not available from this mixer due @@ -670,9 +662,9 @@ public class AudioSystem { * * @param sourceEncoding the encoding for which conversion support is * queried - * @return array of encodings. If {@code sourceEncoding}is not supported, an - * array of length 0 is returned. Otherwise, the array will have a - * length of at least 1, representing {@code sourceEncoding} + * @return array of encodings. If {@code sourceEncoding} is not supported, + * an array of length 0 is returned. Otherwise, the array will have + * a length of at least 1, representing {@code sourceEncoding} * (no conversion). * @throws NullPointerException if {@code sourceEncoding} is {@code null} */ @@ -935,15 +927,15 @@ public class AudioSystem { } /** - * Obtains the audio file format of the specified URL. The URL must point to - * valid audio file data. + * Obtains the audio file format of the specified {@code URL}. The + * {@code URL} must point to valid audio file data. * - * @param url the URL from which file format information should be + * @param url the {@code URL} from which file format information should be * extracted * @return an {@code AudioFileFormat} object describing the audio file * format - * @throws UnsupportedAudioFileException if the URL does not point to valid - * audio file data recognized by the system + * @throws UnsupportedAudioFileException if the {@code URL} does not point + * to valid audio file data recognized by the system * @throws IOException if an input/output exception occurs * @throws NullPointerException if {@code url} is {@code null} */ @@ -1021,15 +1013,15 @@ public class AudioSystem { } /** - * Obtains an audio input stream from the URL provided. The URL must point - * to valid audio file data. + * Obtains an audio input stream from the {@code URL} provided. The + * {@code URL} must point to valid audio file data. * - * @param url the URL for which the {@code AudioInputStream} should be - * constructed + * @param url the {@code URL} for which the {@code AudioInputStream} should + * be constructed * @return an {@code AudioInputStream} object based on the audio file data - * pointed to by the URL - * @throws UnsupportedAudioFileException if the URL does not point to valid - * audio file data recognized by the system + * pointed to by the {@code URL} + * @throws UnsupportedAudioFileException if the {@code URL} does not point + * to valid audio file data recognized by the system * @throws IOException if an I/O exception occurs * @throws NullPointerException if {@code url} is {@code null} */ @@ -1121,8 +1113,8 @@ public class AudioSystem { * Obtains the file types that the system can write from the audio input * stream specified. * - * @param stream the audio input stream for which audio file type - * support is queried + * @param stream the audio input stream for which audio file type support + * is queried * @return array of file types. If no file types are supported, an array of * length 0 is returned. * @throws NullPointerException if {@code stream} is {@code null} @@ -1175,8 +1167,8 @@ public class AudioSystem { * type to the output stream provided. Some file types require that the * length be written into the file header; such files cannot be written from * start to finish unless the length is known in advance. An attempt to - * write a file of such a type will fail with an IOException if the length - * in the audio file type is {@code AudioSystem.NOT_SPECIFIED}. + * write a file of such a type will fail with an {@code IOException} if the + * length in the audio file type is {@code AudioSystem.NOT_SPECIFIED}. * * @param stream the audio input stream containing audio data to be written * to the file @@ -1250,7 +1242,9 @@ public class AudioSystem { // METHODS FOR INTERNAL IMPLEMENTATION USE /** - * Obtains the set of MixerProviders on the system. + * Obtains the list of MixerProviders currently installed on the system. + * + * @return the list of MixerProviders currently installed on the system */ @SuppressWarnings("unchecked") private static List getMixerProviders() { @@ -1331,9 +1325,12 @@ public class AudioSystem { } } - /* Provider class not specified or - provider class cannot be found, or - provider class and instance specified and instance cannot be found or is not appropriate */ + /* + * - Provider class not specified, or + * - provider class cannot be found, or + * - provider class and instance specified and instance cannot be found + * or is not appropriate + */ if (instanceName != null) { mixer = getNamedMixer(instanceName, providers, info); if (mixer != null) { @@ -1342,8 +1339,10 @@ public class AudioSystem { } - /* No default are specified, or if something is specified, everything - failed. */ + /* + * No defaults are specified, or if something is specified, everything + * failed + */ return null; } @@ -1436,10 +1435,14 @@ public class AudioSystem { /** * Checks if a Mixer is appropriate. A Mixer is considered appropriate if it - * support the given line type. If isMixingRequired is true and the line - * type is an output one (SourceDataLine, Clip), the mixer is appropriate if - * it supports at least 2 (concurrent) lines of the given type. + * support the given line type. If isMixingRequired is {@code true} and the + * line type is an output one (SourceDataLine, Clip), the mixer is + * appropriate if it supports at least 2 (concurrent) lines of the given + * type. * + * @param mixer The mixer to check + * @param lineInfo The line to check + * @param isMixingRequired Is the mixing required or not * @return {@code true} if the mixer is considered appropriate according to * the rules given above, {@code false} otherwise */ @@ -1461,6 +1464,10 @@ public class AudioSystem { /** * Like getMixerInfo, but return List. + * + * @return a List of info objects for the currently installed mixers. If no + * mixers are available on the system, an empty List is returned. + * @see #getMixerInfo() */ private static List getMixerInfoList() { List providers = getMixerProviders(); @@ -1469,6 +1476,11 @@ public class AudioSystem { /** * Like getMixerInfo, but return List. + * + * @param providers The list of MixerProviders + * @return a List of info objects for the currently installed mixers. If no + * mixers are available on the system, an empty List is returned. + * @see #getMixerInfo() */ private static List getMixerInfoList(List providers) { List infos = new ArrayList<>(); @@ -1491,6 +1503,11 @@ public class AudioSystem { * Obtains the set of services currently installed on the system using the * SPI mechanism in 1.3. * + * @param providerClass The type of providers requested. This should be one + * of AudioFileReader.class, AudioFileWriter.class, + * FormatConversionProvider.class, MixerProvider.class, + * MidiDeviceProvider.class, MidiFileReader.class, + * MidiFileWriter.class or SoundbankReader.class. * @return a List of instances of providers for the requested service. If no * providers are available, a vector of length 0 will be returned. */ diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/BooleanControl.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/BooleanControl.java index a1abf92cef6..ede71800428 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/BooleanControl.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/BooleanControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -121,7 +121,7 @@ public abstract class BooleanControl extends Control { /** * Provides a string representation of the control. * - * @return a string description + * @return a string representation of the control */ @Override public String toString() { @@ -153,7 +153,7 @@ public abstract class BooleanControl extends Control { /** * Constructs a new boolean control type. * - * @param name the name of the new boolean control type + * @param name the name of the new boolean control type */ protected Type(final String name) { super(name); diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/Clip.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/Clip.java index 2592c32911d..3257eadf0f4 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/Clip.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/Clip.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -178,13 +178,13 @@ public interface Clip extends DataLine { /** * Sets the first and last sample frames that will be played in the loop. * The ending point must be greater than or equal to the starting point, and - * both must fall within the size of the loaded media. A value of 0 for - * the starting point means the beginning of the loaded media. Similarly, a + * both must fall within the size of the loaded media. A value of 0 for the + * starting point means the beginning of the loaded media. Similarly, a * value of -1 for the ending point indicates the last frame of the media. * * @param start the loop's starting position, in sample frames (zero-based) - * @param end the loop's ending position, in sample frames (zero-based), - * or -1 to indicate the final frame + * @param end the loop's ending position, in sample frames (zero-based), or + * -1 to indicate the final frame * @throws IllegalArgumentException if the requested loop points cannot be * set, usually because one or both falls outside the media's * duration or because the ending point is before the starting point diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/CompoundControl.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/CompoundControl.java index 64d9bbabc8b..a3b94c92200 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/CompoundControl.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/CompoundControl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -90,8 +90,7 @@ public abstract class CompoundControl extends Control { /** * An instance of the {@code CompoundControl.Type} inner class identifies - * one kind of compound control. Static instances are provided for the - * common types. + * one kind of compound control. * * @author Kara Kytle * @since 1.3 diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/Control.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/Control.java index bdd3bca4309..bdf3da5c73d 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/Control.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/Control.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -48,7 +48,7 @@ public abstract class Control { private final Type type; /** - * Constructs a Control with the specified type. + * Constructs a control with the specified type. * * @param type the kind of control desired */ @@ -66,9 +66,9 @@ public abstract class Control { } /** - * Obtains a String describing the control type and its current state. + * Obtains a string describing the control type and its current state. * - * @return a String representation of the Control + * @return a string representation of the control */ @Override public String toString() { @@ -77,7 +77,6 @@ public abstract class Control { /** * An instance of the {@code Type} class represents the type of the control. - * Static instances are provided for the common types. */ public static class Type { @@ -98,7 +97,12 @@ public abstract class Control { } /** - * Finalizes the equals method. + * Indicates whether the specified object is equal to this control type, + * returning {@code true} if the objects are the same. + * + * @param obj the reference object with which to compare + * @return {@code true} if the specified object is equal to this control + * type; {@code false} otherwise */ @Override public final boolean equals(Object obj) { @@ -106,7 +110,9 @@ public abstract class Control { } /** - * Finalizes the hashCode method. + * Returns a hash code value for this control type. + * + * @return a hash code value for this control type */ @Override public final int hashCode() { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/DataLine.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/DataLine.java index 6246a40d64f..c036f7a51c5 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/DataLine.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/DataLine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -54,7 +54,7 @@ import java.util.Arrays; * data, a {@code STOP} event is generated. *

* Mixers often support synchronized control of multiple data lines. - * Synchronization can be established through the Mixer interface's + * Synchronization can be established through the {@code Mixer} interface's * {@link Mixer#synchronize synchronize} method. See the description of the * {@link Mixer Mixer} interface for a more complete description. * @@ -181,7 +181,7 @@ public interface DataLine extends Line { * are bytes, but will always correspond to an integral number of sample * frames of audio data. * - * @return the size of the buffer in bytes + * @return the size of the buffer, in bytes */ int getBufferSize(); @@ -260,8 +260,8 @@ public interface DataLine extends Line { * {@code DataLine.Info} provides additional information specific to data * lines. This information includes: *

    - *
  • the audio formats supported by the data line - *
  • the minimum and maximum sizes of its internal buffer + *
  • the audio formats supported by the data line + *
  • the minimum and maximum sizes of its internal buffer *
* Because a {@code Line.Info} knows the class of the line its describes, a * {@code DataLine.Info} object can describe {@code DataLine} subinterfaces @@ -270,14 +270,25 @@ public interface DataLine extends Line { * appropriate instance of {@code DataLine.Info} as the argument to a method * such as {@link Mixer#getLine(Line.Info)}. * - * @see Line.Info * @author Kara Kytle + * @see Line.Info * @since 1.3 */ class Info extends Line.Info { + /** + * The set of supported formats. + */ private final AudioFormat[] formats; + + /** + * Minimum buffer size supported by the data line, in bytes. + */ private final int minBufferSize; + + /** + * Maximum buffer size supported by the data line, in bytes. + */ private final int maxBufferSize; /** @@ -289,10 +300,10 @@ public interface DataLine extends Line { * @param lineClass the class of the data line described by the info * object * @param formats set of formats supported - * @param minBufferSize minimum buffer size supported by the data - * line, in bytes - * @param maxBufferSize maximum buffer size supported by the data - * line, in bytes + * @param minBufferSize minimum buffer size supported by the data line, + * in bytes + * @param maxBufferSize maximum buffer size supported by the data line, + * in bytes */ public Info(Class lineClass, AudioFormat[] formats, int minBufferSize, int maxBufferSize) { @@ -317,7 +328,7 @@ public interface DataLine extends Line { * @param lineClass the class of the data line described by the info * object * @param format desired format - * @param bufferSize desired buffer size in bytes + * @param bufferSize desired buffer size, in bytes */ public Info(Class lineClass, AudioFormat format, int bufferSize) { @@ -354,7 +365,7 @@ public interface DataLine extends Line { * {@code isFormatSupported(AudioFormat)} is guaranteed to return * {@code true} for all formats returned by {@code getFormats()}. *

- * Some fields in the AudioFormat instances can be set to + * Some fields in the {@code AudioFormat} instances can be set to * {@link AudioSystem#NOT_SPECIFIED NOT_SPECIFIED} if that field does * not apply to the format, or if the format supports a wide range of * values for that field. For example, a multi-channel device supporting @@ -419,6 +430,7 @@ public interface DataLine extends Line { * large as that of the object specified, and all of its formats must * match formats supported by the object specified. * + * @param info the info object which is being compared to this one * @return {@code true} if this object matches the one specified, * otherwise {@code false} */ diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/Line.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/Line.java index feb69fde185..4d161c409b7 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/Line.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/Line.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -237,8 +237,8 @@ public interface Line extends AutoCloseable { * class. This constructor is typically used by an application to * describe a desired line. * - * @param lineClass the class of the line that the new Line.Info object - * describes + * @param lineClass the class of the line that the new + * {@code Line.Info} object describes */ public Info(Class lineClass) { @@ -250,7 +250,8 @@ public interface Line extends AutoCloseable { } /** - * Obtains the class of the line that this Line.Info object describes. + * Obtains the class of the line that this {@code Line.Info} object + * describes. * * @return the described line's class */ @@ -261,13 +262,13 @@ public interface Line extends AutoCloseable { /** * Indicates whether the specified info object matches this one. To * match, the specified object must be identical to or a special case of - * this one. The specified info object must be either an instance of - * the same class as this one, or an instance of a sub-type of this one. - * In addition, the attributes of the specified object must be - * compatible with the capabilities of this one. Specifically, the - * routing configuration for the specified info object must be - * compatible with that of this one. Subclasses may add other criteria - * to determine whether the two objects match. + * this one. The specified info object must be either an instance of the + * same class as this one, or an instance of a sub-type of this one. In + * addition, the attributes of the specified object must be compatible + * with the capabilities of this one. Specifically, the routing + * configuration for the specified info object must be compatible with + * that of this one. Subclasses may add other criteria to determine + * whether the two objects match. * * @param info the info object which is being compared to this one * @return {@code true} if the specified object matches this one, diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/LineEvent.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/LineEvent.java index ca57d1de22a..9371cce72ed 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/LineEvent.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/LineEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -48,14 +48,17 @@ import java.util.EventObject; */ public class LineEvent extends EventObject { + /** + * Use serialVersionUID from JDK 1.3 for interoperability. + */ private static final long serialVersionUID = -1274246333383880410L; /** * The kind of line event ({@code OPEN}, {@code CLOSE}, {@code START}, or * {@code STOP}). * - * @serial * @see #getType + * @serial */ private final Type type; @@ -67,8 +70,8 @@ public class LineEvent extends EventObject { * this value is not known, the position value should be * {@link AudioSystem#NOT_SPECIFIED}. * - * @serial * @see #getFramePosition + * @serial */ private final long position; @@ -184,11 +187,11 @@ public class LineEvent extends EventObject { /** * Indicates whether the specified object is equal to this event type, - * returning {@code true} if the objects are identical. + * returning {@code true} if the objects are the same. * * @param obj the reference object with which to compare - * @return {@code true} if this event type is the same as {@code obj}; - * {@code false} otherwise + * @return {@code true} if the specified object is equal to this event + * type; {@code false} otherwise */ @Override public final boolean equals(Object obj) { @@ -196,7 +199,9 @@ public class LineEvent extends EventObject { } /** - * Finalizes the hashcode method. + * Returns a hash code value for this event type. + * + * @return a hash code value for this event type */ @Override public final int hashCode() { @@ -205,6 +210,8 @@ public class LineEvent extends EventObject { /** * Returns the type name as the string representation. + * + * @return the type name as the string representation */ @Override public String toString() { @@ -253,22 +260,24 @@ public class LineEvent extends EventObject { /** * A type of event that is sent when a line ceases to engage in active - * input or output of audio data because the end of media has been reached. + * input or output of audio data because the end of media has been + * reached. */ /* - * ISSUE: we may want to get rid of this. Is JavaSound - * responsible for reporting this?? + * ISSUE: we may want to get rid of this. Is JavaSound responsible for + * reporting this?? * - * [If it's decided to keep this API, the docs will need to be updated to include mention - * of EOM events elsewhere.] + * [If it's decided to keep this API, the docs will need to be updated + * to include mention of EOM events elsewhere.] */ //public static final Type EOM = new Type("EOM"); /** * A type of event that is sent when a line begins to engage in active - * input or output of audio data. Examples of when this happens are - * when a source line begins or resumes writing data to its mixer, and - * when a target line begins or resumes reading data from its mixer. + * input or output of audio data. Examples of when this happens are when + * a source line begins or resumes writing data to its mixer, and when a + * target line begins or resumes reading data from its mixer. + * * @see #STOP * @see SourceDataLine#write * @see TargetDataLine#read @@ -277,8 +286,9 @@ public class LineEvent extends EventObject { //public static final Type ACTIVE = new Type("ACTIVE"); /** - * A type of event that is sent when a line ceases active input or output - * of audio data. + * A type of event that is sent when a line ceases active input or + * output of audio data. + * * @see #START * @see DataLine#stop */ diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/LineUnavailableException.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/LineUnavailableException.java index 701d8ee499a..333315652f9 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/LineUnavailableException.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/LineUnavailableException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -35,6 +35,9 @@ package javax.sound.sampled; */ public class LineUnavailableException extends Exception { + /** + * Use serialVersionUID from JDK 1.3 for interoperability. + */ private static final long serialVersionUID = -2046718279487432130L; /** diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/Mixer.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/Mixer.java index 87784ec62f1..4890bab5690 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/Mixer.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/Mixer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -58,7 +58,7 @@ public interface Mixer extends Line { * version, vendor, etc. * * @return a mixer info object that describes this mixer - * @see Mixer.Info + * @see Info */ Info getMixerInfo(); @@ -144,19 +144,19 @@ public interface Mixer extends Line { /** * Obtains the approximate maximum number of lines of the requested type * that can be open simultaneously on the mixer. - * + *

* Certain types of mixers do not have a hard bound and may allow opening * more lines. Since certain lines are a shared resource, a mixer may not be * able to open the maximum number of lines if another process has opened * lines of this mixer. - * + *

* The requested type is any line that matches the description in the * provided {@code Line.Info} object. For example, if the info object * represents a speaker port, and the mixer supports exactly one speaker - * port, this method should return 1. If the info object represents a - * source data line and the mixer supports the use of 32 source data lines + * port, this method should return 1. If the info object represents a source + * data line and the mixer supports the use of 32 source data lines * simultaneously, the return value should be 32. If there is no limit, this - * function returns {@code AudioSystem.NOT_SPECIFIED}. + * function returns {@link AudioSystem#NOT_SPECIFIED}. * * @param info a {@code Line.Info} that describes the line for which the * number of supported instances is queried @@ -215,11 +215,10 @@ public interface Mixer extends Line { * this mixer are unsynchronized. * * @param lines the synchronized lines for which synchronization should be - * released, or {@code null} for all this mixer's synchronized - * lines + * released, or {@code null} for all this mixer's synchronized lines * @throws IllegalArgumentException if the lines cannot be unsynchronized. - * This may occur if the argument specified does not exactly match - * a set of lines for which synchronization has already been + * This may occur if the argument specified does not exactly match a + * set of lines for which synchronization has already been * established. */ void unsynchronize(Line[] lines); @@ -277,8 +276,8 @@ public interface Mixer extends Line { * information. * * @param name the name of the mixer - * @param vendor the company who manufactures or creates the - * hardware or software mixer + * @param vendor the company who manufactures or creates the hardware + * or software mixer * @param description descriptive text about the mixer * @param version version information for the mixer */ @@ -291,13 +290,12 @@ public interface Mixer extends Line { } /** - * Indicates whether two info objects are equal, returning {@code true} - * if they are identical. + * Indicates whether the specified object is equal to this info object, + * returning {@code true} if the objects are the same. * - * @param obj the reference object with which to compare this info - * object - * @return {@code true} if this info object is the same as the - * {@code obj} argument; {@code false} otherwise + * @param obj the reference object with which to compare + * @return {@code true} if the specified object is equal to this info + * object; {@code false} otherwise */ @Override public final boolean equals(Object obj) { @@ -305,9 +303,9 @@ public interface Mixer extends Line { } /** - * Finalizes the hashcode method. + * Returns a hash code value for this info object. * - * @return the hashcode for this object + * @return a hash code value for this info object */ @Override public final int hashCode() { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/Port.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/Port.java index 08596f031eb..b717fc1dd55 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/Port.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/Port.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -100,7 +100,14 @@ public interface Port extends Line { // DAT // DVD + /** + * The string that names the port. + */ private final String name; + + /** + * Whether this port is source or not. + */ private final boolean isSource; /** @@ -111,8 +118,8 @@ public interface Port extends Line { * @param lineClass the class of the port described by the info object * @param name the string that names the port * @param isSource {@code true} if the port is a source port (such as a - * microphone), {@code false} if the port is a target port - * (such as a speaker) + * microphone), {@code false} if the port is a target port (such + * as a speaker) */ public Info(Class lineClass, String name, boolean isSource) { @@ -134,8 +141,8 @@ public interface Port extends Line { * Indicates whether the port is a source or a target for its mixer. * * @return {@code true} if the port is a source port (such as a - * microphone), {@code false} if the port is a target port - * (such as a speaker) + * microphone), {@code false} if the port is a target port (such + * as a speaker) */ public boolean isSource() { return isSource; @@ -147,6 +154,8 @@ public interface Port extends Line { * types must be equal. * * @param info the info object for which the match is queried + * @return {@code true} if the specified object matches this one, + * {@code false} otherwise */ @Override public boolean matches(Line.Info info) { @@ -167,7 +176,12 @@ public interface Port extends Line { } /** - * Finalizes the equals method. + * Indicates whether the specified object is equal to this info object, + * returning {@code true} if the objects are the same. + * + * @param obj the reference object with which to compare + * @return {@code true} if the specified object is equal to this info + * object; {@code false} otherwise */ @Override public final boolean equals(Object obj) { @@ -175,7 +189,9 @@ public interface Port extends Line { } /** - * Finalizes the hashCode method. + * Returns a hash code value for this info object. + * + * @return a hash code value for this info object */ @Override public final int hashCode() { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/ReverbType.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/ReverbType.java index e1199dbe6c5..cae8f052209 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/ReverbType.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/ReverbType.java @@ -38,7 +38,7 @@ package javax.sound.sampled; * delay time and intensity of early reflections, the delay time and intensity * of late reflections, and an overall decay time. Early reflections are the * initial individual low-order reflections of the direct signal off the - * surfaces in the room. The late Reflections are the dense, high-order + * surfaces in the room. The late reflections are the dense, high-order * reflections that characterize the room's reverberation. The delay times for * the start of these two reflection types give the listener a sense of the * overall size and complexity of the room's shape and contents. The larger the @@ -63,8 +63,8 @@ package javax.sound.sampled; *

* If implementing JavaSound on a I3DL2-compliant device: *

    - *
  • Filtering is disabled (high-frequency attenuations are set to 0.0 dB) - *
  • Density parameters are set to midway between minimum and maximum + *
  • Filtering is disabled (high-frequency attenuations are set to 0.0 dB) + *
  • Density parameters are set to midway between minimum and maximum *
*

* The following table shows what parameter values an implementation might use @@ -74,60 +74,50 @@ package javax.sound.sampled; * Reverb types and params: decay time, late intensity, late delay, * early intensity, and early delay * - * - * Type - * Decay Time (ms) - * Late Intensity (dB) - * Late Delay (ms) - * Early Intensity (dB) - * Early Delay(ms) - * + * + * Type + * Decay Time (ms) + * Late Intensity (dB) + * Late Delay (ms) + * Early Intensity (dB) + * Early Delay(ms) * * - * - * Cavern - * 2250 - * -2.0 - * 41.3 - * -1.4 - * 10.3 - * - * - * - * Dungeon - * 1600 - * -1.0 - * 10.3 - * -0.7 - * 2.6 - * - * - * - * Garage - * 900 - * -6.0 - * 14.7 - * -4.0 - * 3.9 - * - * - * - * Acoustic Lab - * 280 - * -3.0 - * 8.0 - * -2.0 - * 2.0 - * - * - * - * Closet - * 150 - * -10.0 - * 2.5 - * -7.0 - * 0.6 - * + * + * Cavern + * 2250 + * -2.0 + * 41.3 + * -1.4 + * 10.3 + * + * Dungeon + * 1600 + * -1.0 + * 10.3 + * -0.7 + * 2.6 + * + * Garage + * 900 + * -6.0 + * 14.7 + * -4.0 + * 3.9 + * + * Acoustic Lab + * 280 + * -3.0 + * 8.0 + * -2.0 + * 2.0 + * + * Closet + * 150 + * -10.0 + * 2.5 + * -7.0 + * 0.6 * * * @@ -199,7 +189,7 @@ public class ReverbType { * @since 1.5 */ public String getName() { - return name; + return name; } /** @@ -257,11 +247,11 @@ public class ReverbType { /** * Indicates whether the specified object is equal to this reverb type, - * returning {@code true} if the objects are identical. + * returning {@code true} if the objects are the same. * * @param obj the reference object with which to compare - * @return {@code true} if this reverb type is the same as {@code obj}; - * {@code false} otherwise + * @return {@code true} if the specified object is equal to this reverb + * type; {@code false} otherwise */ @Override public final boolean equals(Object obj) { @@ -269,7 +259,9 @@ public class ReverbType { } /** - * Finalizes the hashcode method. + * Returns a hash code value for this reverb type. + * + * @return a hash code value for this reverb type */ @Override public final int hashCode() { diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/SourceDataLine.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/SourceDataLine.java index b5e20f0702a..b42d544bb82 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/SourceDataLine.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/SourceDataLine.java @@ -168,9 +168,9 @@ public interface SourceDataLine extends DataLine { * {@code IllegalArgumentException}. * * @param b a byte array containing data to be written to the data line + * @param off the offset from the beginning of the array, in bytes * @param len the length, in bytes, of the valid data in the array (in * other words, the requested amount of data to write, in bytes) - * @param off the offset from the beginning of the array, in bytes * @return the number of bytes actually written * @throws IllegalArgumentException if the requested number of bytes does * not represent an integral number of sample frames, or if diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java index b58b49e908f..0bb35e1ac65 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/UnsupportedAudioFileException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -35,11 +35,14 @@ package javax.sound.sampled; */ public class UnsupportedAudioFileException extends Exception { + /** + * Use serialVersionUID from JDK 1.3 for interoperability. + */ private static final long serialVersionUID = -139127412623160368L; /** - * Constructs an {@code UnsupportedAudioFileException} that has - * {@code null} as its error detail message. + * Constructs an {@code UnsupportedAudioFileException} that has {@code null} + * as its error detail message. */ public UnsupportedAudioFileException() { super(); diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/package-info.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/package-info.java index e298c19c9d0..84d4ee035d1 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/package-info.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/package-info.java @@ -30,8 +30,8 @@ *

Related Documentation

* For more information on using Java Sound see: * * * @since 1.3 diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileReader.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileReader.java index f130dba477f..244abf23e51 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileReader.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -68,15 +68,15 @@ public abstract class AudioFileReader { throws UnsupportedAudioFileException, IOException; /** - * Obtains the audio file format of the URL provided. The URL must point to - * valid audio file data. + * Obtains the audio file format of the {@code URL} provided. The + * {@code URL} must point to valid audio file data. * - * @param url the URL from which file format information should be + * @param url the {@code URL} from which file format information should be * extracted * @return an {@code AudioFileFormat} object describing the audio file * format - * @throws UnsupportedAudioFileException if the URL does not point to valid - * audio file data recognized by the system + * @throws UnsupportedAudioFileException if the {@code URL} does not point + * to valid audio file data recognized by the system * @throws IOException if an I/O exception occurs * @throws NullPointerException if {@code url} is {@code null} */ @@ -84,11 +84,11 @@ public abstract class AudioFileReader { throws UnsupportedAudioFileException, IOException; /** - * Obtains the audio file format of the {@code File} provided. - * The {@code File} must point to valid audio file data. + * Obtains the audio file format of the {@code File} provided. The + * {@code File} must point to valid audio file data. * - * @param file the {@code File} from which file format information - * should be extracted + * @param file the {@code File} from which file format information should + * be extracted * @return an {@code AudioFileFormat} object describing the audio file * format * @throws UnsupportedAudioFileException if the {@code File} does not point @@ -123,15 +123,15 @@ public abstract class AudioFileReader { throws UnsupportedAudioFileException, IOException; /** - * Obtains an audio input stream from the URL provided. The URL must point - * to valid audio file data. + * Obtains an audio input stream from the {@code URL} provided. The + * {@code URL} must point to valid audio file data. * - * @param url the URL for which the {@code AudioInputStream} should be - * constructed + * @param url the {@code URL} for which the {@code AudioInputStream} should + * be constructed * @return an {@code AudioInputStream} object based on the audio file data - * pointed to by the URL - * @throws UnsupportedAudioFileException if the URL does not point to valid - * audio file data recognized by the system + * pointed to by the {@code URL} + * @throws UnsupportedAudioFileException if the {@code URL} does not point + * to valid audio file data recognized by the system * @throws IOException if an I/O exception occurs * @throws NullPointerException if {@code url} is {@code null} */ @@ -139,8 +139,8 @@ public abstract class AudioFileReader { throws UnsupportedAudioFileException, IOException; /** - * Obtains an audio input stream from the {@code File} provided. - * The {@code File} must point to valid audio file data. + * Obtains an audio input stream from the {@code File} provided. The + * {@code File} must point to valid audio file data. * * @param file the {@code File} for which the {@code AudioInputStream} * should be constructed diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileWriter.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileWriter.java index 0f137363b8c..c9a26ea1317 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileWriter.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/AudioFileWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -113,10 +113,10 @@ public abstract class AudioFileWriter { /** * Writes a stream of bytes representing an audio file of the file type - * indicated to the output stream provided. Some file types require that - * the length be written into the file header, and cannot be written from - * start to finish unless the length is known in advance. An attempt to - * write such a file type will fail with an IOException if the length in the + * indicated to the output stream provided. Some file types require that the + * length be written into the file header, and cannot be written from start + * to finish unless the length is known in advance. An attempt to write such + * a file type will fail with an {@code IOException} if the length in the * audio file format is {@link AudioSystem#NOT_SPECIFIED}. * * @param stream the audio input stream containing audio data to be written diff --git a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/package-info.java b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/package-info.java index 199bce22723..14939758eed 100644 --- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/package-info.java +++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/spi/package-info.java @@ -30,8 +30,8 @@ *

Related Documentation

* For more information on using Java Sound see: * * * @since 1.3 From 00edd2ed613646591b23b3f6dbc966e04eb25d5f Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 31 Aug 2017 17:18:23 -0400 Subject: [PATCH 73/98] 8186978: Introduce configure argument enable-cds Reviewed-by: dholmes, erikj, ihse --- common/autoconf/configure.ac | 1 + common/autoconf/generated-configure.sh | 42 ++++++++++++++++++++++---- common/autoconf/hotspot.m4 | 24 ++++++++++++++- common/autoconf/jdk-options.m4 | 7 +++-- 4 files changed, 64 insertions(+), 10 deletions(-) diff --git a/common/autoconf/configure.ac b/common/autoconf/configure.ac index 443d119f7aa..0bf6cf97c5e 100644 --- a/common/autoconf/configure.ac +++ b/common/autoconf/configure.ac @@ -209,6 +209,7 @@ JDKOPT_SETUP_CODE_COVERAGE # Need toolchain to setup dtrace HOTSPOT_SETUP_DTRACE HOTSPOT_ENABLE_DISABLE_AOT +HOTSPOT_ENABLE_DISABLE_CDS HOTSPOT_ENABLE_DISABLE_GTEST ############################################################################### diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index eed950c7513..43a1446ff2c 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -702,6 +702,7 @@ LIBCXX FIXPATH_DETACH_FLAG FIXPATH BUILD_GTEST +ENABLE_CDS ENABLE_AOT GCOV_ENABLED ZIP_EXTERNAL_DEBUG_SYMBOLS @@ -1191,6 +1192,7 @@ enable_zip_debug_info enable_native_coverage enable_dtrace enable_aot +enable_cds enable_hotspot_gtest with_stdc__lib with_msvcr_dll @@ -1999,6 +2001,8 @@ Optional Features: enable ahead of time compilation feature. Default is auto, where aot is enabled if all dependencies are present. + --enable-cds[=yes/no] enable class data sharing feature in non-minimal VM. + Default is yes. --disable-hotspot-gtest Disables building of the Hotspot unit tests --disable-freetype-bundling disable bundling of the freetype library with the @@ -2016,7 +2020,8 @@ Optional Features: --disable-generate-classlist forces enabling or disabling of the generation of a CDS classlist at build time. Default is to generate - it when either the server or client JVMs are built. + it when either the server or client JVMs are built + and enable-cds is true. --enable-sjavac use sjavac to do fast incremental compiles [disabled] --disable-javac-server disable javac server [enabled] @@ -4345,6 +4350,11 @@ VALID_JVM_VARIANTS="server client minimal core zero zeroshark custom" # +################################################################################ +# Allow to disable CDS +# + + ############################################################################### # Set up all JVM features for each JVM variant. # @@ -5151,7 +5161,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1504027321 +DATE_WHEN_GENERATED=1504214237 ############################################################################### # @@ -54204,6 +54214,23 @@ $as_echo "no, forced" >&6; } + # Check whether --enable-cds was given. +if test "${enable_cds+set}" = set; then : + enableval=$enable_cds; +fi + + + if test "x$enable_cds" = "x" || test "x$enable_cds" = "xyes"; then + ENABLE_CDS="true" + elif test "x$enable_cds" = "xno"; then + ENABLE_CDS="false" + else + as_fn_error $? "Invalid value for --enable-cds: $enable_cds" "$LINENO" 5 + fi + + + + # Check whether --enable-hotspot-gtest was given. if test "${enable_hotspot_gtest+set}" = set; then : enableval=$enable_hotspot_gtest; @@ -65848,7 +65875,10 @@ $as_echo "no" >&6; } fi # All variants but minimal (and custom) get these features - NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti fprof vm-structs jni-check services management all-gcs nmt cds" + NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti fprof vm-structs jni-check services management all-gcs nmt" + if test "x$ENABLE_CDS" = "xtrue"; then + NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES cds" + fi # Enable features depending on variant. JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci $JVM_FEATURES_aot $JVM_FEATURES_graal" @@ -65952,7 +65982,7 @@ fi # Check if it's likely that it's possible to generate the classlist. Depending # on exact jvm configuration it could be possible anyway. - if [[ " $JVM_VARIANTS " =~ " server " ]] || [[ " $JVM_VARIANTS " =~ " client " ]] ; then + if test "x$ENABLE_CDS" = "xtrue" && ( [[ " $JVM_VARIANTS " =~ " server " ]] || [[ " $JVM_VARIANTS " =~ " client " ]] ); then ENABLE_GENERATE_CLASSLIST_POSSIBLE="true" else ENABLE_GENERATE_CLASSLIST_POSSIBLE="false" @@ -65965,8 +65995,8 @@ $as_echo_n "checking if the CDS classlist generation should be enabled... " >&6; $as_echo "yes, forced" >&6; } ENABLE_GENERATE_CLASSLIST="true" if test "x$ENABLE_GENERATE_CLASSLIST_POSSIBLE" = "xfalse"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS" >&5 -$as_echo "$as_me: WARNING: Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS and enable-cds=$ENABLE_CDS" >&5 +$as_echo "$as_me: WARNING: Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS and enable-cds=$ENABLE_CDS" >&2;} fi elif test "x$enable_generate_classlist" = "xno"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, forced" >&5 diff --git a/common/autoconf/hotspot.m4 b/common/autoconf/hotspot.m4 index fa361eb7fad..2d224919185 100644 --- a/common/autoconf/hotspot.m4 +++ b/common/autoconf/hotspot.m4 @@ -240,6 +240,25 @@ AC_DEFUN_ONCE([HOTSPOT_ENABLE_DISABLE_AOT], AC_SUBST(ENABLE_AOT) ]) +################################################################################ +# Allow to disable CDS +# +AC_DEFUN_ONCE([HOTSPOT_ENABLE_DISABLE_CDS], +[ + AC_ARG_ENABLE([cds], [AS_HELP_STRING([--enable-cds@<:@=yes/no@:>@], + [enable class data sharing feature in non-minimal VM. Default is yes.])]) + + if test "x$enable_cds" = "x" || test "x$enable_cds" = "xyes"; then + ENABLE_CDS="true" + elif test "x$enable_cds" = "xno"; then + ENABLE_CDS="false" + else + AC_MSG_ERROR([Invalid value for --enable-cds: $enable_cds]) + fi + + AC_SUBST(ENABLE_CDS) +]) + ############################################################################### # Set up all JVM features for each JVM variant. # @@ -378,7 +397,10 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES], fi # All variants but minimal (and custom) get these features - NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti fprof vm-structs jni-check services management all-gcs nmt cds" + NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti fprof vm-structs jni-check services management all-gcs nmt" + if test "x$ENABLE_CDS" = "xtrue"; then + NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES cds" + fi # Enable features depending on variant. JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci $JVM_FEATURES_aot $JVM_FEATURES_graal" diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 index 73e2d74ecd5..2ce5830c2e5 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 @@ -496,11 +496,12 @@ AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST], [ AC_ARG_ENABLE([generate-classlist], [AS_HELP_STRING([--disable-generate-classlist], [forces enabling or disabling of the generation of a CDS classlist at build time. - Default is to generate it when either the server or client JVMs are built.])]) + Default is to generate it when either the server or client JVMs are built and + enable-cds is true.])]) # Check if it's likely that it's possible to generate the classlist. Depending # on exact jvm configuration it could be possible anyway. - if HOTSPOT_CHECK_JVM_VARIANT(server) || HOTSPOT_CHECK_JVM_VARIANT(client); then + if test "x$ENABLE_CDS" = "xtrue" && (HOTSPOT_CHECK_JVM_VARIANT(server) || HOTSPOT_CHECK_JVM_VARIANT(client)); then ENABLE_GENERATE_CLASSLIST_POSSIBLE="true" else ENABLE_GENERATE_CLASSLIST_POSSIBLE="false" @@ -511,7 +512,7 @@ AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST], AC_MSG_RESULT([yes, forced]) ENABLE_GENERATE_CLASSLIST="true" if test "x$ENABLE_GENERATE_CLASSLIST_POSSIBLE" = "xfalse"; then - AC_MSG_WARN([Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS]) + AC_MSG_WARN([Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS and enable-cds=$ENABLE_CDS]) fi elif test "x$enable_generate_classlist" = "xno"; then AC_MSG_RESULT([no, forced]) From 44875d571072123a8b194f565bb6f11af13aca99 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Thu, 31 Aug 2017 15:47:34 -0700 Subject: [PATCH 74/98] 8184435: Cleanup of javadoc in javax.print package Reviewed-by: prr, psadhukhan --- .../javax/print/AttributeException.java | 29 +- .../javax/print/CancelablePrintJob.java | 69 +- .../share/classes/javax/print/Doc.java | 226 ++- .../share/classes/javax/print/DocFlavor.java | 1382 ++++++++--------- .../classes/javax/print/DocPrintJob.java | 178 +-- .../classes/javax/print/FlavorException.java | 21 +- .../share/classes/javax/print/MimeType.java | 218 +-- .../share/classes/javax/print/MultiDoc.java | 121 +- .../classes/javax/print/MultiDocPrintJob.java | 52 +- .../javax/print/MultiDocPrintService.java | 18 +- .../classes/javax/print/PrintException.java | 29 +- .../classes/javax/print/PrintService.java | 585 ++++--- .../javax/print/PrintServiceLookup.java | 368 +++-- .../share/classes/javax/print/ServiceUI.java | 147 +- .../classes/javax/print/ServiceUIFactory.java | 89 +- .../share/classes/javax/print/SimpleDoc.java | 214 +-- .../javax/print/StreamPrintService.java | 90 +- .../print/StreamPrintServiceFactory.java | 176 ++- .../classes/javax/print/URIException.java | 41 +- .../javax/print/attribute/Attribute.java | 51 +- .../javax/print/attribute/AttributeSet.java | 344 ++-- .../attribute/AttributeSetUtilities.java | 384 +++-- .../javax/print/attribute/DateTimeSyntax.java | 91 +- .../javax/print/attribute/DocAttribute.java | 25 +- .../print/attribute/DocAttributeSet.java | 116 +- .../javax/print/attribute/EnumSyntax.java | 173 ++- .../print/attribute/HashAttributeSet.java | 388 ++--- .../print/attribute/HashDocAttributeSet.java | 64 +- .../attribute/HashPrintJobAttributeSet.java | 63 +- .../HashPrintRequestAttributeSet.java | 63 +- .../HashPrintServiceAttributeSet.java | 62 +- .../javax/print/attribute/IntegerSyntax.java | 61 +- .../print/attribute/PrintJobAttribute.java | 19 +- .../print/attribute/PrintJobAttributeSet.java | 114 +- .../attribute/PrintRequestAttribute.java | 25 +- .../attribute/PrintRequestAttributeSet.java | 118 +- .../attribute/PrintServiceAttribute.java | 15 +- .../attribute/PrintServiceAttributeSet.java | 121 +- .../print/attribute/ResolutionSyntax.java | 242 ++- .../print/attribute/SetOfIntegerSyntax.java | 216 ++- .../javax/print/attribute/Size2DSyntax.java | 249 ++- .../attribute/SupportedValuesAttribute.java | 23 +- .../javax/print/attribute/TextSyntax.java | 67 +- .../javax/print/attribute/URISyntax.java | 69 +- .../attribute/UnmodifiableSetException.java | 23 +- .../javax/print/attribute/package-info.java | 200 ++- .../attribute/standard/Chromaticity.java | 114 +- .../attribute/standard/ColorSupported.java | 86 +- .../print/attribute/standard/Compression.java | 66 +- .../print/attribute/standard/Copies.java | 110 +- .../attribute/standard/CopiesSupported.java | 93 +- .../standard/DateTimeAtCompleted.java | 92 +- .../standard/DateTimeAtCreation.java | 92 +- .../standard/DateTimeAtProcessing.java | 88 +- .../print/attribute/standard/Destination.java | 97 +- .../standard/DialogTypeSelection.java | 81 +- .../attribute/standard/DocumentName.java | 95 +- .../print/attribute/standard/Fidelity.java | 77 +- .../print/attribute/standard/Finishings.java | 336 ++-- .../attribute/standard/JobHoldUntil.java | 144 +- .../attribute/standard/JobImpressions.java | 113 +- .../standard/JobImpressionsCompleted.java | 94 +- .../standard/JobImpressionsSupported.java | 98 +- .../print/attribute/standard/JobKOctets.java | 214 ++- .../standard/JobKOctetsProcessed.java | 110 +- .../standard/JobKOctetsSupported.java | 77 +- .../attribute/standard/JobMediaSheets.java | 114 +- .../standard/JobMediaSheetsCompleted.java | 88 +- .../standard/JobMediaSheetsSupported.java | 92 +- .../standard/JobMessageFromOperator.java | 92 +- .../print/attribute/standard/JobName.java | 95 +- .../standard/JobOriginatingUserName.java | 99 +- .../print/attribute/standard/JobPriority.java | 94 +- .../standard/JobPrioritySupported.java | 89 +- .../print/attribute/standard/JobSheets.java | 79 +- .../print/attribute/standard/JobState.java | 171 +- .../attribute/standard/JobStateReason.java | 233 +-- .../attribute/standard/JobStateReasons.java | 138 +- .../javax/print/attribute/standard/Media.java | 79 +- .../print/attribute/standard/MediaName.java | 54 +- .../standard/MediaPrintableArea.java | 284 ++-- .../print/attribute/standard/MediaSize.java | 343 ++-- .../attribute/standard/MediaSizeName.java | 174 ++- .../print/attribute/standard/MediaTray.java | 41 +- .../standard/MultipleDocumentHandling.java | 289 ++-- .../attribute/standard/NumberOfDocuments.java | 69 +- .../standard/NumberOfInterveningJobs.java | 71 +- .../print/attribute/standard/NumberUp.java | 221 ++- .../attribute/standard/NumberUpSupported.java | 123 +- .../standard/OrientationRequested.java | 135 +- .../standard/OutputDeviceAssigned.java | 89 +- .../standard/PDLOverrideSupported.java | 62 +- .../print/attribute/standard/PageRanges.java | 246 ++- .../attribute/standard/PagesPerMinute.java | 80 +- .../standard/PagesPerMinuteColor.java | 85 +- .../standard/PresentationDirection.java | 102 +- .../attribute/standard/PrintQuality.java | 60 +- .../print/attribute/standard/PrinterInfo.java | 88 +- .../standard/PrinterIsAcceptingJobs.java | 69 +- .../attribute/standard/PrinterLocation.java | 82 +- .../standard/PrinterMakeAndModel.java | 81 +- .../standard/PrinterMessageFromOperator.java | 108 +- .../attribute/standard/PrinterMoreInfo.java | 96 +- .../standard/PrinterMoreInfoManufacturer.java | 89 +- .../print/attribute/standard/PrinterName.java | 84 +- .../attribute/standard/PrinterResolution.java | 138 +- .../attribute/standard/PrinterState.java | 62 +- .../standard/PrinterStateReason.java | 185 ++- .../standard/PrinterStateReasons.java | 199 ++- .../print/attribute/standard/PrinterURI.java | 81 +- .../attribute/standard/QueuedJobCount.java | 75 +- .../ReferenceUriSchemesSupported.java | 96 +- .../standard/RequestingUserName.java | 107 +- .../print/attribute/standard/Severity.java | 111 +- .../attribute/standard/SheetCollate.java | 263 ++-- .../javax/print/attribute/standard/Sides.java | 217 ++- .../attribute/standard/package-info.java | 919 +++++------ .../classes/javax/print/event/PrintEvent.java | 20 +- .../javax/print/event/PrintJobAdapter.java | 66 +- .../print/event/PrintJobAttributeEvent.java | 37 +- .../event/PrintJobAttributeListener.java | 24 +- .../javax/print/event/PrintJobEvent.java | 123 +- .../javax/print/event/PrintJobListener.java | 76 +- .../event/PrintServiceAttributeEvent.java | 36 +- .../event/PrintServiceAttributeListener.java | 29 +- .../javax/print/event/package-info.java | 15 +- .../classes/javax/print/package-info.java | 48 +- 127 files changed, 8415 insertions(+), 8916 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/print/AttributeException.java b/jdk/src/java.desktop/share/classes/javax/print/AttributeException.java index 136d3376810..632a745943c 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/AttributeException.java +++ b/jdk/src/java.desktop/share/classes/javax/print/AttributeException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -28,27 +28,22 @@ package javax.print; import javax.print.attribute.Attribute; /** - * Interface AttributeException is a mixin interface which a subclass of - * {@link - * PrintException PrintException} can implement to report an error condition - * involving one or more printing attributes that a particular Print + * Interface {@code AttributeException} is a mixin interface which a subclass of + * {@link PrintException PrintException} can implement to report an error + * condition involving one or more printing attributes that a particular Print * Service instance does not support. Either the attribute is not supported at * all, or the attribute is supported but the particular specified value is not - * supported. The Print Service API does not define any print exception - * classes that implement interface AttributeException, that being left to the + * supported. The Print Service API does not define any print exception classes + * that implement interface {@code AttributeException}, that being left to the * Print Service implementor's discretion. - * */ - public interface AttributeException { - /** * Returns the array of printing attribute classes for which the Print - * Service instance does not support the attribute at all, or null if - * there are no such attributes. The objects in the returned array are - * classes that extend the base interface - * {@link javax.print.attribute.Attribute Attribute}. + * Service instance does not support the attribute at all, or {@code null} + * if there are no such attributes. The objects in the returned array are + * classes that extend the base interface {@link Attribute Attribute}. * * @return unsupported attribute classes */ @@ -57,10 +52,10 @@ public interface AttributeException { /** * Returns the array of printing attributes for which the Print Service * instance supports the attribute but does not support that particular - * value of the attribute, or null if there are no such attribute values. + * value of the attribute, or {@code null} if there are no such attribute + * values. * * @return unsupported attribute values */ public Attribute[] getUnsupportedValues(); - - } +} diff --git a/jdk/src/java.desktop/share/classes/javax/print/CancelablePrintJob.java b/jdk/src/java.desktop/share/classes/javax/print/CancelablePrintJob.java index 49d86823f66..e8c8a9949c1 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/CancelablePrintJob.java +++ b/jdk/src/java.desktop/share/classes/javax/print/CancelablePrintJob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -26,52 +26,47 @@ package javax.print; /** - * This interface is used by a printing application to cancel a - * print job. This interface extends {@link DocPrintJob}. A - * {@code DocPrintJob} implementation returned from a print - * service implements this interface if the print job can be - * cancelled. Before trying to cancel - * a print job, the client needs to test if the - * {@code DocPrintJob} object returned from the print service - * actually implements this interface. Clients should never assume - * that a {@code DocPrintJob} implements this interface. A - * print service might support cancellation only for certain types - * of print data and representation class names. This means that - * only some of the {@code DocPrintJob} objects returned from - * a service will implement this interface. + * This interface is used by a printing application to cancel a print job. This + * interface extends {@link DocPrintJob}. A {@code DocPrintJob} implementation + * returned from a print service implements this interface if the print job can + * be cancelled. Before trying to cancel a print job, the client needs to test + * if the {@code DocPrintJob} object returned from the print service actually + * implements this interface. Clients should never assume that a + * {@code DocPrintJob} implements this interface. A print service might support + * cancellation only for certain types of print data and representation class + * names. This means that only some of the {@code DocPrintJob} objects returned + * from a service will implement this interface. *

- * Service implementors are encouraged to implement this optional interface - * and to deliver a javax.print.event.PrintJobEvent.JOB_CANCELLED event - * to any listeners if a job is successfully cancelled with an - * implementation of this interface. Services should also note that an - * implementation of this method may be made from a separate client thread - * than that which made the print request. Thus the implementation of - * this interface must be made thread safe. + * Service implementors are encouraged to implement this optional interface and + * to deliver a {@link javax.print.event.PrintJobEvent#JOB_CANCELED} event to + * any listeners if a job is successfully cancelled with an implementation of + * this interface. Services should also note that an implementation of this + * method may be made from a separate client thread than that which made the + * print request. Thus the implementation of this interface must be made thread + * safe. */ - public interface CancelablePrintJob extends DocPrintJob { /** * Stops further processing of a print job. *

- * If a service supports this method it cannot be concluded that - * job cancellation will always succeed. A job may not be able to be - * cancelled once it has reached and passed some point in its processing. - * A successful cancellation means only that the entire job was not - * printed, some portion may already have printed when cancel returns. + * If a service supports this method it cannot be concluded that job + * cancellation will always succeed. A job may not be able to be cancelled + * once it has reached and passed some point in its processing. A successful + * cancellation means only that the entire job was not printed, some portion + * may already have printed when cancel returns. *

- * The service will throw a PrintException if the cancellation did not - * succeed. A job which has not yet been submitted for printing should - * throw this exception. - * Cancelling an already successfully cancelled Print Job is not - * considered an error and will always succeed. + * The service will throw a {@code PrintException} if the cancellation did + * not succeed. A job which has not yet been submitted for printing should + * throw this exception. Cancelling an already successfully cancelled Print + * Job is not considered an error and will always succeed. *

* Cancellation in some services may be a lengthy process, involving - * requests to a server and processing of its print queue. Clients - * may wish to execute cancel in a thread which does not affect - * application execution. - * @throws PrintException if the job could not be successfully cancelled. + * requests to a server and processing of its print queue. Clients may wish + * to execute cancel in a thread which does not affect application + * execution. + * + * @throws PrintException if the job could not be successfully cancelled */ public void cancel() throws PrintException; - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/Doc.java b/jdk/src/java.desktop/share/classes/javax/print/Doc.java index 2b6084fcb30..e920e947d61 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/Doc.java +++ b/jdk/src/java.desktop/share/classes/javax/print/Doc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -25,181 +25,165 @@ package javax.print; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.io.Reader; import javax.print.attribute.DocAttributeSet; - /** - * Interface Doc specifies the interface for an object that supplies one piece - * of print data for a Print Job. "Doc" is a short, easy-to-pronounce term + * Interface {@code Doc} specifies the interface for an object that supplies one + * piece of print data for a Print Job. "Doc" is a short, easy-to-pronounce term * that means "a piece of print data." The client passes to the Print Job an - * object that implements interface Doc, and the Print Job calls methods on - * that object to obtain the print data. The Doc interface lets a Print Job: - *

    - *
  • - * Determine the format, or "doc flavor" (class {@link DocFlavor DocFlavor}), - * in which the print data is available. A doc flavor designates the print - * data format (a MIME type) and the representation class of the object - * from which the print data comes. - * - *
  • - * Obtain the print data representation object, which is an instance of the - * doc flavor's representation class. The Print Job can then obtain the actual - * print data from the representation object. - * - *
  • - * Obtain the printing attributes that specify additional characteristics of - * the doc or that specify processing instructions to be applied to the doc. - * Printing attributes are defined in package {@link javax.print.attribute - * javax.print.attribute}. The doc returns its printing attributes stored in - * an {@link javax.print.attribute.DocAttributeSet javax.print.attribute.DocAttributeSet}. - *
- *

- * Each method in an implementation of interface Doc is permitted always to - * return the same object each time the method is called. - * This has implications - * for a Print Job or other caller of a doc object whose print data + * object that implements interface {@code Doc}, and the Print Job calls methods + * on that object to obtain the print data. The {@code Doc} interface lets a + * Print Job: + *

    + *
  • Determine the format, or "doc flavor" (class + * {@link DocFlavor DocFlavor}), in which the print data is available. A doc + * flavor designates the print data format (a MIME type) and the + * representation class of the object from which the print data comes. + *
  • Obtain the print data representation object, which is an instance of + * the doc flavor's representation class. The Print Job can then obtain the + * actual print data from the representation object. + *
  • Obtain the printing attributes that specify additional characteristics + * of the doc or that specify processing instructions to be applied to the + * doc. Printing attributes are defined in package + * {@link javax.print.attribute}. The doc returns its printing attributes + * stored in an {@link DocAttributeSet javax.print.attribute.DocAttributeSet}. + *
+ * Each method in an implementation of interface {@code Doc} is permitted always + * to return the same object each time the method is called. This has + * implications for a Print Job or other caller of a doc object whose print data * representation object "consumes" the print data as the caller obtains the * print data, such as a print data representation object which is a stream. - * Once the Print Job has called {@link #getPrintData() - * getPrintData()} and obtained the stream, any further calls to - * {@link #getPrintData() getPrintData()} will return the same - * stream object upon which reading may already be in progress, not a new - * stream object that will re-read the print data from the beginning. Specifying - * a doc object to behave this way simplifies the implementation of doc objects, - * and is justified on the grounds that a particular doc is intended to convey - * print data only to one Print Job, not to several different Print Jobs. (To - * convey the same print data to several different Print Jobs, you have to - * create several different doc objects on top of the same print data source.) - *

- * Interface Doc affords considerable implementation flexibility. The print data - * might already be in existence when the doc object is constructed. In this - * case the objects returned by the doc's methods can be supplied to the doc's - * constructor, be stored in the doc ahead of time, and simply be returned when - * called for. Alternatively, the print data might not exist yet when the doc - * object is constructed. In this case the doc object might provide a "lazy" + * Once the Print Job has called {@link #getPrintData() getPrintData()} and + * obtained the stream, any further calls to {@link #getPrintData() + * getPrintData()} will return the same stream object upon which reading may + * already be in progress, not a new stream object that will re-read the + * print data from the beginning. Specifying a doc object to behave this way + * simplifies the implementation of doc objects, and is justified on the grounds + * that a particular doc is intended to convey print data only to one Print Job, + * not to several different Print Jobs. (To convey the same print data to + * several different Print Jobs, you have to create several different doc + * objects on top of the same print data source.) + *

+ * Interface {@code Doc} affords considerable implementation flexibility. The + * print data might already be in existence when the doc object is constructed. + * In this case the objects returned by the doc's methods can be supplied to the + * doc's constructor, be stored in the doc ahead of time, and simply be returned + * when called for. Alternatively, the print data might not exist yet when the + * doc object is constructed. In this case the doc object might provide a "lazy" * implementation that generates the print data representation object (and/or * the print data) only when the Print Job calls for it (when the Print Job * calls the {@link #getPrintData() getPrintData()} method). - *

+ *

* There is no restriction on the number of client threads that may be * simultaneously accessing the same doc. Therefore, all implementations of - * interface Doc must be designed to be multiple thread safe. + * interface {@code Doc} must be designed to be multiple thread safe. *

* However there can only be one consumer of the print data obtained from a - * Doc. + * {@code Doc}. *

- * If print data is obtained from the client as a stream, by calling Doc's - * {@code getReaderForText()} or {@code getStreamForBytes()} - * methods, or because the print data source is already an InputStream or - * Reader, then the print service should always close these streams for the - * client on all job completion conditions. With the following caveat. - * If the print data is itself a stream, the service will always close it. - * If the print data is otherwise something that can be requested as a stream, - * the service will only close the stream if it has obtained the stream before - * terminating. That is, just because a print service might request data as - * a stream does not mean that it will, with the implications that Doc + * If print data is obtained from the client as a stream, by calling + * {@code Doc}'s {@code getReaderForText()} or {@code getStreamForBytes()} + * methods, or because the print data source is already an {@code InputStream} + * or {@code Reader}, then the print service should always close these streams + * for the client on all job completion conditions. With the following caveat. + * If the print data is itself a stream, the service will always close it. If + * the print data is otherwise something that can be requested as a stream, the + * service will only close the stream if it has obtained the stream before + * terminating. That is, just because a print service might request data as a + * stream does not mean that it will, with the implications that {@code Doc} * implementors which rely on the service to close them should create such * streams only in response to a request from the service. - *


*/ public interface Doc { /** - * Determines the doc flavor in which this doc object will supply its - * piece of print data. + * Determines the doc flavor in which this doc object will supply its piece + * of print data. * - * @return Doc flavor. + * @return doc flavor */ public DocFlavor getDocFlavor(); /** * Obtains the print data representation object that contains this doc - * object's piece of print data in the format corresponding to the - * supported doc flavor. - * The {@code getPrintData()} method returns an instance of - * the representation class whose name is given by {@link - * #getDocFlavor() getDocFlavor()}.{@link - * DocFlavor#getRepresentationClassName() - * getRepresentationClassName()}, and the return value can be cast - * from class Object to that representation class. + * object's piece of print data in the format corresponding to the supported + * doc flavor. The {@code getPrintData()} method returns an instance of the + * representation class whose name is given by{@link #getDocFlavor() + * getDocFlavor()}.{@link DocFlavor#getRepresentationClassName() + * getRepresentationClassName()}, and the return value can be cast from + * class {@code Object} to that representation class. * - * @return Print data representation object. - * - * @exception IOException - * Thrown if the representation class is a stream and there was an I/O - * error while constructing the stream. + * @return print data representation object + * @throws IOException if the representation class is a stream and there was + * an I/O error while constructing the stream */ public Object getPrintData() throws IOException; /** * Obtains the set of printing attributes for this doc object. If the * returned attribute set includes an instance of a particular attribute - * X, the printer must use that attribute value for this doc, - * overriding any value of attribute X in the job's attribute set. - * If the returned attribute set does not include an instance - * of a particular attribute X or if null is returned, the printer - * must consult the job's attribute set to obtain the value for - * attribute X, and if not found there, the printer must use an + * X, the printer must use that attribute value for this doc, + * overriding any value of attribute X in the job's attribute set. If + * the returned attribute set does not include an instance of a particular + * attribute X or if {@code null} is returned, the printer must + * consult the job's attribute set to obtain the value for attribute + * X, and if not found there, the printer must use an * implementation-dependent default value. The returned attribute set is * unmodifiable. * - * @return Unmodifiable set of printing attributes for this doc, or null - * to obtain all attribute values from the job's attribute - * set. + * @return unmodifiable set of printing attributes for this doc, or + * {@code null} to obtain all attribute values from the job's + * attribute set */ public DocAttributeSet getAttributes(); /** - * Obtains a reader for extracting character print data from this doc. - * The Doc implementation is required to support this method if the - * DocFlavor has one of the following print data representation classes, - * and return null otherwise: - *
    - *
  • char[] - *
  • java.lang.String - *
  • java.io.Reader - *
+ * Obtains a reader for extracting character print data from this doc. The + * {@code Doc} implementation is required to support this method if the + * {@code DocFlavor} has one of the following print data representation + * classes, and return {@code null} otherwise: + *
    + *
  • char[] + *
  • java.lang.String + *
  • java.io.Reader + *
* The doc's print data representation object is used to construct and - * return a Reader for reading the print data as a stream of characters - * from the print data representation object. - * However, if the print data representation object is itself a Reader, - * then the print data representation object is simply returned. + * return a {@code Reader} for reading the print data as a stream of + * characters from the print data representation object. However, if the + * print data representation object is itself a {@code Reader}, then the + * print data representation object is simply returned. * - * @return Reader for reading the print data characters from this doc. - * If a reader cannot be provided because this doc does not meet - * the criteria stated above, null is returned. - * - * @exception IOException - * Thrown if there was an I/O error while creating the reader. + * @return reader for reading the print data characters from this doc. If a + * reader cannot be provided because this doc does not meet the + * criteria stated above, {@code null} is returned. + * @throws IOException if there was an I/O error while creating the reader */ public Reader getReaderForText() throws IOException; /** - * Obtains an input stream for extracting byte print data from this - * doc. The Doc implementation is required to support this method if - * the DocFlavor has one of the following print data representation - * classes, and return null otherwise: - *
    - *
  • byte[] - *
  • java.io.InputStream - *
+ * Obtains an input stream for extracting byte print data from this doc. The + * {@code Doc} implementation is required to support this method if the + * {@code DocFlavor} has one of the following print data representation + * classes, and return {@code null} otherwise: + *
    + *
  • byte[] + *
  • java.io.InputStream + *
* This doc's print data representation object is obtained, then an input * stream for reading the print data from the print data representation * object as a stream of bytes is created and returned. However, if the * print data representation object is itself an input stream, then the * print data representation object is simply returned. * - * @return Input stream for reading the print data bytes from this doc. If - * an input stream cannot be provided because this doc does not - * meet the criteria stated above, null is returned. - * - * @exception IOException - * Thrown if there was an I/O error while creating the input stream. + * @return input stream for reading the print data bytes from this doc. If + * an input stream cannot be provided because this doc does not meet + * the criteria stated above, {@code null} is returned. + * @throws IOException if there was an I/O error while creating the input + * stream */ public InputStream getStreamForBytes() throws IOException; - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/DocFlavor.java b/jdk/src/java.desktop/share/classes/javax/print/DocFlavor.java index e97a48f6b18..5c48cf29011 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/DocFlavor.java +++ b/jdk/src/java.desktop/share/classes/javax/print/DocFlavor.java @@ -30,447 +30,376 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; - /** - * Class {@code DocFlavor} encapsulates an object that specifies the - * format in which print data is supplied to a {@link DocPrintJob}. - * "Doc" is a short, easy-to-pronounce term that means "a piece of print data." - * The print data format, or "doc flavor", consists of two things: - *
    - *
  • - * MIME type. This is a Multipurpose Internet Mail Extensions (MIME) - * media type (as defined in RFC - * 2045 and RFC 2046) - * that specifies how the print data is to be interpreted. - * The charset of text data should be the IANA MIME-preferred name, or its - * canonical name if no preferred name is specified. Additionally a few - * historical names supported by earlier versions of the Java platform may - * be recognized. - * See - * character encodings for more information on the character encodings - * supported on the Java platform. - * - *
  • - * Representation class name. This specifies the fully-qualified name of - * the class of the object from which the actual print data comes, as returned - * by the {@link java.lang.Class#getName() Class.getName()} method. - * (Thus the class name for {@code byte[]} is {@code "[B"}, for - * {@code char[]} it is {@code "[C"}.) - *
- *

+ * Class {@code DocFlavor} encapsulates an object that specifies the format in + * which print data is supplied to a {@link DocPrintJob}. "Doc" is a short, + * easy-to-pronounce term that means "a piece of print data." The print data + * format, or "doc flavor", consists of two things: + *

    + *
  • MIME type. This is a Multipurpose Internet Mail Extensions + * (MIME) media type (as defined in + * RFC 2045 and + * RFC 2046) that specifies + * how the print data is to be interpreted. The charset of text data should be + * the IANA MIME-preferred name, or its canonical name if no preferred name is + * specified. Additionally a few historical names supported by earlier + * versions of the Java platform may be recognized. See + * character encodings + * for more information on the character encodings supported on the Java + * platform. + *
  • Representation class name. This specifies the fully-qualified + * name of the class of the object from which the actual print data comes, as + * returned by the {@link Class#getName() Class.getName()} method. (Thus the + * class name for {@code byte[]} is {@code "[B"}, for {@code char[]} it is + * {@code "[C"}.) + *
* A {@code DocPrintJob} obtains its print data by means of interface - * {@link Doc Doc}. A {@code Doc} object lets the {@code DocPrintJob} - * determine the doc flavor the client can supply. A {@code Doc} object - * also lets the {@code DocPrintJob} obtain an instance of the doc flavor's - * representation class, from which the {@code DocPrintJob} then obtains - * the actual print data. + * {@link Doc Doc}. A {@code Doc} object lets the {@code DocPrintJob} determine + * the doc flavor the client can supply. A {@code Doc} object also lets the + * {@code DocPrintJob} obtain an instance of the doc flavor's representation + * class, from which the {@code DocPrintJob} then obtains the actual print data. * - *
- *

Client Formatted Print Data

- * There are two broad categories of print data, client formatted print data - * and service formatted print data. - *

- * For client formatted print data, the client determines or knows the - * print data format. - * For example the client may have a JPEG encoded image, a URL for - * HTML code, or a disk file containing plain text in some encoding, - * possibly obtained from an external source, and - * requires a way to describe the data format to the print service. + *


+ *

Client Formatted Print Data

+ * There are two broad categories of print data, client formatted print data and + * service formatted print data. + *

+ * For client formatted print data, the client determines or knows the + * print data format. For example the client may have a JPEG encoded image, a + * {@code URL} for HTML code, or a disk file containing plain text in some + * encoding, possibly obtained from an external source, and requires a way to + * describe the data format to the print service. *

* The doc flavor's representation class is a conduit for the JPS - * {@code DocPrintJob} to obtain a sequence of characters or - * bytes from the client. The - * doc flavor's MIME type is one of the standard media types telling how to - * interpret the sequence of characters or bytes. For a list of standard media - * types, see the Internet Assigned Numbers Authority's (IANA's) Media Types - * Directory. Interface {@link Doc Doc} provides two utility operations, + * {@code DocPrintJob} to obtain a sequence of characters or bytes from the + * client. The doc flavor's MIME type is one of the standard media types telling + * how to interpret the sequence of characters or bytes. For a list of standard + * media types, see the Internet Assigned Numbers Authority's (IANA's) + * Media Types Directory + * . Interface {@link Doc Doc} provides two utility operations, * {@link Doc#getReaderForText() getReaderForText} and - * {@link Doc#getStreamForBytes() getStreamForBytes()}, to help a - * {@code Doc} object's client extract client formatted print data. - *

+ * {@link Doc#getStreamForBytes() getStreamForBytes()}, to help a {@code Doc} + * object's client extract client formatted print data. + *

* For client formatted print data, the print data representation class is * typically one of the following (although other representation classes are * permitted): - *

    - *
  • - * Character array ({@code char[]}) -- The print data consists of the - * Unicode characters in the array. + *
      + *
    • Character array ({@code char[]}) -- The print data consists of the + * Unicode characters in the array. + *
    • {@code String} -- The print data consists of the Unicode characters in + * the string. + *
    • Character stream ({@link java.io.Reader java.io.Reader}) -- The print + * data consists of the Unicode characters read from the stream up to the + * end-of-stream. + *
    • Byte array ({@code byte[]}) -- The print data consists of the bytes in + * the array. The bytes are encoded in the character set specified by the doc + * flavor's MIME type. If the MIME type does not specify a character set, the + * default character set is US-ASCII. + *
    • Byte stream ({@link java.io.InputStream java.io.InputStream}) -- The + * print data consists of the bytes read from the stream up to the + * end-of-stream. The bytes are encoded in the character set specified by the + * doc flavor's MIME type. If the MIME type does not specify a character set, + * the default character set is US-ASCII. + *
    • Uniform Resource Locator ({@link java.net.URL URL}) -- The print data + * consists of the bytes read from the URL location. The bytes are encoded in + * the character set specified by the doc flavor's MIME type. If the MIME type + * does not specify a character set, the default character set is US-ASCII. + * When the representation class is a {@code URL}, the print service itself + * accesses and downloads the document directly from its {@code URL} address, + * without involving the client. The service may be some form of network print + * service which is executing in a different environment. This means you + * should not use a {@code URL} print data flavor to print a document at a + * restricted {@code URL} that the client can see but the printer cannot see. + * This also means you should not use a {@code URL} print data flavor to print + * a document stored in a local file that is not available at a {@code URL} + * accessible independently of the client. For example, a file that is not + * served up by an HTTP server or FTP server. To print such documents, let the + * client open an input stream on the {@code URL} or file and use an input + * stream data flavor. + *
    * - *
  • - * {@code String} -- - * The print data consists of the Unicode characters in the string. - * - *
  • - * Character stream ({@link java.io.Reader java.io.Reader}) - * -- The print data consists of the Unicode characters read from the stream - * up to the end-of-stream. - * - *
  • - * Byte array ({@code byte[]}) -- The print data consists of the bytes in - * the array. The bytes are encoded in the character set specified by the doc - * flavor's MIME type. If the MIME type does not specify a character set, the - * default character set is US-ASCII. - * - *
  • - * Byte stream ({@link java.io.InputStream java.io.InputStream}) -- - * The print data consists of the bytes read from the stream up to the - * end-of-stream. The bytes are encoded in the character set specified by the - * doc flavor's MIME type. If the MIME type does not specify a character set, - * the default character set is US-ASCII. - - *
  • - * Uniform Resource Locator ({@link java.net.URL URL}) - * -- The print data consists of the bytes read from the URL location. - * The bytes are encoded in the character set specified by the doc flavor's - * MIME type. If the MIME type does not specify a character set, the default - * character set is US-ASCII. - *

    - * When the representation class is a URL, the print service itself accesses - * and downloads the document directly from its URL address, without involving - * the client. The service may be some form of network print service which - * is executing in a different environment. - * This means you should not use a URL print data flavor to print a - * document at a restricted URL that the client can see but the printer cannot - * see. This also means you should not use a URL print data flavor to print a - * document stored in a local file that is not available at a URL - * accessible independently of the client. - * For example, a file that is not served up by an HTTP server or FTP server. - * To print such documents, let the client open an input stream on the URL - * or file and use an input stream data flavor. - *

- * - *
+ *
*

Default and Platform Encodings

- *

* For byte print data where the doc flavor's MIME type does not include a * {@code charset} parameter, the Java Print Service instance assumes the * US-ASCII character set by default. This is in accordance with - * RFC 2046, which says the - * default character set is US-ASCII. Note that US-ASCII is a subset of - * UTF-8, so in the future this may be widened if a future RFC endorses - * UTF-8 as the default in a compatible manner. + * RFC 2046, which says the + * default character set is US-ASCII. Note that US-ASCII is a subset of UTF-8, + * so in the future this may be widened if a future RFC endorses UTF-8 as the + * default in a compatible manner. *

- * Also note that this is different than the behaviour of the Java runtime - * when interpreting a stream of bytes as text data. That assumes the - * default encoding for the user's locale. Thus, when spooling a file in local - * encoding to a Java Print Service it is important to correctly specify - * the encoding. Developers working in the English locales should - * be particularly conscious of this, as their platform encoding corresponds - * to the default mime charset. By this coincidence that particular - * case may work without specifying the encoding of platform data. + * Also note that this is different than the behaviour of the Java runtime when + * interpreting a stream of bytes as text data. That assumes the default + * encoding for the user's locale. Thus, when spooling a file in local encoding + * to a Java Print Service it is important to correctly specify the encoding. + * Developers working in the English locales should be particularly conscious of + * this, as their platform encoding corresponds to the default mime charset. By + * this coincidence that particular case may work without specifying the + * encoding of platform data. *

* Every instance of the Java virtual machine has a default character encoding * determined during virtual-machine startup and typically depends upon the - * locale and charset being used by the underlying operating system. - * In a distributed environment there is no guarantee that two VM share - * the same default encoding. Thus clients which want to stream platform - * encoded text data from the host platform to a Java Print Service instance - * must explicitly declare the charset and not rely on defaults. + * locale and charset being used by the underlying operating system. In a + * distributed environment there is no guarantee that two VM share the same + * default encoding. Thus clients which want to stream platform encoded text + * data from the host platform to a Java Print Service instance must explicitly + * declare the charset and not rely on defaults. *

* The preferred form is the official IANA primary name for an encoding. - * Applications which stream text data should always specify the charset - * in the mime type, which necessitates obtaining the encoding of the host - * platform for data (eg files) stored in that platform's encoding. - * A CharSet which corresponds to this and is suitable for use in a - * mime-type for a DocFlavor can be obtained - * from {@link DocFlavor#hostEncoding DocFlavor.hostEncoding} - * This may not always be the primary IANA name but is guaranteed to be - * understood by this VM. - * For common flavors, the pre-defined *HOST DocFlavors may be used. + * Applications which stream text data should always specify the charset in the + * mime type, which necessitates obtaining the encoding of the host platform for + * data (eg files) stored in that platform's encoding. A {@code CharSet} which + * corresponds to this and is suitable for use in a mime-type for a + * {@code DocFlavor} can be obtained from + * {@link DocFlavor#hostEncoding DocFlavor.hostEncoding} This may not always be + * the primary IANA name but is guaranteed to be understood by this VM. For + * common flavors, the pre-defined *HOST {@code DocFlavors} may be used. *

- * See - * character encodings for more information on the character encodings - * supported on the Java platform. - *


+ * See character + * encodings for more information on the character encodings supported on + * the Java platform. + * + *
*

Recommended DocFlavors

- *

* The Java Print Service API does not define any mandatorily supported - * DocFlavors. - * However, here are some examples of MIME types that a Java Print Service - * instance might support for client formatted print data. - * Nested classes inside class DocFlavor declare predefined static - * constant DocFlavor objects for these example doc flavors; class DocFlavor's - * constructor can be used to create an arbitrary doc flavor. - *

    - *
  • Preformatted text - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    MIME-Types and their descriptions
    MIME-TypeDescription
    {@code "text/plain"}Plain text in the default character set (US-ASCII)
    "text/plain; charset=xxx"Plain text in character set xxx
    {@code "text/html"}HyperText Markup Language in the default character set (US-ASCII)
    "text/html; charset=xxx"HyperText Markup Language in character set xxx
    - *

    - * In general, preformatted text print data is provided either in a character - * oriented representation class (character array, String, Reader) or in a - * byte oriented representation class (byte array, InputStream, URL). + * {@code DocFlavors}. However, here are some examples of MIME types that a Java + * Print Service instance might support for client formatted print data. Nested + * classes inside class {@code DocFlavor} declare predefined static constant + * {@code DocFlavor} objects for these example doc flavors; class + * {@code DocFlavor}'s constructor can be used to create an arbitrary doc + * flavor. + *

      + *
    • Preformatted text + * + * + * + * + * + * + * + * + * + * + * + *
      MIME-Types and their descriptions
      MIME-Type + * Description + *
      {@code "text/plain"} + * Plain text in the default character set (US-ASCII) + *
      "text/plain; charset=xxx" + * Plain text in character set xxx + *
      {@code "text/html"} + * HyperText Markup Language in the default character set (US-ASCII) + *
      "text/html; charset=xxx" + * HyperText Markup Language in character set xxx + *
      + * In general, preformatted text print data is provided either in a character + * oriented representation class (character array, String, Reader) or in a + * byte oriented representation class (byte array, InputStream, URL). + *
    • Preformatted page description language (PDL) documents + * + * + * + * + * + * + * + * + * + * + *
      MIME-Types and their descriptions
      MIME-Type + * Description + *
      {@code "application/pdf"} + * Portable Document Format document + *
      {@code "application/postscript"} + * PostScript document + *
      {@code "application/vnd.hp-PCL"} + * Printer Control Language document + *
      + * In general, preformatted PDL print data is provided in a byte oriented + * representation class (byte array, {@code InputStream}, {@code URL}). + *
    • Preformatted images + * + * + * + * + * + * + * + * + * + * + *
      MIME-Types and their descriptions
      MIME-Type + * Description + *
      {@code "image/gif"} + * Graphics Interchange Format image + *
      {@code "image/jpeg"} + * Joint Photographic Experts Group image + *
      {@code "image/png"} + * Portable Network Graphics image + *
      + * In general, preformatted image print data is provided in a byte oriented + * representation class (byte array, {@code InputStream}, {@code URL}). + *
    • Preformatted autosense print data + * + * + * + * + * + * + * + * + *
      MIME-Types and their descriptions
      MIME-Type + * Description + *
      {@code "application/octet-stream"} + * The print data format is unspecified (just an octet stream) + *
      + * The printer decides how to interpret the print data; the way this + * "autosensing" works is implementation dependent. In general, preformatted + * autosense print data is provided in a byte oriented representation class + * (byte array, {@code InputStream}, {@code URL}). + *
    * - *
  • Preformatted page description language (PDL) documents - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    MIME-Types and their descriptions
    MIME-TypeDescription
    {@code "application/pdf"}Portable Document Format document
    {@code "application/postscript"}PostScript document
    {@code "application/vnd.hp-PCL"}Printer Control Language document
    - *

    - * In general, preformatted PDL print data is provided in a byte oriented - * representation class (byte array, InputStream, URL). - * - *

  • Preformatted images - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    MIME-Types and their descriptions
    MIME-TypeDescription
    {@code "image/gif"}Graphics Interchange Format image
    {@code "image/jpeg"}Joint Photographic Experts Group image
    {@code "image/png"}Portable Network Graphics image
    - *

    - * In general, preformatted image print data is provided in a byte oriented - * representation class (byte array, InputStream, URL). - * - *

  • Preformatted autosense print data - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    MIME-Types and their descriptions
    MIME-TypeDescription
    {@code "application/octet-stream"}The print data format is unspecified (just an octet stream)
    - *

    - * The printer decides how to interpret the print data; the way this - * "autosensing" works is implementation dependent. In general, preformatted - * autosense print data is provided in a byte oriented representation class - * (byte array, InputStream, URL). - *

- * - *
- *

Service Formatted Print Data

- *

- * For service formatted print data, the Java Print Service instance + *


+ *

Service Formatted Print Data

+ * For service formatted print data, the Java Print Service instance * determines the print data format. The doc flavor's representation class * denotes an interface whose methods the {@code DocPrintJob} invokes to - * determine the content to be printed -- such as a renderable image - * interface or a Java printable interface. - * The doc flavor's MIME type is the special value - * {@code "application/x-java-jvm-local-objectref"} indicating the client - * will supply a reference to a Java object that implements the interface - * named as the representation class. - * This MIME type is just a placeholder; what's + * determine the content to be printed -- such as a renderable image interface + * or a Java printable interface. The doc flavor's MIME type is the special + * value {@code "application/x-java-jvm-local-objectref"} indicating the client + * will supply a reference to a Java object that implements the interface named + * as the representation class. This MIME type is just a placeholder; what's * important is the print data representation class. - *

+ *

* For service formatted print data, the print data representation class is * typically one of the following (although other representation classes are - * permitted). Nested classes inside class DocFlavor declare predefined static - * constant DocFlavor objects for these example doc flavors; class DocFlavor's - * constructor can be used to create an arbitrary doc flavor. - *

    - *
  • - * Renderable image object -- The client supplies an object that implements - * interface - * {@link java.awt.image.renderable.RenderableImage RenderableImage}. The - * printer calls methods - * in that interface to obtain the image to be printed. + * permitted). Nested classes inside class {@code DocFlavor} declare predefined + * static constant {@code DocFlavor} objects for these example doc flavors; + * class {@code DocFlavor}'s constructor can be used to create an arbitrary doc + * flavor. + *
      + *
    • Renderable image object -- The client supplies an object that + * implements interface + * {@link java.awt.image.renderable.RenderableImage RenderableImage}. The + * printer calls methods in that interface to obtain the image to be printed. + *
    • Printable object -- The client supplies an object that implements + * interface {@link java.awt.print.Printable Printable}. The printer calls + * methods in that interface to obtain the pages to be printed, one by one. + * For each page, the printer supplies a graphics context, and whatever the + * client draws in that graphics context gets printed. + *
    • Pageable object -- The client supplies an object that implements + * interface {@link java.awt.print.Pageable Pageable}. The printer calls + * methods in that interface to obtain the pages to be printed, one by one. + * For each page, the printer supplies a graphics context, and whatever the + * client draws in that graphics context gets printed. + *
    * - *
  • - * Printable object -- The client supplies an object that implements interface - * {@link java.awt.print.Printable Printable}. - * The printer calls methods in that interface to obtain the pages to be - * printed, one by one. - * For each page, the printer supplies a graphics context, and whatever the - * client draws in that graphics context gets printed. - * - *
  • - * Pageable object -- The client supplies an object that implements interface - * {@link java.awt.print.Pageable Pageable}. The printer calls - * methods in that interface to obtain the pages to be printed, one by one. - * For each page, the printer supplies a graphics context, and whatever - * the client draws in that graphics context gets printed. - *
- * - *
- * - *
- *

Pre-defined Doc Flavors

- * A Java Print Service instance is not required to support the - * following print data formats and print data representation classes. In - * fact, a developer using this class should never assume that a - * particular print service supports the document types corresponding to - * these pre-defined doc flavors. Always query the print service - * to determine what doc flavors it supports. However, - * developers who have print services that support these doc flavors are - * encouraged to refer to the predefined singleton instances created here. - *
    - *
  • - * Plain text print data provided through a byte stream. Specifically, the - * following doc flavors are recommended to be supported: - *
    ·   - * {@code ("text/plain", "java.io.InputStream")} - *
    ·   - * {@code ("text/plain; charset=us-ascii", "java.io.InputStream")} - *
    ·   - * {@code ("text/plain; charset=utf-8", "java.io.InputStream")} - * - *
  • - * Renderable image objects. Specifically, the following doc flavor is - * recommended to be supported: - *
    ·   - * {@code ("application/x-java-jvm-local-objectref", "java.awt.image.renderable.RenderableImage")} - *
- *

- * A Java Print Service instance is allowed to support any other doc flavors - * (or none) in addition to the above mandatory ones, at the implementation's + *


+ *

Pre-defined Doc Flavors

+ * A Java Print Service instance is not required to support the + * following print data formats and print data representation classes. In fact, + * a developer using this class should never assume that a particular + * print service supports the document types corresponding to these pre-defined + * doc flavors. Always query the print service to determine what doc flavors it + * supports. However, developers who have print services that support these doc + * flavors are encouraged to refer to the predefined singleton instances created + * here. + *
    + *
  • Plain text print data provided through a byte stream. Specifically, the + * following doc flavors are recommended to be supported: + *
    ·   + * {@code ("text/plain", "java.io.InputStream")} + *
    ·   + * {@code ("text/plain; charset=us-ascii", "java.io.InputStream")} + *
    ·   + * {@code ("text/plain; charset=utf-8", "java.io.InputStream")} + *
  • Renderable image objects. Specifically, the following doc flavor is + * recommended to be supported: + *
    ·   + * {@code ("application/x-java-jvm-local-objectref", "java.awt.image.renderable.RenderableImage")} + *
+ * A Java Print Service instance is allowed to support any other doc flavors (or + * none) in addition to the above mandatory ones, at the implementation's * choice. - *

+ *

* Support for the above doc flavors is desirable so a printing client can rely * on being able to print on any JPS printer, regardless of which doc flavors * the printer supports. If the printer doesn't support the client's preferred * doc flavor, the client can at least print plain text, or the client can * convert its data to a renderable image and print the image. - *

+ *

* Furthermore, every Java Print Service instance must fulfill these * requirements for processing plain text print data: - *

    - *
  • - * The character pair carriage return-line feed (CR-LF) means - * "go to column 1 of the next line." - *
  • - * A carriage return (CR) character standing by itself means - * "go to column 1 of the next line." - *
  • - * A line feed (LF) character standing by itself means - * "go to column 1 of the next line." - *
- *

+ *

    + *
  • The character pair carriage return-line feed (CR-LF) means "go to + * column 1 of the next line." + *
  • A carriage return (CR) character standing by itself means "go to column + * 1 of the next line." + *
  • A line feed (LF) character standing by itself means "go to column 1 of + * the next line." + *
* The client must itself perform all plain text print data formatting not * addressed by the above requirements. * - *

Design Rationale

- *

- * Class DocFlavor in package javax.print.data is similar to class - * {@link java.awt.datatransfer.DataFlavor DataFlavor}. Class - * {@code DataFlavor} - * is not used in the Java Print Service (JPS) API - * for three reasons which are all rooted in allowing the JPS API to be - * shared by other print services APIs which may need to run on Java profiles - * which do not include all of the Java Platform, Standard Edition. - *

    - *
  1. - * The JPS API is designed to be used in Java profiles which do not support - * AWT. - * - *
  2. - * The implementation of class {@code java.awt.datatransfer.DataFlavor} - * does not guarantee that equivalent data flavors will have the same - * serialized representation. DocFlavor does, and can be used in services - * which need this. - * - *
  3. - * The implementation of class {@code java.awt.datatransfer.DataFlavor} - * includes a human presentable name as part of the serialized representation. - * This is not appropriate as part of a service matching constraint. - *
- *

- * Class DocFlavor's serialized representation uses the following + *

Design Rationale

+ * Class {@code DocFlavor} in package {@code javax.print} is similar to class + * {@link java.awt.datatransfer.DataFlavor}. Class {@code DataFlavor} is not + * used in the Java Print Service (JPS) API for three reasons which are all + * rooted in allowing the JPS API to be shared by other print services APIs + * which may need to run on Java profiles which do not include all of the Java + * Platform, Standard Edition. + *
    + *
  1. The JPS API is designed to be used in Java profiles which do not + * support AWT. + *
  2. The implementation of class {@code java.awt.datatransfer.DataFlavor} + * does not guarantee that equivalent data flavors will have the same + * serialized representation. {@code DocFlavor} does, and can be used in + * services which need this. + *
  3. The implementation of class {@code java.awt.datatransfer.DataFlavor} + * includes a human presentable name as part of the serialized representation. + * This is not appropriate as part of a service matching constraint. + *
+ * Class {@code DocFlavor}'s serialized representation uses the following * canonical form of a MIME type string. Thus, two doc flavors with MIME types - * that are not identical but that are equivalent (that have the same - * canonical form) may be considered equal. - *
    - *
  • The media type, media subtype, and parameters are retained, but all - * comments and whitespace characters are discarded. - *
  • The media type, media subtype, and parameter names are converted to - * lowercase. - *
  • The parameter values retain their original case, except a charset - * parameter value for a text media type is converted to lowercase. - *
  • Quote characters surrounding parameter values are removed. - *
  • Quoting backslash characters inside parameter values are removed. - *
  • The parameters are arranged in ascending order of parameter name. - *
- *

- * Class DocFlavor's serialized representation also contains the - * fully-qualified class name of the representation class - * (a String object), rather than the representation class itself - * (a Class object). This allows a client to examine the doc flavors a - * Java Print Service instance supports without having - * to load the representation classes, which may be problematic for - * limited-resource clients. + * that are not identical but that are equivalent (that have the same canonical + * form) may be considered equal. + *

    + *
  • The media type, media subtype, and parameters are retained, but all + * comments and whitespace characters are discarded. + *
  • The media type, media subtype, and parameter names are converted to + * lowercase. + *
  • The parameter values retain their original case, except a charset + * parameter value for a text media type is converted to lowercase. + *
  • Quote characters surrounding parameter values are removed. + *
  • Quoting backslash characters inside parameter values are removed. + *
  • The parameters are arranged in ascending order of parameter name. + *
+ * Class {@code DocFlavor}'s serialized representation also contains the + * fully-qualified class name of the representation class (a + * {@code String} object), rather than the representation class itself (a + * {@code Class} object). This allows a client to examine the doc flavors a Java + * Print Service instance supports without having to load the representation + * classes, which may be problematic for limited-resource clients. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public class DocFlavor implements Serializable, Cloneable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -4512080796965449721L; /** - * A String representing the host operating system encoding. - * This will follow the conventions documented in + * A string representing the host operating system encoding. This will + * follow the conventions documented in * * RFC 2278: IANA Charset Registration Procedures * except where historical names are returned for compatibility with - * previous versions of the Java platform. - * The value returned from method is valid only for the VM which - * returns it, for use in a DocFlavor. - * This is the charset for all the "HOST" pre-defined DocFlavors in + * previous versions of the Java platform. The value returned from method is + * valid only for the VM which returns it, for use in a {@code DocFlavor}. + * This is the charset for all the "HOST" pre-defined {@code DocFlavors} in * the executing VM. */ public static final String hostEncoding; @@ -488,6 +417,7 @@ public class DocFlavor implements Serializable, Cloneable { /** * Representation class name. + * * @serial */ private String myClassName; @@ -497,21 +427,17 @@ public class DocFlavor implements Serializable, Cloneable { */ private transient String myStringValue = null; - /** * Constructs a new doc flavor object from the given MIME type and * representation class name. The given MIME type is converted into * canonical form and stored internally. * - * @param mimeType MIME media type string. - * @param className Fully-qualified representation class name. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code mimeType} is null or - * {@code className} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code mimeType} does not - * obey the syntax for a MIME media type string. + * @param mimeType MIME media type string + * @param className fully-qualified representation class name + * @throws NullPointerException if {@code mimeType} or {@code className} is + * {@code null} + * @throws IllegalArgumentException if {@code mimeType} does not obey the + * syntax for a MIME media type string */ public DocFlavor(String mimeType, String className) { if (className == null) { @@ -522,8 +448,9 @@ public class DocFlavor implements Serializable, Cloneable { } /** - * Returns this doc flavor object's MIME type string based on the - * canonical form. Each parameter value is enclosed in quotes. + * Returns this doc flavor object's MIME type string based on the canonical + * form. Each parameter value is enclosed in quotes. + * * @return the mime type */ public String getMimeType() { @@ -532,6 +459,7 @@ public class DocFlavor implements Serializable, Cloneable { /** * Returns this doc flavor object's media type (from the MIME type). + * * @return the media type */ public String getMediaType() { @@ -540,6 +468,7 @@ public class DocFlavor implements Serializable, Cloneable { /** * Returns this doc flavor object's media subtype (from the MIME type). + * * @return the media sub-type */ public String getMediaSubtype() { @@ -547,19 +476,18 @@ public class DocFlavor implements Serializable, Cloneable { } /** - * Returns a {@code String} representing a MIME - * parameter. - * Mime types may include parameters which are usually optional. - * The charset for text types is a commonly useful example. - * This convenience method will return the value of the specified - * parameter if one was specified in the mime type for this flavor. + * Returns a {@code String} representing a MIME parameter. Mime types may + * include parameters which are usually optional. The charset for text types + * is a commonly useful example. This convenience method will return the + * value of the specified parameter if one was specified in the mime type + * for this flavor. * - * @param paramName the name of the paramater. This name is internally - * converted to the canonical lower case format before performing - * the match. - * @return String representing a mime parameter, or - * null if that parameter is not in the mime type string. - * @exception NullPointerException if paramName is null. + * @param paramName the name of the parameter. This name is internally + * converted to the canonical lower case format before performing + * the match. + * @return a string representing a mime parameter, or {@code null} if that + * parameter is not in the mime type string + * @throws NullPointerException if paramName is {@code null} */ public String getParameter(String paramName) { return myMimeType.getParameterMap().get(paramName.toLowerCase()); @@ -567,7 +495,8 @@ public class DocFlavor implements Serializable, Cloneable { /** * Returns the name of this doc flavor object's representation class. - * @return the name of the representation class. + * + * @return the name of the representation class */ public String getRepresentationClassName() { return myClassName; @@ -576,10 +505,9 @@ public class DocFlavor implements Serializable, Cloneable { /** * Converts this {@code DocFlavor} to a string. * - * @return MIME type string based on the canonical form. Each parameter - * value is enclosed in quotes. - * A "class=" parameter is appended to the - * MIME type string to indicate the representation class name. + * @return MIME type string based on the canonical form. Each parameter + * value is enclosed in quotes. A "class=" parameter is appended to + * the MIME type string to indicate the representation class name. */ public String toString() { return getStringValue(); @@ -593,22 +521,21 @@ public class DocFlavor implements Serializable, Cloneable { } /** - * Determines if this doc flavor object is equal to the given object. - * The two are equal if the given object is not null, is an instance - * of {@code DocFlavor}, has a MIME type equivalent to this doc - * flavor object's MIME type (that is, the MIME types have the same media - * type, media subtype, and parameters), and has the same representation - * class name as this doc flavor object. Thus, if two doc flavor objects' - * MIME types are the same except for comments, they are considered equal. - * However, two doc flavor objects with MIME types of "text/plain" and - * "text/plain; charset=US-ASCII" are not considered equal, even though - * they represent the same media type (because the default character - * set for plain text is US-ASCII). + * Determines if this doc flavor object is equal to the given object. The + * two are equal if the given object is not {@code null}, is an instance of + * {@code DocFlavor}, has a MIME type equivalent to this doc flavor object's + * MIME type (that is, the MIME types have the same media type, media + * subtype, and parameters), and has the same representation class name as + * this doc flavor object. Thus, if two doc flavor objects' MIME types are + * the same except for comments, they are considered equal. However, two doc + * flavor objects with MIME types of "text/plain" and "text/plain; + * charset=US-ASCII" are not considered equal, even though they represent + * the same media type (because the default character set for plain text is + * US-ASCII). * - * @param obj Object to test. - * - * @return True if this doc flavor object equals {@code obj}, false - * otherwise. + * @param obj {@code Object} to test + * @return {@code true} if this doc flavor object equals {@code obj}, + * {@code false} otherwise */ public boolean equals(Object obj) { return @@ -619,6 +546,8 @@ public class DocFlavor implements Serializable, Cloneable { /** * Returns this doc flavor object's string value. + * + * @return the string value */ private String getStringValue() { if (myStringValue == null) { @@ -630,8 +559,9 @@ public class DocFlavor implements Serializable, Cloneable { /** * Write the instance to a stream (ie serialize the object). * + * @param s the output stream * @throws IOException if I/O errors occur while writing to the underlying - * stream + * stream */ private void writeObject(ObjectOutputStream s) throws IOException { @@ -642,14 +572,15 @@ public class DocFlavor implements Serializable, Cloneable { /** * Reconstitute an instance from a stream (that is, deserialize it). * + * @param s the input stream * @throws ClassNotFoundException if the class of a serialized object could - * not be found. + * not be found * @throws IOException if I/O errors occur while reading from the underlying - * stream - * @serialData - * The serialised form of a DocFlavor is the String naming the - * representation class followed by the String representing the canonical - * form of the mime type. + * stream + * @serialData The serialised form of a {@code DocFlavor} is the + * {@code String} naming the representation class followed by + * the {@code String} representing the canonical form of the + * mime type */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { @@ -659,167 +590,140 @@ public class DocFlavor implements Serializable, Cloneable { } /** - * Class DocFlavor.BYTE_ARRAY provides predefined static constant - * DocFlavor objects for example doc flavors using a byte array + * Class {@code DocFlavor.BYTE_ARRAY} provides predefined static constant + * {@code DocFlavor} objects for example doc flavors using a byte array * ({@code byte[]}) as the print data representation class. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public static class BYTE_ARRAY extends DocFlavor { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -9065578006593857475L; /** - * Constructs a new doc flavor with the given MIME type and a print - * data representation class name of {@code "[B"} (byte array). + * Constructs a new doc flavor with the given MIME type and a print data + * representation class name of {@code "[B"} (byte array). * - * @param mimeType MIME media type string. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code mimeType} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code mimeType} does not - * obey the syntax for a MIME media type string. + * @param mimeType MIME media type string + * @throws NullPointerException if {@code mimeType} is {@code null} + * @throws IllegalArgumentException if {@code mimeType} does not obey + * the syntax for a MIME media type string */ public BYTE_ARRAY (String mimeType) { super (mimeType, "[B"); } /** - * Doc flavor with MIME type = {@code "text/plain"}, - * encoded in the host platform encoding. - * See {@link DocFlavor#hostEncoding hostEncoding} - * Print data representation class name = - * {@code "[B"} (byte array). + * Doc flavor with MIME type = {@code "text/plain"}, encoded in the host + * platform encoding. See {@link DocFlavor#hostEncoding hostEncoding}. + * Print data representation class name = {@code "[B"} (byte array). */ public static final BYTE_ARRAY TEXT_PLAIN_HOST = new BYTE_ARRAY ("text/plain; charset="+hostEncoding); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=utf-8"}, - * print data representation class name = {@code "[B"} (byte - * array). + * Doc flavor with MIME type = {@code "text/plain; charset=utf-8"}, + * print data representation class name = {@code "[B"} (byte array). */ public static final BYTE_ARRAY TEXT_PLAIN_UTF_8 = new BYTE_ARRAY ("text/plain; charset=utf-8"); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=utf-16"}, - * print data representation class name = {@code "[B"} (byte - * array). + * Doc flavor with MIME type = {@code "text/plain; charset=utf-16"}, + * print data representation class name = {@code "[B"} (byte array). */ public static final BYTE_ARRAY TEXT_PLAIN_UTF_16 = new BYTE_ARRAY ("text/plain; charset=utf-16"); - /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=utf-16be"} - * (big-endian byte ordering), - * print data representation class name = {@code "[B"} (byte - * array). + * Doc flavor with MIME type = {@code "text/plain; charset=utf-16be"} + * (big-endian byte ordering), print data representation class name = + * {@code "[B"} (byte array). */ public static final BYTE_ARRAY TEXT_PLAIN_UTF_16BE = new BYTE_ARRAY ("text/plain; charset=utf-16be"); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=utf-16le"} - * (little-endian byte ordering), - * print data representation class name = {@code "[B"} (byte - * array). + * Doc flavor with MIME type = {@code "text/plain; charset=utf-16le"} + * (little-endian byte ordering), print data representation class name = + * {@code "[B"} (byte array). */ public static final BYTE_ARRAY TEXT_PLAIN_UTF_16LE = new BYTE_ARRAY ("text/plain; charset=utf-16le"); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=us-ascii"}, - * print data representation class name = - * {@code "[B"} (byte array). + * Doc flavor with MIME type = {@code "text/plain; charset=us-ascii"}, + * print data representation class name = {@code "[B"} (byte array). */ public static final BYTE_ARRAY TEXT_PLAIN_US_ASCII = new BYTE_ARRAY ("text/plain; charset=us-ascii"); /** - * Doc flavor with MIME type = {@code "text/html"}, - * encoded in the host platform encoding. - * See {@link DocFlavor#hostEncoding hostEncoding} - * Print data representation class name = - * {@code "[B"} (byte array). + * Doc flavor with MIME type = {@code "text/html"}, encoded in the host + * platform encoding. See {@link DocFlavor#hostEncoding hostEncoding}. + * Print data representation class name = {@code "[B"} (byte array). */ public static final BYTE_ARRAY TEXT_HTML_HOST = new BYTE_ARRAY ("text/html; charset="+hostEncoding); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=utf-8"}, - * print data representation class name = {@code "[B"} (byte - * array). + * Doc flavor with MIME type = {@code "text/html; charset=utf-8"}, print + * data representation class name = {@code "[B"} (byte array). */ public static final BYTE_ARRAY TEXT_HTML_UTF_8 = new BYTE_ARRAY ("text/html; charset=utf-8"); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=utf-16"}, - * print data representation class name = {@code "[B"} (byte - * array). + * Doc flavor with MIME type = {@code "text/html; charset=utf-16"}, + * print data representation class name = {@code "[B"} (byte array). */ public static final BYTE_ARRAY TEXT_HTML_UTF_16 = new BYTE_ARRAY ("text/html; charset=utf-16"); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=utf-16be"} - * (big-endian byte ordering), - * print data representation class name = {@code "[B"} (byte - * array). + * Doc flavor with MIME type = {@code "text/html; charset=utf-16be"} + * (big-endian byte ordering), print data representation class name = + * {@code "[B"} (byte array). */ public static final BYTE_ARRAY TEXT_HTML_UTF_16BE = new BYTE_ARRAY ("text/html; charset=utf-16be"); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=utf-16le"} - * (little-endian byte ordering), - * print data representation class name = {@code "[B"} (byte - * array). + * Doc flavor with MIME type = {@code "text/html; charset=utf-16le"} + * (little-endian byte ordering), print data representation class name = + * {@code "[B"} (byte array). */ public static final BYTE_ARRAY TEXT_HTML_UTF_16LE = new BYTE_ARRAY ("text/html; charset=utf-16le"); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=us-ascii"}, - * print data representation class name = - * {@code "[B"} (byte array). + * Doc flavor with MIME type = {@code "text/html; charset=us-ascii"}, + * print data representation class name = {@code "[B"} (byte array). */ public static final BYTE_ARRAY TEXT_HTML_US_ASCII = new BYTE_ARRAY ("text/html; charset=us-ascii"); /** - * Doc flavor with MIME type = {@code "application/pdf"}, print - * data representation class name = {@code "[B"} (byte array). + * Doc flavor with MIME type = {@code "application/pdf"}, print data + * representation class name = {@code "[B"} (byte array). */ public static final BYTE_ARRAY PDF = new BYTE_ARRAY ("application/pdf"); /** - * Doc flavor with MIME type = {@code "application/postscript"}, - * print data representation class name = {@code "[B"} (byte - * array). + * Doc flavor with MIME type = {@code "application/postscript"}, print + * data representation class name = {@code "[B"} (byte array). */ public static final BYTE_ARRAY POSTSCRIPT = new BYTE_ARRAY ("application/postscript"); /** - * Doc flavor with MIME type = {@code "application/vnd.hp-PCL"}, - * print data representation class name = {@code "[B"} (byte - * array). + * Doc flavor with MIME type = {@code "application/vnd.hp-PCL"}, print + * data representation class name = {@code "[B"} (byte array). */ public static final BYTE_ARRAY PCL = new BYTE_ARRAY ("application/vnd.hp-PCL"); @@ -843,376 +747,337 @@ public class DocFlavor implements Serializable, Cloneable { public static final BYTE_ARRAY PNG = new BYTE_ARRAY ("image/png"); /** - * Doc flavor with MIME type = - * {@code "application/octet-stream"}, - * print data representation class name = {@code "[B"} (byte - * array). The client must determine that data described - * using this DocFlavor is valid for the printer. + * Doc flavor with MIME type = {@code "application/octet-stream"}, print + * data representation class name = {@code "[B"} (byte array). The + * client must determine that data described using this + * {@code DocFlavor} is valid for the printer. */ public static final BYTE_ARRAY AUTOSENSE = new BYTE_ARRAY ("application/octet-stream"); - } /** - * Class DocFlavor.INPUT_STREAM provides predefined static constant - * DocFlavor objects for example doc flavors using a byte stream ({@link - * java.io.InputStream java.io.InputStream}) as the print - * data representation class. + * Class {@code DocFlavor.INPUT_STREAM} provides predefined static constant + * {@code DocFlavor} objects for example doc flavors using a byte stream + * ({@link java.io.InputStream java.io.InputStream}) as the print data + * representation class. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public static class INPUT_STREAM extends DocFlavor { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -7045842700749194127L; /** - * Constructs a new doc flavor with the given MIME type and a print - * data representation class name of - * {@code "java.io.InputStream"} (byte stream). + * Constructs a new doc flavor with the given MIME type and a print data + * representation class name of {@code "java.io.InputStream"} (byte + * stream). * - * @param mimeType MIME media type string. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code mimeType} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code mimeType} does not - * obey the syntax for a MIME media type string. + * @param mimeType MIME media type string + * @throws NullPointerException if {@code mimeType} is {@code null} + * @throws IllegalArgumentException if {@code mimeType} does not obey + * the syntax for a MIME media type string. */ public INPUT_STREAM (String mimeType) { super (mimeType, "java.io.InputStream"); } /** - * Doc flavor with MIME type = {@code "text/plain"}, - * encoded in the host platform encoding. - * See {@link DocFlavor#hostEncoding hostEncoding} - * Print data representation class name = - * {@code "java.io.InputStream"} (byte stream). + * Doc flavor with MIME type = {@code "text/plain"}, encoded in the host + * platform encoding. See {@link DocFlavor#hostEncoding hostEncoding}. + * Print data representation class name = {@code "java.io.InputStream"} + * (byte stream). */ public static final INPUT_STREAM TEXT_PLAIN_HOST = new INPUT_STREAM ("text/plain; charset="+hostEncoding); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=utf-8"}, - * print data representation class name = - * {@code "java.io.InputStream"} (byte stream). + * Doc flavor with MIME type = {@code "text/plain; charset=utf-8"}, + * print data representation class name = {@code "java.io.InputStream"} + * (byte stream). */ public static final INPUT_STREAM TEXT_PLAIN_UTF_8 = new INPUT_STREAM ("text/plain; charset=utf-8"); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=utf-16"}, - * print data representation class name = - * {@code "java.io.InputStream"} (byte stream). + * Doc flavor with MIME type = {@code "text/plain; charset=utf-16"}, + * print data representation class name = {@code "java.io.InputStream"} + * (byte stream). */ public static final INPUT_STREAM TEXT_PLAIN_UTF_16 = new INPUT_STREAM ("text/plain; charset=utf-16"); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=utf-16be"} - * (big-endian byte ordering), - * print data representation class name = + * Doc flavor with MIME type = {@code "text/plain; charset=utf-16be"} + * (big-endian byte ordering), print data representation class name = * {@code "java.io.InputStream"} (byte stream). */ public static final INPUT_STREAM TEXT_PLAIN_UTF_16BE = new INPUT_STREAM ("text/plain; charset=utf-16be"); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=utf-16le"} - * (little-endian byte ordering), - * print data representation class name = + * Doc flavor with MIME type = {@code "text/plain; charset=utf-16le"} + * (little-endian byte ordering), print data representation class name = * {@code "java.io.InputStream"} (byte stream). */ public static final INPUT_STREAM TEXT_PLAIN_UTF_16LE = new INPUT_STREAM ("text/plain; charset=utf-16le"); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=us-ascii"}, - * print data representation class name = - * {@code "java.io.InputStream"} (byte stream). + * Doc flavor with MIME type = {@code "text/plain; charset=us-ascii"}, + * print data representation class name = {@code "java.io.InputStream"} + * (byte stream). */ public static final INPUT_STREAM TEXT_PLAIN_US_ASCII = new INPUT_STREAM ("text/plain; charset=us-ascii"); /** - * Doc flavor with MIME type = {@code "text/html"}, - * encoded in the host platform encoding. - * See {@link DocFlavor#hostEncoding hostEncoding} - * Print data representation class name = - * {@code "java.io.InputStream"} (byte stream). + * Doc flavor with MIME type = {@code "text/html"}, encoded in the host + * platform encoding. See {@link DocFlavor#hostEncoding hostEncoding}. + * Print data representation class name = {@code "java.io.InputStream"} + * (byte stream). */ public static final INPUT_STREAM TEXT_HTML_HOST = new INPUT_STREAM ("text/html; charset="+hostEncoding); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=utf-8"}, - * print data representation class name = - * {@code "java.io.InputStream"} (byte stream). + * Doc flavor with MIME type = {@code "text/html; charset=utf-8"}, print + * data representation class name = {@code "java.io.InputStream"} (byte + * stream). */ public static final INPUT_STREAM TEXT_HTML_UTF_8 = new INPUT_STREAM ("text/html; charset=utf-8"); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=utf-16"}, - * print data representation class name = - * {@code "java.io.InputStream"} (byte stream). + * Doc flavor with MIME type = {@code "text/html; charset=utf-16"}, + * print data representation class name = {@code "java.io.InputStream"} + * (byte stream). */ public static final INPUT_STREAM TEXT_HTML_UTF_16 = new INPUT_STREAM ("text/html; charset=utf-16"); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=utf-16be"} - * (big-endian byte ordering), - * print data representation class name = + * Doc flavor with MIME type = {@code "text/html; charset=utf-16be"} + * (big-endian byte ordering), print data representation class name = * {@code "java.io.InputStream"} (byte stream). */ public static final INPUT_STREAM TEXT_HTML_UTF_16BE = new INPUT_STREAM ("text/html; charset=utf-16be"); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=utf-16le"} - * (little-endian byte ordering), - * print data representation class name = + * Doc flavor with MIME type = {@code "text/html; charset=utf-16le"} + * (little-endian byte ordering), print data representation class name = * {@code "java.io.InputStream"} (byte stream). */ public static final INPUT_STREAM TEXT_HTML_UTF_16LE = new INPUT_STREAM ("text/html; charset=utf-16le"); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=us-ascii"}, - * print data representation class name = - * {@code "java.io.InputStream"} (byte stream). + * Doc flavor with MIME type = {@code "text/html; charset=us-ascii"}, + * print data representation class name = {@code "java.io.InputStream"} + * (byte stream). */ public static final INPUT_STREAM TEXT_HTML_US_ASCII = new INPUT_STREAM ("text/html; charset=us-ascii"); - /** - * Doc flavor with MIME type = {@code "application/pdf"}, print - * data representation class name = {@code "java.io.InputStream"} - * (byte stream). + * Doc flavor with MIME type = {@code "application/pdf"}, print data + * representation class name = {@code "java.io.InputStream"} (byte + * stream). */ public static final INPUT_STREAM PDF = new INPUT_STREAM ("application/pdf"); /** - * Doc flavor with MIME type = {@code "application/postscript"}, - * print data representation class name = - * {@code "java.io.InputStream"} (byte stream). + * Doc flavor with MIME type = {@code "application/postscript"}, print + * data representation class name = {@code "java.io.InputStream"} (byte + * stream). */ public static final INPUT_STREAM POSTSCRIPT = new INPUT_STREAM ("application/postscript"); /** - * Doc flavor with MIME type = {@code "application/vnd.hp-PCL"}, - * print data representation class name = - * {@code "java.io.InputStream"} (byte stream). + * Doc flavor with MIME type = {@code "application/vnd.hp-PCL"}, print + * data representation class name = {@code "java.io.InputStream"} (byte + * stream). */ public static final INPUT_STREAM PCL = new INPUT_STREAM ("application/vnd.hp-PCL"); /** * Doc flavor with MIME type = {@code "image/gif"}, print data - * representation class name = - * {@code "java.io.InputStream"} (byte stream). + * representation class name = {@code "java.io.InputStream"} (byte + * stream). */ public static final INPUT_STREAM GIF = new INPUT_STREAM ("image/gif"); /** * Doc flavor with MIME type = {@code "image/jpeg"}, print data - * representation class name = - * {@code "java.io.InputStream"} (byte stream). + * representation class name = {@code "java.io.InputStream"} (byte + * stream). */ public static final INPUT_STREAM JPEG = new INPUT_STREAM ("image/jpeg"); /** * Doc flavor with MIME type = {@code "image/png"}, print data - * representation class name = - * {@code "java.io.InputStream"} (byte stream). + * representation class name = {@code "java.io.InputStream"} (byte + * stream). */ public static final INPUT_STREAM PNG = new INPUT_STREAM ("image/png"); /** - * Doc flavor with MIME type = - * {@code "application/octet-stream"}, - * print data representation class name = - * {@code "java.io.InputStream"} (byte stream). - * The client must determine that data described - * using this DocFlavor is valid for the printer. + * Doc flavor with MIME type = {@code "application/octet-stream"}, print + * data representation class name = {@code "java.io.InputStream"} (byte + * stream). The client must determine that data described using this + * {@code DocFlavor} is valid for the printer. */ public static final INPUT_STREAM AUTOSENSE = new INPUT_STREAM ("application/octet-stream"); - } /** - * Class DocFlavor.URL provides predefined static constant DocFlavor - * objects. - * For example doc flavors using a Uniform Resource Locator ({@link - * java.net.URL java.net.URL}) as the print data + * Class {@code DocFlavor.URL} provides predefined static constant + * {@code DocFlavor} objects. For example doc flavors using a Uniform + * Resource Locator ({@link java.net.URL java.net.URL}) as the print data * representation class. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public static class URL extends DocFlavor { + + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 2936725788144902062L; /** - * Constructs a new doc flavor with the given MIME type and a print - * data representation class name of {@code "java.net.URL"}. + * Constructs a new doc flavor with the given MIME type and a print data + * representation class name of {@code "java.net.URL"}. * - * @param mimeType MIME media type string. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code mimeType} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code mimeType} does not - * obey the syntax for a MIME media type string. + * @param mimeType MIME media type string + * @throws NullPointerException if {@code mimeType} is {@code null} + * @throws IllegalArgumentException if {@code mimeType} does not obey + * the syntax for a MIME media type string */ public URL (String mimeType) { super (mimeType, "java.net.URL"); } /** - * Doc flavor with MIME type = {@code "text/plain"}, - * encoded in the host platform encoding. - * See {@link DocFlavor#hostEncoding hostEncoding} - * Print data representation class name = - * {@code "java.net.URL"} (byte stream). + * Doc flavor with MIME type = {@code "text/plain"}, encoded in the host + * platform encoding. See {@link DocFlavor#hostEncoding hostEncoding}. + * Print data representation class name = {@code "java.net.URL"} (byte + * stream). */ public static final URL TEXT_PLAIN_HOST = new URL ("text/plain; charset="+hostEncoding); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=utf-8"}, - * print data representation class name = - * {@code "java.net.URL"} (byte stream). + * Doc flavor with MIME type = {@code "text/plain; charset=utf-8"}, + * print data representation class name = {@code "java.net.URL"} (byte + * stream). */ public static final URL TEXT_PLAIN_UTF_8 = new URL ("text/plain; charset=utf-8"); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=utf-16"}, - * print data representation class name = - * {@code java.net.URL""} (byte stream). + * Doc flavor with MIME type = {@code "text/plain; charset=utf-16"}, + * print data representation class name = {@code java.net.URL""} (byte + * stream). */ public static final URL TEXT_PLAIN_UTF_16 = new URL ("text/plain; charset=utf-16"); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=utf-16be"} - * (big-endian byte ordering), - * print data representation class name = + * Doc flavor with MIME type = {@code "text/plain; charset=utf-16be"} + * (big-endian byte ordering), print data representation class name = * {@code "java.net.URL"} (byte stream). */ public static final URL TEXT_PLAIN_UTF_16BE = new URL ("text/plain; charset=utf-16be"); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=utf-16le"} - * (little-endian byte ordering), - * print data representation class name = + * Doc flavor with MIME type = {@code "text/plain; charset=utf-16le"} + * (little-endian byte ordering), print data representation class name = * {@code "java.net.URL"} (byte stream). */ public static final URL TEXT_PLAIN_UTF_16LE = new URL ("text/plain; charset=utf-16le"); /** - * Doc flavor with MIME type = - * {@code "text/plain; charset=us-ascii"}, - * print data representation class name = - * {@code "java.net.URL"} (byte stream). + * Doc flavor with MIME type = {@code "text/plain; charset=us-ascii"}, + * print data representation class name = {@code "java.net.URL"} (byte + * stream). */ public static final URL TEXT_PLAIN_US_ASCII = new URL ("text/plain; charset=us-ascii"); /** - * Doc flavor with MIME type = {@code "text/html"}, - * encoded in the host platform encoding. - * See {@link DocFlavor#hostEncoding hostEncoding} - * Print data representation class name = - * {@code "java.net.URL"} (byte stream). + * Doc flavor with MIME type = {@code "text/html"}, encoded in the host + * platform encoding. See {@link DocFlavor#hostEncoding hostEncoding}. + * Print data representation class name = {@code "java.net.URL"} (byte + * stream). */ public static final URL TEXT_HTML_HOST = new URL ("text/html; charset="+hostEncoding); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=utf-8"}, - * print data representation class name = - * {@code "java.net.URL"} (byte stream). + * Doc flavor with MIME type = {@code "text/html; charset=utf-8"}, print + * data representation class name = {@code "java.net.URL"} (byte + * stream). */ public static final URL TEXT_HTML_UTF_8 = new URL ("text/html; charset=utf-8"); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=utf-16"}, - * print data representation class name = - * {@code "java.net.URL"} (byte stream). + * Doc flavor with MIME type = {@code "text/html; charset=utf-16"}, + * print data representation class name = {@code "java.net.URL"} (byte + * stream). */ public static final URL TEXT_HTML_UTF_16 = new URL ("text/html; charset=utf-16"); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=utf-16be"} - * (big-endian byte ordering), - * print data representation class name = + * Doc flavor with MIME type = {@code "text/html; charset=utf-16be"} + * (big-endian byte ordering), print data representation class name = * {@code "java.net.URL"} (byte stream). */ public static final URL TEXT_HTML_UTF_16BE = new URL ("text/html; charset=utf-16be"); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=utf-16le"} - * (little-endian byte ordering), - * print data representation class name = + * Doc flavor with MIME type = {@code "text/html; charset=utf-16le"} + * (little-endian byte ordering), print data representation class name = * {@code "java.net.URL"} (byte stream). */ public static final URL TEXT_HTML_UTF_16LE = new URL ("text/html; charset=utf-16le"); /** - * Doc flavor with MIME type = - * {@code "text/html; charset=us-ascii"}, - * print data representation class name = - * {@code "java.net.URL"} (byte stream). + * Doc flavor with MIME type = {@code "text/html; charset=us-ascii"}, + * print data representation class name = {@code "java.net.URL"} (byte + * stream). */ public static final URL TEXT_HTML_US_ASCII = new URL ("text/html; charset=us-ascii"); - /** - * Doc flavor with MIME type = {@code "application/pdf"}, print - * data representation class name = {@code "java.net.URL"}. + * Doc flavor with MIME type = {@code "application/pdf"}, print data + * representation class name = {@code "java.net.URL"}. */ public static final URL PDF = new URL ("application/pdf"); /** - * Doc flavor with MIME type = {@code "application/postscript"}, - * print data representation class name = {@code "java.net.URL"}. + * Doc flavor with MIME type = {@code "application/postscript"}, print + * data representation class name = {@code "java.net.URL"}. */ public static final URL POSTSCRIPT = new URL ("application/postscript"); /** - * Doc flavor with MIME type = {@code "application/vnd.hp-PCL"}, - * print data representation class name = {@code "java.net.URL"}. + * Doc flavor with MIME type = {@code "application/vnd.hp-PCL"}, print + * data representation class name = {@code "java.net.URL"}. */ public static final URL PCL = new URL ("application/vnd.hp-PCL"); @@ -1235,42 +1100,39 @@ public class DocFlavor implements Serializable, Cloneable { public static final URL PNG = new URL ("image/png"); /** - * Doc flavor with MIME type = - * {@code "application/octet-stream"}, - * print data representation class name = {@code "java.net.URL"}. - * The client must determine that data described - * using this DocFlavor is valid for the printer. + * Doc flavor with MIME type = {@code "application/octet-stream"}, print + * data representation class name = {@code "java.net.URL"}. The client + * must determine that data described using this {@code DocFlavor} is + * valid for the printer. */ public static final URL AUTOSENSE = new URL ("application/octet-stream"); - } /** - * Class DocFlavor.CHAR_ARRAY provides predefined static constant - * DocFlavor objects for example doc flavors using a character array - * ({@code char[]}) as the print data representation class. As such, - * the character set is Unicode. + * Class {@code DocFlavor.CHAR_ARRAY} provides predefined static constant + * {@code DocFlavor} objects for example doc flavors using a character array + * ({@code char[]}) as the print data representation class. As such, the + * character set is Unicode. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public static class CHAR_ARRAY extends DocFlavor { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -8720590903724405128L; /** - * Constructs a new doc flavor with the given MIME type and a print - * data representation class name of - * {@code "[C"} (character array). + * Constructs a new doc flavor with the given MIME type and a print data + * representation class name of {@code "[C"} (character array). * - * @param mimeType MIME media type string. If it is a text media - * type, it is assumed to contain a - * {@code "charset=utf-16"} parameter. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code mimeType} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code mimeType} does not - * obey the syntax for a MIME media type string. + * @param mimeType MIME media type string. If it is a text media type, + * it is assumed to contain a {@code "charset=utf-16"} + * parameter. + * @throws NullPointerException if {@code mimeType} is {@code null} + * @throws IllegalArgumentException if {@code mimeType} does not obey + * the syntax for a MIME media type string */ public CHAR_ARRAY (String mimeType) { super (mimeType, "[C"); @@ -1278,47 +1140,46 @@ public class DocFlavor implements Serializable, Cloneable { /** * Doc flavor with MIME type = {@code "text/plain; charset=utf-16"}, - * print data representation class name = - * {@code "[C"} (character array). + * print data representation class name = {@code "[C"} (character + * array). */ public static final CHAR_ARRAY TEXT_PLAIN = new CHAR_ARRAY ("text/plain; charset=utf-16"); /** * Doc flavor with MIME type = {@code "text/html; charset=utf-16"}, - * print data representation class name = - * {@code "[C"} (character array). + * print data representation class name = {@code "[C"} (character + * array). */ public static final CHAR_ARRAY TEXT_HTML = new CHAR_ARRAY ("text/html; charset=utf-16"); - } /** - * Class DocFlavor.STRING provides predefined static constant DocFlavor - * objects for example doc flavors using a string ({@link java.lang.String - * java.lang.String}) as the print data representation class. + * Class {@code DocFlavor.STRING} provides predefined static constant + * {@code DocFlavor} objects for example doc flavors using a string + * ({@link String java.lang.String}) as the print data representation class. * As such, the character set is Unicode. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public static class STRING extends DocFlavor { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 4414407504887034035L; /** - * Constructs a new doc flavor with the given MIME type and a print - * data representation class name of {@code "java.lang.String"}. + * Constructs a new doc flavor with the given MIME type and a print data + * representation class name of {@code "java.lang.String"}. * - * @param mimeType MIME media type string. If it is a text media - * type, it is assumed to contain a - * {@code "charset=utf-16"} parameter. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code mimeType} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code mimeType} does not - * obey the syntax for a MIME media type string. + * @param mimeType MIME media type string. If it is a text media type, + * it is assumed to contain a {@code "charset=utf-16"} + * parameter. + * @throws NullPointerException if {@code mimeType} is {@code null} + * @throws IllegalArgumentException if {@code mimeType} does not obey + * the syntax for a MIME media type string */ public STRING (String mimeType) { super (mimeType, "java.lang.String"); @@ -1326,47 +1187,45 @@ public class DocFlavor implements Serializable, Cloneable { /** * Doc flavor with MIME type = {@code "text/plain; charset=utf-16"}, - * print data representation class name = - * {@code "java.lang.String"}. + * print data representation class name = {@code "java.lang.String"}. */ public static final STRING TEXT_PLAIN = new STRING ("text/plain; charset=utf-16"); /** * Doc flavor with MIME type = {@code "text/html; charset=utf-16"}, - * print data representation class name = - * {@code "java.lang.String"}. + * print data representation class name = {@code "java.lang.String"}. */ public static final STRING TEXT_HTML = new STRING ("text/html; charset=utf-16"); } /** - * Class DocFlavor.READER provides predefined static constant DocFlavor - * objects for example doc flavors using a character stream ({@link - * java.io.Reader java.io.Reader}) as the print data + * Class {@code DocFlavor.READER} provides predefined static constant + * {@code DocFlavor} objects for example doc flavors using a character + * stream ({@link java.io.Reader java.io.Reader}) as the print data * representation class. As such, the character set is Unicode. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public static class READER extends DocFlavor { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 7100295812579351567L; /** - * Constructs a new doc flavor with the given MIME type and a print - * data representation class name of\ - * {@code "java.io.Reader"} (character stream). + * Constructs a new doc flavor with the given MIME type and a print data + * representation class name of {@code "java.io.Reader"} (character + * stream). * - * @param mimeType MIME media type string. If it is a text media - * type, it is assumed to contain a - * {@code "charset=utf-16"} parameter. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code mimeType} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code mimeType} does not - * obey the syntax for a MIME media type string. + * @param mimeType MIME media type string. If it is a text media type, + * it is assumed to contain a {@code "charset=utf-16"} + * parameter. + * @throws NullPointerException if {@code mimeType} is {@code null} + * @throws IllegalArgumentException if {@code mimeType} does not obey + * the syntax for a MIME media type string */ public READER (String mimeType) { super (mimeType, "java.io.Reader"); @@ -1374,16 +1233,16 @@ public class DocFlavor implements Serializable, Cloneable { /** * Doc flavor with MIME type = {@code "text/plain; charset=utf-16"}, - * print data representation class name = - * {@code "java.io.Reader"} (character stream). + * print data representation class name = {@code "java.io.Reader"} + * (character stream). */ public static final READER TEXT_PLAIN = new READER ("text/plain; charset=utf-16"); /** * Doc flavor with MIME type = {@code "text/html; charset=utf-16"}, - * print data representation class name = - * {@code "java.io.Reader"} (character stream). + * print data representation class name = {@code "java.io.Reader"} + * (character stream). */ public static final READER TEXT_HTML = new READER ("text/html; charset=utf-16"); @@ -1391,27 +1250,27 @@ public class DocFlavor implements Serializable, Cloneable { } /** - * Class DocFlavor.SERVICE_FORMATTED provides predefined static constant - * DocFlavor objects for example doc flavors for service formatted print - * data. + * Class {@code DocFlavor.SERVICE_FORMATTED} provides predefined static + * constant {@code DocFlavor} objects for example doc flavors for service + * formatted print data. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public static class SERVICE_FORMATTED extends DocFlavor { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 6181337766266637256L; /** * Constructs a new doc flavor with a MIME type of - * {@code "application/x-java-jvm-local-objectref"} indicating - * service formatted print data and the given print data - * representation class name. + * {@code "application/x-java-jvm-local-objectref"} indicating service + * formatted print data and the given print data representation class + * name. * - * @param className Fully-qualified representation class name. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code className} is - * null. + * @param className fully-qualified representation class name + * @throws NullPointerException if {@code className} is {@code null} */ public SERVICE_FORMATTED (String className) { super ("application/x-java-jvm-local-objectref", className); @@ -1420,8 +1279,8 @@ public class DocFlavor implements Serializable, Cloneable { /** * Service formatted print data doc flavor with print data * representation class name = - * {@code "java.awt.image.renderable.RenderableImage"} - * (renderable image object). + * {@code "java.awt.image.renderable.RenderableImage"} (renderable image + * object). */ public static final SERVICE_FORMATTED RENDERABLE_IMAGE = new SERVICE_FORMATTED("java.awt.image.renderable.RenderableImage"); @@ -1443,5 +1302,4 @@ public class DocFlavor implements Serializable, Cloneable { new SERVICE_FORMATTED ("java.awt.print.Pageable"); } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/DocPrintJob.java b/jdk/src/java.desktop/share/classes/javax/print/DocPrintJob.java index 3ab15f96664..c68d106dbbd 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/DocPrintJob.java +++ b/jdk/src/java.desktop/share/classes/javax/print/DocPrintJob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -29,146 +29,132 @@ import javax.print.attribute.PrintJobAttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.event.PrintJobAttributeListener; import javax.print.event.PrintJobListener; -import javax.print.PrintException; /** - * - * This interface represents a print job that can print a specified - * document with a set of job attributes. An object implementing - * this interface is obtained from a print service. - * + * This interface represents a print job that can print a specified document + * with a set of job attributes. An object implementing this interface is + * obtained from a print service. */ - public interface DocPrintJob { /** - * Determines the {@link PrintService} object to which this print job - * object is bound. - * - * @return {@code PrintService} object. + * Determines the {@link PrintService} object to which this print job object + * is bound. * + * @return {@code PrintService} object */ public PrintService getPrintService(); /** - * Obtains this Print Job's set of printing attributes. - * The returned attribute set object is unmodifiable. - * The returned attribute set object is a "snapshot" of this Print Job's - * attribute set at the time of the {@link #getAttributes()} method - * call; that is, the returned attribute set's object's contents will - * not be updated if this Print Job's attribute set's contents change - * in the future. To detect changes in attribute values, call - * {@code getAttributes()} again and compare the new attribute - * set to the previous attribute set; alternatively, register a - * listener for print job events. - * The returned value may be an empty set but should not be null. + * Obtains this Print Job's set of printing attributes. The returned + * attribute set object is unmodifiable. The returned attribute set object + * is a "snapshot" of this Print Job's attribute set at the time of the + * {@code getAttributes()} method call; that is, the returned attribute + * set's object's contents will not be updated if this Print Job's attribute + * set's contents change in the future. To detect changes in attribute + * values, call {@code getAttributes()} again and compare the new attribute + * set to the previous attribute set; alternatively, register a listener for + * print job events. The returned value may be an empty set but should not + * be {@code null}. + * * @return the print job attributes */ public PrintJobAttributeSet getAttributes(); /** - * Registers a listener for event occurring during this print job. - * If listener is null, no exception is thrown and no action is - * performed. - * If listener is already registered, it will be registered again. + * Registers a listener for event occurring during this print job. If + * listener is {@code null}, no exception is thrown and no action is + * performed. If listener is already registered, it will be registered + * again. + * + * @param listener the object implementing the listener interface * @see #removePrintJobListener - * - * @param listener The object implementing the listener interface - * */ public void addPrintJobListener(PrintJobListener listener); /** - * Removes a listener from this print job. - * This method performs no function, nor does it throw an exception, - * if the listener specified by the argument was not previously added - * to this component. If listener is null, no exception is thrown and - * no action is performed. If a listener was registered more than once - * only one of the registrations will be removed. - * @see #addPrintJobListener + * Removes a listener from this print job. This method performs no function, + * nor does it throw an exception, if the listener specified by the argument + * was not previously added to this print job. If listener is {@code null}, + * no exception is thrown and no action is performed. If a listener was + * registered more than once only one of the registrations will be removed. * - * @param listener The object implementing the listener interface + * @param listener the object implementing the listener interface + * @see #addPrintJobListener */ public void removePrintJobListener(PrintJobListener listener); /** - * Registers a listener for changes in the specified attributes. - * If listener is null, no exception is thrown and no action is - * performed. - * To determine the attribute updates that may be reported by this job, - * a client can call {@code getAttributes()} and identify the - * subset that are interesting and likely to be reported to the - * listener. Clients expecting to be updated about changes in a - * specific job attribute should verify it is in that set, but - * updates about an attribute will be made only if it changes and this - * is detected by the job. Also updates may be subject to batching - * by the job. To minimize overhead in print job processing it is - * recommended to listen on only that subset of attributes which - * are likely to change. - * If the specified set is empty no attribute updates will be reported - * to the listener. - * If the attribute set is null, then this means to listen on all - * dynamic attributes that the job supports. This may result in no - * update notifications if a job can not report any attribute updates. - * + * Registers a listener for changes in the specified attributes. If listener + * is {@code null}, no exception is thrown and no action is performed. To + * determine the attribute updates that may be reported by this job, a + * client can call {@code getAttributes()} and identify the subset that are + * interesting and likely to be reported to the listener. Clients expecting + * to be updated about changes in a specific job attribute should verify it + * is in that set, but updates about an attribute will be made only if it + * changes and this is detected by the job. Also updates may be subject to + * batching by the job. To minimize overhead in print job processing it is + * recommended to listen on only that subset of attributes which are likely + * to change. If the specified set is empty no attribute updates will be + * reported to the listener. If the attribute set is {@code null}, then this + * means to listen on all dynamic attributes that the job supports. This may + * result in no update notifications if a job can not report any attribute + * updates. + *

* If listener is already registered, it will be registered again. - * @see #removePrintJobAttributeListener * - * @param listener The object implementing the listener interface - * @param attributes The attributes to listen on, or null to mean - * all attributes that can change, as determined by the job. + * @param listener the object implementing the listener interface + * @param attributes the attributes to listen on, or {@code null} to mean + * all attributes that can change, as determined by the job + * @see #removePrintJobAttributeListener */ public void addPrintJobAttributeListener( PrintJobAttributeListener listener, PrintJobAttributeSet attributes); /** - * Removes an attribute listener from this print job. - * This method performs no function, nor does it throw an exception, - * if the listener specified by the argument was not previously added - * to this component. If the listener is null, no exception is thrown - * and no action is performed. - * If a listener is registered more than once, even for a different - * set of attributes, no guarantee is made which listener is removed. + * Removes an attribute listener from this print job. This method performs + * no function, nor does it throw an exception, if the listener specified by + * the argument was not previously added to this print job. If the listener + * is {@code null}, no exception is thrown and no action is performed. If a + * listener is registered more than once, even for a different set of + * attributes, no guarantee is made which listener is removed. + * + * @param listener the object implementing the listener interface * @see #addPrintJobAttributeListener - * - * @param listener The object implementing the listener interface - * */ public void removePrintJobAttributeListener( PrintJobAttributeListener listener); /** - * Prints a document with the specified job attributes. - * This method should only be called once for a given print job. - * Calling it again will not result in a new job being spooled to - * the printer. The service implementation will define policy - * for service interruption and recovery. + * Prints a document with the specified job attributes. This method should + * only be called once for a given print job. Calling it again will not + * result in a new job being spooled to the printer. The service + * implementation will define policy for service interruption and recovery. * When the print method returns, printing may not yet have completed as * printing may happen asynchronously, perhaps in a different thread. - * Application clients which want to monitor the success or failure - * should register a PrintJobListener. + * Application clients which want to monitor the success or failure should + * register a {@code PrintJobListener}. *

* Print service implementors should close any print data streams (ie - * Reader or InputStream implementations) that they obtain - * from the client doc. Robust clients may still wish to verify this. - * An exception is always generated if a {@code DocFlavor} cannot - * be printed. + * {@code Reader} or {@code InputStream} implementations) that they obtain + * from the client doc. Robust clients may still wish to verify this. An + * exception is always generated if a {@code DocFlavor} cannot be printed. * - * @param doc The document to be printed. If must be a flavor - * supported by this PrintJob. - * - * @param attributes The job attributes to be applied to this print job. - * If this parameter is null then the default attributes are used. - * @throws PrintException The exception additionally may implement - * an interface that more precisely describes the cause of the - * exception - *

    - *
  • FlavorException. - * If the document has a flavor not supported by this print job. - *
  • AttributeException. - * If one or more of the attributes are not valid for this print job. - *
+ * @param doc the document to be printed. It must be a flavor supported by + * this PrintJob. + * @param attributes the job attributes to be applied to this print job. If + * this parameter is {@code null} then the default attributes are + * used. + * @throws PrintException the exception additionally may implement an + * interface that more precisely describes the cause of the + * exception + *
    + *
  • {@code FlavorException}. If the document has a flavor not + * supported by this print job. + *
  • {@code AttributeException}. If one or more of the + * attributes are not valid for this print job. + *
*/ public void print(Doc doc, PrintRequestAttributeSet attributes) throws PrintException; diff --git a/jdk/src/java.desktop/share/classes/javax/print/FlavorException.java b/jdk/src/java.desktop/share/classes/javax/print/FlavorException.java index eb1ff15f94d..c5d4d9a2233 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/FlavorException.java +++ b/jdk/src/java.desktop/share/classes/javax/print/FlavorException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -25,23 +25,20 @@ package javax.print; -import javax.print.DocFlavor; - /** - * Interface FlavorException is a mixin interface which a subclass of {@link - * PrintException PrintException} can implement to report an error condition - * involving a doc flavor or flavors (class {@link javax.print.DocFlavor - * DocFlavor}). The Print Service API does not define any print exception - * classes that implement interface FlavorException, that being left to the - * Print Service implementor's discretion. - * + * Interface {@code FlavorException} is a mixin interface which a subclass of + * {@link PrintException PrintException} can implement to report an error + * condition involving a doc flavor or flavors (class {@link DocFlavor}). The + * Print Service API does not define any print exception classes that implement + * interface {@code FlavorException}, that being left to the Print Service + * implementor's discretion. */ public interface FlavorException { /** * Returns the unsupported flavors. - * @return the unsupported doc flavors. + * + * @return the unsupported doc flavors */ public DocFlavor[] getUnsupportedFlavors(); - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/MimeType.java b/jdk/src/java.desktop/share/classes/javax/print/MimeType.java index e96859e9c4c..453bfe2866b 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/MimeType.java +++ b/jdk/src/java.desktop/share/classes/javax/print/MimeType.java @@ -26,7 +26,6 @@ package javax.print; import java.io.Serializable; - import java.util.AbstractMap; import java.util.AbstractSet; import java.util.Iterator; @@ -36,63 +35,63 @@ import java.util.Set; import java.util.Vector; /** - * Class MimeType encapsulates a Multipurpose Internet Mail Extensions (MIME) - * media type as defined in RFC - * 2045 and RFC 2046. A - * MIME type object is part of a {@link DocFlavor DocFlavor} object and - * specifies the format of the print data. - *

- * Class MimeType is similar to the like-named - * class in package {@link java.awt.datatransfer java.awt.datatransfer}. Class - * java.awt.datatransfer.MimeType is not used in the Jini Print Service API - * for two reasons: - *

    - *
  1. - * Since not all Java profiles include the AWT, the Jini Print Service should - * not depend on an AWT class. - *
  2. - * The implementation of class java.awt.datatransfer.MimeType does not - * guarantee - * that equivalent MIME types will have the same serialized representation. - * Thus, since the Jini Lookup Service (JLUS) matches service attributes based - * on equality of serialized representations, JLUS searches involving MIME - * types encapsulated in class java.awt.datatransfer.MimeType may incorrectly - * fail to match. - *
- *

+ * Class {@code MimeType} encapsulates a Multipurpose Internet Mail Extensions + * (MIME) media type as defined in + * RFC 2045 and + * RFC 2046. A MIME type + * object is part of a {@link DocFlavor DocFlavor} object and specifies the + * format of the print data. + *

+ * Class {@code MimeType} is similar to the like-named class in package + * {@link java.awt.datatransfer java.awt.datatransfer}. Class + * {@link java.awt.datatransfer.MimeType} is not used in the Jini Print Service + * API for two reasons: + *

    + *
  1. Since not all Java profiles include the AWT, the Jini Print Service + * should not depend on an AWT class. + *
  2. The implementation of class {@code java.awt.datatransfer.MimeType} does + * not guarantee that equivalent MIME types will have the same serialized + * representation. Thus, since the Jini Lookup Service (JLUS) matches service + * attributes based on equality of serialized representations, JLUS searches + * involving MIME types encapsulated in class + * {@code java.awt.datatransfer.MimeType} may incorrectly fail to match. + *
* Class MimeType's serialized representation is based on the following * canonical form of a MIME type string. Thus, two MIME types that are not - * identical but that are equivalent (that have the same canonical form) will - * be considered equal by the JLUS's matching algorithm. - *
    - *
  • The media type, media subtype, and parameters are retained, but all - * comments and whitespace characters are discarded. - *
  • The media type, media subtype, and parameter names are converted to - * lowercase. - *
  • The parameter values retain their original case, except a charset - * parameter value for a text media type is converted to lowercase. - *
  • Quote characters surrounding parameter values are removed. - *
  • Quoting backslash characters inside parameter values are removed. - *
  • The parameters are arranged in ascending order of parameter name. - *
+ * identical but that are equivalent (that have the same canonical form) will be + * considered equal by the JLUS's matching algorithm. + *
    + *
  • The media type, media subtype, and parameters are retained, but all + * comments and whitespace characters are discarded. + *
  • The media type, media subtype, and parameter names are converted to + * lowercase. + *
  • The parameter values retain their original case, except a charset + * parameter value for a text media type is converted to lowercase. + *
  • Quote characters surrounding parameter values are removed. + *
  • Quoting backslash characters inside parameter values are removed. + *
  • The parameters are arranged in ascending order of parameter name. + *
* - * @author Alan Kaminsky + * @author Alan Kaminsky */ class MimeType implements Serializable, Cloneable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -2785720609362367683L; /** - * Array of strings that hold pieces of this MIME type's canonical form. - * If the MIME type has n parameters, n >= 0, then the + * Array of strings that hold pieces of this MIME type's canonical form. If + * the MIME type has n parameters, n >= 0, then the * strings in the array are: - *
Index 0 -- Media type. - *
Index 1 -- Media subtype. - *
Index 2i+2 -- Name of parameter i, - * i=0,1,...,n-1. - *
Index 2i+3 -- Value of parameter i, - * i=0,1,...,n-1. - *
Parameters are arranged in ascending order of parameter name. + *
Index 0 -- Media type. + *
Index 1 -- Media subtype. + *
Index 2i+2 -- Name of parameter i, + * i=0,1,...,n-1. + *
Index 2i+3 -- Value of parameter i, + * i=0,1,...,n-1. + *
Parameters are arranged in ascending order of parameter name. * @serial */ private String[] myPieces; @@ -116,7 +115,17 @@ class MimeType implements Serializable, Cloneable { * Parameter map entry. */ private class ParameterMapEntry implements Map.Entry { + + /** + * The index of the entry. + */ private int myIndex; + + /** + * Constructs a new parameter map entry. + * + * @param theIndex the index of the entry + */ public ParameterMapEntry(int theIndex) { myIndex = theIndex; } @@ -144,6 +153,10 @@ class MimeType implements Serializable, Cloneable { * Parameter map entry set iterator. */ private class ParameterMapEntrySetIterator implements Iterator> { + + /** + * The current index of the iterator. + */ private int myIndex = 2; public boolean hasNext() { return myIndex < myPieces.length; @@ -187,16 +200,13 @@ class MimeType implements Serializable, Cloneable { } /** - * Construct a new MIME type object from the given string. The given - * string is converted into canonical form and stored internally. + * Construct a new MIME type object from the given string. The given string + * is converted into canonical form and stored internally. * - * @param s MIME media type string. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code s} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code s} does not obey the - * syntax for a MIME media type string. + * @param s MIME media type string + * @throws NullPointerException if {@code s} is {@code null} + * @throws IllegalArgumentException if {@code s} does not obey the syntax + * for a MIME media type string */ public MimeType(String s) { parse (s); @@ -205,6 +215,8 @@ class MimeType implements Serializable, Cloneable { /** * Returns this MIME type object's MIME type string based on the canonical * form. Each parameter value is enclosed in quotes. + * + * @return the mime type */ public String getMimeType() { return getStringValue(); @@ -212,6 +224,8 @@ class MimeType implements Serializable, Cloneable { /** * Returns this MIME type object's media type. + * + * @return the media type */ public String getMediaType() { return myPieces[0]; @@ -219,6 +233,8 @@ class MimeType implements Serializable, Cloneable { /** * Returns this MIME type object's media subtype. + * + * @return the media subtype */ public String getMediaSubtype() { return myPieces[1]; @@ -226,11 +242,11 @@ class MimeType implements Serializable, Cloneable { /** * Returns an unmodifiable map view of the parameters in this MIME type - * object. Each entry in the parameter map view consists of a parameter - * name String (key) mapping to a parameter value String. If this MIME - * type object has no parameters, an empty map is returned. + * object. Each entry in the parameter map view consists of a parameter name + * {@code String} (key) mapping to a parameter value {@code String}. If this + * MIME type object has no parameters, an empty map is returned. * - * @return Parameter map for this MIME type object. + * @return parameter map for this MIME type object */ public Map getParameterMap() { if (myParameterMap == null) { @@ -242,8 +258,8 @@ class MimeType implements Serializable, Cloneable { /** * Converts this MIME type object to a string. * - * @return MIME type string based on the canonical form. Each parameter - * value is enclosed in quotes. + * @return MIME type string based on the canonical form. Each parameter + * value is enclosed in quotes. */ public String toString() { return getStringValue(); @@ -258,19 +274,18 @@ class MimeType implements Serializable, Cloneable { /** * Determine if this MIME type object is equal to the given object. The two - * are equal if the given object is not null, is an instance of class - * net.jini.print.data.MimeType, and has the same canonical form as this - * MIME type object (that is, has the same type, subtype, and parameters). - * Thus, if two MIME type objects are the same except for comments, they are - * considered equal. However, "text/plain" and "text/plain; - * charset=us-ascii" are not considered equal, even though they represent - * the same media type (because the default character set for plain text is - * US-ASCII). + * are equal if the given object is not {@code null}, is an instance of + * class {@code javax.print.data.MimeType}, and has the same canonical form + * as this MIME type object (that is, has the same type, subtype, and + * parameters). Thus, if two MIME type objects are the same except for + * comments, they are considered equal. However, "text/plain" and + * "text/plain; charset=us-ascii" are not considered equal, even though they + * represent the same media type (because the default character set for + * plain text is US-ASCII). * - * @param obj Object to test. - * - * @return True if this MIME type object equals {@code obj}, false - * otherwise. + * @param obj {@code object} to test + * @return {@code true} if this MIME type object equals {@code obj}, + * {@code false} otherwise */ public boolean equals (Object obj) { return(obj != null && @@ -280,6 +295,8 @@ class MimeType implements Serializable, Cloneable { /** * Returns this MIME type's string value in canonical form. + * + * @return the MIME type's string value in canonical form */ private String getStringValue() { if (myStringValue == null) { @@ -300,8 +317,8 @@ class MimeType implements Serializable, Cloneable { return myStringValue; } -// Hidden classes, constants, and operations for parsing a MIME media type -// string. + // Hidden classes, constants, and operations for parsing a MIME media type + // string. // Lexeme types. private static final int TOKEN_LEXEME = 0; @@ -310,7 +327,9 @@ class MimeType implements Serializable, Cloneable { private static final int EOF_LEXEME = 3; private static final int ILLEGAL_LEXEME = 4; - // Class for a lexical analyzer. + /** + *Class for a lexical analyzer. + */ private static class LexicalAnalyzer { protected String mySource; protected int mySourceLength; @@ -459,18 +478,19 @@ class MimeType implements Serializable, Cloneable { break; } } - } - } /** - * Returns a lowercase version of the given string. The lowercase version - * is constructed by applying Character.toLowerCase() to each character of - * the given string, which maps characters to lowercase using the rules of - * Unicode. This mapping is the same regardless of locale, whereas the - * mapping of String.toLowerCase() may be different depending on the + * Returns a lowercase version of the given string. The lowercase version is + * constructed by applying {@code Character.toLowerCase()} to each character + * of the given string, which maps characters to lowercase using the rules + * of Unicode. This mapping is the same regardless of locale, whereas the + * mapping of {@code String.toLowerCase()} may be different depending on the * default locale. + * + * @param s the string + * @return the lowercase version of the string */ private static String toUnicodeLowerCase(String s) { int n = s.length(); @@ -483,6 +503,9 @@ class MimeType implements Serializable, Cloneable { /** * Returns a version of the given string with backslashes removed. + * + * @param s the string + * @return the string with backslashes removed */ private static String removeBackslashes(String s) { int n = s.length(); @@ -503,6 +526,10 @@ class MimeType implements Serializable, Cloneable { /** * Returns a version of the string surrounded by quotes and with interior * quotes preceded by a backslash. + * + * @param s the string + * @return the string surrounded by quotes and with interior quotes preceded + * by a backslash */ private static String addQuotes(String s) { int n = s.length(); @@ -524,20 +551,17 @@ class MimeType implements Serializable, Cloneable { /** * Parses the given string into canonical pieces and stores the pieces in * {@link #myPieces myPieces}. - *

+ *

* Special rules applied: - *

    - *
  • If the media type is text, the value of a charset parameter is - * converted to lowercase. - *
+ *
    + *
  • If the media type is text, the value of a charset parameter is + * converted to lowercase. + *
* - * @param s MIME media type string. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code s} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code s} does not obey the - * syntax for a MIME media type string. + * @param s MIME media type string + * @throws NullPointerException if {@code s} is {@code null} + * @throws IllegalArgumentException if {@code s} does not obey the syntax + * for a MIME media type string */ private void parse(String s) { // Initialize. diff --git a/jdk/src/java.desktop/share/classes/javax/print/MultiDoc.java b/jdk/src/java.desktop/share/classes/javax/print/MultiDoc.java index 2d578bd253c..4e45e01f895 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/MultiDoc.java +++ b/jdk/src/java.desktop/share/classes/javax/print/MultiDoc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -28,54 +28,52 @@ package javax.print; import java.io.IOException; /** - * Interface MultiDoc specifies the interface for an object that supplies more - * than one piece of print data for a Print Job. "Doc" is a short, + * Interface {@code MultiDoc} specifies the interface for an object that + * supplies more than one piece of print data for a Print Job. "Doc" is a short, * easy-to-pronounce term that means "a piece of print data," and a "multidoc" - * is a group of several docs. The client passes to the Print Job an object - * that implements interface MultiDoc, and the Print Job calls methods on - * that object to obtain the print data. - *

- * Interface MultiDoc provides an abstraction similar to a "linked list" of - * docs. A multidoc object is like a node in the linked list, containing the + * is a group of several docs. The client passes to the Print Job an object that + * implements interface {@code MultiDoc}, and the Print Job calls methods on + * that object to obtain the print data. + *

+ * Interface {@code MultiDoc} provides an abstraction similar to a "linked list" + * of docs. A multidoc object is like a node in the linked list, containing the * current doc in the list and a pointer to the next node (multidoc) in the - * list. The Print Job can call the multidoc's {@link #getDoc() - * getDoc()} method to get the current doc. When it's ready to go - * on to the next doc, the Print Job can call the multidoc's {@link #next() - * next()} method to get the next multidoc, which contains the - * next doc. So Print Job code for accessing a multidoc might look like this: - *

+ * list. The Print Job can call the multidoc's {@link #getDoc() getDoc()} method
+ * to get the current doc. When it's ready to go on to the next doc, the Print
+ * Job can call the multidoc's {@link #next() next()} method to get the next
+ * multidoc, which contains the next doc. So Print Job code for accessing a
+ * multidoc might look like this:
+ *
+ * 
  *      void processMultiDoc(MultiDoc theMultiDoc) {
  *
  *          MultiDoc current = theMultiDoc;
-
+ *
  *          while (current != null) {
  *              processDoc (current.getDoc());
  *              current = current.next();
  *          }
  *      }
- * 
- *

- * Of course, interface MultiDoc can be implemented in any way that fulfills - * the contract; it doesn't have to use a linked list in the implementation. - *

- * To get all the print data for a multidoc print job, a Print Service - * proxy could use either of two patterns: - *

    - *
  1. - * The interleaved pattern: Get the doc from the current multidoc. Get - * the print data representation object from the current doc. Get all the print - * data from the print data representation object. Get the next multidoc from - * the current multidoc, and repeat until there are no more. (The code example - * above uses the interleaved pattern.) - * - *
  2. - * The all-at-once pattern: Get the doc from the current multidoc, and - * save the doc in a list. Get the next multidoc from the current multidoc, and - * repeat until there are no more. Then iterate over the list of saved docs. Get - * the print data representation object from the current doc. Get all the print - * data from the print data representation object. Go to the next doc in the - * list, and repeat until there are no more. - *
+ *
+ * Of course, interface {@code MultiDoc} can be implemented in any way that + * fulfills the contract; it doesn't have to use a linked list in the + * implementation. + *

+ * To get all the print data for a multidoc print job, a Print Service proxy + * could use either of two patterns: + *

    + *
  1. The interleaved pattern: Get the doc from the current multidoc. + * Get the print data representation object from the current doc. Get all the + * print data from the print data representation object. Get the next multidoc + * from the current multidoc, and repeat until there are no more. (The code + * example above uses the interleaved pattern.) + *
  2. The all-at-once pattern: Get the doc from the current multidoc, + * and save the doc in a list. Get the next multidoc from the current + * multidoc, and repeat until there are no more. Then iterate over the list of + * saved docs. Get the print data representation object from the current doc. + * Get all the print data from the print data representation object. Go to the + * next doc in the list, and repeat until there are no more. + *
* Now, consider a printing client that is generating print data on the fly and * does not have the resources to store more than one piece of print data at a * time. If the print service proxy used the all-at-once pattern to get the @@ -83,41 +81,37 @@ import java.io.IOException; * to keep all the docs' print data around until the print service proxy comes * back and asks for them, which the client is not able to do. To work with such * a client, the print service proxy must use the interleaved pattern. - *

+ *

* To address this problem, and to simplify the design of clients providing -* multiple docs to a Print Job, every Print Service proxy that supports - * multidoc print jobs is required to access a MultiDoc object using the - * interleaved pattern. That is, given a MultiDoc object, the print service - * proxy will call {@link #getDoc() getDoc()} one or more times - * until it successfully obtains the current Doc object. The print service proxy + * multiple docs to a Print Job, every Print Service proxy that supports + * multidoc print jobs is required to access a {@code MultiDoc} object using the + * interleaved pattern. That is, given a {@code MultiDoc} object, the print + * service proxy will call {@link #getDoc() getDoc()} one or more times until it + * successfully obtains the current {@code Doc} object. The print service proxy * will then obtain the current doc's print data, not proceeding until all the * print data is obtained or an unrecoverable error occurs. If it is able to - * continue, the print service proxy will then call {@link #next() - * next()} one or more times until it successfully obtains either - * the next MultiDoc object or an indication that there are no more. An - * implementation of interface MultiDoc can assume the print service proxy will - * follow this interleaved pattern; for any other pattern of usage, the MultiDoc - * implementation's behavior is unspecified. - *

+ * continue, the print service proxy will then call {@link #next() next()} one + * or more times until it successfully obtains either the next {@code MultiDoc} + * object or an indication that there are no more. An implementation of + * interface {@code MultiDoc} can assume the print service proxy will follow + * this interleaved pattern; for any other pattern of usage, the + * {@code MultiDoc} implementation's behavior is unspecified. + *

* There is no restriction on the number of client threads that may be * simultaneously accessing the same multidoc. Therefore, all implementations of * interface MultiDoc must be designed to be multiple thread safe. In fact, a * client thread could be adding docs to the end of the (conceptual) list while * a Print Job thread is simultaneously obtaining docs from the beginning of the * list; provided the multidoc object synchronizes the threads properly, the two - * threads will not interfere with each other + * threads will not interfere with each other. */ - public interface MultiDoc { - /** * Obtain the current doc object. * - * @return Current doc object. - * - * @exception IOException - * Thrown if a error occurred reading the document. + * @return current doc object + * @throws IOException if an error occurred when reading the document */ public Doc getDoc() throws IOException; @@ -125,12 +119,9 @@ public interface MultiDoc { * Go to the multidoc object that contains the next doc object in the * sequence of doc objects. * - * @return Multidoc object containing the next doc object, or null if - * there are no further doc objects. - * - * @exception IOException - * Thrown if an error occurred locating the next document + * @return multidoc object containing the next doc object, or {@code null} + * if there are no further doc objects + * @throws IOException if an error occurred locating the next document */ public MultiDoc next() throws IOException; - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/MultiDocPrintJob.java b/jdk/src/java.desktop/share/classes/javax/print/MultiDocPrintJob.java index 6bf8410f701..cdf62c21c10 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/MultiDocPrintJob.java +++ b/jdk/src/java.desktop/share/classes/javax/print/MultiDocPrintJob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -28,39 +28,35 @@ package javax.print; import javax.print.attribute.PrintRequestAttributeSet; /** - * - * Obtained from a MultiDocPrintService, a MultiDocPrintJob can print a - * specified collection of documents as a single print job with a set of + * Obtained from a {@code MultiDocPrintService}, a {@code MultiDocPrintJob} can + * print a specified collection of documents as a single print job with a set of * job attributes. */ - public interface MultiDocPrintJob extends DocPrintJob { - /** - * Print a MultiDoc with the specified job attributes. - * This method should only be called once for a given print job. - * Calling it again will not result in a new job being spooled to - * the printer. The service implementation will define policy - * for service interruption and recovery. Application clients which - * want to monitor the success or failure should register a - * PrintJobListener. + /** + * Print a {@code MultiDoc} with the specified job attributes. This method + * should only be called once for a given print job. Calling it again will + * not result in a new job being spooled to the printer. The service + * implementation will define policy for service interruption and recovery. + * Application clients which want to monitor the success or failure should + * register a {@code PrintJobListener}. * - * @param multiDoc The documents to be printed. ALL must be a flavor - * supported by the PrintJob {@literal &} PrintService. - * - * @param attributes The job attributes to be applied to this print job. - * If this parameter is null then the default attributes are used. - * - * @throws PrintException The exception additionally may implement - * an interfaces which more precisely describes the cause of the exception - *

    - *
  • FlavorException. - * If the document has a flavor not supported by this print job. - *
  • AttributeException. - * If one or more of the attributes are not valid for this print job. - *
+ * @param multiDoc the documents to be printed. ALL must be a flavor + * supported by the PrintJob {@literal &} PrintService. + * @param attributes the job attributes to be applied to this print job. If + * this parameter is {@code null} then the default attributes are + * used. + * @throws PrintException the exception additionally may implement an + * interfaces which more precisely describes the cause of the + * exception + *
    + *
  • {@code FlavorException}. If the document has a flavor not + * supported by this print job. + *
  • {@code AttributeException}. If one or more of the + * attributes are not valid for this print job. + *
*/ public void print(MultiDoc multiDoc, PrintRequestAttributeSet attributes) throws PrintException; - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/MultiDocPrintService.java b/jdk/src/java.desktop/share/classes/javax/print/MultiDocPrintService.java index 5cddd4b2954..0c4d042816d 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/MultiDocPrintService.java +++ b/jdk/src/java.desktop/share/classes/javax/print/MultiDocPrintService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -25,18 +25,18 @@ package javax.print; - - /** Interface MultiPrintService is the factory for a MultiDocPrintJob. - * A MultiPrintService - * describes the capabilities of a Printer and can be queried regarding - * a printer's supported attributes. - */ +/** + * Interface {@code MultiPrintService} is the factory for a + * {@code MultiDocPrintJob}. A {@code MultiPrintService} describes the + * capabilities of a printer and can be queried regarding a printer's supported + * attributes. + */ public interface MultiDocPrintService extends PrintService { /** * Create a job which can print a multiDoc. - * @return a MultiDocPrintJob + * + * @return a {@code MultiDocPrintJob} */ public MultiDocPrintJob createMultiDocPrintJob(); - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/PrintException.java b/jdk/src/java.desktop/share/classes/javax/print/PrintException.java index f3019980831..c78c49c97e8 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/PrintException.java +++ b/jdk/src/java.desktop/share/classes/javax/print/PrintException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -26,13 +26,16 @@ package javax.print; /** - * Class PrintException encapsulates a printing-related error condition that - * occurred while using a Print Service instance. This base class - * furnishes only a string description of the error. Subclasses furnish more - * detailed information if applicable. - * + * Class {@code PrintException} encapsulates a printing-related error condition + * that occurred while using a Print Service instance. This base class furnishes + * only a string description of the error. Subclasses furnish more detailed + * information if applicable. */ public class PrintException extends Exception { + + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -5932531546705242471L; /** @@ -45,7 +48,7 @@ public class PrintException extends Exception { /** * Construct a print exception with the given detail message. * - * @param s Detail message, or null if no detail message. + * @param s detail message, or {@code null} if no detail message */ public PrintException (String s) { super (s); @@ -54,20 +57,20 @@ public class PrintException extends Exception { /** * Construct a print exception chaining the supplied exception. * - * @param e Chained exception. + * @param e chained exception */ public PrintException (Exception e) { super ( e); } /** - * Construct a print exception with the given detail message - * and chained exception. - * @param s Detail message, or null if no detail message. - * @param e Chained exception. + * Construct a print exception with the given detail message and chained + * exception. + * + * @param s detail message, or {@code null} if no detail message + * @param e chained exception */ public PrintException (String s, Exception e) { super (s, e); } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/PrintService.java b/jdk/src/java.desktop/share/classes/javax/print/PrintService.java index 356e8498d01..733abfcd628 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/PrintService.java +++ b/jdk/src/java.desktop/share/classes/javax/print/PrintService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -25,22 +25,19 @@ package javax.print; -import java.util.Locale; - import javax.print.attribute.Attribute; import javax.print.attribute.AttributeSet; import javax.print.attribute.PrintServiceAttribute; import javax.print.attribute.PrintServiceAttributeSet; import javax.print.event.PrintServiceAttributeListener; - /** - * Interface PrintService is the factory for a DocPrintJob. A PrintService - * describes the capabilities of a Printer and can be queried regarding - * a printer's supported attributes. - *

+ * Interface {@code PrintService} is the factory for a {@code DocPrintJob}. A + * {@code PrintService} describes the capabilities of a printer and can be + * queried regarding a printer's supported attributes. + *

* Example: - *

{@code
+ *   
{@code
  *   DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
  *   PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
  *   aset.add(MediaSizeName.ISO_A4);
@@ -56,299 +53,263 @@ import javax.print.event.PrintServiceAttributeListener;
  *        } catch (PrintException e) {
  *        }
  *   }
- *   }
+ * }
*/ public interface PrintService { - /** Returns a String name for this print service which may be used - * by applications to request a particular print service. - * In a suitable context, such as a name service, this name must be - * unique. - * In some environments this unique name may be the same as the user - * friendly printer name defined as the - * {@link javax.print.attribute.standard.PrinterName PrinterName} - * attribute. - * @return name of the service. - */ + /** + * Returns a string name for this print service which may be used by + * applications to request a particular print service. In a suitable + * context, such as a name service, this name must be unique. In some + * environments this unique name may be the same as the user friendly + * printer name defined as the + * {@link javax.print.attribute.standard.PrinterName PrinterName} attribute. + * + * @return name of the service + */ public String getName(); /** - * Creates and returns a PrintJob capable of handling data from - * any of the supported document flavors. - * @return a DocPrintJob object + * Creates and returns a {@code PrintJob} capable of handling data from any + * of the supported document flavors. + * + * @return a {@code DocPrintJob} object */ public DocPrintJob createPrintJob(); /** - * Registers a listener for events on this PrintService. - * @param listener a PrintServiceAttributeListener, which - * monitors the status of a print service + * Registers a listener for events on this {@code PrintService}. + * + * @param listener a PrintServiceAttributeListener, which monitors the + * status of a print service * @see #removePrintServiceAttributeListener */ public void addPrintServiceAttributeListener( PrintServiceAttributeListener listener); /** - * Removes the print-service listener from this print service. - * This means the listener is no longer interested in - * {@code PrintService} events. - * @param listener a PrintServiceAttributeListener object + * Removes the print-service listener from this print service. This means + * the listener is no longer interested in {@code PrintService} events. + * + * @param listener a {@code PrintServiceAttributeListener} object * @see #addPrintServiceAttributeListener */ public void removePrintServiceAttributeListener( PrintServiceAttributeListener listener); /** - * Obtains this print service's set of printer description attributes - * giving this Print Service's status. The returned attribute set object - * is unmodifiable. The returned attribute set object is a "snapshot" of - * this Print Service's attribute set at the time of the - * {@code getAttributes()} method call: that is, the returned - * attribute set's contents will not be updated if this print - * service's attribute set's contents change in the future. To detect - * changes in attribute values, call {@code getAttributes()} again - * and compare the new attribute set to the previous attribute set; - * alternatively, register a listener for print service events. + * Obtains this print service's set of printer description attributes giving + * this Print Service's status. The returned attribute set object is + * unmodifiable. The returned attribute set object is a "snapshot" of this + * Print Service's attribute set at the time of the {@code getAttributes()} + * method call: that is, the returned attribute set's contents will + * not be updated if this print service's attribute set's contents + * change in the future. To detect changes in attribute values, call + * {@code getAttributes()} again and compare the new attribute set to the + * previous attribute set; alternatively, register a listener for print + * service events. * - * @return Unmodifiable snapshot of this Print Service's attribute set. - * May be empty, but not null. + * @return unmodifiable snapshot of this Print Service's attribute set. May + * be empty, but not {@code null}. */ public PrintServiceAttributeSet getAttributes(); /** - * Gets the value of the single specified service attribute. - * This may be useful to clients which only need the value of one - * attribute and want to minimize overhead. - * @param the type of the specified service attribute - * @param category the category of a PrintServiceAttribute supported - * by this service - may not be null. - * @return the value of the supported attribute or null if the - * attribute is not supported by this service. - * @exception NullPointerException if the category is null. - * @exception IllegalArgumentException - * (unchecked exception) if {@code category} is not a - * {@code Class} that implements interface - *{@link javax.print.attribute.PrintServiceAttribute PrintServiceAttribute}. + * Gets the value of the single specified service attribute. This may be + * useful to clients which only need the value of one attribute and want to + * minimize overhead. + * + * @param the type of the specified service attribute + * @param category the category of a {@code PrintServiceAttribute} + * supported by this service - may not be {@code null} + * @return the value of the supported attribute or {@code null} if the + * attribute is not supported by this service + * @throws NullPointerException if the category is {@code null} + * @throws IllegalArgumentException if {@code category} is not a + * {@code Class} that implements interface + * {@link PrintServiceAttribute PrintServiceAttribute} */ public T getAttribute(Class category); /** - * Determines the print data formats a client can specify when setting - * up a job for this {@code PrintService}. A print data format is - * designated by a "doc - * flavor" (class {@link javax.print.DocFlavor DocFlavor}) - * consisting of a MIME type plus a print data representation class. - *

- * Note that some doc flavors may not be supported in combination - * with all attributes. Use {@code getUnsupportedAttributes(..)} - * to validate specific combinations. - * - * @return Array of supported doc flavors, should have at least - * one element. + * Determines the print data formats a client can specify when setting up a + * job for this {@code PrintService}. A print data format is designated by a + * "doc flavor" (class {@link DocFlavor DocFlavor}) consisting of a MIME + * type plus a print data representation class. + *

+ * Note that some doc flavors may not be supported in combination with all + * attributes. Use {@code getUnsupportedAttributes(..)} to validate specific + * combinations. * + * @return array of supported doc flavors, should have at least one element */ public DocFlavor[] getSupportedDocFlavors(); /** - * Determines if this print service supports a specific - * {@code DocFlavor}. This is a convenience method to determine - * if the {@code DocFlavor} would be a member of the result of - * {@code getSupportedDocFlavors()}. + * Determines if this print service supports a specific {@code DocFlavor}. + * This is a convenience method to determine if the {@code DocFlavor} would + * be a member of the result of {@code getSupportedDocFlavors()}. *

- * Note that some doc flavors may not be supported in combination - * with all attributes. Use {@code getUnsupportedAttributes(..)} - * to validate specific combinations. + * Note that some doc flavors may not be supported in combination with all + * attributes. Use {@code getUnsupportedAttributes(..)} to validate specific + * combinations. * - * @param flavor the {@code DocFlavor} to query for support. - * @return {@code true} if this print service supports the - * specified {@code DocFlavor}; {@code false} otherwise. - * @exception NullPointerException - * (unchecked exception) Thrown if {@code flavor} is null. + * @param flavor the {@code DocFlavor} to query for support + * @return {@code true} if this print service supports the specified + * {@code DocFlavor}; {@code false} otherwise + * @throws NullPointerException if {@code flavor} is {@code null} */ public boolean isDocFlavorSupported(DocFlavor flavor); - /** - * Determines the printing attribute categories a client can specify - * when setting up a job for this print service. - * A printing attribute category is + * Determines the printing attribute categories a client can specify when + * setting up a job for this print service. A printing attribute category is * designated by a {@code Class} that implements interface - * {@link javax.print.attribute.Attribute Attribute}. This method returns - * just the attribute categories that are supported; it does not - * return the particular attribute values that are supported. - *

- * This method returns all the printing attribute - * categories this print service supports for any possible job. - * Some categories may not be supported in a particular context (ie - * for a particular {@code DocFlavor}). - * Use one of the methods that include a {@code DocFlavor} to - * validate the request before submitting it, such as + * {@link Attribute Attribute}. This method returns just the attribute + * categories that are supported; it does not return the particular + * attribute values that are supported. + *

+ * This method returns all the printing attribute categories this print + * service supports for any possible job. Some categories may not be + * supported in a particular context (ie for a particular + * {@code DocFlavor}). Use one of the methods that include a + * {@code DocFlavor} to validate the request before submitting it, such as * {@code getSupportedAttributeValues(..)}. * - * @return Array of printing attribute categories that the client can - * specify as a doc-level or job-level attribute in a Print - * Request. Each element in the array is a {@link java.lang.Class - * Class} that implements interface {@link - * javax.print.attribute.Attribute Attribute}. - * The array is empty if no categories are supported. + * @return array of printing attribute categories that the client can + * specify as a doc-level or job-level attribute in a Print Request. + * Each element in the array is a {@link Class Class} that + * implements interface {@link Attribute Attribute}. The array is + * empty if no categories are supported. */ public Class[] getSupportedAttributeCategories(); /** - * Determines whether a client can specify the given printing - * attribute category when setting up a job for this print service. A - * printing attribute category is designated by a {@code Class} - * that implements interface {@link javax.print.attribute.Attribute - * Attribute}. This method tells whether the attribute category is - * supported; it does not tell whether a particular attribute value - * is supported. + * Determines whether a client can specify the given printing attribute + * category when setting up a job for this print service. A printing + * attribute category is designated by a {@code Class} that implements + * interface {@link Attribute Attribute}. This method + * tells whether the attribute category is supported; it does not + * tell whether a particular attribute value is supported. *

- * Some categories may not be supported in a particular context (ie - * for a particular {@code DocFlavor}). - * Use one of the methods which include a {@code DocFlavor} to - * validate the request before submitting it, such as + * Some categories may not be supported in a particular context (ie for a + * particular {@code DocFlavor}). Use one of the methods which include a + * {@code DocFlavor} to validate the request before submitting it, such as * {@code getSupportedAttributeValues(..)}. - *

- * This is a convenience method to determine if the category - * would be a member of the result of - * {@code getSupportedAttributeCategories()}. + *

+ * This is a convenience method to determine if the category would be a + * member of the result of {@code getSupportedAttributeCategories()}. * - * @param category Printing attribute category to test. It must be a - * {@code Class} that implements - * interface - * {@link javax.print.attribute.Attribute Attribute}. - * - * @return {@code true} if this print service supports - * specifying a doc-level or - * job-level attribute in {@code category} in a Print - * Request; {@code false} if it doesn't. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code category} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code category} is not a - * {@code Class} that implements interface - * {@link javax.print.attribute.Attribute Attribute}. + * @param category printing attribute category to test. It must be a + * {@code Class} that implements interface + * {@link Attribute Attribute}. + * @return {@code true} if this print service supports specifying a + * doc-level or job-level attribute in {@code category} in a Print + * Request; {@code false} if it doesn't + * @throws NullPointerException if {@code category} is {@code null} + * @throws IllegalArgumentException if {@code category} is not a + * {@code Class} that implements interface + * {@link Attribute Attribute} */ public boolean isAttributeCategorySupported(Class category); /** - * Determines this print service's default printing attribute value in - * the given category. A printing attribute value is an instance of - * a class that implements interface - * {@link javax.print.attribute.Attribute Attribute}. If a client sets - * up a print job and does not specify any attribute value in the - * given category, this Print Service will use the - * default attribute value instead. + * Determines this print service's default printing attribute value in the + * given category. A printing attribute value is an instance of a class that + * implements interface {@link Attribute Attribute}. If a client sets up a + * print job and does not specify any attribute value in the given category, + * this Print Service will use the default attribute value instead. *

- * Some attributes may not be supported in a particular context (ie - * for a particular {@code DocFlavor}). - * Use one of the methods that include a {@code DocFlavor} to - * validate the request before submitting it, such as + * Some attributes may not be supported in a particular context (ie for a + * particular {@code DocFlavor}). Use one of the methods that include a + * {@code DocFlavor} to validate the request before submitting it, such as * {@code getSupportedAttributeValues(..)}. - *

- * Not all attributes have a default value. For example the - * service will not have a defaultvalue for {@code RequestingUser} - * i.e. a null return for a supported category means there is no - * service default value for that category. Use the - * {@code isAttributeCategorySupported(Class)} method to - * distinguish these cases. + *

+ * Not all attributes have a default value. For example the service will not + * have a default value for {@code RequestingUser} i.e. a {@code null} + * return for a supported category means there is no service default value + * for that category. Use the {@code isAttributeCategorySupported(Class)} + * method to distinguish these cases. * - * @param category Printing attribute category for which the default - * attribute value is requested. It must be a {@link - * java.lang.Class Class} that implements interface - * {@link javax.print.attribute.Attribute - * Attribute}. - * - * @return Default attribute value for {@code category}, or null - * if this Print Service does not support specifying a doc-level or - * job-level attribute in {@code category} in a Print - * Request, or the service does not have a default value - * for this attribute. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code category} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code category} is not a - * {@link java.lang.Class Class} that implements interface {@link - * javax.print.attribute.Attribute Attribute}. + * @param category printing attribute category for which the default + * attribute value is requested. It must be a {@link Class Class} + * that implements interface {@link Attribute Attribute}. + * @return default attribute value for {@code category}, or {@code null} if + * this Print Service does not support specifying a doc-level or + * job-level attribute in {@code category} in a Print Request, or + * the service does not have a default value for this attribute + * @throws NullPointerException if {@code category} is {@code null} + * @throws IllegalArgumentException if {@code category} is not a + * {@link Class Class} that implements interface + * {@link Attribute Attribute} */ public Object getDefaultAttributeValue(Class category); /** - * Determines the printing attribute values a client can specify in - * the given category when setting up a job for this print service. A - * printing + * Determines the printing attribute values a client can specify in the + * given category when setting up a job for this print service. A printing * attribute value is an instance of a class that implements interface - * {@link javax.print.attribute.Attribute Attribute}. - *

- * If {@code flavor} is null and {@code attributes} is null - * or is an empty set, this method returns all the printing attribute - * values this Print Service supports for any possible job. If - * {@code flavor} is not null or {@code attributes} is not - * an empty set, this method returns just the printing attribute values - * that are compatible with the given doc flavor and/or set of attributes. - * That is, a null return value may indicate that specifying this attribute - * is incompatible with the specified DocFlavor. - * Also if DocFlavor is not null it must be a flavor supported by this - * PrintService, else IllegalArgumentException will be thrown. - *

- * If the {@code attributes} parameter contains an Attribute whose - * category is the same as the {@code category} parameter, the service - * must ignore this attribute in the AttributeSet. + * {@link Attribute Attribute}. *

- * {@code DocAttribute}s which are to be specified on the - * {@code Doc} must be included in this set to accurately - * represent the context. + * If {@code flavor} is {@code null} and {@code attributes} is {@code null} + * or is an empty set, this method returns all the printing attribute values + * this Print Service supports for any possible job. If {@code flavor} is not + * {@code null} or {@code attributes} is not an empty set, this method + * returns just the printing attribute values that are compatible with the + * given doc flavor and/or set of attributes. That is, a {@code null} return + * value may indicate that specifying this attribute is incompatible with + * the specified DocFlavor. Also if {@code DocFlavor} is not {@code null} it + * must be a flavor supported by this {@code PrintService}, else + * {@code IllegalArgumentException} will be thrown. *

- * This method returns an Object because different printing attribute - * categories indicate the supported attribute values in different ways. - * The documentation for each printing attribute in package {@link - * javax.print.attribute.standard javax.print.attribute.standard} + * If the {@code attributes} parameter contains an {@code Attribute} whose + * category is the same as the {@code category} parameter, the service must + * ignore this attribute in the {@code AttributeSet}. + *

+ * {@code DocAttribute}s which are to be specified on the {@code Doc} must + * be included in this set to accurately represent the context. + *

+ * This method returns an {@code Object} because different printing + * attribute categories indicate the supported attribute values in different + * ways. The documentation for each printing attribute in package + * {@link javax.print.attribute.standard javax.print.attribute.standard} * describes how each attribute indicates its supported values. Possible * ways of indicating support include: - *

    - *
  • - * Return a single instance of the attribute category to indicate that any - * value is legal -- used, for example, by an attribute whose value is an - * arbitrary text string. (The value of the returned attribute object is - * irrelevant.) - *
  • - * Return an array of one or more instances of the attribute category, - * containing the legal values -- used, for example, by an attribute with - * a list of enumerated values. The type of the array is an array of the - * specified attribute category type as returned by its - * {@code getCategory(Class)}. - *
  • - * Return a single object (of some class other than the attribute category) - * that indicates bounds on the legal values -- used, for example, by an - * integer-valued attribute that must lie within a certain range. - *
+ *
    + *
  • Return a single instance of the attribute category to indicate that + * any value is legal -- used, for example, by an attribute whose value is + * an arbitrary text string. (The value of the returned attribute object + * is irrelevant.) + *
  • Return an array of one or more instances of the attribute category, + * containing the legal values -- used, for example, by an attribute with + * a list of enumerated values. The type of the array is an array of the + * specified attribute category type as returned by its + * {@code getCategory(Class)}. + *
  • Return a single object (of some class other than the attribute + * category) that indicates bounds on the legal values -- used, for + * example, by an integer-valued attribute that must lie within a certain + * range. + *
* - * @param category Printing attribute category to test. It must be a - * {@link java.lang.Class Class} that implements - * interface {@link - * javax.print.attribute.Attribute Attribute}. - * @param flavor Doc flavor for a supposed job, or null. - * @param attributes Set of printing attributes for a supposed job - * (both job-level attributes and document-level - * attributes), or null. - * - * @return Object indicating supported values for {@code category}, - * or null if this Print Service does not support specifying a - * doc-level or job-level attribute in {@code category} in - * a Print Request. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code category} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code category} is not a - * {@link java.lang.Class Class} that implements interface {@link - * javax.print.attribute.Attribute Attribute}, or - * {@code DocFlavor} is not supported by this service. + * @param category printing attribute category to test. It must be a + * {@link Class Class} that implements interface + * {@link Attribute Attribute}. + * @param flavor doc flavor for a supposed job, or {@code null} + * @param attributes set of printing attributes for a supposed job (both + * job-level attributes and document-level attributes), or + * {@code null} + * @return object indicating supported values for {@code category}, or + * {@code null} if this Print Service does not support specifying a + * doc-level or job-level attribute in {@code category} in a Print + * Request + * @throws NullPointerException if {@code category} is {@code null} + * @throws IllegalArgumentException if {@code category} is not a + * {@link Class Class} that implements interface + * {@link Attribute Attribute}, or {@code DocFlavor} is not + * supported by this service */ public Object getSupportedAttributeValues(Class category, @@ -356,133 +317,121 @@ public interface PrintService { AttributeSet attributes); /** - * Determines whether a client can specify the given printing - * attribute - * value when setting up a job for this Print Service. A printing - * attribute value is an instance of a class that implements interface - * {@link javax.print.attribute.Attribute Attribute}. - *

- * If {@code flavor} is null and {@code attributes} is null or - * is an empty set, this method tells whether this Print Service supports + * Determines whether a client can specify the given printing attribute + * value when setting up a job for this Print Service. A printing attribute + * value is an instance of a class that implements interface + * {@link Attribute Attribute}. + *

+ * If {@code flavor} is {@code null} and {@code attributes} is {@code null} + * or is an empty set, this method tells whether this Print Service supports * the given printing attribute value for some possible combination of doc - * flavor and set of attributes. If {@code flavor} is not null or - * {@code attributes} is not an empty set, this method tells whether - * this Print Service supports the given printing attribute value in - * combination with the given doc flavor and/or set of attributes. + * flavor and set of attributes. If {@code flavor} is not {@code null} or + * {@code attributes} is not an empty set, this method tells whether this + * Print Service supports the given printing attribute value in combination + * with the given doc flavor and/or set of attributes. *

- * Also if DocFlavor is not null it must be a flavor supported by this - * PrintService, else IllegalArgumentException will be thrown. + * Also if {@code DocFlavor} is not {@code null} it must be a flavor + * supported by this {@code PrintService}, else + * {@code IllegalArgumentException} will be thrown. *

- * {@code DocAttribute}s which are to be specified on the - * {@code Doc} must be included in this set to accurately - * represent the context. + * {@code DocAttribute}s which are to be specified on the {@code Doc} must + * be included in this set to accurately represent the context. *

- * This is a convenience method to determine if the value - * would be a member of the result of - * {@code getSupportedAttributeValues(...)}. + * This is a convenience method to determine if the value would be a member + * of the result of {@code getSupportedAttributeValues(...)}. * - * @param attrval Printing attribute value to test. - * @param flavor Doc flavor for a supposed job, or null. - * @param attributes Set of printing attributes for a supposed job - * (both job-level attributes and document-level - * attributes), or null. - * - * @return True if this Print Service supports specifying - * {@code attrval} as a doc-level or job-level attribute in a - * Print Request, false if it doesn't. - * - * @exception NullPointerException - * (unchecked exception) if {@code attrval} is null. - * @exception IllegalArgumentException if flavor is not supported by - * this PrintService. + * @param attrval printing attribute value to test + * @param flavor doc flavor for a supposed job, or {@code null} + * @param attributes set of printing attributes for a supposed job (both + * job-level attributes and document-level attributes), or + * {@code null} + * @return {@code true} if this Print Service supports specifying + * {@code attrval} as a doc-level or job-level attribute in a Print + * Request, {@code false} if it doesn't + * @throws NullPointerException if {@code attrval} is {@code null} + * @throws IllegalArgumentException if flavor is not supported by this + * {@code PrintService} */ public boolean isAttributeValueSupported(Attribute attrval, DocFlavor flavor, AttributeSet attributes); - /** - * Identifies the attributes that are unsupported for a print request - * in the context of a particular DocFlavor. - * This method is useful for validating a potential print job and - * identifying the specific attributes which cannot be supported. - * It is important to supply only a supported DocFlavor or an - * IllegalArgumentException will be thrown. If the - * return value from this method is null, all attributes are supported. + * Identifies the attributes that are unsupported for a print request in the + * context of a particular {@code DocFlavor}. This method is useful for + * validating a potential print job and identifying the specific attributes + * which cannot be supported. It is important to supply only a supported + * {@code DocFlavor} or an {@code IllegalArgumentException} will be thrown. + * If the return value from this method is {@code null}, all attributes are + * supported. *

- * {@code DocAttribute}s which are to be specified on the - * {@code Doc} must be included in this set to accurately - * represent the context. + * {@code DocAttribute}s which are to be specified on the {@code Doc} must + * be included in this set to accurately represent the context. *

- * If the return value is non-null, all attributes in the returned - * set are unsupported with this DocFlavor. The returned set does not - * distinguish attribute categories that are unsupported from + * If the return value is {@code non-null}, all attributes in the returned + * set are unsupported with this {@code DocFlavor}. The returned set does + * not distinguish attribute categories that are unsupported from * unsupported attribute values. *

- * A supported print request can then be created by removing - * all unsupported attributes from the original attribute set, - * except in the case that the DocFlavor is unsupported. + * A supported print request can then be created by removing all unsupported + * attributes from the original attribute set, except in the case that the + * {@code DocFlavor} is unsupported. *

- * If any attributes are unsupported only because they are in conflict - * with other attributes then it is at the discretion of the service - * to select the attribute(s) to be identified as the cause of the - * conflict. + * If any attributes are unsupported only because they are in conflict with + * other attributes then it is at the discretion of the service to select + * the attribute(s) to be identified as the cause of the conflict. *

- * Use {@code isDocFlavorSupported()} to verify that a DocFlavor - * is supported before calling this method. + * Use {@code isDocFlavorSupported()} to verify that a {@code DocFlavor} is + * supported before calling this method. * - * @param flavor Doc flavor to test, or null - * @param attributes Set of printing attributes for a supposed job - * (both job-level attributes and document-level - * attributes), or null. - * - * @return null if this Print Service supports the print request - * specification, else the unsupported attributes. - * - * @exception IllegalArgumentException if {@code flavor} is - * not supported by this PrintService. + * @param flavor doc flavor to test, or {@code null} + * @param attributes set of printing attributes for a supposed job (both + * job-level attributes and document-level attributes), or + * {@code null} + * @return {@code null} if this Print Service supports the print request + * specification, else the unsupported attributes + * @throws IllegalArgumentException if {@code flavor} is not supported by + * this {@code PrintService} */ public AttributeSet getUnsupportedAttributes(DocFlavor flavor, AttributeSet attributes); /** - * Returns a factory for UI components which allow users to interact - * with the service in various roles. - * Services which do not provide any UI should return null. - * Print Services which do provide UI but want to be supported in - * an environment with no UI support should ensure that the factory - * is not initialised unless the application calls this method to - * obtain the factory. - * See {@code ServiceUIFactory} for more information. - * @return null or a factory for UI components. + * Returns a factory for UI components which allow users to interact with + * the service in various roles. Services which do not provide any UI should + * return {@code null}. Print Services which do provide UI but want to be + * supported in an environment with no UI support should ensure that the + * factory is not initialised unless the application calls this method to + * obtain the factory. See {@code ServiceUIFactory} for more information. + * + * @return {@code null} or a factory for UI components */ public ServiceUIFactory getServiceUIFactory(); /** - * Determines if two services are referring to the same underlying - * service. Objects encapsulating a print service may not exhibit - * equality of reference even though they refer to the same underlying - * service. + * Determines if two services are referring to the same underlying service. + * Objects encapsulating a print service may not exhibit equality of + * reference even though they refer to the same underlying service. *

* Clients should call this method to determine if two services are * referring to the same underlying service. *

- * Services must implement this method and return true only if the - * service objects being compared may be used interchangeably by the - * client. + * Services must implement this method and return {@code true} only if the + * service objects being compared may be used interchangeably by the client. * Services are free to return the same object reference to an underlying * service if that, but clients must not depend on equality of reference. - * @param obj the reference object with which to compare. - * @return true if this service is the same as the obj argument, - * false otherwise. + * + * @param obj the reference object with which to compare + * @return {@code true} if this service is the same as the obj argument, + * {@code false} otherwise */ public boolean equals(Object obj); /** * This method should be implemented consistently with * {@code equals(Object)}. - * @return hash code of this object. + * + * @return hash code of this object */ public int hashCode(); - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/PrintServiceLookup.java b/jdk/src/java.desktop/share/classes/javax/print/PrintServiceLookup.java index a6981a1f441..52b3fd507fe 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/PrintServiceLookup.java +++ b/jdk/src/java.desktop/share/classes/javax/print/PrintServiceLookup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,56 +23,69 @@ * questions. */ - package javax.print; import java.util.ArrayList; import java.util.Iterator; +import java.util.ServiceConfigurationError; +import java.util.ServiceLoader; + import javax.print.attribute.AttributeSet; import sun.awt.AppContext; -import java.util.ServiceLoader; -import java.util.ServiceConfigurationError; - -/** Implementations of this class provide lookup services for - * print services (typically equivalent to printers) of a particular type. - *

- * Multiple implementations may be installed concurrently. - * All implementations must be able to describe the located printers - * as instances of a PrintService. - * Typically implementations of this service class are located - * automatically in JAR files (see the SPI JAR file specification). - * These classes must be instantiable using a default constructor. - * Alternatively applications may explicitly register instances - * at runtime. - *

- * Applications use only the static methods of this abstract class. - * The instance methods are implemented by a service provider in a subclass - * and the unification of the results from all installed lookup classes - * are reported by the static methods of this class when called by - * the application. - *

- * A PrintServiceLookup implementor is recommended to check for the - * SecurityManager.checkPrintJobAccess() to deny access to untrusted code. - * Following this recommended policy means that untrusted code may not - * be able to locate any print services. Downloaded applets are the most - * common example of untrusted code. - *

- * This check is made on a per lookup service basis to allow flexibility in - * the policy to reflect the needs of different lookup services. - *

- * Services which are registered by registerService(PrintService) - * will not be included in lookup results if a security manager is - * installed and its checkPrintJobAccess() method denies access. - */ +/** + * Implementations of this class provide lookup services for print services + * (typically equivalent to printers) of a particular type. + *

+ * Multiple implementations may be installed concurrently. All implementations + * must be able to describe the located printers as instances of a + * {@code PrintService}. Typically implementations of this service class are + * located automatically in JAR files (see the SPI JAR file specification). + * These classes must be instantiable using a default constructor. Alternatively + * applications may explicitly register instances at runtime. + *

+ * Applications use only the static methods of this abstract class. The instance + * methods are implemented by a service provider in a subclass and the + * unification of the results from all installed lookup classes are reported by + * the static methods of this class when called by the application. + *

+ * A {@code PrintServiceLookup} implementor is recommended to check for the + * {@code SecurityManager.checkPrintJobAccess()} to deny access to untrusted + * code. Following this recommended policy means that untrusted code may not be + * able to locate any print services. Downloaded applets are the most common + * example of untrusted code. + *

+ * This check is made on a per lookup service basis to allow flexibility in the + * policy to reflect the needs of different lookup services. + *

+ * Services which are registered by {@link #registerService(PrintService)} will + * not be included in lookup results if a security manager is installed and its + * {@code checkPrintJobAccess()} method denies access. + */ public abstract class PrintServiceLookup { + /** + * Contains a lists of services. + */ static class Services { + + /** + * The list of lookup services. + */ private ArrayList listOfLookupServices = null; + + /** + * The list of registered services. + */ private ArrayList registeredServices = null; } + /** + * Returns the services from the current appcontext. + * + * @return the services + */ private static Services getServicesForContext() { Services services = (Services)AppContext.getAppContext().get(Services.class); @@ -83,21 +96,40 @@ public abstract class PrintServiceLookup { return services; } + /** + * Returns the list of lookup services. + * + * @return the list of lookup services + */ private static ArrayList getListOfLookupServices() { return getServicesForContext().listOfLookupServices; } + /** + * Initialize the list of lookup services. + * + * @return the list of lookup services + */ private static ArrayList initListOfLookupServices() { ArrayList listOfLookupServices = new ArrayList<>(); getServicesForContext().listOfLookupServices = listOfLookupServices; return listOfLookupServices; } - + /** + * Returns the list of registered services. + * + * @return the list of registered services + */ private static ArrayList getRegisteredServices() { return getServicesForContext().registeredServices; } + /** + * Initialize the list of registered services. + * + * @return the list of registered services + */ private static ArrayList initRegisteredServices() { ArrayList registeredServices = new ArrayList<>(); getServicesForContext().registeredServices = registeredServices; @@ -108,14 +140,13 @@ public abstract class PrintServiceLookup { * Locates print services capable of printing the specified * {@link DocFlavor}. * - * @param flavor the flavor to print. If null, this constraint is not - * used. - * @param attributes attributes that the print service must support. - * If null this constraint is not used. - * - * @return array of matching {@code PrintService} objects - * representing print services that support the specified flavor - * attributes. If no services match, the array is zero-length. + * @param flavor the flavor to print. If {@code null}, this constraint is + * not used. + * @param attributes attributes that the print service must support. If + * {@code null} this constraint is not used. + * @return array of matching {@code PrintService} objects representing print + * services that support the specified flavor attributes. If no + * services match, the array is zero-length. */ public static final PrintService[] lookupPrintServices(DocFlavor flavor, @@ -124,26 +155,23 @@ public abstract class PrintServiceLookup { return list.toArray(new PrintService[list.size()]); } - /** - * Locates MultiDoc print Services capable of printing MultiDocs - * containing all the specified doc flavors. - *

This method is useful to help locate a service that can print - * a {@code MultiDoc} in which the elements may be different - * flavors. An application could perform this itself by multiple lookups - * on each {@code DocFlavor} in turn and collating the results, - * but the lookup service may be able to do this more efficiently. - * - * @param flavors the flavors to print. If null or empty this - * constraint is not used. - * Otherwise return only multidoc print services that can print all - * specified doc flavors. - * @param attributes attributes that the print service must - * support. If null this constraint is not used. - * - * @return array of matching {@link MultiDocPrintService} objects. - * If no services match, the array is zero-length. + * Locates {@code MultiDoc} print {@code Services} capable of printing + * {@code MultiDocs} containing all the specified doc flavors. + *

+ * This method is useful to help locate a service that can print a + * {@code MultiDoc} in which the elements may be different flavors. An + * application could perform this itself by multiple lookups on each + * {@code DocFlavor} in turn and collating the results, but the lookup + * service may be able to do this more efficiently. * + * @param flavors the flavors to print. If {@code null} or empty this + * constraint is not used. Otherwise return only multidoc print + * services that can print all specified doc flavors. + * @param attributes attributes that the print service must support. If + * {@code null} this constraint is not used. + * @return array of matching {@link MultiDocPrintService} objects. If no + * services match, the array is zero-length. */ public static final MultiDocPrintService[] lookupMultiDocPrintServices(DocFlavor[] flavors, @@ -152,28 +180,23 @@ public abstract class PrintServiceLookup { return list.toArray(new MultiDocPrintService[list.size()]); } - /** - * Locates the default print service for this environment. - * This may return null. - * If multiple lookup services each specify a default, the - * chosen service is not precisely defined, but a - * platform native service, rather than an installed service, - * is usually returned as the default. If there is no clearly - * identifiable - * platform native default print service, the default is the first - * to be located in an implementation-dependent manner. + * Locates the default print service for this environment. This may return + * {@code null}. If multiple lookup services each specify a default, the + * chosen service is not precisely defined, but a platform native service, + * rather than an installed service, is usually returned as the default. If + * there is no clearly identifiable platform native default print service, + * the default is the first to be located in an implementation-dependent + * manner. *

- * This may include making use of any preferences API that is available - * as part of the Java or native platform. - * This algorithm may be overridden by a user setting the property - * javax.print.defaultPrinter. - * A service specified must be discovered to be valid and currently - * available to be returned as the default. + * This may include making use of any preferences API that is available as + * part of the Java or native platform. This algorithm may be overridden by + * a user setting the property {@code javax.print.defaultPrinter}. A service + * specified must be discovered to be valid and currently available to be + * returned as the default. * - * @return the default PrintService. + * @return the default {@code PrintService} */ - public static final PrintService lookupDefaultPrintService() { Iterator psIterator = getAllLookupServices().iterator(); @@ -190,19 +213,16 @@ public abstract class PrintServiceLookup { return null; } - /** - * Allows an application to explicitly register a class that - * implements lookup services. The registration will not persist - * across VM invocations. - * This is useful if an application needs to make a new service - * available that is not part of the installation. - * If the lookup service is already registered, or cannot be registered, - * the method returns false. + * Allows an application to explicitly register a class that implements + * lookup services. The registration will not persist across VM invocations. + * This is useful if an application needs to make a new service available + * that is not part of the installation. If the lookup service is already + * registered, or cannot be registered, the method returns {@code false}. * - * @param sp an implementation of a lookup service. - * @return {@code true} if the new lookup service is newly - * registered; {@code false} otherwise. + * @param sp an implementation of a lookup service + * @return {@code true} if the new lookup service is newly registered; + * {@code false} otherwise */ public static boolean registerServiceProvider(PrintServiceLookup sp) { synchronized (PrintServiceLookup.class) { @@ -220,29 +240,24 @@ public abstract class PrintServiceLookup { getListOfLookupServices().add(sp); return true; } - } - /** - * Allows an application to directly register an instance of a - * class which implements a print service. - * The lookup operations for this service will be - * performed by the PrintServiceLookup class using the attribute - * values and classes reported by the service. - * This may be less efficient than a lookup - * service tuned for that service. - * Therefore registering a {@code PrintServiceLookup} instance - * instead is recommended. - * The method returns true if this service is not previously - * registered and is now successfully registered. - * This method should not be called with StreamPrintService instances. - * They will always fail to register and the method will return false. - * @param service an implementation of a print service. - * @return {@code true} if the service is newly - * registered; {@code false} otherwise. + * Allows an application to directly register an instance of a class which + * implements a print service. The lookup operations for this service will + * be performed by the {@code PrintServiceLookup} class using the attribute + * values and classes reported by the service. This may be less efficient + * than a lookup service tuned for that service. Therefore registering a + * {@code PrintServiceLookup} instance instead is recommended. The method + * returns {@code true} if this service is not previously registered and is + * now successfully registered. This method should not be called with + * {@code StreamPrintService} instances. They will always fail to register + * and the method will return {@code false}. + * + * @param service an implementation of a print service + * @return {@code true} if the service is newly registered; {@code false} + * otherwise */ - public static boolean registerService(PrintService service) { synchronized (PrintServiceLookup.class) { if (service == null || service instanceof StreamPrintService) { @@ -262,68 +277,72 @@ public abstract class PrintServiceLookup { } } - - /** - * Locates services that can be positively confirmed to support - * the combination of attributes and DocFlavors specified. - * This method is not called directly by applications. - *

- * Implemented by a service provider, used by the static methods - * of this class. - *

- * The results should be the same as obtaining all the PrintServices - * and querying each one individually on its support for the - * specified attributes and flavors, but the process can be more - * efficient by taking advantage of the capabilities of lookup services - * for the print services. - * - * @param flavor of document required. If null it is ignored. - * @param attributes required to be supported. If null this - * constraint is not used. - * @return array of matching PrintServices. If no services match, the - * array is zero-length. - */ + /** + * Locates services that can be positively confirmed to support the + * combination of attributes and {@code DocFlavors} specified. This method + * is not called directly by applications. + *

+ * Implemented by a service provider, used by the static methods of this + * class. + *

+ * The results should be the same as obtaining all the {@code PrintServices} + * and querying each one individually on its support for the specified + * attributes and flavors, but the process can be more efficient by taking + * advantage of the capabilities of lookup services for the print services. + * + * @param flavor of document required. If {@code null} it is ignored. + * @param attributes required to be supported. If {@code null} this + * constraint is not used. + * @return array of matching {@code PrintServices}. If no services match, + * the array is zero-length. + */ public abstract PrintService[] getPrintServices(DocFlavor flavor, AttributeSet attributes); /** - * Not called directly by applications. - * Implemented by a service provider, used by the static methods - * of this class. - * @return array of all PrintServices known to this lookup service - * class. If none are found, the array is zero-length. + * Not called directly by applications. Implemented by a service provider, + * used by the static methods of this class. + * + * @return array of all {@code PrintServices} known to this lookup service + * class. If none are found, the array is zero-length. */ public abstract PrintService[] getPrintServices() ; - - /** - * Not called directly by applications. - *

- * Implemented by a service provider, used by the static methods - * of this class. - *

- * Locates MultiDoc print services which can be positively confirmed - * to support the combination of attributes and DocFlavors specified. - * - * @param flavors of documents required. If null or empty it is ignored. - * @param attributes required to be supported. If null this - * constraint is not used. - * @return array of matching PrintServices. If no services match, the - * array is zero-length. - */ + /** + * Not called directly by applications. + *

+ * Implemented by a service provider, used by the static methods of this + * class. + *

+ * Locates {@code MultiDoc} print services which can be positively confirmed + * to support the combination of attributes and {@code DocFlavors} + * specified. + * + * @param flavors of documents required. If {@code null} or empty it is + * ignored. + * @param attributes required to be supported. If {@code null} this + * constraint is not used. + * @return array of matching {@code PrintServices}. If no services match, + * the array is zero-length. + */ public abstract MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors, AttributeSet attributes); /** - * Not called directly by applications. - * Implemented by a service provider, and called by the print lookup - * service - * @return the default PrintService for this lookup service. - * If there is no default, returns null. + * Not called directly by applications. Implemented by a service provider, + * and called by the print lookup service. + * + * @return the default {@code PrintService} for this lookup service. If + * there is no default, returns {@code null}. */ public abstract PrintService getDefaultPrintService(); + /** + * Returns all lookup services for this environment. + * + * @return all lookup services for this environment + */ private static ArrayList getAllLookupServices() { synchronized (PrintServiceLookup.class) { ArrayList listOfLookupServices = getListOfLookupServices(); @@ -362,6 +381,18 @@ public abstract class PrintServiceLookup { } } + /** + * Locates print services capable of printing the specified + * {@link DocFlavor}. + * + * @param flavor the flavor to print. If {@code null}, this constraint is + * not used. + * @param attributes attributes that the print service must support. If + * {@code null} this constraint is not used. + * @return list of matching {@code PrintService} objects representing print + * services that support the specified flavor attributes. If no + * services match, the empty list is returned. + */ private static ArrayList getServices(DocFlavor flavor, AttributeSet attributes) { @@ -388,7 +419,9 @@ public abstract class PrintServiceLookup { } catch (Exception e) { } } - /* add any directly registered services */ + /* + * add any directly registered services + */ ArrayList registeredServices = null; try { SecurityManager security = System.getSecurityManager(); @@ -418,6 +451,18 @@ public abstract class PrintServiceLookup { return listOfServices; } + /** + * Locates {@code MultiDoc} print {@code Services} capable of printing + * {@code MultiDocs} containing all the specified doc flavors. + * + * @param flavors the flavors to print. If {@code null} or empty this + * constraint is not used. Otherwise return only multidoc print + * services that can print all specified doc flavors. + * @param attributes attributes that the print service must support. If + * {@code null} this constraint is not used. + * @return list of matching {@link MultiDocPrintService} objects. If no + * services match, the empty list is returned. + */ private static ArrayList getMultiDocServices(DocFlavor[] flavors, AttributeSet attributes) { @@ -438,7 +483,9 @@ public abstract class PrintServiceLookup { } catch (Exception e) { } } - /* add any directly registered services */ + /* + * add any directly registered services + */ ArrayList registeredServices = null; try { SecurityManager security = System.getSecurityManager(); @@ -480,5 +527,4 @@ public abstract class PrintServiceLookup { } return listOfServices; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java b/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java index 615de409bdf..eca9faadc53 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java +++ b/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -25,99 +25,93 @@ package javax.print; -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; -import java.awt.GraphicsEnvironment; -import java.awt.HeadlessException; import java.awt.Dialog; import java.awt.Frame; -import java.awt.Point; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsEnvironment; +import java.awt.HeadlessException; import java.awt.Rectangle; import java.awt.Window; -import java.awt.KeyboardFocusManager; + import javax.print.attribute.Attribute; import javax.print.attribute.AttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.Fidelity; -import sun.print.DialogOwner; +import sun.print.DialogOwner; import sun.print.ServiceDialog; import sun.print.SunAlternateMedia; -/** This class is a collection of UI convenience methods which provide a +/** + * This class is a collection of UI convenience methods which provide a * graphical user dialog for browsing print services looked up through the Java * Print Service API. *

* The dialogs follow a standard pattern of acting as a continue/cancel option - *for a user as well as allowing the user to select the print service to use - *and specify choices such as paper size and number of copies. + * for a user as well as allowing the user to select the print service to use + * and specify choices such as paper size and number of copies. *

* The dialogs are designed to work with pluggable print services though the * public APIs of those print services. *

* If a print service provides any vendor extensions these may be made - * accessible to the user through a vendor supplied tab panel Component. + * accessible to the user through a vendor supplied tab panel {@code Component}. * Such a vendor extension is encouraged to use Swing! and to support its - * accessibility APIs. - * The vendor extensions should return the settings as part of the - * AttributeSet. - * Applications which want to preserve the user settings should use those - * settings to specify the print job. - * Note that this class is not referenced by any other part of the Java - * Print Service and may not be included in profiles which cannot depend - * on the presence of the AWT packages. + * accessibility APIs. The vendor extensions should return the settings as part + * of the {@code AttributeSet}. Applications which want to preserve the user + * settings should use those settings to specify the print job. Note that this + * class is not referenced by any other part of the Java Print Service and may + * not be included in profiles which cannot depend on the presence of the AWT + * packages. */ - public class ServiceUI { - /** - * Presents a dialog to the user for selecting a print service (printer). - * It is displayed at the location specified by the application and - * is modal. + * Presents a dialog to the user for selecting a print service (printer). It + * is displayed at the location specified by the application and is modal. * If the specification is invalid or would make the dialog not visible it - * will be displayed at a location determined by the implementation. - * The dialog blocks its calling thread and is application modal. + * will be displayed at a location determined by the implementation. The + * dialog blocks its calling thread and is application modal. *

* The dialog may include a tab panel with custom UI lazily obtained from - * the PrintService's ServiceUIFactory when the PrintService is browsed. - * The dialog will attempt to locate a MAIN_UIROLE first as a JComponent, - * then as a Panel. If there is no ServiceUIFactory or no matching role - * the custom tab will be empty or not visible. + * the {@code PrintService}'s {@code ServiceUIFactory} when the + * {@code PrintService} is browsed. The dialog will attempt to locate a + * {@code MAIN_UIROLE} first as a {@code JComponent}, then as a + * {@code Panel}. If there is no {@code ServiceUIFactory} or no matching + * role the custom tab will be empty or not visible. *

* The dialog returns the print service selected by the user if the user - * OK's the dialog and null if the user cancels the dialog. + * OK's the dialog and {@code null} if the user cancels the dialog. *

- * An application must pass in an array of print services to browse. - * The array must be non-null and non-empty. - * Typically an application will pass in only PrintServices capable - * of printing a particular document flavor. + * An application must pass in an array of print services to browse. The + * array must be {@code non-null} and non-empty. Typically an application + * will pass in only {@code PrintServices} capable of printing a particular + * document flavor. *

- * An application may pass in a PrintService to be initially displayed. - * A non-null parameter must be included in the array of browsable - * services. - * If this parameter is null a service is chosen by the implementation. + * An application may pass in a {@code PrintService} to be initially + * displayed. A {@code non-null} parameter must be included in the array of + * browsable services. If this parameter is {@code null} a service is chosen + * by the implementation. *

- * An application may optionally pass in the flavor to be printed. - * If this is non-null choices presented to the user can be better - * validated against those supported by the services. - * An application must pass in a PrintRequestAttributeSet for returning - * user choices. - * On calling the PrintRequestAttributeSet may be empty, or may contain + * An application may optionally pass in the flavor to be printed. If this + * is {@code non-null} choices presented to the user can be better validated + * against those supported by the services. An application must pass in a + * {@code PrintRequestAttributeSet} for returning user choices. On calling + * the {@code PrintRequestAttributeSet} may be empty, or may contain * application-specified values. *

- * These are used to set the initial settings for the initially - * displayed print service. Values which are not supported by the print - * service are ignored. As the user browses print services, attributes - * and values are copied to the new display. If a user browses a - * print service which does not support a particular attribute-value, the - * default for that service is used as the new value to be copied. + * These are used to set the initial settings for the initially displayed + * print service. Values which are not supported by the print service are + * ignored. As the user browses print services, attributes and values are + * copied to the new display. If a user browses a print service which does + * not support a particular attribute-value, the default for that service is + * used as the new value to be copied. *

* If the user cancels the dialog, the returned attributes will not reflect * any changes made by the user. - * - * A typical basic usage of this method may be : + *

+ * A typical basic usage of this method may be: *

{@code
      * PrintService[] services = PrintServiceLookup.lookupPrintServices(
      *                            DocFlavor.INPUT_STREAM.JPEG, null);
@@ -133,24 +127,25 @@ public class ServiceUI {
      * }
      * }
* - * @param gc used to select screen. null means primary or default screen. - * @param x location of dialog including border in screen coordinates - * relative to the origin of {@code gc}. - * @param y location of dialog including border in screen coordinates - * relative to the origin of {@code gc}. - * @param services to be browsable, must be non-null. - * @param defaultService initial PrintService to display. - * @param flavor the flavor to be printed, or null. - * @param attributes on input is the initial application supplied - * preferences. This cannot be null but may be empty. - * On output the attributes reflect changes made by the user. - * @return print service selected by the user, or null if the user - * cancelled the dialog. - * @throws HeadlessException if GraphicsEnvironment.isHeadless() - * returns true. - * @throws IllegalArgumentException if services is null or empty, - * or attributes is null, or the initial PrintService is not in the - * list of browsable services. + * @param gc used to select screen, {@code null} means primary or default + * screen + * @param x location of dialog including border in screen coordinates + * relative to the origin of {@code gc} + * @param y location of dialog including border in screen coordinates + * relative to the origin of {@code gc} + * @param services to be browsable, must be {@code non-null} + * @param defaultService initial {@code PrintService} to display + * @param flavor the flavor to be printed, or {@code null} + * @param attributes on input is the initial application supplied + * preferences. This cannot be {@code null} but may be empty. On + * output the attributes reflect changes made by the user. + * @return print service selected by the user, or {@code null} if the user + * cancelled the dialog + * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()} + * returns {@code true} + * @throws IllegalArgumentException if services is {@code null} or empty, or + * attributes is {@code null}, or the initial {@code PrintService} + * is not in the list of browsable services */ @SuppressWarnings("deprecation") public static PrintService printDialog(GraphicsConfiguration gc, @@ -220,8 +215,8 @@ public class ServiceUI { // check if dialog exceed window bounds at left or bottom // Then position the dialog by moving it by the amount it exceeds // the window bounds - // If it results in dialog moving beyond the window bounds at top/left - // then position it at window top/left + // If it results in dialog moving beyond the window bounds at + // top/left then position it at window top/left if (dlgBounds.x + dlgBounds.width > gcBounds.x + gcBounds.width) { if ((gcBounds.x + gcBounds.width - dlgBounds.width) > gcBounds.x) { x = (gcBounds.x + gcBounds.width) - dlgBounds.width; @@ -315,8 +310,8 @@ public class ServiceUI { */ /** - * Removes any attributes from the given AttributeSet that are - * unsupported by the given PrintService/DocFlavor combination. + * Removes any attributes from the given {@code AttributeSet} that are + * unsupported by the given {@code PrintService/DocFlavor} combination. */ private static void removeUnsupportedAttributes(PrintService ps, DocFlavor flavor, diff --git a/jdk/src/java.desktop/share/classes/javax/print/ServiceUIFactory.java b/jdk/src/java.desktop/share/classes/javax/print/ServiceUIFactory.java index 06deb02e5e8..918cf0155ff 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/ServiceUIFactory.java +++ b/jdk/src/java.desktop/share/classes/javax/print/ServiceUIFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -26,21 +26,20 @@ package javax.print; /** - * Services may optionally provide UIs which allow different styles - * of interaction in different roles. - * One role may be end-user browsing and setting of print options. - * Another role may be administering the print service. + * Services may optionally provide UIs which allow different styles of + * interaction in different roles. One role may be end-user browsing and setting + * of print options. Another role may be administering the print service. *

* Although the Print Service API does not presently provide standardised - * support for administering a print service, monitoring of the print - * service is possible and a UI may provide for private update mechanisms. + * support for administering a print service, monitoring of the print service is + * possible and a UI may provide for private update mechanisms. *

* The basic design intent is to allow applications to lazily locate and - * initialize services only when needed without any API dependencies - * except in an environment in which they are used. + * initialize services only when needed without any API dependencies except in + * an environment in which they are used. *

- * Swing UIs are preferred as they provide a more consistent {@literal L&F} - * and can support accessibility APIs. + * Swing UIs are preferred as they provide a more consistent {@literal L&F} and + * can support accessibility APIs. *

* Example usage: *

@@ -55,34 +54,29 @@ package javax.print;
  *  }
  * 
*/ - public abstract class ServiceUIFactory { /** - * Denotes a UI implemented as a Swing component. - * The value of the String is the fully qualified classname : - * "javax.swing.JComponent". + * Denotes a UI implemented as a Swing component. The value of the string is + * the fully qualified classname : "javax.swing.JComponent". */ public static final String JCOMPONENT_UI = "javax.swing.JComponent"; /** - * Denotes a UI implemented as an AWT panel. - * The value of the String is the fully qualified classname : - * "java.awt.Panel" + * Denotes a UI implemented as an AWT panel. The value of the string is the + * fully qualified classname : "java.awt.Panel" */ public static final String PANEL_UI = "java.awt.Panel"; /** - * Denotes a UI implemented as an AWT dialog. - * The value of the String is the fully qualified classname : - * "java.awt.Dialog" + * Denotes a UI implemented as an AWT dialog. The value of the string is the + * fully qualified classname : "java.awt.Dialog" */ public static final String DIALOG_UI = "java.awt.Dialog"; /** - * Denotes a UI implemented as a Swing dialog. - * The value of the String is the fully qualified classname : - * "javax.swing.JDialog" + * Denotes a UI implemented as a Swing dialog. The value of the string is + * the fully qualified classname : "javax.swing.JDialog" */ public static final String JDIALOG_UI = "javax.swing.JDialog"; @@ -102,41 +96,38 @@ public abstract class ServiceUIFactory { public static final int MAIN_UIROLE = 3; /** - * Not a valid role but role id's greater than this may be used - * for private roles supported by a service. Knowledge of the - * function performed by this role is required to make proper use - * of it. + * Not a valid role but role id's greater than this may be used for private + * roles supported by a service. Knowledge of the function performed by this + * role is required to make proper use of it. */ public static final int RESERVED_UIROLE = 99; + /** - * Get a UI object which may be cast to the requested UI type - * by the application and used in its user interface. + * Get a UI object which may be cast to the requested UI type by the + * application and used in its user interface. * - * @param role requested. Must be one of the standard roles or - * a private role supported by this factory. - * @param ui type in which the role is requested. - * @return the UI role or null if the requested UI role is not available - * from this factory - * @throws IllegalArgumentException if the role or ui is neither - * one of the standard ones, nor a private one - * supported by the factory. + * @param role requested. Must be one of the standard roles or a private + * role supported by this factory. + * @param ui type in which the role is requested + * @return the UI role or {@code null} if the requested UI role is not + * available from this factory + * @throws IllegalArgumentException if the role or ui is neither one of the + * standard ones, nor a private one supported by the factory */ public abstract Object getUI(int role, String ui) ; /** - * Given a UI role obtained from this factory obtain the UI - * types available from this factory which implement this role. - * The returned Strings should refer to the static variables defined - * in this class so that applications can use equality of reference - * ("=="). - * @param role to be looked up. + * Given a UI role obtained from this factory obtain the UI types available + * from this factory which implement this role. The returned {@code Strings} + * should refer to the static variables defined in this class so that + * applications can use equality of reference ("=="). + * + * @param role to be looked up * @return the UI types supported by this class for the specified role, - * null if no UIs are available for the role. - * @throws IllegalArgumentException is the role is a non-standard - * role not supported by this factory. + * {@code null} if no UIs are available for the role + * @throws IllegalArgumentException is the role is a non-standard role not + * supported by this factory */ public abstract String[] getUIClassNamesForRole(int role) ; - - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/SimpleDoc.java b/jdk/src/java.desktop/share/classes/javax/print/SimpleDoc.java index dfe8dc4a470..5a42fc9b472 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/SimpleDoc.java +++ b/jdk/src/java.desktop/share/classes/javax/print/SimpleDoc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -27,60 +27,76 @@ package javax.print; import java.io.ByteArrayInputStream; import java.io.CharArrayReader; -import java.io.StringReader; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.io.Reader; +import java.io.StringReader; + import javax.print.attribute.AttributeSetUtilities; import javax.print.attribute.DocAttributeSet; /** - * This class is an implementation of interface {@code Doc} that can - * be used in many common printing requests. - * It can handle all of the presently defined "pre-defined" doc flavors - * defined as static variables in the DocFlavor class. + * This class is an implementation of interface {@code Doc} that can be used in + * many common printing requests. It can handle all of the presently defined + * "pre-defined" doc flavors defined as static variables in the + * {@code DocFlavor} class. *

* In particular this class implements certain required semantics of the - * Doc specification as follows: + * {@code Doc} specification as follows: *

    - *
  • constructs a stream for the service if requested and appropriate. - *
  • ensures the same object is returned for each call on a method. - *
  • ensures multiple threads can access the Doc - *
  • performs some validation of that the data matches the doc flavor. + *
  • constructs a stream for the service if requested and appropriate. + *
  • ensures the same object is returned for each call on a method. + *
  • ensures multiple threads can access the {@code Doc} + *
  • performs some validation of that the data matches the doc flavor. *
- * Clients who want to re-use the doc object in other jobs, - * or need a MultiDoc will not want to use this class. + * Clients who want to re-use the doc object in other jobs, or need a + * {@code MultiDoc} will not want to use this class. *

- * If the print data is a stream, or a print job requests data as a - * stream, then {@code SimpleDoc} does not monitor if the service - * properly closes the stream after data transfer completion or job - * termination. - * Clients may prefer to use provide their own implementation of doc that - * adds a listener to monitor job completion and to validate that - * resources such as streams are freed (ie closed). + * If the print data is a stream, or a print job requests data as a stream, then + * {@code SimpleDoc} does not monitor if the service properly closes the stream + * after data transfer completion or job termination. Clients may prefer to use + * provide their own implementation of doc that adds a listener to monitor job + * completion and to validate that resources such as streams are freed (ie + * closed). */ - public final class SimpleDoc implements Doc { + /** + * The doc flavor in which this doc will supply its piece of print data. + */ private DocFlavor flavor; + + /** + * The set of printing attributes for this doc. + */ private DocAttributeSet attributes; + + /** + * The print data. + */ private Object printData; + + /** + * The reader for extracting character print data from this doc. + */ private Reader reader; + + /** + * The input stream for extracting byte print data from this doc. + */ private InputStream inStream; /** - * Constructs a {@code SimpleDoc} with the specified - * print data, doc flavor and doc attribute set. - * @param printData the print data object - * @param flavor the {@code DocFlavor} object - * @param attributes a {@code DocAttributeSet}, which can - * be {@code null} - * @throws IllegalArgumentException if {@code flavor} or - * {@code printData} is {@code null}, or the - * {@code printData} does not correspond - * to the specified doc flavor--for example, the data is - * not of the type specified as the representation in the - * {@code DocFlavor}. + * Constructs a {@code SimpleDoc} with the specified print data, doc flavor + * and doc attribute set. + * + * @param printData the print data object + * @param flavor the {@code DocFlavor} object + * @param attributes a {@code DocAttributeSet}, which can be {@code null} + * @throws IllegalArgumentException if {@code flavor} or {@code printData} + * is {@code null}, or the {@code printData} does not correspond to + * the specified doc flavor--for example, the data is not of the + * type specified as the representation in the {@code DocFlavor} */ public SimpleDoc(Object printData, DocFlavor flavor, DocAttributeSet attributes) { @@ -110,11 +126,11 @@ public final class SimpleDoc implements Doc { this.printData = printData; } - /** - * Determines the doc flavor in which this doc object will supply its - * piece of print data. + /** + * Determines the doc flavor in which this doc object will supply its piece + * of print data. * - * @return Doc flavor. + * @return doc flavor */ public DocFlavor getDocFlavor() { return flavor; @@ -123,67 +139,60 @@ public final class SimpleDoc implements Doc { /** * Obtains the set of printing attributes for this doc object. If the * returned attribute set includes an instance of a particular attribute - * X, the printer must use that attribute value for this doc, - * overriding any value of attribute X in the job's attribute set. - * If the returned attribute set does not include an instance - * of a particular attribute X or if null is returned, the printer - * must consult the job's attribute set to obtain the value for - * attribute X, and if not found there, the printer must use an + * X, the printer must use that attribute value for this doc, + * overriding any value of attribute X in the job's attribute set. If + * the returned attribute set does not include an instance of a particular + * attribute X or if {@code null} is returned, the printer must + * consult the job's attribute set to obtain the value for attribute + * X, and if not found there, the printer must use an * implementation-dependent default value. The returned attribute set is * unmodifiable. * - * @return Unmodifiable set of printing attributes for this doc, or null - * to obtain all attribute values from the job's attribute - * set. + * @return unmodifiable set of printing attributes for this doc, or + * {@code null} to obtain all attribute values from the job's + * attribute set */ public DocAttributeSet getAttributes() { return attributes; } - /* + /** * Obtains the print data representation object that contains this doc - * object's piece of print data in the format corresponding to the - * supported doc flavor. - * The {@code getPrintData()} method returns an instance of - * the representation class whose name is given by - * {@link DocFlavor#getRepresentationClassName() getRepresentationClassName}, - * and the return value can be cast - * from class Object to that representation class. + * object's piece of print data in the format corresponding to the supported + * doc flavor. The {@code getPrintData()} method returns an instance of the + * representation class whose name is given by {@link #getDocFlavor() + * getDocFlavor()}.{@link DocFlavor#getRepresentationClassName() + * getRepresentationClassName()}, and the return value can be cast from + * class {@code Object} to that representation class. * - * @return Print data representation object. - * - * @exception IOException if the representation class is a stream and - * there was an I/O error while constructing the stream. + * @return print data representation object + * @throws IOException if the representation class is a stream and there was + * an I/O error while constructing the stream */ public Object getPrintData() throws IOException { return printData; } /** - * Obtains a reader for extracting character print data from this doc. - * The {@code Doc} implementation is required to support this - * method if the {@code DocFlavor} has one of the following print - * data representation classes, and return {@code null} - * otherwise: - *

    - *
  • {@code char[]} - *
  • {@code java.lang.String} - *
  • {@code java.io.Reader} - *
+ * Obtains a reader for extracting character print data from this doc. The + * {@code Doc} implementation is required to support this method if the + * {@code DocFlavor} has one of the following print data representation + * classes, and return {@code null} otherwise: + *
    + *
  • {@code char[]} + *
  • {@code java.lang.String} + *
  • {@code java.io.Reader} + *
* The doc's print data representation object is used to construct and - * return a {@code Reader} for reading the print data as a stream - * of characters from the print data representation object. - * However, if the print data representation object is itself a - * {@code Reader} then the print data representation object is - * simply returned. + * return a {@code Reader} for reading the print data as a stream of + * characters from the print data representation object. However, if the + * print data representation object is itself a {@code Reader} then the + * print data representation object is simply returned. * - * @return a {@code Reader} for reading the print data - * characters from this doc. - * If a reader cannot be provided because this doc does not meet - * the criteria stated above, {@code null} is returned. - * - * @exception IOException if there was an I/O error while creating - * the reader. + * @return a {@code Reader} for reading the print data characters from this + * doc. If a reader cannot be provided because this doc does not + * meet the criteria stated above, {@code null} is returned. + * @throws IOException if there was an I/O error while creating the reader */ public Reader getReaderForText() throws IOException { @@ -207,31 +216,25 @@ public final class SimpleDoc implements Doc { } /** - * Obtains an input stream for extracting byte print data from - * this doc. - * The {@code Doc} implementation is required to support this - * method if the {@code DocFlavor} has one of the following print - * data representation classes; otherwise this method - * returns {@code null}: - *
    - *
  • {@code byte[]} - *
  • {@code java.io.InputStream} - *
- * The doc's print data representation object is obtained. Then, an - * input stream for reading the print data - * from the print data representation object as a stream of bytes is - * created and returned. - * However, if the print data representation object is itself an - * input stream then the print data representation object is simply - * returned. + * Obtains an input stream for extracting byte print data from this doc. The + * {@code Doc} implementation is required to support this method if the + * {@code DocFlavor} has one of the following print data representation + * classes; otherwise this method returns {@code null}: + *
    + *
  • {@code byte[]} + *
  • {@code java.io.InputStream} + *
+ * The doc's print data representation object is obtained. Then, an input + * stream for reading the print data from the print data representation + * object as a stream of bytes is created and returned. However, if the + * print data representation object is itself an input stream then the print + * data representation object is simply returned. * - * @return an {@code InputStream} for reading the print data - * bytes from this doc. If an input stream cannot be - * provided because this doc does not meet - * the criteria stated above, {@code null} is returned. - * - * @exception IOException - * if there was an I/O error while creating the input stream. + * @return an {@code InputStream} for reading the print data bytes from this + * doc. If an input stream cannot be provided because this doc does + * not meet the criteria stated above, {@code null} is returned. + * @throws IOException if there was an I/O error while creating the input + * stream */ public InputStream getStreamForBytes() throws IOException { @@ -250,5 +253,4 @@ public final class SimpleDoc implements Doc { } return inStream; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/StreamPrintService.java b/jdk/src/java.desktop/share/classes/javax/print/StreamPrintService.java index a735d542a58..5be233c47ad 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/StreamPrintService.java +++ b/jdk/src/java.desktop/share/classes/javax/print/StreamPrintService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -28,43 +28,47 @@ package javax.print; import java.io.OutputStream; /** - * This class extends {@link PrintService} and represents a - * print service that prints data in different formats to a - * client-provided output stream. - * This is principally intended for services where - * the output format is a document type suitable for viewing - * or archiving. - * The output format must be declared as a mime type. - * This is equivalent to an output document flavor where the - * representation class is always "java.io.OutputStream" - * An instance of the {@code StreamPrintService} class is - * obtained from a {@link StreamPrintServiceFactory} instance. + * This class extends {@link PrintService} and represents a print service that + * prints data in different formats to a client-provided output stream. This is + * principally intended for services where the output format is a document type + * suitable for viewing or archiving. The output format must be declared as a + * mime type. This is equivalent to an output document flavor where the + * representation class is always "java.io.OutputStream" An instance of the + * {@code StreamPrintService} class is obtained from a + * {@link StreamPrintServiceFactory} instance. *

* Note that a {@code StreamPrintService} is different from a * {@code PrintService}, which supports a - * {@link javax.print.attribute.standard.Destination Destination} - * attribute. A {@code StreamPrintService} always requires an output - * stream, whereas a {@code PrintService} optionally accepts a - * {@code Destination}. A {@code StreamPrintService} - * has no default destination for its formatted output. - * Additionally a {@code StreamPrintService} is expected to generate -output in - * a format useful in other contexts. - * StreamPrintService's are not expected to support the Destination attribute. + * {@link javax.print.attribute.standard.Destination Destination} attribute. A + * {@code StreamPrintService} always requires an output stream, whereas a + * {@code PrintService} optionally accepts a {@code Destination}. A + * {@code StreamPrintService} has no default destination for its formatted + * output. Additionally a {@code StreamPrintService} is expected to generate + * output in a format useful in other contexts. {@code StreamPrintService}'s are + * not expected to support the {@code Destination} attribute. */ - public abstract class StreamPrintService implements PrintService { + /** + * The output stream to which this service will send formatted print data. + */ private OutputStream outStream; + + /** + * Whether or not this {@code StreamPrintService} has been disposed. + */ private boolean disposed = false; + /** + * Constructs a {@code StreamPrintService} object. + */ private StreamPrintService() { }; /** - * Constructs a StreamPrintService object. + * Constructs a {@code StreamPrintService} object. * - * @param out stream to which to send formatted print data. + * @param out stream to which to send formatted print data */ protected StreamPrintService(OutputStream out) { this.outStream = out; @@ -73,42 +77,44 @@ public abstract class StreamPrintService implements PrintService { /** * Gets the output stream. * - * @return the stream to which this service will send formatted print data. + * @return the stream to which this service will send formatted print data */ public OutputStream getOutputStream() { return outStream; } /** - * Returns the document format emitted by this print service. - * Must be in mimetype format, compatible with the mime type - * components of DocFlavors @see DocFlavor. - * @return mime type identifying the output format. + * Returns the document format emitted by this print service. Must be in + * mimetype format, compatible with the mime type components of + * {@code DocFlavors} + * + * @return mime type identifying the output format + * @see DocFlavor */ public abstract String getOutputFormat(); /** - * Disposes this {@code StreamPrintService}. - * If a stream service cannot be re-used, it must be disposed - * to indicate this. Typically the client will call this method. - * Services which write data which cannot meaningfully be appended to - * may also dispose the stream. This does not close the stream. It - * just marks it as not for further use by this service. + * Disposes this {@code StreamPrintService}. If a stream service cannot be + * re-used, it must be disposed to indicate this. Typically the client will + * call this method. Services which write data which cannot meaningfully be + * appended to may also dispose the stream. This does not close the stream. + * It just marks it as not for further use by this service. */ public void dispose() { disposed = true; } /** - * Returns a {@code boolean} indicating whether or not - * this {@code StreamPrintService} has been disposed. - * If this object has been disposed, will return true. - * Used by services and client applications to recognize streams - * to which no further data should be written. - * @return if this {@code StreamPrintService} has been disposed + * Returns a {@code boolean} indicating whether or not this + * {@code StreamPrintService} has been disposed. If this object has been + * disposed, will return {@code true}. Used by services and client + * applications to recognize streams to which no further data should be + * written. + * + * @return {@code true} if this {@code StreamPrintService} has been + * disposed; {@code false} otherwise */ public boolean isDisposed() { return disposed; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/StreamPrintServiceFactory.java b/jdk/src/java.desktop/share/classes/javax/print/StreamPrintServiceFactory.java index cd1523a94b2..58a1ae7bb23 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/StreamPrintServiceFactory.java +++ b/jdk/src/java.desktop/share/classes/javax/print/StreamPrintServiceFactory.java @@ -26,40 +26,48 @@ package javax.print; import java.io.OutputStream; - import java.util.ArrayList; import java.util.Iterator; +import java.util.ServiceConfigurationError; +import java.util.ServiceLoader; -import javax.print.DocFlavor; +import javax.print.attribute.PrintRequestAttributeSet; import sun.awt.AppContext; -import java.util.ServiceLoader; -import java.util.ServiceConfigurationError; /** * A {@code StreamPrintServiceFactory} is the factory for - * {@link StreamPrintService} instances, - * which can print to an output stream in a particular - * document format described as a mime type. - * A typical output document format may be Postscript(TM). + * {@link StreamPrintService} instances, which can print to an output stream in + * a particular document format described as a mime type. A typical output + * document format may be Postscript(TM). *

- * This class is implemented by a service and located by the - * implementation using the {@link java.util.ServiceLoader} facility. + * This class is implemented by a service and located by the implementation + * using the {@link ServiceLoader} facility. *

* Applications locate instances of this class by calling the * {@link #lookupStreamPrintServiceFactories(DocFlavor, String)} method. *

- * Applications can use a {@code StreamPrintService} obtained from a - * factory in place of a {@code PrintService} which represents a - * physical printer device. + * Applications can use a {@code StreamPrintService} obtained from a factory in + * place of a {@code PrintService} which represents a physical printer device. */ - public abstract class StreamPrintServiceFactory { + /** + * Contains a list of factories. + */ static class Services { + + /** + * The list of factories which will be stored per appcontext. + */ private ArrayList listOfFactories = null; } + /** + * Returns the services from the current appcontext. + * + * @return the services + */ private static Services getServices() { Services services = (Services)AppContext.getAppContext().get(Services.class); @@ -70,10 +78,20 @@ public abstract class StreamPrintServiceFactory { return services; } + /** + * Returns the list of factories. + * + * @return the list of factories + */ private static ArrayList getListOfFactories() { return getServices().listOfFactories; } + /** + * Initialize the list of factories. + * + * @return the list of factories + */ private static ArrayList initListOfFactories() { ArrayList listOfFactories = new ArrayList<>(); getServices().listOfFactories = listOfFactories; @@ -81,26 +99,26 @@ public abstract class StreamPrintServiceFactory { } /** - * Locates factories for print services that can be used with - * a print job to output a stream of data in the - * format specified by {@code outputMimeType}. + * Locates factories for print services that can be used with a print job to + * output a stream of data in the format specified by + * {@code outputMimeType}. *

- * The {@code outputMimeType} parameter describes the document type that - * you want to create, whereas the {@code flavor} parameter describes the - * format in which the input data will be provided by the application - * to the {@code StreamPrintService}. + * The {@code outputMimeType} parameter describes the document type that you + * want to create, whereas the {@code flavor} parameter describes the format + * in which the input data will be provided by the application to the + * {@code StreamPrintService}. *

- * Although null is an acceptable value to use in the lookup of stream - * printing services, it's typical to search for a particular - * desired format, such as Postscript(TM). + * Although {@code null} is an acceptable value to use in the lookup of + * stream printing services, it's typical to search for a particular desired + * format, such as Postscript(TM). * - * @param flavor of the input document type - null means match all - * types. - * @param outputMimeType representing the required output format, used to - * identify suitable stream printer factories. A value of null means - * match all formats. - * @return matching factories for stream print service instance, - * empty if no suitable factories could be located. + * @param flavor of the input document type - {@code null} means match all + * types + * @param outputMimeType representing the required output format, used to + * identify suitable stream printer factories. A value of + * {@code null} means match all formats. + * @return matching factories for stream print service instance, empty if no + * suitable factories could be located */ public static StreamPrintServiceFactory[] lookupStreamPrintServiceFactories(DocFlavor flavor, @@ -110,55 +128,56 @@ public abstract class StreamPrintServiceFactory { return list.toArray(new StreamPrintServiceFactory[list.size()]); } - /** Queries the factory for the document format that is emitted - * by printers obtained from this factory. + /** + * Queries the factory for the document format that is emitted by printers + * obtained from this factory. * - * @return the output format described as a mime type. + * @return the output format described as a mime type */ public abstract String getOutputFormat(); /** - * Queries the factory for the document flavors that can be accepted - * by printers obtained from this factory. - * @return array of supported doc flavors. + * Queries the factory for the document flavors that can be accepted by + * printers obtained from this factory. + * + * @return array of supported doc flavors */ public abstract DocFlavor[] getSupportedDocFlavors(); /** - * Returns a {@code StreamPrintService} that can print to - * the specified output stream. - * The output stream is created and managed by the application. - * It is the application's responsibility to close the stream and - * to ensure that this Printer is not reused. - * The application should not close this stream until any print job - * created from the printer is complete. Doing so earlier may generate - * a {@code PrinterException} and an event indicating that the - * job failed. + * Returns a {@code StreamPrintService} that can print to the specified + * output stream. The output stream is created and managed by the + * application. It is the application's responsibility to close the stream + * and to ensure that this {@code Printer} is not reused. The application + * should not close this stream until any print job created from the printer + * is complete. Doing so earlier may generate a {@code PrinterException} and + * an event indicating that the job failed. *

- * Whereas a {@code PrintService} connected to a physical printer - * can be reused, - * a {@code StreamPrintService} connected to a stream cannot. - * The underlying {@code StreamPrintService} may be disposed by - * the print system with - * the {@link StreamPrintService#dispose() dispose} method - * before returning from the - * {@link DocPrintJob#print(Doc, javax.print.attribute.PrintRequestAttributeSet) print} - * method of {@code DocPrintJob} so that the print system knows - * this printer is no longer usable. - * This is equivalent to a physical printer going offline - permanently. - * Applications may supply a null print stream to create a queryable - * service. It is not valid to create a PrintJob for such a stream. - * Implementations which allocate resources on construction should examine - * the stream and may wish to only allocate resources if the stream is - * non-null. + * Whereas a {@code PrintService} connected to a physical printer can be + * reused, a {@code StreamPrintService} connected to a stream cannot. The + * underlying {@code StreamPrintService} may be disposed by the print system + * with the {@link StreamPrintService#dispose() dispose} method before + * returning from the + * {@link DocPrintJob#print(Doc, PrintRequestAttributeSet) print} method of + * {@code DocPrintJob} so that the print system knows this printer is no + * longer usable. This is equivalent to a physical printer going offline - + * permanently. Applications may supply a {@code null} print stream to + * create a queryable service. It is not valid to create a {@code PrintJob} + * for such a stream. Implementations which allocate resources on + * construction should examine the stream and may wish to only allocate + * resources if the stream is {@code non-null}. * - * @param out destination stream for generated output. - * @return a PrintService which will generate the format specified by the - * DocFlavor supported by this Factory. + * @param out destination stream for generated output + * @return a {@code PrintService} which will generate the format specified + * by the {@code DocFlavor} supported by this factory */ public abstract StreamPrintService getPrintService(OutputStream out); - + /** + * Returns all factories for print services. + * + * @return all factories + */ private static ArrayList getAllFactories() { synchronized (StreamPrintServiceFactory.class) { @@ -198,6 +217,15 @@ public abstract class StreamPrintServiceFactory { } } + /** + * Checks if the array of {@code flavors} contains the {@code flavor} + * object. + * + * @param flavor the flavor + * @param flavors the array of flavors + * @return {@code true} if {@code flavors} contains the {@code flavor} + * object; {@code false} otherwise + */ private static boolean isMember(DocFlavor flavor, DocFlavor[] flavors) { for (int f=0; f + * Locates factories for print services that can be used with a print job to + * output a stream of data in the format specified by + * {@code outputMimeType}. + * + * @param flavor of the input document type - {@code null} means match all + * types + * @param outType representing the required output format, used to identify + * suitable stream printer factories. A value of {@code null} means + * match all formats. + * @return matching factories for stream print service instance, empty if no + * suitable factories could be located + */ private static ArrayList getFactories(DocFlavor flavor, String outType) { if (flavor == null && outType == null) { @@ -227,5 +270,4 @@ public abstract class StreamPrintServiceFactory { return list; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/URIException.java b/jdk/src/java.desktop/share/classes/javax/print/URIException.java index 5f2083168ee..8d23ba4f61a 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/URIException.java +++ b/jdk/src/java.desktop/share/classes/javax/print/URIException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -28,46 +28,45 @@ package javax.print; import java.net.URI; /** - * Interface URIException is a mixin interface which a subclass of {@link - * PrintException PrintException} can implement to report an error condition - * involving a URI address. The Print Service API does not define any print - * exception classes that implement interface URIException, that being left to - * the Print Service implementor's discretion. - * + * Interface {@code URIException} is a mixin interface which a subclass of + * {@link PrintException PrintException} can implement to report an error + * condition involving a {@code URI} address. The Print Service API does not + * define any print exception classes that implement interface + * {@code URIException}, that being left to the Print Service implementor's + * discretion. */ - public interface URIException { /** - * Indicates that the printer cannot access the URI address. - * For example, the printer might report this error if it goes to get - * the print data and cannot even establish a connection to the - * URI address. + * Indicates that the printer cannot access the {@code URI} address. For + * example, the printer might report this error if it goes to get the print + * data and cannot even establish a connection to the {@code URI} address. */ public static final int URIInaccessible = 1; /** - * Indicates that the printer does not support the URI - * scheme ("http", "ftp", etc.) in the URI address. + * Indicates that the printer does not support the {@code URI} scheme + * ("http", "ftp", etc.) in the {@code URI} address. */ public static final int URISchemeNotSupported = 2; /** - * Indicates any kind of problem not specifically identified - * by the other reasons. + * Indicates any kind of problem not specifically identified by the other + * reasons. */ public static final int URIOtherProblem = -1; /** - * Return the URI. - * @return the URI that is the cause of this exception. + * Returns the {@code URI}. + * + * @return the {@code URI} that is the cause of this exception */ public URI getUnsupportedURI(); /** - * Return the reason for the event. - * @return one of the predefined reasons enumerated in this interface. + * Returns the reason of this exception. + * + * @return one of the predefined reasons enumerated in this interface */ public int getReason(); - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/Attribute.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/Attribute.java index e493b4869de..71317df1dec 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/Attribute.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/Attribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -28,35 +28,34 @@ package javax.print.attribute; import java.io.Serializable; /** - * Interface Attribute is the base interface implemented by any and every - * printing attribute class to indicate that the class represents a + * Interface {@code Attribute} is the base interface implemented by any and + * every printing attribute class to indicate that the class represents a * printing attribute. All printing attributes are serializable. * - * @author David Mendenhall - * @author Alan Kaminsky + * @author David Mendenhall + * @author Alan Kaminsky */ public interface Attribute extends Serializable { - /** - * Get the printing attribute class which is to be used as the "category" - * for this printing attribute value when it is added to an attribute set. - * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. - */ - public Class getCategory(); - - /** - * Get the name of the category of which this attribute value is an - * instance. - *

- * Note: This method is intended to provide a default, nonlocalized - * string for the attribute's category. If two attribute objects return the - * same category from the {@code getCategory()} method, they should - * return the same name from the {@code getName()} method. - * - * @return Attribute category name. - */ - public String getName(); + /** + * Get the printing attribute class which is to be used as the "category" + * for this printing attribute value when it is added to an attribute set. + * + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} + */ + public Class getCategory(); + /** + * Get the name of the category of which this attribute value is an + * instance. + *

+ * Note: This method is intended to provide a default, nonlocalized + * string for the attribute's category. If two attribute objects return the + * same category from the {@code getCategory()} method, they should return + * the same name from the {@code getName()} method. + * + * @return attribute category name + */ + public String getName(); } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/AttributeSet.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/AttributeSet.java index f2fe1b3d5b2..58b23569a92 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/AttributeSet.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/AttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -26,284 +26,240 @@ package javax.print.attribute; /** - * Interface AttributeSet specifies the interface for a set of printing + * Interface {@code AttributeSet} specifies the interface for a set of printing * attributes. A printing attribute is an object whose class implements * interface {@link Attribute Attribute}. - *

- * An attribute set contains a group of attribute values, - * where duplicate values are not allowed in the set. - * Furthermore, each value in an attribute set is - * a member of some category, and at most one value in any particular - * category is allowed in the set. For an attribute set, the values are {@link - * Attribute Attribute} objects, and the categories are {@link java.lang.Class - * Class} objects. An attribute's category is the class (or interface) at the - * root of the class hierarchy for that kind of attribute. Note that an - * attribute object's category may be a superclass of the attribute object's - * class rather than the attribute object's class itself. An attribute - * object's - * category is determined by calling the {@link Attribute#getCategory() - * getCategory()} method defined in interface {@link Attribute - * Attribute}. - *

- * The interfaces of an AttributeSet resemble those of the Java Collections - * API's java.util.Map interface, but is more restrictive in the types - * it will accept, and combines keys and values into an Attribute. - *

- * Attribute sets are used in several places in the Print Service API. In - * each context, only certain kinds of attributes are allowed to appear in the + *

+ * An attribute set contains a group of attribute values, where duplicate + * values are not allowed in the set. Furthermore, each value in an attribute + * set is a member of some category, and at most one value in any + * particular category is allowed in the set. For an attribute set, the values + * are {@link Attribute Attribute} objects, and the categories are + * {@link Class Class} objects. An attribute's category is the class (or + * interface) at the root of the class hierarchy for that kind of attribute. + * Note that an attribute object's category may be a superclass of the attribute + * object's class rather than the attribute object's class itself. An attribute + * object's category is determined by calling the + * {@link Attribute#getCategory() getCategory()} method defined in interface + * {@link Attribute Attribute}. + *

+ * The interfaces of an {@code AttributeSet} resemble those of the Java + * Collections API's {@code java.util.Map} interface, but is more restrictive in + * the types it will accept, and combines keys and values into an + * {@code Attribute}. + *

+ * Attribute sets are used in several places in the Print Service API. In each + * context, only certain kinds of attributes are allowed to appear in the * attribute set, as determined by the tagging interfaces which the attribute - * class implements -- {@link DocAttribute DocAttribute}, {@link - * PrintRequestAttribute PrintRequestAttribute}, {@link PrintJobAttribute - * PrintJobAttribute}, and {@link PrintServiceAttribute - * PrintServiceAttribute}. + * class implements -- {@link DocAttribute DocAttribute}, + * {@link PrintRequestAttribute PrintRequestAttribute}, + * {@link PrintJobAttribute PrintJobAttribute}, and + * {@link PrintServiceAttribute PrintServiceAttribute}. * There are four specializations of an attribute set that are restricted to - * contain just one of the four kinds of attribute -- {@link DocAttributeSet - * DocAttributeSet}, {@link PrintRequestAttributeSet - * PrintRequestAttributeSet}, - * {@link PrintJobAttributeSet PrintJobAttributeSet}, and {@link - * PrintServiceAttributeSet PrintServiceAttributeSet}, respectively. Note that - * many attribute classes implement more than one tagging interface and so may - * appear in more than one context. - *

    - *
  • - * A {@link DocAttributeSet DocAttributeSet}, containing {@link DocAttribute - * DocAttribute}s, specifies the characteristics of an individual doc and the - * print job settings to be applied to an individual doc. - * - *
  • - * A {@link PrintRequestAttributeSet PrintRequestAttributeSet}, containing - * {@link PrintRequestAttribute PrintRequestAttribute}s, specifies the - * settings - * to be applied to a whole print job and to all the docs in the print job. - * - *
  • - * A {@link PrintJobAttributeSet PrintJobAttributeSet}, containing {@link - * PrintJobAttribute PrintJobAttribute}s, reports the status of a print job. - * - *
  • - * A {@link PrintServiceAttributeSet PrintServiceAttributeSet}, containing - * {@link PrintServiceAttribute PrintServiceAttribute}s, reports the status of - * a Print Service instance. - *
- *

+ * contain just one of the four kinds of attribute -- + * {@link DocAttributeSet DocAttributeSet}, + * {@link PrintRequestAttributeSet PrintRequestAttributeSet}, + * {@link PrintJobAttributeSet PrintJobAttributeSet}, and + * {@link PrintServiceAttributeSet PrintServiceAttributeSet}, respectively. Note + * that many attribute classes implement more than one tagging interface and so + * may appear in more than one context. + *

    + *
  • A {@link DocAttributeSet DocAttributeSet}, containing + * {@link DocAttribute DocAttribute}s, specifies the characteristics of an + * individual doc and the print job settings to be applied to an individual + * doc. + *
  • A {@link PrintRequestAttributeSet PrintRequestAttributeSet}, containing + * {@link PrintRequestAttribute PrintRequestAttribute}s, specifies the + * settings to be applied to a whole print job and to all the docs in the + * print job. + *
  • A {@link PrintJobAttributeSet PrintJobAttributeSet}, containing + * {@link PrintJobAttribute PrintJobAttribute}s, reports the status of a print + * job. + *
  • A {@link PrintServiceAttributeSet PrintServiceAttributeSet}, containing + * {@link PrintServiceAttribute PrintServiceAttribute}s, reports the status of + * a Print Service instance. + *
* In some contexts, the client is only allowed to examine an attribute set's * contents but not change them (the set is read-only). In other places, the * client is allowed both to examine and to change an attribute set's contents * (the set is read-write). For a read-only attribute set, calling a mutating - * operation throws an UnmodifiableSetException. - *

+ * operation throws an {@code UnmodifiableSetException}. + *

* The Print Service API provides one implementation of interface - * AttributeSet, class {@link HashAttributeSet HashAttributeSet}. - * A client can use class {@link - * HashAttributeSet HashAttributeSet} or provide its own implementation of - * interface AttributeSet. The Print Service API also provides - * implementations of interface AttributeSet's subinterfaces -- classes {@link - * HashDocAttributeSet HashDocAttributeSet}, - * {@link HashPrintRequestAttributeSet - * HashPrintRequestAttributeSet}, {@link HashPrintJobAttributeSet - * HashPrintJobAttributeSet}, and {@link HashPrintServiceAttributeSet - * HashPrintServiceAttributeSet}. + * {@code AttributeSet}, class {@link HashAttributeSet HashAttributeSet}. A + * client can use class {@link HashAttributeSet HashAttributeSet} or provide its + * own implementation of interface {@code AttributeSet}. The Print Service API + * also provides implementations of interface {@code AttributeSet}'s + * subinterfaces -- classes + * {@link HashDocAttributeSet HashDocAttributeSet}, + * {@link HashPrintRequestAttributeSet HashPrintRequestAttributeSet}, + * {@link HashPrintJobAttributeSet HashPrintJobAttributeSet}, and + * {@link HashPrintServiceAttributeSet HashPrintServiceAttributeSet}. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public interface AttributeSet { - /** * Returns the attribute value which this attribute set contains in the - * given attribute category. Returns {@code null} if this attribute set - * does not contain any attribute value in the given attribute category. + * given attribute category. Returns {@code null} if this attribute set does + * not contain any attribute value in the given attribute category. * - * @param category Attribute category whose associated attribute value - * is to be returned. It must be a - * {@link java.lang.Class Class} - * that implements interface {@link Attribute - * Attribute}. - * - * @return The attribute value in the given attribute category contained - * in this attribute set, or {@code null} if this attribute set - * does not contain any attribute value in the given attribute - * category. - * - * @throws NullPointerException - * (unchecked exception) Thrown if the {@code category} is null. - * @throws ClassCastException - * (unchecked exception) Thrown if the {@code category} is not a - * {@link java.lang.Class Class} that implements interface {@link - * Attribute Attribute}. + * @param category attribute category whose associated attribute value is + * to be returned. It must be a {@link Class Class} that implements + * interface {@link Attribute Attribute}. + * @return the attribute value in the given attribute category contained in + * this attribute set, or {@code null} if this attribute set does + * not contain any attribute value in the given attribute category + * @throws NullPointerException if the {@code category} is {@code null} + * @throws ClassCastException if the {@code category} is not a + * {@link Class Class} that implements interface + * {@link Attribute Attribute} */ public Attribute get(Class category); /** - * Adds the specified attribute to this attribute set if it is not - * already present, first removing any existing value in the same - * attribute category as the specified attribute value. + * Adds the specified attribute to this attribute set if it is not already + * present, first removing any existing value in the same attribute category + * as the specified attribute value. * - * @param attribute Attribute value to be added to this attribute set. - * - * @return {@code true} if this attribute set changed as a result of the - * call, i.e., the given attribute value was not already a member - * of this attribute set. - * - * @throws NullPointerException - * (unchecked exception) Thrown if the {@code attribute} is null. - * @throws UnmodifiableSetException - * (unchecked exception) Thrown if this attribute set does not support - * the {@code add()} operation. + * @param attribute attribute value to be added to this attribute set + * @return {@code true} if this attribute set changed as a result of the + * call, i.e., the given attribute value was not already a member of + * this attribute set + * @throws NullPointerException if the {@code attribute} is {@code null} + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code add()} operation */ public boolean add(Attribute attribute); - /** * Removes any attribute for this category from this attribute set if - * present. If {@code category} is null, then - * {@code remove()} does nothing and returns {@code false}. + * present. If {@code category} is {@code null}, then {@code remove()} does + * nothing and returns {@code false}. * - * @param category Attribute category to be removed from this - * attribute set. - * - * @return {@code true} if this attribute set changed as a result of the + * @param category attribute category to be removed from this attribute set + * @return {@code true} if this attribute set changed as a result of the * call, i.e., the given attribute value had been a member of this - * attribute set. - * - * @throws UnmodifiableSetException - * (unchecked exception) Thrown if this attribute set does not support - * the {@code remove()} operation. + * attribute set + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code remove()} operation */ public boolean remove(Class category); /** - * Removes the specified attribute from this attribute set if - * present. If {@code attribute} is null, then - * {@code remove()} does nothing and returns {@code false}. + * Removes the specified attribute from this attribute set if present. If + * {@code attribute} is {@code null}, then {@code remove()} does nothing and + * returns {@code false}. * - * @param attribute Attribute value to be removed from this attribute set. - * - * @return {@code true} if this attribute set changed as a result of the + * @param attribute attribute value to be removed from this attribute set + * @return {@code true} if this attribute set changed as a result of the * call, i.e., the given attribute value had been a member of this - * attribute set. - * - * @throws UnmodifiableSetException - * (unchecked exception) Thrown if this attribute set does not support - * the {@code remove()} operation. + * attribute set + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code remove()} operation */ public boolean remove(Attribute attribute); /** - * Returns {@code true} if this attribute set contains an - * attribute for the specified category. + * Returns {@code true} if this attribute set contains an attribute for the + * specified category. * - * @param category whose presence in this attribute set is - * to be tested. - * - * @return {@code true} if this attribute set contains an attribute - * value for the specified category. + * @param category whose presence in this attribute set is to be tested + * @return {@code true} if this attribute set contains an attribute value + * for the specified category */ public boolean containsKey(Class category); /** - * Returns {@code true} if this attribute set contains the given - * attribute value. + * Returns {@code true} if this attribute set contains the given attribute + * value. * - * @param attribute Attribute value whose presence in this - * attribute set is to be tested. - * - * @return {@code true} if this attribute set contains the given - * attribute value. + * @param attribute attribute value whose presence in this attribute set is + * to be tested + * @return {@code true} if this attribute set contains the given attribute + * value */ public boolean containsValue(Attribute attribute); /** - * Adds all of the elements in the specified set to this attribute. - * The outcome is the same as if the = - * {@link #add(Attribute) add(Attribute)} + * Adds all of the elements in the specified set to this attribute. The + * outcome is the same as if the = {@link #add(Attribute) add(Attribute)} * operation had been applied to this attribute set successively with each - * element from the specified set. - * The behavior of the {@code addAll(AttributeSet)} - * operation is unspecified if the specified set is modified while - * the operation is in progress. - *

- * If the {@code addAll(AttributeSet)} operation throws an exception, - * the effect on this attribute set's state is implementation dependent; - * elements from the specified set before the point of the exception may - * or may not have been added to this attribute set. - * - * @param attributes whose elements are to be added to this attribute - * set. - * - * @return {@code true} if this attribute set changed as a result of the - * call. - * - * @throws UnmodifiableSetException - * (Unchecked exception) Thrown if this attribute set does not support - * the {@code addAll(AttributeSet)} method. - * @throws NullPointerException - * (Unchecked exception) Thrown if some element in the specified - * set is null. + * element from the specified set. The behavior of the + * {@code addAll(AttributeSet)} operation is unspecified if the specified + * set is modified while the operation is in progress. + *

+ * If the {@code addAll(AttributeSet)} operation throws an exception, the + * effect on this attribute set's state is implementation dependent; + * elements from the specified set before the point of the exception may or + * may not have been added to this attribute set. * + * @param attributes whose elements are to be added to this attribute set + * @return {@code true} if this attribute set changed as a result of the + * call + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code addAll(AttributeSet)} method + * @throws NullPointerException if some element in the specified set is + * {@code null} * @see #add(Attribute) */ public boolean addAll(AttributeSet attributes); /** - * Returns the number of attributes in this attribute set. If this - * attribute set contains more than {@code Integer.MAX_VALUE} elements, - * returns {@code Integer.MAX_VALUE}. + * Returns the number of attributes in this attribute set. If this attribute + * set contains more than {@code Integer.MAX_VALUE} elements, returns + * {@code Integer.MAX_VALUE}. * - * @return The number of attributes in this attribute set. + * @return the number of attributes in this attribute set */ public int size(); /** * Returns an array of the attributes contained in this set. - * @return the Attributes contained in this set as an array, zero length - * if the AttributeSet is empty. + * + * @return the {@code Attributes} contained in this set as an array, zero + * length if the {@code AttributeSet} is empty */ public Attribute[] toArray(); - /** * Removes all attributes from this attribute set. * - * @throws UnmodifiableSetException - * (unchecked exception) Thrown if this attribute set does not support - * the {@code clear()} operation. + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code clear()} operation */ public void clear(); /** - * Returns true if this attribute set contains no attributes. + * Returns {@code true} if this attribute set contains no attributes. * - * @return true if this attribute set contains no attributes. + * @return {@code true} if this attribute set contains no attributes */ public boolean isEmpty(); /** * Compares the specified object with this attribute set for equality. - * Returns {@code true} if the given object is also an attribute set and - * the two attribute sets contain the same attribute category-attribute - * value mappings. This ensures that the - * {@code equals()} method works properly across different - * implementations of the AttributeSet interface. + * Returns {@code true} if the given object is also an attribute set and the + * two attribute sets contain the same attribute category-attribute value + * mappings. This ensures that the {@code equals()} method works properly + * across different implementations of the {@code AttributeSet} interface. * - * @param object to be compared for equality with this attribute set. - * - * @return {@code true} if the specified object is equal to this - * attribute set. + * @param object to be compared for equality with this attribute set + * @return {@code true} if the specified object is equal to this attribute + * set */ public boolean equals(Object object); /** * Returns the hash code value for this attribute set. The hash code of an - * attribute set is defined to be the sum of the hash codes of each entry - * in the AttributeSet. - * This ensures that {@code t1.equals(t2)} implies that - * {@code t1.hashCode()==t2.hashCode()} for any two attribute sets + * attribute set is defined to be the sum of the hash codes of each entry in + * the {@code AttributeSet}. This ensures that {@code t1.equals(t2)} implies + * that {@code t1.hashCode()==t2.hashCode()} for any two attribute sets * {@code t1} and {@code t2}, as required by the general contract of - * {@link java.lang.Object#hashCode() Object.hashCode()}. + * {@link Object#hashCode() Object.hashCode()}. * - * @return The hash code value for this attribute set. + * @return the hash code value for this attribute set */ public int hashCode(); - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/AttributeSetUtilities.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/AttributeSetUtilities.java index 587a4833501..b6fce0c9448 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/AttributeSetUtilities.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/AttributeSetUtilities.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,65 +23,75 @@ * questions. */ - package javax.print.attribute; import java.io.Serializable; /** - * Class AttributeSetUtilities provides static methods for manipulating - * AttributeSets. + * Class {@code AttributeSetUtilities} provides static methods for manipulating + * {@code AttributeSets}. *

    - *
  • Methods for creating unmodifiable and synchronized views of attribute - * sets. - *
  • operations useful for building - * implementations of interface {@link AttributeSet AttributeSet} + *
  • Methods for creating unmodifiable and synchronized views of attribute + * sets. + *
  • operations useful for building implementations of interface + * {@link AttributeSet AttributeSet} *
- *

- * An unmodifiable view U of an AttributeSet S provides a - * client with "read-only" access to S. Query operations on U - * "read through" to S; thus, changes in S are reflected in - * U. However, any attempt to modify U, - * results in an UnmodifiableSetException. - * The unmodifiable view object U will be serializable if the - * attribute set object S is serializable. - *

- * A synchronized view V of an attribute set S provides a - * client with synchronized (multiple thread safe) access to S. Each - * operation of V is synchronized using V itself as the lock - * object and then merely invokes the corresponding operation of S. In - * order to guarantee mutually exclusive access, it is critical that all - * access to S is accomplished through V. The synchronized view - * object V will be serializable if the attribute set object S - * is serializable. - *

- * As mentioned in the package description of javax.print, a null reference - * parameter to methods is - * incorrect unless explicitly documented on the method as having a meaningful - * interpretation. Usage to the contrary is incorrect coding and may result in - * a run time exception either immediately - * or at some later time. IllegalArgumentException and NullPointerException - * are examples of typical and acceptable run time exceptions for such cases. + * An unmodifiable view U of an {@code AttributeSet} S + * provides a client with "read-only" access to S. Query operations on + * U "read through" to S; thus, changes in S are reflected + * in U. However, any attempt to modify U, results in an + * {@code UnmodifiableSetException}. The unmodifiable view object U will + * be serializable if the attribute set object S is serializable. + *

+ * A synchronized view V of an attribute set S provides a + * client with synchronized (multiple thread safe) access to S. Each + * operation of V is synchronized using V itself as the lock + * object and then merely invokes the corresponding operation of S. In + * order to guarantee mutually exclusive access, it is critical that all access + * to S is accomplished through V. The synchronized view object + * V will be serializable if the attribute set object S is + * serializable. + *

+ * As mentioned in the package description of {@code javax.print}, a + * {@code null} reference parameter to methods is incorrect unless explicitly + * documented on the method as having a meaningful interpretation. Usage to the + * contrary is incorrect coding and may result in a run time exception either + * immediately or at some later time. {@code IllegalArgumentException} and + * {@code NullPointerException} are examples of typical and acceptable run time + * exceptions for such cases. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class AttributeSetUtilities { - /* Suppress default constructor, ensuring non-instantiability. + /** + * Suppress default constructor, ensuring non-instantiability. */ private AttributeSetUtilities() { } /** - * @serial include - */ + * Unmodifiable view of {@code AttributeSet}. + * + * @serial include + */ private static class UnmodifiableAttributeSet implements AttributeSet, Serializable { + + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -6131802583863447813L; + /** + * The attribute set. + */ private AttributeSet attrset; - /* Unmodifiable view of the underlying attribute set. + /** + * Constructs unmodifiable view of the underlying attribute set. + * + * @param attributeSet the attribute set */ public UnmodifiableAttributeSet(AttributeSet attributeSet) { @@ -139,17 +149,27 @@ public final class AttributeSetUtilities { public int hashCode() { return attrset.hashCode(); } - } /** - * @serial include - */ + * Unmodifiable view of {@code DocAttributeSet}. + * + * @serial include + */ private static class UnmodifiableDocAttributeSet extends UnmodifiableAttributeSet implements DocAttributeSet, Serializable { + + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -6349408326066898956L; + /** + * Constructs a new unmodifiable doc attribute set. + * + * @param attributeSet the doc attribute set + */ public UnmodifiableDocAttributeSet(DocAttributeSet attributeSet) { super (attributeSet); @@ -157,13 +177,25 @@ public final class AttributeSetUtilities { } /** - * @serial include - */ + * Unmodifiable view of {@code PrintRequestAttributeSet}. + * + * @serial include + */ private static class UnmodifiablePrintRequestAttributeSet extends UnmodifiableAttributeSet implements PrintRequestAttributeSet, Serializable { + + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 7799373532614825073L; + + /** + * Constructs a new unmodifiable print request attribute set. + * + * @param attributeSet the print request attribute set + */ public UnmodifiablePrintRequestAttributeSet (PrintRequestAttributeSet attributeSet) { @@ -172,13 +204,24 @@ public final class AttributeSetUtilities { } /** - * @serial include - */ + * Unmodifiable view of {@code PrintJobAttributeSet}. + * + * @serial include + */ private static class UnmodifiablePrintJobAttributeSet extends UnmodifiableAttributeSet implements PrintJobAttributeSet, Serializable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -8002245296274522112L; + + /** + * Constructs a new unmodifiable print job attribute set. + * + * @param attributeSet the print job attribute set + */ public UnmodifiablePrintJobAttributeSet (PrintJobAttributeSet attributeSet) { @@ -187,13 +230,24 @@ public final class AttributeSetUtilities { } /** - * @serial include - */ + * Unmodifiable view of {@code PrintServiceAttributeSet}. + * + * @serial include + */ private static class UnmodifiablePrintServiceAttributeSet extends UnmodifiableAttributeSet implements PrintServiceAttributeSet, Serializable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -7112165137107826819L; + + /** + * Constructs a new unmodifiable print service attribute set. + * + * @param attributeSet the print service attribute set + */ public UnmodifiablePrintServiceAttributeSet (PrintServiceAttributeSet attributeSet) { @@ -204,12 +258,9 @@ public final class AttributeSetUtilities { /** * Creates an unmodifiable view of the given attribute set. * - * @param attributeSet Underlying attribute set. - * - * @return Unmodifiable view of {@code attributeSet}. - * - * @exception NullPointerException - * Thrown if {@code attributeSet} is null. Null is never a + * @param attributeSet underlying attribute set + * @return unmodifiable view of {@code attributeSet} + * @throws NullPointerException if {@code attributeSet} is {@code null} */ public static AttributeSet unmodifiableView(AttributeSet attributeSet) { if (attributeSet == null) { @@ -222,12 +273,9 @@ public final class AttributeSetUtilities { /** * Creates an unmodifiable view of the given doc attribute set. * - * @param attributeSet Underlying doc attribute set. - * - * @return Unmodifiable view of {@code attributeSet}. - * - * @exception NullPointerException - * Thrown if {@code attributeSet} is null. + * @param attributeSet underlying doc attribute set + * @return unmodifiable view of {@code attributeSet} + * @throws NullPointerException if {@code attributeSet} is {@code null} */ public static DocAttributeSet unmodifiableView (DocAttributeSet attributeSet) { @@ -240,12 +288,9 @@ public final class AttributeSetUtilities { /** * Creates an unmodifiable view of the given print request attribute set. * - * @param attributeSet Underlying print request attribute set. - * - * @return Unmodifiable view of {@code attributeSet}. - * - * @exception NullPointerException - * Thrown if {@code attributeSet} is null. + * @param attributeSet underlying print request attribute set + * @return unmodifiable view of {@code attributeSet} + * @throws NullPointerException if {@code attributeSet} is {@code null} */ public static PrintRequestAttributeSet unmodifiableView(PrintRequestAttributeSet attributeSet) { @@ -258,12 +303,9 @@ public final class AttributeSetUtilities { /** * Creates an unmodifiable view of the given print job attribute set. * - * @param attributeSet Underlying print job attribute set. - * - * @return Unmodifiable view of {@code attributeSet}. - * - * @exception NullPointerException - * Thrown if {@code attributeSet} is null. + * @param attributeSet underlying print job attribute set + * @return unmodifiable view of {@code attributeSet} + * @throws NullPointerException if {@code attributeSet} is {@code null} */ public static PrintJobAttributeSet unmodifiableView(PrintJobAttributeSet attributeSet) { @@ -276,12 +318,9 @@ public final class AttributeSetUtilities { /** * Creates an unmodifiable view of the given print service attribute set. * - * @param attributeSet Underlying print service attribute set. - * - * @return Unmodifiable view of {@code attributeSet}. - * - * @exception NullPointerException - * Thrown if {@code attributeSet} is null. + * @param attributeSet underlying print service attribute set + * @return unmodifiable view of {@code attributeSet} + * @throws NullPointerException if {@code attributeSet} is {@code null} */ public static PrintServiceAttributeSet unmodifiableView(PrintServiceAttributeSet attributeSet) { @@ -292,14 +331,28 @@ public final class AttributeSetUtilities { } /** - * @serial include - */ + * Synchronized view of {@code AttributeSet}. + * + * @serial include + */ private static class SynchronizedAttributeSet implements AttributeSet, Serializable { + + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 8365731020128564925L; + /** + * The attribute set. + */ private AttributeSet attrset; + /** + * Constructs a new synchronized attribute set. + * + * @param attributeSet the attribute set + */ public SynchronizedAttributeSet(AttributeSet attributeSet) { attrset = attributeSet; } @@ -358,26 +411,48 @@ public final class AttributeSetUtilities { } /** - * @serial include - */ + * Synchronized view of {@code DocAttributeSet}. + * + * @serial include + */ private static class SynchronizedDocAttributeSet extends SynchronizedAttributeSet implements DocAttributeSet, Serializable { + + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 6455869095246629354L; + /** + * Constructs a new synchronized doc attribute set. + * + * @param attributeSet the doc attribute set + */ public SynchronizedDocAttributeSet(DocAttributeSet attributeSet) { super(attributeSet); } } /** - * @serial include - */ + * Synchronized view of {@code PrintRequestAttributeSet}. + * + * @serial include + */ private static class SynchronizedPrintRequestAttributeSet extends SynchronizedAttributeSet implements PrintRequestAttributeSet, Serializable { + + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 5671237023971169027L; + /** + * Constructs a new synchronized print request attribute set. + * + * @param attributeSet the print request attribute set + */ public SynchronizedPrintRequestAttributeSet (PrintRequestAttributeSet attributeSet) { super(attributeSet); @@ -385,13 +460,24 @@ public final class AttributeSetUtilities { } /** - * @serial include - */ + * Synchronized view of {@code PrintJobAttributeSet}. + * + * @serial include + */ private static class SynchronizedPrintJobAttributeSet extends SynchronizedAttributeSet implements PrintJobAttributeSet, Serializable { + + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 2117188707856965749L; + /** + * Constructs a new synchronized print job attribute set. + * + * @param attributeSet the print job attribute set + */ public SynchronizedPrintJobAttributeSet (PrintJobAttributeSet attributeSet) { super(attributeSet); @@ -399,13 +485,24 @@ public final class AttributeSetUtilities { } /** - * @serial include - */ + * Synchronized view of {@code PrintServiceAttributeSet}. + * + * @serial include + */ private static class SynchronizedPrintServiceAttributeSet extends SynchronizedAttributeSet implements PrintServiceAttributeSet, Serializable { + + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -2830705374001675073L; + /** + * Constructs a new synchronized print service attribute set. + * + * @param attributeSet the print service attribute set + */ public SynchronizedPrintServiceAttributeSet (PrintServiceAttributeSet attributeSet) { super(attributeSet); @@ -415,12 +512,9 @@ public final class AttributeSetUtilities { /** * Creates a synchronized view of the given attribute set. * - * @param attributeSet Underlying attribute set. - * - * @return Synchronized view of {@code attributeSet}. - * - * @exception NullPointerException - * Thrown if {@code attributeSet} is null. + * @param attributeSet underlying attribute set + * @return synchronized view of {@code attributeSet} + * @throws NullPointerException if {@code attributeSet} is {@code null} */ public static AttributeSet synchronizedView (AttributeSet attributeSet) { @@ -433,12 +527,9 @@ public final class AttributeSetUtilities { /** * Creates a synchronized view of the given doc attribute set. * - * @param attributeSet Underlying doc attribute set. - * - * @return Synchronized view of {@code attributeSet}. - * - * @exception NullPointerException - * Thrown if {@code attributeSet} is null. + * @param attributeSet underlying doc attribute set + * @return synchronized view of {@code attributeSet} + * @throws NullPointerException if {@code attributeSet} is {@code null} */ public static DocAttributeSet synchronizedView(DocAttributeSet attributeSet) { @@ -451,12 +542,9 @@ public final class AttributeSetUtilities { /** * Creates a synchronized view of the given print request attribute set. * - * @param attributeSet Underlying print request attribute set. - * - * @return Synchronized view of {@code attributeSet}. - * - * @exception NullPointerException - * Thrown if {@code attributeSet} is null. + * @param attributeSet underlying print request attribute set + * @return synchronized view of {@code attributeSet} + * @throws NullPointerException if {@code attributeSet} is {@code null} */ public static PrintRequestAttributeSet synchronizedView(PrintRequestAttributeSet attributeSet) { @@ -469,12 +557,9 @@ public final class AttributeSetUtilities { /** * Creates a synchronized view of the given print job attribute set. * - * @param attributeSet Underlying print job attribute set. - * - * @return Synchronized view of {@code attributeSet}. - * - * @exception NullPointerException - * Thrown if {@code attributeSet} is null. + * @param attributeSet underlying print job attribute set + * @return synchronized view of {@code attributeSet} + * @throws NullPointerException if {@code attributeSet} is {@code null} */ public static PrintJobAttributeSet synchronizedView(PrintJobAttributeSet attributeSet) { @@ -487,9 +572,9 @@ public final class AttributeSetUtilities { /** * Creates a synchronized view of the given print service attribute set. * - * @param attributeSet Underlying print service attribute set. - * - * @return Synchronized view of {@code attributeSet}. + * @param attributeSet underlying print service attribute set + * @return synchronized view of {@code attributeSet} + * @throws NullPointerException if {@code attributeSet} is {@code null} */ public static PrintServiceAttributeSet synchronizedView(PrintServiceAttributeSet attributeSet) { @@ -499,26 +584,19 @@ public final class AttributeSetUtilities { return new SynchronizedPrintServiceAttributeSet(attributeSet); } - /** - * Verify that the given object is a {@link java.lang.Class Class} that - * implements the given interface, which is assumed to be interface {@link - * Attribute Attribute} or a subinterface thereof. + * Verify that the given object is a {@link Class Class} that implements the + * given interface, which is assumed to be interface + * {@link Attribute Attribute} or a subinterface thereof. * - * @param object Object to test. - * @param interfaceName Interface the object must implement. - * - * @return If {@code object} is a {@link java.lang.Class Class} - * that implements {@code interfaceName}, - * {@code object} is returned downcast to type {@link - * java.lang.Class Class}; otherwise an exception is thrown. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code object} is null. - * @exception ClassCastException - * (unchecked exception) Thrown if {@code object} is not a - * {@link java.lang.Class Class} that implements - * {@code interfaceName}. + * @param object {@code Object} to test + * @param interfaceName interface the object must implement + * @return if {@code object} is a {@link Class Class} that implements + * {@code interfaceName}, {@code object} is returned downcast to + * type {@link Class Class}; otherwise an exception is thrown + * @throws NullPointerException if {@code object} is {@code null} + * @throws ClassCastException if {@code object} is not a + * {@link Class Class} that implements {@code interfaceName} */ public static Class verifyAttributeCategory(Object object, Class interfaceName) { @@ -537,19 +615,14 @@ public final class AttributeSetUtilities { * is assumed to be interface {@link Attribute Attribute} or a subinterface * thereof. * - * @param object Object to test. - * @param interfaceName Interface of which the object must be an instance. - * - * @return If {@code object} is an instance of - * {@code interfaceName}, {@code object} is returned - * downcast to type {@link Attribute Attribute}; otherwise an - * exception is thrown. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code object} is null. - * @exception ClassCastException - * (unchecked exception) Thrown if {@code object} is not an - * instance of {@code interfaceName}. + * @param object {@code Object} to test + * @param interfaceName interface of which the object must be an instance + * @return if {@code object} is an instance of {@code interfaceName}, + * {@code object} is returned downcast to type + * {@link Attribute Attribute}; otherwise an exception is thrown + * @throws NullPointerException if {@code object} is {@code null} + * @throws ClassCastException if {@code object} is not an instance of + * {@code interfaceName} */ public static Attribute verifyAttributeValue(Object object, Class interfaceName) { @@ -565,19 +638,16 @@ public final class AttributeSetUtilities { } /** - * Verify that the given attribute category object is equal to the - * category of the given attribute value object. If so, this method - * returns doing nothing. If not, this method throws an exception. + * Verify that the given attribute category object is equal to the category + * of the given attribute value object. If so, this method returns doing + * nothing. If not, this method throws an exception. * - * @param category Attribute category to test. - * @param attribute Attribute value to test. - * - * @exception NullPointerException - * (unchecked exception) Thrown if the {@code category} is - * null or if the {@code attribute} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if the {@code category} is not - * equal to the category of the {@code attribute}. + * @param category attribute category to test + * @param attribute attribute value to test + * @throws NullPointerException if the {@code category} or {@code attribute} + * are {@code null} + * @throws IllegalArgumentException if the {@code category} is not equal to + * the category of the {@code attribute} */ public static void verifyCategoryForValue(Class category, Attribute attribute) { diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/DateTimeSyntax.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/DateTimeSyntax.java index 0515be6e801..7feed2b22d3 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/DateTimeSyntax.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/DateTimeSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,47 +23,48 @@ * questions. */ - package javax.print.attribute; import java.io.Serializable; - import java.util.Date; /** - * Class DateTimeSyntax is an abstract base class providing the common + * Class {@code DateTimeSyntax} is an abstract base class providing the common * implementation of all attributes whose value is a date and time. - *

+ *

* Under the hood, a date-time attribute is stored as a value of class - * {@code java.util.Date}. You can get a date-time attribute's Date value by - * calling {@link #getValue() getValue()}. A date-time attribute's - * Date value is established when it is constructed (see {@link - * #DateTimeSyntax(Date) DateTimeSyntax(Date)}). Once - * constructed, a date-time attribute's value is immutable. - *

+ * {@code java.util.Date}. You can get a date-time attribute's {@code Date} + * value by calling {@link #getValue() getValue()}. A date-time attribute's + * {@code Date} value is established when it is constructed (see + * {@link #DateTimeSyntax(Date) DateTimeSyntax(Date)}). Once constructed, a + * date-time attribute's value is immutable. + *

* To construct a date-time attribute from separate values of the year, month, - * day, hour, minute, and so on, use a {@code java.util.Calendar} - * object to construct a {@code java.util.Date} object, then use the - * {@code java.util.Date} object to construct the date-time attribute. - * To convert - * a date-time attribute to separate values of the year, month, day, hour, - * minute, and so on, create a {@code java.util.Calendar} object and - * set it to the {@code java.util.Date} from the date-time attribute. Class - * DateTimeSyntax stores its value in the form of a {@code java.util.Date} - * rather than a {@code java.util.Calendar} because it typically takes - * less memory to store and less time to compare a {@code java.util.Date} - * than a {@code java.util.Calendar}. + * day, hour, minute, and so on, use a {@code java.util.Calendar} object to + * construct a {@code java.util.Date} object, then use the + * {@code java.util.Date} object to construct the date-time attribute. To + * convert a date-time attribute to separate values of the year, month, day, + * hour, minute, and so on, create a {@code java.util.Calendar} object and set + * it to the {@code java.util.Date} from the date-time attribute. Class + * {@code DateTimeSyntax} stores its value in the form of a + * {@code java.util.Date} rather than a {@code java.util.Calendar} because it + * typically takes less memory to store and less time to compare a + * {@code java.util.Date} than a {@code java.util.Calendar}. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public abstract class DateTimeSyntax implements Serializable, Cloneable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -1400819079791208582L; // Hidden data members. /** * This date-time attribute's {@code java.util.Date} value. + * * @serial */ private Date value; @@ -71,13 +72,11 @@ public abstract class DateTimeSyntax implements Serializable, Cloneable { // Hidden constructors. /** - * Construct a new date-time attribute with the given - * {@code java.util.Date} value. + * Construct a new date-time attribute with the given {@code java.util.Date} + * value. * - * @param value {@code java.util.Date} value. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code theValue} is null. + * @param value {@code java.util.Date} value + * @throws NullPointerException if {@code value} is {@code null} */ protected DateTimeSyntax(Date value) { if (value == null) { @@ -89,9 +88,9 @@ public abstract class DateTimeSyntax implements Serializable, Cloneable { // Exported operations. /** - * Returns this date-time attribute's {@code java.util.Date} - * value. - * @return the Date. + * Returns this date-time attribute's {@code java.util.Date} value. + * + * @return the {@code Date} */ public Date getValue() { return new Date (value.getTime()); @@ -102,20 +101,16 @@ public abstract class DateTimeSyntax implements Serializable, Cloneable { /** * Returns whether this date-time attribute is equivalent to the passed in * object. To be equivalent, all of the following conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class DateTimeSyntax. - *
  3. - * This date-time attribute's {@code java.util.Date} value and - * {@code object}'s {@code java.util.Date} value are - * equal.
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code DateTimeSyntax}. + *
  3. This date-time attribute's {@code java.util.Date} value and + * {@code object}'s {@code java.util.Date} value are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this date-time - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this date-time + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return (object != null && @@ -132,13 +127,11 @@ public abstract class DateTimeSyntax implements Serializable, Cloneable { } /** - * Returns a string value corresponding to this date-time attribute. - * The string value is just this attribute's - * {@code java.util.Date} value + * Returns a string value corresponding to this date-time attribute. The + * string value is just this attribute's {@code java.util.Date} value * converted to a string. */ public String toString() { return "" + value; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/DocAttribute.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/DocAttribute.java index 509eee309d4..81f7bf61ea0 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/DocAttribute.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/DocAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,25 +23,22 @@ * questions. */ - package javax.print.attribute; /** - * Interface DocAttribute is a tagging interface which a printing attribute - * class implements to indicate the attribute denotes a setting for a doc. - * ("Doc" is a short, easy-to-pronounce term that means "a piece of print - * data.") The client may include a DocAttribute in a {@code Doc}'s - * attribute set to specify a characteristic of - * that doc. If an attribute implements {@link PrintRequestAttribute - * PrintRequestAttribute} as well as DocAttribute, the client may include the - * attribute in a attribute set which specifies a print job - * to specify a characteristic for all the docs in that job. + * Interface {@code DocAttribute} is a tagging interface which a printing + * attribute class implements to indicate the attribute denotes a setting for a + * doc. ("Doc" is a short, easy-to-pronounce term that means "a piece of print + * data.") The client may include a {@code DocAttribute} in a {@code Doc}'s + * attribute set to specify a characteristic of that doc. If an attribute + * implements {@link PrintRequestAttribute PrintRequestAttribute} as well as + * {@code DocAttribute}, the client may include the attribute in a attribute set + * which specifies a print job to specify a characteristic for all the docs in + * that job. * + * @author Alan Kaminsky * @see DocAttributeSet * @see PrintRequestAttributeSet - * - * @author Alan Kaminsky */ public interface DocAttribute extends Attribute { - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/DocAttributeSet.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/DocAttributeSet.java index bd8433dc32b..102786da27b 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/DocAttributeSet.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/DocAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,88 +23,70 @@ * questions. */ - package javax.print.attribute; /** - * Interface DocAttributeSet specifies the interface for a set of doc - * attributes, i.e. printing attributes that implement interface {@link - * DocAttribute DocAttribute}. In the Print Service API, the client uses a - * DocAttributeSet to specify the characteristics of an individual doc and - * the print job settings to be applied to an individual doc. - *

- * A DocAttributeSet is just an {@link AttributeSet AttributeSet} whose + * Interface {@code DocAttributeSet} specifies the interface for a set of doc + * attributes, i.e. printing attributes that implement interface + * {@link DocAttribute DocAttribute}. In the Print Service API, the client uses + * a {@code DocAttributeSet} to specify the characteristics of an individual doc + * and the print job settings to be applied to an individual doc. + *

+ * A {@code DocAttributeSet} is just an {@link AttributeSet AttributeSet} whose * constructors and mutating operations guarantee an additional invariant, - * namely that all attribute values in the DocAttributeSet must be instances - * of interface {@link DocAttribute DocAttribute}. - * The {@link #add(Attribute) add(Attribute)}, and - * {@link #addAll(AttributeSet) addAll(AttributeSet)} operations - * are respecified below to guarantee this additional invariant. + * namely that all attribute values in the {@code DocAttributeSet} must be + * instances of interface {@link DocAttribute DocAttribute}. The + * {@link #add(Attribute) add(Attribute)}, and + * {@link #addAll(AttributeSet) addAll(AttributeSet)} operations are respecified + * below to guarantee this additional invariant. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public interface DocAttributeSet extends AttributeSet { - /** * Adds the specified attribute value to this attribute set if it is not - * already present, first removing any existing value in the same - * attribute category as the specified attribute value (optional - * operation). + * already present, first removing any existing value in the same attribute + * category as the specified attribute value (optional operation). * - * @param attribute Attribute value to be added to this attribute set. - * - * @return {@code true} if this attribute set changed as a result of - * the call, i.e., the given attribute value was not already a - * member of this attribute set. - * - * @throws UnmodifiableSetException - * (unchecked exception) Thrown if this attribute set does not - * support the {@code add()} operation. - * @throws ClassCastException - * (unchecked exception) Thrown if the {@code attribute} is - * not an instance of interface - * {@link DocAttribute DocAttribute}. - * @throws NullPointerException - * (unchecked exception) Thrown if the {@code attribute} is null. + * @param attribute attribute value to be added to this attribute set + * @return {@code true} if this attribute set changed as a result of the + * call, i.e., the given attribute value was not already a member of + * this attribute set + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code add()} operation + * @throws ClassCastException if the {@code attribute} is not an instance of + * interface {@link DocAttribute DocAttribute} + * @throws NullPointerException if the {@code attribute} is {@code null} */ public boolean add(Attribute attribute); /** - * Adds all of the elements in the specified set to this attribute. - * The outcome is the same as if the - * {@link #add(Attribute) add(Attribute)} - * operation had been applied to this attribute set successively with - * each element from the specified set. If none of the categories in the - * specified set are the same as any categories in this attribute set, - * the {@code addAll()} operation effectively modifies this attribute - * set so that its value is the union of the two sets. - *

- * The behavior of the {@code addAll()} operation is unspecified if - * the specified set is modified while the operation is in progress. - *

- * If the {@code addAll()} operation throws an exception, the effect - * on this attribute set's state is implementation dependent; elements - * from the specified set before the point of the exception may or - * may not have been added to this attribute set. - * - * @param attributes whose elements are to be added to this attribute - * set. - * - * @return {@code true} if this attribute set changed as a result of - * the call. - * - * @throws UnmodifiableSetException - * (Unchecked exception) Thrown if this attribute set does not - * support the {@code addAll()} method. - * @throws ClassCastException - * (Unchecked exception) Thrown if some element in the specified - * set is not an instance of interface {@link DocAttribute - * DocAttribute}. - * @throws NullPointerException - * (Unchecked exception) Thrown if the specified set is null. + * Adds all of the elements in the specified set to this attribute. The + * outcome is the same as if the {@link #add(Attribute) add(Attribute)} + * operation had been applied to this attribute set successively with each + * element from the specified set. If none of the categories in the + * specified set are the same as any categories in this attribute set, the + * {@code addAll()} operation effectively modifies this attribute set so + * that its value is the union of the two sets. + *

+ * The behavior of the {@code addAll()} operation is unspecified if the + * specified set is modified while the operation is in progress. + *

+ * If the {@code addAll()} operation throws an exception, the effect on this + * attribute set's state is implementation dependent; elements from the + * specified set before the point of the exception may or may not have been + * added to this attribute set. * + * @param attributes whose elements are to be added to this attribute set + * @return {@code true} if this attribute set changed as a result of the + * call + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code addAll()} method + * @throws ClassCastException if some element in the specified set is not an + * instance of interface {@link DocAttribute DocAttribute} + * @throws NullPointerException if the specified set is {@code null} * @see #add(Attribute) */ - public boolean addAll(AttributeSet attributes); + public boolean addAll(AttributeSet attributes); } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/EnumSyntax.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/EnumSyntax.java index 2b3470c5da4..250f56eba80 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/EnumSyntax.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/EnumSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,7 +23,6 @@ * questions. */ - package javax.print.attribute; import java.io.InvalidObjectException; @@ -31,11 +30,13 @@ import java.io.ObjectStreamException; import java.io.Serializable; /** - * Class EnumSyntax is an abstract base class providing the common + * Class {@code EnumSyntax} is an abstract base class providing the common * implementation of all "type safe enumeration" objects. An enumeration class - * (which extends class EnumSyntax) provides a group of enumeration values - * (objects) that are singleton instances of the enumeration class; for example: - *

+ * (which extends class {@code EnumSyntax}) provides a group of enumeration
+ * values (objects) that are singleton instances of the enumeration class; for
+ * example:
+ *
+ * 
  *     public class Bach extends EnumSyntax {
  *         public static final Bach JOHANN_SEBASTIAN     = new Bach(0);
  *         public static final Bach WILHELM_FRIEDEMANN   = new Bach(1);
@@ -67,51 +68,54 @@ import java.io.Serializable;
  *             return enumValueTable;
  *         }
  *     }
- * 
- * You can then write code that uses the {@code ==} and {@code !=} - * operators to test enumeration values; for example: - *
+ * 
+ * You can then write code that uses the {@code ==} and {@code !=} operators to + * test enumeration values; for example: + *
  *     Bach theComposer;
  *     . . .
  *     if (theComposer == Bach.JOHANN_SEBASTIAN) {
  *         System.out.println ("The greatest composer of all time!");
  *     }
- * 
- * The {@code equals()} method for an enumeration class just does a test - * for identical objects ({@code ==}). - *

- * You can convert an enumeration value to a string by calling {@link - * #toString() toString()}. The string is obtained from a table - * supplied by the enumeration class. - *

+ *

+ * The {@code equals()} method for an enumeration class just does a test for + * identical objects ({@code ==}). + *

+ * You can convert an enumeration value to a string by calling + * {@link #toString() toString()}. The string is obtained from a table supplied + * by the enumeration class. + *

* Under the hood, an enumeration value is just an integer, a different integer * for each enumeration value within an enumeration class. You can get an - * enumeration value's integer value by calling {@link #getValue() - * getValue()}. An enumeration value's integer value is established - * when it is constructed (see {@link #EnumSyntax(int) - * EnumSyntax(int)}). Since the constructor is protected, the only - * possible enumeration values are the singleton objects declared in the - * enumeration class; additional enumeration values cannot be created at run - * time. - *

+ * enumeration value's integer value by calling {@link #getValue() getValue()}. + * An enumeration value's integer value is established when it is constructed + * (see {@link #EnumSyntax(int) EnumSyntax(int)}). Since the constructor is + * protected, the only possible enumeration values are the singleton objects + * declared in the enumeration class; additional enumeration values cannot be + * created at run time. + *

* You can define a subclass of an enumeration class that extends it with * additional enumeration values. The subclass's enumeration values' integer * values need not be distinct from the superclass's enumeration values' integer - * values; the {@code ==}, {@code !=}, {@code equals()}, and - * {@code toString()} methods will still work properly even if the subclass - * uses some of the same integer values as the superclass. However, the - * application in which the enumeration class and subclass are used may need to - * have distinct integer values in the superclass and subclass. + * values; the {@code ==}, {@code !=}, {@code equals()}, and {@code toString()} + * methods will still work properly even if the subclass uses some of the same + * integer values as the superclass. However, the application in which the + * enumeration class and subclass are used may need to have distinct integer + * values in the superclass and subclass. * - * @author David Mendenhall - * @author Alan Kaminsky + * @author David Mendenhall + * @author Alan Kaminsky */ public abstract class EnumSyntax implements Serializable, Cloneable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -2739521845085831642L; /** * This enumeration value's integer value. + * * @serial */ private int value; @@ -119,7 +123,7 @@ public abstract class EnumSyntax implements Serializable, Cloneable { /** * Construct a new enumeration value with the given integer value. * - * @param value Integer value. + * @param value Integer value */ protected EnumSyntax(int value) { this.value = value; @@ -127,6 +131,7 @@ public abstract class EnumSyntax implements Serializable, Cloneable { /** * Returns this enumeration value's integer value. + * * @return the value */ public int getValue() { @@ -167,22 +172,20 @@ public abstract class EnumSyntax implements Serializable, Cloneable { * During object input, convert this deserialized enumeration instance to * the proper enumeration value defined in the enumeration attribute class. * - * @return The enumeration singleton value stored at index - * i-L in the enumeration value table returned by - * {@link #getEnumValueTable() getEnumValueTable()}, - * where i is this enumeration value's integer value and - * L is the value returned by {@link #getOffset() - * getOffset()}. - * + * @return The enumeration singleton value stored at index i-L + * in the enumeration value table returned by + * {@link #getEnumValueTable() getEnumValueTable()}, where i + * is this enumeration value's integer value and L is the + * value returned by {@link #getOffset() getOffset()} * @throws ObjectStreamException if the stream can't be deserialised - * @throws InvalidObjectException - * Thrown if the enumeration value table is null, this enumeration - * value's integer value does not correspond to an element in the - * enumeration value table, or the corresponding element in the - * enumeration value table is null. (Note: {@link - * java.io.InvalidObjectException InvalidObjectException} is a subclass - * of {@link java.io.ObjectStreamException ObjectStreamException}, which - * {@code readResolve()} is declared to throw.) + * @throws InvalidObjectException if the enumeration value table is + * {@code null}, this enumeration value's integer value does not + * correspond to an element in the enumeration value table, or the + * corresponding element in the enumeration value table is + * {@code null}. (Note: + * {@link InvalidObjectException InvalidObjectException} is a + * subclass of {@link ObjectStreamException ObjectStreamException}, + * which {@code readResolve()} is declared to throw.) */ protected Object readResolve() throws ObjectStreamException { @@ -218,20 +221,21 @@ public abstract class EnumSyntax implements Serializable, Cloneable { /** * Returns the string table for this enumeration value's enumeration class. * The enumeration class's integer values are assumed to lie in the range - * L..L+N-1, where L is the value returned by - * {@link #getOffset() getOffset()} and N is the length - * of the string table. The element in the string table at index - * i-L is the value returned by {@link #toString() - * toString()} for the enumeration value whose integer value - * is i. If an integer within the above range is not used by any - * enumeration value, leave the corresponding table element null. - *

- * The default implementation returns null. If the enumeration class (a - * subclass of class EnumSyntax) does not override this method to return a - * non-null string table, and the subclass does not override the {@link - * #toString() toString()} method, the base class {@link - * #toString() toString()} method will return just a string + * L..L+N-1, where L is the value returned by + * {@link #getOffset() getOffset()} and N is the length of the string + * table. The element in the string table at index i-L is the + * value returned by {@link #toString() toString()} for the enumeration + * value whose integer value is i. If an integer within the above + * range is not used by any enumeration value, leave the corresponding table + * element {@code null}. + *

+ * The default implementation returns {@code null}. If the enumeration class + * (a subclass of class {@code EnumSyntax}) does not override this method to + * return a {@code non-null} string table, and the subclass does not + * override the {@link #toString() toString()} method, the base class + * {@link #toString() toString()} method will return just a string * representation of this enumeration value's integer value. + * * @return the string table */ protected String[] getStringTable() { @@ -241,23 +245,24 @@ public abstract class EnumSyntax implements Serializable, Cloneable { /** * Returns the enumeration value table for this enumeration value's * enumeration class. The enumeration class's integer values are assumed to - * lie in the range L..L+N-1, where L is the - * value returned by {@link #getOffset() getOffset()} and - * N is the length of the enumeration value table. The element in the - * enumeration value table at index i-L is the enumeration - * value object whose integer value is i; the {@link #readResolve() - * readResolve()} method needs this to preserve singleton - * semantics during deserialization of an enumeration instance. If an - * integer within the above range is not used by any enumeration value, - * leave the corresponding table element null. - *

- * The default implementation returns null. If the enumeration class (a - * subclass of class EnumSyntax) does not override this method to return - * a non-null enumeration value table, and the subclass does not override - * the {@link #readResolve() readResolve()} method, the base - * class {@link #readResolve() readResolve()} method will throw - * an exception whenever an enumeration instance is deserialized from an - * object input stream. + * lie in the range L..L+N-1, where L is the + * value returned by {@link #getOffset() getOffset()} and N is the + * length of the enumeration value table. The element in the enumeration + * value table at index i-L is the enumeration value object + * whose integer value is i; the {@link #readResolve() readResolve()} + * method needs this to preserve singleton semantics during deserialization + * of an enumeration instance. If an integer within the above range is not + * used by any enumeration value, leave the corresponding table element + * {@code null}. + *

+ * The default implementation returns {@code null}. If the enumeration class + * (a subclass of class EnumSyntax) does not override this method to return + * a {@code non-null} enumeration value table, and the subclass does not + * override the {@link #readResolve() readResolve()} method, the base class + * {@link #readResolve() readResolve()} method will throw an exception + * whenever an enumeration instance is deserialized from an object input + * stream. + * * @return the value table */ protected EnumSyntax[] getEnumValueTable() { @@ -267,14 +272,14 @@ public abstract class EnumSyntax implements Serializable, Cloneable { /** * Returns the lowest integer value used by this enumeration value's * enumeration class. - *

+ *

* The default implementation returns 0. If the enumeration class (a - * subclass of class EnumSyntax) uses integer values starting at other than - * 0, override this method in the subclass. - * @return the offset of the lowest enumeration value. + * subclass of class {@code EnumSyntax}) uses integer values starting at + * other than 0, override this method in the subclass. + * + * @return the offset of the lowest enumeration value */ protected int getOffset() { return 0; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/HashAttributeSet.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/HashAttributeSet.java index 69a28c756cc..1d4f3e04f04 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/HashAttributeSet.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/HashAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -32,37 +32,42 @@ import java.io.Serializable; import java.util.HashMap; /** - * Class HashAttributeSet provides an {@code AttributeSet} + * Class {@code HashAttributeSet} provides an {@code AttributeSet} * implementation with characteristics of a hash map. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public class HashAttributeSet implements AttributeSet, Serializable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 5311560590283707917L; /** * The interface of which all members of this attribute set must be an - * instance. It is assumed to be interface {@link Attribute Attribute} - * or a subinterface thereof. + * instance. It is assumed to be interface {@link Attribute Attribute} or a + * subinterface thereof. + * * @serial */ private Class myInterface; - /* - * A HashMap used by the implementation. - * The serialised form doesn't include this instance variable. + /** + * A {@code HashMap} used by the implementation. The serialised form doesn't + * include this instance variable. */ private transient HashMap, Attribute> attrMap = new HashMap<>(); /** - * Write the instance to a stream (ie serialize the object) + * Write the instance to a stream (ie serialize the object). * - * @serialData - * The serialized form of an attribute set explicitly writes the - * number of attributes in the set, and each of the attributes. - * This does not guarantee equality of serialized forms since - * the order in which the attributes are written is not defined. + * @param s the output stream + * @throws IOException if an I/O exception has occurred + * @serialData The serialized form of an attribute set explicitly writes the + * number of attributes in the set, and each of the attributes. + * This does not guarantee equality of serialized forms since + * the order in which the attributes are written is not defined. */ private void writeObject(ObjectOutputStream s) throws IOException { @@ -76,6 +81,10 @@ public class HashAttributeSet implements AttributeSet, Serializable { /** * Reconstitute an instance from a stream that is, deserialize it). + * + * @param s the input stream + * @throws ClassNotFoundException if the class is not found + * @throws IOException if an I/O exception has occurred */ private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException { @@ -98,59 +107,51 @@ public class HashAttributeSet implements AttributeSet, Serializable { } /** - * Construct a new attribute set, - * initially populated with the given attribute. + * Construct a new attribute set, initially populated with the given + * attribute. * - * @param attribute Attribute value to add to the set. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code attribute} is null. + * @param attribute attribute value to add to the set + * @throws NullPointerException if {@code attribute} is {@code null} */ public HashAttributeSet(Attribute attribute) { this (attribute, Attribute.class); } /** - * Construct a new attribute set, - * initially populated with the values from the - * given array. The new attribute set is populated by - * adding the elements of {@code attributes} array to the set in - * sequence, starting at index 0. Thus, later array elements may replace - * earlier array elements if the array contains duplicate attribute - * values or attribute categories. + * Construct a new attribute set, initially populated with the values from + * the given array. The new attribute set is populated by adding the + * elements of {@code attributes} array to the set in sequence, starting at + * index 0. Thus, later array elements may replace earlier array elements if + * the array contains duplicate attribute values or attribute categories. * - * @param attributes Array of attribute values to add to the set. - * If null, an empty attribute set is constructed. - * - * @exception NullPointerException - * (unchecked exception) Thrown if any element of - * {@code attributes} is null. + * @param attributes array of attribute values to add to the set. If + * {@code null}, an empty attribute set is constructed. + * @throws NullPointerException if any element of {@code attributes} is + * {@code null} */ public HashAttributeSet(Attribute[] attributes) { this (attributes, Attribute.class); } /** - * Construct a new attribute set, - * initially populated with the values from the given set. - * - * @param attributes Set of attributes from which to initialise this set. - * If null, an empty attribute set is constructed. + * Construct a new attribute set, initially populated with the values from + * the given set. * + * @param attributes set of attributes from which to initialise this set. + * If {@code null}, an empty attribute set is constructed. */ public HashAttributeSet(AttributeSet attributes) { this (attributes, Attribute.class); } /** - * Construct a new, empty attribute set, where the members of - * the attribute set are restricted to the given interface. + * Construct a new, empty attribute set, where the members of the attribute + * set are restricted to the given interface. * - * @param interfaceName The interface of which all members of this - * attribute set must be an instance. It is assumed to - * be interface {@link Attribute Attribute} or a - * subinterface thereof. - * @exception NullPointerException if interfaceName is null. + * @param interfaceName the interface of which all members of this + * attribute set must be an instance. It is assumed to be interface + * {@link Attribute Attribute} or a subinterface thereof. + * @throws NullPointerException if {@code interfaceName} is {@code null} */ protected HashAttributeSet(Class interfaceName) { if (interfaceName == null) { @@ -164,18 +165,14 @@ public class HashAttributeSet implements AttributeSet, Serializable { * attribute, where the members of the attribute set are restricted to the * given interface. * - * @param attribute Attribute value to add to the set. - * @param interfaceName The interface of which all members of this - * attribute set must be an instance. It is assumed to - * be interface {@link Attribute Attribute} or a - * subinterface thereof. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code attribute} is null. - * @exception NullPointerException if interfaceName is null. - * @exception ClassCastException - * (unchecked exception) Thrown if {@code attribute} is not an - * instance of {@code interfaceName}. + * @param attribute attribute value to add to the set + * @param interfaceName the interface of which all members of this + * attribute set must be an instance. It is assumed to be interface + * {@link Attribute Attribute} or a subinterface thereof. + * @throws NullPointerException if {@code attribute} or + * {@code interfaceName} are {@code null} + * @throws ClassCastException if {@code attribute} is not an instance of + * {@code interfaceName} */ protected HashAttributeSet(Attribute attribute, Class interfaceName) { if (interfaceName == null) { @@ -186,29 +183,22 @@ public class HashAttributeSet implements AttributeSet, Serializable { } /** - * Construct a new attribute set, where the members of the attribute - * set are restricted to the given interface. - * The new attribute set is populated - * by adding the elements of {@code attributes} array to the set in - * sequence, starting at index 0. Thus, later array elements may replace - * earlier array elements if the array contains duplicate attribute - * values or attribute categories. + * Construct a new attribute set, where the members of the attribute set are + * restricted to the given interface. The new attribute set is populated by + * adding the elements of {@code attributes} array to the set in sequence, + * starting at index 0. Thus, later array elements may replace earlier array + * elements if the array contains duplicate attribute values or attribute + * categories. * - * @param attributes Array of attribute values to add to the set. If - * null, an empty attribute set is constructed. - * @param interfaceName The interface of which all members of this - * attribute set must be an instance. It is assumed to - * be interface {@link Attribute Attribute} or a - * subinterface thereof. - * - * @exception NullPointerException - * (unchecked exception) Thrown if any element of - * {@code attributes} is null. - * @exception NullPointerException if interfaceName is null. - * @exception ClassCastException - * (unchecked exception) Thrown if any element of - * {@code attributes} is not an instance of - * {@code interfaceName}. + * @param attributes array of attribute values to add to the set. If + * {@code null}, an empty attribute set is constructed. + * @param interfaceName the interface of which all members of this + * attribute set must be an instance. It is assumed to be interface + * {@link Attribute Attribute} or a subinterface thereof. + * @throws NullPointerException if {@code interfaceName} is {@code null}, or + * if any element of {@code attributes} is {@code null} + * @throws ClassCastException if any element of {@code attributes} is not an + * instance of {@code interfaceName} */ protected HashAttributeSet(Attribute[] attributes, Class interfaceName) { if (interfaceName == null) { @@ -222,21 +212,17 @@ public class HashAttributeSet implements AttributeSet, Serializable { } /** - * Construct a new attribute set, initially populated with the - * values from the given set where the members of the attribute - * set are restricted to the given interface. + * Construct a new attribute set, initially populated with the values from + * the given set where the members of the attribute set are restricted to + * the given interface. * * @param attributes set of attribute values to initialise the set. If - * null, an empty attribute set is constructed. - * @param interfaceName The interface of which all members of this - * attribute set must be an instance. It is assumed to - * be interface {@link Attribute Attribute} or a - * subinterface thereof. - * - * @exception ClassCastException - * (unchecked exception) Thrown if any element of - * {@code attributes} is not an instance of - * {@code interfaceName}. + * {@code null}, an empty attribute set is constructed. + * @param interfaceName The interface of which all members of this + * attribute set must be an instance. It is assumed to be interface + * {@link Attribute Attribute} or a subinterface thereof. + * @throws ClassCastException if any element of {@code attributes} is not an + * instance of {@code interfaceName} */ protected HashAttributeSet(AttributeSet attributes, Class interfaceName) { myInterface = interfaceName; @@ -251,26 +237,19 @@ public class HashAttributeSet implements AttributeSet, Serializable { /** * Returns the attribute value which this attribute set contains in the - * given attribute category. Returns {@code null} if this attribute set - * does not contain any attribute value in the given attribute category. + * given attribute category. Returns {@code null} if this attribute set does + * not contain any attribute value in the given attribute category. * - * @param category Attribute category whose associated attribute value - * is to be returned. It must be a - * {@link java.lang.Class Class} - * that implements interface {@link Attribute - * Attribute}. - * - * @return The attribute value in the given attribute category contained - * in this attribute set, or {@code null} if this attribute set - * does not contain any attribute value in the given attribute - * category. - * - * @throws NullPointerException - * (unchecked exception) Thrown if the {@code category} is null. - * @throws ClassCastException - * (unchecked exception) Thrown if the {@code category} is not a - * {@link java.lang.Class Class} that implements interface {@link - * Attribute Attribute}. + * @param category attribute category whose associated attribute value is + * to be returned. It must be a {@link Class Class} that implements + * interface {@link Attribute Attribute}. + * @return the attribute value in the given attribute category contained in + * this attribute set, or {@code null} if this attribute set does + * not contain any attribute value in the given attribute category + * @throws NullPointerException if the {@code category} is {@code null} + * @throws ClassCastException if the {@code category} is not a + * {@link Class Class} that implements interface + * {@link Attribute Attribute} */ public Attribute get(Class category) { return attrMap.get(AttributeSetUtilities. @@ -279,21 +258,17 @@ public class HashAttributeSet implements AttributeSet, Serializable { } /** - * Adds the specified attribute to this attribute set if it is not - * already present, first removing any existing in the same - * attribute category as the specified attribute value. + * Adds the specified attribute to this attribute set if it is not already + * present, first removing any existing in the same attribute category as + * the specified attribute value. * - * @param attribute Attribute value to be added to this attribute set. - * - * @return {@code true} if this attribute set changed as a result of the - * call, i.e., the given attribute value was not already a - * member of this attribute set. - * - * @throws NullPointerException - * (unchecked exception) Thrown if the {@code attribute} is null. - * @throws UnmodifiableSetException - * (unchecked exception) Thrown if this attribute set does not support - * the {@code add()} operation. + * @param attribute attribute value to be added to this attribute set + * @return {@code true} if this attribute set changed as a result of the + * call, i.e., the given attribute value was not already a member of + * this attribute set + * @throws NullPointerException if the {@code attribute} is {@code null} + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code add()} operation */ public boolean add(Attribute attribute) { Object oldAttribute = @@ -305,19 +280,15 @@ public class HashAttributeSet implements AttributeSet, Serializable { /** * Removes any attribute for this category from this attribute set if - * present. If {@code category} is null, then - * {@code remove()} does nothing and returns {@code false}. + * present. If {@code category} is {@code null}, then {@code remove()} does + * nothing and returns {@code false}. * - * @param category Attribute category to be removed from this - * attribute set. - * - * @return {@code true} if this attribute set changed as a result of the + * @param category attribute category to be removed from this attribute set + * @return {@code true} if this attribute set changed as a result of the * call, i.e., the given attribute category had been a member of - * this attribute set. - * - * @throws UnmodifiableSetException - * (unchecked exception) Thrown if this attribute set does not - * support the {@code remove()} operation. + * this attribute set + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code remove()} operation */ public boolean remove(Class category) { return @@ -328,19 +299,16 @@ public class HashAttributeSet implements AttributeSet, Serializable { } /** - * Removes the specified attribute from this attribute set if - * present. If {@code attribute} is null, then - * {@code remove()} does nothing and returns {@code false}. + * Removes the specified attribute from this attribute set if present. If + * {@code attribute} is {@code null}, then {@code remove()} does nothing and + * returns {@code false}. * - * @param attribute Attribute value to be removed from this attribute set. - * - * @return {@code true} if this attribute set changed as a result of the - * call, i.e., the given attribute value had been a member of - * this attribute set. - * - * @throws UnmodifiableSetException - * (unchecked exception) Thrown if this attribute set does not - * support the {@code remove()} operation. + * @param attribute attribute value to be removed from this attribute set + * @return {@code true} if this attribute set changed as a result of the + * call, i.e., the given attribute value had been a member of this + * attribute set + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code remove()} operation */ public boolean remove(Attribute attribute) { return @@ -349,14 +317,12 @@ public class HashAttributeSet implements AttributeSet, Serializable { } /** - * Returns {@code true} if this attribute set contains an - * attribute for the specified category. + * Returns {@code true} if this attribute set contains an attribute for the + * specified category. * - * @param category whose presence in this attribute set is - * to be tested. - * - * @return {@code true} if this attribute set contains an attribute - * value for the specified category. + * @param category whose presence in this attribute set is to be tested + * @return {@code true} if this attribute set contains an attribute value + * for the specified category */ public boolean containsKey(Class category) { return @@ -367,14 +333,12 @@ public class HashAttributeSet implements AttributeSet, Serializable { } /** - * Returns {@code true} if this attribute set contains the given - * attribute. + * Returns {@code true} if this attribute set contains the given attribute. * - * @param attribute value whose presence in this attribute set is - * to be tested. - * - * @return {@code true} if this attribute set contains the given - * attribute value. + * @param attribute value whose presence in this attribute set is to be + * tested + * @return {@code true} if this attribute set contains the given attribute + * value */ public boolean containsValue(Attribute attribute) { return @@ -384,33 +348,25 @@ public class HashAttributeSet implements AttributeSet, Serializable { } /** - * Adds all of the elements in the specified set to this attribute. - * The outcome is the same as if the - * {@link #add(Attribute) add(Attribute)} - * operation had been applied to this attribute set successively with - * each element from the specified set. - * The behavior of the {@code addAll(AttributeSet)} - * operation is unspecified if the specified set is modified while - * the operation is in progress. - *

- * If the {@code addAll(AttributeSet)} operation throws an exception, - * the effect on this attribute set's state is implementation dependent; - * elements from the specified set before the point of the exception may - * or may not have been added to this attribute set. - * - * @param attributes whose elements are to be added to this attribute - * set. - * - * @return {@code true} if this attribute set changed as a result of the - * call. - * - * @throws UnmodifiableSetException - * (Unchecked exception) Thrown if this attribute set does not - * support the {@code addAll(AttributeSet)} method. - * @throws NullPointerException - * (Unchecked exception) Thrown if some element in the specified - * set is null, or the set is null. + * Adds all of the elements in the specified set to this attribute. The + * outcome is the same as if the {@link #add(Attribute) add(Attribute)} + * operation had been applied to this attribute set successively with each + * element from the specified set. The behavior of the + * {@code addAll(AttributeSet)} operation is unspecified if the specified + * set is modified while the operation is in progress. + *

+ * If the {@code addAll(AttributeSet)} operation throws an exception, the + * effect on this attribute set's state is implementation dependent; + * elements from the specified set before the point of the exception may or + * may not have been added to this attribute set. * + * @param attributes whose elements are to be added to this attribute set + * @return {@code true} if this attribute set changed as a result of the + * call + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code addAll(AttributeSet)} method + * @throws NullPointerException if some element in the specified set is + * {@code null}, or the set is {@code null} * @see #add(Attribute) */ public boolean addAll(AttributeSet attributes) { @@ -428,20 +384,21 @@ public class HashAttributeSet implements AttributeSet, Serializable { } /** - * Returns the number of attributes in this attribute set. If this - * attribute set contains more than {@code Integer.MAX_VALUE} elements, - * returns {@code Integer.MAX_VALUE}. + * Returns the number of attributes in this attribute set. If this attribute + * set contains more than {@code Integer.MAX_VALUE} elements, returns + * {@code Integer.MAX_VALUE}. * - * @return The number of attributes in this attribute set. + * @return the number of attributes in this attribute set */ public int size() { return attrMap.size(); } /** + * Returns an array of the attributes contained in this set. * - * @return the Attributes contained in this set as an array, zero length - * if the AttributeSet is empty. + * @return the attributes contained in this set as an array, zero length if + * the {@code AttributeSet} is empty */ public Attribute[] toArray() { Attribute []attrs = new Attribute[size()]; @@ -449,22 +406,20 @@ public class HashAttributeSet implements AttributeSet, Serializable { return attrs; } - /** * Removes all attributes from this attribute set. * - * @throws UnmodifiableSetException - * (unchecked exception) Thrown if this attribute set does not support - * the {@code clear()} operation. + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code clear()} operation */ public void clear() { attrMap.clear(); } - /** - * Returns true if this attribute set contains no attributes. + /** + * Returns {@code true} if this attribute set contains no attributes. * - * @return true if this attribute set contains no attributes. + * @return {@code true} if this attribute set contains no attributes */ public boolean isEmpty() { return attrMap.isEmpty(); @@ -472,18 +427,15 @@ public class HashAttributeSet implements AttributeSet, Serializable { /** * Compares the specified object with this attribute set for equality. - * Returns {@code true} if the given object is also an attribute set and - * the two attribute sets contain the same attribute category-attribute - * value mappings. This ensures that the - * {@code equals()} method works properly across different - * implementations of the AttributeSet interface. + * Returns {@code true} if the given object is also an attribute set and the + * two attribute sets contain the same attribute category-attribute value + * mappings. This ensures that the {@code equals()} method works properly + * across different implementations of the {@code AttributeSet} interface. * - * @param object to be compared for equality with this attribute set. - * - * @return {@code true} if the specified object is equal to this - * attribute set. + * @param object to be compared for equality with this attribute set + * @return {@code true} if the specified object is equal to this attribute + * set */ - public boolean equals(Object object) { if (object == null || !(object instanceof AttributeSet)) { return false; @@ -504,15 +456,14 @@ public class HashAttributeSet implements AttributeSet, Serializable { } /** - * Returns the hash code value for this attribute set. - * The hash code of an attribute set is defined to be the sum - * of the hash codes of each entry in the AttributeSet. - * This ensures that {@code t1.equals(t2)} implies that - * {@code t1.hashCode()==t2.hashCode()} for any two attribute sets + * Returns the hash code value for this attribute set. The hash code of an + * attribute set is defined to be the sum of the hash codes of each entry in + * the {@code AttributeSet}. This ensures that {@code t1.equals(t2)} implies + * that {@code t1.hashCode()==t2.hashCode()} for any two attribute sets * {@code t1} and {@code t2}, as required by the general contract of - * {@link java.lang.Object#hashCode() Object.hashCode()}. + * {@link Object#hashCode() Object.hashCode()}. * - * @return The hash code value for this attribute set. + * @return the hash code value for this attribute set */ public int hashCode() { int hcode = 0; @@ -522,5 +473,4 @@ public class HashAttributeSet implements AttributeSet, Serializable { } return hcode; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/HashDocAttributeSet.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/HashDocAttributeSet.java index 5742a074420..69067b7bff6 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/HashDocAttributeSet.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/HashDocAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,22 +23,24 @@ * questions. */ - package javax.print.attribute; import java.io.Serializable; /** - * Class HashDocAttributeSet provides an attribute set which - * inherits its implementation from class {@link HashAttributeSet - * HashAttributeSet} and enforces the semantic restrictions of interface {@link - * DocAttributeSet DocAttributeSet}. + * Class {@code HashDocAttributeSet} provides an attribute set which inherits + * its implementation from class {@link HashAttributeSet HashAttributeSet} and + * enforces the semantic restrictions of interface + * {@link DocAttributeSet DocAttributeSet}. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public class HashDocAttributeSet extends HashAttributeSet implements DocAttributeSet, Serializable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -1128534486061432528L; /** @@ -49,53 +51,43 @@ public class HashDocAttributeSet extends HashAttributeSet } /** - * Construct a new hash doc attribute set, - * initially populated with the given value. + * Construct a new hash doc attribute set, initially populated with the + * given value. * - * @param attribute Attribute value to add to the set. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code attribute} is null. + * @param attribute attribute value to add to the set + * @throws NullPointerException if {@code attribute} is {@code null} */ public HashDocAttributeSet(DocAttribute attribute) { super (attribute, DocAttribute.class); } /** - * Construct a new hash doc attribute set, - * initially populated with the values from the given array. - * The new attribute set is populated by - * adding the elements of {@code attributes} array to the set in - * sequence, starting at index 0. Thus, later array elements may replace - * earlier array elements if the array contains duplicate attribute - * values or attribute categories. + * Construct a new hash doc attribute set, initially populated with the + * values from the given array. The new attribute set is populated by adding + * the elements of {@code attributes} array to the set in sequence, starting + * at index 0. Thus, later array elements may replace earlier array elements + * if the array contains duplicate attribute values or attribute categories. * - * @param attributes Array of attribute values to add to the set. - * If null, an empty attribute set is constructed. - * - * @exception NullPointerException - * (unchecked exception) - * Thrown if any element of {@code attributes} is null. + * @param attributes array of attribute values to add to the set. If + * {@code null}, an empty attribute set is constructed. + * @throws NullPointerException if any element of {@code attributes} is + * {@code null} */ public HashDocAttributeSet(DocAttribute[] attributes) { super (attributes, DocAttribute.class); } /** - * Construct a new attribute set, initially populated with the - * values from the given set where the members of the attribute set - * are restricted to the {@code DocAttribute} interface. + * Construct a new attribute set, initially populated with the values from + * the given set where the members of the attribute set are restricted to + * the {@code DocAttribute} interface. * * @param attributes set of attribute values to initialise the set. If - * null, an empty attribute set is constructed. - * - * @exception ClassCastException - * (unchecked exception) Thrown if any element of - * {@code attributes} is not an instance of - * {@code DocAttribute}. + * {@code null}, an empty attribute set is constructed. + * @throws ClassCastException if any element of {@code attributes} is not an + * instance of {@code DocAttribute} */ public HashDocAttributeSet(DocAttributeSet attributes) { super(attributes, DocAttribute.class); } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/HashPrintJobAttributeSet.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/HashPrintJobAttributeSet.java index e9971e9a45c..7ad5afb830d 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/HashPrintJobAttributeSet.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/HashPrintJobAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,22 +23,24 @@ * questions. */ - package javax.print.attribute; import java.io.Serializable; /** - * Class HashPrintJobAttributeSet provides an attribute set - * which inherits its implementation from class {@link HashAttributeSet - * HashAttributeSet} and enforces the semantic restrictions of interface - * {@link PrintJobAttributeSet PrintJobAttributeSet}. + * Class {@code HashPrintJobAttributeSet} provides an attribute set which + * inherits its implementation from class + * {@link HashAttributeSet HashAttributeSet} and enforces the semantic + * restrictions of interface {@link PrintJobAttributeSet PrintJobAttributeSet}. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public class HashPrintJobAttributeSet extends HashAttributeSet implements PrintJobAttributeSet, Serializable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -4204473656070350348L; /** @@ -49,49 +51,42 @@ public class HashPrintJobAttributeSet extends HashAttributeSet } /** - * Construct a new hash print job attribute set, - * initially populated with the given value. + * Construct a new hash print job attribute set, initially populated with + * the given value. * - * @param attribute Attribute value to add to the set. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code attribute} is null. + * @param attribute attribute value to add to the set + * @throws NullPointerException if {@code attribute} is {@code null} */ public HashPrintJobAttributeSet(PrintJobAttribute attribute) { super(attribute, PrintJobAttribute.class); } /** - * Construct a new hash print job attribute set, - * initially populated with the values from the given array. - * The new attribute set is populated - * by adding the elements of {@code attributes} array to the set in - * sequence, starting at index 0. Thus, later array elements may replace - * earlier array elements if the array contains duplicate attribute - * values or attribute categories. + * Construct a new hash print job attribute set, initially populated with + * the values from the given array. The new attribute set is populated by + * adding the elements of {@code attributes} array to the set in sequence, + * starting at index 0. Thus, later array elements may replace earlier array + * elements if the array contains duplicate attribute values or attribute + * categories. * - * @param attributes Array of attribute values to add to the set. - * If null, an empty attribute set is constructed. - * - * @exception NullPointerException (unchecked exception) - * Thrown if any element of {@code attributes} is null. + * @param attributes array of attribute values to add to the set. If + * {@code null}, an empty attribute set is constructed. + * @throws NullPointerException if any element of {@code attributes} is + * {@code null} */ public HashPrintJobAttributeSet(PrintJobAttribute[] attributes) { super (attributes, PrintJobAttribute.class); } /** - * Construct a new attribute set, initially populated with the - * values from the given set where the members of the attribute set - * are restricted to the {@code PrintJobAttribute} interface. + * Construct a new attribute set, initially populated with the values from + * the given set where the members of the attribute set are restricted to + * the {@code PrintJobAttribute} interface. * * @param attributes set of attribute values to initialise the set. If - * null, an empty attribute set is constructed. - * - * @exception ClassCastException - * (unchecked exception) Thrown if any element of - * {@code attributes} is not an instance of - * {@code PrintJobAttribute}. + * {@code null}, an empty attribute set is constructed. + * @throws ClassCastException if any element of {@code attributes} is not an + * instance of {@code PrintJobAttribute} */ public HashPrintJobAttributeSet(PrintJobAttributeSet attributes) { super(attributes, PrintJobAttribute.class); diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/HashPrintRequestAttributeSet.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/HashPrintRequestAttributeSet.java index 9ef717500e7..b85961ba40c 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/HashPrintRequestAttributeSet.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/HashPrintRequestAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,22 +23,24 @@ * questions. */ - package javax.print.attribute; import java.io.Serializable; /** - * Class HashPrintRequestAttributeSet inherits its implementation from - * class {@link HashAttributeSet HashAttributeSet} and enforces the - * semantic restrictions of interface + * Class {@code HashPrintRequestAttributeSet} inherits its implementation from + * class {@link HashAttributeSet HashAttributeSet} and enforces the semantic + * restrictions of interface * {@link PrintRequestAttributeSet PrintRequestAttributeSet}. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public class HashPrintRequestAttributeSet extends HashAttributeSet implements PrintRequestAttributeSet, Serializable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 2364756266107751933L; /** @@ -49,55 +51,44 @@ public class HashPrintRequestAttributeSet extends HashAttributeSet } /** - * Construct a new print request attribute set, - * initially populated with the given value. + * Construct a new print request attribute set, initially populated with the + * given value. * - * @param attribute Attribute value to add to the set. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code attribute} is null. + * @param attribute attribute value to add to the set + * @throws NullPointerException if {@code attribute} is {@code null} */ public HashPrintRequestAttributeSet(PrintRequestAttribute attribute) { super (attribute, PrintRequestAttribute.class); } /** - * Construct a new print request attribute set, initially populated with - * the values from the given array. The new attribute set is populated - * by adding the elements of {@code attributes} array to the set in - * sequence, starting at index 0. Thus, later array elements may replace - * earlier array elements if the array contains duplicate attribute - * values or attribute categories. + * Construct a new print request attribute set, initially populated with the + * values from the given array. The new attribute set is populated by adding + * the elements of {@code attributes} array to the set in sequence, starting + * at index 0. Thus, later array elements may replace earlier array elements + * if the array contains duplicate attribute values or attribute categories. * - * @param attributes Array of attribute values to add to the set. - * If null, an empty attribute set is constructed. - * - * @exception NullPointerException - * (unchecked exception) - * Thrown if any element of {@code attributes} is null. + * @param attributes array of attribute values to add to the set. If + * {@code null}, an empty attribute set is constructed. + * @throws NullPointerException if any element of {@code attributes} is + * {@code null} */ public HashPrintRequestAttributeSet(PrintRequestAttribute[] attributes) { super (attributes, PrintRequestAttribute.class); } - /** - * Construct a new attribute set, initially populated with the - * values from the given set where the members of the attribute set - * are restricted to the {@code (PrintRequestAttributeSe} interface. + * Construct a new attribute set, initially populated with the values from + * the given set where the members of the attribute set are restricted to + * the {@code (PrintRequestAttributeSe} interface. * * @param attributes set of attribute values to initialise the set. If - * null, an empty attribute set is constructed. - * - * @exception ClassCastException - * (unchecked exception) Thrown if any element of - * {@code attributes} is not an instance of - * {@code (PrintRequestAttributeSe}. + * {@code null}, an empty attribute set is constructed. + * @throws ClassCastException if any element of {@code attributes} is not an + * instance of {@code PrintRequestAttributeSe} */ public HashPrintRequestAttributeSet(PrintRequestAttributeSet attributes) { super(attributes, PrintRequestAttribute.class); } - - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/HashPrintServiceAttributeSet.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/HashPrintServiceAttributeSet.java index 31bd2ec738c..721af0f3e24 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/HashPrintServiceAttributeSet.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/HashPrintServiceAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -28,16 +28,20 @@ package javax.print.attribute; import java.io.Serializable; /** - * Class HashPrintServiceAttributeSet provides an attribute set - * which inherits its implementation from class {@link HashAttributeSet - * HashAttributeSet} and enforces the semantic restrictions of interface + * Class {@code HashPrintServiceAttributeSet} provides an attribute set which + * inherits its implementation from class + * {@link HashAttributeSet HashAttributeSet} and enforces the semantic + * restrictions of interface * {@link PrintServiceAttributeSet PrintServiceAttributeSet}. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public class HashPrintServiceAttributeSet extends HashAttributeSet implements PrintServiceAttributeSet, Serializable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 6642904616179203070L; /** @@ -47,52 +51,42 @@ public class HashPrintServiceAttributeSet extends HashAttributeSet super (PrintServiceAttribute.class); } - /** - * Construct a new hash print service attribute set, - * initially populated with the given value. + * Construct a new hash print service attribute set, initially populated + * with the given value. * - * @param attribute Attribute value to add to the set. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code attribute} is null. + * @param attribute attribute value to add to the set + * @throws NullPointerException if {@code attribute} is {@code null} */ public HashPrintServiceAttributeSet(PrintServiceAttribute attribute) { super (attribute, PrintServiceAttribute.class); } /** - * Construct a new print service attribute set, initially populated with - * the values from the given array. The new attribute set is populated - * by adding the elements of {@code attributes} array to the set in - * sequence, starting at index 0. Thus, later array elements may replace - * earlier array elements if the array contains duplicate attribute - * values or attribute categories. + * Construct a new print service attribute set, initially populated with the + * values from the given array. The new attribute set is populated by adding + * the elements of {@code attributes} array to the set in sequence, starting + * at index 0. Thus, later array elements may replace earlier array elements + * if the array contains duplicate attribute values or attribute categories. * - * @param attributes Array of attribute values to add to the set. - * If null, an empty attribute set is constructed. - * - * @exception NullPointerException - * (unchecked exception) - * Thrown if any element of {@code attributes} is null. + * @param attributes array of attribute values to add to the set. If + * {@code null}, an empty attribute set is constructed. + * @throws NullPointerException if any element of {@code attributes} is + * {@code null} */ public HashPrintServiceAttributeSet(PrintServiceAttribute[] attributes) { super (attributes, PrintServiceAttribute.class); } - /** - * Construct a new attribute set, initially populated with the - * values from the given set where the members of the attribute set - * are restricted to the {@code PrintServiceAttribute} interface. + * Construct a new attribute set, initially populated with the values from + * the given set where the members of the attribute set are restricted to + * the {@code PrintServiceAttribute} interface. * * @param attributes set of attribute values to initialise the set. If - * null, an empty attribute set is constructed. - * - * @exception ClassCastException - * (unchecked exception) Thrown if any element of - * {@code attributes} is not an instance of - * {@code PrintServiceAttribute}. + * {@code null}, an empty attribute set is constructed. + * @throws ClassCastException if any element of {@code attributes} is not an + * instance of {@code PrintServiceAttribute} */ public HashPrintServiceAttributeSet(PrintServiceAttributeSet attributes) { diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/IntegerSyntax.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/IntegerSyntax.java index a68cb0eac97..d6c4a557010 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/IntegerSyntax.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/IntegerSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -28,25 +28,28 @@ package javax.print.attribute; import java.io.Serializable; /** - * Class IntegerSyntax is an abstract base class providing the common + * Class {@code IntegerSyntax} is an abstract base class providing the common * implementation of all attributes with integer values. - *

+ *

* Under the hood, an integer attribute is just an integer. You can get an - * integer attribute's integer value by calling {@link #getValue() - * getValue()}. An integer attribute's integer value is - * established when it is constructed (see {@link #IntegerSyntax(int) - * IntegerSyntax(int)}). Once constructed, an integer attribute's - * value is immutable. + * integer attribute's integer value by calling {@link #getValue() getValue()}. + * An integer attribute's integer value is established when it is constructed + * (see {@link #IntegerSyntax(int) IntegerSyntax(int)}). Once constructed, an + * integer attribute's value is immutable. * - * @author David Mendenhall - * @author Alan Kaminsky + * @author David Mendenhall + * @author Alan Kaminsky */ public abstract class IntegerSyntax implements Serializable, Cloneable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 3644574816328081943L; /** * This integer attribute's integer value. + * * @serial */ private int value; @@ -54,7 +57,7 @@ public abstract class IntegerSyntax implements Serializable, Cloneable { /** * Construct a new integer attribute with the given integer value. * - * @param value Integer value. + * @param value Integer value */ protected IntegerSyntax(int value) { this.value = value; @@ -64,14 +67,11 @@ public abstract class IntegerSyntax implements Serializable, Cloneable { * Construct a new integer attribute with the given integer value, which * must lie within the given range. * - * @param value Integer value. - * @param lowerBound Lower bound. - * @param upperBound Upper bound. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than - * {@code lowerBound} or greater than - * {@code upperBound}. + * @param value Integer value + * @param lowerBound Lower bound + * @param upperBound Upper bound + * @throws IllegalArgumentException if {@code value} is less than + * {@code lowerBound} or greater than {@code upperBound} */ protected IntegerSyntax(int value, int lowerBound, int upperBound) { if (lowerBound > value || value > upperBound) { @@ -84,6 +84,7 @@ public abstract class IntegerSyntax implements Serializable, Cloneable { /** * Returns this integer attribute's integer value. + * * @return the integer value */ public int getValue() { @@ -93,20 +94,16 @@ public abstract class IntegerSyntax implements Serializable, Cloneable { /** * Returns whether this integer attribute is equivalent to the passed in * object. To be equivalent, all of the following conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class IntegerSyntax. - *
  3. - * This integer attribute's value and {@code object}'s value are - * equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code IntegerSyntax}. + *
  3. This integer attribute's value and {@code object}'s value are + * equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this integer - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this integer + * attribute, {@code false} otherwise */ public boolean equals(Object object) { diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintJobAttribute.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintJobAttribute.java index ad9a0d7217a..78bd03ca9d6 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintJobAttribute.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintJobAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -26,19 +26,18 @@ package javax.print.attribute; /** - * PrintJobAttribute is a tagging interface which a printing attribute + * {@code PrintJobAttribute} is a tagging interface which a printing attribute * class implements to indicate the attribute describes the status of a Print - * Job or some other characteristic of a Print Job. A Print Service - * instance adds a number of PrintJobAttributes to a Print Job's attribute set - * to report the Print Job's status. If an attribute implements {@link - * PrintRequestAttribute PrintRequestAttribute} as well as PrintJobAttribute, - * the client may include the attribute in a attribute set to - * specify the attribute's value for the Print Job. + * Job or some other characteristic of a Print Job. A Print Service instance + * adds a number of {@code PrintJobAttributes} to a Print Job's attribute set to + * report the Print Job's status. If an attribute implements + * {@link PrintRequestAttribute PrintRequestAttribute} as well as + * {@code PrintJobAttribute}, the client may include the attribute in a + * attribute set to specify the attribute's value for the Print Job. * + * @author Alan Kaminsky * @see PrintRequestAttributeSet * @see PrintJobAttributeSet - * - * @author Alan Kaminsky */ public interface PrintJobAttribute extends Attribute { } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintJobAttributeSet.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintJobAttributeSet.java index 2b5ef237089..63535fba93e 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintJobAttributeSet.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintJobAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,85 +23,69 @@ * questions. */ - package javax.print.attribute; /** - * Interface PrintJobAttributeSet specifies the interface for a set of print - * job attributes, i.e. printing attributes that implement interface {@link - * PrintJobAttribute PrintJobAttribute}. In the Print Service API, a - * service uses a PrintJobAttributeSet to report the status of a print job. - *

- * A PrintJobAttributeSet is just an {@link AttributeSet AttributeSet} whose - * constructors and mutating operations guarantee an additional invariant, - * namely that all attribute values in the PrintJobAttributeSet must be - * instances of interface {@link PrintJobAttribute PrintJobAttribute}. - * The {@link #add(Attribute) add(Attribute)}, and - * {@link #addAll(AttributeSet) >addAll(AttributeSet)} operations - * are respecified below to guarantee this additional invariant. + * Interface {@code PrintJobAttributeSet} specifies the interface for a set of + * print job attributes, i.e. printing attributes that implement interface + * {@link PrintJobAttribute PrintJobAttribute}. In the Print Service API, a + * service uses a {@code PrintJobAttributeSet} to report the status of a print + * job. + *

+ * A {@code PrintJobAttributeSet} is just an {@link AttributeSet AttributeSet} + * whose constructors and mutating operations guarantee an additional invariant, + * namely that all attribute values in the {@code PrintJobAttributeSet} must be + * instances of interface {@link PrintJobAttribute PrintJobAttribute}. The + * {@link #add(Attribute) add(Attribute)}, and + * {@link #addAll(AttributeSet) addAll(AttributeSet)} operations are respecified + * below to guarantee this additional invariant. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public interface PrintJobAttributeSet extends AttributeSet { /** * Adds the specified attribute value to this attribute set if it is not - * already present, first removing any existing value in the same - * attribute category as the specified attribute value (optional - * operation). + * already present, first removing any existing value in the same attribute + * category as the specified attribute value (optional operation). * - * @param attribute Attribute value to be added to this attribute set. - * - * @return {@code true} if this attribute set changed as a result of - * the call, i.e., the given attribute value was not already a - * member of this attribute set. - * - * @throws UnmodifiableSetException - * (unchecked exception) Thrown if this attribute set does not - * support the {@code add()} operation. - * @throws ClassCastException - * (unchecked exception) Thrown if the {@code attribute} is - * not an instance of interface - * {@link PrintJobAttribute PrintJobAttribute}. - * @throws NullPointerException - * (unchecked exception) Thrown if the {@code attribute} is null. + * @param attribute attribute value to be added to this attribute set + * @return {@code true} if this attribute set changed as a result of the + * call, i.e., the given attribute value was not already a member of + * this attribute set + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code add()} operation + * @throws ClassCastException if the {@code attribute} is not an instance of + * interface {@link PrintJobAttribute PrintJobAttribute} + * @throws NullPointerException if the {@code attribute} is {@code null} */ public boolean add(Attribute attribute); /** - * Adds all of the elements in the specified set to this attribute. - * The outcome is the same as if the - * {@link #add(Attribute) add(Attribute)} - * operation had been applied to this attribute set successively with - * each element from the specified set. If none of the categories in the - * specified set are the same as any categories in this attribute set, - * the {@code addAll()} operation effectively modifies this attribute - * set so that its value is the union of the two sets. - *

- * The behavior of the {@code addAll()} operation is unspecified if - * the specified set is modified while the operation is in progress. - *

- * If the {@code addAll()} operation throws an exception, the effect - * on this attribute set's state is implementation dependent; elements - * from the specified set before the point of the exception may or - * may not have been added to this attribute set. - * - * @param attributes whose elements are to be added to this attribute - * set. - * - * @return {@code true} if this attribute set changed as a result of - * the call. - * - * @throws UnmodifiableSetException - * (Unchecked exception) Thrown if this attribute set does not - * support the {@code addAll()} method. - * @throws ClassCastException - * (Unchecked exception) Thrown if some element in the specified - * set is not an instance of interface {@link PrintJobAttribute - * PrintJobAttribute}. - * @throws NullPointerException - * (Unchecked exception) Thrown if the specified set is null. + * Adds all of the elements in the specified set to this attribute. The + * outcome is the same as if the {@link #add(Attribute) add(Attribute)} + * operation had been applied to this attribute set successively with each + * element from the specified set. If none of the categories in the + * specified set are the same as any categories in this attribute set, the + * {@code addAll()} operation effectively modifies this attribute set so + * that its value is the union of the two sets. + *

+ * The behavior of the {@code addAll()} operation is unspecified if the + * specified set is modified while the operation is in progress. + *

+ * If the {@code addAll()} operation throws an exception, the effect on this + * attribute set's state is implementation dependent; elements from the + * specified set before the point of the exception may or may not have been + * added to this attribute set. * + * @param attributes whose elements are to be added to this attribute set + * @return {@code true} if this attribute set changed as a result of the + * call + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code addAll()} method + * @throws ClassCastException if some element in the specified set is not an + * instance of interface {@link PrintJobAttribute PrintJobAttribute} + * @throws NullPointerException if the specified set is {@code null} * @see #add(Attribute) */ public boolean addAll(AttributeSet attributes); diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintRequestAttribute.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintRequestAttribute.java index 6acf9ca51ef..e56b1b5ccf2 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintRequestAttribute.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintRequestAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,28 +23,25 @@ * questions. */ - package javax.print.attribute; /** - * Interface PrintRequestAttribute is a tagging interface which a printing - * attribute class implements to indicate the attribute denotes a + * Interface {@code PrintRequestAttribute} is a tagging interface which a + * printing attribute class implements to indicate the attribute denotes a * requested setting for a print job. *

- * Attributes which are tagged with PrintRequestAttribute and are also tagged - * as PrintJobAttribute, represent the subset of job attributes which - * can be part of the specification of a job request. + * Attributes which are tagged with {@code PrintRequestAttribute} and are also + * tagged as {@code PrintJobAttribute}, represent the subset of job attributes + * which can be part of the specification of a job request. *

- * If an attribute implements {@link DocAttribute DocAttribute} - * as well as PrintRequestAttribute, the client may include the - * attribute in a {@code Doc}'s attribute set to specify - * a job setting which pertains just to that doc. + * If an attribute implements {@link DocAttribute DocAttribute} as well as + * {@code PrintRequestAttribute}, the client may include the attribute in a + * {@code Doc}'s attribute set to specify a job setting which pertains just to + * that doc. * + * @author Alan Kaminsky * @see DocAttributeSet * @see PrintRequestAttributeSet - * - * @author Alan Kaminsky */ - public interface PrintRequestAttribute extends Attribute { } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintRequestAttributeSet.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintRequestAttributeSet.java index af0acaabfa4..95a07655f03 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintRequestAttributeSet.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintRequestAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,88 +23,72 @@ * questions. */ - package javax.print.attribute; /** - * Interface PrintRequestAttributeSet specifies the interface for a set of - * print request attributes, i.e. printing attributes that implement interface - * {@link PrintRequestAttribute PrintRequestAttribute}. - * The client uses a PrintRequestAttributeSet to specify the settings to be - * applied to a whole print job and to all the docs in the print job. - *

- * PrintRequestAttributeSet is just an {@link AttributeSet AttributeSet} whose - * constructors and mutating operations guarantee an additional invariant, - * namely that all attribute values in the PrintRequestAttributeSet must be - * instances of interface {@link PrintRequestAttribute PrintRequestAttribute}. - * The {@link #add(Attribute) add(Attribute)}, and - * {@link #addAll(AttributeSet) addAll(AttributeSet)} operations - * are respecified below to guarantee this additional invariant. + * Interface {@code PrintRequestAttributeSet} specifies the interface for a set + * of print request attributes, i.e. printing attributes that implement + * interface {@link PrintRequestAttribute PrintRequestAttribute}. The client + * uses a {@code PrintRequestAttributeSet} to specify the settings to be applied + * to a whole print job and to all the docs in the print job. + *

+ * {@code PrintRequestAttributeSet} is just an {@link AttributeSet AttributeSet} + * whose constructors and mutating operations guarantee an additional invariant, + * namely that all attribute values in the {@code PrintRequestAttributeSet} must + * be instances of interface + * {@link PrintRequestAttribute PrintRequestAttribute}. The + * {@link #add(Attribute) add(Attribute)}, and + * {@link #addAll(AttributeSet) addAll(AttributeSet)} operations are respecified + * below to guarantee this additional invariant. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public interface PrintRequestAttributeSet extends AttributeSet { /** * Adds the specified attribute value to this attribute set if it is not - * already present, first removing any existing value in the same - * attribute category as the specified attribute value (optional - * operation). + * already present, first removing any existing value in the same attribute + * category as the specified attribute value (optional operation). * - * @param attribute Attribute value to be added to this attribute set. - * - * @return {@code true} if this attribute set changed as a result of - * the call, i.e., the given attribute value was not already a - * member of this attribute set. - * - * @throws UnmodifiableSetException - * (unchecked exception) Thrown if this attribute set does not - * support the {@code add()} operation. - * @throws ClassCastException - * (unchecked exception) Thrown if the {@code attribute} is - * not an instance of interface - * {@link PrintRequestAttribute PrintRequestAttribute}. - * @throws NullPointerException - * (unchecked exception) Thrown if the {@code attribute} is null. + * @param attribute attribute value to be added to this attribute set + * @return {@code true} if this attribute set changed as a result of the + * call, i.e., the given attribute value was not already a member of + * this attribute set + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code add()} operation + * @throws ClassCastException if the {@code attribute} is not an instance of + * interface {@link PrintRequestAttribute PrintRequestAttribute} + * @throws NullPointerException if the {@code attribute} is {@code null} */ public boolean add(Attribute attribute); /** - * Adds all of the elements in the specified set to this attribute. - * The outcome is the same as if the - * {@link #add(Attribute) add(Attribute)} - * operation had been applied to this attribute set successively with - * each element from the specified set. If none of the categories in the - * specified set are the same as any categories in this attribute set, - * the {@code addAll()} operation effectively modifies this attribute - * set so that its value is the union of the two sets. - *

- * The behavior of the {@code addAll()} operation is unspecified if - * the specified set is modified while the operation is in progress. - *

- * If the {@code addAll()} operation throws an exception, the effect - * on this attribute set's state is implementation dependent; elements - * from the specified set before the point of the exception may or - * may not have been added to this attribute set. - * - * @param attributes whose elements are to be added to this attribute - * set. - * - * @return {@code true} if this attribute set changed as a result of - * the call. - * - * @throws UnmodifiableSetException - * (Unchecked exception) Thrown if this attribute set does not - * support the {@code addAll()} method. - * @throws ClassCastException - * (Unchecked exception) Thrown if some element in the specified - * set is not an instance of interface {@link PrintRequestAttribute - * PrintRequestAttribute}. - * @throws NullPointerException - * (Unchecked exception) Thrown if the specified set is null. + * Adds all of the elements in the specified set to this attribute. The + * outcome is the same as if the {@link #add(Attribute) add(Attribute)} + * operation had been applied to this attribute set successively with each + * element from the specified set. If none of the categories in the + * specified set are the same as any categories in this attribute set, the + * {@code addAll()} operation effectively modifies this attribute set so + * that its value is the union of the two sets. + *

+ * The behavior of the {@code addAll()} operation is unspecified if the + * specified set is modified while the operation is in progress. + *

+ * If the {@code addAll()} operation throws an exception, the effect on this + * attribute set's state is implementation dependent; elements from the + * specified set before the point of the exception may or may not have been + * added to this attribute set. * + * @param attributes whose elements are to be added to this attribute set + * @return {@code true} if this attribute set changed as a result of the + * call + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code addAll()} method + * @throws ClassCastException if some element in the specified set is not an + * instance of interface + * {@link PrintRequestAttribute PrintRequestAttribute} + * @throws NullPointerException if the specified set is {@code null} * @see #add(Attribute) */ public boolean addAll(AttributeSet attributes); - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintServiceAttribute.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintServiceAttribute.java index f09b38870ed..77c45160d40 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintServiceAttribute.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintServiceAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -26,15 +26,14 @@ package javax.print.attribute; /** - * Interface PrintServiceAttribute is a tagging interface which a printing - * attribute class implements to indicate the attribute describes the status - * of a Print Service or some other characteristic of a Print Service. A Print - * Service instance adds a number of PrintServiceAttributes to a Print - * service's attribute set to report the Print Service's status. + * Interface {@code PrintServiceAttribute} is a tagging interface which a + * printing attribute class implements to indicate the attribute describes the + * status of a Print Service or some other characteristic of a Print Service. A + * Print Service instance adds a number of {@code PrintServiceAttributes} to a + * Print service's attribute set to report the Print Service's status. * + * @author Alan Kaminsky * @see PrintServiceAttributeSet - * - * @author Alan Kaminsky */ public interface PrintServiceAttribute extends Attribute { } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintServiceAttributeSet.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintServiceAttributeSet.java index 59e9a320b63..fd2d4dc4694 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintServiceAttributeSet.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/PrintServiceAttributeSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,90 +23,71 @@ * questions. */ - package javax.print.attribute; /** - * Interface PrintServiceAttributeSet specifies the interface for a set of - * print job attributes, i.e. printing attributes that implement interface - * {@link - * PrintServiceAttribute PrintServiceAttribute}. In the Print Service API, - * the Print Service instance uses a PrintServiceAttributeSet to report the - * status of the print service. - *

- * A PrintServiceAttributeSet is just an {@link AttributeSet AttributeSet} - * whose constructors and mutating operations guarantee an additional - * invariant, - * namely that all attribute values in the PrintServiceAttributeSet must be - * instances of interface {@link PrintServiceAttribute PrintServiceAttribute}. - * The {@link #add(Attribute) add(Attribute)}, and - * {@link #addAll(AttributeSet) addAll(AttributeSet)} operations - * are respecified below to guarantee this additional invariant. + * Interface {@code PrintServiceAttributeSet} specifies the interface for a set + * of print job attributes, i.e. printing attributes that implement interface + * {@link PrintServiceAttribute PrintServiceAttribute}. In the Print Service + * API, the Print Service instance uses a {@code PrintServiceAttributeSet} to + * report the status of the print service. + *

+ * A {@code PrintServiceAttributeSet} is just an + * {@link AttributeSet AttributeSet} whose constructors and mutating operations + * guarantee an additional invariant, namely that all attribute values in the + * {@code PrintServiceAttributeSet} must be instances of interface + * {@link PrintServiceAttribute PrintServiceAttribute}. The + * {@link #add(Attribute) add(Attribute)}, and + * {@link #addAll(AttributeSet) addAll(AttributeSet)} operations are respecified + * below to guarantee this additional invariant. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public interface PrintServiceAttributeSet extends AttributeSet { - - /** * Adds the specified attribute value to this attribute set if it is not - * already present, first removing any existing value in the same - * attribute category as the specified attribute value (optional - * operation). + * already present, first removing any existing value in the same attribute + * category as the specified attribute value (optional operation). * - * @param attribute Attribute value to be added to this attribute set. - * - * @return {@code true} if this attribute set changed as a result of - * the call, i.e., the given attribute value was not already a - * member of this attribute set. - * - * @throws UnmodifiableSetException - * (unchecked exception) Thrown if this attribute set does not - * support the {@code add()} operation. - * @throws ClassCastException - * (unchecked exception) Thrown if the {@code attribute} is - * not an instance of interface - * {@link PrintServiceAttribute PrintServiceAttribute}. - * @throws NullPointerException - * (unchecked exception) Thrown if the {@code attribute} is null. + * @param attribute attribute value to be added to this attribute set + * @return {@code true} if this attribute set changed as a result of the + * call, i.e., the given attribute value was not already a member of + * this attribute set + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code add()} operation + * @throws ClassCastException if the {@code attribute} is not an instance of + * interface {@link PrintServiceAttribute PrintServiceAttribute} + * @throws NullPointerException if the {@code attribute} is {@code null} */ public boolean add(Attribute attribute); /** - * Adds all of the elements in the specified set to this attribute. - * The outcome is the same as if the - * {@link #add(Attribute) add(Attribute)} - * operation had been applied to this attribute set successively with - * each element from the specified set. If none of the categories in the - * specified set are the same as any categories in this attribute set, - * the {@code addAll()} operation effectively modifies this attribute - * set so that its value is the union of the two sets. - *

- * The behavior of the {@code addAll()} operation is unspecified if - * the specified set is modified while the operation is in progress. - *

- * If the {@code addAll()} operation throws an exception, the effect - * on this attribute set's state is implementation dependent; elements - * from the specified set before the point of the exception may or - * may not have been added to this attribute set. - * - * @param attributes whose elements are to be added to this attribute - * set. - * - * @return {@code true} if this attribute set changed as a result of - * the call. - * - * @throws UnmodifiableSetException - * (Unchecked exception) Thrown if this attribute set does not - * support the {@code addAll()} method. - * @throws ClassCastException - * (Unchecked exception) Thrown if some element in the specified - * set is not an instance of interface {@link PrintServiceAttribute - * PrintServiceAttribute}. - * @throws NullPointerException - * (Unchecked exception) Thrown if the specified set is null. + * Adds all of the elements in the specified set to this attribute. The + * outcome is the same as if the {@link #add(Attribute) add(Attribute)} + * operation had been applied to this attribute set successively with each + * element from the specified set. If none of the categories in the + * specified set are the same as any categories in this attribute set, the + * {@code addAll()} operation effectively modifies this attribute set so + * that its value is the union of the two sets. + *

+ * The behavior of the {@code addAll()} operation is unspecified if the + * specified set is modified while the operation is in progress. + *

+ * If the {@code addAll()} operation throws an exception, the effect on this + * attribute set's state is implementation dependent; elements from the + * specified set before the point of the exception may or may not have been + * added to this attribute set. * + * @param attributes whose elements are to be added to this attribute set + * @return {@code true} if this attribute set changed as a result of the + * call + * @throws UnmodifiableSetException if this attribute set does not support + * the {@code addAll()} method + * @throws ClassCastException if some element in the specified set is not an + * instance of interface + * {@link PrintServiceAttribute PrintServiceAttribute} + * @throws NullPointerException if the specified set is {@code null} * @see #add(Attribute) */ public boolean addAll(AttributeSet attributes); diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/ResolutionSyntax.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/ResolutionSyntax.java index c6674707ec0..524452ddf7a 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/ResolutionSyntax.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/ResolutionSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,29 +23,27 @@ * questions. */ - package javax.print.attribute; import java.io.Serializable; /** - * Class ResolutionSyntax is an abstract base class providing the common + * Class {@code ResolutionSyntax} is an abstract base class providing the common * implementation of all attributes denoting a printer resolution. - *

+ *

* A resolution attribute's value consists of two items, the cross feed * direction resolution and the feed direction resolution. A resolution * attribute may be constructed by supplying the two values and indicating the * units in which the values are measured. Methods are provided to return a * resolution attribute's values, indicating the units in which the values are * to be returned. The two most common resolution units are dots per inch (dpi) - * and dots per centimeter (dpcm), and exported constants {@link #DPI - * DPI} and {@link #DPCM DPCM} are provided for - * indicating those units. - *

+ * and dots per centimeter (dpcm), and exported constants {@link #DPI DPI} and + * {@link #DPCM DPCM} are provided for indicating those units. + *

* Once constructed, a resolution attribute's value is immutable. - *

- * Design - *

+ *

+ * Design + *

* A resolution attribute's cross feed direction resolution and feed direction * resolution values are stored internally using units of dots per 100 inches * (dphi). Storing the values in dphi rather than, say, metric units allows @@ -57,43 +55,47 @@ import java.io.Serializable; * resolution attribute's values are created in one units and retrieved in * different units; for example, 600 dpi will be rounded to 236 dpcm, whereas * the true value (to five figures) is 236.22 dpcm. - *

+ *

* Storing the values internally in common units of dphi lets two resolution * attributes be compared without regard to the units in which they were * created; for example, 300 dpcm will compare equal to 762 dpi, as they both - * are stored as 76200 dphi. In particular, a lookup service can - * match resolution attributes based on equality of their serialized - * representations regardless of the units in which they were created. Again, - * using integers for internal storage allows precise equality comparisons to be - * done, which would not be guaranteed if a floating point representation were - * used. - *

- * The exported constant {@link #DPI DPI} is actually the - * conversion factor by which to multiply a value in dpi to get the value in - * dphi. Likewise, the exported constant {@link #DPCM DPCM} is the - * conversion factor by which to multiply a value in dpcm to get the value in - * dphi. A client can specify a resolution value in units other than dpi or dpcm - * by supplying its own conversion factor. However, since the internal units of - * dphi was chosen with supporting only the external units of dpi and dpcm in - * mind, there is no guarantee that the conversion factor for the client's units - * will be an exact integer. If the conversion factor isn't an exact integer, - * resolution values in the client's units won't be stored precisely. + * are stored as 76200 dphi. In particular, a lookup service can match + * resolution attributes based on equality of their serialized representations + * regardless of the units in which they were created. Again, using integers for + * internal storage allows precise equality comparisons to be done, which would + * not be guaranteed if a floating point representation were used. + *

+ * The exported constant {@link #DPI DPI} is actually the conversion factor by + * which to multiply a value in dpi to get the value in dphi. Likewise, the + * exported constant {@link #DPCM DPCM} is the conversion factor by which to + * multiply a value in dpcm to get the value in dphi. A client can specify a + * resolution value in units other than dpi or dpcm by supplying its own + * conversion factor. However, since the internal units of dphi was chosen with + * supporting only the external units of dpi and dpcm in mind, there is no + * guarantee that the conversion factor for the client's units will be an exact + * integer. If the conversion factor isn't an exact integer, resolution values + * in the client's units won't be stored precisely. * - * @author David Mendenhall - * @author Alan Kaminsky + * @author David Mendenhall + * @author Alan Kaminsky */ public abstract class ResolutionSyntax implements Serializable, Cloneable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 2706743076526672017L; /** * Cross feed direction resolution in units of dots per 100 inches (dphi). + * * @serial */ private int crossFeedResolution; /** * Feed direction resolution in units of dots per 100 inches (dphi). + * * @serial */ private int feedResolution; @@ -105,26 +107,20 @@ public abstract class ResolutionSyntax implements Serializable, Cloneable { public static final int DPI = 100; /** - * Value to indicate units of dots per centimeter (dpcm). It is actually - * the conversion factor by which to multiply dpcm to yield dphi (254). + * Value to indicate units of dots per centimeter (dpcm). It is actually the + * conversion factor by which to multiply dpcm to yield dphi (254). */ public static final int DPCM = 254; - /** * Construct a new resolution attribute from the given items. * - * @param crossFeedResolution - * Cross feed direction resolution. - * @param feedResolution - * Feed direction resolution. - * @param units - * Unit conversion factor, e.g. {@link #DPI DPI} or - * {@link #DPCM DPCM}. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code crossFeedResolution < 1} - * or {@code feedResolution < 1} or {@code units < 1}. + * @param crossFeedResolution cross feed direction resolution + * @param feedResolution feed direction resolution + * @param units unit conversion factor, e.g. {@link #DPI DPI} or + * {@link #DPCM DPCM} + * @throws IllegalArgumentException if {@code crossFeedResolution < 1} or + * {@code feedResolution < 1} or {@code units < 1} */ public ResolutionSyntax(int crossFeedResolution, int feedResolution, int units) { @@ -147,16 +143,11 @@ public abstract class ResolutionSyntax implements Serializable, Cloneable { * Convert a value from dphi to some other units. The result is rounded to * the nearest integer. * - * @param dphi - * Value (dphi) to convert. - * @param units - * Unit conversion factor, e.g. {@link #DPI DPI} or - * {@link #DPCM DPCM}. - * - * @return The value of {@code dphi} converted to the desired units. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units} < 1. + * @param dphi value (dphi) to convert + * @param units unit conversion factor, e.g. {@link #DPI DPI} or + * {@link #DPCM DPCM} + * @return the value of {@code dphi} converted to the desired units + * @throws IllegalArgumentException if {@code units < 1} */ private static int convertFromDphi(int dphi, int units) { if (units < 1) { @@ -167,18 +158,14 @@ public abstract class ResolutionSyntax implements Serializable, Cloneable { } /** - * Get this resolution attribute's resolution values in the given units. - * The values are rounded to the nearest integer. + * Get this resolution attribute's resolution values in the given units. The + * values are rounded to the nearest integer. * - * @param units - * Unit conversion factor, e.g. {@link #DPI DPI} or - * {@link #DPCM DPCM}. - * - * @return A two-element array with the cross feed direction resolution - * at index 0 and the feed direction resolution at index 1. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #DPI DPI} or + * {@link #DPCM DPCM} + * @return a two-element array with the cross feed direction resolution at + * index 0 and the feed direction resolution at index 1 + * @throws IllegalArgumentException if {@code units < 1} */ public int[] getResolution(int units) { return new int[] { getCrossFeedResolution(units), @@ -190,14 +177,10 @@ public abstract class ResolutionSyntax implements Serializable, Cloneable { * Returns this resolution attribute's cross feed direction resolution in * the given units. The value is rounded to the nearest integer. * - * @param units - * Unit conversion factor, e.g. {@link #DPI DPI} or - * {@link #DPCM DPCM}. - * - * @return Cross feed direction resolution. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #DPI DPI} or + * {@link #DPCM DPCM} + * @return cross feed direction resolution + * @throws IllegalArgumentException if {@code units < 1} */ public int getCrossFeedResolution(int units) { return convertFromDphi (crossFeedResolution, units); @@ -207,14 +190,10 @@ public abstract class ResolutionSyntax implements Serializable, Cloneable { * Returns this resolution attribute's feed direction resolution in the * given units. The value is rounded to the nearest integer. * - * @param units - * Unit conversion factor, e.g. {@link #DPI DPI} or {@link - * #DPCM DPCM}. - * - * @return Feed direction resolution. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #DPI DPI} or + * {@link #DPCM DPCM} + * @return feed direction resolution + * @throws IllegalArgumentException if {@code units < 1} */ public int getFeedResolution(int units) { return convertFromDphi (feedResolution, units); @@ -222,22 +201,18 @@ public abstract class ResolutionSyntax implements Serializable, Cloneable { /** * Returns a string version of this resolution attribute in the given units. - * The string takes the form "CxF U", - * where C is the cross feed direction resolution, F is the - * feed direction resolution, and U is the units name. The values are + * The string takes the form "CxF U", + * where C is the cross feed direction resolution, F is the + * feed direction resolution, and U is the units name. The values are * rounded to the nearest integer. * - * @param units - * Unit conversion factor, e.g. {@link #DPI CODE>DPI} or {@link - * #DPCM DPCM}. - * @param unitsName - * Units name string, e.g. {@code "dpi"} or {@code "dpcm"}. If - * null, no units name is appended to the result. - * - * @return String version of this resolution attribute. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #DPI CODE>DPI} or + * {@link #DPCM DPCM} + * @param unitsName units name string, e.g. {@code "dpi"} or + * {@code "dpcm"}. If {@code null}, no units name is appended to the + * result. + * @return string version of this resolution attribute + * @throws IllegalArgumentException if {@code units < 1} */ public String toString(int units, String unitsName) { StringBuilder result = new StringBuilder(); @@ -251,54 +226,43 @@ public abstract class ResolutionSyntax implements Serializable, Cloneable { return result.toString(); } - /** - * Determine whether this resolution attribute's value is less than or - * equal to the given resolution attribute's value. This is true if all - * of the following conditions are true: - *

    - *
  • - * This attribute's cross feed direction resolution is less than or equal to - * the {@code other} attribute's cross feed direction resolution. - *
  • - * This attribute's feed direction resolution is less than or equal to the - * {@code other} attribute's feed direction resolution. - *
+ * Determine whether this resolution attribute's value is less than or equal + * to the given resolution attribute's value. This is true if all of the + * following conditions are true: + *
    + *
  • This attribute's cross feed direction resolution is less than or + * equal to the {@code other} attribute's cross feed direction resolution. + *
  • This attribute's feed direction resolution is less than or equal to + * the {@code other} attribute's feed direction resolution. + *
* - * @param other Resolution attribute to compare with. - * - * @return True if this resolution attribute is less than or equal to the - * {@code other} resolution attribute, false otherwise. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code other} is null. + * @param other resolution attribute to compare with + * @return {@code true} if this resolution attribute is less than or equal + * to the {@code other} resolution attribute, {@code false} + * otherwise + * @throws NullPointerException if {@code other} is {@code null} */ public boolean lessThanOrEquals(ResolutionSyntax other) { return (this.crossFeedResolution <= other.crossFeedResolution && this.feedResolution <= other.feedResolution); } - /** * Returns whether this resolution attribute is equivalent to the passed in * object. To be equivalent, all of the following conditions must be true: - *
    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class ResolutionSyntax. - *
  3. - * This attribute's cross feed direction resolution is equal to - * {@code object}'s cross feed direction resolution. - *
  4. - * This attribute's feed direction resolution is equal to - * {@code object}'s feed direction resolution. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code ResolutionSyntax}. + *
  3. This attribute's cross feed direction resolution is equal to + * {@code object}'s cross feed direction resolution. + *
  4. This attribute's feed direction resolution is equal to + * {@code object}'s feed direction resolution. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this resolution - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this resolution + * attribute, {@code false} otherwise */ public boolean equals(Object object) { @@ -320,8 +284,8 @@ public abstract class ResolutionSyntax implements Serializable, Cloneable { /** * Returns a string version of this resolution attribute. The string takes - * the form "CxF dphi", where C is the - * cross feed direction resolution and F is the feed direction + * the form "CxF dphi", where C is the + * cross feed direction resolution and F is the feed direction * resolution. The values are reported in the internal units of dphi. */ public String toString() { @@ -333,25 +297,23 @@ public abstract class ResolutionSyntax implements Serializable, Cloneable { return result.toString(); } - /** * Returns this resolution attribute's cross feed direction resolution in * units of dphi. (For use in a subclass.) * - * @return Cross feed direction resolution. + * @return cross feed direction resolution */ protected int getCrossFeedResolutionDphi() { return crossFeedResolution; } /** - * Returns this resolution attribute's feed direction resolution in units - * of dphi. (For use in a subclass.) + * Returns this resolution attribute's feed direction resolution in units of + * dphi. (For use in a subclass.) * - * @return Feed direction resolution. + * @return feed direction resolution */ protected int getFeedResolutionDphi() { return feedResolution; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/SetOfIntegerSyntax.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/SetOfIntegerSyntax.java index ca1c81a6f31..5d97bc2fc1a 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/SetOfIntegerSyntax.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/SetOfIntegerSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,82 +23,82 @@ * questions. */ - package javax.print.attribute; import java.io.Serializable; import java.util.Vector; /** - * Class SetOfIntegerSyntax is an abstract base class providing the common - * implementation of all attributes whose value is a set of nonnegative + * Class {@code SetOfIntegerSyntax} is an abstract base class providing the + * common implementation of all attributes whose value is a set of nonnegative * integers. This includes attributes whose value is a single range of integers * and attributes whose value is a set of ranges of integers. - *

- * You can construct an instance of SetOfIntegerSyntax by giving it in "string - * form." The string consists of zero or more comma-separated integer groups. - * Each integer group consists of either one integer, two integers separated by - * a hyphen ({@code -}), or two integers separated by a colon - * ({@code :}). Each integer consists of one or more decimal digits - * ({@code 0} through {@code 9}). Whitespace characters cannot - * appear within an integer but are otherwise ignored. For example: - * {@code ""}, {@code "1"}, {@code "5-10"}, {@code "1:2, 4"}. - *

- * You can also construct an instance of SetOfIntegerSyntax by giving it in - * "array form." Array form consists of an array of zero or more integer groups - * where each integer group is a length-1 or length-2 array of - * {@code int}s; for example, {@code int[0][]}, - * {@code int[][]{{1}}}, {@code int[][]{{5,10}}}, - * {@code int[][]{{1,2},{4}}}. - *

+ *

+ * You can construct an instance of {@code SetOfIntegerSyntax} by giving it in + * "string form." The string consists of zero or more comma-separated integer + * groups. Each integer group consists of either one integer, two integers + * separated by a hyphen ({@code -}), or two integers separated by a colon + * ({@code :}). Each integer consists of one or more decimal digits ({@code 0} + * through {@code 9}). Whitespace characters cannot appear within an integer but + * are otherwise ignored. For example: {@code ""}, {@code "1"}, {@code "5-10"}, + * {@code "1:2, 4"}. + *

+ * You can also construct an instance of {@code SetOfIntegerSyntax} by giving it + * in "array form." Array form consists of an array of zero or more integer + * groups where each integer group is a length-1 or length-2 array of + * {@code int}s; for example, {@code int[0][]}, {@code int[][]{{1}}}, + * {@code int[][]{{5,10}}}, {@code int[][]{{1,2},{4}}}. + *

* In both string form and array form, each successive integer group gives a * range of integers to be included in the set. The first integer in each group * gives the lower bound of the range; the second integer in each group gives * the upper bound of the range; if there is only one integer in the group, the * upper bound is the same as the lower bound. If the upper bound is less than - * the lower bound, it denotes a null range (no values). If the upper bound is - * equal to the lower bound, it denotes a range consisting of a single value. If - * the upper bound is greater than the lower bound, it denotes a range + * the lower bound, it denotes a {@code null} range (no values). If the upper + * bound is equal to the lower bound, it denotes a range consisting of a single + * value. If the upper bound is greater than the lower bound, it denotes a range * consisting of more than one value. The ranges may appear in any order and are * allowed to overlap. The union of all the ranges gives the set's contents. - * Once a SetOfIntegerSyntax instance is constructed, its value is immutable. - *

- * The SetOfIntegerSyntax object's value is actually stored in "canonical - * array form." This is the same as array form, except there are no null ranges; - * the members of the set are represented in as few ranges as possible (i.e., - * overlapping ranges are coalesced); the ranges appear in ascending order; and - * each range is always represented as a length-two array of {@code int}s - * in the form {lower bound, upper bound}. An empty set is represented as a - * zero-length array. - *

- * Class SetOfIntegerSyntax has operations to return the set's members in - * canonical array form, to test whether a given integer is a member of the + * Once a {@code SetOfIntegerSyntax} instance is constructed, its value is + * immutable. + *

+ * The {@code SetOfIntegerSyntax} object's value is actually stored in + * "canonical array form." This is the same as array form, except there + * are no {@code null} ranges; the members of the set are represented in as few + * ranges as possible (i.e., overlapping ranges are coalesced); the ranges + * appear in ascending order; and each range is always represented as a + * length-two array of {@code int}s in the form {lower bound, upper bound}. An + * empty set is represented as a zero-length array. + *

+ * Class {@code SetOfIntegerSyntax} has operations to return the set's members + * in canonical array form, to test whether a given integer is a member of the * set, and to iterate through the members of the set. * - * @author David Mendenhall - * @author Alan Kaminsky + * @author David Mendenhall + * @author Alan Kaminsky */ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 3666874174847632203L; /** * This set's members in canonical array form. + * * @serial */ private int[][] members; - /** - * Construct a new set-of-integer attribute with the given members in - * string form. + * Construct a new set-of-integer attribute with the given members in string + * form. * - * @param members Set members in string form. If null, an empty set is - * constructed. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code members} does not - * obey the proper syntax. + * @param members set members in string form. If {@code null}, an empty set + * is constructed. + * @throws IllegalArgumentException if {@code members} does not obey the + * proper syntax */ protected SetOfIntegerSyntax(String members) { this.members = parse (members); @@ -106,6 +106,9 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { /** * Parse the given string, returning canonical array form. + * + * @param members the string + * @return the canonical array form */ private static int[][] parse(String members) { // Create vector to hold int[] elements, each element being one range @@ -238,8 +241,8 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { } /** - * Accumulate the given range (lb .. ub) into the canonical array form - * into the given vector of int[] objects. + * Accumulate the given range (lb .. ub) into the canonical array form into + * the given vector of int[] objects. */ private static void accumulate(Vector ranges, int lb,int ub) { // Make sure range is non-null. @@ -257,12 +260,12 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { int[] rangeb = ranges.elementAt (j+1); int lbb = rangeb[0]; int ubb = rangeb[1]; - - /* If the two ranges overlap or are adjacent, coalesce them. - * The two ranges overlap if the larger lower bound is less - * than or equal to the smaller upper bound. The two ranges - * are adjacent if the larger lower bound is one greater - * than the smaller upper bound. + /* + * If the two ranges overlap or are adjacent, coalesce them. The + * two ranges overlap if the larger lower bound is less than or + * equal to the smaller upper bound. The two ranges are adjacent + * if the larger lower bound is one greater than the smaller + * upper bound. */ if (Math.max(lba, lbb) - Math.min(uba, ubb) <= 1) { // The coalesced range is from the smaller lower bound to @@ -279,9 +282,10 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { ranges.setElementAt (rangeb, j); ranges.setElementAt (rangea, j+1); } else { - /* If the two ranges don't overlap and aren't adjacent and - * aren't out of order, we're done early. - */ + /* + * If the two ranges don't overlap and aren't adjacent and + * aren't out of order, we're done early. + */ break; } } @@ -296,20 +300,16 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { } /** - * Construct a new set-of-integer attribute with the given members in - * array form. + * Construct a new set-of-integer attribute with the given members in array + * form. * - * @param members Set members in array form. If null, an empty set is - * constructed. - * - * @exception NullPointerException - * (Unchecked exception) Thrown if any element of - * {@code members} is null. - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if any element of - * {@code members} is not a length-one or length-two array or if - * any non-null range in {@code members} has a lower bound less - * than zero. + * @param members set members in array form. If {@code null}, an empty set + * is constructed. + * @throws NullPointerException if any element of {@code members} is + * {@code null} + * @throws IllegalArgumentException if any element of {@code members} is not + * a length-one or length-two array or if any {@code non-null} range + * in {@code members} has a lower bound less than zero */ protected SetOfIntegerSyntax(int[][] members) { this.members = parse (members); @@ -353,11 +353,8 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { /** * Construct a new set-of-integer attribute containing a single integer. * - * @param member Set member. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code member} is less than - * zero. + * @param member set member + * @throws IllegalArgumentException if {@code member} is negative */ protected SetOfIntegerSyntax(int member) { if (member < 0) { @@ -371,12 +368,10 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { * integers. If the lower bound is greater than the upper bound (a null * range), an empty set is constructed. * - * @param lowerBound Lower bound of the range. - * @param upperBound Upper bound of the range. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if the range is non-null and - * {@code lowerBound} is less than zero. + * @param lowerBound Lower bound of the range + * @param upperBound Upper bound of the range + * @throws IllegalArgumentException if the range is {@code non-null} and + * {@code lowerBound} is less than zero */ protected SetOfIntegerSyntax(int lowerBound, int upperBound) { if (lowerBound <= upperBound && lowerBound < 0) { @@ -387,13 +382,12 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { new int[0][]; } - /** * Obtain this set-of-integer attribute's members in canonical array form. * The returned array is "safe;" the client may alter it without affecting * this set-of-integer attribute. * - * @return This set-of-integer attribute's members in canonical array form. + * @return this set-of-integer attribute's members in canonical array form */ public int[][] getMembers() { int n = members.length; @@ -407,10 +401,9 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { /** * Determine if this set-of-integer attribute contains the given value. * - * @param x Integer value. - * - * @return True if this set-of-integer attribute contains the value - * {@code x}, false otherwise. + * @param x the Integer value + * @return {@code true} if this set-of-integer attribute contains the value + * {@code x}, {@code false} otherwise */ public boolean contains(int x) { // Do a linear search to find the range that contains x, if any. @@ -429,10 +422,9 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { * Determine if this set-of-integer attribute contains the given integer * attribute's value. * - * @param attribute Integer attribute. - * - * @return True if this set-of-integer attribute contains - * {@code theAttribute}'s value, false otherwise. + * @param attribute the Integer attribute + * @return {@code true} if this set-of-integer attribute contains + * {@code attribute}'s value, {@code false} otherwise */ public boolean contains(IntegerSyntax attribute) { return contains (attribute.getValue()); @@ -446,20 +438,19 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { * values, {@code -1} will never appear in the set.) You can use the * {@code next()} method to iterate through the integer values in a * set-of-integer attribute in ascending order, like this: - *

+     * 
      *     SetOfIntegerSyntax attribute = . . .;
      *     int i = -1;
      *     while ((i = attribute.next (i)) != -1)
      *         {
      *         foo (i);
      *         }
-     * 
+ *
* - * @param x Integer value. - * - * @return The smallest integer in this set-of-integer attribute that is - * greater than {@code x}, or {@code -1} if no integer in - * this set-of-integer attribute is greater than {@code x}. + * @param x the Integer value + * @return the smallest integer in this set-of-integer attribute that is + * greater than {@code x}, or {@code -1} if no integer in this + * set-of-integer attribute is greater than {@code x}. */ public int next(int x) { // Do a linear search to find the range that contains x, if any. @@ -478,20 +469,16 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { * Returns whether this set-of-integer attribute is equivalent to the passed * in object. To be equivalent, all of the following conditions must be * true: - *
    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class SetOfIntegerSyntax. - *
  3. - * This set-of-integer attribute's members and {@code object}'s - * members are the same. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code SetOfIntegerSyntax}. + *
  3. This set-of-integer attribute's members and {@code object}'s + * members are the same. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this - * set-of-integer attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this + * set-of-integer attribute, {@code false} otherwise */ public boolean equals(Object object) { if (object != null && object instanceof SetOfIntegerSyntax) { @@ -533,9 +520,9 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { * Returns a string value corresponding to this set-of-integer attribute. * The string value is a zero-length string if this set is empty. Otherwise, * the string value is a comma-separated list of the ranges in the canonical - * array form, where each range is represented as "i" if + * array form, where each range is represented as "i" if * the lower bound equals the upper bound or - * "i-j" otherwise. + * "i-j" otherwise. */ public String toString() { StringBuilder result = new StringBuilder(); @@ -552,5 +539,4 @@ public abstract class SetOfIntegerSyntax implements Serializable, Cloneable { } return result.toString(); } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/Size2DSyntax.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/Size2DSyntax.java index e57c0812d58..b2f4d0c5528 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/Size2DSyntax.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/Size2DSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,75 +23,78 @@ * questions. */ - package javax.print.attribute; import java.io.Serializable; /** - * Class Size2DSyntax is an abstract base class providing the common + * Class {@code Size2DSyntax} is an abstract base class providing the common * implementation of all attributes denoting a size in two dimensions. - *

- * A two-dimensional size attribute's value consists of two items, the X - * dimension and the Y dimension. A two-dimensional size attribute may be - * constructed by supplying the two values and indicating the units in which the - * values are measured. Methods are provided to return a two-dimensional size - * attribute's values, indicating the units in which the values are to be + *

+ * A two-dimensional size attribute's value consists of two items, the {@code X} + * dimension and the {@code Y} dimension. A two-dimensional size attribute may + * be constructed by supplying the two values and indicating the units in which + * the values are measured. Methods are provided to return a two-dimensional + * size attribute's values, indicating the units in which the values are to be * returned. The two most common size units are inches (in) and millimeters - * (mm), and exported constants {@link #INCH INCH} and {@link #MM - * MM} are provided for indicating those units. - *

+ * (mm), and exported constants {@link #INCH INCH} and {@link #MM MM} are + * provided for indicating those units. + *

* Once constructed, a two-dimensional size attribute's value is immutable. - *

- * Design - *

- * A two-dimensional size attribute's X and Y dimension values are stored - * internally as integers in units of micrometers (µm), where 1 micrometer - * = 10-6 meter = 1/1000 millimeter = 1/25400 inch. This permits - * dimensions to be represented exactly to a precision of 1/1000 mm (= 1 + *

+ * Design + *

+ * A two-dimensional size attribute's {@code X} and {@code Y} dimension values + * are stored internally as integers in units of micrometers (µm), where 1 + * micrometer = 10-6 meter = 1/1000 millimeter = 1/25400 inch. This + * permits dimensions to be represented exactly to a precision of 1/1000 mm (= 1 * µm) or 1/100 inch (= 254 µm). If fractional inches are expressed in * negative powers of two, this permits dimensions to be represented exactly to * a precision of 1/8 inch (= 3175 µm) but not 1/16 inch (because 1/16 inch * does not equal an integral number of µm). - *

+ *

* Storing the dimensions internally in common units of µm lets two size * attributes be compared without regard to the units in which they were * created; for example, 8.5 in will compare equal to 215.9 mm, as they both are - * stored as 215900 µm. For example, a lookup service can - * match resolution attributes based on equality of their serialized - * representations regardless of the units in which they were created. Using - * integers for internal storage allows precise equality comparisons to be done, - * which would not be guaranteed if an internal floating point representation - * were used. Note that if you're looking for U.S. letter sized media in metric - * units, you have to search for a media size of 215.9 x 279.4 mm; rounding off - * to an integral 216 x 279 mm will not match. - *

- * The exported constant {@link #INCH INCH} is actually the - * conversion factor by which to multiply a value in inches to get the value in - * µm. Likewise, the exported constant {@link #MM MM} is the - * conversion factor by which to multiply a value in mm to get the value in - * µm. A client can specify a resolution value in units other than inches - * or mm by supplying its own conversion factor. However, since the internal - * units of µm was chosen with supporting only the external units of inch - * and mm in mind, there is no guarantee that the conversion factor for the - * client's units will be an exact integer. If the conversion factor isn't an - * exact integer, resolution values in the client's units won't be stored - * precisely. + * stored as 215900 µm. For example, a lookup service can match resolution + * attributes based on equality of their serialized representations regardless + * of the units in which they were created. Using integers for internal storage + * allows precise equality comparisons to be done, which would not be guaranteed + * if an internal floating point representation were used. Note that if you're + * looking for {@code U.S. letter} sized media in metric units, you have to + * search for a media size of 215.9 x 279.4 mm; rounding off to an integral + * 216 x 279 mm will not match. + *

+ * The exported constant {@link #INCH INCH} is actually the conversion factor by + * which to multiply a value in inches to get the value in µm. Likewise, + * the exported constant {@link #MM MM} is the conversion factor by which to + * multiply a value in mm to get the value in µm. A client can specify a + * resolution value in units other than inches or mm by supplying its own + * conversion factor. However, since the internal units of µm was chosen + * with supporting only the external units of inch and mm in mind, there is no + * guarantee that the conversion factor for the client's units will be an exact + * integer. If the conversion factor isn't an exact integer, resolution values + * in the client's units won't be stored precisely. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public abstract class Size2DSyntax implements Serializable, Cloneable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 5584439964938660530L; /** - * X dimension in units of micrometers (µm). + * {@code X} dimension in units of micrometers (µm). + * * @serial */ private int x; /** - * Y dimension in units of micrometers (µm). + * {@code Y} dimension in units of micrometers (µm). + * * @serial */ private int y; @@ -108,20 +111,16 @@ public abstract class Size2DSyntax implements Serializable, Cloneable { */ public static final int MM = 1000; - /** * Construct a new two-dimensional size attribute from the given * floating-point values. * - * @param x X dimension. - * @param y Y dimension. - * @param units - * Unit conversion factor, e.g. {@link #INCH INCH} or - * {@link #MM MM}. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or - * {@code units < 1}. + * @param x {@code X} dimension + * @param y {@code Y} dimension + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @throws IllegalArgumentException if {@code x < 0} or {@code y < 0} or + * {@code units < 1} */ protected Size2DSyntax(float x, float y, int units) { if (x < 0.0f) { @@ -141,15 +140,12 @@ public abstract class Size2DSyntax implements Serializable, Cloneable { * Construct a new two-dimensional size attribute from the given integer * values. * - * @param x X dimension. - * @param y Y dimension. - * @param units - * Unit conversion factor, e.g. {@link #INCH INCH} or - * {@link #MM MM}. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} - * or {@code units < 1}. + * @param x {@code X} dimension + * @param y {@code Y} dimension + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @throws IllegalArgumentException if {@code x < 0} or {@code y < 0} or + * {@code units < 1} */ protected Size2DSyntax(int x, int y, int units) { if (x < 0) { @@ -169,16 +165,11 @@ public abstract class Size2DSyntax implements Serializable, Cloneable { * Convert a value from micrometers to some other units. The result is * returned as a floating-point number. * - * @param x - * Value (micrometers) to convert. - * @param units - * Unit conversion factor, e.g. {@link #INCH INCH} or - * {@link #MM MM}. - * - * @return The value of {@code x} converted to the desired units. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units} < 1. + * @param x value (micrometers) to convert + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @return the value of {@code x} converted to the desired units + * @throws IllegalArgumentException if {@code units < 1} */ private static float convertFromMicrometers(int x, int units) { if (units < 1) { @@ -191,46 +182,37 @@ public abstract class Size2DSyntax implements Serializable, Cloneable { * Get this two-dimensional size attribute's dimensions in the given units * as floating-point values. * - * @param units - * Unit conversion factor, e.g. {@link #INCH INCH} or {@link #MM MM}. - * - * @return A two-element array with the X dimension at index 0 and the Y - * dimension at index 1. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @return a two-element array with the {@code X} dimension at index 0 and + * the {@code Y} dimension at index 1 + * @throws IllegalArgumentException if {@code units < 1} */ public float[] getSize(int units) { return new float[] {getX(units), getY(units)}; } /** - * Returns this two-dimensional size attribute's X dimension in the given - * units as a floating-point value. + * Returns this two-dimensional size attribute's {@code X} dimension in the + * given units as a floating-point value. * - * @param units - * Unit conversion factor, e.g. {@link #INCH INCH} or {@link #MM MM}. - * - * @return X dimension. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @return {@code X} dimension + * @throws IllegalArgumentException if {@code units < 1} */ public float getX(int units) { return convertFromMicrometers(x, units); } /** - * Returns this two-dimensional size attribute's Y dimension in the given - * units as a floating-point value. + * Returns this two-dimensional size attribute's {@code Y} dimension in the + * given units as a floating-point value. * - * @param units - * Unit conversion factor, e.g. {@link #INCH INCH} or {@link #MM MM}. - * - * @return Y dimension. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @return {@code Y} dimension + * @throws IllegalArgumentException if {@code units < 1} */ public float getY(int units) { return convertFromMicrometers(y, units); @@ -238,22 +220,17 @@ public abstract class Size2DSyntax implements Serializable, Cloneable { /** * Returns a string version of this two-dimensional size attribute in the - * given units. The string takes the form "XxY - * U", where X is the X dimension, Y is the Y - * dimension, and U is the units name. The values are displayed in - * floating point. + * given units. The string takes the form "XxY + * U", where X is the {@code X} dimension, Y is + * the {@code Y} dimension, and U is the units name. The values are + * displayed in floating point. * - * @param units - * Unit conversion factor, e.g. {@link #INCH INCH} or {@link #MM MM}. - * - * @param unitsName - * Units name string, e.g. {@code in} or {@code mm}. If - * null, no units name is appended to the result. - * - * @return String version of this two-dimensional size attribute. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @param unitsName units name string, e.g. {@code in} or {@code mm}. If + * {@code null}, no units name is appended to the result + * @return {@code String} version of this two-dimensional size attribute + * @throws IllegalArgumentException if {@code units < 1} */ public String toString(int units, String unitsName) { StringBuilder result = new StringBuilder(); @@ -271,23 +248,18 @@ public abstract class Size2DSyntax implements Serializable, Cloneable { * Returns whether this two-dimensional size attribute is equivalent to the * passed in object. To be equivalent, all of the following conditions must * be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class Size2DSyntax. - *
  3. - * This attribute's X dimension is equal to {@code object}'s X - * dimension. - *
  4. - * This attribute's Y dimension is equal to {@code object}'s Y - * dimension. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code Size2DSyntax} + *
  3. This attribute's {@code X} dimension is equal to {@code object}'s + * {@code X} dimension. + *
  4. This attribute's {@code Y} dimension is equal to {@code object}'s + * {@code Y} dimension. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this - * two-dimensional size attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this + * two-dimensional size attribute, {@code false} otherwise */ public boolean equals(Object object) { return(object != null && @@ -306,9 +278,9 @@ public abstract class Size2DSyntax implements Serializable, Cloneable { /** * Returns a string version of this two-dimensional size attribute. The - * string takes the form "XxY um", where - * X is the X dimension and Y is the Y dimension. - * The values are reported in the internal units of micrometers. + * string takes the form "XxY um", where X + * is the {@code X} dimension and Y is the {@code Y} dimension. The + * values are reported in the internal units of micrometers. */ public String toString() { StringBuilder result = new StringBuilder(); @@ -320,23 +292,22 @@ public abstract class Size2DSyntax implements Serializable, Cloneable { } /** - * Returns this two-dimensional size attribute's X dimension in units of - * micrometers (µm). (For use in a subclass.) + * Returns this two-dimensional size attribute's {@code X} dimension in + * units of micrometers (µm). (For use in a subclass.) * - * @return X dimension (µm). + * @return {@code X} dimension (µm) */ protected int getXMicrometers(){ return x; } /** - * Returns this two-dimensional size attribute's Y dimension in units of - * micrometers (µm). (For use in a subclass.) + * Returns this two-dimensional size attribute's {@code Y} dimension in + * units of micrometers (µm). (For use in a subclass.) * - * @return Y dimension (µm). + * @return {@code Y} dimension (µm) */ protected int getYMicrometers() { return y; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/SupportedValuesAttribute.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/SupportedValuesAttribute.java index ca8736b1315..e642e1febeb 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/SupportedValuesAttribute.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/SupportedValuesAttribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,21 +23,20 @@ * questions. */ - package javax.print.attribute; /** - * Interface SupportedValuesAttribute is a tagging interface which a printing - * attribute class implements to indicate the attribute describes the supported - * values for another attribute. For example, if a Print Service instance - * supports the {@link javax.print.attribute.standard.Copies Copies} - * attribute, the Print Service instance will have a {@link - * javax.print.attribute.standard.CopiesSupported CopiesSupported} attribute, - * which is a SupportedValuesAttribute giving the legal values a client may - * specify for the {@link javax.print.attribute.standard.Copies Copies} - * attribute. + * Interface {@code SupportedValuesAttribute} is a tagging interface which a + * printing attribute class implements to indicate the attribute describes the + * supported values for another attribute. For example, if a Print Service + * instance supports the {@link javax.print.attribute.standard.Copies Copies} + * attribute, the Print Service instance will have a + * {@link javax.print.attribute.standard.CopiesSupported CopiesSupported} + * attribute, which is a {@code SupportedValuesAttribute} giving the legal + * values a client may specify for the + * {@link javax.print.attribute.standard.Copies Copies} attribute. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public interface SupportedValuesAttribute extends Attribute { } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/TextSyntax.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/TextSyntax.java index fb7a5654364..79bb0541565 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/TextSyntax.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/TextSyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,48 +23,50 @@ * questions. */ - package javax.print.attribute; import java.io.Serializable; import java.util.Locale; /** - * Class TextSyntax is an abstract base class providing the common + * Class {@code TextSyntax} is an abstract base class providing the common * implementation of all attributes whose value is a string. The text attribute * includes a locale to indicate the natural language. Thus, a text attribute * always represents a localized string. Once constructed, a text attribute's * value is immutable. * - * @author David Mendenhall - * @author Alan Kaminsky + * @author David Mendenhall + * @author Alan Kaminsky */ public abstract class TextSyntax implements Serializable, Cloneable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -8130648736378144102L; /** * String value of this text attribute. + * * @serial */ private String value; /** * Locale of this text attribute. + * * @serial */ private Locale locale; /** - * Constructs a TextAttribute with the specified string and locale. + * Constructs a {@code TextAttribute} with the specified string and locale. * - * @param value Text string. - * @param locale Natural language of the text string. null - * is interpreted to mean the default locale for as returned - * by {@code Locale.getDefault()} - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code value} is null. + * @param value text string + * @param locale natural language of the text string. {@code null} is + * interpreted to mean the default locale for as returned by + * {@code Locale.getDefault()} + * @throws NullPointerException if {@code value} is {@code null} */ protected TextSyntax(String value, Locale locale) { this.value = verify (value); @@ -87,7 +89,8 @@ public abstract class TextSyntax implements Serializable, Cloneable { /** * Returns this text attribute's text string. - * @return the text string. + * + * @return the text string */ public String getValue() { return value; @@ -95,6 +98,7 @@ public abstract class TextSyntax implements Serializable, Cloneable { /** * Returns this text attribute's text string's natural language (locale). + * * @return the locale */ public Locale getLocale() { @@ -104,7 +108,7 @@ public abstract class TextSyntax implements Serializable, Cloneable { /** * Returns a hashcode for this text attribute. * - * @return A hashcode value for this object. + * @return a hashcode value for this object */ public int hashCode() { return value.hashCode() ^ locale.hashCode(); @@ -113,23 +117,17 @@ public abstract class TextSyntax implements Serializable, Cloneable { /** * Returns whether this text attribute is equivalent to the passed in * object. To be equivalent, all of the following conditions must be true: - *
    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class TextSyntax. - *
  3. - * This text attribute's underlying string and {@code object}'s - * underlying string are equal. - *
  4. - * This text attribute's locale and {@code object}'s locale are - * equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code TextSyntax}. + *
  3. This text attribute's underlying string and {@code object}'s + * underlying string are equal. + *
  4. This text attribute's locale and {@code object}'s locale are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this text - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this text + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return(object != null && @@ -139,13 +137,12 @@ public abstract class TextSyntax implements Serializable, Cloneable { } /** - * Returns a String identifying this text attribute. The String is - * the attribute's underlying text string. + * Returns a {@code String} identifying this text attribute. The + * {@code String} is the attribute's underlying text string. * - * @return A String identifying this object. + * @return a {@code String} identifying this object */ public String toString(){ return value; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/URISyntax.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/URISyntax.java index baee148a778..f741961facd 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/URISyntax.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/URISyntax.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -23,36 +23,37 @@ * questions. */ - package javax.print.attribute; import java.io.Serializable; import java.net.URI; /** - * Class URISyntax is an abstract base class providing the common - * implementation of all attributes whose value is a Uniform Resource - * Identifier (URI). Once constructed, a URI attribute's value is immutable. + * Class {@code URISyntax} is an abstract base class providing the common + * implementation of all attributes whose value is a Uniform Resource Identifier + * (URI). Once constructed, a {@code URI} attribute's value is immutable. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public abstract class URISyntax implements Serializable, Cloneable { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -7842661210486401678L; /** - * URI value of this URI attribute. + * {@code URI} value of this {@code URI} attribute. + * * @serial */ private URI uri; /** - * Constructs a URI attribute with the specified URI. + * Constructs a {@code URI} attribute with the specified {@code URI}. * - * @param uri URI. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code uri} is null. + * @param uri the {@code URI} + * @throws NullPointerException if {@code uri} is {@code null} */ protected URISyntax(URI uri) { this.uri = verify (uri); @@ -66,40 +67,36 @@ public abstract class URISyntax implements Serializable, Cloneable { } /** - * Returns this URI attribute's URI value. - * @return the URI. + * Returns this {@code URI} attribute's {@code URI} value. + * + * @return the {@code URI} */ public URI getURI() { return uri; } /** - * Returns a hashcode for this URI attribute. + * Returns a hashcode for this {@code URI} attribute. * - * @return A hashcode value for this object. + * @return a hashcode value for this object */ public int hashCode() { return uri.hashCode(); } /** - * Returns whether this URI attribute is equivalent to the passed in - * object. - * To be equivalent, all of the following conditions must be true: - *
    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class URISyntax. - *
  3. - * This URI attribute's underlying URI and {@code object}'s - * underlying URI are equal. - *
+ * Returns whether this {@code URI} attribute is equivalent to the passed in + * object. To be equivalent, all of the following conditions must be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code URISyntax}. + *
  3. This {@code URI} attribute's underlying {@code URI} and + * {@code object}'s underlying {@code URI} are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this URI - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this {@code URI} + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return(object != null && @@ -108,13 +105,13 @@ public abstract class URISyntax implements Serializable, Cloneable { } /** - * Returns a String identifying this URI attribute. The String is the - * string representation of the attribute's underlying URI. + * Returns a {@code String} identifying this {@code URI} attribute. The + * {@code String} is the string representation of the attribute's underlying + * {@code URI}. * - * @return A String identifying this object. + * @return a {@code String} identifying this object */ public String toString() { return uri.toString(); } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/UnmodifiableSetException.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/UnmodifiableSetException.java index a5b4d1d9ddb..ea2ffde3386 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/UnmodifiableSetException.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/UnmodifiableSetException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -26,26 +26,31 @@ package javax.print.attribute; /** - * Thrown to indicate that the requested operation cannot be performed - * because the set is unmodifiable. + * Thrown to indicate that the requested operation cannot be performed because + * the set is unmodifiable. * - * @author Phil Race - * @since 1.4 + * @author Phil Race + * @since 1.4 */ public class UnmodifiableSetException extends RuntimeException { + + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 2255250308571511731L; /** - * Constructs an UnsupportedOperationException with no detail message. + * Constructs an {@code UnsupportedOperationException} with no detail + * message. */ public UnmodifiableSetException() { } /** - * Constructs an UnmodifiableSetException with the specified - * detail message. + * Constructs an {@code UnmodifiableSetException} with the specified detail + * message. * - * @param message the detail message + * @param message the detail message */ public UnmodifiableSetException(String message) { super(message); diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/package-info.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/package-info.java index f9c571f56c0..12ae39c342e 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/package-info.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/package-info.java @@ -39,19 +39,20 @@ * The print data and the processing instructions are separate entities. This * means that: *
    - *
  • You can print the same print data at different times using different - * processing instructions.
    For example, you can print a slide - * presentation on US letter-sized white paper, double-sided, stapled, 20 - * copies to make handouts for a talk; and you could print the same slide - * presentation on US letter-sized transparencies, single-sided, one copy to - * make the actual slides for the talk.
  • - *
  • You can use the same processing instructions at different times to - * print different data. For example, you could set your default processing - * instructions to: US letter-sized paper, double sided, stapled. Whenever - * you print a job, it prints with these settings, unless you explicitly - * override them.
  • + *
  • You can print the same print data at different times using different + * processing instructions. + *
    + * For example, you can print a slide presentation on US letter-sized white + * paper, double-sided, stapled, 20 copies to make handouts for a talk; and + * you could print the same slide presentation on US letter-sized + * transparencies, single-sided, one copy to make the actual slides for the + * talk. + *
  • You can use the same processing instructions at different times to + * print different data. For example, you could set your default processing + * instructions to: US letter-sized paper, double sided, stapled. Whenever you + * print a job, it prints with these settings, unless you explicitly override + * them. *
- *

* The processing instruction does not specify how the print job processes the * request; each processing instruction is only a description of the results of * a print job. The print job determines the manner in which it achieves the @@ -97,18 +98,18 @@ * The Java Print Service API defines these different kinds of attributes with * five subinterfaces of {@code Attribute}: *

    - *
  • DocAttribute specifies a - * characteristic of an individual document and the print job settings to be - * applied to an individual document.
  • - *
  • PrintRequestAttribute - * specifies a setting applied to a whole print job and to all the documents - * in the print job.
  • - *
  • PrintJobAttribute reports the - * status of a print job.
  • - *
  • PrintServiceAttribute - * reports the status of a print service.
  • - *
  • SupportedValuesAttribute - * gives the supported values for another attribute.
  • + *
  • DocAttribute specifies a characteristic + * of an individual document and the print job settings to be applied to an + * individual document. + *
  • PrintRequestAttribute + * specifies a setting applied to a whole print job and to all the documents + * in the print job. + *
  • PrintJobAttribute reports the + * status of a print job. + *
  • PrintServiceAttribute reports + * the status of a print service. + *
  • SupportedValuesAttribute + * gives the supported values for another attribute. *
* Each attribute class implements one or more of these tagging subinterfaces to * indicate where the attribute can be used in the API. If an attribute class @@ -123,40 +124,39 @@ * The Java Print Service API defines a group of standard attribute classes * modeled upon the attributes in the Internet Printing Protocol (IPP) version * 1.1. The standard attribute classes are in the subpackage - * javax.print.attribute.standard to keep the actual attribute classes + * {@code javax.print.attribute.standard} to keep the actual attribute classes * conceptually separate from the generic apparatus defined in package - * javax.print.attribute. + * {@code javax.print.attribute}. * *

Attribute Sets

* A client usually needs to provide more than one processing instruction when - * submitting a print job. For example, the client might need to specify a - * media size of A4 and a landscape orientation. To send more than one - * processing instruction, the client collects the attributes into an attribute - * set, which the Java Print Service API represents with the + * submitting a print job. For example, the client might need to specify a media + * size of A4 and a landscape orientation. To send more than one processing + * instruction, the client collects the attributes into an attribute set, which + * the Java Print Service API represents with the * AttributeSet interface. *

* The {@code AttributeSet} interface is similar to the * Map interface: it provides a map of * key to values, in which each key is unique and can contain no more than one * value. However, the {@code AttributeSet} interface is designed to - * specifically support the needs of the Java Print Service API. An {@code - * AttributeSet} requires that: + * specifically support the needs of the Java Print Service API. An + * {@code AttributeSet} requires that: *

    - *
  1. Each key in an {@code AttributeSet} corresponds to a category, and - * the value of the key can only be one of the attribute values that belong - * to the category represented by the key. Thus, unlike a {@code Map}, an - * {@code AttributeSet} restricts the possible values of a key: an attribute - * category cannot be set to an attribute value that does not belong to that - * category.
  2. - *
  3. No two attributes from the same category can exist in the same set. - * For example, an attribute collection must not contain both a "one-sided" - * attribute and a "two-sided" attribute because these two attributes give - * the printer conflicting instructions.
  4. - *
  5. Only attributes implementing the {@code Attribute} interface can be - * added to the set.
  6. + *
  7. Each key in an {@code AttributeSet} corresponds to a category, and the + * value of the key can only be one of the attribute values that belong to the + * category represented by the key. Thus, unlike a {@code Map}, an + * {@code AttributeSet} restricts the possible values of a key: an attribute + * category cannot be set to an attribute value that does not belong to that + * category. + *
  8. No two attributes from the same category can exist in the same set. For + * example, an attribute collection must not contain both a "one-sided" + * attribute and a "two-sided" attribute because these two attributes give the + * printer conflicting instructions. + *
  9. Only attributes implementing the {@code Attribute} interface can be + * added to the set. *
- *

- * The javax.print.attribute package includes + * The {@code javax.print.attribute} package includes * HashAttributeSet as a concrete * implementation of the attribute set interface. {@code HashAttributeSet} * provides an attribute set based on a hash map. You can use this @@ -167,18 +167,15 @@ * that are restricted to contain just one of the four kinds of attributes, as * discussed in the Attribute Roles section: *

* Notice that only four kinds of attribute sets are listed here, but there are * five kinds of attributes. Interface - * SupportedValuesAttribute - * denotes an attribute that gives the supported values for another attribute. + * SupportedValuesAttribute denotes + * an attribute that gives the supported values for another attribute. * Supported-values attributes are never aggregated into attribute sets, so * there is no attribute set subinterface defined for them. *

@@ -189,17 +186,15 @@ * For a read-only attribute set, calling a mutating operation throws an * {@code UnmodifiableSetException}. *

- * Package javax.print.attribute includes one concrete implementation of each of - * the attribute set subinterfaces: + * Package {@code javax.print.attribute} includes one concrete implementation of + * each of the attribute set subinterfaces: *

* All of these classes extend * HashAttributeSet and enforce the @@ -211,12 +206,11 @@ * enumerated value. The Java Print Service API does not use primitive data * types, such as int, to represent attribute values for these reasons: *
    - *
  • Primitive data types are not type-safe. For example, a compiler - * should not allow a "copies" attribute value to be used for a "sides" - * attribute.
  • - *
  • Some attributes must be represented as a record of several values. - * One example is printer resolution, which requires two numbers, such as - * 600 and 300 representing 600 x 300 dpi.
  • + *
  • Primitive data types are not type-safe. For example, a compiler should + * not allow a "copies" attribute value to be used for a "sides" attribute. + *
  • Some attributes must be represented as a record of several values. One + * example is printer resolution, which requires two numbers, such as 600 and + * 300 representing 600 x 300 dpi. *
* For type-safety and to represent all attributes uniformly, the Java Print * Service API defines each attribute category as a class, such as class @@ -240,27 +234,27 @@ * represent each abstract syntax, and these classes are used as the parent of * standard attributes whenever possible. The abstract syntax classes are: *
    - *
  • EnumSyntax provides a type-safe - * enumeration in which enumerated values are represented as singleton - * objects. Each enumeration singleton is an instance of the enumeration - * class that wraps a hidden int value.
  • - *
  • IntegerSyntax is the abstract syntax - * for integer-valued attributes.
  • - *
  • TextSyntax is the abstract syntax for - * text-valued attributes, and includes a locale giving the text string's - * natural language.
  • - *
  • SetOfIntegerSyntax is the - * abstract syntax for attributes representing a range or set of integers - *
  • ResolutionSyntax is the abstract - * syntax for attributes representing resolution values, such as 600x300 - * dpi.
  • - *
  • Size2DSyntax is the abstract syntax - * for attributes representing a two-dimensional size, such as a paper size - * of 8.5 x 11 inches.
  • - *
  • DateTimeSyntax is the abstract - * syntax for attributes whose value is a date and time.
  • - *
  • URISyntax is the abstract syntax for - * attributes whose value is a Uniform Resource Indicator.
  • + *
  • EnumSyntax provides a type-safe + * enumeration in which enumerated values are represented as singleton + * objects. Each enumeration singleton is an instance of the enumeration class + * that wraps a hidden int value. + *
  • IntegerSyntax is the abstract syntax + * for integer-valued attributes. + *
  • TextSyntax is the abstract syntax for + * text-valued attributes, and includes a locale giving the text string's + * natural language. + *
  • SetOfIntegerSyntax is the + * abstract syntax for attributes representing a range or set of integers + *
  • ResolutionSyntax is the abstract + * syntax for attributes representing resolution values, such as 600x300 + * dpi. + *
  • Size2DSyntax is the abstract syntax for + * attributes representing a two-dimensional size, such as a paper size of + * 8.5 x 11 inches. + *
  • DateTimeSyntax is the abstract syntax + * for attributes whose value is a date and time. + *
  • URISyntax is the abstract syntax for + * attributes whose value is a Uniform Resource Indicator. *
* The abstract syntax classes are independent of the attributes that use them. * In fact, applications that have nothing to do with printing can use the @@ -304,12 +298,10 @@ *

Attribute Vendors

* The Java Print Service API is designed so that vendors can: *
    - *
  • define new vendor-specific values for any standard attribute defined - * in javax.print.attribute.standard - * .
  • - *
  • define new attribute categories representing the vendor printer's - * proprietary capabilities not already supported by the standard - * attributes.
  • + *
  • define new vendor-specific values for any standard attribute defined in + * javax.print.attribute.standard. + *
  • define new attribute categories representing the vendor printer's + * proprietary capabilities not already supported by the standard attributes. *
* To define a new value for an attribute, a client can construct instances of * such attributes with arbitrary values at runtime. However, an enumerated @@ -364,12 +356,12 @@ * }
* *

- * Please note: In the javax.print APIs, a null reference parameter to methods - * is incorrect unless explicitly documented on the method as having a - * meaningful interpretation. Usage to the contrary is incorrect coding and may - * result in a run time exception either immediately or at some later time. - * IllegalArgumentException and NullPointerException are examples of typical and - * acceptable run time exceptions for such cases. + * Please note: In the {@code javax.print} APIs, a {@code null} reference + * parameter to methods is incorrect unless explicitly documented on the method + * as having a meaningful interpretation. Usage to the contrary is incorrect + * coding and may result in a run time exception either immediately or at some + * later time. {@code IllegalArgumentException} and {@code NullPointerException} + * are examples of typical and acceptable run time exceptions for such cases. * * @since 1.4 */ diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Chromaticity.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Chromaticity.java index afe46620cae..68f6e49eb81 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Chromaticity.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Chromaticity.java @@ -22,75 +22,57 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; -import javax.print.attribute.EnumSyntax; import javax.print.attribute.DocAttribute; -import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.EnumSyntax; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class Chromaticity is a printing attribute class, an enumeration, that - * specifies monochrome or color printing. This is used by a print client + * Class {@code Chromaticity} is a printing attribute class, an enumeration, + * that specifies monochrome or color printing. This is used by a print client * to specify how the print data should be generated or processed. It is not * descriptive of the color capabilities of the device. Query the service's * {@link ColorSupported ColorSupported} attribute to determine if the device * can be verified to support color printing. - *

+ *

* The table below shows the effects of specifying a Chromaticity attribute of - * {@link #MONOCHROME MONOCHROME} or {@link #COLOR COLOR} - * for a monochrome or color document. - * + * {@link #MONOCHROME MONOCHROME} or {@link #COLOR COLOR} for a monochrome or + * color document. * - * + * * - * - * - * - * - * + * + * * - * - * - * - * - * - * - * - * - * - * + * + * + * - *
Shows effects of specifying MONOCHROME or COLOR Chromaticity - * attributesShows effects of specifying {@code MONOCHROME} or {@code COLOR} + * Chromaticity attributes
- * Chromaticity
Attribute - *
- * Effect on
Monochrome Document - *
- * Effect on
Color Document - *
Chromaticity
Attribute + *
Effect on
Monochrome Document + *
Effect on
Color Document *
- * {@link #MONOCHROME MONOCHROME} - * - * Printed as is, in monochrome - * - * Printed in monochrome, with colors converted to shades of gray - *
- * {@link #COLOR COLOR} - * - * Printed as is, in monochrome - * - * Printed as is, in color - *
{@link #MONOCHROME MONOCHROME} + * Printed as is, in monochrome + * Printed in monochrome, with colors converted to shades of gray + *
{@link #COLOR COLOR} + * Printed as is, in monochrome + * Printed as is, in color *
- *

- * IPP Compatibility: Chromaticity is not an IPP attribute at present. + * + *

+ * IPP Compatibility: Chromaticity is not an IPP attribute at present. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class Chromaticity extends EnumSyntax implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 4660543931355214012L; /** @@ -103,32 +85,37 @@ public final class Chromaticity extends EnumSyntax */ public static final Chromaticity COLOR = new Chromaticity(1); - /** * Construct a new chromaticity enumeration value with the given integer * value. * - * @param value Integer value. + * @param value Integer value */ protected Chromaticity(int value) { super(value); } + /** + * The string table for class {@code Chromaticity}. + */ private static final String[] myStringTable = {"monochrome", "color"}; + /** + * The enumeration value table for class {@code Chromaticity}. + */ private static final Chromaticity[] myEnumValueTable = {MONOCHROME, COLOR}; /** - * Returns the string table for class Chromaticity. + * Returns the string table for class {@code Chromaticity}. */ protected String[] getStringTable() { return myStringTable; } /** - * Returns the enumeration value table for class Chromaticity. + * Returns the enumeration value table for class {@code Chromaticity}. */ protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; @@ -137,11 +124,12 @@ public final class Chromaticity extends EnumSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class Chromaticity, the category is the class Chromaticity itself. + *

+ * For class {@code Chromaticity}, the category is the class + * {@code Chromaticity} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return Chromaticity.class; @@ -150,13 +138,13 @@ public final class Chromaticity extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class Chromaticity, the category name is {@code "chromaticity"}. + *

+ * For class {@code Chromaticity}, the category name is + * {@code "chromaticity"}. * - * @return Attribute category name. + * @return attribute category name */ - public final String getName() { - return "chromaticity"; - } - - } + public final String getName() { + return "chromaticity"; + } +} diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/ColorSupported.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/ColorSupported.java index ab5bee83451..207f1cd32fa 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/ColorSupported.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/ColorSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,35 +30,39 @@ import javax.print.attribute.EnumSyntax; import javax.print.attribute.PrintServiceAttribute; /** - * Class ColorSupported is a printing attribute class, an enumeration, that - * identifies whether the device is capable of any type of color printing at - * all, including highlight color as well as full process color. All document + * Class {@code ColorSupported} is a printing attribute class, an enumeration, + * that identifies whether the device is capable of any type of color printing + * at all, including highlight color as well as full process color. All document * instructions having to do with color are embedded within the print data (none * are attributes attached to the job outside the print data). - *

+ *

* Note: End users are able to determine the nature and details of the color - * support by querying the {@link PrinterMoreInfoManufacturer - * PrinterMoreInfoManufacturer} attribute. - *

- * Don't confuse the ColorSupported attribute with the {@link Chromaticity - * Chromaticity} attribute. {@link Chromaticity Chromaticity} is an attribute - * the client can specify for a job to tell the printer whether to print a - * document in monochrome or color, possibly causing the printer to print a - * color document in monochrome. ColorSupported is a printer description - * attribute that tells whether the printer can print in color regardless of how - * the client specifies to print any particular document. - *

- * IPP Compatibility: The IPP boolean value is "true" for SUPPORTED and - * "false" for NOT_SUPPORTED. The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. + * support by querying the + * {@link PrinterMoreInfoManufacturer PrinterMoreInfoManufacturer} attribute. + *

+ * Don't confuse the {@code ColorSupported} attribute with the + * {@link Chromaticity Chromaticity} attribute. + * {@link Chromaticity Chromaticity} is an attribute the client can specify for + * a job to tell the printer whether to print a document in monochrome or color, + * possibly causing the printer to print a color document in monochrome. + * {@code ColorSupported} is a printer description attribute that tells whether + * the printer can print in color regardless of how the client specifies to + * print any particular document. + *

+ * IPP Compatibility: The IPP boolean value is "true" for SUPPORTED and + * "false" for NOT_SUPPORTED. The category name returned by {@code getName()} is + * the IPP attribute name. The enumeration's integer value is the IPP enum + * value. The {@code toString()} method returns the IPP string representation of + * the attribute value. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class ColorSupported extends EnumSyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -2700555589688535545L; /** @@ -66,36 +71,42 @@ public final class ColorSupported extends EnumSyntax public static final ColorSupported NOT_SUPPORTED = new ColorSupported(0); /** - * The printer is capable of some type of color printing, such as - * highlight color or full process color. + * The printer is capable of some type of color printing, such as highlight + * color or full process color. */ public static final ColorSupported SUPPORTED = new ColorSupported(1); /** - * Construct a new color supported enumeration value with the given - * integer value. + * Construct a new color supported enumeration value with the given integer + * value. * - * @param value Integer value. + * @param value Integer value */ protected ColorSupported(int value) { super (value); } + /** + * The string table for class {@code ColorSupported}. + */ private static final String[] myStringTable = {"not-supported", "supported"}; + /** + * The enumeration value table for class {@code ColorSupported}. + */ private static final ColorSupported[] myEnumValueTable = {NOT_SUPPORTED, SUPPORTED}; /** - * Returns the string table for class ColorSupported. + * Returns the string table for class {@code ColorSupported}. */ protected String[] getStringTable() { return myStringTable; } /** - * Returns the enumeration value table for class ColorSupported. + * Returns the enumeration value table for class {@code ColorSupported}. */ protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; @@ -104,11 +115,12 @@ public final class ColorSupported extends EnumSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class ColorSupported, the category is class ColorSupported itself. + *

+ * For class {@code ColorSupported}, the category is class + * {@code ColorSupported} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return ColorSupported.class; @@ -117,13 +129,13 @@ public final class ColorSupported extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class ColorSupported, the category name is {@code "color-supported"}. + *

+ * For class {@code ColorSupported}, the category name is + * {@code "color-supported"} * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "color-supported"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Compression.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Compression.java index c0ba6680aba..36859fd3c7b 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Compression.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Compression.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,29 +22,33 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; -import javax.print.attribute.EnumSyntax; import javax.print.attribute.DocAttribute; +import javax.print.attribute.EnumSyntax; /** - * Class Compression is a printing attribute class, an enumeration, that - * specifies how print data is compressed. Compression is an attribute of the - * print data (the doc), not of the Print Job. If a Compression attribute is not - * specified for a doc, the printer assumes the doc's print data is uncompressed - * (i.e., the default Compression value is always {@link #NONE - * NONE}). - *

- * IPP Compatibility: The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. + * Class {@code Compression} is a printing attribute class, an enumeration, that + * specifies how print data is compressed. {@code Compression} is an attribute + * of the print data (the doc), not of the Print Job. If a {@code Compression} + * attribute is not specified for a doc, the printer assumes the doc's print + * data is uncompressed (i.e., the default Compression value is always + * {@link #NONE NONE}). + *

+ * IPP Compatibility: The category name returned by {@code getName()} is + * the IPP attribute name. The enumeration's integer value is the IPP enum + * value. The {@code toString()} method returns the IPP string representation of + * the attribute value. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public class Compression extends EnumSyntax implements DocAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -5716748913324997674L; /** @@ -59,7 +63,7 @@ public class Compression extends EnumSyntax implements DocAttribute { /** * GNU zip compression technology described in - * RFC 1952. + * RFC 1952. */ public static final Compression GZIP = new Compression(2); @@ -72,32 +76,37 @@ public class Compression extends EnumSyntax implements DocAttribute { * Construct a new compression enumeration value with the given integer * value. * - * @param value Integer value. + * @param value Integer value */ protected Compression(int value) { super(value); } - + /** + * The string table for class {@code Compression}. + */ private static final String[] myStringTable = {"none", "deflate", "gzip", "compress"}; + /** + * The enumeration value table for class {@code Compression}. + */ private static final Compression[] myEnumValueTable = {NONE, DEFLATE, GZIP, COMPRESS}; /** - * Returns the string table for class Compression. + * Returns the string table for class {@code Compression}. */ protected String[] getStringTable() { return myStringTable.clone(); } /** - * Returns the enumeration value table for class Compression. + * Returns the enumeration value table for class {@code Compression}. */ protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); @@ -106,12 +115,12 @@ public class Compression extends EnumSyntax implements DocAttribute { /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class Compression and any vendor-defined subclasses, the category is - * class Compression itself. + *

+ * For class {@code Compression} and any vendor-defined subclasses, the + * category is class {@code Compression} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return Compression.class; @@ -120,14 +129,13 @@ public class Compression extends EnumSyntax implements DocAttribute { /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class Compression and any vendor-defined subclasses, the category - * name is {@code "compression"}. + *

+ * For class {@code Compression} and any vendor-defined subclasses, the + * category name is {@code "compression"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "compression"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Copies.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Copies.java index 67cd5258885..2a8620394c9 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Copies.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Copies.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,64 +22,60 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; import javax.print.attribute.IntegerSyntax; -import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class Copies is an integer valued printing attribute class that specifies the - * number of copies to be printed. - *

+ * Class {@code Copies} is an integer valued printing attribute class that + * specifies the number of copies to be printed. + *

* On many devices the supported number of collated copies will be limited by * the number of physical output bins on the device, and may be different from * the number of uncollated copies which can be supported. - *

- * The effect of a Copies attribute with a value of n on a multidoc print - * job (a job with multiple documents) depends on the (perhaps defaulted) value - * of the {@link MultipleDocumentHandling MultipleDocumentHandling} attribute: - *

    - *
  • - * SINGLE_DOCUMENT -- The result will be n copies of a single output - * document comprising all the input docs. + *

    + * The effect of a {@code Copies} attribute with a value of n on a + * multidoc print job (a job with multiple documents) depends on the (perhaps + * defaulted) value of the + * {@link MultipleDocumentHandling MultipleDocumentHandling} attribute: + *

      + *
    • {@code SINGLE_DOCUMENT} -- The result will be n copies of a + * single output document comprising all the input docs. + *
    • {@code SINGLE_DOCUMENT_NEW_SHEET} -- The result will be n copies + * of a single output document comprising all the input docs, and the first + * impression of each input doc will always start on a new media sheet. + *
    • {@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- The result will be + * n copies of the first input document, followed by n copies of + * the second input document, . . . followed by n copies of the last + * input document. + *
    • {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- The result will be the + * first input document, the second input document, . . . the last input + * document, the group of documents being repeated n times. + *
    + *

    + * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * - *

  • - * SINGLE_DOCUMENT_NEW_SHEET -- The result will be n copies of a single - * output document comprising all the input docs, and the first impression of - * each input doc will always start on a new media sheet. - * - *
  • - * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The result will be n copies of - * the first input document, followed by n copies of the second input - * document, . . . followed by n copies of the last input document. - * - *
  • - * SEPARATE_DOCUMENTS_COLLATED_COPIES -- The result will be the first input - * document, the second input document, . . . the last input document, the group - * of documents being repeated n times. - *
- *

- * IPP Compatibility: The integer value gives the IPP integer value. The - * category name returned by {@code getName()} gives the IPP attribute - * name. - * - * @author David Mendenhall - * @author Alan Kamihensky + * @author David Mendenhall + * @author Alan Kamihensky */ public final class Copies extends IntegerSyntax implements PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -6426631521680023833L; /** * Construct a new copies attribute with the given integer value. * - * @param value Integer value. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 1. + * @param value Integer value + * @throws IllegalArgumentException if {@code value < 1} */ public Copies(int value) { super (value, 1, Integer.MAX_VALUE); @@ -88,20 +84,15 @@ public final class Copies extends IntegerSyntax /** * Returns whether this copies attribute is equivalent to the passed in * object. To be equivalent, all of the following conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class Copies. - *
  3. - * This copies attribute's value and {@code object}'s value are - * equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code Copies}. + *
  3. This copies attribute's value and {@code object}'s value are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this copies - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this copies + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return super.equals (object) && object instanceof Copies; @@ -110,11 +101,11 @@ public final class Copies extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class Copies, the category is class Copies itself. + *

+ * For class {@code Copies}, the category is class {@code Copies} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return Copies.class; @@ -123,13 +114,12 @@ public final class Copies extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class Copies, the category name is {@code "copies"}. + *

+ * For class {@code Copies}, the category name is {@code "copies"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "copies"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/CopiesSupported.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/CopiesSupported.java index 96efbb60bac..28f17e1eafc 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/CopiesSupported.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/CopiesSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,33 +30,34 @@ import javax.print.attribute.SetOfIntegerSyntax; import javax.print.attribute.SupportedValuesAttribute; /** - * Class CopiesSupported is a printing attribute class, a set of integers, that - * gives the supported values for a {@link Copies Copies} attribute. It is - * restricted to a single contiguous range of integers; multiple non-overlapping - * ranges are not allowed. - *

- * IPP Compatibility: The CopiesSupported attribute's canonical array + * Class {@code CopiesSupported} is a printing attribute class, a set of + * integers, that gives the supported values for a {@link Copies Copies} + * attribute. It is restricted to a single contiguous range of integers; + * multiple non-overlapping ranges are not allowed. + *

+ * IPP Compatibility: The CopiesSupported attribute's canonical array * form gives the lower and upper bound for the range of copies to be included - * in an IPP "copies-supported" attribute. See class {@link - * javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an - * explanation of canonical array form. The category name returned by - * {@code getName()} gives the IPP attribute name. + * in an IPP "copies-supported" attribute. See class + * {@link SetOfIntegerSyntax SetOfIntegerSyntax} for an explanation of canonical + * array form. The category name returned by {@code getName()} gives the IPP + * attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class CopiesSupported extends SetOfIntegerSyntax implements SupportedValuesAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 6927711687034846001L; /** * Construct a new copies supported attribute containing a single integer. - * That is, only the one value of Copies is supported. + * That is, only the one value of {@code Copies} is supported. * - * @param member Set member. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code member} is less than 1. + * @param member set member + * @throws IllegalArgumentException if {@code member < 1} */ public CopiesSupported(int member) { super (member); @@ -66,16 +68,14 @@ public final class CopiesSupported extends SetOfIntegerSyntax /** * Construct a new copies supported attribute containing a single range of - * integers. That is, only those values of Copies in the one range are - * supported. + * integers. That is, only those values of {@code Copies} in the one range + * are supported. * - * @param lowerBound Lower bound of the range. - * @param upperBound Upper bound of the range. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if a null range is specified or if a - * non-null range is specified with {@code lowerBound} less than - * 1. + * @param lowerBound Lower bound of the range + * @param upperBound Upper bound of the range + * @throws IllegalArgumentException if a {@code null} range is specified or + * if a {@code non-null} range is specified with {@code lowerBound} + * less than 1 */ public CopiesSupported(int lowerBound, int upperBound) { super(lowerBound, upperBound); @@ -91,20 +91,16 @@ public final class CopiesSupported extends SetOfIntegerSyntax * Returns whether this copies supported attribute is equivalent to the * passed in object. To be equivalent, all of the following conditions must * be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class CopiesSupported. - *
  3. - * This copies supported attribute's members and {@code object}'s - * members are the same. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code CopiesSupported}. + *
  3. This copies supported attribute's members and {@code object}'s + * members are the same. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this copies - * supported attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this copies + * supported attribute, {@code false} otherwise */ public boolean equals(Object object) { return super.equals (object) && object instanceof CopiesSupported; @@ -113,12 +109,12 @@ public final class CopiesSupported extends SetOfIntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class CopiesSupported, the category - * is class CopiesSupported itself. + *

+ * For class {@code CopiesSupported}, the category is class + * {@code CopiesSupported} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return CopiesSupported.class; @@ -127,14 +123,13 @@ public final class CopiesSupported extends SetOfIntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class CopiesSupported, the category - * name is {@code "copies-supported"}. + *

+ * For class {@code CopiesSupported}, the category name is + * {@code "copies-supported"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "copies-supported"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCompleted.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCompleted.java index 9005e940db1..0308e4521f1 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCompleted.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCompleted.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,47 +22,50 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; +import java.util.Calendar; import java.util.Date; + import javax.print.attribute.Attribute; import javax.print.attribute.DateTimeSyntax; import javax.print.attribute.PrintJobAttribute; /** - * Class DateTimeAtCompleted is a printing attribute class, a date-time + * Class {@code DateTimeAtCompleted} is a printing attribute class, a date-time * attribute, that indicates the date and time at which the Print Job completed * (or was canceled or aborted). - *

- * To construct a DateTimeAtCompleted attribute from separate values of the - * year, month, day, hour, minute, and so on, use a {@link java.util.Calendar - * Calendar} object to construct a {@link java.util.Date Date} object, then use - * the {@link java.util.Date Date} object to construct the DateTimeAtCompleted - * attribute. To convert a DateTimeAtCompleted attribute to separate values of - * the year, month, day, hour, minute, and so on, create a {@link - * java.util.Calendar Calendar} object and set it to the {@link java.util.Date - * Date} from the DateTimeAtCompleted attribute. - *

- * IPP Compatibility: The information needed to construct an IPP + *

+ * To construct a {@code DateTimeAtCompleted} attribute from separate values of + * the year, month, day, hour, minute, and so on, use a + * {@link Calendar Calendar} object to construct a {@link Date Date} object, + * then use the {@link Date Date} object to construct the DateTimeAtCompleted + * attribute. To convert a {@code DateTimeAtCompleted} attribute to separate + * values of the year, month, day, hour, minute, and so on, create a + * {@link Calendar Calendar} object and set it to the {@link Date Date} from the + * {@code DateTimeAtCompleted} attribute. + *

+ * IPP Compatibility: The information needed to construct an IPP * "date-time-at-completed" attribute can be obtained as described above. The - * category name returned by {@code getName()} gives the IPP attribute - * name. + * category name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class DateTimeAtCompleted extends DateTimeSyntax implements PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 6497399708058490000L; /** - * Construct a new date-time at completed attribute with the given {@link - * java.util.Date Date} value. + * Construct a new date-time at completed attribute with the given + * {@link Date Date} value. * - * @param dateTime {@link java.util.Date Date} value. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code dateTime} is null. + * @param dateTime {@link Date Date} value + * @throws NullPointerException if {@code dateTime} is {@code null} */ public DateTimeAtCompleted(Date dateTime) { super (dateTime); @@ -72,38 +75,34 @@ public final class DateTimeAtCompleted extends DateTimeSyntax * Returns whether this date-time at completed attribute is equivalent to * the passed in object. To be equivalent, all of the following conditions * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class DateTimeAtCompleted. - *
  3. - * This date-time at completed attribute's {@link java.util.Date Date} value - * and {@code object}'s {@link java.util.Date Date} value are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code DateTimeAtCompleted}. + *
  3. This date-time at completed attribute's {@link Date Date} + * value and {@code object}'s {@link Date Date} value are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this date-time - * at completed attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this date-time at + * completed attribute, {@code false} otherwise */ public boolean equals(Object object) { return(super.equals (object) && object instanceof DateTimeAtCompleted); } -// Exported operations inherited and implemented from interface Attribute. + // Exported operations inherited and implemented from interface Attribute. /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class DateTimeAtCompleted, the category is class - * DateTimeAtCompleted itself. - * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. - */ + *

+ * For class {@code DateTimeAtCompleted}, the category is class + * {@code DateTimeAtCompleted} itself. + * + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} + */ public final Class getCategory() { return DateTimeAtCompleted.class; } @@ -111,14 +110,13 @@ public final class DateTimeAtCompleted extends DateTimeSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class DateTimeAtCompleted, the category name is + *

+ * For class {@code DateTimeAtCompleted}, the category name is * {@code "date-time-at-completed"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "date-time-at-completed"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCreation.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCreation.java index 497398cc3d2..2835ba52c02 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCreation.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtCreation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,70 +22,69 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; +import java.util.Calendar; import java.util.Date; + import javax.print.attribute.Attribute; import javax.print.attribute.DateTimeSyntax; import javax.print.attribute.PrintJobAttribute; /** - * Class DateTimeAtCreation is a printing attribute class, a date-time + * Class {@code DateTimeAtCreation} is a printing attribute class, a date-time * attribute, that indicates the date and time at which the Print Job was * created. - *

- * To construct a DateTimeAtCreation attribute from separate values of the year, - * month, day, hour, minute, and so on, use a {@link java.util.Calendar - * Calendar} object to construct a {@link java.util.Date Date} object, then use - * the {@link java.util.Date Date} object to construct the DateTimeAtCreation - * attribute. To convert a DateTimeAtCreation attribute to separate values of - * the year, month, day, hour, minute, and so on, create a {@link - * java.util.Calendar Calendar} object and set it to the {@link java.util.Date - * Date} from the DateTimeAtCreation attribute. - *

- * IPP Compatibility: The information needed to construct an IPP + *

+ * To construct a {@code DateTimeAtCreation} attribute from separate values of + * the year, month, day, hour, minute, and so on, use a + * {@link Calendar Calendar} object to construct a {@link Date Date} object, + * then use the {@link Date Date} object to construct the DateTimeAtCreation + * attribute. To convert a {@code DateTimeAtCreation} attribute to separate + * values of the year, month, day, hour, minute, and so on, create a + * {@link Calendar Calendar} object and set it to the {@link Date Date} from the + * {@code DateTimeAtCreation} attribute. + *

+ * IPP Compatibility: The information needed to construct an IPP * "date-time-at-creation" attribute can be obtained as described above. The - * category name returned by {@code getName()} gives the IPP attribute - * name. + * category name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class DateTimeAtCreation extends DateTimeSyntax implements PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -2923732231056647903L; /** - * Construct a new date-time at creation attribute with the given {@link - * java.util.Date Date} value. + * Construct a new date-time at creation attribute with the given + * {@link Date Date} value. * - * @param dateTime {@link java.util.Date Date} value. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code dateTime} is null. + * @param dateTime {@link Date Date} value + * @throws NullPointerException if {@code dateTime} is {@code null} */ public DateTimeAtCreation(Date dateTime) { super (dateTime); } /** - * Returns whether this date-time at creation attribute is equivalent to - * the passed in object. To be equivalent, all of the following conditions - * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class DateTimeAtCreation. - *
  3. - * This date-time at creation attribute's {@link java.util.Date Date} value - * and {@code object}'s {@link java.util.Date Date} value are equal. - *
+ * Returns whether this date-time at creation attribute is equivalent to the + * passed in object. To be equivalent, all of the following conditions must + * be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code DateTimeAtCreation}. + *
  3. This date-time at creation attribute's {@link Date Date} + * value and {@code object}'s {@link Date Date} value are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this date-time - * at creation attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this date-time at + * creation attribute, {@code false} otherwise */ public boolean equals(Object object) { return(super.equals (object) && @@ -95,12 +94,12 @@ public final class DateTimeAtCreation extends DateTimeSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class DateTimeAtCreation, the category is class - * DateTimeAtCreation itself. + *

+ * For class {@code DateTimeAtCreation}, the category is class + * {@code DateTimeAtCreation} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return DateTimeAtCreation.class; @@ -109,14 +108,13 @@ public final class DateTimeAtCreation extends DateTimeSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class DateTimeAtCreation, the category name is + *

+ * For class {@code DateTimeAtCreation}, the category name is * {@code "date-time-at-creation"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "date-time-at-creation"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtProcessing.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtProcessing.java index 98ad0d2216d..ca182ea6205 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtProcessing.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DateTimeAtProcessing.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,47 +22,50 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; +import java.util.Calendar; import java.util.Date; + import javax.print.attribute.Attribute; import javax.print.attribute.DateTimeSyntax; import javax.print.attribute.PrintJobAttribute; /** - * Class DateTimeAtProcessing is a printing attribute class, a date-time + * Class {@code DateTimeAtProcessing} is a printing attribute class, a date-time * attribute, that indicates the date and time at which the Print Job first * began processing. - *

- * To construct a DateTimeAtProcessing attribute from separate values of the - * year, month, day, hour, minute, and so on, use a {@link java.util.Calendar - * Calendar} object to construct a {@link java.util.Date Date} object, then use - * the {@link java.util.Date Date} object to construct the DateTimeAtProcessing - * attribute. To convert a DateTimeAtProcessing attribute to separate values of - * the year, month, day, hour, minute, and so on, create a {@link - * java.util.Calendar Calendar} object and set it to the {@link java.util.Date - * Date} from the DateTimeAtProcessing attribute. - *

- * IPP Compatibility: The information needed to construct an IPP + *

+ * To construct a {@code DateTimeAtProcessing} attribute from separate values of + * the year, month, day, hour, minute, and so on, use a + * {@link Calendar Calendar} object to construct a {@link Date Date} object, + * then use the {@link Date Date} object to construct the DateTimeAtProcessing + * attribute. To convert a {@code DateTimeAtProcessing} attribute to separate + * values of the year, month, day, hour, minute, and so on, create a + * {@link Calendar Calendar} object and set it to the {@link Date Date} from the + * {@code DateTimeAtProcessing} attribute. + *

+ * IPP Compatibility: The information needed to construct an IPP * "date-time-at-processing" attribute can be obtained as described above. The - * category name returned by {@code getName()} gives the IPP attribute - * name. + * category name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class DateTimeAtProcessing extends DateTimeSyntax implements PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -3710068197278263244L; /** - * Construct a new date-time at processing attribute with the given {@link - * java.util.Date Date} value. + * Construct a new date-time at processing attribute with the given + * {@link Date Date} value. * - * @param dateTime {@link java.util.Date Date} value. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code dateTime} is null. + * @param dateTime {@link Date Date} value + * @throws NullPointerException if {@code dateTime} is {@code null} */ public DateTimeAtProcessing(Date dateTime) { super (dateTime); @@ -72,21 +75,17 @@ public final class DateTimeAtProcessing extends DateTimeSyntax * Returns whether this date-time at processing attribute is equivalent to * the passed in object. To be equivalent, all of the following conditions * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class DateTimeAtProcessing. - *
  3. - * This date-time at processing attribute's {@link java.util.Date Date} - * value and {@code object}'s {@link java.util.Date Date} value - * are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class + * {@code DateTimeAtProcessing}. + *
  3. This date-time at processing attribute's {@link Date Date} + * value and {@code object}'s {@link Date Date} value are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this date-time - * at processing attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this date-time at + * processing attribute, {@code false} otherwise */ public boolean equals(Object object) { return(super.equals (object) && @@ -96,12 +95,12 @@ public final class DateTimeAtProcessing extends DateTimeSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class DateTimeAtProcessing, the category is class - * DateTimeAtProcessing itself. + *

+ * For class {@code DateTimeAtProcessing}, the category is class + * {@code DateTimeAtProcessing} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return DateTimeAtProcessing.class; @@ -110,14 +109,13 @@ public final class DateTimeAtProcessing extends DateTimeSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class DateTimeAtProcessing, the category name is + *

+ * For class {@code DateTimeAtProcessing}, the category name is * {@code "date-time-at-processing"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "date-time-at-processing"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Destination.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Destination.java index 4c855da4b73..651ddef0a77 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Destination.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Destination.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,72 +22,70 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; +import java.io.File; import java.net.URI; import javax.print.attribute.Attribute; -import javax.print.attribute.URISyntax; -import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.URISyntax; /** - * Class Destination is a printing attribute class, a URI, that is used to - * indicate an alternate destination for the spooled printer formatted - * data. Many PrintServices will not support the notion of a destination - * other than the printer device, and so will not support this attribute. + * Class {@code Destination} is a printing attribute class, a {@code URI}, that + * is used to indicate an alternate destination for the spooled printer + * formatted data. Many {@code PrintServices} will not support the notion of a + * destination other than the printer device, and so will not support this + * attribute. *

- * A common use for this attribute will be applications which want - * to redirect output to a local disk file : eg."file:out.prn". - * Note that proper construction of "file:" scheme URI instances should - * be performed using the {@code toURI()} method of class - * {@link java.io.File File}. - * See the documentation on that class for more information. + * A common use for this attribute will be applications which want to redirect + * output to a local disk file : eg."file:out.prn". Note that proper + * construction of "file:" scheme {@code URI} instances should be performed + * using the {@code toURI()} method of class {@link File File}. See the + * documentation on that class for more information. *

- * If a destination URI is specified in a PrintRequest and it is not - * accessible for output by the PrintService, a PrintException will be thrown. - * The PrintException may implement URIException to provide a more specific - * cause. - *

- * IPP Compatibility: Destination is not an IPP attribute. + * If a destination {@code URI} is specified in a PrintRequest and it is not + * accessible for output by the {@code PrintService}, a {@code PrintException} + * will be thrown. The {@code PrintException} may implement {@code URIException} + * to provide a more specific cause. + *

+ * IPP Compatibility: Destination is not an IPP attribute. * - * @author Phil Race. + * @author Phil Race */ public final class Destination extends URISyntax implements PrintJobAttribute, PrintRequestAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 6776739171700415321L; /** - * Constructs a new destination attribute with the specified URI. + * Constructs a new destination attribute with the specified {@code URI}. * - * @param uri URI. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code uri} is null. + * @param uri {@code URI} + * @throws NullPointerException if {@code uri} is {@code null} */ public Destination(URI uri) { super (uri); } /** - * Returns whether this destination attribute is equivalent to the - * passed in object. To be equivalent, all of the following conditions - * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class Destination. - *
  3. - * This destination attribute's URI and {@code object}'s URI - * are equal. - *
+ * Returns whether this destination attribute is equivalent to the passed in + * object. To be equivalent, all of the following conditions must be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code Destination}. + *
  3. This destination attribute's {@code URI} and {@code object}'s + * {@code URI} are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this destination - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this destination + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && @@ -97,11 +95,12 @@ public final class Destination extends URISyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class Destination, the category is class Destination itself. + *

+ * For class {@code Destination}, the category is class {@code Destination} + * itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return Destination.class; @@ -110,13 +109,13 @@ public final class Destination extends URISyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class Destination, the category name is {@code "spool-data-destination"}. + *

+ * For class {@code Destination}, the category name is + * {@code "spool-data-destination"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "spool-data-destination"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DialogTypeSelection.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DialogTypeSelection.java index f4827744815..2162bee502c 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DialogTypeSelection.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DialogTypeSelection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -25,107 +25,112 @@ package javax.print.attribute.standard; -import javax.print.attribute.EnumSyntax; import javax.print.attribute.Attribute; +import javax.print.attribute.EnumSyntax; import javax.print.attribute.PrintRequestAttribute; /** - * Class DialogTypeSelection is a printing attribute class, an enumeration, - * that indicates the user dialog type to be used for specifying - * printing options. - * If {@code NATIVE} is specified, then where available, a native - * platform dialog is displayed. - * If {@code COMMON} is specified, a cross-platform print dialog is displayed. - * - * This option to specify a native dialog for use with an IPP attribute - * set provides a standard way to reflect back of the setting and option - * changes made by a user to the calling application, and integrates - * the native dialog into the Java printing APIs. - * But note that some options and settings in a native dialog may not - * necessarily map to IPP attributes as they may be non-standard platform, - * or even printer specific options. - *

- * IPP Compatibility: This is not an IPP attribute. + * Class {@code DialogTypeSelection} is a printing attribute class, an + * enumeration, that indicates the user dialog type to be used for specifying + * printing options. If {@code NATIVE} is specified, then where available, a + * native platform dialog is displayed. If {@code COMMON} is specified, a + * cross-platform print dialog is displayed. + *

+ * This option to specify a native dialog for use with an IPP attribute set + * provides a standard way to reflect back of the setting and option changes + * made by a user to the calling application, and integrates the native dialog + * into the Java printing APIs. But note that some options and settings in a + * native dialog may not necessarily map to IPP attributes as they may be + * non-standard platform, or even printer specific options. + *

+ * IPP Compatibility: This is not an IPP attribute. * * @since 1.7 */ public final class DialogTypeSelection extends EnumSyntax implements PrintRequestAttribute { + /** + * Use serialVersionUID from JDK 1.7 for interoperability. + */ private static final long serialVersionUID = 7518682952133256029L; /** - * + * The native platform print dialog should be used. */ public static final DialogTypeSelection NATIVE = new DialogTypeSelection(0); /** - * + * The cross-platform print dialog should be used. */ public static final DialogTypeSelection COMMON = new DialogTypeSelection(1); /** - * Constructs a new dialog type selection enumeration value with the - * given integer value. + * Constructs a new dialog type selection enumeration value with the given + * integer value. * - * @param value Integer value. + * @param value Integer value */ protected DialogTypeSelection(int value) { super(value); } + /** + * The string table for class {@code DialogTypeSelection}. + */ private static final String[] myStringTable = { "native", "common"}; - + /** + * The enumeration value table for class + * {@code DialogTypeSelection}. + */ private static final DialogTypeSelection[] myEnumValueTable = { NATIVE, COMMON }; /** - * Returns the string table for class DialogTypeSelection. + * Returns the string table for class {@code DialogTypeSelection}. */ protected String[] getStringTable() { return myStringTable; } /** - * Returns the enumeration value table for class DialogTypeSelection. + * Returns the enumeration value table for class + * {@code DialogTypeSelection}. */ protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } - - /** + /** * Gets the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class DialogTypeSelection the category is class - * DialogTypeSelection itself. + *

+ * For class {@code DialogTypeSelection} the category is class + * {@code DialogTypeSelection} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return DialogTypeSelection.class; } - /** * Gets the name of the category of which this attribute value is an * instance. - *

- * For class DialogTypeSelection the category name is + *

+ * For class {@code DialogTypeSelection} the category name is * {@code "dialog-type-selection"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "dialog-type-selection"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DocumentName.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DocumentName.java index a2716895cf1..a2aeaf6333a 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DocumentName.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/DocumentName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,71 +22,67 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.Locale; import javax.print.attribute.Attribute; -import javax.print.attribute.TextSyntax; import javax.print.attribute.DocAttribute; +import javax.print.attribute.TextSyntax; /** - * Class DocumentName is a printing attribute class, a text attribute, that - * specifies the name of a document. DocumentName is an attribute of the print - * data (the doc), not of the Print Job. A document's name is an arbitrary - * string defined by the client. - * However if a JobName is not specified, the DocumentName should be used - * instead, which implies that supporting specification of DocumentName - * requires reporting of JobName and vice versa. - * See {@link JobName JobName} for more information. - *

- * IPP Compatibility: The string value gives the IPP name value. The + * Class {@code DocumentName} is a printing attribute class, a text attribute, + * that specifies the name of a document. {@code DocumentName} is an attribute + * of the print data (the doc), not of the Print Job. A document's name is an + * arbitrary string defined by the client. However if a JobName is not + * specified, the {@code DocumentName} should be used instead, which implies + * that supporting specification of {@code DocumentName} requires reporting of + * JobName and vice versa. See {@link JobName JobName} for more information. + *

+ * IPP Compatibility: The string value gives the IPP name value. The * locale gives the IPP natural language. The category name returned by * {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class DocumentName extends TextSyntax implements DocAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 7883105848533280430L; /** - * Constructs a new document name attribute with the given document name - * and locale. + * Constructs a new document name attribute with the given document name and + * locale. * - * @param documentName Document name. - * @param locale Natural language of the text string. null - * is interpreted to mean the default locale as returned - * by {@code Locale.getDefault()} - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code documentName} is null. + * @param documentName document name + * @param locale natural language of the text string. {@code null} is + * interpreted to mean the default locale as returned by + * {@code Locale.getDefault()} + * @throws NullPointerException if {@code documentName} is {@code null} */ public DocumentName(String documentName, Locale locale) { super (documentName, locale); } /** - * Returns whether this document name attribute is equivalent to the - * passed in object. - * To be equivalent, all of the following conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class DocumentName. - *
  3. - * This document name attribute's underlying string and - * {@code object}'s underlying string are equal. - *
  4. - * This document name attribute's locale and {@code object}'s locale - * are equal. - *
+ * Returns whether this document name attribute is equivalent to the passed + * in object. To be equivalent, all of the following conditions must be + * true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code DocumentName}. + *
  3. This document name attribute's underlying string and + * {@code object}'s underlying string are equal. + *
  4. This document name attribute's locale and {@code object}'s locale + * are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this document - * name attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this document + * name attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && object instanceof DocumentName); @@ -95,11 +91,12 @@ public final class DocumentName extends TextSyntax implements DocAttribute { /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class DocumentName, the category is class DocumentName itself. + *

+ * For class {@code DocumentName}, the category is class + * {@code DocumentName} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return DocumentName.class; @@ -108,13 +105,13 @@ public final class DocumentName extends TextSyntax implements DocAttribute { /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class DocumentName, the category name is {@code "document-name"}. + *

+ * For class {@code DocumentName}, the category name is + * {@code "document-name"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "document-name"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Fidelity.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Fidelity.java index b77b110d309..945e91e5af7 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Fidelity.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Fidelity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -30,27 +31,27 @@ import javax.print.attribute.PrintJobAttribute; import javax.print.attribute.PrintRequestAttribute; /** - * Class Fidelity is a printing attribute class, an enumeration, - * that indicates whether total fidelity to client supplied print request - * attributes is required. - * If FIDELITY_TRUE is specified and a service cannot print the job exactly - * as specified it must reject the job. - * If FIDELITY_FALSE is specified a reasonable attempt to print the job is - * acceptable. If not supplied the default is FIDELITY_FALSE. - * - *

- * IPP Compatibility: The IPP boolean value is "true" for FIDELITY_TRUE - * and "false" for FIDELITY_FALSE. The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. - * See RFC 2911 Section 15.1 for - * a fuller description of the IPP fidelity attribute. - * + * Class {@code Fidelity} is a printing attribute class, an enumeration, that + * indicates whether total fidelity to client supplied print request attributes + * is required. If {@code FIDELITY_TRUE} is specified and a service cannot print + * the job exactly as specified it must reject the job. If + * {@code FIDELITY_FALSE} is specified a reasonable attempt to print the job is + * acceptable. If not supplied the default is {@code FIDELITY_FALSE}. + *

+ * IPP Compatibility: The IPP boolean value is "true" for + * {@code FIDELITY_TRUE} and "false" for {@code FIDELITY_FALSE}. The category + * name returned by {@code getName()} is the IPP attribute name. The + * enumeration's integer value is the IPP enum value. The {@code toString()} + * method returns the IPP string representation of the attribute value. See + * RFC 2911 Section 15.1 for a + * fuller description of the IPP fidelity attribute. */ public final class Fidelity extends EnumSyntax implements PrintJobAttribute, PrintRequestAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 6320827847329172308L; /** @@ -60,53 +61,60 @@ public final class Fidelity extends EnumSyntax FIDELITY_TRUE = new Fidelity(0); /** - * The printer should make reasonable attempts to print the job, - * even if it cannot print it exactly as specified. + * The printer should make reasonable attempts to print the job, even if it + * cannot print it exactly as specified. */ public static final Fidelity FIDELITY_FALSE = new Fidelity(1); /** - * Construct a new fidelity enumeration value with the - * given integer value. + * Construct a new fidelity enumeration value with the given integer value. * - * @param value Integer value. + * @param value Integer value */ protected Fidelity(int value) { super (value); } + /** + * The string table for class {@code Fidelity}. + */ private static final String[] myStringTable = { "true", "false" }; - + /** + * The enumeration value table for class {@code Fidelity}. + */ private static final Fidelity[] myEnumValueTable = { FIDELITY_TRUE, FIDELITY_FALSE }; /** - * Returns the string table for class Fidelity. + * Returns the string table for class {@code Fidelity}. */ protected String[] getStringTable() { return myStringTable; } /** - * Returns the enumeration value table for class Fidelity. + * Returns the enumeration value table for class {@code Fidelity}. */ protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; - } /** + } + + /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class Fidelity the category is class Fidelity itself. + *

+ * For class {@code Fidelity} the category is class + * {@code Fidelity} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return Fidelity.class; @@ -115,14 +123,13 @@ public final class Fidelity extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class Fidelity the category name is + *

+ * For class {@code Fidelity} the category name is * {@code "ipp-attribute-fidelity"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "ipp-attribute-fidelity"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java index e4be4c98a2a..4bf5531f4e3 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java @@ -22,209 +22,134 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; -import javax.print.attribute.EnumSyntax; import javax.print.attribute.DocAttribute; -import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.EnumSyntax; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class Finishings is a printing attribute class, an enumeration, that - * identifies whether the printer applies a finishing operation of some kind - * of binding to each copy of each printed document in the job. For multidoc - * print jobs (jobs with multiple documents), the - * {@link MultipleDocumentHandling - * MultipleDocumentHandling} attribute determines what constitutes a "copy" - * for purposes of finishing. - *

+ * Class {@code Finishings} is a printing attribute class, an enumeration, that + * identifies whether the printer applies a finishing operation of some kind of + * binding to each copy of each printed document in the job. For multidoc print + * jobs (jobs with multiple documents), the + * {@link MultipleDocumentHandling MultipleDocumentHandling} attribute + * determines what constitutes a "copy" for purposes of finishing. + *

* Standard Finishings values are: * * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Standard Finishings values
- *   - * - * {@link #NONE NONE} - * - * {@link #STAPLE STAPLE} - * - * {@link #EDGE_STITCH EDGE_STITCH} - *
- *   - * - * {@link #BIND BIND} - * - * {@link #SADDLE_STITCH SADDLE_STITCH} - * - * {@link #COVER COVER} - * - *   - *
- *

- * The following Finishings values are more specific; they indicate a + * + *   + * {@link #NONE NONE} + * {@link #STAPLE STAPLE} + * {@link #EDGE_STITCH EDGE_STITCH} + * + *   + * {@link #BIND BIND} + * {@link #SADDLE_STITCH SADDLE_STITCH} + * {@link #COVER COVER} + *   + * + *

+ * The following {@code Finishings} values are more specific; they indicate a * corner or an edge as if the document were a portrait document: * * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Specific Finishings values
- *   - * - * {@link #STAPLE_TOP_LEFT STAPLE_TOP_LEFT} - * - * {@link #EDGE_STITCH_LEFT EDGE_STITCH_LEFT} - * - * {@link #STAPLE_DUAL_LEFT STAPLE_DUAL_LEFT} - * - *   - *
- *   - * - * {@link #STAPLE_BOTTOM_LEFT STAPLE_BOTTOM_LEFT} - * - * {@link #EDGE_STITCH_TOP EDGE_STITCH_TOP} - * - * {@link #STAPLE_DUAL_TOP STAPLE_DUAL_TOP} - * - *   - *
- *   - * - * {@link #STAPLE_TOP_RIGHT STAPLE_TOP_RIGHT} - * - * {@link #EDGE_STITCH_RIGHT EDGE_STITCH_RIGHT} - * - * {@link #STAPLE_DUAL_RIGHT STAPLE_DUAL_RIGHT} - * - *   - *
- *   - * - * {@link #STAPLE_BOTTOM_RIGHT STAPLE_BOTTOM_RIGHT} - * - * {@link #EDGE_STITCH_BOTTOM EDGE_STITCH_BOTTOM} - * - * {@link #STAPLE_DUAL_BOTTOM STAPLE_DUAL_BOTTOM} - * - *   - *
- *

- * The STAPLE_XXX values are specified with respect to the - * document as if the document were a portrait document. If the document is - * actually a landscape or a reverse-landscape document, the client supplies the + * + *   + * {@link #STAPLE_TOP_LEFT STAPLE_TOP_LEFT} + * {@link #EDGE_STITCH_LEFT EDGE_STITCH_LEFT} + * {@link #STAPLE_DUAL_LEFT STAPLE_DUAL_LEFT} + *   + * + *   + * {@link #STAPLE_BOTTOM_LEFT STAPLE_BOTTOM_LEFT} + * {@link #EDGE_STITCH_TOP EDGE_STITCH_TOP} + * {@link #STAPLE_DUAL_TOP STAPLE_DUAL_TOP} + *   + * + *   + * {@link #STAPLE_TOP_RIGHT STAPLE_TOP_RIGHT} + * {@link #EDGE_STITCH_RIGHT EDGE_STITCH_RIGHT} + * {@link #STAPLE_DUAL_RIGHT STAPLE_DUAL_RIGHT} + *   + * + *   + * {@link #STAPLE_BOTTOM_RIGHT STAPLE_BOTTOM_RIGHT} + * {@link #EDGE_STITCH_BOTTOM EDGE_STITCH_BOTTOM} + * {@link #STAPLE_DUAL_BOTTOM STAPLE_DUAL_BOTTOM} + *   + * + *

+ * The STAPLE_XXX values are specified with respect to the document as if + * the document were a portrait document. If the document is actually a + * landscape or a reverse-landscape document, the client supplies the * appropriate transformed value. For example, to position a staple in the upper * left hand corner of a landscape document when held for reading, the client - * supplies the STAPLE_BOTTOM_LEFT value (since landscape is - * defined as a +90 degree rotation from portrait, i.e., anti-clockwise). On the - * other hand, to position a staple in the upper left hand corner of a + * supplies the {@code STAPLE_BOTTOM_LEFT} value (since landscape is defined as + * a +90 degree rotation from portrait, i.e., anti-clockwise). On the other + * hand, to position a staple in the upper left hand corner of a * reverse-landscape document when held for reading, the client supplies the - * STAPLE_TOP_RIGHT value (since reverse-landscape is defined as a - * -90 degree rotation from portrait, i.e., clockwise). - *

+ * {@code STAPLE_TOP_RIGHT} value (since reverse-landscape is defined as a -90 + * degree rotation from portrait, i.e., clockwise). + *

* The angle (vertical, horizontal, angled) of each staple with respect to the * document depends on the implementation which may in turn depend on the value * of the attribute. - *

- * The effect of a Finishings attribute on a multidoc print job (a job + *

+ * The effect of a {@code Finishings} attribute on a multidoc print job (a job * with multiple documents) depends on whether all the docs have the same * binding specified or whether different docs have different bindings - * specified, and on the (perhaps defaulted) value of the {@link - * MultipleDocumentHandling MultipleDocumentHandling} attribute. - *

    - *
  • - * If all the docs have the same binding specified, then any value of {@link - * MultipleDocumentHandling MultipleDocumentHandling} makes sense, and the - * printer's processing depends on the {@link MultipleDocumentHandling - * MultipleDocumentHandling} value: - *
      - *
    • - * SINGLE_DOCUMENT -- All the input docs will be bound together as one output - * document with the specified binding. + * specified, and on the (perhaps defaulted) value of the + * {@link MultipleDocumentHandling MultipleDocumentHandling} attribute. + *
        + *
      • If all the docs have the same binding specified, then any value of + * {@link MultipleDocumentHandling MultipleDocumentHandling} makes sense, and + * the printer's processing depends on the + * {@link MultipleDocumentHandling MultipleDocumentHandling} value: + *
          + *
        • {@code SINGLE_DOCUMENT} -- All the input docs will be bound together + * as one output document with the specified binding. + *
        • {@code SINGLE_DOCUMENT_NEW_SHEET} -- All the input docs will be bound + * together as one output document with the specified binding, and the first + * impression of each input doc will always start on a new media sheet. + *
        • {@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- Each input doc will + * be bound separately with the specified binding. + *
        • {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- Each input doc will be + * bound separately with the specified binding. + *
        + *
      • If different docs have different bindings specified, then only two + * values of {@link MultipleDocumentHandling MultipleDocumentHandling} make + * sense, and the printer reports an error when the job is submitted if any + * other value is specified: + *
          + *
        • {@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- Each input doc will + * be bound separately with its own specified binding. + *
        • {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- Each input doc will be + * bound separately with its own specified binding. + *
        + *
      + *

      + * IPP Compatibility: Class Finishings encapsulates some of the IPP enum + * values that can be included in an IPP "finishings" attribute, which is a set + * of enums. The category name returned by {@code getName()} is the IPP + * attribute name. The enumeration's integer value is the IPP enum value. The + * {@code toString()} method returns the IPP string representation of the + * attribute value. In IPP Finishings is a multi-value attribute, this API + * currently allows only one binding to be specified. * - *

    • - * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be bound together as one - * output document with the specified binding, and the first impression of each - * input doc will always start on a new media sheet. - * - *
    • - * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- Each input doc will be bound - * separately with the specified binding. - * - *
    • - * SEPARATE_DOCUMENTS_COLLATED_COPIES -- Each input doc will be bound separately - * with the specified binding. - *
    - * - *
  • - * If different docs have different bindings specified, then only two values of - * {@link MultipleDocumentHandling MultipleDocumentHandling} make sense, and the - * printer reports an error when the job is submitted if any other value is - * specified: - *
      - *
    • - * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- Each input doc will be bound - * separately with its own specified binding. - * - *
    • - * SEPARATE_DOCUMENTS_COLLATED_COPIES -- Each input doc will be bound separately - * with its own specified binding. - *
    - *
- *

- * IPP Compatibility: Class Finishings encapsulates some of the - * IPP enum values that can be included in an IPP "finishings" attribute, which - * is a set of enums. The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. - * In IPP Finishings is a multi-value attribute, this API currently allows - * only one binding to be specified. - * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public class Finishings extends EnumSyntax implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -627840419548391754L; /** @@ -241,21 +166,21 @@ public class Finishings extends EnumSyntax /** * This value is specified when it is desired to select a non-printed (or * pre-printed) cover for the document. This does not supplant the - * specification of a printed cover (on cover stock medium) by the - * document itself. + * specification of a printed cover (on cover stock medium) by the document + * itself. */ public static final Finishings COVER = new Finishings(6); /** - * This value indicates that a binding is to be applied to the document; - * the type and placement of the binding is site-defined. + * This value indicates that a binding is to be applied to the document; the + * type and placement of the binding is site-defined. */ public static final Finishings BIND = new Finishings(7); /** * Bind the document(s) with one or more staples (wire stitches) along the - * middle fold. The exact number and placement of the staples and the - * middle fold is implementation- and/or site-defined. + * middle fold. The exact number and placement of the staples and the middle + * fold is implementation- and/or site-defined. */ public static final Finishings SADDLE_STITCH = new Finishings(8); @@ -275,8 +200,7 @@ public class Finishings extends EnumSyntax new Finishings(20); /** - * Bind the document(s) with one or more staples in the bottom left - * corner. + * Bind the document(s) with one or more staples in the bottom left corner. */ public static final Finishings STAPLE_BOTTOM_LEFT = new Finishings(21); @@ -288,8 +212,7 @@ public class Finishings extends EnumSyntax new Finishings(22); /** - * Bind the document(s) with one or more staples in the bottom right - * corner. + * Bind the document(s) with one or more staples in the bottom right corner. */ public static final Finishings STAPLE_BOTTOM_RIGHT = new Finishings(23); @@ -327,15 +250,15 @@ public class Finishings extends EnumSyntax new Finishings(27); /** - * Bind the document(s) with two staples (wire stitches) along the left - * edge assuming a portrait document (see above). + * Bind the document(s) with two staples (wire stitches) along the left edge + * assuming a portrait document (see above). */ public static final Finishings STAPLE_DUAL_LEFT = new Finishings(28); /** - * Bind the document(s) with two staples (wire stitches) along the top - * edge assuming a portrait document (see above). + * Bind the document(s) with two staples (wire stitches) along the top edge + * assuming a portrait document (see above). */ public static final Finishings STAPLE_DUAL_TOP = new Finishings(29); @@ -358,12 +281,15 @@ public class Finishings extends EnumSyntax * Construct a new finishings binding enumeration value with the given * integer value. * - * @param value Integer value. + * @param value Integer value */ protected Finishings(int value) { super(value); } + /** + * The string table for class {@code Finishings}. + */ private static final String[] myStringTable = {"none", "staple", @@ -396,6 +322,9 @@ public class Finishings extends EnumSyntax "staple-dual-bottom" }; + /** + * The enumeration value table for class {@code Finishings}. + */ private static final Finishings[] myEnumValueTable = {NONE, STAPLE, @@ -429,21 +358,21 @@ public class Finishings extends EnumSyntax }; /** - * Returns the string table for class Finishings. + * Returns the string table for class {@code Finishings}. */ protected String[] getStringTable() { return myStringTable.clone(); } /** - * Returns the enumeration value table for class Finishings. + * Returns the enumeration value table for class {@code Finishings}. */ protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } /** - * Returns the lowest integer value used by class Finishings. + * Returns the lowest integer value used by class {@code Finishings}. */ protected int getOffset() { return 3; @@ -452,12 +381,12 @@ public class Finishings extends EnumSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class Finishings and any vendor-defined subclasses, the - * category is class Finishings itself. + *

+ * For class {@code Finishings} and any vendor-defined subclasses, the + * category is class {@code Finishings} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return Finishings.class; @@ -466,14 +395,13 @@ public class Finishings extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class Finishings and any vendor-defined subclasses, the + *

+ * For class {@code Finishings} and any vendor-defined subclasses, the * category name is {@code "finishings"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "finishings"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobHoldUntil.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobHoldUntil.java index 6c6da671faf..fb37997e463 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobHoldUntil.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobHoldUntil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,116 +22,118 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; +import java.util.Calendar; import java.util.Date; + import javax.print.attribute.Attribute; import javax.print.attribute.DateTimeSyntax; -import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class JobHoldUntil is a printing attribute class, a date-time attribute, that - * specifies the exact date and time at which the job must become a candidate - * for printing. - *

+ * Class {@code JobHoldUntil} is a printing attribute class, a date-time + * attribute, that specifies the exact date and time at which the job must + * become a candidate for printing. + *

* If the value of this attribute specifies a date-time that is in the future, * the printer should add the {@link JobStateReason JobStateReason} value of - * JOB_HOLD_UNTIL_SPECIFIED to the job's {@link JobStateReasons JobStateReasons} - * attribute, must move the job to the PENDING_HELD state, and must not schedule - * the job for printing until the specified date-time arrives. - *

- * When the specified date-time arrives, the printer must remove the {@link - * JobStateReason JobStateReason} value of JOB_HOLD_UNTIL_SPECIFIED from the - * job's {@link JobStateReasons JobStateReasons} attribute, if present. If there - * are no other job state reasons that keep the job in the PENDING_HELD state, - * the printer must consider the job as a candidate for processing by moving the - * job to the PENDING state. - *

+ * {@code JOB_HOLD_UNTIL_SPECIFIED} to the job's + * {@link JobStateReasons JobStateReasons} attribute, must move the job to the + * {@code PENDING_HELD} state, and must not schedule the job for printing until + * the specified date-time arrives. + *

+ * When the specified date-time arrives, the printer must remove the + * {@link JobStateReason JobStateReason} value of + * {@code JOB_HOLD_UNTIL_SPECIFIED} from the job's + * {@link JobStateReasons JobStateReasons} attribute, if present. If there are + * no other job state reasons that keep the job in the {@code PENDING_HELD} + * state, the printer must consider the job as a candidate for processing by + * moving the job to the PENDING state. + *

* If the specified date-time has already passed, the job must be a candidate * for processing immediately. Thus, one way to make the job immediately become - * a candidate for processing is to specify a JobHoldUntil attribute constructed - * like this (denoting a date-time of January 1, 1970, 00:00:00 GMT): - *

+ * a candidate for processing is to specify a {@code JobHoldUntil} attribute
+ * constructed like this
+ * (denoting a date-time of January 1, 1970, 00:00:00 GMT):
+ * 
  *     JobHoldUntil immediately = new JobHoldUntil (new Date (0L));
- * 
- *

+ *

+ *

* If the client does not supply this attribute in a Print Request and the * printer supports this attribute, the printer must use its - * (implementation-dependent) default JobHoldUntil value at job submission time - * (unlike most job template attributes that are used if necessary at job - * processing time). - *

- * To construct a JobHoldUntil attribute from separate values of the year, - * month, day, hour, minute, and so on, use a {@link java.util.Calendar - * Calendar} object to construct a {@link java.util.Date Date} object, then use - * the {@link java.util.Date Date} object to construct the JobHoldUntil - * attribute. To convert a JobHoldUntil attribute to separate values of the - * year, month, day, hour, minute, and so on, create a {@link java.util.Calendar - * Calendar} object and set it to the {@link java.util.Date Date} from the - * JobHoldUntil attribute. - *

- * IPP Compatibility: Although IPP supports a "job-hold-until" attribute + * (implementation-dependent) default {@code JobHoldUntil} value at job + * submission time (unlike most job template attributes that are used if + * necessary at job processing time). + *

+ * To construct a {@code JobHoldUntil} attribute from separate values of the + * year, month, day, hour, minute, and so on, use a {@link Calendar Calendar} + * object to construct a {@link Date Date} object, then use the + * {@link Date Date} object to construct the {@code JobHoldUntil} attribute. To + * convert a {@code JobHoldUntil} attribute to separate values of the year, + * month, day, hour, minute, and so on, create a {@link Calendar Calendar} + * object and set it to the {@link Date Date} from the {@code JobHoldUntil} + * attribute. + *

+ * IPP Compatibility: Although IPP supports a "job-hold-until" attribute * specified as a keyword, IPP does not at this time support a "job-hold-until" * attribute specified as a date and time. However, the date and time can be * converted to one of the standard IPP keywords with some loss of precision; - * for example, a JobHoldUntil value with today's date and 9:00pm local time - * might be converted to the standard IPP keyword "night". The category name - * returned by {@code getName()} gives the IPP attribute name. + * for example, a {@code JobHoldUntil} value with today's date and 9:00pm local + * time might be converted to the standard IPP keyword "night". The category + * name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class JobHoldUntil extends DateTimeSyntax implements PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -1664471048860415024L; - /** * Construct a new job hold until date-time attribute with the given - * {@link java.util.Date Date} value. + * {@link Date Date} value. * - * @param dateTime {@link java.util.Date Date} value. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code dateTime} is null. + * @param dateTime {@link Date Date} value + * @throws NullPointerException if {@code dateTime} is {@code null} */ public JobHoldUntil(Date dateTime) { super (dateTime); } /** - * Returns whether this job hold until attribute is equivalent to the - * passed in object. To be equivalent, all of the following conditions - * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobHoldUntil. - *
  3. - * This job hold until attribute's {@link java.util.Date Date} value and - * {@code object}'s {@link java.util.Date Date} value are equal. - *
+ * Returns whether this job hold until attribute is equivalent to the passed + * in object. To be equivalent, all of the following conditions must be + * true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code JobHoldUntil}. + *
  3. This job hold until attribute's {@link Date Date} value and + * {@code object}'s {@link Date Date} value are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job hold - * until attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job hold + * until attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && object instanceof JobHoldUntil); } - /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobHoldUntil, the category is class JobHoldUntil itself. + *

+ * For class {@code JobHoldUntil}, the category is class + * {@code JobHoldUntil} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobHoldUntil.class; @@ -140,13 +142,13 @@ public final class JobHoldUntil extends DateTimeSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobHoldUntil, the category name is {@code "job-hold-until"}. + *

+ * For class {@code JobHoldUntil}, the category name is + * {@code "job-hold-until"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-hold-until"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressions.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressions.java index 8d5a1244327..abdf8f786b5 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressions.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,70 +22,71 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; import javax.print.attribute.IntegerSyntax; -import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class JobImpressions is an integer valued printing attribute class that - * specifies the total size in number of impressions of the document(s) being - * submitted. An "impression" is the image (possibly many print-stream pages in - * different configurations) imposed onto a single media page. - *

- * The JobImpressions attribute describes the size of the job. This attribute is - * not intended to be a counter; it is intended to be useful routing and - * scheduling information if known. The printer may try to compute the - * JobImpressions attribute's value if it is not supplied in the Print Request. - * Even if the client does supply a value for the JobImpressions attribute in - * the Print Request, the printer may choose to change the value if the printer - * is able to compute a value which is more accurate than the client supplied - * value. The printer may be able to determine the correct value for the - * JobImpressions attribute either right at job submission time or at any later - * point in time. - *

- * As with {@link JobKOctets JobKOctets}, the JobImpressions value must not - * include the multiplicative factors contributed by the number of copies + * Class {@code JobImpressions} is an integer valued printing attribute class + * that specifies the total size in number of impressions of the document(s) + * being submitted. An "impression" is the image (possibly many print-stream + * pages in different configurations) imposed onto a single media page. + *

+ * The {@code JobImpressions} attribute describes the size of the job. This + * attribute is not intended to be a counter; it is intended to be useful + * routing and scheduling information if known. The printer may try to compute + * the {@code JobImpressions} attribute's value if it is not supplied in the + * Print Request. Even if the client does supply a value for the + * {@code JobImpressions} attribute in the Print Request, the printer may choose + * to change the value if the printer is able to compute a value which is more + * accurate than the client supplied value. The printer may be able to determine + * the correct value for the {@code JobImpressions} attribute either right at + * job submission time or at any later point in time. + *

+ * As with {@link JobKOctets JobKOctets}, the {@code JobImpressions} value must + * not include the multiplicative factors contributed by the number of copies * specified by the {@link Copies Copies} attribute, independent of whether the * device can process multiple copies without making multiple passes over the * job or document data and independent of whether the output is collated or * not. Thus the value is independent of the implementation and reflects the * size of the document(s) measured in impressions independent of the number of * copies. - *

- * As with {@link JobKOctets JobKOctets}, the JobImpressions value must also not - * include the multiplicative factor due to a copies instruction embedded in the - * document data. If the document data actually includes replications of the - * document data, this value will include such replication. In other words, this - * value is always the number of impressions in the source document data, rather - * than a measure of the number of impressions to be produced by the job. - *

- * IPP Compatibility: The integer value gives the IPP integer value. The - * category name returned by {@code getName()} gives the IPP attribute - * name. + *

+ * As with {@link JobKOctets JobKOctets}, the {@code JobImpressions} value must + * also not include the multiplicative factor due to a copies instruction + * embedded in the document data. If the document data actually includes + * replications of the document data, this value will include such replication. + * In other words, this value is always the number of impressions in the source + * document data, rather than a measure of the number of impressions to be + * produced by the job. + *

+ * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * + * @author Alan Kaminsky * @see JobImpressionsSupported * @see JobImpressionsCompleted * @see JobKOctets * @see JobMediaSheets - * - * @author Alan Kaminsky */ public final class JobImpressions extends IntegerSyntax implements PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 8225537206784322464L; - /** * Construct a new job impressions attribute with the given integer value. * - * @param value Integer value. + * @param value Integer value + * @throws IllegalArgumentException if {@code value} is negative * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 0. */ public JobImpressions(int value) { super(value, 0, Integer.MAX_VALUE); @@ -95,20 +96,16 @@ public final class JobImpressions extends IntegerSyntax * Returns whether this job impressions attribute is equivalent to the * passed in object. To be equivalent, all of the following conditions must * be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobImpressions. - *
  3. - * This job impressions attribute's value and {@code object}'s value - * are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code JobImpressions}. + *
  3. This job impressions attribute's value and {@code object}'s value + * are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job - * impressions attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job + * impressions attribute, {@code false} otherwise */ public boolean equals(Object object) { return super.equals (object) && object instanceof JobImpressions; @@ -117,11 +114,12 @@ public final class JobImpressions extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobImpressions, the category is class JobImpressions itself. + *

+ * For class {@code JobImpressions}, the category is class + * {@code JobImpressions} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobImpressions.class; @@ -130,14 +128,13 @@ public final class JobImpressions extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobImpressions, the category name is + *

+ * For class {@code JobImpressions}, the category name is * {@code "job-impressions"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-impressions"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsCompleted.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsCompleted.java index ea346435dd6..6243cda6985 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsCompleted.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsCompleted.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,68 +30,66 @@ import javax.print.attribute.IntegerSyntax; import javax.print.attribute.PrintJobAttribute; /** - * Class JobImpressionsCompleted is an integer valued printing attribute class - * that specifies the number of impressions completed for the job so far. For - * printing devices, the impressions completed includes interpreting, marking, - * and stacking the output. - *

- * The JobImpressionsCompleted attribute describes the progress of the job. This - * attribute is intended to be a counter. That is, the JobImpressionsCompleted - * value for a job that has not started processing must be 0. When the job's - * {@link JobState JobState} is PROCESSING or PROCESSING_STOPPED, the - * JobImpressionsCompleted value is intended to increase as the job is + * Class {@code JobImpressionsCompleted} is an integer valued printing attribute + * class that specifies the number of impressions completed for the job so far. + * For printing devices, the impressions completed includes interpreting, + * marking, and stacking the output. + *

+ * The {@code JobImpressionsCompleted} attribute describes the progress of the + * job. This attribute is intended to be a counter. That is, the + * {@code JobImpressionsCompleted} value for a job that has not started + * processing must be 0. When the job's {@link JobState JobState} is + * {@code PROCESSING} or {@code PROCESSING_STOPPED}, the + * {@code JobImpressionsCompleted} value is intended to increase as the job is * processed; it indicates the amount of the job that has been processed at the * time the Print Job's attribute set is queried or at the time a print job - * event is reported. When the job enters the COMPLETED, CANCELED, or ABORTED - * states, the JobImpressionsCompleted value is the final value for the job. - *

- * IPP Compatibility: The integer value gives the IPP integer value. The - * category name returned by {@code getName()} gives the IPP attribute - * name. + * event is reported. When the job enters the {@code COMPLETED}, + * {@code CANCELED}, or {@code ABORTED} states, the + * {@code JobImpressionsCompleted} value is the final value for the job. + *

+ * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * + * @author Alan Kaminsky * @see JobImpressions * @see JobImpressionsSupported * @see JobKOctetsProcessed * @see JobMediaSheetsCompleted - * - * @author Alan Kaminsky */ public final class JobImpressionsCompleted extends IntegerSyntax implements PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 6722648442432393294L; /** * Construct a new job impressions completed attribute with the given * integer value. * - * @param value Integer value. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 0. + * @param value Integer value + * @throws IllegalArgumentException if {@code value} is negative */ public JobImpressionsCompleted(int value) { super (value, 0, Integer.MAX_VALUE); } /** - * Returns whether this job impressions completed attribute is equivalent - * tp the passed in object. To be equivalent, all of the following - * conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobImpressionsCompleted. - *
  3. - * This job impressions completed attribute's value and - * {@code object}'s value are equal. - *
+ * Returns whether this job impressions completed attribute is equivalent tp + * the passed in object. To be equivalent, all of the following conditions + * must be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class + * {@code JobImpressionsCompleted}. + *
  3. This job impressions completed attribute's value and + * {@code object}'s value are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job - * impressions completed attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job + * impressions completed attribute, {@code false} otherwise */ public boolean equals(Object object) { return(super.equals (object) && @@ -100,12 +99,12 @@ public final class JobImpressionsCompleted extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobImpressionsCompleted, the category is class - * JobImpressionsCompleted itself. + *

+ * For class {@code JobImpressionsCompleted}, the category is class + * {@code JobImpressionsCompleted} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobImpressionsCompleted.class; @@ -114,14 +113,13 @@ public final class JobImpressionsCompleted extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobImpressionsCompleted, the category name is + *

+ * For class {@code JobImpressionsCompleted}, the category name is * {@code "job-impressions-completed"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-impressions-completed"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsSupported.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsSupported.java index ee53d2a3614..63c7d32f171 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsSupported.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobImpressionsSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,40 +30,40 @@ import javax.print.attribute.SetOfIntegerSyntax; import javax.print.attribute.SupportedValuesAttribute; /** - * Class JobImpressionsSupported is a printing attribute class, a set of - * integers, that gives the supported values for a {@link JobImpressions - * JobImpressions} attribute. It is restricted to a single contiguous range of - * integers; multiple non-overlapping ranges are not allowed. This gives the - * lower and upper bounds of the total sizes of print jobs in number of - * impressions that the printer will accept. - *

- * IPP Compatibility: The JobImpressionsSupported attribute's canonical - * array form gives the lower and upper bound for the range of values to be - * included in an IPP "job-impressions-supported" attribute. See class {@link - * javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an - * explanation of canonical array form. The category name returned by - * {@code getName()} gives the IPP attribute name. + * Class {@code JobImpressionsSupported} is a printing attribute class, a set of + * integers, that gives the supported values for a + * {@link JobImpressions JobImpressions} attribute. It is restricted to a single + * contiguous range of integers; multiple non-overlapping ranges are not + * allowed. This gives the lower and upper bounds of the total sizes of print + * jobs in number of impressions that the printer will accept. + *

+ * IPP Compatibility: The {@code JobImpressionsSupported} attribute's + * canonical array form gives the lower and upper bound for the range of values + * to be included in an IPP "job-impressions-supported" attribute. See class + * {@link SetOfIntegerSyntax SetOfIntegerSyntax} for an explanation of canonical + * array form. The category name returned by {@code getName()} gives the IPP + * attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class JobImpressionsSupported extends SetOfIntegerSyntax implements SupportedValuesAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -4887354803843173692L; - /** * Construct a new job impressions supported attribute containing a single - * range of integers. That is, only those values of JobImpressions in the - * one range are supported. + * range of integers. That is, only those values of {@code JobImpressions} + * in the one range are supported. * - * @param lowerBound Lower bound of the range. - * @param upperBound Upper bound of the range. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if a null range is specified or if a - * non-null range is specified with {@code lowerBound} less than - * 0. + * @param lowerBound lower bound of the range + * @param upperBound upper bound of the range + * @throws IllegalArgumentException if a {@code null} range is specified or + * if a {@code non-null} range is specified with {@code lowerBound} + * less than zero */ public JobImpressionsSupported(int lowerBound, int upperBound) { super (lowerBound, upperBound); @@ -74,25 +75,21 @@ public final class JobImpressionsSupported extends SetOfIntegerSyntax } } - /** - * Returns whether this job impressions supported attribute is equivalent - * to the passed in object. To be equivalent, all of the following - * conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobImpressionsSupported. - *
  3. - * This job impressions supported attribute's members and - * {@code object}'s members are the same. - *
+ * Returns whether this job impressions supported attribute is equivalent to + * the passed in object. To be equivalent, all of the following conditions + * must be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class + * {@code JobImpressionsSupported}. + *
  3. This job impressions supported attribute's members and + * {@code object}'s members are the same. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job - * impressions supported attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job + * impressions supported attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && @@ -102,12 +99,12 @@ public final class JobImpressionsSupported extends SetOfIntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobImpressionsSupported, the category is class - * JobImpressionsSupported itself. + *

+ * For class {@code JobImpressionsSupported}, the category is class + * {@code JobImpressionsSupported} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobImpressionsSupported.class; @@ -116,14 +113,13 @@ public final class JobImpressionsSupported extends SetOfIntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobImpressionsSupported, the category name is + *

+ * For class {@code JobImpressionsSupported}, the category name is * {@code "job-impressions-supported"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-impressions-supported"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctets.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctets.java index 5be4b258294..eba1e3c231f 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctets.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctets.java @@ -22,126 +22,119 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; import javax.print.attribute.IntegerSyntax; -import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class JobKOctets is an integer valued printing attribute class that specifies - * the total size of the document(s) in K octets, i.e., in units of 1024 octets - * requested to be processed in the job. The value must be rounded up, so that a - * job between 1 and 1024 octets must be indicated as being 1K octets, 1025 to - * 2048 must be 2K octets, etc. For a multidoc print job (a job with multiple - * documents), the JobKOctets value is computed by adding up the individual - * documents' sizes in octets, then rounding up to the next K octets value. - *

- * The JobKOctets attribute describes the size of the job. This attribute is not - * intended to be a counter; it is intended to be useful routing and scheduling - * information if known. The printer may try to compute the JobKOctets - * attribute's value if it is not supplied in the Print Request. Even if the - * client does supply a value for the JobKOctets attribute in the Print Request, - * the printer may choose to change the value if the printer is able to compute - * a value which is more accurate than the client supplied value. The printer - * may be able to determine the correct value for the JobKOctets attribute - * either right at job submission time or at any later point in time. - *

- * The JobKOctets value must not include the multiplicative factors contributed - * by the number of copies specified by the {@link Copies Copies} attribute, - * independent of whether the device can process multiple copies without making - * multiple passes over the job or document data and independent of whether the - * output is collated or not. Thus the value is independent of the - * implementation and indicates the size of the document(s) measured in K octets - * independent of the number of copies. - *

- * The JobKOctets value must also not include the multiplicative factor due to a - * copies instruction embedded in the document data. If the document data - * actually includes replications of the document data, this value will include - * such replication. In other words, this value is always the size of the source - * document data, rather than a measure of the hardcopy output to be produced. - *

+ * Class {@code JobKOctets} is an integer valued printing attribute class that + * specifies the total size of the document(s) in K octets, i.e., in units of + * 1024 octets requested to be processed in the job. The value must be rounded + * up, so that a job between 1 and 1024 octets must be indicated as being 1K + * octets, 1025 to 2048 must be 2K octets, etc. For a multidoc print job (a job + * with multiple documents), the {@code JobKOctets} value is computed by adding + * up the individual documents' sizes in octets, then rounding up to the next K + * octets value. + *

+ * The {@code JobKOctets} attribute describes the size of the job. This + * attribute is not intended to be a counter; it is intended to be useful + * routing and scheduling information if known. The printer may try to compute + * the {@code JobKOctets} attribute's value if it is not supplied in the Print + * Request. Even if the client does supply a value for the {@code JobKOctets} + * attribute in the Print Request, the printer may choose to change the value if + * the printer is able to compute a value which is more accurate than the client + * supplied value. The printer may be able to determine the correct value for + * the {@code JobKOctets} attribute either right at job submission time or at + * any later point in time. + *

+ * The {@code JobKOctets} value must not include the multiplicative factors + * contributed by the number of copies specified by the {@link Copies Copies} + * attribute, independent of whether the device can process multiple copies + * without making multiple passes over the job or document data and independent + * of whether the output is collated or not. Thus the value is independent of + * the implementation and indicates the size of the document(s) measured in K + * octets independent of the number of copies. + *

+ * The {@code JobKOctets} value must also not include the multiplicative factor + * due to a copies instruction embedded in the document data. If the document + * data actually includes replications of the document data, this value will + * include such replication. In other words, this value is always the size of + * the source document data, rather than a measure of the hardcopy output to be + * produced. + *

* The size of a doc is computed based on the print data representation class as - * specified by the doc's {@link javax.print.DocFlavor DocFlavor}, as - * shown in the table below. - * + * specified by the doc's {@link javax.print.DocFlavor DocFlavor}, as shown in + * the table below. * * * - * - * - * - * + * + * * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * - *
Table showing computation of doc sizes
Representation ClassDocument Size
Representation Class + * Document Size *
byte[]Length of the byte array
java.io.InputStreamNumber of bytes read from the stream
char[]Length of the character array x 2
java.lang.StringLength of the string x 2
java.io.ReaderNumber of characters read from the stream x 2
java.net.URLNumber of bytes read from the file at the given URL address
java.awt.image.renderable.RenderableImageImplementation dependent*
java.awt.print.PrintableImplementation dependent*
java.awt.print.PageableImplementation dependent*
{@code byte[]} + * Length of the byte array + *
{@code java.io.InputStream} + * Number of bytes read from the stream + *
{@code char[]} + * Length of the character array x 2 + *
{@code java.lang.String} + * Length of the string x 2 + *
{@code java.io.Reader} + * Number of characters read from the stream x 2 + *
{@code java.net.URL} + * Number of bytes read from the file at the given {@code URL} address + *
{@code java.awt.image.renderable.RenderableImage} + * Implementation dependent* + *
{@code java.awt.print.Printable} + * Implementation dependent* + *
{@code java.awt.print.Pageable} + * Implementation dependent* *
- *

+ * + *

* * In these cases the Print Service itself generates the print data sent - * to the printer. If the Print Service supports the JobKOctets attribute, for - * these cases the Print Service itself must calculate the size of the print - * data, replacing any JobKOctets value the client specified. - *

- * IPP Compatibility: The integer value gives the IPP integer value. The - * category name returned by {@code getName()} gives the IPP attribute - * name. + * to the printer. If the Print Service supports the {@code JobKOctets} + * attribute, for these cases the Print Service itself must calculate the size + * of the print data, replacing any {@code JobKOctets} value the client + * specified. + *

+ * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * + * @author Alan Kaminsky * @see JobKOctetsSupported * @see JobKOctetsProcessed * @see JobImpressions * @see JobMediaSheets - * - * @author Alan Kaminsky */ public final class JobKOctets extends IntegerSyntax implements PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -8959710146498202869L; /** * Construct a new job K octets attribute with the given integer value. * - * @param value Integer value. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 0. + * @param value Integer value + * @throws IllegalArgumentException if {@code value} is negative */ public JobKOctets(int value) { super (value, 0, Integer.MAX_VALUE); @@ -151,20 +144,16 @@ public final class JobKOctets extends IntegerSyntax * Returns whether this job K octets attribute is equivalent to the passed * in object. To be equivalent, all of the following conditions must be * true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobKOctets. - *
  3. - * This job K octets attribute's value and {@code object}'s value - * are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code JobKOctets}. + *
  3. This job K octets attribute's value and {@code object}'s value are + * equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job K - * octets attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job K octets + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return super.equals(object) && object instanceof JobKOctets; @@ -173,11 +162,12 @@ public final class JobKOctets extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobKOctets, the category is class JobKOctets itself. + *

+ * For class {@code JobKOctets}, the category is class + * {@code JobKOctets} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobKOctets.class; @@ -186,13 +176,13 @@ public final class JobKOctets extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobKOctets, the category name is {@code "job-k-octets"}. + *

+ * For class {@code JobKOctets}, the category name is + * {@code "job-k-octets"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-k-octets"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsProcessed.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsProcessed.java index d3fff73454f..47da75f019f 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsProcessed.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsProcessed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,57 +30,57 @@ import javax.print.attribute.IntegerSyntax; import javax.print.attribute.PrintJobAttribute; /** - * Class JobKOctetsProcessed is an integer valued printing attribute class that - * specifies the total number of print data octets processed so far in K octets, - * i.e., in units of 1024 octets. The value must be rounded up, so that a job - * between 1 and 1024 octets inclusive must be indicated as being 1K octets, - * 1025 to 2048 inclusive must be 2K, etc. For a multidoc print job (a job with - * multiple documents), the JobKOctetsProcessed value is computed by adding up - * the individual documents' number of octets processed so far, then rounding up - * to the next K octets value. - *

- * The JobKOctetsProcessed attribute describes the progress of the job. This - * attribute is intended to be a counter. That is, the JobKOctetsProcessed value - * for a job that has not started processing must be 0. When the job's {@link - * JobState JobState} is PROCESSING or PROCESSING_STOPPED, the - * JobKOctetsProcessed value is intended to increase as the job is processed; it - * indicates the amount of the job that has been processed at the time the Print - * Job's attribute set is queried or at the time a print job event is reported. - * When the job enters the COMPLETED, CANCELED, or ABORTED states, the - * JobKOctetsProcessed value is the final value for the job. - *

+ * Class {@code JobKOctetsProcessed} is an integer valued printing attribute + * class that specifies the total number of print data octets processed so far + * in K octets, i.e., in units of 1024 octets. The value must be rounded up, so + * that a job between 1 and 1024 octets inclusive must be indicated as being 1K + * octets, 1025 to 2048 inclusive must be 2K, etc. For a multidoc print job (a + * job with multiple documents), the JobKOctetsProcessed value is computed by + * adding up the individual documents' number of octets processed so far, then + * rounding up to the next K octets value. + *

+ * The {@code JobKOctetsProcessed} attribute describes the progress of the job. + * This attribute is intended to be a counter. That is, the JobKOctetsProcessed + * value for a job that has not started processing must be 0. When the job's + * {@link JobState JobState} is {@code PROCESSING} or + * {@code PROCESSING_STOPPED}, the {@code JobKOctetsProcessed} value is intended + * to increase as the job is processed; it indicates the amount of the job that + * has been processed at the time the Print Job's attribute set is queried or at + * the time a print job event is reported. When the job enters the + * {@code COMPLETED}, {@code CANCELED}, or {@code ABORTED} states, the + * {@code JobKOctetsProcessed} value is the final value for the job. + *

* For implementations where multiple copies are produced by the interpreter * with only a single pass over the data, the final value of the - * JobKOctetsProcessed attribute must be equal to the value of the {@link - * JobKOctets JobKOctets} attribute. For implementations where multiple copies - * are produced by the interpreter by processing the data for each copy, the - * final value must be a multiple of the value of the {@link JobKOctets - * JobKOctets} attribute. - *

- * IPP Compatibility: The integer value gives the IPP integer value. The - * category name returned by {@code getName()} gives the IPP attribute - * name. + * JobKOctetsProcessed attribute must be equal to the value of the + * {@link JobKOctets JobKOctets} attribute. For implementations where multiple + * copies are produced by the interpreter by processing the data for each copy, + * the final value must be a multiple of the value of the + * {@link JobKOctets JobKOctets} attribute. + *

+ * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * + * @author Alan Kaminsky * @see JobKOctets * @see JobKOctetsSupported * @see JobImpressionsCompleted * @see JobMediaSheetsCompleted - * - * @author Alan Kaminsky */ public final class JobKOctetsProcessed extends IntegerSyntax implements PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -6265238509657881806L; /** * Construct a new job K octets processed attribute with the given integer * value. * - * @param value Integer value. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 0. + * @param value Integer value + * @throws IllegalArgumentException if {@code value} is negative */ public JobKOctetsProcessed(int value) { super (value, 0, Integer.MAX_VALUE); @@ -89,20 +90,16 @@ public final class JobKOctetsProcessed extends IntegerSyntax * Returns whether this job K octets processed attribute is equivalent to * the passed in object. To be equivalent, all of the following conditions * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobKOctetsProcessed. - *
  3. - * This job K octets processed attribute's value and - * {@code object}'s value are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code JobKOctetsProcessed}. + *
  3. This job K octets processed attribute's value and {@code object}'s + * value are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job K - * octets processed attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job K octets + * processed attribute, {@code false} otherwise */ public boolean equals(Object object) { return(super.equals (object) && @@ -112,12 +109,12 @@ public final class JobKOctetsProcessed extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobKOctetsProcessed, the category is class - * JobKOctetsProcessed itself. + *

+ * For class {@code JobKOctetsProcessed}, the category is class + * {@code JobKOctetsProcessed} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobKOctetsProcessed.class; @@ -126,14 +123,13 @@ public final class JobKOctetsProcessed extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobKOctetsProcessed, the category name is + *

+ * For class {@code JobKOctetsProcessed}, the category name is * {@code "job-k-octets-processed"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-k-octets-processed"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsSupported.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsSupported.java index c4666bee8b1..9d6836d25a7 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsSupported.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobKOctetsSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,25 +30,28 @@ import javax.print.attribute.SetOfIntegerSyntax; import javax.print.attribute.SupportedValuesAttribute; /** - * Class JobKOctetsSupported is a printing attribute class, a set of integers, - * that gives the supported values for a {@link JobKOctets JobKOctets} + * Class {@code JobKOctetsSupported} is a printing attribute class, a set of + * integers, that gives the supported values for a {@link JobKOctets JobKOctets} * attribute. It is restricted to a single contiguous range of integers; * multiple non-overlapping ranges are not allowed. This gives the lower and * upper bounds of the total sizes of print jobs in units of K octets (1024 * octets) that the printer will accept. - *

- * IPP Compatibility: The JobKOctetsSupported attribute's canonical array - * form gives the lower and upper bound for the range of values to be included - * in an IPP "job-k-octets-supported" attribute. See class {@link - * javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an - * explanation of canonical array form. The category name returned by - * {@code getName()} gives the IPP attribute name. + *

+ * IPP Compatibility: The {@code JobKOctetsSupported} attribute's + * canonical array form gives the lower and upper bound for the range of values + * to be included in an IPP "job-k-octets-supported" attribute. See class + * {@link SetOfIntegerSyntax SetOfIntegerSyntax} for an explanation of canonical + * array form. The category name returned by {@code getName()} gives the IPP + * attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class JobKOctetsSupported extends SetOfIntegerSyntax implements SupportedValuesAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -2867871140549897443L; /** @@ -55,13 +59,11 @@ public final class JobKOctetsSupported extends SetOfIntegerSyntax * range of integers. That is, only those values of JobKOctets in the one * range are supported. * - * @param lowerBound Lower bound of the range. - * @param upperBound Upper bound of the range. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if a null range is specified or if a - * non-null range is specified with {@code lowerBound} less than - * 0. + * @param lowerBound Lower bound of the range + * @param upperBound Upper bound of the range + * @throws IllegalArgumentException if a {@code null} range is specified or + * if a {@code non-null} range is specified with {@code lowerBound} + * less than zero */ public JobKOctetsSupported(int lowerBound, int upperBound) { super (lowerBound, upperBound); @@ -77,20 +79,16 @@ public final class JobKOctetsSupported extends SetOfIntegerSyntax * Returns whether this job K octets supported attribute is equivalent to * the passed in object. To be equivalent, all of the following conditions * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobKOctetsSupported. - *
  3. - * This job K octets supported attribute's members and - * {@code object}'s members are the same. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code JobKOctetsSupported}. + *
  3. This job K octets supported attribute's members and + * {@code object}'s members are the same. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job K - * octets supported attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job K octets + * supported attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && @@ -100,12 +98,12 @@ public final class JobKOctetsSupported extends SetOfIntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobKOctetsSupported, the category is class - * JobKOctetsSupported itself. + *

+ * For class {@code JobKOctetsSupported}, the category is class + * {@code JobKOctetsSupported} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobKOctetsSupported.class; @@ -114,14 +112,13 @@ public final class JobKOctetsSupported extends SetOfIntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobKOctetsSupported, the category name is + *

+ * For class {@code JobKOctetsSupported}, the category name is * {@code "job-k-octets-supported"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-k-octets-supported"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheets.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheets.java index ad574753c4e..ef43818780c 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheets.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,63 +22,62 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; import javax.print.attribute.IntegerSyntax; -import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class JobMediaSheets is an integer valued printing attribute class that - * specifies the total number of media sheets to be produced for this job. - *

- * The JobMediaSheets attribute describes the size of the job. This attribute is - * not intended to be a counter; it is intended to be useful routing and - * scheduling information if known. The printer may try to compute the - * JobMediaSheets attribute's value if it is not supplied in the Print Request. - * Even if the client does supply a value for the JobMediaSheets attribute in - * the Print Request, the printer may choose to change the value if the printer - * is able to compute a value which is more accurate than the client supplied - * value. The printer may be able to determine the correct value for the - * JobMediaSheets attribute either right at job submission time or at any later - * point in time. - *

- * Unlike the {@link JobKOctets JobKOctets} and {@link JobImpressions - * JobImpressions} attributes, the JobMediaSheets value must include the - * multiplicative factors contributed by the number of copies specified by the - * {@link Copies Copies} attribute and a "number of copies" instruction embedded - * in the document data, if any. This difference allows the system administrator - * to control the lower and upper bounds of both (1) the size of the document(s) - * with {@link JobKOctetsSupported JobKOctetsSupported} and {@link - * JobImpressionsSupported JobImpressionsSupported} and (2) the size of the job - * with {@link JobMediaSheetsSupported JobMediaSheetsSupported}. - *

- * IPP Compatibility: The integer value gives the IPP integer value. The - * category name returned by {@code getName()} gives the IPP attribute - * name. + * Class {@code JobMediaSheets} is an integer valued printing attribute class + * that specifies the total number of media sheets to be produced for this job. + *

+ * The {@code JobMediaSheets} attribute describes the size of the job. This + * attribute is not intended to be a counter; it is intended to be useful + * routing and scheduling information if known. The printer may try to compute + * the {@code JobMediaSheets} attribute's value if it is not supplied in the + * Print Request. Even if the client does supply a value for the + * {@code JobMediaSheets} attribute in the Print Request, the printer may choose + * to change the value if the printer is able to compute a value which is more + * accurate than the client supplied value. The printer may be able to determine + * the correct value for the {@code JobMediaSheets} attribute either right at + * job submission time or at any later point in time. + *

+ * Unlike the {@link JobKOctets JobKOctets} and + * {@link JobImpressions JobImpressions} attributes, the {@code JobMediaSheets} + * value must include the multiplicative factors contributed by the number of + * copies specified by the {@link Copies Copies} attribute and a "number of + * copies" instruction embedded in the document data, if any. This difference + * allows the system administrator to control the lower and upper bounds of both + * (1) the size of the document(s) with + * {@link JobKOctetsSupported JobKOctetsSupported} and + * {@link JobImpressionsSupported JobImpressionsSupported} and (2) the size of + * the job with {@link JobMediaSheetsSupported JobMediaSheetsSupported}. + *

+ * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * + * @author Alan Kaminsky * @see JobMediaSheetsSupported * @see JobMediaSheetsCompleted * @see JobKOctets * @see JobImpressions - * - * @author Alan Kaminsky */ public class JobMediaSheets extends IntegerSyntax implements PrintRequestAttribute, PrintJobAttribute { - + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 408871131531979741L; /** - * Construct a new job media sheets attribute with the given integer - * value. + * Construct a new job media sheets attribute with the given integer value. * - * @param value Integer value. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 0. + * @param value Integer value + * @throws IllegalArgumentException if {@code value} is negative */ public JobMediaSheets(int value) { super (value, 0, Integer.MAX_VALUE); @@ -88,20 +87,16 @@ public class JobMediaSheets extends IntegerSyntax * Returns whether this job media sheets attribute is equivalent to the * passed in object. To be equivalent, all of the following conditions must * be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobMediaSheets. - *
  3. - * This job media sheets attribute's value and {@code object}'s - * value are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code JobMediaSheets}. + *
  3. This job media sheets attribute's value and {@code object}'s value + * are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job media - * sheets attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job media + * sheets attribute, {@code false} otherwise */ public boolean equals(Object object) { return super.equals(object) && object instanceof JobMediaSheets; @@ -110,12 +105,12 @@ public class JobMediaSheets extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobMediaSheets and any vendor-defined subclasses, the category - * is class JobMediaSheets itself. + *

+ * For class {@code JobMediaSheets} and any vendor-defined subclasses, the + * category is class {@code JobMediaSheets} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobMediaSheets.class; @@ -124,14 +119,13 @@ public class JobMediaSheets extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobMediaSheets and any vendor-defined subclasses, the + *

+ * For class {@code JobMediaSheets} and any vendor-defined subclasses, the * category name is {@code "job-media-sheets"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-media-sheets"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsCompleted.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsCompleted.java index ed39a52e122..0f16f384a06 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsCompleted.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsCompleted.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,46 +30,46 @@ import javax.print.attribute.IntegerSyntax; import javax.print.attribute.PrintJobAttribute; /** - * Class JobMediaSheetsCompleted is an integer valued printing attribute class - * that specifies the number of media sheets which have completed marking and - * stacking for the entire job so far, whether those sheets have been processed - * on one side or on both. - *

- * The JobMediaSheetsCompleted attribute describes the progress of the job. This - * attribute is intended to be a counter. That is, the JobMediaSheetsCompleted - * value for a job that has not started processing must be 0. When the job's - * {@link JobState JobState} is PROCESSING or PROCESSING_STOPPED, the - * JobMediaSheetsCompleted value is intended to increase as the job is + * Class {@code JobMediaSheetsCompleted} is an integer valued printing attribute + * class that specifies the number of media sheets which have completed marking + * and stacking for the entire job so far, whether those sheets have been + * processed on one side or on both. + *

+ * The {@code JobMediaSheetsCompleted} attribute describes the progress of the + * job. This attribute is intended to be a counter. That is, the + * {@code JobMediaSheetsCompleted} value for a job that has not started + * processing must be 0. When the job's {@link JobState JobState} is + * {@code PROCESSING} or {@code PROCESSING_STOPPED}, the + * {@code JobMediaSheetsCompleted} value is intended to increase as the job is * processed; it indicates the amount of the job that has been processed at the * time the Print Job's attribute set is queried or at the time a print job - * event is reported. When the job enters the COMPLETED, CANCELED, or ABORTED - * states, the JobMediaSheetsCompleted value is the final value for the job. - *

- * IPP Compatibility: The integer value gives the IPP integer value. The - * category name returned by {@code getName()} gives the IPP attribute - * name. + * event is reported. When the job enters the {@code COMPLETED}, + * {@code CANCELED}, or {@code ABORTED} states, the + * {@code JobMediaSheetsCompleted} value is the final value for the job. + *

+ * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * + * @author Alan Kaminsky * @see JobMediaSheets * @see JobMediaSheetsSupported * @see JobKOctetsProcessed * @see JobImpressionsCompleted - * - * @author Alan Kaminsky */ public final class JobMediaSheetsCompleted extends IntegerSyntax implements PrintJobAttribute { - + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 1739595973810840475L; /** * Construct a new job media sheets completed attribute with the given * integer value. * - * @param value Integer value. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 0. + * @param value Integer value + * @throws IllegalArgumentException if {@code value} is negative */ public JobMediaSheetsCompleted(int value) { super (value, 0, Integer.MAX_VALUE); @@ -78,20 +79,17 @@ public final class JobMediaSheetsCompleted extends IntegerSyntax * Returns whether this job media sheets completed attribute is equivalent * to the passed in object. To be equivalent, all of the following * conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobMediaSheetsCompleted. - *
  3. - * This job media sheets completed attribute's value and - * {@code object}'s value are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class + * {@code JobMediaSheetsCompleted}. + *
  3. This job media sheets completed attribute's value and + * {@code object}'s value are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job media - * sheets completed attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job media + * sheets completed attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && @@ -101,12 +99,12 @@ public final class JobMediaSheetsCompleted extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobMediaSheetsCompleted, the category is class - * JobMediaSheetsCompleted itself. + *

+ * For class {@code JobMediaSheetsCompleted}, the category is class + * {@code JobMediaSheetsCompleted} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobMediaSheetsCompleted.class; @@ -115,11 +113,11 @@ public final class JobMediaSheetsCompleted extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobMediaSheetsCompleted, the category name is + *

+ * For class {@code JobMediaSheetsCompleted}, the category name is * {@code "job-media-sheets-completed"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-media-sheets-completed"; diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsSupported.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsSupported.java index 19d3a6a2084..6a12b7a81f6 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsSupported.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMediaSheetsSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,39 +30,40 @@ import javax.print.attribute.SetOfIntegerSyntax; import javax.print.attribute.SupportedValuesAttribute; /** - * Class JobMediaSheetsSupported is a printing attribute class, a set of - * integers, that gives the supported values for a {@link JobMediaSheets - * JobMediaSheets} attribute. It is restricted to a single contiguous range of - * integers; multiple non-overlapping ranges are not allowed. This gives the - * lower and upper bounds of the total sizes of print jobs in number of media - * sheets that the printer will accept. - *

- * IPP Compatibility: The JobMediaSheetsSupported attribute's canonical - * array form gives the lower and upper bound for the range of values to be - * included in an IPP "job-media-sheets-supported" attribute. See class {@link - * javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an - * explanation of canonical array form. The category name returned by - * {@code getName()} gives the IPP attribute name. + * Class {@code JobMediaSheetsSupported} is a printing attribute class, a set of + * integers, that gives the supported values for a + * {@link JobMediaSheets JobMediaSheets} attribute. It is restricted to a single + * contiguous range of integers; multiple non-overlapping ranges are not + * allowed. This gives the lower and upper bounds of the total sizes of print + * jobs in number of media sheets that the printer will accept. + *

+ * IPP Compatibility: The {@code JobMediaSheetsSupported} attribute's + * canonical array form gives the lower and upper bound for the range of values + * to be included in an IPP "job-media-sheets-supported" attribute. See class + * {@link SetOfIntegerSyntax SetOfIntegerSyntax} for an explanation of canonical + * array form. The category name returned by {@code getName()} gives the IPP + * attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class JobMediaSheetsSupported extends SetOfIntegerSyntax implements SupportedValuesAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 2953685470388672940L; /** * Construct a new job media sheets supported attribute containing a single - * range of integers. That is, only those values of JobMediaSheets in the - * one range are supported. + * range of integers. That is, only those values of {@code JobMediaSheets} + * in the one range are supported. * - * @param lowerBound Lower bound of the range. - * @param upperBound Upper bound of the range. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if a null range is specified or if a - * non-null range is specified with {@code lowerBound} less than - * 0. + * @param lowerBound lower bound of the range + * @param upperBound upper bound of the range + * @throws IllegalArgumentException if a {@code null} range is specified or + * if a {@code non-null} range is specified with {@code lowerBound} + * less than zero */ public JobMediaSheetsSupported(int lowerBound, int upperBound) { super (lowerBound, upperBound); @@ -77,20 +79,17 @@ public final class JobMediaSheetsSupported extends SetOfIntegerSyntax * Returns whether this job media sheets supported attribute is equivalent * to the passed in object. To be equivalent, all of the following * conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobMediaSheetsSupported. - *
  3. - * This job media sheets supported attribute's members and - * {@code object}'s members are the same. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class + * {@code JobMediaSheetsSupported}. + *
  3. This job media sheets supported attribute's members and + * {@code object}'s members are the same. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job media - * sheets supported attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job media + * sheets supported attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && @@ -100,12 +99,12 @@ public final class JobMediaSheetsSupported extends SetOfIntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobMediaSheetsSupported, the - * category is class JobMediaSheetsSupported itself. + *

+ * For class {@code JobMediaSheetsSupported}, the category is class + * {@code JobMediaSheetsSupported} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobMediaSheetsSupported.class; @@ -114,14 +113,13 @@ public final class JobMediaSheetsSupported extends SetOfIntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobMediaSheetsSupported, the - * category name is {@code "job-media-sheets-supported"}. + *

+ * For class {@code JobMediaSheetsSupported}, the category name is + * {@code "job-media-sheets-supported"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-media-sheets-supported"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMessageFromOperator.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMessageFromOperator.java index f52de7d303a..5742c04270b 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMessageFromOperator.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobMessageFromOperator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,50 +22,53 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.Locale; import javax.print.attribute.Attribute; -import javax.print.attribute.TextSyntax; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.TextSyntax; /** - * Class JobMessageFromOperator is a printing attribute class, a text attribute, - * that provides a message from an operator, system administrator, or + * Class {@code JobMessageFromOperator} is a printing attribute class, a text + * attribute, that provides a message from an operator, system administrator, or * "intelligent" process to indicate to the end user the reasons for * modification or other management action taken on a job. - *

+ *

* A Print Job's attribute set includes zero instances or one instance of a - * JobMessageFromOperator attribute, not more than one instance. A new - * JobMessageFromOperator attribute replaces an existing JobMessageFromOperator - * attribute, if any. In other words, JobMessageFromOperator is not intended to - * be a history log. If it wishes, the client can detect changes to a Print - * Job's JobMessageFromOperator attribute and maintain the client's own history - * log of the JobMessageFromOperator attribute values. - *

- * IPP Compatibility: The string value gives the IPP name value. The + * {@code JobMessageFromOperator} attribute, not more than one instance. A new + * {@code JobMessageFromOperator} attribute replaces an existing + * {@code JobMessageFromOperator} attribute, if any. In other words, + * {@code JobMessageFromOperator} is not intended to be a history log. If it + * wishes, the client can detect changes to a Print Job's + * {@code JobMessageFromOperator} attribute and maintain the client's own + * history log of the {@code JobMessageFromOperator} attribute values. + *

+ * IPP Compatibility: The string value gives the IPP name value. The * locale gives the IPP natural language. The category name returned by * {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class JobMessageFromOperator extends TextSyntax implements PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -4620751846003142047L; /** * Constructs a new job message from operator attribute with the given * message and locale. * - * @param message Message. - * @param locale Natural language of the text string. null - * is interpreted to mean the default locale as returned - * by {@code Locale.getDefault()} - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code message} is null. + * @param message the message + * @param locale Natural language of the text string. {@code null} is + * interpreted to mean the default locale as returned by + * {@code Locale.getDefault()} + * @throws NullPointerException if {@code message} is {@code null} */ public JobMessageFromOperator(String message, Locale locale) { super (message, locale); @@ -75,23 +78,19 @@ public final class JobMessageFromOperator extends TextSyntax * Returns whether this job message from operator attribute is equivalent to * the passed in object. To be equivalent, all of the following conditions * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobMessageFromOperator. - *
  3. - * This job message from operator attribute's underlying string and - * {@code object}'s underlying string are equal. - *
  4. - * This job message from operator attribute's locale and - * {@code object}'s locale are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class + * {@code JobMessageFromOperator}. + *
  3. This job message from operator attribute's underlying string and + * {@code object}'s underlying string are equal. + *
  4. This job message from operator attribute's locale and + * {@code object}'s locale are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job - * message from operator attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job message + * from operator attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && @@ -101,12 +100,12 @@ public final class JobMessageFromOperator extends TextSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobMessageFromOperator, the - * category is class JobMessageFromOperator itself. + *

+ * For class {@code JobMessageFromOperator}, the category is class + * {@code JobMessageFromOperator} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobMessageFromOperator.class; @@ -115,14 +114,13 @@ public final class JobMessageFromOperator extends TextSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobMessageFromOperator, the - * category name is {@code "job-message-from-operator"}. + *

+ * For class {@code JobMessageFromOperator}, the category name is + * {@code "job-message-from-operator"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-message-from-operator"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobName.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobName.java index 7be25f02c91..ff70d4d437c 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobName.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,50 +22,53 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.Locale; import javax.print.attribute.Attribute; -import javax.print.attribute.TextSyntax; -import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.TextSyntax; /** - * Class JobName is a printing attribute class, a text attribute, that specifies - * the name of a print job. A job's name is an arbitrary string defined by the - * client. It does not need to be unique between different jobs. A Print Job's - * JobName attribute is set to the value supplied by the client in the Print - * Request's attribute set. If, however, the client does not supply a JobName - * attribute in the Print Request, the printer, when it creates the Print Job, - * must generate a JobName. The printer should generate the value of the Print - * Job's JobName attribute from the first of the following sources that produces - * a value: (1) the {@link DocumentName DocumentName} attribute of the first (or - * only) doc in the job, (2) the URL of the first (or only) doc in the job, if - * the doc's print data representation object is a URL, or (3) any other piece - * of Print Job specific and/or document content information. - *

- * IPP Compatibility: The string value gives the IPP name value. The + * Class {@code JobName} is a printing attribute class, a text attribute, that + * specifies the name of a print job. A job's name is an arbitrary string + * defined by the client. It does not need to be unique between different jobs. + * A Print Job's {@code JobName} attribute is set to the value supplied by the + * client in the Print Request's attribute set. If, however, the client does not + * supply a {@code JobName} attribute in the Print Request, the printer, when it + * creates the Print Job, must generate a {@code JobName}. The printer should + * generate the value of the Print Job's {@code JobName} attribute from the + * first of the following sources that produces a value: (1) the + * {@link DocumentName DocumentName} attribute of the first (or only) doc in the + * job, (2) the {@code URL} of the first (or only) doc in the job, if the doc's + * print data representation object is a {@code URL}, or (3) any other piece of + * Print Job specific and/or document content information. + *

+ * IPP Compatibility: The string value gives the IPP name value. The * locale gives the IPP natural language. The category name returned by * {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class JobName extends TextSyntax implements PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 4660359192078689545L; /** * Constructs a new job name attribute with the given job name and locale. * - * @param jobName Job name. - * @param locale Natural language of the text string. null - * is interpreted to mean the default locale as returned - * by {@code Locale.getDefault()} - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code jobName} is null. + * @param jobName job name + * @param locale natural language of the text string. {@code null} is + * interpreted to mean the default locale as returned by + * {@code Locale.getDefault()} + * @throws NullPointerException if {@code jobName} is {@code null} */ public JobName(String jobName, Locale locale) { super (jobName, locale); @@ -74,23 +77,18 @@ public final class JobName extends TextSyntax /** * Returns whether this job name attribute is equivalent to the passed in * object. To be equivalent, all of the following conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobName. - *
  3. - * This job name attribute's underlying string and {@code object}'s - * underlying string are equal. - *
  4. - * This job name attribute's locale and {@code object}'s locale are - * equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code JobName}. + *
  3. This job name attribute's underlying string and {@code object}'s + * underlying string are equal. + *
  4. This job name attribute's locale and {@code object}'s locale are + * equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job name - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job name + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && object instanceof JobName); @@ -99,11 +97,11 @@ public final class JobName extends TextSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobName, the category is class JobName itself. + *

+ * For class {@code JobName}, the category is class {@code JobName} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobName.class; @@ -112,13 +110,12 @@ public final class JobName extends TextSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobName, the category name is {@code "job-name"}. + *

+ * For class {@code JobName}, the category name is {@code "job-name"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-name"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobOriginatingUserName.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobOriginatingUserName.java index 62a3e20b235..11770ed5e09 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobOriginatingUserName.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobOriginatingUserName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,50 +22,50 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.Locale; import javax.print.attribute.Attribute; -import javax.print.attribute.TextSyntax; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.TextSyntax; /** - * Class JobOriginatingUserName is a printing attribute class, a text - * attribute, that contains the name of the end user that submitted the - * print job. If possible, the printer sets this attribute to the most - * authenticated printable user name that it can obtain from the - * authentication service that authenticated the submitted Print Request. - * If such is not available, the printer uses the value of the - * {@link RequestingUserName RequestingUserName} - * attribute supplied by the client in the Print Request's attribute set. - * If no authentication service is available, and the client did not supply - * a {@link RequestingUserName RequestingUserName} attribute, - * the printer sets the JobOriginatingUserName attribute to an empty - * (zero-length) string. - *

- * IPP Compatibility: The string value gives the IPP name value. The + * Class {@code JobOriginatingUserName} is a printing attribute class, a text + * attribute, that contains the name of the end user that submitted the print + * job. If possible, the printer sets this attribute to the most authenticated + * printable user name that it can obtain from the authentication service that + * authenticated the submitted Print Request. If such is not available, the + * printer uses the value of the {@link RequestingUserName RequestingUserName} + * attribute supplied by the client in the Print Request's attribute set. If no + * authentication service is available, and the client did not supply a + * {@link RequestingUserName RequestingUserName} attribute, the printer sets the + * JobOriginatingUserName attribute to an empty (zero-length) string. + *

+ * IPP Compatibility: The string value gives the IPP name value. The * locale gives the IPP natural language. The category name returned by * {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class JobOriginatingUserName extends TextSyntax implements PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -8052537926362933477L; /** - * Constructs a new job originating user name attribute with the given - * user name and locale. + * Constructs a new job originating user name attribute with the given user + * name and locale. * - * @param userName User name. - * @param locale Natural language of the text string. null - * is interpreted to mean the default locale as returned - * by {@code Locale.getDefault()} - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code userName} is null. + * @param userName user name + * @param locale natural language of the text string. {@code null} is + * interpreted to mean the default locale as returned by + * {@code Locale.getDefault()} + * @throws NullPointerException if {@code userName} is {@code null} */ public JobOriginatingUserName(String userName, Locale locale) { super (userName, locale); @@ -75,23 +75,19 @@ public final class JobOriginatingUserName extends TextSyntax * Returns whether this job originating user name attribute is equivalent to * the passed in object. To be equivalent, all of the following conditions * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobOriginatingUserName. - *
  3. - * This job originating user name attribute's underlying string and - * {@code object}'s underlying string are equal. - *
  4. - * This job originating user name attribute's locale and - * {@code object}'s locale are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class + * {@code JobOriginatingUserName}. + *
  3. This job originating user name attribute's underlying string and + * {@code object}'s underlying string are equal. + *
  4. This job originating user name attribute's locale and + * {@code object}'s locale are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job - * originating user name attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job + * originating user name attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && @@ -101,12 +97,12 @@ public final class JobOriginatingUserName extends TextSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobOriginatingUserName, the - * category is class JobOriginatingUserName itself. + *

+ * For class {@code JobOriginatingUserName}, the category is class + * {@code JobOriginatingUserName} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobOriginatingUserName.class; @@ -115,14 +111,13 @@ public final class JobOriginatingUserName extends TextSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobOriginatingUserName, the - * category name is {@code "job-originating-user-name"}. + *

+ * For class {@code JobOriginatingUserName}, the category name is + * {@code "job-originating-user-name"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-originating-user-name"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobPriority.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobPriority.java index 7a03e304f1b..938856b9b52 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobPriority.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobPriority.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,54 +22,55 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; import javax.print.attribute.IntegerSyntax; -import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class JobPriority is an integer valued printing attribute class that + * Class {@code JobPriority} is an integer valued printing attribute class that * specifies a print job's priority. - *

- * If a JobPriority attribute is specified for a Print Job, it specifies a - * priority for scheduling the job. A higher value specifies a higher priority. - * The value 1 indicates the lowest possible priority. The value 100 indicates - * the highest possible priority. Among those jobs that are ready to print, a - * printer must print all jobs with a priority value of n before printing - * those with a priority value of n-1 for all n. - *

- * If the client does not specify a JobPriority attribute for a Print Job and - * the printer does support the JobPriority attribute, the printer must use an - * implementation-defined default JobPriority value. - *

+ *

+ * If a {@code JobPriority} attribute is specified for a Print Job, it specifies + * a priority for scheduling the job. A higher value specifies a higher + * priority. The value 1 indicates the lowest possible priority. The value 100 + * indicates the highest possible priority. Among those jobs that are ready to + * print, a printer must print all jobs with a priority value of n before + * printing those with a priority value of n-1 for all n. + *

+ * If the client does not specify a {@code JobPriority} attribute for a Print + * Job and the printer does support the JobPriority attribute, the printer must + * use an implementation-defined default JobPriority value. + *

* The client can always specify any job priority value from 1 to 100 for a job. - * However, a Print Service instance may support fewer than 100 different - * job priority levels. If this is the case, the Print Service instance + * However, a Print Service instance may support fewer than 100 different job + * priority levels. If this is the case, the Print Service instance * automatically maps the client-specified job priority value to one of the * supported job priority levels, dividing the 100 job priority values equally * among the available job priority levels. - *

- * IPP Compatibility: The integer value gives the IPP integer value. The - * category name returned by {@code getName()} gives the IPP attribute - * name. + *

+ * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class JobPriority extends IntegerSyntax implements PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -4599900369040602769L; /** * Construct a new job priority attribute with the given integer value. * - * @param value Integer value. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 1 - * or greater than 100. + * @param value Integer value + * @throws IllegalArgumentException if {@code value} is less than 1 or + * greater than 100 */ public JobPriority(int value) { super (value, 1, 100); @@ -79,20 +80,16 @@ public final class JobPriority extends IntegerSyntax * Returns whether this job priority attribute is equivalent to the passed * in object. To be equivalent, all of the following conditions must be * true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobPriority. - *
  3. - * This job priority attribute's value and {@code object}'s value - * are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code JobPriority}. + *
  3. This job priority attribute's value and {@code object}'s value are + * equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job - * priority attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job priority + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && object instanceof JobPriority); @@ -101,11 +98,12 @@ public final class JobPriority extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobPriority, the category is class JobPriority itself. + *

+ * For class {@code JobPriority}, the category is class + * {@code JobPriority} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobPriority.class; @@ -114,13 +112,13 @@ public final class JobPriority extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobPriority, the category name is {@code "job-priority"}. + *

+ * For class {@code JobPriority}, the category name is + * {@code "job-priority"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-priority"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobPrioritySupported.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobPrioritySupported.java index 3d7cf55095a..5d97d56d3d2 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobPrioritySupported.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobPrioritySupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,39 +30,38 @@ import javax.print.attribute.IntegerSyntax; import javax.print.attribute.SupportedValuesAttribute; /** - * Class JobPrioritySupported is an integer valued printing attribute class - * that specifies whether a Print Service instance supports the {@link - * JobPriority JobPriority} attribute and the number of different job priority - * levels supported. - *

- * The client can always specify any {@link JobPriority JobPriority} value - * from 1 to 100 for a job. However, the Print Service instance may support - * fewer than 100 different job priority levels. If this is the case, the - * Print Service instance automatically maps the client-specified job priority - * value to one of the supported job priority levels, dividing the 100 job - * priority values equally among the available job priority levels. - *

- * IPP Compatibility: The integer value gives the IPP integer value. - * The category name returned by {@code getName()} gives the IPP - * attribute name. + * Class {@code JobPrioritySupported} is an integer valued printing attribute + * class that specifies whether a Print Service instance supports the + * {@link JobPriority JobPriority} attribute and the number of different job + * priority levels supported. + *

+ * The client can always specify any {@link JobPriority JobPriority} value from + * 1 to 100 for a job. However, the Print Service instance may support fewer + * than 100 different job priority levels. If this is the case, the Print + * Service instance automatically maps the client-specified job priority value + * to one of the supported job priority levels, dividing the 100 job priority + * values equally among the available job priority levels. + *

+ * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class JobPrioritySupported extends IntegerSyntax implements SupportedValuesAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 2564840378013555894L; - /** * Construct a new job priority supported attribute with the given integer * value. * - * @param value Number of different job priority levels supported. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 1 - * or greater than 100. + * @param value number of different job priority levels supported + * @throws IllegalArgumentException if {@code value} is less than 1 or + * greater than 100 */ public JobPrioritySupported(int value) { super (value, 1, 100); @@ -71,20 +71,17 @@ public final class JobPrioritySupported extends IntegerSyntax * Returns whether this job priority supported attribute is equivalent to * the passed in object. To be equivalent, all of the following conditions * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class JobPrioritySupported. - *
  3. - * This job priority supported attribute's value and - * {@code object}'s value are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class + * {@code JobPrioritySupported}. + *
  3. This job priority supported attribute's value and {@code object}'s + * value are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this job - * priority supported attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this job priority + * supported attribute, {@code false} otherwise */ public boolean equals (Object object) { @@ -92,16 +89,15 @@ public final class JobPrioritySupported extends IntegerSyntax object instanceof JobPrioritySupported); } - /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobPrioritySupported, the - * category is class JobPrioritySupported itself. + *

+ * For class {@code JobPrioritySupported}, the category is class + * {@code JobPrioritySupported} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobPrioritySupported.class; @@ -110,14 +106,13 @@ public final class JobPrioritySupported extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobPrioritySupported, the - * category name is {@code "job-priority-supported"}. + *

+ * For class {@code JobPrioritySupported}, the category name is + * {@code "job-priority-supported"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-priority-supported"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobSheets.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobSheets.java index 69579ce6c60..2eeef66083c 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobSheets.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobSheets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,39 +22,40 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package javax.print.attribute.standard; -import java.util.Locale; +package javax.print.attribute.standard; import javax.print.attribute.Attribute; import javax.print.attribute.EnumSyntax; -import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class JobSheets is a printing attribute class, an enumeration, that + * Class {@code JobSheets} is a printing attribute class, an enumeration, that * determines which job start and end sheets, if any, must be printed with a - * job. Class JobSheets declares keywords for standard job sheets values. - * Implementation- or site-defined names for a job sheets attribute may also be - * created by defining a subclass of class JobSheets. - *

- * The effect of a JobSheets attribute on multidoc print jobs (jobs with - * multiple documents) may be affected by the {@link MultipleDocumentHandling - * MultipleDocumentHandling} job attribute, depending on the meaning of the - * particular JobSheets value. - *

- * IPP Compatibility: The category name returned by - * {@code getName()} is the IPP attribute name. The - * enumeration's integer value is the IPP enum value. The - * {@code toString()} method returns the IPP string representation of - * the attribute value. For a subclass, the attribute value must be - * localized to give the IPP name and natural language values. + * job. Class {@code JobSheets} declares keywords for standard job sheets + * values. Implementation- or site-defined names for a job sheets attribute may + * also be created by defining a subclass of class {@code JobSheets}. + *

+ * The effect of a {@code JobSheets} attribute on multidoc print jobs (jobs with + * multiple documents) may be affected by the + * {@link MultipleDocumentHandling MultipleDocumentHandling} job attribute, + * depending on the meaning of the particular {@code JobSheets} value. + *

+ * IPP Compatibility: The category name returned by {@code getName()} is + * the IPP attribute name. The enumeration's integer value is the IPP enum + * value. The {@code toString()} method returns the IPP string representation of + * the attribute value. For a subclass, the attribute value must be localized to + * give the IPP name and natural language values. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public class JobSheets extends EnumSyntax implements PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -4735258056132519759L; /** @@ -63,9 +64,8 @@ public class JobSheets extends EnumSyntax public static final JobSheets NONE = new JobSheets(0); /** - * One or more site specific standard job sheets are printed. e.g. a - * single start sheet is printed, or both start and end sheets are - * printed. + * One or more site specific standard job sheets are printed. e.g. a single + * start sheet is printed, or both start and end sheets are printed. */ public static final JobSheets STANDARD = new JobSheets(1); @@ -73,31 +73,37 @@ public class JobSheets extends EnumSyntax * Construct a new job sheets enumeration value with the given integer * value. * - * @param value Integer value. + * @param value Integer value */ protected JobSheets(int value) { super (value); } + /** + * The string table for class {@code JobSheets}. + */ private static final String[] myStringTable = { "none", "standard" }; + /** + * The enumeration value table for class {@code JobSheets}. + */ private static final JobSheets[] myEnumValueTable = { NONE, STANDARD }; /** - * Returns the string table for class JobSheets. + * Returns the string table for class {@code JobSheets}. */ protected String[] getStringTable() { return myStringTable.clone(); } /** - * Returns the enumeration value table for class JobSheets. + * Returns the enumeration value table for class {@code JobSheets}. */ protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); @@ -106,12 +112,12 @@ public class JobSheets extends EnumSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobSheets and any vendor-defined subclasses, the category is - * class JobSheets itself. + *

+ * For class {@code JobSheets} and any vendor-defined subclasses, the + * category is class {@code JobSheets} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobSheets.class; @@ -120,14 +126,13 @@ public class JobSheets extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobSheets and any vendor-defined subclasses, the category - * name is {@code "job-sheets"}. + *

+ * For class {@code JobSheets} and any vendor-defined subclasses, the + * category name is {@code "job-sheets"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-sheets"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobState.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobState.java index e87de1aab70..3bf8064ae7f 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobState.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -30,24 +30,27 @@ import javax.print.attribute.EnumSyntax; import javax.print.attribute.PrintJobAttribute; /** - * JobState is a printing attribute class, an enumeration, that identifies - * the current state of a print job. Class JobState defines standard job state - * values. A Print Service implementation only needs to report those job - * states which are appropriate for the particular implementation; it does not - * have to report every defined job state. The {@link JobStateReasons - * JobStateReasons} attribute augments the JobState attribute to give more - * detailed information about the job in the given job state. - *

- * IPP Compatibility: The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. + * {@code JobState} is a printing attribute class, an enumeration, that + * identifies the current state of a print job. Class {@code JobState} defines + * standard job state values. A Print Service implementation only needs to + * report those job states which are appropriate for the particular + * implementation; it does not have to report every defined job state. The + * {@link JobStateReasons JobStateReasons} attribute augments the + * {@code JobState} attribute to give more detailed information about the job in + * the given job state. + *

+ * IPP Compatibility: The category name returned by {@code getName()} is + * the IPP attribute name. The enumeration's integer value is the IPP enum + * value. The {@code toString()} method returns the IPP string representation of + * the attribute value. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ - public class JobState extends EnumSyntax implements PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 400465010094018920L; /** @@ -62,61 +65,57 @@ public class JobState extends EnumSyntax implements PrintJobAttribute { /** * The job is not a candidate for processing for any number of reasons but - * will return to the PENDING state as soon as the reasons are no longer - * present. The job's {@link JobStateReasons JobStateReasons} attribute must - * indicate why the job is no longer a candidate for processing. + * will return to the {@code PENDING} state as soon as the reasons are no + * longer present. The job's {@link JobStateReasons JobStateReasons} + * attribute must indicate why the job is no longer a candidate for + * processing. */ public static final JobState PENDING_HELD = new JobState(4); /** * The job is processing. One or more of the following activities is * occurring: - *

    - *
  1. - * The job is using, or is attempting to use, one or more purely software - * processes that are analyzing, creating, or interpreting a PDL, etc. - * - *
  2. - * The job is using, or is attempting to use, one or more hardware - * devices that are interpreting a PDL, making marks on a medium, and/or - * performing finishing, such as stapling, etc. - * - *
  3. - * The printer has made the job ready for printing, but the output - * device is not yet printing it, either because the job hasn't reached the - * output device or because the job is queued in the output device or some - * other spooler, awaiting the output device to print it. - *
- *

- * When the job is in the PROCESSING state, the entire job state includes - * the detailed status represented in the printer's {@link PrinterState - * PrinterState} and {@link PrinterStateReasons PrinterStateReasons} - * attributes. - *

+ *

    + *
  1. The job is using, or is attempting to use, one or more purely + * software processes that are analyzing, creating, or interpreting a PDL, + * etc. + *
  2. The job is using, or is attempting to use, one or more hardware + * devices that are interpreting a PDL, making marks on a medium, and/or + * performing finishing, such as stapling, etc. + *
  3. The printer has made the job ready for printing, but the output + * device is not yet printing it, either because the job hasn't reached + * the output device or because the job is queued in the output device or + * some other spooler, awaiting the output device to print it. + *
+ * When the job is in the {@code PROCESSING} state, the entire job state + * includes the detailed status represented in the printer's + * {@link PrinterState PrinterState} and + * {@link PrinterStateReasons PrinterStateReasons} attributes. + *

* Implementations may, though they need not, include additional values in * the job's {@link JobStateReasons JobStateReasons} attribute to indicate - * the progress of the job, such as adding the JOB_PRINTING value to + * the progress of the job, such as adding the {@code JOB_PRINTING} value to * indicate when the output device is actually making marks on paper and/or - * the PROCESSING_TO_STOP_POINT value to indicate that the printer is in the - * process of canceling or aborting the job. + * the {@code PROCESSING_TO_STOP_POINT} value to indicate that the printer + * is in the process of canceling or aborting the job. */ public static final JobState PROCESSING = new JobState (5); /** * The job has stopped while processing for any number of reasons and will - * return to the PROCESSING state as soon as the reasons are no longer - * present. - *

+ * return to the {@code PROCESSING} state as soon as the reasons are no + * longer present. + *

* The job's {@link JobStateReasons JobStateReasons} attribute may indicate * why the job has stopped processing. For example, if the output device is - * stopped, the PRINTER_STOPPED value may be included in the job's {@link - * JobStateReasons JobStateReasons} attribute. - *

- * Note: When an output device is stopped, the device usually + * stopped, the {@code PRINTER_STOPPED} value may be included in the job's + * {@link JobStateReasons JobStateReasons} attribute. + *

+ * Note: When an output device is stopped, the device usually * indicates its condition in human readable form locally at the device. A * client can obtain more complete device status remotely by querying the - * printer's {@link PrinterState PrinterState} and {@link - * PrinterStateReasons PrinterStateReasons} attributes. + * printer's {@link PrinterState PrinterState} and + * {@link PrinterStateReasons PrinterStateReasons} attributes. */ public static final JobState PROCESSING_STOPPED = new JobState (6); @@ -125,24 +124,27 @@ public class JobState extends EnumSyntax implements PrintJobAttribute { * canceling the job, and all job status attributes have reached their final * values for the job. While the printer is canceling the job, the job * remains in its current state, but the job's {@link JobStateReasons - * JobStateReasons} attribute should contain the PROCESSING_TO_STOP_POINT - * value and one of the CANCELED_BY_USER, CANCELED_BY_OPERATOR, or - * CANCELED_AT_DEVICE values. When the job moves to the CANCELED state, the - * PROCESSING_TO_STOP_POINT value, if present, must be removed, but the - * CANCELED_BY_xxx value, if present, must remain. + * JobStateReasons} attribute should contain the + * {@code PROCESSING_TO_STOP_POINT} value and one of the + * {@code CANCELED_BY_USER}, {@code CANCELED_BY_OPERATOR}, or + * {@code CANCELED_AT_DEVICE} values. When the job moves to the + * {@code CANCELED} state, the {@code PROCESSING_TO_STOP_POINT} value, if + * present, must be removed, but the CANCELED_BY_xxx value, if + * present, must remain. */ public static final JobState CANCELED = new JobState (7); /** * The job has been aborted by the system (usually while the job was in the - * PROCESSING or PROCESSING_STOPPED state), the printer has completed - * aborting the job, and all job status attributes have reached their final - * values for the job. While the printer is aborting the job, the job - * remains in its current state, but the job's {@link JobStateReasons - * JobStateReasons} attribute should contain the PROCESSING_TO_STOP_POINT - * and ABORTED_BY_SYSTEM values. When the job moves to the ABORTED state, - * the PROCESSING_TO_STOP_POINT value, if present, must be removed, but the - * ABORTED_BY_SYSTEM value, if present, must remain. + * {@code PROCESSING} or {@code PROCESSING_STOPPED} state), the printer has + * completed aborting the job, and all job status attributes have reached + * their final values for the job. While the printer is aborting the job, + * the job remains in its current state, but the job's + * {@link JobStateReasons JobStateReasons} attribute should contain the + * {@code PROCESSING_TO_STOP_POINT} and {@code ABORTED_BY_SYSTEM} values. + * When the job moves to the {@code ABORTED} state, the + * {@code PROCESSING_TO_STOP_POINT} value, if present, must be removed, but + * the {@code ABORTED_BY_SYSTEM} value, if present, must remain. */ public static final JobState ABORTED = new JobState (8); @@ -150,10 +152,10 @@ public class JobState extends EnumSyntax implements PrintJobAttribute { * The job has completed successfully or with warnings or errors after * processing, all of the job media sheets have been successfully stacked in * the appropriate output bin(s), and all job status attributes have reached - * their final values for the job. The job's {@link JobStateReasons - * JobStateReasons} attribute should contain one of these values: - * COMPLETED_SUCCESSFULLY, COMPLETED_WITH_WARNINGS, or - * COMPLETED_WITH_ERRORS. + * their final values for the job. The job's + * {@link JobStateReasons JobStateReasons} attribute should contain one of + * these values: {@code COMPLETED_SUCCESSFULLY}, + * {@code COMPLETED_WITH_WARNINGS}, or {@code COMPLETED_WITH_ERRORS}. */ public static final JobState COMPLETED = new JobState (9); @@ -162,12 +164,15 @@ public class JobState extends EnumSyntax implements PrintJobAttribute { /** * Construct a new job state enumeration value with the given integer value. * - * @param value Integer value. + * @param value Integer value */ protected JobState(int value) { super (value); } + /** + * The string table for class {@code JobState}. + */ private static final String[] myStringTable = {"unknown", null, @@ -180,6 +185,9 @@ public class JobState extends EnumSyntax implements PrintJobAttribute { "aborted", "completed"}; + /** + * The enumeration value table for class {@code JobState}. + */ private static final JobState[] myEnumValueTable = {UNKNOWN, null, @@ -193,14 +201,14 @@ public class JobState extends EnumSyntax implements PrintJobAttribute { COMPLETED}; /** - * Returns the string table for class JobState. + * Returns the string table for class {@code JobState}. */ protected String[] getStringTable() { return myStringTable; } /** - * Returns the enumeration value table for class JobState. + * Returns the enumeration value table for class {@code JobState}. */ protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; @@ -209,12 +217,12 @@ public class JobState extends EnumSyntax implements PrintJobAttribute { /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobState and any vendor-defined subclasses, the category is - * class JobState itself. + *

+ * For class {@code JobState} and any vendor-defined subclasses, the + * category is class {@code JobState} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobState.class; @@ -223,14 +231,13 @@ public class JobState extends EnumSyntax implements PrintJobAttribute { /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobState and any vendor-defined subclasses, the category - * name is {@code "job-state"}. + *

+ * For class {@code JobState} and any vendor-defined subclasses, the + * category name is {@code "job-state"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-state"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReason.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReason.java index 553236efaeb..08e1391bfa2 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReason.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReason.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,40 +22,45 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; -import javax.print.attribute.EnumSyntax; import javax.print.attribute.Attribute; +import javax.print.attribute.EnumSyntax; /** - * Class JobStateReason is a printing attribute class, an enumeration, that - * provides additional information about the job's current state, i.e., + * Class {@code JobStateReason} is a printing attribute class, an enumeration, + * that provides additional information about the job's current state, i.e., * information that augments the value of the job's {@link JobState JobState} - * attribute. Class JobStateReason defines standard job state reason values. A - * Print Service implementation only needs to report those job state + * attribute. Class {@code JobStateReason} defines standard job state reason + * values. A Print Service implementation only needs to report those job state * reasons which are appropriate for the particular implementation; it does not * have to report every defined job state reason. - *

- * Instances of JobStateReason do not appear in a Print Job's attribute set - * directly. Rather, a {@link JobStateReasons JobStateReasons} attribute appears - * in the Print Job's attribute set. The {@link JobStateReasons JobStateReasons} - * attribute contains zero, one, or more than one JobStateReason objects which - * pertain to the Print Job's status. The printer adds a JobStateReason object - * to the Print Job's {@link JobStateReasons JobStateReasons} attribute when the - * corresponding condition becomes true of the Print Job, and the printer - * removes the JobStateReason object again when the corresponding condition - * becomes false, regardless of whether the Print Job's overall {@link JobState - * JobState} also changed. - *

- * IPP Compatibility: The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. + *

+ * Instances of {@code JobStateReason} do not appear in a Print Job's attribute + * set directly. Rather, a {@link JobStateReasons JobStateReasons} attribute + * appears in the Print Job's attribute set. The + * {@link JobStateReasons JobStateReasons} attribute contains zero, one, or more + * than one {@code JobStateReason} objects which pertain to the Print Job's + * status. The printer adds a JobStateReason object to the Print Job's + * {@link JobStateReasons JobStateReasons} attribute when the corresponding + * condition becomes true of the Print Job, and the printer removes the + * {@code JobStateReason} object again when the corresponding condition becomes + * false, regardless of whether the Print Job's overall + * {@link JobState JobState} also changed. + *

+ * IPP Compatibility: The category name returned by {@code getName()} is + * the IPP attribute name. The enumeration's integer value is the IPP enum + * value. The {@code toString()} method returns the IPP string representation of + * the attribute value. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public class JobStateReason extends EnumSyntax implements Attribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -8765894420449009168L; /** @@ -67,27 +72,29 @@ public class JobStateReason extends EnumSyntax implements Attribute { /** * The printer has created the Print Job, but the printer is expecting - * additional print data before it can move the job into the PROCESSING - * state. If a printer starts processing before it has received all data, - * the printer removes the JOB_DATA_INSUFFICIENT reason, but the - * JOB_INCOMING reason remains. If a printer starts processing after it - * has received all data, the printer removes the JOB_DATA_INSUFFICIENT - * and JOB_INCOMING reasons at the same time. + * additional print data before it can move the job into the + * {@code PROCESSING} state. If a printer starts processing before it has + * received all data, the printer removes the {@code JOB_DATA_INSUFFICIENT} + * reason, but the {@code JOB_INCOMING} reason remains. If a printer starts + * processing after it has received all data, the printer removes the + * {@code JOB_DATA_INSUFFICIENT} and {@code JOB_INCOMING} reasons at the + * same time. */ public static final JobStateReason JOB_DATA_INSUFFICIENT = new JobStateReason(1); /** - * The Printer could not access one or more documents passed by reference - * (i.e., the print data representation object is a URL). This reason is - * intended to cover any file access problem,including file does not exist - * and access denied because of an access control problem. Whether the - * printer aborts the job and moves the job to the ABORTED job state or - * prints all documents that are accessible and moves the job to the - * COMPLETED job state and adds the COMPLETED_WITH_ERRORS reason to the - * job's {@link JobStateReasons JobStateReasons} attribute depends on - * implementation and/or site policy. This value should be supported if - * the printer supports doc flavors with URL print data representation + * The printer could not access one or more documents passed by reference + * (i.e., the print data representation object is a {@code URL}). This + * reason is intended to cover any file access problem,including file does + * not exist and access denied because of an access control problem. Whether + * the printer aborts the job and moves the job to the {@code ABORTED} job + * state or prints all documents that are accessible and moves the job to + * the {@code COMPLETED} job state and adds the + * {@code COMPLETED_WITH_ERRORS} reason to the job's + * {@link JobStateReasons JobStateReasons} attribute depends on + * implementation and/or site policy. This value should be supported if the + * printer supports doc flavors with {@code URL} print data representation * objects. */ public static final JobStateReason @@ -112,9 +119,8 @@ public class JobStateReason extends EnumSyntax implements Attribute { /** * The value of the job's {@link JobHoldUntil JobHoldUntil} attribute was - * specified with a date-time that is still in the future. The job must - * not be a candidate for processing until this reason is removed and - * there are + * specified with a date-time that is still in the future. The job must not + * be a candidate for processing until this reason is removed and there are * no other reasons to hold the job. This value should be supported if the * {@link JobHoldUntil JobHoldUntil} job template attribute is supported. */ @@ -123,63 +129,64 @@ public class JobStateReason extends EnumSyntax implements Attribute { /** * At least one of the resources needed by the job, such as media, fonts, - * resource objects, etc., is not ready on any of the physical printers - * for which the job is a candidate. This condition may be detected - * when the job is accepted, or subsequently while the job is pending - * or processing, depending on implementation. - * The job may remain in its current state or - * be moved to the PENDING_HELD state, depending on implementation and/or - * job scheduling policy. + * resource objects, etc., is not ready on any of the physical printers for + * which the job is a candidate. This condition may be detected when the job + * is accepted, or subsequently while the job is pending or processing, + * depending on implementation. The job may remain in its current state or + * be moved to the {@code PENDING_HELD} state, depending on implementation + * and/or job scheduling policy. */ public static final JobStateReason RESOURCES_ARE_NOT_READY = new JobStateReason(6); /** * The value of the printer's {@link PrinterStateReasons - * PrinterStateReasons} attribute contains a {@link PrinterStateReason - * PrinterStateReason} value of STOPPED_PARTLY. + * PrinterStateReasons} attribute contains a + * {@link PrinterStateReason PrinterStateReason} value of + * {@code STOPPED_PARTLY}. */ public static final JobStateReason PRINTER_STOPPED_PARTLY = new JobStateReason(7); /** - * The value of the printer's {@link PrinterState PrinterState} attribute - * ia STOPPED. + * The value of the printer's {@link PrinterState PrinterState} attribute ia + * {@code STOPPED}. */ public static final JobStateReason PRINTER_STOPPED = new JobStateReason(8); /** - * The job is in the PROCESSING state, but more specifically, the printer - * ia interpreting the document data. + * The job is in the {@code PROCESSING} state, but more specifically, the + * printer ia interpreting the document data. */ public static final JobStateReason JOB_INTERPRETING = new JobStateReason(9); /** - * The job is in the PROCESSING state, but more specifically, the printer - * has queued the document data. + * The job is in the {@code PROCESSING} state, but more specifically, the + * printer has queued the document data. */ public static final JobStateReason JOB_QUEUED = new JobStateReason(10); /** - * The job is in the PROCESSING state, but more specifically, the printer - * is interpreting document data and producing another electronic + * The job is in the {@code PROCESSING} state, but more specifically, the + * printer is interpreting document data and producing another electronic * representation. */ public static final JobStateReason JOB_TRANSFORMING = new JobStateReason(11); /** - * The job is in the PENDING_HELD, PENDING, or PROCESSING state, but more - * specifically, the printer has completed enough processing of the document - * to be able to start marking and the job is waiting for the marker. - * Systems that require human intervention to release jobs put the job into - * the PENDING_HELD job state. Systems that automatically select a job to - * use the marker put the job into the PENDING job state or keep the job - * in the PROCESSING job state while waiting for the marker, depending on + * The job is in the {@code PENDING_HELD}, {@code PENDING}, or + * {@code PROCESSING} state, but more specifically, the printer has + * completed enough processing of the document to be able to start marking + * and the job is waiting for the marker. Systems that require human + * intervention to release jobs put the job into the {@code PENDING_HELD} + * job state. Systems that automatically select a job to use the marker put + * the job into the {@code PENDING} job state or keep the job in the + * {@code PROCESSING} job state while waiting for the marker, depending on * implementation. All implementations put the job into (or back into) the - * PROCESSING state when marking does begin. + * {@code PROCESSING} state when marking does begin. */ public static final JobStateReason JOB_QUEUED_FOR_MARKER = new JobStateReason(12); @@ -189,8 +196,9 @@ public class JobStateReason extends EnumSyntax implements Attribute { * which spend a great deal of time processing (1) when no marking is * happening and then want to show that marking is now happening or (2) when * the job is in the process of being canceled or aborted while the job - * remains in the PROCESSING state, but the marking has not yet stopped so - * that impression or sheet counts are still increasing for the job. + * remains in the {@code PROCESSING} state, but the marking has not yet + * stopped so that impression or sheet counts are still increasing for the + * job. */ public static final JobStateReason JOB_PRINTING = new JobStateReason(13); @@ -229,9 +237,9 @@ public class JobStateReason extends EnumSyntax implements Attribute { /** * The job was aborted by the system. Either the job (1) is in the process * of being aborted, (2) has been aborted by the system and placed in the - * ABORTED state, or (3) has been aborted by the system and placed in the - * PENDING_HELD state, so that a user or operator can manually try the job - * again. This value should be supported. + * {@code ABORTED} state, or (3) has been aborted by the system and placed + * in the {@code PENDING_HELD} state, so that a user or operator can + * manually try the job again. This value should be supported. */ public static final JobStateReason ABORTED_BY_SYSTEM = new JobStateReason(17); @@ -250,7 +258,7 @@ public class JobStateReason extends EnumSyntax implements Attribute { * The job was aborted by the system because the printer encountered an * error in the document data while decompressing it. If the printer posts * this reason, the document data has already passed any tests that would - * have led to the UNSUPPORTED_COMPRESSION job state reason. + * have led to the {@code UNSUPPORTED_COMPRESSION} job state reason. */ public static final JobStateReason COMPRESSION_ERROR = new JobStateReason(19); @@ -259,8 +267,8 @@ public class JobStateReason extends EnumSyntax implements Attribute { * The job was aborted by the system because the document data's document * format (doc flavor) is not among those supported by the printer. If the * client specifies a doc flavor with a MIME type of - * {@code "application/octet-stream"}, the printer may abort the job if - * the printer cannot determine the document data's actual format through + * {@code "application/octet-stream"}, the printer may abort the job if the + * printer cannot determine the document data's actual format through * auto-sensing (even if the printer supports the document format if * specified explicitly). This value must be supported, since a doc flavor * is required to be specified for each doc. @@ -272,7 +280,7 @@ public class JobStateReason extends EnumSyntax implements Attribute { * The job was aborted by the system because the printer encountered an * error in the document data while processing it. If the printer posts this * reason, the document data has already passed any tests that would have - * led to the UNSUPPORTED_DOCUMENT_FORMAT job state reason. + * led to the {@code UNSUPPORTED_DOCUMENT_FORMAT} job state reason. */ public static final JobStateReason DOCUMENT_FORMAT_ERROR = new JobStateReason(21); @@ -281,22 +289,23 @@ public class JobStateReason extends EnumSyntax implements Attribute { * The requester has canceled the job or the printer has aborted the job, * but the printer is still performing some actions on the job until a * specified stop point occurs or job termination/cleanup is completed. - *

+ *

* If the implementation requires some measurable time to cancel the job in - * the PROCESSING or PROCESSING_STOPPED job states, the printer must use - * this reason to indicate that the printer is still performing some actions - * on the job while the job remains in the PROCESSING or PROCESSING_STOPPED - * state. After all the job's job description attributes have stopped - * incrementing, the printer moves the job from the PROCESSING state to the - * CANCELED or ABORTED job states. + * the {@code PROCESSING} or {@code PROCESSING_STOPPED} job states, the + * printer must use this reason to indicate that the printer is still + * performing some actions on the job while the job remains in the + * {@code PROCESSING} or {@code PROCESSING_STOPPED} state. After all the + * job's job description attributes have stopped incrementing, the printer + * moves the job from the PROCESSING state to the {@code CANCELED} or + * {@code ABORTED} job states. */ public static final JobStateReason PROCESSING_TO_STOP_POINT = new JobStateReason(22); /** - * The printer is off-line and accepting no jobs. All PENDING jobs are put - * into the PENDING_HELD state. This situation could be true if the - * service's or document transform's input is impaired or broken. + * The printer is off-line and accepting no jobs. All {@code PENDING} jobs + * are put into the {@code PENDING_HELD} state. This situation could be true + * if the service's or document transform's input is impaired or broken. */ public static final JobStateReason SERVICE_OFF_LINE = new JobStateReason(23); @@ -323,11 +332,11 @@ public class JobStateReason extends EnumSyntax implements Attribute { /** * This job is retained and is currently able to be restarted. If - * JOB_RESTARTABLE is contained in the job's {@link JobStateReasons - * JobStateReasons} attribute, then the printer must accept a request to - * restart that job. This value should be supported if restarting jobs is - * supported. [The capability for restarting jobs is not in the Java - * Print Service API at present.] + * {@code JOB_RESTARTABLE} is contained in the job's + * {@link JobStateReasons JobStateReasons} attribute, then the printer must + * accept a request to restart that job. This value should be supported if + * restarting jobs is supported. [The capability for restarting jobs is + * not in the Java Print Service API at present.] */ public static final JobStateReason JOB_RESTARTABLE = new JobStateReason(27); @@ -335,24 +344,27 @@ public class JobStateReason extends EnumSyntax implements Attribute { /** * The job has been forwarded to a device or print system that is unable to * send back status. The printer sets the job's {@link JobState JobState} - * attribute to COMPLETED and adds the QUEUED_IN_DEVICE reason to the job's - * {@link JobStateReasons JobStateReasons} attribute to indicate that the - * printer has no additional information about the job and never will have - * any better information. + * attribute to {@code COMPLETED} and adds the {@code QUEUED_IN_DEVICE} + * reason to the job's {@link JobStateReasons JobStateReasons} attribute to + * indicate that the printer has no additional information about the job and + * never will have any better information. */ public static final JobStateReason QUEUED_IN_DEVICE = new JobStateReason(28); /** - * Construct a new job state reason enumeration value with the given - * integer value. + * Construct a new job state reason enumeration value with the given integer + * value. * - * @param value Integer value. + * @param value Integer value */ protected JobStateReason(int value) { super (value); } + /** + * The string table for class {@code JobStateReason}. + */ private static final String[] myStringTable = { "job-incoming", "job-data-insufficient", @@ -384,6 +396,9 @@ public class JobStateReason extends EnumSyntax implements Attribute { "job-restartable", "queued-in-device"}; + /** + * The enumeration value table for class {@code JobStateReason}. + */ private static final JobStateReason[] myEnumValueTable = { JOB_INCOMING, JOB_DATA_INSUFFICIENT, @@ -416,29 +431,28 @@ public class JobStateReason extends EnumSyntax implements Attribute { QUEUED_IN_DEVICE}; /** - * Returns the string table for class JobStateReason. + * Returns the string table for class {@code JobStateReason}. */ protected String[] getStringTable() { return myStringTable.clone(); } /** - * Returns the enumeration value table for class JobStateReason. + * Returns the enumeration value table for class {@code JobStateReason}. */ protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } - /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobStateReason and any vendor-defined subclasses, the - * category is class JobStateReason itself. + *

+ * For class {@code JobStateReason} and any vendor-defined subclasses, the + * category is class {@code JobStateReason} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobStateReason.class; @@ -447,14 +461,13 @@ public class JobStateReason extends EnumSyntax implements Attribute { /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobStateReason and any vendor-defined subclasses, the + *

+ * For class {@code JobStateReason} and any vendor-defined subclasses, the * category name is {@code "job-state-reason"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-state-reason"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReasons.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReasons.java index 0710de48d41..22c7be9d46b 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReasons.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/JobStateReasons.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.Collection; @@ -31,43 +32,47 @@ import javax.print.attribute.Attribute; import javax.print.attribute.PrintJobAttribute; /** - * Class JobStateReasons is a printing attribute class, a set of enumeration - * values, that provides additional information about the job's current state, - * i.e., information that augments the value of the job's {@link JobState - * JobState} attribute. - *

+ * Class {@code JobStateReasons} is a printing attribute class, a set of + * enumeration values, that provides additional information about the job's + * current state, i.e., information that augments the value of the job's + * {@link JobState JobState} attribute. + *

* Instances of {@link JobStateReason JobStateReason} do not appear in a Print - * Job's attribute set directly. Rather, a JobStateReasons attribute appears in - * the Print Job's attribute set. The JobStateReasons attribute contains zero, - * one, or more than one {@link JobStateReason JobStateReason} objects which - * pertain to the Print Job's status. The printer adds a {@link JobStateReason - * JobStateReason} object to the Print Job's JobStateReasons attribute when the - * corresponding condition becomes true of the Print Job, and the printer - * removes the {@link JobStateReason JobStateReason} object again when the - * corresponding condition becomes false, regardless of whether the Print Job's - * overall {@link JobState JobState} also changed. - *

- * Class JobStateReasons inherits its implementation from class {@link - * java.util.HashSet java.util.HashSet}. Unlike most printing attributes which - * are immutable once constructed, class JobStateReasons is designed to be - * mutable; you can add {@link JobStateReason JobStateReason} objects to an - * existing JobStateReasons object and remove them again. However, like class - * {@link java.util.HashSet java.util.HashSet}, class JobStateReasons is not - * multiple thread safe. If a JobStateReasons object will be used by multiple - * threads, be sure to synchronize its operations (e.g., using a synchronized - * set view obtained from class {@link java.util.Collections - * java.util.Collections}). - *

- * IPP Compatibility: The string value returned by each individual {@link - * JobStateReason JobStateReason} object's {@code toString()} method gives - * the IPP keyword value. The category name returned by {@code getName()} + * Job's attribute set directly. Rather, a {@code JobStateReasons} attribute + * appears in the Print Job's attribute set. The {@code JobStateReasons} + * attribute contains zero, one, or more than one + * {@link JobStateReason JobStateReason} objects which pertain to the Print + * Job's status. The printer adds a {@link JobStateReason JobStateReason} object + * to the Print Job's JobStateReasons attribute when the corresponding condition + * becomes true of the Print Job, and the printer removes the + * {@link JobStateReason JobStateReason} object again when the corresponding + * condition becomes false, regardless of whether the Print Job's overall + * {@link JobState JobState} also changed. + *

+ * Class {@code JobStateReasons} inherits its implementation from class + * {@link HashSet java.util.HashSet}. Unlike most printing attributes + * which are immutable once constructed, class {@code JobStateReasons} is + * designed to be mutable; you can add {@link JobStateReason JobStateReason} + * objects to an existing {@code JobStateReasons} object and remove them again. + * However, like class {@link HashSet java.util.HashSet}, class + * {@code JobStateReasons} is not multiple thread safe. If a + * {@code JobStateReasons} object will be used by multiple threads, be sure to + * synchronize its operations (e.g., using a synchronized set view obtained + * from class {@link java.util.Collections java.util.Collections}). + *

+ * IPP Compatibility: The string value returned by each individual + * {@link JobStateReason JobStateReason} object's {@code toString()} method + * gives the IPP keyword value. The category name returned by {@code getName()} * gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class JobStateReasons extends HashSet implements PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 8849088261264331812L; /** @@ -82,9 +87,8 @@ public final class JobStateReasons * Construct a new, empty job state reasons attribute; the underlying hash * set has the given initial capacity and the default load factor. * - * @param initialCapacity Initial capacity. - * @throws IllegalArgumentException if the initial capacity is less - * than zero. + * @param initialCapacity initial capacity + * @throws IllegalArgumentException if the initial capacity is negative */ public JobStateReasons(int initialCapacity) { super (initialCapacity); @@ -94,10 +98,9 @@ public final class JobStateReasons * Construct a new, empty job state reasons attribute; the underlying hash * set has the given initial capacity and load factor. * - * @param initialCapacity Initial capacity. - * @param loadFactor Load factor. - * @throws IllegalArgumentException if the initial capacity is less - * than zero. + * @param initialCapacity initial capacity + * @param loadFactor load factor + * @throws IllegalArgumentException if the initial capacity is negative */ public JobStateReasons(int initialCapacity, float loadFactor) { super (initialCapacity, loadFactor); @@ -107,23 +110,18 @@ public final class JobStateReasons * Construct a new job state reasons attribute that contains the same * {@link JobStateReason JobStateReason} objects as the given collection. * The underlying hash set's initial capacity and load factor are as - * specified in the superclass constructor {@link - * java.util.HashSet#HashSet(java.util.Collection) - * HashSet(Collection)}. + * specified in the superclass constructor + * {@link HashSet#HashSet(Collection) HashSet(Collection)}. * - * @param collection Collection to copy. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code collection} is null or - * if any element in {@code collection} is null. - * @throws ClassCastException - * (unchecked exception) Thrown if any element in - * {@code collection} is not an instance of class {@link - * JobStateReason JobStateReason}. + * @param collection collection to copy + * @throws NullPointerException if {@code collection} is {@code null} or if + * any element in {@code collection} is {@code null} + * @throws ClassCastException if any element in {@code collection} is not an + * instance of class {@link JobStateReason JobStateReason} */ - public JobStateReasons(Collection collection) { - super (collection); - } + public JobStateReasons(Collection collection) { + super (collection); + } /** * Adds the specified element to this job state reasons attribute if it is @@ -132,16 +130,12 @@ public final class JobStateReasons * attribute already contains the specified element, the call leaves this * job state reasons attribute unchanged and returns {@code false}. * - * @param o Element to be added to this job state reasons attribute. - * - * @return {@code true} if this job state reasons attribute did not - * already contain the specified element. - * - * @throws NullPointerException - * (unchecked exception) Thrown if the specified element is null. - * @throws ClassCastException - * (unchecked exception) Thrown if the specified element is not an - * instance of class {@link JobStateReason JobStateReason}. + * @param o element to be added to this job state reasons attribute + * @return {@code true} if this job state reasons attribute did not already + * contain the specified element + * @throws NullPointerException if the specified element is {@code null} + * @throws ClassCastException if the specified element is not an instance of + * class {@link JobStateReason JobStateReason} * @since 1.5 */ public boolean add(JobStateReason o) { @@ -154,11 +148,12 @@ public final class JobStateReasons /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class JobStateReasons, the category is class JobStateReasons itself. + *

+ * For class {@code JobStateReasons}, the category is class + * JobStateReasons itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return JobStateReasons.class; @@ -167,14 +162,13 @@ public final class JobStateReasons /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class JobStateReasons, the category - * name is {@code "job-state-reasons"}. + *

+ * For class JobStateReasons, the category name is + * {@code "job-state-reasons"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "job-state-reasons"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Media.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Media.java index 94eec385dfb..bc56c3e173c 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Media.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Media.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,48 +22,51 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; import javax.print.attribute.DocAttribute; import javax.print.attribute.EnumSyntax; -import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class Media is a printing attribute class that specifies the - * medium on which to print. + * Class {@code Media} is a printing attribute class that specifies the medium + * on which to print. *

* Media may be specified in different ways. *

    - *
  • it may be specified by paper source - eg paper tray - *
  • it may be specified by a standard size - eg "A4" - *
  • it may be specified by a name - eg "letterhead" + *
  • it may be specified by paper source - eg paper tray + *
  • it may be specified by a standard size - eg "A4" + *
  • it may be specified by a name - eg "letterhead" *
- * Each of these corresponds to the IPP "media" attribute. - * The current API does not support describing media by characteristics - * (eg colour, opacity). - * This may be supported in a later revision of the specification. + * Each of these corresponds to the IPP "media" attribute. The current API does + * not support describing media by characteristics (eg colour, opacity). This + * may be supported in a later revision of the specification. *

- * A Media object is constructed with a value which represents - * one of the ways in which the Media attribute can be specified. + * A {@code Media} object is constructed with a value which represents one of + * the ways in which the Media attribute can be specified. *

- * IPP Compatibility: The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. + * IPP Compatibility: The category name returned by {@code getName()} is + * the IPP attribute name. The enumeration's integer value is the IPP enum + * value. The {@code toString()} method returns the IPP string representation of + * the attribute value. * * @author Phil Race */ public abstract class Media extends EnumSyntax implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -2823970704630722439L; /** * Constructs a new media attribute specified by name. * - * @param value a value + * @param value a value */ protected Media(int value) { super (value); @@ -72,19 +75,16 @@ public abstract class Media extends EnumSyntax /** * Returns whether this media attribute is equivalent to the passed in * object. To be equivalent, all of the following conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is of the same subclass of Media as this object. - *
  3. - * The values are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is of the same subclass of {@code Media} as this + * object. + *
  3. The values are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this media - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this media + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return(object != null && object instanceof Media && @@ -95,12 +95,12 @@ public abstract class Media extends EnumSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class Media and any vendor-defined subclasses, the category is - * class Media itself. + *

+ * For class {@code Media} and any vendor-defined subclasses, the category + * is class {@code Media} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return Media.class; @@ -109,14 +109,13 @@ public abstract class Media extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class Media and any vendor-defined subclasses, the category name is - * {@code "media"}. + *

+ * For class {@code Media} and any vendor-defined subclasses, the category + * name is {@code "media"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "media"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaName.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaName.java index 28772c1ae83..631a3f628c7 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaName.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,37 +22,40 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; -import java.util.Locale; import javax.print.attribute.Attribute; import javax.print.attribute.EnumSyntax; /** - * Class MediaName is a subclass of Media, a printing attribute class (an - * enumeration) that specifies the media for a print job as a name. - *

- * This attribute can be used instead of specifying MediaSize or MediaTray. + * Class {@code MediaName} is a subclass of {@code Media}, a printing attribute + * class (an enumeration) that specifies the media for a print job as a name. *

- * Class MediaName currently declares a few standard media names. - * Implementation- or site-defined names for a media name attribute may also - * be created by defining a subclass of class MediaName. - *

- * IPP Compatibility: MediaName is a representation class for + * This attribute can be used instead of specifying {@code MediaSize} or + * {@code MediaTray}. + *

+ * Class {@code MediaName} currently declares a few standard media names. + * Implementation- or site-defined names for a media name attribute may also be + * created by defining a subclass of class {@code MediaName}. + *

+ * IPP Compatibility: {@code MediaName} is a representation class for * values of the IPP "media" attribute which names media. - * */ public class MediaName extends Media implements Attribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 4653117714524155448L; /** - * white letter paper. + * white letter paper. */ public static final MediaName NA_LETTER_WHITE = new MediaName(0); /** - * letter transparency. + * letter transparency. */ public static final MediaName NA_LETTER_TRANSPARENT = new MediaName(1); @@ -61,23 +64,24 @@ public class MediaName extends Media implements Attribute { */ public static final MediaName ISO_A4_WHITE = new MediaName(2); - /** - * A4 transparency. + * A4 transparency. */ public static final MediaName ISO_A4_TRANSPARENT= new MediaName(3); - /** * Constructs a new media name enumeration value with the given integer * value. * - * @param value Integer value. + * @param value Integer value */ protected MediaName(int value) { super (value); } + /** + * The string table for class {@code MediaTray}. + */ private static final String[] myStringTable = { "na-letter-white", "na-letter-transparent", @@ -85,6 +89,9 @@ public class MediaName extends Media implements Attribute { "iso-a4-transparent" }; + /** + * The enumeration value table for class {@code MediaTray}. + */ private static final MediaName[] myEnumValueTable = { NA_LETTER_WHITE, NA_LETTER_TRANSPARENT, @@ -93,8 +100,9 @@ public class MediaName extends Media implements Attribute { }; /** - * Returns the string table for class MediaTray. - * @return the String table. + * Returns the string table for class {@code MediaTray}. + * + * @return the string table */ protected String[] getStringTable() { @@ -102,11 +110,11 @@ public class MediaName extends Media implements Attribute { } /** - * Returns the enumeration value table for class MediaTray. - * @return the enumeration value table. + * Returns the enumeration value table for class {@code MediaTray}. + * + * @return the enumeration value table */ protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaPrintableArea.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaPrintableArea.java index 05937b5dcaf..4bf14435127 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaPrintableArea.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaPrintableArea.java @@ -22,9 +22,11 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.DocFlavor; +import javax.print.PrintService; import javax.print.attribute.Attribute; import javax.print.attribute.AttributeSet; import javax.print.attribute.DocAttribute; @@ -32,60 +34,67 @@ import javax.print.attribute.PrintJobAttribute; import javax.print.attribute.PrintRequestAttribute; /** - * Class MediaPrintableArea is a printing attribute used to distinguish + * Class {@code MediaPrintableArea} is a printing attribute used to distinguish * the printable and non-printable areas of media. *

* The printable area is specified to be a rectangle, within the overall * dimensions of a media. *

- * Most printers cannot print on the entire surface of the media, due - * to printer hardware limitations. This class can be used to query - * the acceptable values for a supposed print job, and to request an area - * within the constraints of the printable area to be used in a print job. + * Most printers cannot print on the entire surface of the media, due to printer + * hardware limitations. This class can be used to query the acceptable values + * for a supposed print job, and to request an area within the constraints of + * the printable area to be used in a print job. *

* To query for the printable area, a client must supply a suitable context. - * Without specifying at the very least the size of the media being used - * no meaningful value for printable area can be obtained. + * Without specifying at the very least the size of the media being used no + * meaningful value for printable area can be obtained. *

- * The attribute is not described in terms of the distance from the edge - * of the paper, in part to emphasise that this attribute is not independent - * of a particular media, but must be described within the context of a - * choice of other attributes. Additionally it is usually more convenient - * for a client to use the printable area. + * The attribute is not described in terms of the distance from the edge of the + * paper, in part to emphasise that this attribute is not independent of a + * particular media, but must be described within the context of a choice of + * other attributes. Additionally it is usually more convenient for a client to + * use the printable area. *

- * The hardware's minimum margins is not just a property of the printer, - * but may be a function of the media size, orientation, media type, and - * any specified finishings. - * {@code PrintService} provides the method to query the supported - * values of an attribute in a suitable context : - * See {@link javax.print.PrintService#getSupportedAttributeValues(Class,DocFlavor, AttributeSet) PrintService.getSupportedAttributeValues()} + * The hardware's minimum margins is not just a property of the printer, but may + * be a function of the media size, orientation, media type, and any specified + * finishings. {@code PrintService} provides the method to query the supported + * values of an attribute in a suitable context : See + * {@link PrintService#getSupportedAttributeValues(Class, DocFlavor, AttributeSet) + * PrintService.getSupportedAttributeValues()} *

- * The rectangular printable area is defined thus: - * The (x,y) origin is positioned at the top-left of the paper in portrait - * mode regardless of the orientation specified in the requesting context. - * For example a printable area for A4 paper in portrait or landscape - * orientation will have height {@literal >} width. + * The rectangular printable area is defined thus: The (x,y) origin is + * positioned at the top-left of the paper in portrait mode regardless of the + * orientation specified in the requesting context. For example a printable area + * for A4 paper in portrait or landscape orientation will have height + * {@literal >} width. *

- * A printable area attribute's values are stored - * internally as integers in units of micrometers (µm), where 1 micrometer - * = 10-6 meter = 1/1000 millimeter = 1/25400 inch. This permits - * dimensions to be represented exactly to a precision of 1/1000 mm (= 1 - * µm) or 1/100 inch (= 254 µm). If fractional inches are expressed in - - * negative powers of two, this permits dimensions to be represented exactly to - * a precision of 1/8 inch (= 3175 µm) but not 1/16 inch (because 1/16 inch - - * does not equal an integral number of µm). + * A printable area attribute's values are stored internally as integers in + * units of micrometers (µm), where 1 micrometer = 10-6 meter = + * 1/1000 millimeter = 1/25400 inch. This permits dimensions to be represented + * exactly to a precision of 1/1000 mm (= 1 µm) or 1/100 inch (= 254 + * µm). If fractional inches are expressed in negative powers of two, this + * permits dimensions to be represented exactly to a precision of 1/8 inch + * (= 3175 µm) but not 1/16 inch (because 1/16 inch does not equal an + * integral number of µm). *

- * IPP Compatibility: MediaPrintableArea is not an IPP attribute. + * IPP Compatibility: MediaPrintableArea is not an IPP attribute. */ - public final class MediaPrintableArea implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { + /** + * Printable {@code x}, {@code y}, {@code width} and {@code height}. + */ private int x, y, w, h; + + /** + * The units in which the values are expressed. + */ private int units; + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -1597171464050795793L; /** @@ -101,18 +110,17 @@ public final class MediaPrintableArea public static final int MM = 1000; /** - * Constructs a MediaPrintableArea object from floating point values. - * @param x printable x - * @param y printable y - * @param w printable width - * @param h printable height - * @param units in which the values are expressed. - * - * @exception IllegalArgumentException - * Thrown if {@code x < 0} or {@code y < 0} - * or {@code w <= 0} or {@code h <= 0} or - * {@code units < 1}. - */ + * Constructs a {@code MediaPrintableArea} object from floating point + * values. + * + * @param x printable x + * @param y printable y + * @param w printable width + * @param h printable height + * @param units in which the values are expressed + * @throws IllegalArgumentException if {@code x < 0} or {@code y < 0} or + * {@code w <= 0} or {@code h <= 0} or {@code units < 1} + */ public MediaPrintableArea(float x, float y, float w, float h, int units) { if ((x < 0.0) || (y < 0.0) || (w <= 0.0) || (h <= 0.0) || (units < 1)) { @@ -127,18 +135,16 @@ public final class MediaPrintableArea } /** - * Constructs a MediaPrintableArea object from integer values. - * @param x printable x - * @param y printable y - * @param w printable width - * @param h printable height - * @param units in which the values are expressed. - * - * @exception IllegalArgumentException - * Thrown if {@code x < 0} or {@code y < 0} - * or {@code w <= 0} or {@code h <= 0} or - * {@code units < 1}. - */ + * Constructs a {@code MediaPrintableArea} object from integer values. + * + * @param x printable x + * @param y printable y + * @param w printable width + * @param h printable height + * @param units in which the values are expressed + * @throws IllegalArgumentException if {@code x < 0} or {@code y < 0} or + * {@code w <= 0} or {@code h <= 0} or {@code units < 1} + */ public MediaPrintableArea(int x, int y, int w, int h, int units) { if ((x < 0) || (y < 0) || (w <= 0) || (h <= 0) || (units < 1)) { @@ -153,15 +159,13 @@ public final class MediaPrintableArea /** * Get the printable area as an array of 4 values in the order - * x, y, w, h. The values returned are in the given units. - * @param units - * Unit conversion factor, e.g. {@link #INCH INCH} or - * {@link #MM MM}. + * {@code x, y, w, h}. The values returned are in the given units. * - * @return printable area as array of x, y, w, h in the specified units. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @return printable area as array of {@code x, y, w, h} in the specified + * units + * @throws IllegalArgumentException if {@code units < 1} */ public float[] getPrintableArea(int units) { return new float[] { getX(units), getY(units), @@ -169,86 +173,70 @@ public final class MediaPrintableArea } /** - * Get the x location of the origin of the printable area in the - * specified units. - * @param units - * Unit conversion factor, e.g. {@link #INCH INCH} or - * {@link #MM MM}. - * - * @return x location of the origin of the printable area in the + * Get the {@code x} location of the origin of the printable area in the * specified units. * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @return {@code x} location of the origin of the printable area in the + * specified units + * @throws IllegalArgumentException if {@code units < 1} */ - public float getX(int units) { + public float getX(int units) { return convertFromMicrometers(x, units); - } + } /** - * Get the y location of the origin of the printable area in the - * specified units. - * @param units - * Unit conversion factor, e.g. {@link #INCH INCH} or - * {@link #MM MM}. - * - * @return y location of the origin of the printable area in the + * Get the {@code y} location of the origin of the printable area in the * specified units. * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @return {@code y} location of the origin of the printable area in the + * specified units + * @throws IllegalArgumentException if {@code units < 1} */ - public float getY(int units) { + public float getY(int units) { return convertFromMicrometers(y, units); - } + } /** - * Get the width of the printable area in the specified units. - * @param units - * Unit conversion factor, e.g. {@link #INCH INCH} or - * {@link #MM MM}. + * Get the {@code width} of the printable area in the specified units. * - * @return width of the printable area in the specified units. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @return {@code width} of the printable area in the specified units + * @throws IllegalArgumentException if {@code units < 1} */ - public float getWidth(int units) { + public float getWidth(int units) { return convertFromMicrometers(w, units); - } + } /** - * Get the height of the printable area in the specified units. - * @param units - * Unit conversion factor, e.g. {@link #INCH INCH} or - * {@link #MM MM}. + * Get the {@code height} of the printable area in the specified units. * - * @return height of the printable area in the specified units. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @return {@code height} of the printable area in the specified units + * @throws IllegalArgumentException if {@code units < 1} */ - public float getHeight(int units) { + public float getHeight(int units) { return convertFromMicrometers(h, units); - } + } /** * Returns whether this media margins attribute is equivalent to the passed - * in object. - * To be equivalent, all of the following conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class MediaPrintableArea. - *
  3. - * The origin and dimensions are the same. - *
+ * in object. To be equivalent, all of the following conditions must be + * true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code MediaPrintableArea}. + *
  3. The origin and dimensions are the same. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this media margins - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this media + * margins attribute, {@code false} otherwise */ public boolean equals(Object object) { boolean ret = false; @@ -264,12 +252,12 @@ public final class MediaPrintableArea /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class MediaPrintableArea, the category is - * class MediaPrintableArea itself. + *

+ * For class {@code MediaPrintableArea}, the category is class + * {@code MediaPrintableArea} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return MediaPrintableArea.class; @@ -278,32 +266,28 @@ public final class MediaPrintableArea /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class MediaPrintableArea, - * the category name is {@code "media-printable-area"}. - *

This is not an IPP V1.1 attribute. + *

+ * For class {@code MediaPrintableArea}, the category name is + * {@code "media-printable-area"}. + *

+ * This is not an IPP V1.1 attribute. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "media-printable-area"; } /** - * Returns a string version of this rectangular size attribute in the - * given units. + * Returns a string version of this rectangular size attribute in the given + * units. * - * @param units - * Unit conversion factor, e.g. {@link #INCH INCH} or - * {@link #MM MM}. - * @param unitsName - * Units name string, e.g. {@code "in"} or {@code "mm"}. If - * null, no units name is appended to the result. - * - * @return String version of this two-dimensional size attribute. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code units < 1}. + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @param unitsName units name string, e.g. {@code "in"} or {@code "mm"}. + * If {@code null}, no units name is appended to the result + * @return string version of this two-dimensional size attribute + * @throws IllegalArgumentException if {@code units < 1} */ public String toString(int units, String unitsName) { if (unitsName == null) { @@ -328,6 +312,14 @@ public final class MediaPrintableArea return x + 37*y + 43*w + 47*h; } + /** + * Converts the {@code x} from micrometers to {@code units}. + * + * @param x the value + * @param units unit conversion factor, e.g. {@link #INCH INCH} or + * {@link #MM MM} + * @return the value of {@code x} in the specified units + */ private static float convertFromMicrometers(int x, int units) { if (units < 1) { throw new IllegalArgumentException("units is < 1"); diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSize.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSize.java index 55990097a71..44385af73dc 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSize.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,37 +22,44 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.HashMap; import java.util.Vector; -import javax.print.attribute.Size2DSyntax; import javax.print.attribute.Attribute; +import javax.print.attribute.Size2DSyntax; /** - * Class MediaSize is a two-dimensional size valued printing attribute class - * that indicates the dimensions of the medium in a portrait orientation, with - * the X dimension running along the bottom edge and the Y dimension running - * along the left edge. Thus, the Y dimension must be greater than or equal to - * the X dimension. Class MediaSize declares many standard media size - * values, organized into nested classes for ISO, JIS, North American, - * engineering, and other media. - *

- * MediaSize is not yet used to specify media. Its current role is - * as a mapping for named media (see {@link MediaSizeName MediaSizeName}). - * Clients can use the mapping method - * {@code MediaSize.getMediaSizeForName(MediaSizeName)} - * to find the physical dimensions of the MediaSizeName instances - * enumerated in this API. This is useful for clients which need this - * information to format {@literal &} paginate printing. + * Class {@code MediaSize} is a two-dimensional size valued printing attribute + * class that indicates the dimensions of the medium in a portrait orientation, + * with the {@code X} dimension running along the bottom edge and the {@code Y} + * dimension running along the left edge. Thus, the {@code Y} dimension must be + * greater than or equal to the {@code X} dimension. Class {@code MediaSize} + * declares many standard media size values, organized into nested classes for + * ISO, JIS, North American, engineering, and other media. + *

+ * {@code MediaSize} is not yet used to specify media. Its current role is as a + * mapping for named media (see {@link MediaSizeName MediaSizeName}). Clients + * can use the mapping method + * {@code MediaSize.getMediaSizeForName(MediaSizeName)} to find the physical + * dimensions of the {@code MediaSizeName} instances enumerated in this API. + * This is useful for clients which need this information to format {@literal &} + * paginate printing. * - * @author Phil Race, Alan Kaminsky + * @author Phil Race, Alan Kaminsky */ public class MediaSize extends Size2DSyntax implements Attribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -1967958664615414771L; + /** + * The media name. + */ private MediaSizeName mediaName; private static HashMap mediaMap = new HashMap<>(100, 10); @@ -63,15 +70,12 @@ public class MediaSize extends Size2DSyntax implements Attribute { * Construct a new media size attribute from the given floating-point * values. * - * @param x X dimension. - * @param y Y dimension. - * @param units - * Unit conversion factor, e.g. {@code Size2DSyntax.INCH} or - * {@code Size2DSyntax.MM}. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or - * {@code units < 1} or {@code x > y}. + * @param x {@code X} dimension + * @param y {@code Y} dimension + * @param units unit conversion factor, e.g. {@code Size2DSyntax.INCH} or + * {@code Size2DSyntax.MM} + * @throws IllegalArgumentException if {@code x < 0} or {@code y < 0} or + * {@code units < 1} or {@code x > y} */ public MediaSize(float x, float y,int units) { super (x, y, units); @@ -84,15 +88,12 @@ public class MediaSize extends Size2DSyntax implements Attribute { /** * Construct a new media size attribute from the given integer values. * - * @param x X dimension. - * @param y Y dimension. - * @param units - * Unit conversion factor, e.g. {@code Size2DSyntax.INCH} or - * {@code Size2DSyntax.MM}. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or - * {@code units < 1} or {@code x > y}. + * @param x {@code X} dimension + * @param y {@code Y} dimension + * @param units unit conversion factor, e.g. {@code Size2DSyntax.INCH} or + * {@code Size2DSyntax.MM} + * @throws IllegalArgumentException if {@code x < 0} or {@code y < 0} or + * {@code units < 1} or {@code x > y} */ public MediaSize(int x, int y,int units) { super (x, y, units); @@ -102,20 +103,17 @@ public class MediaSize extends Size2DSyntax implements Attribute { sizeVector.add(this); } - /** + /** * Construct a new media size attribute from the given floating-point * values. * - * @param x X dimension. - * @param y Y dimension. - * @param units - * Unit conversion factor, e.g. {@code Size2DSyntax.INCH} or - * {@code Size2DSyntax.MM}. - * @param media a media name to associate with this MediaSize - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or - * {@code units < 1} or {@code x > y}. + * @param x {@code X} dimension + * @param y {@code Y} dimension + * @param units unit conversion factor, e.g. {@code Size2DSyntax.INCH} or + * {@code Size2DSyntax.MM} + * @param media a media name to associate with this {@code MediaSize} + * @throws IllegalArgumentException if {@code x < 0} or {@code y < 0} or + * {@code units < 1} or {@code x > y} */ public MediaSize(float x, float y,int units, MediaSizeName media) { super (x, y, units); @@ -132,16 +130,13 @@ public class MediaSize extends Size2DSyntax implements Attribute { /** * Construct a new media size attribute from the given integer values. * - * @param x X dimension. - * @param y Y dimension. - * @param units - * Unit conversion factor, e.g. {@code Size2DSyntax.INCH} or - * {@code Size2DSyntax.MM}. - * @param media a media name to associate with this MediaSize - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code x < 0} or {@code y < 0} or - * {@code units < 1} or {@code x > y}. + * @param x {@code X} dimension + * @param y {@code Y} dimension + * @param units unit conversion factor, e.g. {@code Size2DSyntax.INCH} or + * {@code Size2DSyntax.MM} + * @param media a media name to associate with this {@code MediaSize} + * @throws IllegalArgumentException if {@code x < 0} or {@code y < 0} or + * {@code units < 1} or {@code x > y} */ public MediaSize(int x, int y,int units, MediaSizeName media) { super (x, y, units); @@ -158,44 +153,43 @@ public class MediaSize extends Size2DSyntax implements Attribute { /** * Get the media name, if any, for this size. * - * @return the name for this media size, or null if no name was - * associated with this size (an anonymous size). + * @return the name for this media size, or {@code null} if no name was + * associated with this size (an anonymous size) */ public MediaSizeName getMediaSizeName() { return mediaName; } /** - * Get the MediaSize for the specified named media. + * Get the {@code MediaSize} for the specified named media. * - * @param media the name of the media for which the size is sought - * @return size of the media, or null if this media is not associated - * with any size. + * @param media the name of the media for which the size is sought + * @return size of the media, or {@code null} if this media is not + * associated with any size */ public static MediaSize getMediaSizeForName(MediaSizeName media) { return mediaMap.get(media); } /** - * The specified dimensions are used to locate a matching MediaSize - * instance from amongst all the standard MediaSize instances. - * If there is no exact match, the closest match is used. + * The specified dimensions are used to locate a matching {@code MediaSize} + * instance from amongst all the standard {@code MediaSize} instances. If + * there is no exact match, the closest match is used. *

- * The MediaSize is in turn used to locate the MediaSizeName object. - * This method may return null if the closest matching MediaSize - * has no corresponding Media instance. + * The {@code MediaSize} is in turn used to locate the {@code MediaSizeName} + * object. This method may return {@code null} if the closest matching + * {@code MediaSize} has no corresponding {@code Media} instance. *

- * This method is useful for clients which have only dimensions and - * want to find a Media which corresponds to the dimensions. - * @param x X dimension - * @param y Y dimension. - * @param units - * Unit conversion factor, e.g. {@code Size2DSyntax.INCH} or - * {@code Size2DSyntax.MM} - * @return MediaSizeName matching these dimensions, or null. - * @exception IllegalArgumentException if {@code x <= 0}, - * {@code y <= 0}, or {@code units < 1}. + * This method is useful for clients which have only dimensions and want to + * find a {@code Media} which corresponds to the dimensions. * + * @param x {@code X} dimension + * @param y {@code Y} dimension + * @param units unit conversion factor, e.g. {@code Size2DSyntax.INCH} or + * {@code Size2DSyntax.MM} + * @return {@code MediaSizeName} matching these dimensions, or {@code null} + * @throws IllegalArgumentException if {@code x <= 0}, {@code y <= 0}, or + * {@code units < 1} */ public static MediaSizeName findMedia(float x, float y, int units) { @@ -232,26 +226,20 @@ public class MediaSize extends Size2DSyntax implements Attribute { } /** - * Returns whether this media size attribute is equivalent to the passed - * in object. - * To be equivalent, all of the following conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class MediaSize. - *
  3. - * This media size attribute's X dimension is equal to - * {@code object}'s X dimension. - *
  4. - * This media size attribute's Y dimension is equal to - * {@code object}'s Y dimension. - *
+ * Returns whether this media size attribute is equivalent to the passed in + * object. To be equivalent, all of the following conditions must be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code MediaSize}. + *
  3. This media size attribute's {@code X} dimension is equal to + * {@code object}'s {@code X} dimension. + *
  4. This media size attribute's {@code Y} dimension is equal to + * {@code object}'s {@code Y} dimension. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this media size - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this media size + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && object instanceof MediaSize); @@ -260,12 +248,12 @@ public class MediaSize extends Size2DSyntax implements Attribute { /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class MediaSize and any vendor-defined subclasses, the category is - * class MediaSize itself. + *

+ * For class {@code MediaSize} and any vendor-defined subclasses, the + * category is class {@code MediaSize} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return MediaSize.class; @@ -274,151 +262,178 @@ public class MediaSize extends Size2DSyntax implements Attribute { /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class MediaSize and any vendor-defined subclasses, the category - * name is {@code "media-size"}. + *

+ * For class {@code MediaSize} and any vendor-defined subclasses, the + * category name is {@code "media-size"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "media-size"; } /** - * Class MediaSize.ISO includes {@link MediaSize MediaSize} values for ISO - * media. + * Class {@code MediaSize.ISO} includes {@link MediaSize MediaSize} values + * for ISO media. */ public static final class ISO { + /** * Specifies the ISO A0 size, 841 mm by 1189 mm. */ public static final MediaSize A0 = new MediaSize(841, 1189, Size2DSyntax.MM, MediaSizeName.ISO_A0); + /** * Specifies the ISO A1 size, 594 mm by 841 mm. */ public static final MediaSize A1 = new MediaSize(594, 841, Size2DSyntax.MM, MediaSizeName.ISO_A1); + /** * Specifies the ISO A2 size, 420 mm by 594 mm. */ public static final MediaSize A2 = new MediaSize(420, 594, Size2DSyntax.MM, MediaSizeName.ISO_A2); + /** * Specifies the ISO A3 size, 297 mm by 420 mm. */ public static final MediaSize A3 = new MediaSize(297, 420, Size2DSyntax.MM, MediaSizeName.ISO_A3); + /** * Specifies the ISO A4 size, 210 mm by 297 mm. */ public static final MediaSize A4 = new MediaSize(210, 297, Size2DSyntax.MM, MediaSizeName.ISO_A4); + /** * Specifies the ISO A5 size, 148 mm by 210 mm. */ public static final MediaSize A5 = new MediaSize(148, 210, Size2DSyntax.MM, MediaSizeName.ISO_A5); + /** * Specifies the ISO A6 size, 105 mm by 148 mm. */ public static final MediaSize A6 = new MediaSize(105, 148, Size2DSyntax.MM, MediaSizeName.ISO_A6); + /** * Specifies the ISO A7 size, 74 mm by 105 mm. */ public static final MediaSize A7 = new MediaSize(74, 105, Size2DSyntax.MM, MediaSizeName.ISO_A7); + /** * Specifies the ISO A8 size, 52 mm by 74 mm. */ public static final MediaSize A8 = new MediaSize(52, 74, Size2DSyntax.MM, MediaSizeName.ISO_A8); + /** * Specifies the ISO A9 size, 37 mm by 52 mm. */ public static final MediaSize A9 = new MediaSize(37, 52, Size2DSyntax.MM, MediaSizeName.ISO_A9); + /** * Specifies the ISO A10 size, 26 mm by 37 mm. */ public static final MediaSize A10 = new MediaSize(26, 37, Size2DSyntax.MM, MediaSizeName.ISO_A10); + /** * Specifies the ISO B0 size, 1000 mm by 1414 mm. */ public static final MediaSize B0 = new MediaSize(1000, 1414, Size2DSyntax.MM, MediaSizeName.ISO_B0); + /** * Specifies the ISO B1 size, 707 mm by 1000 mm. */ public static final MediaSize B1 = new MediaSize(707, 1000, Size2DSyntax.MM, MediaSizeName.ISO_B1); + /** * Specifies the ISO B2 size, 500 mm by 707 mm. */ public static final MediaSize B2 = new MediaSize(500, 707, Size2DSyntax.MM, MediaSizeName.ISO_B2); + /** * Specifies the ISO B3 size, 353 mm by 500 mm. */ public static final MediaSize B3 = new MediaSize(353, 500, Size2DSyntax.MM, MediaSizeName.ISO_B3); + /** * Specifies the ISO B4 size, 250 mm by 353 mm. */ public static final MediaSize B4 = new MediaSize(250, 353, Size2DSyntax.MM, MediaSizeName.ISO_B4); + /** * Specifies the ISO B5 size, 176 mm by 250 mm. */ public static final MediaSize B5 = new MediaSize(176, 250, Size2DSyntax.MM, MediaSizeName.ISO_B5); + /** * Specifies the ISO B6 size, 125 mm by 176 mm. */ public static final MediaSize B6 = new MediaSize(125, 176, Size2DSyntax.MM, MediaSizeName.ISO_B6); + /** * Specifies the ISO B7 size, 88 mm by 125 mm. */ public static final MediaSize B7 = new MediaSize(88, 125, Size2DSyntax.MM, MediaSizeName.ISO_B7); + /** * Specifies the ISO B8 size, 62 mm by 88 mm. */ public static final MediaSize B8 = new MediaSize(62, 88, Size2DSyntax.MM, MediaSizeName.ISO_B8); + /** * Specifies the ISO B9 size, 44 mm by 62 mm. */ public static final MediaSize B9 = new MediaSize(44, 62, Size2DSyntax.MM, MediaSizeName.ISO_B9); + /** * Specifies the ISO B10 size, 31 mm by 44 mm. */ public static final MediaSize B10 = new MediaSize(31, 44, Size2DSyntax.MM, MediaSizeName.ISO_B10); + /** * Specifies the ISO C3 size, 324 mm by 458 mm. */ public static final MediaSize C3 = new MediaSize(324, 458, Size2DSyntax.MM, MediaSizeName.ISO_C3); + /** * Specifies the ISO C4 size, 229 mm by 324 mm. */ public static final MediaSize C4 = new MediaSize(229, 324, Size2DSyntax.MM, MediaSizeName.ISO_C4); + /** * Specifies the ISO C5 size, 162 mm by 229 mm. */ public static final MediaSize C5 = new MediaSize(162, 229, Size2DSyntax.MM, MediaSizeName.ISO_C5); + /** * Specifies the ISO C6 size, 114 mm by 162 mm. */ public static final MediaSize C6 = new MediaSize(114, 162, Size2DSyntax.MM, MediaSizeName.ISO_C6); + /** * Specifies the ISO Designated Long size, 110 mm by 220 mm. */ @@ -434,8 +449,8 @@ public class MediaSize extends Size2DSyntax implements Attribute { } /** - * Class MediaSize.JIS includes {@link MediaSize MediaSize} values for JIS - * (Japanese) media. * + * Class {@code MediaSize.JIS} includes {@link MediaSize MediaSize} values + * for JIS (Japanese) media. */ public static final class JIS { @@ -444,152 +459,188 @@ public class MediaSize extends Size2DSyntax implements Attribute { */ public static final MediaSize B0 = new MediaSize(1030, 1456, Size2DSyntax.MM, MediaSizeName.JIS_B0); + /** * Specifies the JIS B1 size, 728 mm by 1030 mm. */ public static final MediaSize B1 = new MediaSize(728, 1030, Size2DSyntax.MM, MediaSizeName.JIS_B1); + /** * Specifies the JIS B2 size, 515 mm by 728 mm. */ public static final MediaSize B2 = new MediaSize(515, 728, Size2DSyntax.MM, MediaSizeName.JIS_B2); + /** * Specifies the JIS B3 size, 364 mm by 515 mm. */ public static final MediaSize B3 = new MediaSize(364, 515, Size2DSyntax.MM, MediaSizeName.JIS_B3); + /** * Specifies the JIS B4 size, 257 mm by 364 mm. */ public static final MediaSize B4 = new MediaSize(257, 364, Size2DSyntax.MM, MediaSizeName.JIS_B4); + /** * Specifies the JIS B5 size, 182 mm by 257 mm. */ public static final MediaSize B5 = new MediaSize(182, 257, Size2DSyntax.MM, MediaSizeName.JIS_B5); + /** * Specifies the JIS B6 size, 128 mm by 182 mm. */ public static final MediaSize B6 = new MediaSize(128, 182, Size2DSyntax.MM, MediaSizeName.JIS_B6); + /** * Specifies the JIS B7 size, 91 mm by 128 mm. */ public static final MediaSize B7 = new MediaSize(91, 128, Size2DSyntax.MM, MediaSizeName.JIS_B7); + /** * Specifies the JIS B8 size, 64 mm by 91 mm. */ public static final MediaSize B8 = new MediaSize(64, 91, Size2DSyntax.MM, MediaSizeName.JIS_B8); + /** * Specifies the JIS B9 size, 45 mm by 64 mm. */ public static final MediaSize B9 = new MediaSize(45, 64, Size2DSyntax.MM, MediaSizeName.JIS_B9); + /** * Specifies the JIS B10 size, 32 mm by 45 mm. */ public static final MediaSize B10 = new MediaSize(32, 45, Size2DSyntax.MM, MediaSizeName.JIS_B10); + /** * Specifies the JIS Chou ("long") #1 envelope size, 142 mm by 332 mm. */ public static final MediaSize CHOU_1 = new MediaSize(142, 332, Size2DSyntax.MM); + /** * Specifies the JIS Chou ("long") #2 envelope size, 119 mm by 277 mm. */ public static final MediaSize CHOU_2 = new MediaSize(119, 277, Size2DSyntax.MM); + /** * Specifies the JIS Chou ("long") #3 envelope size, 120 mm by 235 mm. */ public static final MediaSize CHOU_3 = new MediaSize(120, 235, Size2DSyntax.MM); + /** * Specifies the JIS Chou ("long") #4 envelope size, 90 mm by 205 mm. */ public static final MediaSize CHOU_4 = new MediaSize(90, 205, Size2DSyntax.MM); + /** * Specifies the JIS Chou ("long") #30 envelope size, 92 mm by 235 mm. */ public static final MediaSize CHOU_30 = new MediaSize(92, 235, Size2DSyntax.MM); + /** * Specifies the JIS Chou ("long") #40 envelope size, 90 mm by 225 mm. */ public static final MediaSize CHOU_40 = new MediaSize(90, 225, Size2DSyntax.MM); + /** * Specifies the JIS Kaku ("square") #0 envelope size, 287 mm by 382 mm. */ public static final MediaSize KAKU_0 = new MediaSize(287, 382, Size2DSyntax.MM); + /** * Specifies the JIS Kaku ("square") #1 envelope size, 270 mm by 382 mm. */ public static final MediaSize KAKU_1 = new MediaSize(270, 382, Size2DSyntax.MM); + /** * Specifies the JIS Kaku ("square") #2 envelope size, 240 mm by 332 mm. */ public static final MediaSize KAKU_2 = new MediaSize(240, 332, Size2DSyntax.MM); + /** * Specifies the JIS Kaku ("square") #3 envelope size, 216 mm by 277 mm. */ public static final MediaSize KAKU_3 = new MediaSize(216, 277, Size2DSyntax.MM); + /** * Specifies the JIS Kaku ("square") #4 envelope size, 197 mm by 267 mm. */ public static final MediaSize KAKU_4 = new MediaSize(197, 267, Size2DSyntax.MM); + /** * Specifies the JIS Kaku ("square") #5 envelope size, 190 mm by 240 mm. */ public static final MediaSize KAKU_5 = new MediaSize(190, 240, Size2DSyntax.MM); + /** * Specifies the JIS Kaku ("square") #6 envelope size, 162 mm by 229 mm. */ public static final MediaSize KAKU_6 = new MediaSize(162, 229, Size2DSyntax.MM); + /** * Specifies the JIS Kaku ("square") #7 envelope size, 142 mm by 205 mm. */ public static final MediaSize KAKU_7 = new MediaSize(142, 205, Size2DSyntax.MM); + /** * Specifies the JIS Kaku ("square") #8 envelope size, 119 mm by 197 mm. */ public static final MediaSize KAKU_8 = new MediaSize(119, 197, Size2DSyntax.MM); + /** - * Specifies the JIS Kaku ("square") #20 envelope size, 229 mm by 324 mm. + * Specifies the JIS Kaku ("square") #20 envelope size, 229 mm by 324 + * mm. */ public static final MediaSize KAKU_20 = new MediaSize(229, 324, Size2DSyntax.MM); + /** * Specifies the JIS Kaku ("square") A4 envelope size, 228 mm by 312 mm. */ public static final MediaSize KAKU_A4 = new MediaSize(228, 312, Size2DSyntax.MM); + /** * Specifies the JIS You ("Western") #1 envelope size, 120 mm by 176 mm. */ public static final MediaSize YOU_1 = new MediaSize(120, 176, Size2DSyntax.MM); + /** * Specifies the JIS You ("Western") #2 envelope size, 114 mm by 162 mm. */ public static final MediaSize YOU_2 = new MediaSize(114, 162, Size2DSyntax.MM); + /** * Specifies the JIS You ("Western") #3 envelope size, 98 mm by 148 mm. */ public static final MediaSize YOU_3 = new MediaSize(98, 148, Size2DSyntax.MM); + /** * Specifies the JIS You ("Western") #4 envelope size, 105 mm by 235 mm. */ public static final MediaSize YOU_4 = new MediaSize(105, 235, Size2DSyntax.MM); + /** * Specifies the JIS You ("Western") #5 envelope size, 95 mm by 217 mm. */ public static final MediaSize YOU_5 = new MediaSize(95, 217, Size2DSyntax.MM); + /** * Specifies the JIS You ("Western") #6 envelope size, 98 mm by 190 mm. */ public static final MediaSize YOU_6 = new MediaSize(98, 190, Size2DSyntax.MM); + /** * Specifies the JIS You ("Western") #7 envelope size, 92 mm by 165 mm. */ public static final MediaSize YOU_7 = new MediaSize(92, 165, Size2DSyntax.MM); + /** * Hide all constructors. */ @@ -598,8 +649,8 @@ public class MediaSize extends Size2DSyntax implements Attribute { } /** - * Class MediaSize.NA includes {@link MediaSize MediaSize} values for North - * American media. + * Class {@code MediaSize.NA} includes {@link MediaSize MediaSize} values + * for North American media. */ public static final class NA { @@ -609,59 +660,67 @@ public class MediaSize extends Size2DSyntax implements Attribute { public static final MediaSize LETTER = new MediaSize(8.5f, 11.0f, Size2DSyntax.INCH, MediaSizeName.NA_LETTER); + /** * Specifies the North American legal size, 8.5 inches by 14 inches. */ public static final MediaSize LEGAL = new MediaSize(8.5f, 14.0f, Size2DSyntax.INCH, MediaSizeName.NA_LEGAL); + /** * Specifies the North American 5 inch by 7 inch paper. */ public static final MediaSize NA_5X7 = new MediaSize(5, 7, Size2DSyntax.INCH, MediaSizeName.NA_5X7); + /** * Specifies the North American 8 inch by 10 inch paper. */ public static final MediaSize NA_8X10 = new MediaSize(8, 10, Size2DSyntax.INCH, MediaSizeName.NA_8X10); + /** - * Specifies the North American Number 9 business envelope size, - * 3.875 inches by 8.875 inches. + * Specifies the North American Number 9 business envelope size, 3.875 + * inches by 8.875 inches. */ public static final MediaSize NA_NUMBER_9_ENVELOPE = new MediaSize(3.875f, 8.875f, Size2DSyntax.INCH, MediaSizeName.NA_NUMBER_9_ENVELOPE); + /** - * Specifies the North American Number 10 business envelope size, - * 4.125 inches by 9.5 inches. + * Specifies the North American Number 10 business envelope size, 4.125 + * inches by 9.5 inches. */ public static final MediaSize NA_NUMBER_10_ENVELOPE = new MediaSize(4.125f, 9.5f, Size2DSyntax.INCH, MediaSizeName.NA_NUMBER_10_ENVELOPE); + /** - * Specifies the North American Number 11 business envelope size, - * 4.5 inches by 10.375 inches. + * Specifies the North American Number 11 business envelope size, 4.5 + * inches by 10.375 inches. */ public static final MediaSize NA_NUMBER_11_ENVELOPE = new MediaSize(4.5f, 10.375f, Size2DSyntax.INCH, MediaSizeName.NA_NUMBER_11_ENVELOPE); + /** - * Specifies the North American Number 12 business envelope size, - * 4.75 inches by 11 inches. + * Specifies the North American Number 12 business envelope size, 4.75 + * inches by 11 inches. */ public static final MediaSize NA_NUMBER_12_ENVELOPE = new MediaSize(4.75f, 11.0f, Size2DSyntax.INCH, MediaSizeName.NA_NUMBER_12_ENVELOPE); + /** - * Specifies the North American Number 14 business envelope size, - * 5 inches by 11.5 inches. + * Specifies the North American Number 14 business envelope size, 5 + * inches by 11.5 inches. */ public static final MediaSize NA_NUMBER_14_ENVELOPE = @@ -674,42 +733,49 @@ public class MediaSize extends Size2DSyntax implements Attribute { public static final MediaSize NA_6X9_ENVELOPE = new MediaSize(6.0f, 9.0f, Size2DSyntax.INCH, MediaSizeName.NA_6X9_ENVELOPE); + /** * Specifies the North American 7 inch by 9 inch envelope size. */ public static final MediaSize NA_7X9_ENVELOPE = new MediaSize(7.0f, 9.0f, Size2DSyntax.INCH, MediaSizeName.NA_7X9_ENVELOPE); + /** * Specifies the North American 9 inch by 11 inch envelope size. */ public static final MediaSize NA_9x11_ENVELOPE = new MediaSize(9.0f, 11.0f, Size2DSyntax.INCH, MediaSizeName.NA_9X11_ENVELOPE); + /** * Specifies the North American 9 inch by 12 inch envelope size. */ public static final MediaSize NA_9x12_ENVELOPE = new MediaSize(9.0f, 12.0f, Size2DSyntax.INCH, MediaSizeName.NA_9X12_ENVELOPE); + /** * Specifies the North American 10 inch by 13 inch envelope size. */ public static final MediaSize NA_10x13_ENVELOPE = new MediaSize(10.0f, 13.0f, Size2DSyntax.INCH, MediaSizeName.NA_10X13_ENVELOPE); + /** * Specifies the North American 10 inch by 14 inch envelope size. */ public static final MediaSize NA_10x14_ENVELOPE = new MediaSize(10.0f, 14.0f, Size2DSyntax.INCH, MediaSizeName.NA_10X14_ENVELOPE); + /** * Specifies the North American 10 inch by 15 inch envelope size. */ public static final MediaSize NA_10X15_ENVELOPE = new MediaSize(10.0f, 15.0f, Size2DSyntax.INCH, MediaSizeName.NA_10X15_ENVELOPE); + /** * Hide all constructors. */ @@ -718,8 +784,8 @@ public class MediaSize extends Size2DSyntax implements Attribute { } /** - * Class MediaSize.Engineering includes {@link MediaSize MediaSize} values - * for engineering media. + * Class {@code MediaSize.Engineering} includes {@link MediaSize MediaSize} + * values for engineering media. */ public static final class Engineering { @@ -729,30 +795,35 @@ public class MediaSize extends Size2DSyntax implements Attribute { public static final MediaSize A = new MediaSize(8.5f, 11.0f, Size2DSyntax.INCH, MediaSizeName.A); + /** * Specifies the engineering B size, 11 inch by 17 inch. */ public static final MediaSize B = new MediaSize(11.0f, 17.0f, Size2DSyntax.INCH, MediaSizeName.B); + /** * Specifies the engineering C size, 17 inch by 22 inch. */ public static final MediaSize C = new MediaSize(17.0f, 22.0f, Size2DSyntax.INCH, MediaSizeName.C); + /** * Specifies the engineering D size, 22 inch by 34 inch. */ public static final MediaSize D = new MediaSize(22.0f, 34.0f, Size2DSyntax.INCH, MediaSizeName.D); + /** * Specifies the engineering E size, 34 inch by 44 inch. */ public static final MediaSize E = new MediaSize(34.0f, 44.0f, Size2DSyntax.INCH, MediaSizeName.E); + /** * Hide all constructors. */ @@ -761,16 +832,18 @@ public class MediaSize extends Size2DSyntax implements Attribute { } /** - * Class MediaSize.Other includes {@link MediaSize MediaSize} values for - * miscellaneous media. + * Class {@code MediaSize.Other} includes {@link MediaSize MediaSize} values + * for miscellaneous media. */ public static final class Other { + /** * Specifies the executive size, 7.25 inches by 10.5 inches. */ public static final MediaSize EXECUTIVE = new MediaSize(7.25f, 10.5f, Size2DSyntax.INCH, MediaSizeName.EXECUTIVE); + /** * Specifies the ledger size, 11 inches by 17 inches. */ @@ -780,6 +853,7 @@ public class MediaSize extends Size2DSyntax implements Attribute { /** * Specifies the tabloid size, 11 inches by 17 inches. + * * @since 1.5 */ public static final MediaSize @@ -792,48 +866,56 @@ public class MediaSize extends Size2DSyntax implements Attribute { public static final MediaSize INVOICE = new MediaSize(5.5f, 8.5f, Size2DSyntax.INCH, MediaSizeName.INVOICE); + /** * Specifies the folio size, 8.5 inches by 13 inches. */ public static final MediaSize FOLIO = new MediaSize(8.5f, 13.0f, Size2DSyntax.INCH, MediaSizeName.FOLIO); + /** * Specifies the quarto size, 8.5 inches by 10.83 inches. */ public static final MediaSize QUARTO = new MediaSize(8.5f, 10.83f, Size2DSyntax.INCH, MediaSizeName.QUARTO); + /** * Specifies the Italy envelope size, 110 mm by 230 mm. */ public static final MediaSize ITALY_ENVELOPE = new MediaSize(110, 230, Size2DSyntax.MM, MediaSizeName.ITALY_ENVELOPE); + /** * Specifies the Monarch envelope size, 3.87 inch by 7.5 inch. */ public static final MediaSize MONARCH_ENVELOPE = new MediaSize(3.87f, 7.5f, Size2DSyntax.INCH, MediaSizeName.MONARCH_ENVELOPE); + /** * Specifies the Personal envelope size, 3.625 inch by 6.5 inch. */ public static final MediaSize PERSONAL_ENVELOPE = new MediaSize(3.625f, 6.5f, Size2DSyntax.INCH, MediaSizeName.PERSONAL_ENVELOPE); + /** * Specifies the Japanese postcard size, 100 mm by 148 mm. */ public static final MediaSize JAPANESE_POSTCARD = new MediaSize(100, 148, Size2DSyntax.MM, MediaSizeName.JAPANESE_POSTCARD); + /** * Specifies the Japanese Double postcard size, 148 mm by 200 mm. */ public static final MediaSize JAPANESE_DOUBLE_POSTCARD = new MediaSize(148, 200, Size2DSyntax.MM, MediaSizeName.JAPANESE_DOUBLE_POSTCARD); + /** * Hide all constructors. */ @@ -841,8 +923,9 @@ public class MediaSize extends Size2DSyntax implements Attribute { } } - /* force loading of all the subclasses so that the instances - * are created and inserted into the hashmap. + /* + * force loading of all the subclasses so that the instances are created and + * inserted into the hashmap. */ static { MediaSize ISOA4 = ISO.A4; diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSizeName.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSizeName.java index bbb266ba891..136f4287378 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSizeName.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaSizeName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,161 +22,192 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; -import java.util.Locale; - import javax.print.attribute.EnumSyntax; -import javax.print.attribute.Attribute; /** - * Class MediaSizeName is a subclass of Media. - *

- * This attribute can be used instead of specifying MediaName or MediaTray. + * Class {@code MediaSizeName} is a subclass of {@code Media}. *

- * Class MediaSizeName currently declares a few standard media - * name values. - *

- * IPP Compatibility: MediaSizeName is a representation class for - * values of the IPP "media" attribute which names media sizes. - * The names of the media sizes correspond to those in the IPP 1.1 RFC - * RFC 2911 - * + * This attribute can be used instead of specifying {@code MediaName} or + * {@code MediaTray}. + *

+ * Class {@code MediaSizeName} currently declares a few standard media name + * values. + *

+ * IPP Compatibility: {@code MediaSizeName} is a representation class for + * values of the IPP "media" attribute which names media sizes. The names of the + * media sizes correspond to those in the IPP 1.1 RFC + * RFC 2911 */ public class MediaSizeName extends Media { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 2778798329756942747L; /** * A0 size. */ public static final MediaSizeName ISO_A0 = new MediaSizeName(0); + /** * A1 size. */ public static final MediaSizeName ISO_A1 = new MediaSizeName(1); + /** * A2 size. */ public static final MediaSizeName ISO_A2 = new MediaSizeName(2); + /** * A3 size. */ public static final MediaSizeName ISO_A3 = new MediaSizeName(3); + /** * A4 size. */ public static final MediaSizeName ISO_A4 = new MediaSizeName(4); + /** * A5 size. */ public static final MediaSizeName ISO_A5 = new MediaSizeName(5); + /** * A6 size. */ public static final MediaSizeName ISO_A6 = new MediaSizeName(6); + /** * A7 size. */ public static final MediaSizeName ISO_A7 = new MediaSizeName(7); + /** * A8 size. */ public static final MediaSizeName ISO_A8 = new MediaSizeName(8); + /** * A9 size. */ public static final MediaSizeName ISO_A9 = new MediaSizeName(9); + /** * A10 size. */ public static final MediaSizeName ISO_A10 = new MediaSizeName(10); - /** + /** * ISO B0 size. */ public static final MediaSizeName ISO_B0 = new MediaSizeName(11); + /** * ISO B1 size. */ public static final MediaSizeName ISO_B1 = new MediaSizeName(12); + /** * ISO B2 size. */ public static final MediaSizeName ISO_B2 = new MediaSizeName(13); + /** * ISO B3 size. */ public static final MediaSizeName ISO_B3 = new MediaSizeName(14); + /** * ISO B4 size. */ public static final MediaSizeName ISO_B4 = new MediaSizeName(15); + /** * ISO B5 size. */ public static final MediaSizeName ISO_B5 = new MediaSizeName(16); + /** * ISO B6 size. */ public static final MediaSizeName ISO_B6 = new MediaSizeName(17); + /** * ISO B7 size. */ public static final MediaSizeName ISO_B7 = new MediaSizeName(18); + /** * ISO B8 size. */ public static final MediaSizeName ISO_B8 = new MediaSizeName(19); + /** * ISO B9 size. */ public static final MediaSizeName ISO_B9 = new MediaSizeName(20); + /** * ISO B10 size. */ public static final MediaSizeName ISO_B10 = new MediaSizeName(21); - /** + /** * JIS B0 size. */ public static final MediaSizeName JIS_B0 = new MediaSizeName(22); + /** * JIS B1 size. */ public static final MediaSizeName JIS_B1 = new MediaSizeName(23); + /** * JIS B2 size. */ public static final MediaSizeName JIS_B2 = new MediaSizeName(24); + /** * JIS B3 size. */ public static final MediaSizeName JIS_B3 = new MediaSizeName(25); + /** * JIS B4 size. */ public static final MediaSizeName JIS_B4 = new MediaSizeName(26); + /** * JIS B5 size. */ public static final MediaSizeName JIS_B5 = new MediaSizeName(27); + /** * JIS B6 size. */ public static final MediaSizeName JIS_B6 = new MediaSizeName(28); + /** * JIS B7 size. */ public static final MediaSizeName JIS_B7 = new MediaSizeName(29); + /** * JIS B8 size. */ public static final MediaSizeName JIS_B8 = new MediaSizeName(30); + /** * JIS B9 size. */ public static final MediaSizeName JIS_B9 = new MediaSizeName(31); + /** * JIS B10 size. */ @@ -186,198 +217,216 @@ public class MediaSizeName extends Media { * ISO C0 size. */ public static final MediaSizeName ISO_C0 = new MediaSizeName(33); + /** * ISO C1 size. */ public static final MediaSizeName ISO_C1 = new MediaSizeName(34); + /** * ISO C2 size. */ public static final MediaSizeName ISO_C2 = new MediaSizeName(35); + /** * ISO C3 size. */ public static final MediaSizeName ISO_C3 = new MediaSizeName(36); + /** * ISO C4 size. */ public static final MediaSizeName ISO_C4 = new MediaSizeName(37); + /** * ISO C5 size. */ public static final MediaSizeName ISO_C5 = new MediaSizeName(38); + /** - * letter size. + * letter size. */ public static final MediaSizeName ISO_C6 = new MediaSizeName(39); + /** - * letter size. + * letter size. */ public static final MediaSizeName NA_LETTER = new MediaSizeName(40); /** - * legal size . + * legal size. */ public static final MediaSizeName NA_LEGAL = new MediaSizeName(41); /** - * executive size . + * executive size. */ public static final MediaSizeName EXECUTIVE = new MediaSizeName(42); /** - * ledger size . + * ledger size. */ public static final MediaSizeName LEDGER = new MediaSizeName(43); /** - * tabloid size . + * tabloid size. */ public static final MediaSizeName TABLOID = new MediaSizeName(44); /** - * invoice size . + * invoice size. */ public static final MediaSizeName INVOICE = new MediaSizeName(45); /** - * folio size . + * folio size. */ public static final MediaSizeName FOLIO = new MediaSizeName(46); /** - * quarto size . + * quarto size. */ public static final MediaSizeName QUARTO = new MediaSizeName(47); /** - * Japanese Postcard size. + * Japanese Postcard size. */ public static final MediaSizeName JAPANESE_POSTCARD = new MediaSizeName(48); - /** - * Japanese Double Postcard size. + + /** + * Japanese Double Postcard size. */ public static final MediaSizeName JAPANESE_DOUBLE_POSTCARD = new MediaSizeName(49); /** - * A size . + * A size. */ public static final MediaSizeName A = new MediaSizeName(50); /** - * B size . + * B size. */ public static final MediaSizeName B = new MediaSizeName(51); /** - * C size . + * C size. */ public static final MediaSizeName C = new MediaSizeName(52); /** - * D size . + * D size. */ public static final MediaSizeName D = new MediaSizeName(53); /** - * E size . + * E size. */ public static final MediaSizeName E = new MediaSizeName(54); /** - * ISO designated long size . + * ISO designated long size. */ public static final MediaSizeName ISO_DESIGNATED_LONG = new MediaSizeName(55); /** - * Italy envelope size . + * Italy envelope size. */ public static final MediaSizeName ITALY_ENVELOPE = new MediaSizeName(56); // DESIGNATED_LONG? /** - * monarch envelope size . + * monarch envelope size. */ public static final MediaSizeName MONARCH_ENVELOPE = new MediaSizeName(57); + /** - * personal envelope size . + * personal envelope size. */ public static final MediaSizeName PERSONAL_ENVELOPE = new MediaSizeName(58); + /** - * number 9 envelope size . + * number 9 envelope size. */ public static final MediaSizeName NA_NUMBER_9_ENVELOPE = new MediaSizeName(59); + /** - * number 10 envelope size . + * number 10 envelope size. */ public static final MediaSizeName NA_NUMBER_10_ENVELOPE = new MediaSizeName(60); + /** - * number 11 envelope size . + * number 11 envelope size. */ public static final MediaSizeName NA_NUMBER_11_ENVELOPE = new MediaSizeName(61); + /** - * number 12 envelope size . + * number 12 envelope size. */ public static final MediaSizeName NA_NUMBER_12_ENVELOPE = new MediaSizeName(62); + /** - * number 14 envelope size . + * number 14 envelope size. */ public static final MediaSizeName NA_NUMBER_14_ENVELOPE = new MediaSizeName(63); - /** - * 6x9 North American envelope size. + + /** + * 6x9 North American envelope size. */ public static final MediaSizeName NA_6X9_ENVELOPE = new MediaSizeName(64); - /** - * 7x9 North American envelope size. + + /** + * 7x9 North American envelope size. */ public static final MediaSizeName NA_7X9_ENVELOPE = new MediaSizeName(65); - /** - * 9x11 North American envelope size. + + /** + * 9x11 North American envelope size. */ public static final MediaSizeName NA_9X11_ENVELOPE = new MediaSizeName(66); + /** - * 9x12 North American envelope size. + * 9x12 North American envelope size. */ public static final MediaSizeName NA_9X12_ENVELOPE = new MediaSizeName(67); /** - * 10x13 North American envelope size . + * 10x13 North American envelope size. */ public static final MediaSizeName NA_10X13_ENVELOPE = new MediaSizeName(68); /** - * 10x14North American envelope size . + * 10x14North American envelope size. */ public static final MediaSizeName NA_10X14_ENVELOPE = new MediaSizeName(69); /** - * 10x15 North American envelope size. + * 10x15 North American envelope size. */ public static final MediaSizeName NA_10X15_ENVELOPE = new MediaSizeName(70); /** - * 5x7 North American paper. + * 5x7 North American paper. */ public static final MediaSizeName NA_5X7 = new MediaSizeName(71); /** - * 8x10 North American paper. + * 8x10 North American paper. */ public static final MediaSizeName NA_8X10 = new MediaSizeName(72); @@ -386,12 +435,15 @@ public class MediaSizeName extends Media { * Construct a new media size enumeration value with the given integer * value. * - * @param value Integer value. + * @param value Integer value */ protected MediaSizeName(int value) { super (value); } + /** + * The string table for class {@code MediaSizeName}. + */ private static final String[] myStringTable = { "iso-a0", "iso-a1", @@ -468,6 +520,9 @@ public class MediaSizeName extends Media { "na-8x10", }; + /** + * The enumeration value table for class {@code MediaSizeName}. + */ private static final MediaSizeName[] myEnumValueTable = { ISO_A0, ISO_A1, @@ -544,9 +599,8 @@ public class MediaSizeName extends Media { NA_8X10, }; - /** - * Returns the string table for class MediaSizeName. + * Returns the string table for class {@code MediaSizeName}. */ protected String[] getStringTable() { @@ -554,11 +608,9 @@ public class MediaSizeName extends Media { } /** - * Returns the enumeration value table for class MediaSizeName. + * Returns the enumeration value table for class {@code MediaSizeName}. */ protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } - - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaTray.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaTray.java index 9a4da0a408e..7201242385a 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaTray.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MediaTray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,29 +22,30 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package javax.print.attribute.standard; -import java.util.Locale; +package javax.print.attribute.standard; import javax.print.attribute.Attribute; import javax.print.attribute.EnumSyntax; - /** - * Class MediaTray is a subclass of Media. - * Class MediaTray is a printing attribute class, an enumeration, that - * specifies the media tray or bin for the job. - * This attribute can be used instead of specifying MediaSize or MediaName. + * Class {@code MediaTray} is a subclass of {@code Media}. Class + * {@code MediaTray} is a printing attribute class, an enumeration, that + * specifies the media tray or bin for the job. This attribute can be used + * instead of specifying {@code MediaSize} or {@code MediaName}. *

- * Class MediaTray declares keywords for standard media kind values. - * Implementation- or site-defined names for a media kind attribute may also - * be created by defining a subclass of class MediaTray. - *

- * IPP Compatibility: MediaTray is a representation class for + * Class {@code MediaTray} declares keywords for standard media kind values. + * Implementation- or site-defined names for a media kind attribute may also be + * created by defining a subclass of class {@code MediaTray}. + *

+ * IPP Compatibility: {@code MediaTray} is a representation class for * values of the IPP "media" attribute which name paper trays. */ public class MediaTray extends Media implements Attribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -982503611095214703L; /** @@ -91,12 +92,15 @@ public class MediaTray extends Media implements Attribute { * Construct a new media tray enumeration value with the given integer * value. * - * @param value Integer value. + * @param value Integer value */ protected MediaTray(int value) { super (value); } + /** + * The string table for class {@code MediaTray}. + */ private static final String[] myStringTable ={ "top", "middle", @@ -108,6 +112,9 @@ public class MediaTray extends Media implements Attribute { "side" }; + /** + * The enumeration value table for class {@code MediaTray}. + */ private static final MediaTray[] myEnumValueTable = { TOP, MIDDLE, @@ -120,7 +127,7 @@ public class MediaTray extends Media implements Attribute { }; /** - * Returns the string table for class MediaTray. + * Returns the string table for class {@code MediaTray}. */ protected String[] getStringTable() { @@ -128,11 +135,9 @@ public class MediaTray extends Media implements Attribute { } /** - * Returns the enumeration value table for class MediaTray. + * Returns the enumeration value table for class {@code MediaTray}. */ protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } - - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java index 86a84de83d0..03ec3630934 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java @@ -22,178 +22,162 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; import javax.print.attribute.EnumSyntax; -import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class MultipleDocumentHandling is a printing attribute class, an enumeration, - * that controls finishing operations and the placement of one or more - * print-stream pages into impressions and onto media sheets. When the value of - * the {@link Copies Copies} attribute exceeds 1, MultipleDocumentHandling also - * controls the order in which the copies that result from processing the - * documents are produced. This attribute is relevant only for a multidoc print - * job consisting of two or more individual docs. - *

- * Briefly, MultipleDocumentHandling determines the relationship between the - * multiple input (electronic) documents fed into a multidoc print job and the - * output (physical) document or documents produced by the multidoc print job. + * Class {@code MultipleDocumentHandling} is a printing attribute class, an + * enumeration, that controls finishing operations and the placement of one or + * more print-stream pages into impressions and onto media sheets. When the + * value of the {@link Copies Copies} attribute exceeds 1, + * {@code MultipleDocumentHandling} also controls the order in which the copies + * that result from processing the documents are produced. This attribute is + * relevant only for a multidoc print job consisting of two or more individual + * docs. + *

+ * Briefly, {@code MultipleDocumentHandling} determines the relationship between + * the multiple input (electronic) documents fed into a multidoc print job and + * the output (physical) document or documents produced by the multidoc print + * job. * There are two possibilities: - *

    - *
  • - * The multiple input documents are combined into a single output document. - * Finishing operations ({@link Finishings Finishings}), - * are performed on this single output - * document. The {@link Copies Copies} attribute tells how many copies of this - * single output document to produce. The MultipleDocumentHandling values - * SINGLE_DOCUMENT and SINGLE_DOCUMENT_NEW_SHEET specify two variations of - * this possibility. - * - *
  • - * The multiple input documents remain separate output documents. Finishing - * operations ({@link Finishings Finishings}), - * are performed on each output document - * separately. The {@link Copies Copies} attribute tells how many copies of each - * separate output document to produce. The MultipleDocumentHandling values - * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES and SEPARATE_DOCUMENTS_COLLATED_COPIES - * specify two variations of this possibility. - *
- *

- * In the detailed explanations below, if "{@code a}" represents an - * instance of document data, then the result of processing the data in - * document "{@code a}" is a sequence of media sheets represented by - * "{@code a(*)}". - *

- * The standard MultipleDocumentHandling values are: - *

    - *
  • - * {@link #SINGLE_DOCUMENT - * SINGLE_DOCUMENT}. If a print job has multiple - * documents -- say, the document data is called {@code a} and - * {@code b} -- then the result of processing all the document data - * ({@code a} and then {@code b}) must be treated as a single sequence - * of media sheets for finishing operations; that is, finishing would be - * performed on the concatenation of the sequences {@code a(*),b(*)}. The - * printer must not force the data in each document instance to be formatted - * onto a new print-stream page, nor to start a new impression on a new media - * sheet. If more than one copy is made, the ordering of the sets of media - * sheets resulting from processing the document data must be - * {@code a(*),b(*),a(*),b(*),...}, and the printer object must force - * each copy ({@code a(*),b(*)}) to start on a new media sheet. - * - *
  • - * {@link #SEPARATE_DOCUMENTS_UNCOLLATED_COPIES - * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES}. If a print job - * has multiple documents -- say, the document data is called {@code a} and - * {@code b} -- then the result of processing the data in each document - * instance must be treated as a single sequence of media sheets for finishing - * operations; that is, the sets {@code a(*)} and {@code b(*)} would - * each be finished separately. The printer must force each copy of the result - * of processing the data in a single document to start on a new media sheet. - * If more than one copy is made, the ordering of the sets of media sheets - * resulting from processing the document data must be - * {@code a(*),a(*),...,b(*),b(*)...}. - * - *
  • - * {@link #SEPARATE_DOCUMENTS_COLLATED_COPIES - * SEPARATE_DOCUMENTS_COLLATED_COPIES}. If a print job - * has multiple documents -- say, the document data is called {@code a} and - * {@code b} -- then the result of processing the data in each document - * instance must be treated as a single sequence of media sheets for finishing - * operations; that is, the sets {@code a(*)} and {@code b(*)} would - * each be finished separately. The printer must force each copy of the result - * of processing the data in a single document to start on a new media sheet. - * If more than one copy is made, the ordering of the sets of media sheets - * resulting from processing the document data must be - * {@code a(*),b(*),a(*),b(*),...}. - * - *
  • - * {@link #SINGLE_DOCUMENT_NEW_SHEET - * SINGLE_DOCUMENT_NEW_SHEET}. Same as SINGLE_DOCUMENT, - * except that the printer must ensure that the first impression of each - * document instance in the job is placed on a new media sheet. This value - * allows multiple documents to be stapled together with a single staple where - * each document starts on a new sheet. - *
- *

- * SINGLE_DOCUMENT is the same as SEPARATE_DOCUMENTS_COLLATED_COPIES with - * respect to ordering of print-stream pages, but not media sheet generation, - * since SINGLE_DOCUMENT will put the first page of the next document on the - * back side of a sheet if an odd number of pages have been produced so far - * for the job, while SEPARATE_DOCUMENTS_COLLATED_COPIES always forces the + *

    + *
  • The multiple input documents are combined into a single output + * document. Finishing operations ({@link Finishings Finishings}), are + * performed on this single output document. The {@link Copies Copies} + * attribute tells how many copies of this single output document to produce. + * The {@code MultipleDocumentHandling} values {@code SINGLE_DOCUMENT} and + * {@code SINGLE_DOCUMENT_NEW_SHEET} specify two variations of this + * possibility. + *
  • The multiple input documents remain separate output documents. + * Finishing operations ({@link Finishings Finishings}), are performed on each + * output document separately. The {@link Copies Copies} attribute tells how + * many copies of each separate output document to produce. The + * {@code MultipleDocumentHandling} values + * {@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} and + * {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} specify two variations of this + * possibility. + *
+ * In the detailed explanations below, if "{@code a}" represents an instance of + * document data, then the result of processing the data in document "{@code a}" + * is a sequence of media sheets represented by "{@code a(*)}". + *

+ * The standard {@code MultipleDocumentHandling} values are: + *

    + *
  • {@link #SINGLE_DOCUMENT SINGLE_DOCUMENT}. If a + * print job has multiple documents -- say, the document data is called + * {@code a} and {@code b} -- then the result of processing all the document + * data ({@code a} and then {@code b}) must be treated as a single sequence of + * media sheets for finishing operations; that is, finishing would be + * performed on the concatenation of the sequences {@code a(*),b(*)}. The + * printer must not force the data in each document instance to be formatted + * onto a new print-stream page, nor to start a new impression on a new media + * sheet. If more than one copy is made, the ordering of the sets of media + * sheets resulting from processing the document data must be + * {@code a(*),b(*),a(*),b(*),...}, and the printer object must force each + * copy ({@code a(*),b(*)}) to start on a new media sheet. + *
  • {@link #SEPARATE_DOCUMENTS_UNCOLLATED_COPIES + * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES}. If a print job has multiple + * documents -- say, the document data is called {@code a} and {@code b} -- + * then the result of processing the data in each document instance must be + * treated as a single sequence of media sheets for finishing operations; that + * is, the sets {@code a(*)} and {@code b(*)} would each be finished + * separately. The printer must force each copy of the result of processing + * the data in a single document to start on a new media sheet. If more than + * one copy is made, the ordering of the sets of media sheets resulting from + * processing the document data must be {@code a(*),a(*),...,b(*),b(*)...}. + *
  • {@link #SEPARATE_DOCUMENTS_COLLATED_COPIES + * SEPARATE_DOCUMENTS_COLLATED_COPIES}. If a print job has multiple + * documents -- say, the document data is called {@code a} and {@code b} -- + * then the result of processing the data in each document instance must be + * treated as a single sequence of media sheets for finishing operations; that + * is, the sets {@code a(*)} and {@code b(*)} would each be finished + * separately. The printer must force each copy of the result of processing + * the data in a single document to start on a new media sheet. If more than + * one copy is made, the ordering of the sets of media sheets resulting from + * processing the document data must be {@code a(*),b(*),a(*),b(*),...}. + *
  • {@link #SINGLE_DOCUMENT_NEW_SHEET + * SINGLE_DOCUMENT_NEW_SHEET}. Same as SINGLE_DOCUMENT, except that the + * printer must ensure that the first impression of each document instance in + * the job is placed on a new media sheet. This value allows multiple + * documents to be stapled together with a single staple where each document + * starts on a new sheet. + *
+ *

+ * {@code SINGLE_DOCUMENT} is the same as + * {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} with respect to ordering of + * print-stream pages, but not media sheet generation, since + * {@code SINGLE_DOCUMENT} will put the first page of the next document on the + * back side of a sheet if an odd number of pages have been produced so far for + * the job, while {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} always forces the * next document or document copy on to a new sheet. - *

+ *

* In addition, if a {@link Finishings Finishings} attribute of * {@link Finishings#STAPLE STAPLE} is specified, then: - *

    - *
  • - * With SINGLE_DOCUMENT, documents {@code a} and {@code b} are - * stapled together as a single document with no regard to new sheets. + *
      + *
    • With {@code SINGLE_DOCUMENT}, documents {@code a} and {@code b} are + * stapled together as a single document with no regard to new sheets. + *
    • With {@code SINGLE_DOCUMENT_NEW_SHEET}, documents {@code a} and + * {@code b} are stapled together as a single document, but document {@code b} + * starts on a new sheet. + *
    • With {@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} and + * {@code SEPARATE_DOCUMENTS_COLLATED_COPIES}, documents {@code a} and + * {@code b} are stapled separately. + *
    + * Note: None of these values provide means to produce uncollated sheets + * within a document, i.e., where multiple copies of sheet n are produced + * before sheet n+1 of the same document. To specify that, see the + * {@link SheetCollate SheetCollate} attribute. + *

    + * IPP Compatibility: The category name returned by {@code getName()} is + * the IPP attribute name. The enumeration's integer value is the IPP enum + * value. The {@code toString()} method returns the IPP string representation of + * the attribute value. * - *

  • - * With SINGLE_DOCUMENT_NEW_SHEET, documents {@code a} and {@code b} - * are stapled together as a single document, but document {@code b} - * starts on a new sheet. - * - *
  • - * With SEPARATE_DOCUMENTS_UNCOLLATED_COPIES and - * SEPARATE_DOCUMENTS_COLLATED_COPIES, documents {@code a} and - * {@code b} are stapled separately. - *
- *

- * Note: None of these values provide means to produce uncollated - * sheets within a document, i.e., where multiple copies of sheet n - * are produced before sheet n+1 of the same document. - * To specify that, see the {@link SheetCollate SheetCollate} attribute. - *

- * IPP Compatibility: The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. - * - * @see Copies - * @see Finishings - * @see NumberUp - * @see PageRanges - * @see SheetCollate - * @see Sides - * - * @author David Mendenhall - * @author Alan Kaminsky + * @author David Mendenhall + * @author Alan Kaminsky + * @see Copies + * @see Finishings + * @see NumberUp + * @see PageRanges + * @see SheetCollate + * @see Sides */ public class MultipleDocumentHandling extends EnumSyntax implements PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 8098326460746413466L; - /** - * Single document -- see above for further - * information. + * Single document -- see above for further information. */ public static final MultipleDocumentHandling SINGLE_DOCUMENT = new MultipleDocumentHandling (0); /** * Separate documents uncollated copies -- see above for - * further information. + * further information. */ public static final MultipleDocumentHandling SEPARATE_DOCUMENTS_UNCOLLATED_COPIES = new MultipleDocumentHandling (1); /** * Separate documents collated copies -- see above for - * further information. + * further information. */ public static final MultipleDocumentHandling SEPARATE_DOCUMENTS_COLLATED_COPIES = new MultipleDocumentHandling (2); /** - * Single document new sheet -- see above for - * further information. + * Single document new sheet -- see above for further + * information. */ public static final MultipleDocumentHandling SINGLE_DOCUMENT_NEW_SHEET = new MultipleDocumentHandling (3); @@ -203,12 +187,15 @@ public class MultipleDocumentHandling extends EnumSyntax * Construct a new multiple document handling enumeration value with the * given integer value. * - * @param value Integer value. + * @param value Integer value */ protected MultipleDocumentHandling(int value) { super (value); } + /** + * The string table for class {@code MultipleDocumentHandling}. + */ private static final String[] myStringTable = { "single-document", "separate-documents-uncollated-copies", @@ -216,6 +203,9 @@ public class MultipleDocumentHandling extends EnumSyntax "single-document-new-sheet" }; + /** + * The enumeration value table for class {@code MultipleDocumentHandling}. + */ private static final MultipleDocumentHandling[] myEnumValueTable = { SINGLE_DOCUMENT, SEPARATE_DOCUMENTS_UNCOLLATED_COPIES, @@ -224,14 +214,15 @@ public class MultipleDocumentHandling extends EnumSyntax }; /** - * Returns the string table for class MultipleDocumentHandling. + * Returns the string table for class {@code MultipleDocumentHandling}. */ protected String[] getStringTable() { return myStringTable.clone(); } /** - * Returns the enumeration value table for class MultipleDocumentHandling. + * Returns the enumeration value table for class + * {@code MultipleDocumentHandling}. */ protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); @@ -240,12 +231,13 @@ public class MultipleDocumentHandling extends EnumSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class MultipleDocumentHandling and any vendor-defined subclasses, - * the category is class MultipleDocumentHandling itself. + *

+ * For class {@code MultipleDocumentHandling} and any vendor-defined + * subclasses, the category is class {@code MultipleDocumentHandling} + * itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return MultipleDocumentHandling.class; @@ -254,14 +246,13 @@ public class MultipleDocumentHandling extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class MultipleDocumentHandling and any vendor-defined subclasses, - * the category name is {@code "multiple-document-handling"}. + *

+ * For class {@code MultipleDocumentHandling} and any vendor-defined + * subclasses, the category name is {@code "multiple-document-handling"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "multiple-document-handling"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfDocuments.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfDocuments.java index 50e0b10b7c9..5fa7fc859ae 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfDocuments.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfDocuments.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,31 +30,30 @@ import javax.print.attribute.IntegerSyntax; import javax.print.attribute.PrintJobAttribute; /** - * Class NumberOfDocuments is an integer valued printing attribute that + * Class {@code NumberOfDocuments} is an integer valued printing attribute that * indicates the number of individual docs the printer has accepted for this * job, regardless of whether the docs' print data has reached the printer or * not. - *

- * IPP Compatibility: The integer value gives the IPP integer value. The - * category name returned by {@code getName()} gives the IPP attribute - * name. + *

+ * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class NumberOfDocuments extends IntegerSyntax implements PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 7891881310684461097L; - /** * Construct a new number of documents attribute with the given integer * value. * - * @param value Integer value. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 0. + * @param value Integer value + * @throws IllegalArgumentException if {@code value} is negative */ public NumberOfDocuments(int value) { super (value, 0, Integer.MAX_VALUE); @@ -61,22 +61,18 @@ public final class NumberOfDocuments extends IntegerSyntax /** * Returns whether this number of documents attribute is equivalent to the - * passed in object. To be equivalent, all of the following conditions - * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class NumberOfDocuments. - *
  3. - * This number of documents attribute's value and {@code object}'s - * value are equal. - *
+ * passed in object. To be equivalent, all of the following conditions must + * be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code NumberOfDocuments}. + *
  3. This number of documents attribute's value and {@code object}'s + * value are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this number of - * documents attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this number of + * documents attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && @@ -86,12 +82,12 @@ public final class NumberOfDocuments extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class NumberOfDocuments, the - * category is class NumberOfDocuments itself. + *

+ * For class {@code NumberOfDocuments}, the category is class + * {@code NumberOfDocuments} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return NumberOfDocuments.class; @@ -100,14 +96,13 @@ public final class NumberOfDocuments extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class NumberOfDocuments, the - * category name is {@code "number-of-documents"}. + *

+ * For class {@code NumberOfDocuments}, the category name is + * {@code "number-of-documents"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "number-of-documents"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfInterveningJobs.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfInterveningJobs.java index 0a01f090bf3..6ca19438c65 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfInterveningJobs.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberOfInterveningJobs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,30 +30,30 @@ import javax.print.attribute.IntegerSyntax; import javax.print.attribute.PrintJobAttribute; /** - * Class NumberOfInterveningJobs is an integer valued printing attribute that - * indicates the number of jobs that are ahead of this job in the relative - * chronological order of expected time to complete (i.e., the current - * scheduled order). - *

- * IPP Compatibility: The integer value gives the IPP integer value. - * The category name returned by {@code getName()} gives the IPP - * attribute name. + * Class {@code NumberOfInterveningJobs} is an integer valued printing attribute + * that indicates the number of jobs that are ahead of this job in the relative + * chronological order of expected time to complete (i.e., the current scheduled + * order). + *

+ * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class NumberOfInterveningJobs extends IntegerSyntax implements PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 2568141124844982746L; /** * Construct a new number of intervening jobs attribute with the given * integer value. * - * @param value Integer value. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 0. + * @param value Integer value + * @throws IllegalArgumentException if {@code value} is negative */ public NumberOfInterveningJobs(int value) { super(value, 0, Integer.MAX_VALUE); @@ -62,20 +63,17 @@ public final class NumberOfInterveningJobs extends IntegerSyntax * Returns whether this number of intervening jobs attribute is equivalent * to the passed in object. To be equivalent, all of the following * conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class NumberOfInterveningJobs. - *
  3. - * This number of intervening jobs attribute's value and - * {@code object}'s value are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class + * {@code NumberOfInterveningJobs}. + *
  3. This number of intervening jobs attribute's value and + * {@code object}'s value are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this number of - * intervening jobs attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this number of + * intervening jobs attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && @@ -85,12 +83,12 @@ public final class NumberOfInterveningJobs extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class NumberOfInterveningJobs, the - * category is class NumberOfInterveningJobs itself. + *

+ * For class {@code NumberOfInterveningJobs}, the category is class + * {@code NumberOfInterveningJobs} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return NumberOfInterveningJobs.class; @@ -99,14 +97,13 @@ public final class NumberOfInterveningJobs extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class NumberOfInterveningJobs, the - * category name is {@code "number-of-intervening-jobs"}. + *

+ * For class {@code NumberOfInterveningJobs}, the category name is + * {@code "number-of-intervening-jobs"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "number-of-intervening-jobs"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUp.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUp.java index b6a965a7c76..0e232043270 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUp.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,120 +22,107 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; -import javax.print.attribute.IntegerSyntax; import javax.print.attribute.DocAttribute; -import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.IntegerSyntax; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class NumberUp is an integer valued printing attribute class that specifies - * the number of print-stream pages to impose upon a single side of an - * instance of a selected medium. That is, if the NumberUp value is n, - * the printer must place n print-stream pages on a single side of - * an instance of the - * selected medium. To accomplish this, the printer may add some sort of - * translation, scaling, or rotation. This attribute primarily controls the - * translation, scaling and rotation of print-stream pages. - *

- * The effect of a NumberUp attribute on a multidoc print job (a job with - * multiple documents) depends on whether all the docs have the same number up - * values specified or whether different docs have different number up values - * specified, and on the (perhaps defaulted) value of the {@link - * MultipleDocumentHandling MultipleDocumentHandling} attribute. - *

    - *
  • - * If all the docs have the same number up value n specified, then any - * value of {@link MultipleDocumentHandling MultipleDocumentHandling} makes - * sense, and the printer's processing depends on the {@link - * MultipleDocumentHandling MultipleDocumentHandling} value: - *
      - *
    • - * SINGLE_DOCUMENT -- All the input docs will be combined together into one - * output document. Each media impression will consist of nm - * print-stream pages from the output document. + * Class {@code NumberUp} is an integer valued printing attribute class that + * specifies the number of print-stream pages to impose upon a single side of an + * instance of a selected medium. That is, if the NumberUp value is n, + * the printer must place n print-stream pages on a single side of an + * instance of the selected medium. To accomplish this, the printer may add some + * sort of translation, scaling, or rotation. This attribute primarily controls + * the translation, scaling and rotation of print-stream pages. + *

      + * The effect of a {@code NumberUp} attribute on a multidoc print job (a job + * with multiple documents) depends on whether all the docs have the same number + * up values specified or whether different docs have different number up values + * specified, and on the (perhaps defaulted) value of the + * {@link MultipleDocumentHandling MultipleDocumentHandling} attribute. + *

        + *
      • If all the docs have the same number up value n specified, then + * any value of {@link MultipleDocumentHandling MultipleDocumentHandling} + * makes sense, and the printer's processing depends on the + * {@link MultipleDocumentHandling MultipleDocumentHandling} value: + *
          + *
        • {@code SINGLE_DOCUMENT} -- All the input docs will be combined + * together into one output document. Each media impression will consist of + * nm print-stream pages from the output document. + *
        • {@code SINGLE_DOCUMENT_NEW_SHEET} -- All the input docs will be + * combined together into one output document. Each media impression will + * consist of n print-stream pages from the output document. However, + * the first impression of each input doc will always start on a new media + * sheet; this means the last impression of an input doc may have fewer than + * n print-stream pages on it. + *
        • {@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- The input docs will + * remain separate. Each media impression will consist of n + * print-stream pages from the input doc. Since the input docs are separate, + * the first impression of each input doc will always start on a new media + * sheet; this means the last impression of an input doc may have fewer than + * n print-stream pages on it. + *
        • {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- The input docs will + * remain separate. Each media impression will consist of n + * print-stream pages from the input doc. Since the input docs are separate, + * the first impression of each input doc will always start on a new media + * sheet; this means the last impression of an input doc may have fewer than + * n print-stream pages on it. + *
        + *
          + *
        • {@code SINGLE_DOCUMENT} -- All the input docs will be combined + * together into one output document. Each media impression will consist of + * ni print-stream pages from the output document, where + * i is the number of the input doc corresponding to that point in + * the output document. When the next input doc has a different number up + * value from the previous input doc, the first print-stream page of the + * next input doc goes at the start of the next media impression, possibly + * leaving fewer than the full number of print-stream pages on the previous + * media impression. + *
        • {@code SINGLE_DOCUMENT_NEW_SHEET} -- All the input docs will be + * combined together into one output document. Each media impression will + * consist of n print-stream pages from the output document. However, + * the first impression of each input doc will always start on a new media + * sheet; this means the last impression of an input doc may have fewer than + * n print-stream pages on it. + *
        • {@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- The input docs will + * remain separate. For input doc i, each media impression will + * consist of ni print-stream pages from the input doc. + * Since the input docs are separate, the first impression of each input doc + * will always start on a new media sheet; this means the last impression of + * an input doc may have fewer than ni print-stream pages + * on it. + *
        • {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- The input docs will + * remain separate. For input doc i, each media impression will + * consist of ni print-stream pages from the input doc. + * Since the input docs are separate, the first impression of each input doc + * will always start on a new media sheet; this means the last impression of + * an input doc may have fewer than ni print-stream pages + * on it. + *
        + *
      + * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * - *
    • - * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together - * into one output document. Each media impression will consist of n - * print-stream pages from the output document. However, the first impression of - * each input doc will always start on a new media sheet; this means the last - * impression of an input doc may have fewer than n print-stream pages - * on it. - * - *
    • - * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate. - * Each media impression will consist of n print-stream pages from the - * input doc. Since the input docs are separate, the first impression of each - * input doc will always start on a new media sheet; this means the last - * impression of an input doc may have fewer than n print-stream pages on - * it. - * - *
    • - * SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate. - * Each media impression will consist of n print-stream pages from the - * input doc. Since the input docs are separate, the first impression of each - * input doc will always start on a new media sheet; this means the last - * impression of an input doc may have fewer than n print-stream pages - * on it. - *
    - *
      - *
    • - * SINGLE_DOCUMENT -- All the input docs will be combined together into one - * output document. Each media impression will consist of ni - * print-stream pages from the output document, where i is the number of - * the input doc corresponding to that point in the output document. When the - * next input doc has a different number up value from the previous input doc, - * the first print-stream page of the next input doc goes at the start of the - * next media impression, possibly leaving fewer than the full number of - * print-stream pages on the previous media impression. - * - *
    • - * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together - * into one output document. Each media impression will consist of n - * print-stream pages from the output document. However, the first impression of - * each input doc will always start on a new media sheet; this means the last - * impression of an input doc may have fewer than n print-stream pages - * on it. - * - *
    • - * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate. - * For input doc i, each media impression will consist of - * ni print-stream pages from the input doc. Since the input - * docs are separate, the first impression of each input doc will always start - * on a new media sheet; this means the last impression of an input doc may have - * fewer than ni print-stream pages on it. - * - *
    • - * SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate. - * For input doc i, each media impression will consist of - * ni print-stream pages from the input doc. Since the input - * docs are separate, the first impression of each input doc will always start - * on a new media sheet; this means the last impression of an input doc may - * have fewer than ni print-stream pages on it. - *
    - *
- * IPP Compatibility: The integer value gives the IPP integer value. - * The category name returned by {@code getName()} gives the IPP - * attribute name. - * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class NumberUp extends IntegerSyntax implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -3040436486786527811L; - /** * Construct a new number up attribute with the given integer value. * - * @param value Integer value. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 1. + * @param value Integer value + * @throws IllegalArgumentException if {@code value < 1} */ public NumberUp(int value) { super (value, 1, Integer.MAX_VALUE); @@ -144,20 +131,16 @@ public final class NumberUp extends IntegerSyntax /** * Returns whether this number up attribute is equivalent to the passed in * object. To be equivalent, all of the following conditions must be true: - *
    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class NumberUp. - *
  3. - * This number up attribute's value and {@code object}'s value are - * equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code NumberUp}. + *
  3. This number up attribute's value and {@code object}'s value are + * equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this number up - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this number up + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && object instanceof NumberUp); @@ -166,11 +149,12 @@ public final class NumberUp extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class NumberUp, the category is class NumberUp itself. + *

+ * For class {@code NumberUp}, the category is class {@code NumberUp} + * itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return NumberUp.class; @@ -179,13 +163,12 @@ public final class NumberUp extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class NumberUp, the category name is {@code "number-up"}. + *

+ * For class {@code NumberUp}, the category name is {@code "number-up"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "number-up"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUpSupported.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUpSupported.java index e5107b8ca04..c4f26bbafed 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUpSupported.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/NumberUpSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,41 +30,39 @@ import javax.print.attribute.SetOfIntegerSyntax; import javax.print.attribute.SupportedValuesAttribute; /** - * Class NumberUpSupported is a printing attribute class, a set of integers, - * that gives the supported values for a {@link NumberUp NumberUp} attribute. - *

- * IPP Compatibility: The NumberUpSupported attribute's canonical array + * Class {@code NumberUpSupported} is a printing attribute class, a set of + * integers, that gives the supported values for a {@link NumberUp NumberUp} + * attribute. + *

+ * IPP Compatibility: The NumberUpSupported attribute's canonical array * form gives the lower and upper bound for each range of number-up to be - * included in an IPP "number-up-supported" attribute. See class {@link - * javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an - * explanation of canonical array form. The category name returned by - * {@code getName()} gives the IPP attribute name. + * included in an IPP "number-up-supported" attribute. See class + * {@link SetOfIntegerSyntax SetOfIntegerSyntax} for an explanation of canonical + * array form. The category name returned by {@code getName()} gives the IPP + * attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class NumberUpSupported extends SetOfIntegerSyntax implements SupportedValuesAttribute { - private static final long serialVersionUID = -1041573395759141805L; - + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ + private static final long serialVersionUID = -1041573395759141805L; /** - * Construct a new number up supported attribute with the given members. - * The supported values for NumberUp are specified in "array form;" see - * class - * {@link javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} - * for an explanation of array form. + * Construct a new number up supported attribute with the given members. The + * supported values for NumberUp are specified in "array form;" see class + * {@link SetOfIntegerSyntax SetOfIntegerSyntax} for + * an explanation of array form. * - * @param members Set members in array form. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code members} is null or - * any element of {@code members} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if any element of - * {@code members} is not a length-one or length-two array. Also - * thrown if {@code members} is a zero-length array or if any - * member of the set is less than 1. + * @param members set members in array form + * @throws NullPointerException if {@code members} is {@code null} or any + * element of {@code members} is {@code null} + * @throws IllegalArgumentException if any element of {@code members} is not + * a length-one or length-two array. Also if {@code members} is a + * zero-length array or if any member of the set is less than 1. */ public NumberUpSupported(int[][] members) { super (members); @@ -86,13 +85,10 @@ public final class NumberUpSupported extends SetOfIntegerSyntax /** * Construct a new number up supported attribute containing a single - * integer. That is, only the one value of NumberUp is supported. + * integer. That is, only the one value of {@code NumberUp} is supported. * - * @param member Set member. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code member} is less than - * 1. + * @param member set member + * @throws IllegalArgumentException if {@code member < 1} */ public NumberUpSupported(int member) { super (member); @@ -103,16 +99,14 @@ public final class NumberUpSupported extends SetOfIntegerSyntax /** * Construct a new number up supported attribute containing a single range - * of integers. That is, only those values of NumberUp in the one range are - * supported. + * of integers. That is, only those values of {@code NumberUp} in the one + * range are supported. * - * @param lowerBound Lower bound of the range. - * @param upperBound Upper bound of the range. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if a null range is specified or if a - * non-null range is specified with {@code lowerBound} less than - * 1. + * @param lowerBound lower bound of the range + * @param upperBound upper bound of the range + * @throws IllegalArgumentException if a {@code null} range is specified or + * if a {@code non-null} range is specified with {@code lowerBound} + * less than 1 */ public NumberUpSupported(int lowerBound, int upperBound) { super (lowerBound, upperBound); @@ -126,22 +120,18 @@ public final class NumberUpSupported extends SetOfIntegerSyntax /** * Returns whether this number up supported attribute is equivalent to the - * passed in object. To be equivalent, all of the following conditions - * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class NumberUpSupported. - *
  3. - * This number up supported attribute's members and {@code object}'s - * members are the same. - *
+ * passed in object. To be equivalent, all of the following conditions must + * be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code NumberUpSupported}. + *
  3. This number up supported attribute's members and {@code object}'s + * members are the same. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this number up - * supported attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this number up + * supported attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && @@ -151,12 +141,12 @@ public final class NumberUpSupported extends SetOfIntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class NumberUpSupported, the - * category is class NumberUpSupported itself. + *

+ * For class {@code NumberUpSupported}, the category is class + * {@code NumberUpSupported} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return NumberUpSupported.class; @@ -165,14 +155,13 @@ public final class NumberUpSupported extends SetOfIntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class NumberUpSupported, the - * category name is {@code "number-up-supported"}. + *

+ * For class {@code NumberUpSupported}, the category name is + * {@code "number-up-supported"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "number-up-supported"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/OrientationRequested.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/OrientationRequested.java index 0ce78a5b390..0b7c2983132 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/OrientationRequested.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/OrientationRequested.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,48 +22,51 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; -import javax.print.attribute.EnumSyntax; import javax.print.attribute.DocAttribute; -import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.EnumSyntax; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class OrientationRequested is a printing attribute class, an enumeration, - * that indicates the desired orientation for printed print-stream pages; it - * does not describe the orientation of the client-supplied print-stream - * pages. - *

- * For some document formats (such as {@code "application/postscript"}), - * the desired orientation of the print-stream pages is specified within the - * document data. This information is generated by a device driver prior to - * the submission of the print job. Other document formats (such as - * {@code "text/plain"}) do not include the notion of desired orientation - * within the document data. In the latter case it is possible for the printer - * to bind the desired orientation to the document data after it has been - * submitted. It is expected that a printer would only support the - * OrientationRequested attribute for some document formats (e.g., + * Class {@code OrientationRequested} is a printing attribute class, an + * enumeration, that indicates the desired orientation for printed print-stream + * pages; it does not describe the orientation of the client-supplied + * print-stream pages. + *

+ * For some document formats (such as {@code "application/postscript"}), the + * desired orientation of the print-stream pages is specified within the + * document data. This information is generated by a device driver prior to the + * submission of the print job. Other document formats (such as + * {@code "text/plain"}) do not include the notion of desired orientation within + * the document data. In the latter case it is possible for the printer to bind + * the desired orientation to the document data after it has been submitted. It + * is expected that a printer would only support the + * {@code OrientationRequested} attribute for some document formats (e.g., * {@code "text/plain"} or {@code "text/html"}) but not others (e.g. - * {@code "application/postscript"}). This is no different from any other - * job template attribute, since a print job can always impose constraints - * among the values of different job template attributes. - * However, a special mention - * is made here since it is very likely that a printer will support the - * OrientationRequested attribute for only a subset of the supported document - * formats. - *

- * IPP Compatibility: The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. + * {@code "application/postscript"}). This is no different from any other job + * template attribute, since a print job can always impose constraints among the + * values of different job template attributes. However, a special mention is + * made here since it is very likely that a printer will support the + * {@code OrientationRequested} attribute for only a subset of the supported + * document formats. + *

+ * IPP Compatibility: The category name returned by {@code getName()} is + * the IPP attribute name. The enumeration's integer value is the IPP enum + * value. The {@code toString()} method returns the IPP string representation of + * the attribute value. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class OrientationRequested extends EnumSyntax implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -4447437289862822276L; /** @@ -73,11 +76,10 @@ public final class OrientationRequested extends EnumSyntax PORTRAIT = new OrientationRequested(3); /** - * The content will be imaged across the long edge of the medium. - * Landscape is defined to be a rotation of the print-stream page to be - * imaged by +90 degrees with respect to the medium - * (i.e. anti-clockwise) from the - * portrait orientation. Note: The +90 direction was chosen because + * The content will be imaged across the long edge of the medium. Landscape + * is defined to be a rotation of the print-stream page to be imaged by +90 + * degrees with respect to the medium (i.e. anti-clockwise) from the + * portrait orientation. Note: The +90 direction was chosen because * simple finishing on the long edge is the same edge whether portrait or * landscape. */ @@ -85,13 +87,13 @@ public final class OrientationRequested extends EnumSyntax LANDSCAPE = new OrientationRequested(4); /** - * The content will be imaged across the long edge of the medium, but in - * the opposite manner from landscape. Reverse-landscape is defined to be - * a rotation of the print-stream page to be imaged by -90 degrees with + * The content will be imaged across the long edge of the medium, but in the + * opposite manner from landscape. Reverse-landscape is defined to be a + * rotation of the print-stream page to be imaged by -90 degrees with * respect to the medium (i.e. clockwise) from the portrait orientation. - * Note: The REVERSE_LANDSCAPE value was added because some - * applications rotate landscape -90 degrees from portrait, rather than - * +90 degrees. + * Note: The REVERSE_LANDSCAPE value was added because some + * applications rotate landscape -90 degrees from portrait, rather than +90 + * degrees. */ public static final OrientationRequested REVERSE_LANDSCAPE = new OrientationRequested(5); @@ -100,14 +102,14 @@ public final class OrientationRequested extends EnumSyntax * The content will be imaged across the short edge of the medium, but in * the opposite manner from portrait. Reverse-portrait is defined to be a * rotation of the print-stream page to be imaged by 180 degrees with - * respect to the medium from the portrait orientation. Note: The - * REVERSE_PORTRAIT value was added for use with the {@link - * Finishings Finishings} attribute in cases where the - * opposite edge is desired for finishing a portrait document on simple - * finishing devices that have only one finishing position. Thus a - * {@code "text/plain"} portrait document can be stapled "on the - * right" by a simple finishing device as is common use with some - * Middle Eastern languages such as Hebrew. + * respect to the medium from the portrait orientation. Note: The + * REVERSE_PORTRAIT value was added for use with the + * {@link Finishings Finishings} attribute in cases where the opposite edge + * is desired for finishing a portrait document on simple finishing devices + * that have only one finishing position. Thus a {@code "text/plain"} + * portrait document can be stapled "on the right" by a simple finishing + * device as is common use with some Middle Eastern languages such as + * Hebrew. */ public static final OrientationRequested REVERSE_PORTRAIT = new OrientationRequested(6); @@ -116,12 +118,15 @@ public final class OrientationRequested extends EnumSyntax * Construct a new orientation requested enumeration value with the given * integer value. * - * @param value Integer value. + * @param value Integer value */ protected OrientationRequested(int value) { super(value); } + /** + * The string table for class {@code OrientationRequested}. + */ private static final String[] myStringTable = { "portrait", "landscape", @@ -129,6 +134,9 @@ public final class OrientationRequested extends EnumSyntax "reverse-portrait" }; + /** + * The enumeration value table for class {@code OrientationRequested}. + */ private static final OrientationRequested[] myEnumValueTable = { PORTRAIT, LANDSCAPE, @@ -137,21 +145,23 @@ public final class OrientationRequested extends EnumSyntax }; /** - * Returns the string table for class OrientationRequested. + * Returns the string table for class {@code OrientationRequested}. */ protected String[] getStringTable() { return myStringTable; } /** - * Returns the enumeration value table for class OrientationRequested. + * Returns the enumeration value table for class + * {@code OrientationRequested}. */ protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } /** - * Returns the lowest integer value used by class OrientationRequested. + * Returns the lowest integer value used by class + * {@code OrientationRequested}. */ protected int getOffset() { return 3; @@ -160,12 +170,12 @@ public final class OrientationRequested extends EnumSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class OrientationRequested, the - * category is class OrientationRequested itself. + *

+ * For class {@code OrientationRequested}, the category is class + * {@code OrientationRequested} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return OrientationRequested.class; @@ -174,14 +184,13 @@ public final class OrientationRequested extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class OrientationRequested, the - * category name is {@code "orientation-requested"}. + *

+ * For class {@code OrientationRequested}, the category name is + * {@code "orientation-requested"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "orientation-requested"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/OutputDeviceAssigned.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/OutputDeviceAssigned.java index e9411371466..e94a7b96a77 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/OutputDeviceAssigned.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/OutputDeviceAssigned.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,46 +22,48 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.Locale; import javax.print.attribute.Attribute; -import javax.print.attribute.TextSyntax; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.TextSyntax; /** - * Class OutputDeviceAssigned is a printing attribute class, a text attribute, - * that identifies the output device to which the service has assigned this - * job. If an output device implements an embedded Print Service instance, the - * printer need not set this attribute. If a print server implements a - * Print Service instance, the value may be empty (zero- length string) or not - * returned until the service assigns an output device to the job. This - * attribute is particularly useful when a single service supports multiple - * devices (so called "fan-out"). - *

- * IPP Compatibility: The string value gives the IPP name value. The + * Class {@code OutputDeviceAssigned} is a printing attribute class, a text + * attribute, that identifies the output device to which the service has + * assigned this job. If an output device implements an embedded Print Service + * instance, the printer need not set this attribute. If a print server + * implements a Print Service instance, the value may be empty (zero- length + * string) or not returned until the service assigns an output device to the + * job. This attribute is particularly useful when a single service supports + * multiple devices (so called "fan-out"). + *

+ * IPP Compatibility: The string value gives the IPP name value. The * locale gives the IPP natural language. The category name returned by * {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class OutputDeviceAssigned extends TextSyntax implements PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 5486733778854271081L; /** * Constructs a new output device assigned attribute with the given device * name and locale. * - * @param deviceName Device name. - * @param locale Natural language of the text string. null - * is interpreted to mean the default locale as returned - * by {@code Locale.getDefault()} - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code deviceName} is null. + * @param deviceName device name + * @param locale natural language of the text string. {@code null} is + * interpreted to mean the default locale as returned by + * {@code Locale.getDefault()} + * @throws NullPointerException if {@code deviceName} is {@code null} */ public OutputDeviceAssigned(String deviceName, Locale locale) { @@ -74,23 +76,19 @@ public final class OutputDeviceAssigned extends TextSyntax * Returns whether this output device assigned attribute is equivalent to * the passed in object. To be equivalent, all of the following conditions * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class OutputDeviceAssigned. - *
  3. - * This output device assigned attribute's underlying string and - * {@code object}'s underlying string are equal. - *
  4. - * This output device assigned attribute's locale and - * {@code object}'s locale are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class + * {@code OutputDeviceAssigned}. + *
  3. This output device assigned attribute's underlying string and + * {@code object}'s underlying string are equal. + *
  4. This output device assigned attribute's locale and {@code object}'s + * locale are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this output - * device assigned attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this output + * device assigned attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && @@ -100,12 +98,12 @@ public final class OutputDeviceAssigned extends TextSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class OutputDeviceAssigned, the - * category is class OutputDeviceAssigned itself. + *

+ * For class {@code OutputDeviceAssigned}, the category is class + * {@code OutputDeviceAssigned} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return OutputDeviceAssigned.class; @@ -114,14 +112,13 @@ public final class OutputDeviceAssigned extends TextSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class OutputDeviceAssigned, the - * category name is {@code "output-device-assigned"}. + *

+ * For class {@code OutputDeviceAssigned}, the category name is + * {@code "output-device-assigned"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "output-device-assigned"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PDLOverrideSupported.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PDLOverrideSupported.java index e1d31db38c1..495022739af 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PDLOverrideSupported.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PDLOverrideSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,27 +30,29 @@ import javax.print.attribute.EnumSyntax; import javax.print.attribute.PrintServiceAttribute; /** - * Class PDLOverrideSupported is a printing attribute class, an enumeration, - * that expresses the printer's ability to attempt to override processing - * instructions embedded in documents' print data with processing instructions - * specified as attributes outside the print data. - *

- * IPP Compatibility: The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. + * Class {@code PDLOverrideSupported} is a printing attribute class, an + * enumeration, that expresses the printer's ability to attempt to override + * processing instructions embedded in documents' print data with processing + * instructions specified as attributes outside the print data. + *

+ * IPP Compatibility: The category name returned by {@code getName()} is + * the IPP attribute name. The enumeration's integer value is the IPP enum + * value. The {@code toString()} method returns the IPP string representation of + * the attribute value. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public class PDLOverrideSupported extends EnumSyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -4393264467928463934L; /** * The printer makes no attempt to make the external job attribute values - * take precedence over embedded instructions in the documents' print - * data. + * take precedence over embedded instructions in the documents' print data. */ public static final PDLOverrideSupported NOT_ATTEMPTED = new PDLOverrideSupported(0); @@ -62,36 +65,42 @@ public class PDLOverrideSupported extends EnumSyntax public static final PDLOverrideSupported ATTEMPTED = new PDLOverrideSupported(1); - /** * Construct a new PDL override supported enumeration value with the given * integer value. * - * @param value Integer value. + * @param value Integer value */ protected PDLOverrideSupported(int value) { super (value); } + /** + * The string table for class {@code PDLOverrideSupported}. + */ private static final String[] myStringTable = { "not-attempted", "attempted" }; + /** + * The enumeration value table for class {@code PDLOverrideSupported}. + */ private static final PDLOverrideSupported[] myEnumValueTable = { NOT_ATTEMPTED, ATTEMPTED }; /** - * Returns the string table for class PDLOverrideSupported. + * Returns the string table for class {@code PDLOverrideSupported}. */ protected String[] getStringTable() { return myStringTable.clone(); } /** - * Returns the enumeration value table for class PDLOverrideSupported. + * Returns the enumeration value table for class + * {@code PDLOverrideSupported}. */ protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); @@ -100,12 +109,12 @@ public class PDLOverrideSupported extends EnumSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PDLOverrideSupported and any vendor-defined subclasses, the - * category is class PDLOverrideSupported itself. + *

+ * For class {@code PDLOverrideSupported} and any vendor-defined subclasses, + * the category is class {@code PDLOverrideSupported} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PDLOverrideSupported.class; @@ -114,14 +123,13 @@ public class PDLOverrideSupported extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PDLOverrideSupported and any vendor-defined subclasses, the - * category name is {@code "pdl-override-supported"}. + *

+ * For class {@code PDLOverrideSupported} and any vendor-defined subclasses, + * the category name is {@code "pdl-override-supported"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "pdl-override-supported"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PageRanges.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PageRanges.java index 7e92d6db2c0..26026d77af6 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PageRanges.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PageRanges.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -26,106 +26,93 @@ package javax.print.attribute.standard; import javax.print.attribute.Attribute; -import javax.print.attribute.SetOfIntegerSyntax; import javax.print.attribute.DocAttribute; -import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.SetOfIntegerSyntax; /** - * Class PageRanges is a printing attribute class, a set of integers, that - * identifies the range(s) of print-stream pages that the Printer object uses - * for each copy of each document which are to be printed. Nothing is printed - * for any pages identified that do not exist in the document(s). The attribute - * is associated with print-stream pages, not application-numbered pages - * (for example, the page numbers found in the headers and or footers for - * certain word processing applications). - *

+ * Class {@code PageRanges} is a printing attribute class, a set of integers, + * that identifies the range(s) of print-stream pages that the Printer object + * uses for each copy of each document which are to be printed. Nothing is + * printed for any pages identified that do not exist in the document(s). The + * attribute is associated with print-stream pages, not + * application-numbered pages (for example, the page numbers found in the + * headers and or footers for certain word processing applications). + *

* In most cases, the exact pages to be printed will be generated by a device * driver and this attribute would not be required. However, when printing an * archived document which has already been formatted, the end user may elect to * print just a subset of the pages contained in the document. In this case, if - * a page range of "n-m" is specified, the first page - * to be printed will be page n. All subsequent pages of the document - * will be printed through and including page m. - *

- * If a PageRanges attribute is not specified for a print job, all pages of - * the document will be printed. In other words, the default value for the - * PageRanges attribute is always {@code {{1, Integer.MAX_VALUE}}}. - *

- * The effect of a PageRanges attribute on a multidoc print job (a job with - * multiple documents) depends on whether all the docs have the same page ranges - * specified or whether different docs have different page ranges specified, and - * on the (perhaps defaulted) value of the {@link MultipleDocumentHandling - * MultipleDocumentHandling} attribute. - *

    - *
  • - * If all the docs have the same page ranges specified, then any value of {@link - * MultipleDocumentHandling MultipleDocumentHandling} makes sense, and the - * printer's processing depends on the {@link MultipleDocumentHandling - * MultipleDocumentHandling} value: - *
      - *
    • - * SINGLE_DOCUMENT -- All the input docs will be combined together into one - * output document. The specified page ranges of that output document will be - * printed. + * a page range of "n-m" is specified, the first page + * to be printed will be page n. All subsequent pages of the document + * will be printed through and including page m. + *

      + * If a {@code PageRanges} attribute is not specified for a print job, all pages + * of the document will be printed. In other words, the default value for the + * {@code PageRanges} attribute is always {@code {{1, Integer.MAX_VALUE}}}. + *

      + * The effect of a {@code PageRanges} attribute on a multidoc print job (a job + * with multiple documents) depends on whether all the docs have the same page + * ranges specified or whether different docs have different page ranges + * specified, and on the (perhaps defaulted) value of the + * {@link MultipleDocumentHandling MultipleDocumentHandling} attribute. + *

        + *
      • If all the docs have the same page ranges specified, then any value of + * {@link MultipleDocumentHandling MultipleDocumentHandling} makes sense, and + * the printer's processing depends on the + * {@link MultipleDocumentHandling MultipleDocumentHandling} value: + *
          + *
        • {@code SINGLE_DOCUMENT} -- All the input docs will be combined + * together into one output document. The specified page ranges of that + * output document will be printed. + *
        • {@code SINGLE_DOCUMENT_NEW_SHEET} -- All the input docs will be + * combined together into one output document, and the first impression of + * each input doc will always start on a new media sheet. The specified page + * ranges of that output document will be printed. + *
        • {@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- For each separate + * input doc, the specified page ranges will be printed. + *
        • {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- For each separate input + * doc, the specified page ranges will be printed. + *
        + *
          + *
        • {@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- For each separate + * input doc, its own specified page ranges will be printed. + *
        • {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- For each separate input + * doc, its own specified page ranges will be printed. + *
        + *
      + *

      + * IPP Compatibility: The PageRanges attribute's canonical array form + * gives the lower and upper bound for each range of pages to be included in and + * IPP "page-ranges" attribute. See class + * {@link SetOfIntegerSyntax SetOfIntegerSyntax} for an explanation of canonical + * array form. The category name returned by {@code getName()} gives the IPP + * attribute name. * - *

    • - * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together - * into one output document, and the first impression of each input doc will - * always start on a new media sheet. The specified page ranges of that output - * document will be printed. - * - *
    • - * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- For each separate input doc, the - * specified page ranges will be printed. - * - *
    • - * SEPARATE_DOCUMENTS_COLLATED_COPIES -- For each separate input doc, the - * specified page ranges will be printed. - *
    - *
      - *
    • - * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- For each separate input doc, its own - * specified page ranges will be printed.. - * - *
    • - * SEPARATE_DOCUMENTS_COLLATED_COPIES -- For each separate input doc, its own - * specified page ranges will be printed.. - *
    - *
- *

- * IPP Compatibility: The PageRanges attribute's canonical array form - * gives the lower and upper bound for each range of pages to be included in - * and IPP "page-ranges" attribute. See class {@link - * javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an - * explanation of canonical array form. The category name returned by - * {@code getName()} gives the IPP attribute name. - * - * @author David Mendenhall - * @author Alan Kaminsky + * @author David Mendenhall + * @author Alan Kaminsky */ public final class PageRanges extends SetOfIntegerSyntax implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 8639895197656148392L; - /** - * Construct a new page ranges attribute with the given members. The - * members are specified in "array form;" see class {@link - * javax.print.attribute.SetOfIntegerSyntax SetOfIntegerSyntax} for an - * explanation of array form. + * Construct a new page ranges attribute with the given members. The members + * are specified in "array form;" see class + * {@link SetOfIntegerSyntax SetOfIntegerSyntax} for an explanation of array + * form. * - * @param members Set members in array form. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code members} is null or - * any element of {@code members} is null. - * @exception IllegalArgumentException - * (unchecked exception) Thrown if any element of - * {@code members} is not a length-one or length-two array. Also - * thrown if {@code members} is a zero-length array or if any - * member of the set is less than 1. + * @param members set members in array form + * @throws NullPointerException if {@code members} is {@code null} or any + * element of {@code members} is {@code null} + * @throws IllegalArgumentException if any element of {@code members} is not + * a length-one or length-two array. Also if {@code members} is a + * zero-length array or if any member of the set is less than 1. */ public PageRanges(int[][] members) { super (members); @@ -134,24 +121,18 @@ public final class PageRanges extends SetOfIntegerSyntax } myPageRanges(); } + /** - * Construct a new page ranges attribute with the given members in - * string form. - * See class {@link javax.print.attribute.SetOfIntegerSyntax - * SetOfIntegerSyntax} - * for explanation of the syntax. + * Construct a new page ranges attribute with the given members in string + * form. See class {@link SetOfIntegerSyntax SetOfIntegerSyntax} for + * explanation of the syntax. * - * @param members Set members in string form. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code members} is null or - * any element of {@code members} is null. - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code members} does not - * obey the proper syntax. Also - * thrown if the constructed set-of-integer is a - * zero-length array or if any - * member of the set is less than 1. + * @param members set members in string form + * @throws NullPointerException if {@code members} is {@code null} or any + * element of {@code members} is {@code null} + * @throws IllegalArgumentException if {@code members} does not obey the + * proper syntax. Also if the constructed set-of-integer is a + * zero-length array or if any member of the set is less than 1. */ public PageRanges(String members) { super(members); @@ -161,6 +142,9 @@ public final class PageRanges extends SetOfIntegerSyntax myPageRanges(); } + /** + * Validates the page ranges. + */ private void myPageRanges() { int[][] myMembers = getMembers(); int n = myMembers.length; @@ -179,11 +163,8 @@ public final class PageRanges extends SetOfIntegerSyntax * Construct a new page ranges attribute containing a single integer. That * is, only the one page is to be printed. * - * @param member Set member. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code member} is less than - * 1. + * @param member set member + * @throws IllegalArgumentException if {@code member < 1} */ public PageRanges(int member) { super (member); @@ -196,13 +177,11 @@ public final class PageRanges extends SetOfIntegerSyntax * Construct a new page ranges attribute containing a single range of * integers. That is, only those pages in the one range are to be printed. * - * @param lowerBound Lower bound of the range. - * @param upperBound Upper bound of the range. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if a null range is specified or if a - * non-null range is specified with {@code lowerBound} less than - * 1. + * @param lowerBound lower bound of the range + * @param upperBound upper bound of the range + * @throws IllegalArgumentException if a {@code null} range is specified or + * if a {@code non-null} range is specified with {@code lowerBound} + * less than 1 */ public PageRanges(int lowerBound, int upperBound) { super (lowerBound, upperBound); @@ -214,23 +193,18 @@ public final class PageRanges extends SetOfIntegerSyntax } /** - * Returns whether this page ranges attribute is equivalent to the passed - * in object. To be equivalent, all of the following conditions must be - * true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class PageRanges. - *
  3. - * This page ranges attribute's members and {@code object}'s members - * are the same. - *
+ * Returns whether this page ranges attribute is equivalent to the passed in + * object. To be equivalent, all of the following conditions must be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code PageRanges}. + *
  3. This page ranges attribute's members and {@code object}'s members + * are the same. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this page ranges - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this page ranges + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && object instanceof PageRanges); @@ -239,11 +213,12 @@ public final class PageRanges extends SetOfIntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PageRanges, the category is class PageRanges itself. + *

+ * For class {@code PageRanges}, the category is class + * {@code PageRanges} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PageRanges.class; @@ -252,13 +227,12 @@ public final class PageRanges extends SetOfIntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PageRanges, the category name is {@code "page-ranges"}. + *

+ * For class {@code PageRanges}, the category name is {@code "page-ranges"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "page-ranges"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinute.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinute.java index 397ad356837..ce0ef30b0ae 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinute.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,32 +30,31 @@ import javax.print.attribute.IntegerSyntax; import javax.print.attribute.PrintServiceAttribute; /** - * Class PagesPerMinute is an integer valued printing attribute that indicates - * the nominal number of pages per minute to the nearest whole number which may - * be generated by this printer (e.g., simplex, black-and-white). This attribute - * is informative, not a service guarantee. Generally, it is the value used in - * the marketing literature to describe the device. A value of 0 indicates a - * device that takes more than two minutes to process a page. - *

- * IPP Compatibility: The integer value gives the IPP integer value. The - * category name returned by {@code getName()} gives the IPP attribute - * name. + * Class {@code PagesPerMinute} is an integer valued printing attribute that + * indicates the nominal number of pages per minute to the nearest whole number + * which may be generated by this printer (e.g., simplex, black-and-white). This + * attribute is informative, not a service guarantee. Generally, it is the value + * used in the marketing literature to describe the device. A value of 0 + * indicates a device that takes more than two minutes to process a page. + *

+ * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class PagesPerMinute extends IntegerSyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -6366403993072862015L; /** - * Construct a new pages per minute attribute with the given integer - * value. + * Construct a new pages per minute attribute with the given integer value. * - * @param value Integer value. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 0. + * @param value Integer value + * @throws IllegalArgumentException if {@code value} is negative */ public PagesPerMinute(int value) { super(value, 0, Integer.MAX_VALUE); @@ -62,22 +62,18 @@ public final class PagesPerMinute extends IntegerSyntax /** * Returns whether this pages per minute attribute is equivalent to the - * passed in object. To be equivalent, all of the following conditions - * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class PagesPerMinute. - *
  3. - * This pages per minute attribute's value and {@code object}'s - * value are equal. - *
+ * passed in object. To be equivalent, all of the following conditions must + * be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code PagesPerMinute}. + *
  3. This pages per minute attribute's value and {@code object}'s value + * are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this pages per - * minute attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this pages per + * minute attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && @@ -87,11 +83,12 @@ public final class PagesPerMinute extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PagesPerMinute, the category is class PagesPerMinute itself. + *

+ * For class {@code PagesPerMinute}, the category is class + * {@code PagesPerMinute} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PagesPerMinute.class; @@ -100,14 +97,13 @@ public final class PagesPerMinute extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PagesPerMinute, the - * category name is {@code "pages-per-minute"}. + *

+ * For class {@code PagesPerMinute}, the category name is + * {@code "pages-per-minute"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "pages-per-minute"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinuteColor.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinuteColor.java index 9af138bf5dd..f2928dce79e 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinuteColor.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PagesPerMinuteColor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,43 +30,44 @@ import javax.print.attribute.IntegerSyntax; import javax.print.attribute.PrintServiceAttribute; /** - * Class PagesPerMinuteColor is an integer valued printing attribute that - * indicates the nominal number of pages per minute to the nearest whole number - * which may be generated by this printer when printing color (e.g., simplex, - * color). For purposes of this attribute, "color" means the same as for the - * {@link ColorSupported ColorSupported} attribute, namely, the device is - * capable of any type of color printing at all, including highlight color as + * Class {@code PagesPerMinuteColor} is an integer valued printing attribute + * that indicates the nominal number of pages per minute to the nearest whole + * number which may be generated by this printer when printing color (e.g., + * simplex, color). For purposes of this attribute, "color" means the same as + * for the {@link ColorSupported ColorSupported} attribute, namely, the device + * is capable of any type of color printing at all, including highlight color as * well as full process color. This attribute is informative, not a service * guarantee. Generally, it is the value used in the marketing literature to * describe the color capabilities of this device. A value of 0 indicates a * device that takes more than two minutes to process a page. If a color device * has several color modes, it may use the pages-per- minute value for this * attribute that corresponds to the mode that produces the highest number. - *

- * A black and white only printer must not include the PagesPerMinuteColor - * attribute in its attribute set or service registration. If this attribute is - * present, then the {@link ColorSupported ColorSupported} printer description - * attribute must also be present and have a value of SUPPORTED. - *

- * IPP Compatibility: The integer value gives the IPP integer value. The - * category name returned by {@code getName()} gives the IPP attribute - * name. + *

+ * A black and white only printer must not include the + * {@code PagesPerMinuteColor} attribute in its attribute set or service + * registration. If this attribute is present, then the + * {@link ColorSupported ColorSupported} printer description attribute must also + * be present and have a value of {@code SUPPORTED}. + *

+ * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class PagesPerMinuteColor extends IntegerSyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ static final long serialVersionUID = 1684993151687470944L; /** * Construct a new pages per minute color attribute with the given integer * value. * - * @param value Integer value. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 0. + * @param value Integer value + * @throws IllegalArgumentException if {@code value} is negative */ public PagesPerMinuteColor(int value) { super(value, 0, Integer.MAX_VALUE); @@ -75,20 +77,16 @@ public final class PagesPerMinuteColor extends IntegerSyntax * Returns whether this pages per minute color attribute is equivalent to * the passed in object. To be equivalent, all of the following conditions * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class PagesPerMinuteColor. - *
  3. - * This pages per minute attribute's value and {@code object}'s - * value are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code PagesPerMinuteColor}. + *
  3. This pages per minute attribute's value and {@code object}'s value + * are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this pages per - * minute color attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this pages per + * minute color attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && @@ -98,12 +96,12 @@ public final class PagesPerMinuteColor extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PagesPerMinuteColor, the - * category is class PagesPerMinuteColor itself. + *

+ * For class {@code PagesPerMinuteColor}, the category is class + * {@code PagesPerMinuteColor} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PagesPerMinuteColor.class; @@ -112,14 +110,13 @@ public final class PagesPerMinuteColor extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PagesPerMinuteColor, the - * category name is {@code "pages-per-minute-color"}. + *

+ * For class {@code PagesPerMinuteColor}, the category name is + * {@code "pages-per-minute-color"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "pages-per-minute-color"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PresentationDirection.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PresentationDirection.java index 70d8acff70b..261824ce07f 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PresentationDirection.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PresentationDirection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -30,81 +31,84 @@ import javax.print.attribute.PrintJobAttribute; import javax.print.attribute.PrintRequestAttribute; /** - * Class PresentationDirection is a printing attribute class, an enumeration, - * that is used in conjunction with the {@link NumberUp NumberUp} attribute to - * indicate the layout of multiple print-stream pages to impose upon a - * single side of an instance of a selected medium. - * This is useful to mirror the text layout conventions of different scripts. - * For example, English is "toright-tobottom", Hebrew is "toleft-tobottom" - * and Japanese is usually "tobottom-toleft". - *

- * IPP Compatibility: This attribute is not an IPP 1.1 - * attribute; it is an attribute in the Production Printing Extension - * (PDF) - * of IPP 1.1. The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. + * Class {@code PresentationDirection} is a printing attribute class, an + * enumeration, that is used in conjunction with the {@link NumberUp NumberUp} + * attribute to indicate the layout of multiple print-stream pages to impose + * upon a single side of an instance of a selected medium. This is useful to + * mirror the text layout conventions of different scripts. For example, English + * is "toright-tobottom", Hebrew is "toleft-tobottom" and Japanese is usually + * "tobottom-toleft". + *

+ * IPP Compatibility: This attribute is not an IPP 1.1 attribute; it is + * an attribute in the Production Printing Extension + * (PDF) of IPP + * 1.1. The category name returned by {@code getName()} is the IPP attribute + * name. The enumeration's integer value is the IPP enum value. The + * {@code toString()} method returns the IPP string representation of the + * attribute value. * - * @author Phil Race. + * @author Phil Race */ public final class PresentationDirection extends EnumSyntax implements PrintJobAttribute, PrintRequestAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 8294728067230931780L; /** - * Pages are laid out in columns starting at the top left, - * proceeding towards the bottom {@literal &} right. + * Pages are laid out in columns starting at the top left, proceeding + * towards the bottom {@literal &} right. */ public static final PresentationDirection TOBOTTOM_TORIGHT = new PresentationDirection(0); /** - * Pages are laid out in columns starting at the top right, - * proceeding towards the bottom {@literal &} left. + * Pages are laid out in columns starting at the top right, proceeding + * towards the bottom {@literal &} left. */ public static final PresentationDirection TOBOTTOM_TOLEFT = new PresentationDirection(1); /** - * Pages are laid out in columns starting at the bottom left, - * proceeding towards the top {@literal &} right. + * Pages are laid out in columns starting at the bottom left, proceeding + * towards the top {@literal &} right. */ public static final PresentationDirection TOTOP_TORIGHT = new PresentationDirection(2); /** - * Pages are laid out in columns starting at the bottom right, - * proceeding towards the top {@literal &} left. + * Pages are laid out in columns starting at the bottom right, proceeding + * towards the top {@literal &} left. */ public static final PresentationDirection TOTOP_TOLEFT = new PresentationDirection(3); /** - * Pages are laid out in rows starting at the top left, - * proceeding towards the right {@literal &} bottom. + * Pages are laid out in rows starting at the top left, proceeding towards + * the right {@literal &} bottom. */ public static final PresentationDirection TORIGHT_TOBOTTOM = new PresentationDirection(4); /** - * Pages are laid out in rows starting at the bottom left, - * proceeding towards the right {@literal &} top. + * Pages are laid out in rows starting at the bottom left, proceeding + * towards the right {@literal &} top. */ public static final PresentationDirection TORIGHT_TOTOP = new PresentationDirection(5); /** - * Pages are laid out in rows starting at the top right, - * proceeding towards the left {@literal &} bottom. + * Pages are laid out in rows starting at the top right, proceeding towards + * the left {@literal &} bottom. */ public static final PresentationDirection TOLEFT_TOBOTTOM = new PresentationDirection(6); /** - * Pages are laid out in rows starting at the bottom right, - * proceeding towards the left {@literal &} top. + * Pages are laid out in rows starting at the bottom right, proceeding + * towards the left {@literal &} top. */ public static final PresentationDirection TOLEFT_TOTOP = new PresentationDirection(7); @@ -113,12 +117,15 @@ public final class PresentationDirection extends EnumSyntax * Construct a new presentation direction enumeration value with the given * integer value. * - * @param value Integer value. + * @param value Integer value */ private PresentationDirection(int value) { super (value); } + /** + * The string table for class {@code PresentationDirection}. + */ private static final String[] myStringTable = { "tobottom-toright", "tobottom-toleft", @@ -130,6 +137,9 @@ public final class PresentationDirection extends EnumSyntax "toleft-totop", }; + /** + * The enumeration value table for class {@code PresentationDirection}. + */ private static final PresentationDirection[] myEnumValueTable = { TOBOTTOM_TORIGHT, TOBOTTOM_TOLEFT, @@ -142,14 +152,15 @@ public final class PresentationDirection extends EnumSyntax }; /** - * Returns the string table for class PresentationDirection. + * Returns the string table for class {@code PresentationDirection}. */ protected String[] getStringTable() { return myStringTable; } /** - * Returns the enumeration value table for class PresentationDirection. + * Returns the enumeration value table for class + * {@code PresentationDirection}. */ protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; @@ -158,12 +169,12 @@ public final class PresentationDirection extends EnumSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PresentationDirection - * the category is class PresentationDirection itself. + *

+ * For class {@code PresentationDirection} the category is class + * {@code PresentationDirection} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PresentationDirection.class; @@ -172,14 +183,13 @@ public final class PresentationDirection extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PresentationDirection - * the category name is {@code "presentation-direction"}. + *

+ * For class {@code PresentationDirection} the category name is + * {@code "presentation-direction"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "presentation-direction"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrintQuality.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrintQuality.java index 6ed83ff5842..b83ec332de0 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrintQuality.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrintQuality.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,30 +22,35 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; -import javax.print.attribute.EnumSyntax; import javax.print.attribute.DocAttribute; -import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.EnumSyntax; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class PrintQuality is a printing attribute class, an enumeration, + * Class {@code PrintQuality} is a printing attribute class, an enumeration, * that specifies the print quality that the printer uses for the job. - *

- * IPP Compatibility: The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. + *

+ * IPP Compatibility: The category name returned by {@code getName()} is + * the IPP attribute name. The enumeration's integer value is the IPP enum + * value. The {@code toString()} method returns the IPP string representation of + * the attribute value. * - * @author David Mendenhall - * @author Alan Kaminsky + * @author David Mendenhall + * @author Alan Kaminsky */ public class PrintQuality extends EnumSyntax implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -3072341285225858365L; + /** * Lowest quality available on the printer. */ @@ -65,18 +70,24 @@ public class PrintQuality extends EnumSyntax * Construct a new print quality enumeration value with the given integer * value. * - * @param value Integer value. + * @param value Integer value */ protected PrintQuality(int value) { super (value); } + /** + * The string table for class {@code PrintQuality}. + */ private static final String[] myStringTable = { "draft", "normal", "high" }; + /** + * The enumeration value table for class {@code PrintQuality}. + */ private static final PrintQuality[] myEnumValueTable = { DRAFT, NORMAL, @@ -84,21 +95,21 @@ public class PrintQuality extends EnumSyntax }; /** - * Returns the string table for class PrintQuality. + * Returns the string table for class {@code PrintQuality}. */ protected String[] getStringTable() { return myStringTable.clone(); } /** - * Returns the enumeration value table for class PrintQuality. + * Returns the enumeration value table for class {@code PrintQuality}. */ protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } /** - * Returns the lowest integer value used by class PrintQuality. + * Returns the lowest integer value used by class {@code PrintQuality}. */ protected int getOffset() { return 3; @@ -107,12 +118,12 @@ public class PrintQuality extends EnumSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrintQuality and any vendor-defined subclasses, the category is - * class PrintQuality itself. + *

+ * For class {@code PrintQuality} and any vendor-defined subclasses, the + * category is class {@code PrintQuality} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrintQuality.class; @@ -121,14 +132,13 @@ public class PrintQuality extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrintQuality and any vendor-defined subclasses, the category - * name is {@code "print-quality"}. + *

+ * For class {@code PrintQuality} and any vendor-defined subclasses, the + * category name is {@code "print-quality"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "print-quality"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterInfo.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterInfo.java index 13b8ca7c33c..6e5cbeffe14 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterInfo.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,45 +22,47 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.Locale; import javax.print.attribute.Attribute; -import javax.print.attribute.TextSyntax; import javax.print.attribute.PrintServiceAttribute; +import javax.print.attribute.TextSyntax; /** - * Class PrinterInfo is a printing attribute class, a text attribute, that - * provides descriptive information about a printer. This could include things - * like: {@code "This printer can be used for printing color transparencies for - * HR presentations"}, or {@code "Out of courtesy for others, please - * print only small (1-5 page) jobs at this printer"}, or even + * Class {@code PrinterInfo} is a printing attribute class, a text attribute, + * that provides descriptive information about a printer. This could include + * things like: {@code "This printer can be used for printing color + * transparencies for HR presentations"}, or {@code "Out of courtesy for others, + * please print only small (1-5 page) jobs at this printer"}, or even * {@code "This printer is going away on July 1, 1997, please find a new * printer"}. - *

- * IPP Compatibility: The string value gives the IPP name value. The - * locale gives the IPP natural language. The category name returned by - * {@code getName()} gives the IPP attribute name. + *

+ * IPP Compatibility: The string value gives the IPP name value. The + * locale gives the IPP natural language. The category name returned by {@code + * getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class PrinterInfo extends TextSyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 7765280618777599727L; /** - * Constructs a new printer info attribute with the given information - * string and locale. + * Constructs a new printer info attribute with the given information string + * and locale. * - * @param info Printer information string. - * @param locale Natural language of the text string. null - * is interpreted to mean the default locale as returned - * by {@code Locale.getDefault()} - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code info} is null. + * @param info printer information string + * @param locale natural language of the text string. {@code null} is + * interpreted to mean the default locale as returned by + * {@code Locale.getDefault()} + * @throws NullPointerException if {@code info} is {@code null} */ public PrinterInfo(String info, Locale locale) { super (info, locale); @@ -70,23 +72,18 @@ public final class PrinterInfo extends TextSyntax * Returns whether this printer info attribute is equivalent to the passed * in object. To be equivalent, all of the following conditions must be * true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class PrinterInfo. - *
  3. - * This printer info attribute's underlying string and - * {@code object}'s underlying string are equal. - *
  4. - * This printer info attribute's locale and {@code object}'s - * locale are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code PrinterInfo}. + *
  3. This printer info attribute's underlying string and + * {@code object}'s underlying string are equal. + *
  4. This printer info attribute's locale and {@code object}'s locale + * are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this printer - * info attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this printer info + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && object instanceof PrinterInfo); @@ -95,11 +92,12 @@ public final class PrinterInfo extends TextSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrinterInfo, the category is class PrinterInfo itself. + *

+ * For class {@code PrinterInfo}, the category is class + * {@code PrinterInfo} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrinterInfo.class; @@ -108,13 +106,13 @@ public final class PrinterInfo extends TextSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrinterInfo, the category name is {@code "printer-info"}. + *

+ * For class {@code PrinterInfo}, the category name is + * {@code "printer-info"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "printer-info"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterIsAcceptingJobs.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterIsAcceptingJobs.java index 39b4961399a..223bbb1b7db 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterIsAcceptingJobs.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterIsAcceptingJobs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,26 +30,30 @@ import javax.print.attribute.EnumSyntax; import javax.print.attribute.PrintServiceAttribute; /** - * Class PrinterIsAcceptingJobs is a printing attribute class, an enumeration, - * that indicates whether the printer is currently able to accept jobs. This - * value is independent of the {@link PrinterState PrinterState} and {@link - * PrinterStateReasons PrinterStateReasons} attributes because its value does - * not affect the current job; rather it affects future jobs. If the value is - * NOT_ACCEPTING_JOBS, the printer will reject jobs even when the {@link - * PrinterState PrinterState} is IDLE. If value is ACCEPTING_JOBS, the Printer - * will accept jobs even when the {@link PrinterState PrinterState} is STOPPED. - *

- * IPP Compatibility: The IPP boolean value is "true" for ACCEPTING_JOBS - * and "false" for NOT_ACCEPTING_JOBS. The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. + * Class {@code PrinterIsAcceptingJobs} is a printing attribute class, an + * enumeration, that indicates whether the printer is currently able to accept + * jobs. This value is independent of the {@link PrinterState PrinterState} and + * {@link PrinterStateReasons PrinterStateReasons} attributes because its value + * does not affect the current job; rather it affects future jobs. If the value + * is {@code NOT_ACCEPTING_JOBS}, the printer will reject jobs even when the + * {@link PrinterState PrinterState} is {@code IDLE}. If value is + * {@code ACCEPTING_JOBS}, the Printer will accept jobs even when the + * {@link PrinterState PrinterState} is {@code STOPPED}. + *

+ * IPP Compatibility: The IPP boolean value is "true" for + * {@code ACCEPTING_JOBS} and "false" for {@code NOT_ACCEPTING_JOBS}. The + * category name returned by {@code getName()} is the IPP attribute name. The + * enumeration's integer value is the IPP enum value. The {@code toString()} + * method returns the IPP string representation of the attribute value. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class PrinterIsAcceptingJobs extends EnumSyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -5052010680537678061L; /** @@ -67,31 +72,38 @@ public final class PrinterIsAcceptingJobs extends EnumSyntax * Construct a new printer is accepting jobs enumeration value with the * given integer value. * - * @param value Integer value. + * @param value Integer value */ protected PrinterIsAcceptingJobs(int value) { super (value); } + /** + * The string table for class {@code PrinterIsAcceptingJobs}. + */ private static final String[] myStringTable = { "not-accepting-jobs", "accepting-jobs" }; + /** + * The enumeration value table for class {@code PrinterIsAcceptingJobs}. + */ private static final PrinterIsAcceptingJobs[] myEnumValueTable = { NOT_ACCEPTING_JOBS, ACCEPTING_JOBS }; /** - * Returns the string table for class PrinterIsAcceptingJobs. + * Returns the string table for class {@code PrinterIsAcceptingJobs}. */ protected String[] getStringTable() { return myStringTable; } /** - * Returns the enumeration value table for class PrinterIsAcceptingJobs. + * Returns the enumeration value table for class + * {@code PrinterIsAcceptingJobs}. */ protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; @@ -100,12 +112,12 @@ public final class PrinterIsAcceptingJobs extends EnumSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrinterIsAcceptingJobs, the - * category is class PrinterIsAcceptingJobs itself. + *

+ * For class {@code PrinterIsAcceptingJobs}, the category is class + * {@code PrinterIsAcceptingJobs} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrinterIsAcceptingJobs.class; @@ -114,14 +126,13 @@ public final class PrinterIsAcceptingJobs extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrinterIsAcceptingJobs, the - * category name is {@code "printer-is-accepting-jobs"}. + *

+ * For class {@code PrinterIsAcceptingJobs}, the category name is + * {@code "printer-is-accepting-jobs"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "printer-is-accepting-jobs"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterLocation.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterLocation.java index 73056a85820..7b2e2ca9b6a 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterLocation.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterLocation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,41 +22,43 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.Locale; import javax.print.attribute.Attribute; -import javax.print.attribute.TextSyntax; import javax.print.attribute.PrintServiceAttribute; +import javax.print.attribute.TextSyntax; /** - * Class PrinterLocation is a printing attribute class, a text attribute, that - * identifies the location of the device. This could include things like: - * {@code "in Room 123A, second floor of building XYZ"}. - *

- * IPP Compatibility: The string value gives the IPP name value. The + * Class {@code PrinterLocation} is a printing attribute class, a text + * attribute, that identifies the location of the device. This could include + * things like: {@code "in Room 123A, second floor of building XYZ"}. + *

+ * IPP Compatibility: The string value gives the IPP name value. The * locale gives the IPP natural language. The category name returned by * {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class PrinterLocation extends TextSyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -1598610039865566337L; /** * Constructs a new printer location attribute with the given location and * locale. * - * @param location Printer location. - * @param locale Natural language of the text string. null - * is interpreted to mean the default locale as returned - * by {@code Locale.getDefault()} - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code location} is null. + * @param location printer location + * @param locale natural language of the text string. {@code null} is + * interpreted to mean the default locale as returned by + * {@code Locale.getDefault()} + * @throws NullPointerException if {@code location} is {@code null} */ public PrinterLocation(String location, Locale locale) { super (location, locale); @@ -64,25 +66,20 @@ public final class PrinterLocation extends TextSyntax /** * Returns whether this printer location attribute is equivalent to the - * passed in object. To be equivalent, all of the following conditions - * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class PrinterLocation. - *
  3. - * This printer location attribute's underlying string and - * {@code object}'s underlying string are equal. - *
  4. - * This printer location attribute's locale and {@code object}'s - * locale are equal. - *
+ * passed in object. To be equivalent, all of the following conditions must + * be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code PrinterLocation}. + *
  3. This printer location attribute's underlying string and + * {@code object}'s underlying string are equal. + *
  4. This printer location attribute's locale and {@code object}'s + * locale are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this printer - * location attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this printer + * location attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && object instanceof PrinterLocation); @@ -91,12 +88,12 @@ public final class PrinterLocation extends TextSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrinterLocation, the - * category is class PrinterLocation itself. + *

+ * For class {@code PrinterLocation}, the category is class + * {@code PrinterLocation} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrinterLocation.class; @@ -105,14 +102,13 @@ public final class PrinterLocation extends TextSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrinterLocation, the - * category name is {@code "printer-location"}. + *

+ * For class {@code PrinterLocation}, the category name is + * {@code "printer-location"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "printer-location"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMakeAndModel.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMakeAndModel.java index 55a61ea44a3..cf5b9a7eb83 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMakeAndModel.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMakeAndModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,39 +22,42 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.Locale; + import javax.print.attribute.Attribute; -import javax.print.attribute.TextSyntax; import javax.print.attribute.PrintServiceAttribute; +import javax.print.attribute.TextSyntax; /** - * Class PrinterMakeAndModel is a printing attribute class, a text attribute, - * that the make and model of the printer. - *

- * IPP Compatibility: The string value gives the IPP name value. The + * Class {@code PrinterMakeAndModel} is a printing attribute class, a text + * attribute, that the make and model of the printer. + *

+ * IPP Compatibility: The string value gives the IPP name value. The * locale gives the IPP natural language. The category name returned by * {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class PrinterMakeAndModel extends TextSyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 4580461489499351411L; /** - * Constructs a new printer make and model attribute with the given make - * and model string and locale. + * Constructs a new printer make and model attribute with the given make and + * model string and locale. * - * @param makeAndModel Printer make and model string. - * @param locale Natural language of the text string. null - * is interpreted to mean the default locale as returned - * by {@code Locale.getDefault()} - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code makeAndModel} is null. + * @param makeAndModel printer make and model string + * @param locale natural language of the text string. {@code null} is + * interpreted to mean the default locale as returned by + * {@code Locale.getDefault()} + * @throws NullPointerException if {@code makeAndModel} is {@code null} */ public PrinterMakeAndModel(String makeAndModel, Locale locale) { super (makeAndModel, locale); @@ -64,23 +67,18 @@ public final class PrinterMakeAndModel extends TextSyntax * Returns whether this printer make and model attribute is equivalent to * the passed in object. To be equivalent, all of the following conditions * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class PrinterMakeAndModel. - *
  3. - * This printer make and model attribute's underlying string and - * {@code object}'s underlying string are equal. - *
  4. - * This printer make and model attribute's locale and - * {@code object}'s locale are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code PrinterMakeAndModel}. + *
  3. This printer make and model attribute's underlying string and + * {@code object}'s underlying string are equal. + *
  4. This printer make and model attribute's locale and {@code object}'s + * locale are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this printer - * make and model attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this printer make + * and model attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && @@ -90,12 +88,12 @@ public final class PrinterMakeAndModel extends TextSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrinterMakeAndModel, the - * category is class PrinterMakeAndModel itself. + *

+ * For class {@code PrinterMakeAndModel}, the category is class + * {@code PrinterMakeAndModel} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrinterMakeAndModel.class; @@ -104,14 +102,13 @@ public final class PrinterMakeAndModel extends TextSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrinterMakeAndModel, the - * category name is {@code "printer-make-and-model"}. + *

+ * For class {@code PrinterMakeAndModel}, the category name is + * {@code "printer-make-and-model"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "printer-make-and-model"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMessageFromOperator.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMessageFromOperator.java index 94388ca9469..70199f859a3 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMessageFromOperator.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMessageFromOperator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,54 +22,54 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.Locale; import javax.print.attribute.Attribute; -import javax.print.attribute.TextSyntax; import javax.print.attribute.PrintServiceAttribute; +import javax.print.attribute.TextSyntax; /** - * Class PrinterMessageFromOperator is a printing attribute class, a text - * attribute, that provides a message from an operator, system administrator, - * or "intelligent" process to indicate to the end user information about or - * status of the printer, such as why it is unavailable or when it is - * expected to be available. - *

- * A Print Service's attribute set includes zero instances or one instance of - * a - * PrinterMessageFromOperator attribute, not more than one instance. A new - * PrinterMessageFromOperator attribute replaces an existing - * PrinterMessageFromOperator attribute, if any. In other words, - * PrinterMessageFromOperator is not intended to be a history log. - * If it wishes, the client can detect changes to a Print Service's - * PrinterMessageFromOperator - * attribute and maintain the client's own history log of the - * PrinterMessageFromOperator attribute values. - *

- * IPP Compatibility: The string value gives the IPP name value. The + * Class {@code PrinterMessageFromOperator} is a printing attribute class, a + * text attribute, that provides a message from an operator, system + * administrator, or "intelligent" process to indicate to the end user + * information about or status of the printer, such as why it is unavailable or + * when it is expected to be available. + *

+ * A Print Service's attribute set includes zero instances or one instance of a + * {@code PrinterMessageFromOperator} attribute, not more than one instance. A + * new {@code PrinterMessageFromOperator} attribute replaces an existing + * {@code PrinterMessageFromOperator} attribute, if any. In other words, + * {@code PrinterMessageFromOperator} is not intended to be a history log. If it + * wishes, the client can detect changes to a Print Service's + * {@code PrinterMessageFromOperator} attribute and maintain the client's own + * history log of the {@code PrinterMessageFromOperator} attribute values. + *

+ * IPP Compatibility: The string value gives the IPP name value. The * locale gives the IPP natural language. The category name returned by * {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class PrinterMessageFromOperator extends TextSyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ static final long serialVersionUID = -4486871203218629318L; /** - * Constructs a new printer message from operator attribute with the - * given message and locale. + * Constructs a new printer message from operator attribute with the given + * message and locale. * - * @param message Message. - * @param locale Natural language of the text string. null - * is interpreted to mean the default locale as returned - * by {@code Locale.getDefault()} - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code message} is null. + * @param message the message + * @param locale natural language of the text string. {@code null} is + * interpreted to mean the default locale as returned by + * {@code Locale.getDefault()} + * @throws NullPointerException if {@code message} is {@code null} */ public PrinterMessageFromOperator(String message, Locale locale) { super (message, locale); @@ -79,24 +79,19 @@ public final class PrinterMessageFromOperator extends TextSyntax * Returns whether this printer message from operator attribute is * equivalent to the passed in object. To be equivalent, all of the * following conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class - * PrinterMessageFromOperator. - *
  3. - * This printer message from operator attribute's underlying string and - * {@code object}'s underlying string are equal. - *
  4. - * This printer message from operator attribute's locale and - * {@code object}'s locale are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class + * {@code PrinterMessageFromOperator}. + *
  3. This printer message from operator attribute's underlying string + * and {@code object}'s underlying string are equal. + *
  4. This printer message from operator attribute's locale and + * {@code object}'s locale are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this printer - * message from operator attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this printer + * message from operator attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && @@ -106,12 +101,12 @@ public final class PrinterMessageFromOperator extends TextSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrinterMessageFromOperator, - * the category is class PrinterMessageFromOperator itself. + *

+ * For class {@code PrinterMessageFromOperator}, the category is class + * {@code PrinterMessageFromOperator} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrinterMessageFromOperator.class; @@ -120,14 +115,13 @@ public final class PrinterMessageFromOperator extends TextSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrinterMessageFromOperator, - * the category name is {@code "printer-message-from-operator"}. + *

+ * For class {@code PrinterMessageFromOperator}, the category name is + * {@code "printer-message-from-operator"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "printer-message-from-operator"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfo.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfo.java index 285a42574b0..1095515fd75 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfo.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,48 +22,50 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.net.URI; import javax.print.attribute.Attribute; -import javax.print.attribute.URISyntax; import javax.print.attribute.PrintServiceAttribute; +import javax.print.attribute.URISyntax; /** - * Class PrinterMoreInfo is a printing attribute class, a URI, that is used to - * obtain more information about this specific printer. For example, this - * could be an HTTP type URI referencing an HTML page accessible to a web - * browser. The information obtained from this URI is intended for end user - * consumption. Features outside the scope of the Print Service API can be - * accessed from this URI. - * The information is intended to be specific to this printer instance and - * site specific services (e.g. job pricing, services offered, end user - * assistance). - *

- * In contrast, the {@link PrinterMoreInfoManufacturer - * PrinterMoreInfoManufacturer} attribute is used to find out more information - * about this general kind of printer rather than this specific printer. - *

- * IPP Compatibility: The string form returned by - * {@code toString()} gives the IPP uri value. - * The category name returned by {@code getName()} + * Class {@code PrinterMoreInfo} is a printing attribute class, a {@code URI}, + * that is used to obtain more information about this specific printer. For + * example, this could be an HTTP type {@code URI} referencing an HTML page + * accessible to a web browser. The information obtained from this {@code URI} + * is intended for end user consumption. Features outside the scope of the Print + * Service API can be accessed from this {@code URI}. The information is + * intended to be specific to this printer instance and site specific services + * (e.g. job pricing, services offered, end user assistance). + *

+ * In contrast, the + * {@link PrinterMoreInfoManufacturer PrinterMoreInfoManufacturer} attribute is + * used to find out more information about this general kind of printer rather + * than this specific printer. + *

+ * IPP Compatibility: The string form returned by {@code toString()} + * gives the IPP uri value. The category name returned by {@code getName()} * gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class PrinterMoreInfo extends URISyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 4555850007675338574L; /** - * Constructs a new printer more info attribute with the specified URI. + * Constructs a new printer more info attribute with the specified + * {@code URI}. * - * @param uri URI. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code uri} is null. + * @param uri {@code URI} + * @throws NullPointerException if {@code uri} is {@code null} */ public PrinterMoreInfo(URI uri) { super (uri); @@ -71,22 +73,18 @@ public final class PrinterMoreInfo extends URISyntax /** * Returns whether this printer more info attribute is equivalent to the - * passed in object. To be equivalent, all of the following conditions - * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class PrinterMoreInfo. - *
  3. - * This printer more info attribute's URI and {@code object}'s URI - * are equal. - *
+ * passed in object. To be equivalent, all of the following conditions must + * be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code PrinterMoreInfo}. + *
  3. This printer more info attribute's {@code URI} and {@code object}'s + * {@code URI} are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this printer - * more info attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this printer more + * info attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && @@ -96,11 +94,12 @@ public final class PrinterMoreInfo extends URISyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrinterMoreInfo, the category is class PrinterMoreInfo itself. + *

+ * For class {@code PrinterMoreInfo}, the category is class + * {@code PrinterMoreInfo} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrinterMoreInfo.class; @@ -109,14 +108,13 @@ public final class PrinterMoreInfo extends URISyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrinterMoreInfo, the - * category name is {@code "printer-more-info"}. + *

+ * For class {@code PrinterMoreInfo}, the category name is + * {@code "printer-more-info"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "printer-more-info"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfoManufacturer.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfoManufacturer.java index 881b5cb8a14..73ed4ded77a 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfoManufacturer.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterMoreInfoManufacturer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,49 +22,49 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.net.URI; import javax.print.attribute.Attribute; -import javax.print.attribute.URISyntax; import javax.print.attribute.PrintServiceAttribute; +import javax.print.attribute.URISyntax; /** - * Class PrinterMoreInfoManufacturer is a printing attribute class, a URI, - * that is used to obtain more information about this type of device. - * The information obtained from this URI is intended for end user - * consumption. Features outside the scope of the Print Service API - * can be accessed from this URI (e.g., - * latest firmware, upgrades, service proxies, optional features available, - * details on color support). The information is intended to be germane to - * this kind of printer without regard to site specific modifications or - * services. - *

- * In contrast, the {@link PrinterMoreInfo PrinterMoreInfo} attribute is used - * to find out more information about this specific printer rather than this + * Class {@code PrinterMoreInfoManufacturer} is a printing attribute class, a + * {@code URI}, that is used to obtain more information about this type of + * device. The information obtained from this {@code URI} is intended for end + * user consumption. Features outside the scope of the Print Service API can be + * accessed from this {@code URI} (e.g., latest firmware, upgrades, service + * proxies, optional features available, details on color support). The + * information is intended to be germane to this kind of printer without regard + * to site specific modifications or services. + *

+ * In contrast, the {@link PrinterMoreInfo PrinterMoreInfo} attribute is used to + * find out more information about this specific printer rather than this * general kind of printer. - *

- * IPP Compatibility: The string form returned by - * {@code toString()} gives the IPP uri value. - * The category name returned by {@code getName()} + *

+ * IPP Compatibility: The string form returned by {@code toString()} + * gives the IPP uri value. The category name returned by {@code getName()} * gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class PrinterMoreInfoManufacturer extends URISyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 3323271346485076608L; /** * Constructs a new printer more info manufacturer attribute with the - * specified URI. + * specified {@code URI}. * - * @param uri URI. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code uri} is null. + * @param uri {@code URI} + * @throws NullPointerException if {@code uri} is {@code null} */ public PrinterMoreInfoManufacturer(URI uri) { super (uri); @@ -74,21 +74,17 @@ public final class PrinterMoreInfoManufacturer extends URISyntax * Returns whether this printer more info manufacturer attribute is * equivalent to the passed in object. To be equivalent, all of the * following conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class - * PrinterMoreInfoManufacturer. - *
  3. - * This printer more info manufacturer attribute's URI and - * {@code object}'s URI are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class + * {@code PrinterMoreInfoManufacturer}. + *
  3. This printer more info manufacturer attribute's {@code URI} and + * {@code object}'s {@code URI} are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this printer - * more info manufacturer attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this printer more + * info manufacturer attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && @@ -98,12 +94,12 @@ public final class PrinterMoreInfoManufacturer extends URISyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrinterMoreInfoManufacturer, the category is - * class PrinterMoreInfoManufacturer itself. + *

+ * For class {@code PrinterMoreInfoManufacturer}, the category is class + * {@code PrinterMoreInfoManufacturer} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrinterMoreInfoManufacturer.class; @@ -112,14 +108,13 @@ public final class PrinterMoreInfoManufacturer extends URISyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrinterMoreInfoManufacturer, the category name is + *

+ * For class {@code PrinterMoreInfoManufacturer}, the category name is * {@code "printer-more-info-manufacturer"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "printer-more-info-manufacturer"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterName.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterName.java index 3bc293df02b..e17bef9f796 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterName.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,43 +22,45 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.Locale; import javax.print.attribute.Attribute; -import javax.print.attribute.TextSyntax; import javax.print.attribute.PrintServiceAttribute; +import javax.print.attribute.TextSyntax; /** - * Class PrinterName is a printing attribute class, a text attribute, that - * specifies the name of a printer. It is a name that is more end-user friendly - * than a URI. An administrator determines a printer's name and sets this - * attribute to that name. This name may be the last part of the printer's URI - * or it may be unrelated. In non-US-English locales, a name may contain - * characters that are not allowed in a URI. - *

- * IPP Compatibility: The string value gives the IPP name value. The + * Class {@code PrinterName} is a printing attribute class, a text attribute, + * that specifies the name of a printer. It is a name that is more end-user + * friendly than a {@code URI}. An administrator determines a printer's name and + * sets this attribute to that name. This name may be the last part of the + * printer's {@code URI} or it may be unrelated. In non-US-English locales, a + * name may contain characters that are not allowed in a {@code URI}. + *

+ * IPP Compatibility: The string value gives the IPP name value. The * locale gives the IPP natural language. The category name returned by * {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class PrinterName extends TextSyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 299740639137803127L; /** * Constructs a new printer name attribute with the given name and locale. * - * @param printerName Printer name. - * @param locale Natural language of the text string. null - * is interpreted to mean the default locale as returned - * by {@code Locale.getDefault()} - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code printerName} is null. + * @param printerName printer name + * @param locale natural language of the text string. {@code null} is + * interpreted to mean the default locale as returned by + * {@code Locale.getDefault()} + * @throws NullPointerException if {@code printerName} is {@code null} */ public PrinterName(String printerName, Locale locale) { super (printerName, locale); @@ -68,23 +70,18 @@ public final class PrinterName extends TextSyntax * Returns whether this printer name attribute is equivalent to the passed * in object. To be equivalent, all of the following conditions must be * true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class PrinterName. - *
  3. - * This printer name attribute's underlying string and - * {@code object}'s underlying string are equal. - *
  4. - * This printer name attribute's locale and {@code object}'s locale - * are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code PrinterName}. + *
  3. This printer name attribute's underlying string and + * {@code object}'s underlying string are equal. + *
  4. This printer name attribute's locale and {@code object}'s locale + * are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this printer - * name attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this printer name + * attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && object instanceof PrinterName); @@ -93,12 +90,12 @@ public final class PrinterName extends TextSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrinterName, the category is - * class PrinterName itself. + *

+ * For class {@code PrinterName}, the category is class + * {@code PrinterName} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrinterName.class; @@ -107,14 +104,13 @@ public final class PrinterName extends TextSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrinterName, the category - * name is {@code "printer-name"}. + *

+ * For class {@code PrinterName}, the category name is + * {@code "printer-name"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "printer-name"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterResolution.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterResolution.java index 408d2007324..f51c16694bb 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterResolution.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterResolution.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,71 +22,66 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; -import javax.print.attribute.ResolutionSyntax; import javax.print.attribute.DocAttribute; -import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.ResolutionSyntax; /** - * Class PrinterResolution is a printing attribute class that specifies an - * exact resolution supported by a printer or to be used for a print job. + * Class {@code PrinterResolution} is a printing attribute class that specifies + * an exact resolution supported by a printer or to be used for a print job. * This attribute assumes that printers have a small set of device resolutions * at which they can operate rather than a continuum. *

- * PrinterResolution is used in multiple ways: - *

    - *
  1. - * When a client searches looking for a printer that supports the client's - * desired resolution exactly (no more, no less), the client specifies - * an instance of class PrinterResolution indicating the exact resolution the - * client wants. Only printers supporting that exact resolution will match the - * search. + * {@code PrinterResolution} is used in multiple ways: + *
      + *
    1. When a client searches looking for a printer that supports the client's + * desired resolution exactly (no more, no less), the client specifies an + * instance of class {@code PrinterResolution} indicating the exact resolution + * the client wants. Only printers supporting that exact resolution will match + * the search. + *
    2. When a client needs to print a job using the client's desired + * resolution exactly (no more, no less), the client specifies an instance of + * class {@code PrinterResolution} as an attribute of the Print Job. This will + * fail if the Print Job doesn't support that exact resolution, and + * {@code Fidelity} is set to true. + *
    + * If a client wants to locate a printer supporting a resolution greater than + * some required minimum, then it may be necessary to exclude this attribute + * from a lookup request and to directly query the set of supported resolutions, + * and specify the one that most closely meets the client's requirements. In + * some cases this may be more simply achieved by specifying a + * {@code PrintQuality} attribute which often controls resolution. + *

    + * IPP Compatibility: The information needed to construct an IPP + * {@code "printer-resolution"} attribute can be obtained by calling methods on + * the PrinterResolution object. The category name returned by {@code getName()} + * gives the IPP attribute name. * - *

  2. - * When a client needs to print a job using the client's desired resolution - * exactly (no more, no less), the client specifies an instance of class - * PrinterResolution as an attribute of the Print Job. This will fail if the - * Print Job doesn't support that exact resolution, and Fidelity is set to - * true. - *
- * If a client wants to locate a printer supporting a resolution - * greater than some required minimum, then it may be necessary to exclude - * this attribute from a lookup request and to directly query the set of - * supported resolutions, and specify the one that most closely meets - * the client's requirements. - * In some cases this may be more simply achieved by specifying a - * PrintQuality attribute which often controls resolution. - *

- * IPP Compatibility: The information needed to construct an IPP - * {@code "printer-resolution"} attribute can be obtained by calling - * methods on the PrinterResolution object. The category name returned by - * {@code getName()} gives the IPP attribute name. - * - * @author David Mendenhall - * @author Alan Kaminsky + * @author David Mendenhall + * @author Alan Kaminsky */ public final class PrinterResolution extends ResolutionSyntax implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 13090306561090558L; /** * Construct a new printer resolution attribute from the given items. * - * @param crossFeedResolution - * Cross feed direction resolution. - * @param feedResolution - * Feed direction resolution. - * @param units - * Unit conversion factor, e.g. {@code ResolutionSyntax.DPI} - * or {@code ResolutionSyntax.DPCM}. - * - * @exception IllegalArgumentException - * (unchecked exception) Thrown if {@code crossFeedResolution < 1} or - * {@code feedResolution < 1} or {@code units < 1}. + * @param crossFeedResolution cross feed direction resolution + * @param feedResolution feed direction resolution + * @param units unit conversion factor, e.g. {@code ResolutionSyntax.DPI} + * or {@code ResolutionSyntax.DPCM} + * @throws IllegalArgumentException if {@code crossFeedResolution < 1} or + * {@code feedResolution < 1} or {@code units < 1} */ public PrinterResolution(int crossFeedResolution, int feedResolution, int units) { @@ -95,25 +90,20 @@ public final class PrinterResolution extends ResolutionSyntax /** * Returns whether this printer resolution attribute is equivalent to the - * passed in object. To be equivalent, all of the following conditions - * must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class PrinterResolution. - *
  3. - * This attribute's cross feed direction resolution is equal to - * {@code object}'s cross feed direction resolution. - *
  4. - * This attribute's feed direction resolution is equal to - * {@code object}'s feed direction resolution. - *
+ * passed in object. To be equivalent, all of the following conditions must + * be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code PrinterResolution}. + *
  3. This attribute's cross feed direction resolution is equal to + * {@code object}'s cross feed direction resolution. + *
  4. This attribute's feed direction resolution is equal to + * {@code object}'s feed direction resolution. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this printer - * resolution attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this printer + * resolution attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && @@ -123,27 +113,27 @@ public final class PrinterResolution extends ResolutionSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrinterResolution, the category is class PrinterResolution itself. + *

+ * For class {@code PrinterResolution}, the category is class + * {@code PrinterResolution} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrinterResolution.class; - } + } /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrinterResolution, the - * category name is {@code "printer-resolution"}. + *

+ * For class {@code PrinterResolution}, the category name is + * {@code "printer-resolution"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "printer-resolution"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterState.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterState.java index 4af01a6cda6..c9c98b07d3d 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterState.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,25 +30,28 @@ import javax.print.attribute.EnumSyntax; import javax.print.attribute.PrintServiceAttribute; /** - * Class PrinterState is a printing attribute class, an enumeration, that - * identifies the current state of a printer. Class PrinterState defines - * standard printer state values. A Print Service implementation only needs - * to report those printer states which are appropriate for the particular + * Class {@code PrinterState} is a printing attribute class, an enumeration, + * that identifies the current state of a printer. Class {@code PrinterState} + * defines standard printer state values. A Print Service implementation only + * needs to report those printer states which are appropriate for the particular * implementation; it does not have to report every defined printer state. The * {@link PrinterStateReasons PrinterStateReasons} attribute augments the - * PrinterState attribute to give more detailed information about the printer - * in given printer state. - *

- * IPP Compatibility: The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. + * {@code PrinterState} attribute to give more detailed information about the + * printer in given printer state. + *

+ * IPP Compatibility: The category name returned by {@code getName()} is + * the IPP attribute name. The enumeration's integer value is the IPP enum + * value. The {@code toString()} method returns the IPP string representation of + * the attribute value. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class PrinterState extends EnumSyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -649578618346507718L; /** @@ -61,8 +65,7 @@ implements PrintServiceAttribute { public static final PrinterState IDLE = new PrinterState(3); /** - * Indicates that jobs are processing; - * new jobs will wait before processing. + * Indicates that jobs are processing; new jobs will wait before processing. */ public static final PrinterState PROCESSING = new PrinterState(4); @@ -75,12 +78,15 @@ implements PrintServiceAttribute { * Construct a new printer state enumeration value with the given integer * value. * - * @param value Integer value. + * @param value Integer value */ protected PrinterState(int value) { super (value); } + /** + * The string table for class {@code PrinterState}. + */ private static final String[] myStringTable = { "unknown", null, @@ -90,6 +96,9 @@ implements PrintServiceAttribute { "stopped" }; + /** + * The enumeration value table for class {@code PrinterState}. + */ private static final PrinterState[] myEnumValueTable = { UNKNOWN, null, @@ -100,14 +109,14 @@ implements PrintServiceAttribute { }; /** - * Returns the string table for class PrinterState. + * Returns the string table for class {@code PrinterState}. */ protected String[] getStringTable() { return myStringTable; } /** - * Returns the enumeration value table for class PrinterState. + * Returns the enumeration value table for class {@code PrinterState}. */ protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; @@ -116,11 +125,12 @@ implements PrintServiceAttribute { /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrinterState, the category is class PrinterState itself. + *

+ * For class {@code PrinterState}, the category is class + * {@code PrinterState} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrinterState.class; @@ -129,13 +139,13 @@ implements PrintServiceAttribute { /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrinterState, the category name is {@code "printer-state"}. + *

+ * For class {@code PrinterState}, the category name is + * {@code "printer-state"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "printer-state"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReason.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReason.java index cdcb8e56d88..5c07411e1d1 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReason.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReason.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,50 +22,51 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; -import javax.print.attribute.EnumSyntax; import javax.print.attribute.Attribute; +import javax.print.attribute.EnumSyntax; /** - * Class PrinterStateReason is a printing attribute class, an enumeration, - * that provides additional information about the printer's current state, - * i.e., information that augments the value of the printer's - * {@link PrinterState PrinterState} attribute. - * Class PrinterStateReason defines standard printer - * state reason values. A Print Service implementation only needs to report - * those printer state reasons which are appropriate for the particular - * implementation; it does not have to report every defined printer state - * reason. - *

- * Instances of PrinterStateReason do not appear in a Print Service's - * attribute set directly. - * Rather, a {@link PrinterStateReasons PrinterStateReasons} - * attribute appears in the Print Service's attribute set. The {@link - * PrinterStateReasons PrinterStateReasons} attribute contains zero, one, or - * more than one PrinterStateReason objects which pertain to the - * Print Service's status, and each PrinterStateReason object is - * associated with a {@link Severity Severity} level of REPORT (least severe), - * WARNING, or ERROR (most severe). The printer adds a PrinterStateReason - * object to the Print Service's + * Class {@code PrinterStateReason} is a printing attribute class, an + * enumeration, that provides additional information about the printer's current + * state, i.e., information that augments the value of the printer's + * {@link PrinterState PrinterState} attribute. Class PrinterStateReason defines + * standard printer state reason values. A Print Service implementation only + * needs to report those printer state reasons which are appropriate for the + * particular implementation; it does not have to report every defined printer + * state reason. + *

+ * Instances of {@code PrinterStateReason} do not appear in a Print Service's + * attribute set directly. Rather, a + * {@link PrinterStateReasons PrinterStateReasons} attribute appears in the + * Print Service's attribute set. The + * {@link PrinterStateReasons PrinterStateReasons} attribute contains zero, one, + * or more than one {@code PrinterStateReason} objects which pertain to the + * Print Service's status, and each PrinterStateReason object is associated with + * a {@link Severity Severity} level of {@code REPORT} (least severe), + * {@code WARNING}, or {@code ERROR} (most severe). The printer adds a + * {@code PrinterStateReason} object to the Print Service's * {@link PrinterStateReasons PrinterStateReasons} attribute when the - * corresponding condition becomes true of the printer, and the printer - * removes the PrinterStateReason object again when the corresponding - * condition becomes false, regardless of whether the Print Service's overall + * corresponding condition becomes true of the printer, and the printer removes + * the {@code PrinterStateReason} object again when the corresponding condition + * becomes false, regardless of whether the Print Service's overall * {@link PrinterState PrinterState} also changed. - *

- * IPP Compatibility: - * The string values returned by each individual {@link PrinterStateReason} and - * associated {@link Severity} object's {@code toString()} - * methods, concatenated together with a hyphen ({@code "-"}) in - * between, gives the IPP keyword value for a {@link PrinterStateReasons}. - * The category name returned by {@code getName()} gives the IPP - * attribute name. + *

+ * IPP Compatibility: The string values returned by each individual + * {@link PrinterStateReason} and associated {@link Severity} object's + * {@code toString()} methods, concatenated together with a hyphen ({@code "-"}) + * in between, gives the IPP keyword value for a {@link PrinterStateReasons}. + * The category name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public class PrinterStateReason extends EnumSyntax implements Attribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -1623720656201472593L; /** @@ -87,51 +88,48 @@ public class PrinterStateReason extends EnumSyntax implements Attribute { /** * Someone has paused the printer, but the device(s) are taking an - * appreciable time to stop. Later, when all output has stopped, - * the {@link PrinterState PrinterState} becomes STOPPED, - * and the PAUSED value replaces - * the MOVING_TO_PAUSED value in the {@link PrinterStateReasons - * PrinterStateReasons} attribute. This value must be supported if the - * printer can be paused and the implementation takes significant time to - * pause a device in certain circumstances. + * appreciable time to stop. Later, when all output has stopped, the + * {@link PrinterState PrinterState} becomes {@code STOPPED}, and the + * {@code PAUSED} value replaces the {@code MOVING_TO_PAUSED} value in the + * {@link PrinterStateReasons PrinterStateReasons} attribute. This value + * must be supported if the printer can be paused and the implementation + * takes significant time to pause a device in certain circumstances. */ public static final PrinterStateReason MOVING_TO_PAUSED = new PrinterStateReason(3); /** - * Someone has paused the printer and the printer's {@link PrinterState - * PrinterState} is STOPPED. In this state, a printer must not produce - * printed output, but it must perform other operations requested by a - * client. If a printer had been printing a job when the printer was - * paused, - * the Printer must resume printing that job when the printer is no longer - * paused and leave no evidence in the printed output of such a pause. - * This value must be supported if the printer can be paused. + * Someone has paused the printer and the printer's + * {@link PrinterState PrinterState} is {@code STOPPED}. In this state, a + * printer must not produce printed output, but it must perform other + * operations requested by a client. If a printer had been printing a job + * when the printer was paused, the {@code Printer} must resume printing + * that job when the printer is no longer paused and leave no evidence in + * the printed output of such a pause. This value must be supported if the + * printer can be paused. */ public static final PrinterStateReason PAUSED = new PrinterStateReason(4); /** - * Someone has removed a printer from service, and the device may be - * powered down or physically removed. - * In this state, a printer must not produce - * printed output, and unless the printer is realized by a print server - * that is still active, the printer must perform no other operations - * requested by a client. - * If a printer had been printing a job when it was shut down, + * Someone has removed a printer from service, and the device may be powered + * down or physically removed. In this state, a printer must not produce + * printed output, and unless the printer is realized by a print server that + * is still active, the printer must perform no other operations requested + * by a client. If a printer had been printing a job when it was shut down, * the printer need not resume printing that job when the printer is no * longer shut down. If the printer resumes printing such a job, it may * leave evidence in the printed output of such a shutdown, e.g. the part * printed before the shutdown may be printed a second time after the * shutdown. - */ + */ public static final PrinterStateReason SHUTDOWN = new PrinterStateReason(5); /** * The printer has scheduled a job on the output device and is in the - * process of connecting to a shared network output device (and might not - * be able to actually start printing the job for an arbitrarily long time + * process of connecting to a shared network output device (and might not be + * able to actually start printing the job for an arbitrarily long time * depending on the usage of the output device by other servers on the * network). */ @@ -146,14 +144,13 @@ public class PrinterStateReason extends EnumSyntax implements Attribute { TIMED_OUT = new PrinterStateReason(7); /** - * The printer is in the process of stopping the device and will be - * stopped in a while. - * When the device is stopped, the printer will change the - * {@link PrinterState PrinterState} to STOPPED. The STOPPING reason is - * never an error, even for a printer with a single output device. When an - * output device ceases accepting jobs, the printer's {@link - * PrinterStateReasons PrinterStateReasons} will have this reason while - * the output device completes printing. + * The printer is in the process of stopping the device and will be stopped + * in a while. When the device is stopped, the printer will change the + * {@link PrinterState PrinterState} to {@code STOPPED}. The + * {@code STOPPING} reason is never an error, even for a printer with a + * single output device. When an output device ceases accepting jobs, the + * printer's {@link PrinterStateReasons PrinterStateReasons} will have this + * reason while the output device completes printing. */ public static final PrinterStateReason STOPPING = new PrinterStateReason(8); @@ -161,10 +158,9 @@ public class PrinterStateReason extends EnumSyntax implements Attribute { /** * When a printer controls more than one output device, this reason * indicates that one or more output devices are stopped. If the reason's - * severity is a report, fewer than half of the output devices are - * stopped. - * If the reason's severity is a warning, half or more but fewer than - * all of the output devices are stopped. + * severity is a report, fewer than half of the output devices are stopped. + * If the reason's severity is a warning, half or more but fewer than all of + * the output devices are stopped. */ public static final PrinterStateReason STOPPED_PARTLY = new PrinterStateReason(9); @@ -182,12 +178,10 @@ public class PrinterStateReason extends EnumSyntax implements Attribute { TONER_EMPTY = new PrinterStateReason(11); /** - * The limit of persistent storage allocated for spooling has been - * reached. + * The limit of persistent storage allocated for spooling has been reached. * The printer is temporarily unable to accept more jobs. The printer will - * remove this reason when it is able to accept more jobs. - * This value should be used by a non-spooling printer that only - * accepts one or a small number + * remove this reason when it is able to accept more jobs. This value should + * be used by a non-spooling printer that only accepts one or a small number * jobs at a time or a spooling printer that has filled the spool space. */ public static final PrinterStateReason @@ -236,8 +230,7 @@ public class PrinterStateReason extends EnumSyntax implements Attribute { OUTPUT_TRAY_MISSING = new PrinterStateReason(19); /** - * One or more output areas are almost full - * (e.g. tray, stacker, collator). + * One or more output areas are almost full (e.g. tray, stacker, collator). */ public static final PrinterStateReason OUTPUT_AREA_ALMOST_FULL = new PrinterStateReason(20); @@ -317,15 +310,18 @@ public class PrinterStateReason extends EnumSyntax implements Attribute { INTERPRETER_RESOURCE_UNAVAILABLE = new PrinterStateReason(32); /** - * Construct a new printer state reason enumeration value with - * the given integer value. + * Construct a new printer state reason enumeration value with the given + * integer value. * - * @param value Integer value. + * @param value Integer value */ protected PrinterStateReason(int value) { super (value); } + /** + * The string table for class {@code PrinterStateReason}. + */ private static final String[] myStringTable = { "other", "media-needed", @@ -362,6 +358,9 @@ public class PrinterStateReason extends EnumSyntax implements Attribute { "interpreter-resource-unavailable" }; + /** + * The enumeration value table for class {@code PrinterStateReason}. + */ private static final PrinterStateReason[] myEnumValueTable = { OTHER, MEDIA_NEEDED, @@ -399,29 +398,28 @@ public class PrinterStateReason extends EnumSyntax implements Attribute { }; /** - * Returns the string table for class PrinterStateReason. + * Returns the string table for class {@code PrinterStateReason}. */ protected String[] getStringTable() { return myStringTable.clone(); } /** - * Returns the enumeration value table for class PrinterStateReason. + * Returns the enumeration value table for class {@code PrinterStateReason}. */ protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); } - /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrinterStateReason and any vendor-defined subclasses, the - * category is class PrinterStateReason itself. + *

+ * For class {@code PrinterStateReason} and any vendor-defined subclasses, + * the category is class {@code PrinterStateReason} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrinterStateReason.class; @@ -430,14 +428,13 @@ public class PrinterStateReason extends EnumSyntax implements Attribute { /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrinterStateReason and any vendor-defined subclasses, the - * category name is {@code "printer-state-reason"}. + *

+ * For class {@code PrinterStateReason} and any vendor-defined subclasses, + * the category name is {@code "printer-state-reason"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "printer-state-reason"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReasons.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReasons.java index 73248ad5321..344a1063edc 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReasons.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterStateReasons.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,69 +22,72 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.AbstractSet; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; -import java.util.HashMap; import java.util.Set; import javax.print.attribute.Attribute; import javax.print.attribute.PrintServiceAttribute; /** - * Class PrinterStateReasons is a printing attribute class, a set of - * enumeration values, that provides additional information about the - * printer's current state, i.e., information that augments the value of the - * printer's {@link PrinterState PrinterState} attribute. - *

- * Instances of {@link PrinterStateReason PrinterStateReason} do not appear in - * a Print Service's attribute set directly. Rather, a PrinterStateReasons + * Class {@code PrinterStateReasons} is a printing attribute class, a set of + * enumeration values, that provides additional information about the printer's + * current state, i.e., information that augments the value of the printer's + * {@link PrinterState PrinterState} attribute. + *

+ * Instances of {@link PrinterStateReason PrinterStateReason} do not appear in a + * Print Service's attribute set directly. Rather, a {@code PrinterStateReasons} * attribute appears in the Print Service's attribute set. The - * PrinterStateReasons attribute contains zero, one, or more than one {@link - * PrinterStateReason PrinterStateReason} objects which pertain to the Print - * Service's status, and each {@link PrinterStateReason PrinterStateReason} - * object is associated with a {@link Severity Severity} level of REPORT - * (least severe), WARNING, or ERROR (most severe). The printer adds a {@link - * PrinterStateReason PrinterStateReason} object to the Print Service's - * PrinterStateReasons attribute when the corresponding condition becomes true - * of the printer, and the printer removes the {@link PrinterStateReason - * PrinterStateReason} object again when the corresponding condition becomes - * false, regardless of whether the Print Service's overall - * {@link PrinterState PrinterState} also changed. - *

- * Class PrinterStateReasons inherits its implementation from class {@link - * java.util.HashMap java.util.HashMap}. Each entry in the map consists of a + * {@code PrinterStateReasons} attribute contains zero, one, or more than one + * {@link PrinterStateReason PrinterStateReason} objects which pertain to the + * Print Service's status, and each + * {@link PrinterStateReason PrinterStateReason} object is associated with a + * {@link Severity Severity} level of {@code REPORT} (least severe), + * {@code WARNING}, or {@code ERROR} (most severe). The printer adds a + * {@link PrinterStateReason PrinterStateReason} object to the Print Service's + * {@code PrinterStateReasons} attribute when the corresponding condition + * becomes true of the printer, and the printer removes the + * {@link PrinterStateReason PrinterStateReason} object again when the + * corresponding condition becomes false, regardless of whether the Print + * Service's overall {@link PrinterState PrinterState} also changed. + *

+ * Class PrinterStateReasons inherits its implementation from class + * {@link HashMap java.util.HashMap}. Each entry in the map consists of a * {@link PrinterStateReason PrinterStateReason} object (key) mapping to a * {@link Severity Severity} object (value): - *

+ *

* Unlike most printing attributes which are immutable once constructed, class - * PrinterStateReasons is designed to be mutable; you can add {@link - * PrinterStateReason PrinterStateReason} objects to an existing - * PrinterStateReasons object and remove them again. However, like class - * {@link java.util.HashMap java.util.HashMap}, class PrinterStateReasons is - * not multiple thread safe. If a PrinterStateReasons object will be used by + * {@code PrinterStateReasons} is designed to be mutable; you can add + * {@link PrinterStateReason PrinterStateReason} objects to an existing + * {@code PrinterStateReasons} object and remove them again. However, like class + * {@link HashMap java.util.HashMap}, class {@code PrinterStateReasons} is not + * multiple thread safe. If a {@code PrinterStateReasons} object will be used by * multiple threads, be sure to synchronize its operations (e.g., using a * synchronized map view obtained from class {@link java.util.Collections * java.util.Collections}). - *

- * IPP Compatibility: The string values returned by each individual + *

+ * IPP Compatibility: The string values returned by each individual * {@link PrinterStateReason PrinterStateReason} object's and the associated - * {@link Severity Severity} object's {@code toString()} methods, - * concatenated - * together with a hyphen ({@code "-"}) in between, gives the IPP keyword - * value. The category name returned by {@code getName()} gives the IPP - * attribute name. + * {@link Severity Severity} object's {@code toString()} methods, concatenated + * together with a hyphen ({@code "-"}) in between, gives the IPP keyword value. + * The category name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class PrinterStateReasons extends HashMap implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -3731791085163619457L; /** @@ -96,13 +99,11 @@ public final class PrinterStateReasons } /** - * super a new, empty printer state reasons attribute; the underlying + * Construct a new, empty printer state reasons attribute; the underlying * hash map has the given initial capacity and the default load factor. * - * @param initialCapacity Initial capacity. - * - * @throws IllegalArgumentException if the initial capacity is less - * than zero. + * @param initialCapacity initial capacity + * @throws IllegalArgumentException if the initial capacity is negative */ public PrinterStateReasons(int initialCapacity) { super (initialCapacity); @@ -112,11 +113,9 @@ public final class PrinterStateReasons * Construct a new, empty printer state reasons attribute; the underlying * hash map has the given initial capacity and load factor. * - * @param initialCapacity Initial capacity. - * @param loadFactor Load factor. - * - * @throws IllegalArgumentException if the initial capacity is less - * than zero. + * @param initialCapacity initial capacity + * @param loadFactor load factor + * @throws IllegalArgumentException if the initial capacity is negative */ public PrinterStateReasons(int initialCapacity, float loadFactor) { super (initialCapacity, loadFactor); @@ -127,19 +126,15 @@ public final class PrinterStateReasons * {@link PrinterStateReason PrinterStateReason}-to-{@link Severity * Severity} mappings as the given map. The underlying hash map's initial * capacity and load factor are as specified in the superclass constructor - * {@link java.util.HashMap#HashMap(java.util.Map) - * HashMap(Map)}. + * {@link HashMap#HashMap(Map) HashMap(Map)}. * - * @param map Map to copy. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code map} is null or if any - * key or value in {@code map} is null. - * @throws ClassCastException - * (unchecked exception) Thrown if any key in {@code map} is not - * an instance of class {@link PrinterStateReason PrinterStateReason} or - * if any value in {@code map} is not an instance of class - * {@link Severity Severity}. + * @param map map to copy + * @throws NullPointerException if {@code map} is {@code null} or if any key + * or value in {@code map} is {@code null} + * @throws ClassCastException if any key in {@code map} is not an instance + * of class {@link PrinterStateReason PrinterStateReason} or if any + * value in {@code map} is not an instance of class + * {@link Severity Severity} */ public PrinterStateReasons(Map map) { this(); @@ -149,27 +144,23 @@ public final class PrinterStateReasons /** * Adds the given printer state reason to this printer state reasons - * attribute, associating it with the given severity level. If this - * printer state reasons attribute previously contained a mapping for the - * given printer state reason, the old value is replaced. + * attribute, associating it with the given severity level. If this printer + * state reasons attribute previously contained a mapping for the given + * printer state reason, the old value is replaced. * - * @param reason Printer state reason. This must be an instance of - * class {@link PrinterStateReason PrinterStateReason}. - * @param severity Severity of the printer state reason. This must be - * an instance of class {@link Severity Severity}. - * - * @return Previous severity associated with the given printer state - * reason, or {@code null} if the given printer state reason was - * not present. - * - * @throws NullPointerException - * (unchecked exception) Thrown if {@code reason} is null or - * {@code severity} is null. - * @throws ClassCastException - * (unchecked exception) Thrown if {@code reason} is not an - * instance of class {@link PrinterStateReason PrinterStateReason} or if - * {@code severity} is not an instance of class {@link Severity - * Severity}. + * @param reason printer state reason. This must be an instance of class + * {@link PrinterStateReason PrinterStateReason} + * @param severity severity of the printer state reason. This must be an + * instance of class {@link Severity Severity} + * @return previous severity associated with the given printer state reason, + * or {@code null} if the given printer state reason was not + * present + * @throws NullPointerException if {@code reason} is {@code null} or + * {@code severity} is {@code null} + * @throws ClassCastException if {@code reason} is not an instance of class + * {@link PrinterStateReason PrinterStateReason} or if + * {@code severity} is not an instance of class + * {@link Severity Severity} * @since 1.5 */ public Severity put(PrinterStateReason reason, Severity severity) { @@ -185,12 +176,12 @@ public final class PrinterStateReasons /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrinterStateReasons, the - * category is class PrinterStateReasons itself. + *

+ * For class {@code PrinterStateReasons}, the category is class + * {@code PrinterStateReasons} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrinterStateReasons.class; @@ -199,11 +190,11 @@ public final class PrinterStateReasons /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrinterStateReasons, the - * category name is {@code "printer-state-reasons"}. + *

+ * For class {@code PrinterStateReasons}, the category name is + * {@code "printer-state-reasons"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "printer-state-reasons"; @@ -211,24 +202,21 @@ public final class PrinterStateReasons /** * Obtain an unmodifiable set view of the individual printer state reason - * attributes at the given severity level in this PrinterStateReasons - * attribute. Each element in the set view is a {@link PrinterStateReason - * PrinterStateReason} object. The only elements in the set view are the - * {@link PrinterStateReason PrinterStateReason} objects that map to the - * given severity value. The set view is backed by this - * PrinterStateReasons attribute, so changes to this PrinterStateReasons - * attribute are reflected in the set view. - * The set view does not support element insertion or - * removal. The set view's iterator does not support element removal. + * attributes at the given severity level in this + * {@code PrinterStateReasons} attribute. Each element in the set view is a + * {@link PrinterStateReason PrinterStateReason} object. The only elements + * in the set view are the {@link PrinterStateReason PrinterStateReason} + * objects that map to the given severity value. The set view is backed by + * this {@code PrinterStateReasons} attribute, so changes to this + * {@code PrinterStateReasons} attribute are reflected in the set view. The + * set view does not support element insertion or removal. The set view's + * iterator does not support element removal. * - * @param severity Severity level. - * - * @return Set view of the individual {@link PrinterStateReason - * PrinterStateReason} attributes at the given {@link Severity - * Severity} level. - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code severity} is null. + * @param severity severity level + * @return set view of the individual + * {@link PrinterStateReason PrinterStateReason} attributes at the + * given {@link Severity Severity} level + * @throws NullPointerException if {@code severity} is {@code null} */ public Set printerStateReasonSet(Severity severity) { if (severity == null) { @@ -305,5 +293,4 @@ public final class PrinterStateReasons throw new UnsupportedOperationException(); } } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterURI.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterURI.java index b2224d10bfe..c4aa5f69576 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterURI.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/PrinterURI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -22,41 +22,41 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.net.URI; -import java.util.Locale; import javax.print.attribute.Attribute; -import javax.print.attribute.URISyntax; import javax.print.attribute.PrintServiceAttribute; +import javax.print.attribute.URISyntax; /** - * Class PrinterURI is a printing attribute class, a URI, that specifies the - * globally unique name of a printer. If it has such a name, an administrator - * determines a printer's URI and sets this attribute to that name. - *

- * IPP Compatibility: This implements the - * IPP printer-uri attribute. The string form returned by - * {@code toString()} gives the IPP printer-uri value. - * The category name returned by {@code getName()} - * gives the IPP attribute name. + * Class {@code PrinterURI} is a printing attribute class, a {@code URI}, that + * specifies the globally unique name of a printer. If it has such a name, an + * administrator determines a printer's {@code URI} and sets this attribute to + * that name. + *

+ * IPP Compatibility: This implements the IPP printer-uri attribute. The + * string form returned by {@code toString()} gives the IPP printer-uri value. + * The category name returned by {@code getName()} gives the IPP attribute name. * - * @author Robert Herriot + * @author Robert Herriot */ - public final class PrinterURI extends URISyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 7923912792485606497L; /** - * Constructs a new PrinterURI attribute with the specified URI. + * Constructs a new {@code PrinterURI} attribute with the specified + * {@code URI}. * - * @param uri URI of the printer - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code uri} is null. + * @param uri {@code URI} of the printer + * @throws NullPointerException if {@code uri} is {@code null} */ public PrinterURI(URI uri) { super (uri); @@ -66,34 +66,30 @@ public final class PrinterURI extends URISyntax * Returns whether this printer name attribute is equivalent to the passed * in object. To be equivalent, all of the following conditions must be * true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class PrinterURI. - *
  3. - * This PrinterURI attribute's underlying URI and - * {@code object}'s underlying URI are equal. - *
+ *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code PrinterURI}. + *
  3. This {@code PrinterURI} attribute's underlying {@code URI} and + * {@code object}'s underlying {@code URI} are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this PrinterURI - * attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this + * {@code PrinterURI} attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && object instanceof PrinterURI); } - /** + /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class PrinterURI and any vendor-defined subclasses, the category is - * class PrinterURI itself. + *

+ * For class {@code PrinterURI} and any vendor-defined subclasses, the + * category is class {@code PrinterURI} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return PrinterURI.class; @@ -102,14 +98,13 @@ public final class PrinterURI extends URISyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class PrinterURI and any vendor-defined subclasses, the category - * name is {@code "printer-uri"}. + *

+ * For class {@code PrinterURI} and any vendor-defined subclasses, the + * category name is {@code "printer-uri"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "printer-uri"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/QueuedJobCount.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/QueuedJobCount.java index 41a710cb624..87ea357a86c 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/QueuedJobCount.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/QueuedJobCount.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; @@ -29,29 +30,29 @@ import javax.print.attribute.IntegerSyntax; import javax.print.attribute.PrintServiceAttribute; /** - * Class QueuedJobCount is an integer valued printing attribute that indicates - * the number of jobs in the printer whose {@link JobState JobState} is either - * PENDING, PENDING_HELD, PROCESSING, or PROCESSING_STOPPED. - *

- * IPP Compatibility: The integer value gives the IPP integer value. - * The category name returned by {@code getName()} gives the IPP - * attribute name. + * Class {@code QueuedJobCount} is an integer valued printing attribute that + * indicates the number of jobs in the printer whose {@link JobState JobState} + * is either {@code PENDING}, {@code PENDING_HELD}, {@code PROCESSING}, or + * {@code PROCESSING_STOPPED}. + *

+ * IPP Compatibility: The integer value gives the IPP integer value. The + * category name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class QueuedJobCount extends IntegerSyntax implements PrintServiceAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 7499723077864047742L; /** - * Construct a new queued job count attribute with the given integer - * value. + * Construct a new queued job count attribute with the given integer value. * - * @param value Integer value. - * - * @exception IllegalArgumentException - * (Unchecked exception) Thrown if {@code value} is less than 0. + * @param value Integer value + * @throws IllegalArgumentException if {@code value} is negative */ public QueuedJobCount(int value) { super (value, 0, Integer.MAX_VALUE); @@ -59,22 +60,18 @@ public final class QueuedJobCount extends IntegerSyntax /** * Returns whether this queued job count attribute is equivalent to the - * passed in object. To be equivalent, all of the following conditions - * mus be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class QueuedJobCount. - *
  3. - * This queued job count attribute's value and {@code object}'s - * value are equal. - *
+ * passed in object. To be equivalent, all of the following conditions mus + * be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code QueuedJobCount}. + *
  3. This queued job count attribute's value and {@code object}'s value + * are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this queued job - * count attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this queued job + * count attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals (object) && @@ -84,11 +81,12 @@ public final class QueuedJobCount extends IntegerSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class QueuedJobCount, the category is class QueuedJobCount itself. + *

+ * For class {@code QueuedJobCount}, the category is class + * {@code QueuedJobCount} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return QueuedJobCount.class; @@ -97,14 +95,13 @@ public final class QueuedJobCount extends IntegerSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class QueuedJobCount, the - * category name is {@code "queued-job-count"}. + *

+ * For class {@code QueuedJobCount}, the category name is + * {@code "queued-job-count"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "queued-job-count"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java index ac8dcd326b0..b08ba77025d 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/ReferenceUriSchemesSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,45 +22,50 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; -import javax.print.attribute.EnumSyntax; import javax.print.attribute.Attribute; +import javax.print.attribute.EnumSyntax; /** - * Class ReferenceUriSchemesSupported is a printing attribute class - * an enumeration, that indicates a "URI scheme," such as "http:" or "ftp:", - * that a printer can use to retrieve print data stored at a URI location. - * If a printer supports doc flavors with a print data representation class of + * Class {@code ReferenceUriSchemesSupported} is a printing attribute class an + * enumeration, that indicates a "URI scheme," such as "http:" or "ftp:", that a + * printer can use to retrieve print data stored at a {@code URI} location. If a + * printer supports doc flavors with a print data representation class of * {@code "java.net.URL"}, the printer uses instances of class - * ReferenceUriSchemesSupported to advertise the URI schemes it can accept. - * The acceptable URI schemes are included as service attributes in the - * lookup service; this lets clients search the - * for printers that can get print data using a certain URI scheme. The - * acceptable URI schemes can also be queried using the capability methods in - * interface {@code PrintService}. However, - * ReferenceUriSchemesSupported attributes are used solely for determining - * acceptable URI schemes, they are never included in a doc's, - * print request's, print job's, or print service's attribute set. - *

- * The Internet Assigned Numbers Authority maintains the - * official - * list of URI schemes. + * {@code ReferenceUriSchemesSupported} to advertise the {@code URI} schemes it + * can accept. The acceptable {@code URI} schemes are included as service + * attributes in the lookup service; this lets clients search the for printers + * that can get print data using a certain {@code URI} scheme. The acceptable + * {@code URI} schemes can also be queried using the capability methods in + * interface {@code PrintService}. However, {@code ReferenceUriSchemesSupported} + * attributes are used solely for determining acceptable {@code URI} schemes, + * they are never included in a doc's, print request's, print job's, or print + * service's attribute set. *

- * Class ReferenceUriSchemesSupported defines enumeration values for widely - * used URI schemes. A printer that supports additional URI schemes - * can define them in a subclass of class ReferenceUriSchemesSupported. - *

- * IPP Compatibility: The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. + * The Internet Assigned Numbers Authority maintains the + * official list of + * URI schemes. + *

+ * Class {@code ReferenceUriSchemesSupported} defines enumeration values for + * widely used {@code URI} schemes. A printer that supports additional + * {@code URI} schemes can define them in a subclass of class + * {@code ReferenceUriSchemesSupported}. + *

+ * IPP Compatibility: The category name returned by {@code getName()} is + * the IPP attribute name. The enumeration's integer value is the IPP enum + * value. The {@code toString()} method returns the IPP string representation of + * the attribute value. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public class ReferenceUriSchemesSupported extends EnumSyntax implements Attribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -8989076942813442805L; /** @@ -105,15 +110,18 @@ public class ReferenceUriSchemesSupported public static final ReferenceUriSchemesSupported FILE = new ReferenceUriSchemesSupported(7); /** - * Construct a new reference URI scheme enumeration value with the given - * integer value. + * Construct a new reference {@code URI} scheme enumeration value with the + * given integer value. * - * @param value Integer value. + * @param value Integer value */ protected ReferenceUriSchemesSupported(int value) { super (value); } + /** + * The string table for class {@code ReferenceUriSchemesSupported}. + */ private static final String[] myStringTable = { "ftp", "http", @@ -125,6 +133,10 @@ public class ReferenceUriSchemesSupported "file", }; + /** + * The enumeration value table for class + * {@code ReferenceUriSchemesSupported}. + */ private static final ReferenceUriSchemesSupported[] myEnumValueTable = { FTP, HTTP, @@ -137,7 +149,7 @@ public class ReferenceUriSchemesSupported }; /** - * Returns the string table for class ReferenceUriSchemesSupported. + * Returns the string table for class {@code ReferenceUriSchemesSupported}. */ protected String[] getStringTable() { return myStringTable.clone(); @@ -145,7 +157,7 @@ public class ReferenceUriSchemesSupported /** * Returns the enumeration value table for class - * ReferenceUriSchemesSupported. + * {@code ReferenceUriSchemesSupported}. */ protected EnumSyntax[] getEnumValueTable() { return (EnumSyntax[])myEnumValueTable.clone(); @@ -154,12 +166,13 @@ public class ReferenceUriSchemesSupported /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class ReferenceUriSchemesSupported and any vendor-defined - * subclasses, the category is class ReferenceUriSchemesSupported itself. + *

+ * For class {@code ReferenceUriSchemesSupported} and any vendor-defined + * subclasses, the category is class {@code ReferenceUriSchemesSupported} + * itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return ReferenceUriSchemesSupported.class; @@ -168,15 +181,14 @@ public class ReferenceUriSchemesSupported /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class ReferenceUriSchemesSupported and any vendor-defined + *

+ * For class {@code ReferenceUriSchemesSupported} and any vendor-defined * subclasses, the category name is * {@code "reference-uri-schemes-supported"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "reference-uri-schemes-supported"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/RequestingUserName.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/RequestingUserName.java index c0284c8a041..746c01c1fce 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/RequestingUserName.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/RequestingUserName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,77 +22,73 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import java.util.Locale; import javax.print.attribute.Attribute; -import javax.print.attribute.TextSyntax; import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.TextSyntax; /** - * Class RequestingUserName is a printing attribute class, a text attribute, - * that specifies the name of the end user that submitted the print job. A - * requesting user name is an arbitrary string defined by the client. The - * printer does not put the client-specified RequestingUserName attribute into - * the Print Job's attribute set; rather, the printer puts in a {@link - * JobOriginatingUserName JobOriginatingUserName} attribute. - * This means that services which support specifying a username with this - * attribute should also report a JobOriginatingUserName in the job's - * attribute set. Note that many print services may have a way to independently - * authenticate the user name, and so may state support for a - * requesting user name, but in practice will then report the user name - * authenticated by the service rather than that specified via this - * attribute. - *

- * IPP Compatibility: The string value gives the IPP name value. The + * Class {@code RequestingUserName} is a printing attribute class, a text + * attribute, that specifies the name of the end user that submitted the print + * job. A requesting user name is an arbitrary string defined by the client. The + * printer does not put the client-specified {@code RequestingUserName} + * attribute into the Print Job's attribute set; rather, the printer puts in a + * {@link JobOriginatingUserName JobOriginatingUserName} attribute. This means + * that services which support specifying a username with this attribute should + * also report a {@code JobOriginatingUserName} in the job's attribute set. Note + * that many print services may have a way to independently authenticate the + * user name, and so may state support for a requesting user name, but in + * practice will then report the user name authenticated by the service rather + * than that specified via this attribute. + *

+ * IPP Compatibility: The string value gives the IPP name value. The * locale gives the IPP natural language. The category name returned by * {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class RequestingUserName extends TextSyntax implements PrintRequestAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -2683049894310331454L; /** - * Constructs a new requesting user name attribute with the given user - * name and locale. + * Constructs a new requesting user name attribute with the given user name + * and locale. * - * @param userName User name. - * @param locale Natural language of the text string. null - * is interpreted to mean the default locale as returned - * by {@code Locale.getDefault()} - * - * @exception NullPointerException - * (unchecked exception) Thrown if {@code userName} is null. + * @param userName user name + * @param locale natural language of the text string. {@code null} is + * interpreted to mean the default locale as returned by + * {@code Locale.getDefault()} + * @throws NullPointerException if {@code userName} is {@code null} */ public RequestingUserName(String userName, Locale locale) { super (userName, locale); } /** - * Returns whether this requesting user name attribute is equivalent to - * the passed in object. To be equivalent, all of the following - * conditions must be true: - *

    - *
  1. - * {@code object} is not null. - *
  2. - * {@code object} is an instance of class RequestingUserName. - *
  3. - * This requesting user name attribute's underlying string and - * {@code object}'s underlying string are equal. - *
  4. - * This requesting user name attribute's locale and - * {@code object}'s locale are equal. - *
+ * Returns whether this requesting user name attribute is equivalent to the + * passed in object. To be equivalent, all of the following conditions must + * be true: + *
    + *
  1. {@code object} is not {@code null}. + *
  2. {@code object} is an instance of class {@code RequestingUserName}. + *
  3. This requesting user name attribute's underlying string and + * {@code object}'s underlying string are equal. + *
  4. This requesting user name attribute's locale and {@code object}'s + * locale are equal. + *
* - * @param object Object to compare to. - * - * @return True if {@code object} is equivalent to this requesting - * user name attribute, false otherwise. + * @param object {@code Object} to compare to + * @return {@code true} if {@code object} is equivalent to this requesting + * user name attribute, {@code false} otherwise */ public boolean equals(Object object) { return (super.equals(object) && @@ -102,12 +98,12 @@ public final class RequestingUserName extends TextSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class RequestingUserName, the - * category is class RequestingUserName itself. + *

+ * For class {@code RequestingUserName}, the category is class + * {@code RequestingUserName} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return RequestingUserName.class; @@ -116,14 +112,13 @@ public final class RequestingUserName extends TextSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class RequestingUserName, the - * category name is {@code "requesting-user-name"}. + *

+ * For class {@code RequestingUserName}, the category name is + * {@code "requesting-user-name"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "requesting-user-name"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Severity.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Severity.java index d9db96cf299..4983d9624a5 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Severity.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Severity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,54 +22,53 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; -import javax.print.attribute.EnumSyntax; import javax.print.attribute.Attribute; +import javax.print.attribute.EnumSyntax; /** - * Class Severity is a printing attribute class, an enumeration, that denotes - * the severity of a {@link PrinterStateReason PrinterStateReason} attribute. - *

- * Instances of Severity do not appear in a Print Service's attribute set - * directly. Rather, a {@link PrinterStateReasons PrinterStateReasons} + * Class {@code Severity} is a printing attribute class, an enumeration, that + * denotes the severity of a {@link PrinterStateReason PrinterStateReason} + * attribute. + *

+ * Instances of {@code Severity} do not appear in a Print Service's attribute + * set directly. Rather, a {@link PrinterStateReasons PrinterStateReasons} * attribute appears in the Print Service's attribute set. - * The {@link PrinterStateReasons - * PrinterStateReasons} attribute contains zero, one, or more than one {@link - * PrinterStateReason PrinterStateReason} objects which pertain to the Print - * Service's status, and each {@link PrinterStateReason PrinterStateReason} - * object is associated with a Severity level of REPORT (least severe), - * WARNING, or ERROR (most severe). - * The printer adds a {@link PrinterStateReason - * PrinterStateReason} object to the Print Service's + * The {@link PrinterStateReasons PrinterStateReasons} attribute contains zero, + * one, or more than one {@link PrinterStateReason PrinterStateReason} objects + * which pertain to the Print Service's status, and each + * {@link PrinterStateReason PrinterStateReason} object is associated with a + * Severity level of {@code REPORT} (least severe), {@code WARNING}, or + * {@code ERROR} (most severe). The printer adds a + * {@link PrinterStateReason PrinterStateReason} object to the Print Service's * {@link PrinterStateReasons PrinterStateReasons} attribute when the - * corresponding condition becomes true - * of the printer, and the printer removes the {@link PrinterStateReason - * PrinterStateReason} object again when the corresponding condition becomes - * false, regardless of whether the Print Service's overall - * {@link PrinterState PrinterState} also changed. - *

- * IPP Compatibility: - * {@code Severity.toString()} returns either "error", "warning", or - * "report". The string values returned by - * each individual {@link PrinterStateReason} and - * associated {@link Severity} object's {@code toString()} - * methods, concatenated together with a hyphen ({@code "-"}) in - * between, gives the IPP keyword value for a {@link PrinterStateReasons}. - * The category name returned by {@code getName()} gives the IPP - * attribute name. + * corresponding condition becomes true of the printer, and the printer removes + * the {@link PrinterStateReason PrinterStateReason} object again when the + * corresponding condition becomes false, regardless of whether the Print + * Service's overall {@link PrinterState PrinterState} also changed. + *

+ * IPP Compatibility: {@code Severity.toString()} returns either "error", + * "warning", or "report". The string values returned by each individual + * {@link PrinterStateReason} and associated {@link Severity} object's + * {@code toString()} methods, concatenated together with a hyphen ({@code "-"}) + * in between, gives the IPP keyword value for a {@link PrinterStateReasons}. + * The category name returned by {@code getName()} gives the IPP attribute name. * - * @author Alan Kaminsky + * @author Alan Kaminsky */ public final class Severity extends EnumSyntax implements Attribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 8781881462717925380L; /** * Indicates that the {@link PrinterStateReason PrinterStateReason} is a - * "report" (least severe). An implementation may choose to omit some or - * all reports. - * Some reports specify finer granularity about the printer state; + * "report" (least severe). An implementation may choose to omit some or all + * reports. Some reports specify finer granularity about the printer state; * others serve as a precursor to a warning. A report must contain nothing * that could affect the printed output. */ @@ -78,36 +77,41 @@ public final class Severity extends EnumSyntax implements Attribute { /** * Indicates that the {@link PrinterStateReason PrinterStateReason} is a * "warning." An implementation may choose to omit some or all warnings. - * Warnings serve as a precursor to an error. A warning must contain - * nothing that prevents a job from completing, though in some cases the - * output may be of lower quality. + * Warnings serve as a precursor to an error. A warning must contain nothing + * that prevents a job from completing, though in some cases the output may + * be of lower quality. */ public static final Severity WARNING = new Severity (1); /** * Indicates that the {@link PrinterStateReason PrinterStateReason} is an - * "error" (most severe). An implementation must include all errors. - * If this attribute contains one or more errors, the printer's - * {@link PrinterState PrinterState} must be STOPPED. + * "error" (most severe). An implementation must include all errors. If this + * attribute contains one or more errors, the printer's + * {@link PrinterState PrinterState} must be {@code STOPPED}. */ public static final Severity ERROR = new Severity (2); /** - * Construct a new severity enumeration value with the given integer - * value. + * Construct a new severity enumeration value with the given integer value. * - * @param value Integer value. + * @param value Integer value */ protected Severity(int value) { super (value); } + /** + * The string table for class {@code Severity}. + */ private static final String[] myStringTable = { "report", "warning", "error" }; + /** + * The enumeration value table for class {@code Severity}. + */ private static final Severity[] myEnumValueTable = { REPORT, WARNING, @@ -115,28 +119,28 @@ public final class Severity extends EnumSyntax implements Attribute { }; /** - * Returns the string table for class Severity. + * Returns the string table for class {@code Severity}. */ protected String[] getStringTable() { return myStringTable; } /** - * Returns the enumeration value table for class Severity. + * Returns the enumeration value table for class {@code Severity}. */ protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; } - /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class Severity, the category is class Severity itself. + *

+ * For class {@code Severity}, the category is class + * {@code Severity} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return Severity.class; @@ -145,13 +149,12 @@ public final class Severity extends EnumSyntax implements Attribute { /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class Severit, the category name is {@code "severity"}. + *

+ * For class {@code Severity}, the category name is {@code "severity"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "severity"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/SheetCollate.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/SheetCollate.java index b497791f2a1..e1b6fd9062c 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/SheetCollate.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/SheetCollate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,146 +22,134 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; -import javax.print.attribute.EnumSyntax; import javax.print.attribute.DocAttribute; -import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.EnumSyntax; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class SheetCollate is a printing attribute class, an enumeration, that - * specifies whether or not the media sheets of each copy of each printed + * Class {@code SheetCollate} is a printing attribute class, an enumeration, + * that specifies whether or not the media sheets of each copy of each printed * document in a job are to be in sequence, when multiple copies of the document - * are specified by the {@link Copies Copies} attribute. When SheetCollate is - * COLLATED, each copy of each document is printed with the print-stream sheets - * in sequence. When SheetCollate is UNCOLLATED, each print-stream sheet is - * printed a number of times equal to the value of the {@link Copies Copies} - * attribute in succession. For example, suppose a document produces two media - * sheets as output, {@link Copies Copies} is 6, and SheetCollate is UNCOLLATED; - * in this case six copies of the first media sheet are printed followed by - * six copies of the second media sheet. - *

+ * are specified by the {@link Copies Copies} attribute. When + * {@code SheetCollate} is {@code COLLATED}, each copy of each document is + * printed with the print-stream sheets in sequence. When {@code SheetCollate} + * is {@code UNCOLLATED}, each print-stream sheet is printed a number of times + * equal to the value of the {@link Copies Copies} attribute in succession. For + * example, suppose a document produces two media sheets as output, + * {@link Copies Copies} is 6, and {@code SheetCollate} is UNCOLLATED; in this + * case six copies of the first media sheet are printed followed by six copies + * of the second media sheet. + *

* Whether the effect of sheet collation is achieved by placing copies of a * document in multiple output bins or in the same output bin with - * implementation defined document separation is implementation dependent. - * Also whether it is achieved by making multiple passes over the job or by - * using an output sorter is implementation dependent. - *

- * If a printer does not support the SheetCollate attribute (meaning the client - * cannot specify any particular sheet collation), the printer must behave as - * though SheetCollate were always set to COLLATED. - *

- * The SheetCollate attribute interacts with the {@link MultipleDocumentHandling - * MultipleDocumentHandling} attribute. The {@link MultipleDocumentHandling - * MultipleDocumentHandling} attribute describes the collation of entire - * documents, and the SheetCollate attribute describes the semantics of - * collating individual pages within a document. - *

- * The effect of a SheetCollate attribute on a multidoc print job (a job with - * multiple documents) depends on whether all the docs have the same sheet - * collation specified or whether different docs have different sheet - * collations specified, and on the (perhaps defaulted) value of the {@link - * MultipleDocumentHandling MultipleDocumentHandling} attribute. - *

    - *
  • - * If all the docs have the same sheet collation specified, then the following - * combinations of SheetCollate and {@link MultipleDocumentHandling - * MultipleDocumentHandling} are permitted, and the printer reports an error - * when the job is submitted if any other combination is specified: - *
      - *
    • - * SheetCollate = COLLATED, {@link MultipleDocumentHandling - * MultipleDocumentHandling} = SINGLE_DOCUMENT -- All the input docs will be - * combined into one output document. Multiple copies of the output document - * will be produced with pages in collated order, i.e. pages 1, 2, 3, . . ., - * 1, 2, 3, . . . + * implementation defined document separation is implementation dependent. Also + * whether it is achieved by making multiple passes over the job or by using an + * output sorter is implementation dependent. + *

      + * If a printer does not support the {@code SheetCollate} attribute (meaning the + * client cannot specify any particular sheet collation), the printer must + * behave as though {@code SheetCollate} were always set to {@code COLLATED}. + *

      + * The {@code SheetCollate} attribute interacts with the + * {@link MultipleDocumentHandling MultipleDocumentHandling} attribute. The + * {@link MultipleDocumentHandling MultipleDocumentHandling} attribute describes + * the collation of entire documents, and the {@code SheetCollate} attribute + * describes the semantics of collating individual pages within a document. + *

      + * The effect of a {@code SheetCollate} attribute on a multidoc print job (a job + * with multiple documents) depends on whether all the docs have the same sheet + * collation specified or whether different docs have different sheet collations + * specified, and on the (perhaps defaulted) value of the + * {@link MultipleDocumentHandling MultipleDocumentHandling} attribute. + *

        + *
      • If all the docs have the same sheet collation specified, then the + * following combinations of {@code SheetCollate} and + * {@link MultipleDocumentHandling MultipleDocumentHandling} are permitted, + * and the printer reports an error when the job is submitted if any other + * combination is specified: + *
          + *
        • SheetCollate = COLLATED, {@link MultipleDocumentHandling + * MultipleDocumentHandling} = SINGLE_DOCUMENT -- All the input docs will be + * combined into one output document. Multiple copies of the output document + * will be produced with pages in collated order, i.e. pages 1, 2, 3, . . ., + * 1, 2, 3, . . . + *
        • SheetCollate = COLLATED, {@link MultipleDocumentHandling + * MultipleDocumentHandling} = SINGLE_DOCUMENT_NEW_SHEET -- All the input + * docs will be combined into one output document, and the first impression + * of each input doc will always start on a new media sheet. Multiple copies + * of the output document will be produced with pages in collated order, + * i.e. pages 1, 2, 3, . . ., 1, 2, 3, . . . + *
        • SheetCollate = COLLATED, {@link MultipleDocumentHandling + * MultipleDocumentHandling} = SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- Each + * input doc will remain a separate output document. Multiple copies of each + * output document (call them A, B, . . .) will be produced with each + * document's pages in collated order, but the documents themselves in + * uncollated order, i.e. pages A1, A2, A3, . . ., A1, A2, A3, . . ., B1, + * B2, B3, . . ., B1, B2, B3, . . . + *
        • SheetCollate = COLLATED, {@link MultipleDocumentHandling + * MultipleDocumentHandling} = SEPARATE_DOCUMENTS_COLLATED_COPIES -- Each + * input doc will remain a separate output document. Multiple copies of each + * output document (call them A, B, . . .) will be produced with each + * document's pages in collated order, with the documents themselves also in + * collated order, i.e. pages A1, A2, A3, . . ., B1, B2, B3, . . ., A1, A2, + * A3, . . ., B1, B2, B3, . . . + *
        • SheetCollate = UNCOLLATED, {@link MultipleDocumentHandling + * MultipleDocumentHandling} = SINGLE_DOCUMENT -- All the input docs will be + * combined into one output document. Multiple copies of the output document + * will be produced with pages in uncollated order, i.e. pages 1, 1, . . ., + * 2, 2, . . ., 3, 3, . . . + *
        • SheetCollate = UNCOLLATED, {@link MultipleDocumentHandling + * MultipleDocumentHandling} = SINGLE_DOCUMENT_NEW_SHEET -- All the input + * docs will be combined into one output document, and the first impression + * of each input doc will always start on a new media sheet. Multiple copies + * of the output document will be produced with pages in uncollated order, + * i.e. pages 1, 1, . . ., 2, 2, . . ., 3, 3, . . . + *
        • SheetCollate = UNCOLLATED, {@link MultipleDocumentHandling + * MultipleDocumentHandling} = SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- Each + * input doc will remain a separate output document. Multiple copies of each + * output document (call them A, B, . . .) will be produced with each + * document's pages in uncollated order, with the documents themselves also + * in uncollated order, i.e. pages A1, A1, . . ., A2, A2, . . ., A3, A3, . . + * ., B1, B1, . . ., B2, B2, . . ., B3, B3, . . . + *
        + *
      • If different docs have different sheet collations specified, then only + * one value of {@link MultipleDocumentHandling MultipleDocumentHandling} is + * permitted, and the printer reports an error when the job is submitted if + * any other value is specified: + *
          + *
        • {@link MultipleDocumentHandling MultipleDocumentHandling} = + * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- Each input doc will remain a + * separate output document. Multiple copies of each output document (call + * them A, B, . . .) will be produced with each document's pages in collated + * or uncollated order as the corresponding input doc's SheetCollate + * attribute specifies, and with the documents themselves in uncollated + * order. If document A had SheetCollate = UNCOLLATED and document B had + * SheetCollate = COLLATED, the following pages would be produced: A1, A1, . + * . ., A2, A2, . . ., A3, A3, . . ., B1, B2, B3, . . ., B1, B2, B3, . . . + *
        + *
      + *

      + * IPP Compatibility: SheetCollate is not an IPP attribute at present. * - *

    • - * SheetCollate = COLLATED, {@link MultipleDocumentHandling - * MultipleDocumentHandling} = SINGLE_DOCUMENT_NEW_SHEET -- All the input docs - * will be combined into one output document, and the first impression of each - * input doc will always start on a new media sheet. Multiple copies of the - * output document will be produced with pages in collated order, i.e. pages - * 1, 2, 3, . . ., 1, 2, 3, . . . - * - *
    • - * SheetCollate = COLLATED, {@link MultipleDocumentHandling - * MultipleDocumentHandling} = SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- Each - * input doc will remain a separate output document. Multiple copies of each - * output document (call them A, B, . . .) will be produced with each document's - * pages in collated order, but the documents themselves in uncollated order, - * i.e. pages A1, A2, A3, . . ., A1, A2, A3, . . ., B1, B2, B3, . . ., B1, B2, - * B3, . . . - * - *
    • - * SheetCollate = COLLATED, {@link MultipleDocumentHandling - * MultipleDocumentHandling} = SEPARATE_DOCUMENTS_COLLATED_COPIES -- Each input - * doc will remain a separate output document. Multiple copies of each output - * document (call them A, B, . . .) will be produced with each document's pages - * in collated order, with the documents themselves also in collated order, i.e. - * pages A1, A2, A3, . . ., B1, B2, B3, . . ., A1, A2, A3, . . ., B1, B2, B3, - * . . . - * - *
    • - * SheetCollate = UNCOLLATED, {@link MultipleDocumentHandling - * MultipleDocumentHandling} = SINGLE_DOCUMENT -- All the input docs will be - * combined into one output document. Multiple copies of the output document - * will be produced with pages in uncollated order, i.e. pages 1, 1, . . ., - * 2, 2, . . ., 3, 3, . . . - * - *
    • - * SheetCollate = UNCOLLATED, {@link MultipleDocumentHandling - * MultipleDocumentHandling} = SINGLE_DOCUMENT_NEW_SHEET -- All the input docs - * will be combined into one output document, and the first impression of each - * input doc will always start on a new media sheet. Multiple copies of the - * output document will be produced with pages in uncollated order, i.e. pages - * 1, 1, . . ., 2, 2, . . ., 3, 3, . . . - * - *
    • - * SheetCollate = UNCOLLATED, {@link MultipleDocumentHandling - * MultipleDocumentHandling} = SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- Each - * input doc will remain a separate output document. Multiple copies of each - * output document (call them A, B, . . .) will be produced with each document's - * pages in uncollated order, with the documents themselves also in uncollated - * order, i.e. pages A1, A1, . . ., A2, A2, . . ., A3, A3, . . ., B1, B1, . . ., - * B2, B2, . . ., B3, B3, . . . - *
    - * - *
  • - * If different docs have different sheet collations specified, then only one - * value of {@link MultipleDocumentHandling MultipleDocumentHandling} is - * permitted, and the printer reports an error when the job is submitted if any - * other value is specified: - *
      - *
    • - * {@link MultipleDocumentHandling MultipleDocumentHandling} = - * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- Each input doc will remain a separate - * output document. Multiple copies of each output document (call them A, B, - * . . .) will be produced with each document's pages in collated or uncollated - * order as the corresponding input doc's SheetCollate attribute specifies, and - * with the documents themselves in uncollated order. If document A had - * SheetCollate = UNCOLLATED and document B had SheetCollate = COLLATED, the - * following pages would be produced: A1, A1, . . ., A2, A2, . . ., A3, A3, - * . . ., B1, B2, B3, . . ., B1, B2, B3, . . . - *
    - *
- *

- * IPP Compatibility: SheetCollate is not an IPP attribute at present. - * - * @see MultipleDocumentHandling - * - * @author Alan Kaminsky + * @author Alan Kaminsky + * @see MultipleDocumentHandling */ public final class SheetCollate extends EnumSyntax implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 7080587914259873003L; /** - * Sheets within a document appear in uncollated order when multiple - * copies are printed. + * Sheets within a document appear in uncollated order when multiple copies + * are printed. */ public static final SheetCollate UNCOLLATED = new SheetCollate(0); @@ -175,31 +163,37 @@ public final class SheetCollate extends EnumSyntax * Construct a new sheet collate enumeration value with the given integer * value. * - * @param value Integer value. + * @param value Integer value */ protected SheetCollate(int value) { super (value); } + /** + * The string table for class {@code SheetCollate}. + */ private static final String[] myStringTable = { "uncollated", "collated" }; + /** + * The enumeration value table for class {@code SheetCollate}. + */ private static final SheetCollate[] myEnumValueTable = { UNCOLLATED, COLLATED }; /** - * Returns the string table for class SheetCollate. + * Returns the string table for class {@code SheetCollate}. */ protected String[] getStringTable() { return myStringTable; } /** - * Returns the enumeration value table for class SheetCollate. + * Returns the enumeration value table for class {@code SheetCollate}. */ protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; @@ -208,11 +202,12 @@ public final class SheetCollate extends EnumSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class SheetCollate, the category is class SheetCollate itself. + *

+ * For class {@code SheetCollate}, the category is class + * {@code SheetCollate} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return SheetCollate.class; @@ -221,13 +216,13 @@ public final class SheetCollate extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class SheetCollate, the category name is {@code "sheet-collate"}. + *

+ * For class {@code SheetCollate}, the category name is + * {@code "sheet-collate"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "sheet-collate"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Sides.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Sides.java index a9c13c11282..f76c24731d8 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Sides.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Sides.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -22,104 +22,96 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package javax.print.attribute.standard; import javax.print.attribute.Attribute; -import javax.print.attribute.EnumSyntax; import javax.print.attribute.DocAttribute; -import javax.print.attribute.PrintRequestAttribute; +import javax.print.attribute.EnumSyntax; import javax.print.attribute.PrintJobAttribute; +import javax.print.attribute.PrintRequestAttribute; /** - * Class Sides is a printing attribute class, an enumeration, that specifies - * how print-stream pages are to be imposed upon the sides of an instance of a - * selected medium, i.e., an impression. - *

- * The effect of a Sides attribute on a multidoc print job (a job with multiple - * documents) depends on whether all the docs have the same sides values - * specified or whether different docs have different sides values specified, - * and on the (perhaps defaulted) value of the {@link MultipleDocumentHandling - * MultipleDocumentHandling} attribute. - *

    - *
  • - * If all the docs have the same sides value n specified, then any value - * of {@link MultipleDocumentHandling MultipleDocumentHandling} makes sense, - * and the printer's processing depends on the {@link MultipleDocumentHandling - * MultipleDocumentHandling} value: - *
      - *
    • - * SINGLE_DOCUMENT -- All the input docs will be combined together into one - * output document. Each media sheet will consist of n impressions from - * the output document. + * Class {@code Sides} is a printing attribute class, an enumeration, that + * specifies how print-stream pages are to be imposed upon the sides of an + * instance of a selected medium, i.e., an impression. + *

      + * The effect of a {@code Sides} attribute on a multidoc print job (a job with + * multiple documents) depends on whether all the docs have the same sides + * values specified or whether different docs have different sides values + * specified, and on the (perhaps defaulted) value of the + * {@link MultipleDocumentHandling MultipleDocumentHandling} attribute. + *

        + *
      • If all the docs have the same sides value n specified, then any + * value of {@link MultipleDocumentHandling MultipleDocumentHandling} makes + * sense, and the printer's processing depends on the + * {@link MultipleDocumentHandling MultipleDocumentHandling} value: + *
          + *
        • {@code SINGLE_DOCUMENT} -- All the input docs will be combined + * together into one output document. Each media sheet will consist of + * n impressions from the output document. + *
        • {@code SINGLE_DOCUMENT_NEW_SHEET} -- All the input docs will be + * combined together into one output document. Each media sheet will consist + * of n impressions from the output document. However, the first + * impression of each input doc will always start on a new media sheet; this + * means the last media sheet of an input doc may have only one impression + * on it. + *
        • {@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- The input docs will + * remain separate. Each media sheet will consist of n impressions + * from the input doc. Since the input docs are separate, the first + * impression of each input doc will always start on a new media sheet; this + * means the last media sheet of an input doc may have only one impression + * on it. + *
        • {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- The input docs will + * remain separate. Each media sheet will consist of n impressions + * from the input doc. Since the input docs are separate, the first + * impression of each input doc will always start on a new media sheet; this + * means the last media sheet of an input doc may have only one impression + * on it. + *
        + *
          + *
        • {@code SINGLE_DOCUMENT} -- All the input docs will be combined + * together into one output document. Each media sheet will consist of + * ni impressions from the output document, where i + * is the number of the input doc corresponding to that point in the output + * document. When the next input doc has a different sides value from the + * previous input doc, the first print-stream page of the next input doc + * goes at the start of the next media sheet, possibly leaving only one + * impression on the previous media sheet. + *
        • {@code SINGLE_DOCUMENT_NEW_SHEET} -- All the input docs will be + * combined together into one output document. Each media sheet will consist + * of n impressions from the output document. However, the first + * impression of each input doc will always start on a new media sheet; this + * means the last impression of an input doc may have only one impression on + * it. + *
        • {@code SEPARATE_DOCUMENTS_UNCOLLATED_COPIES} -- The input docs will + * remain separate. For input doc i, each media sheet will consist of + * ni impressions from the input doc. Since the input docs + * are separate, the first impression of each input doc will always start on + * a new media sheet; this means the last media sheet of an input doc may + * have only one impression on it. + *
        • {@code SEPARATE_DOCUMENTS_COLLATED_COPIES} -- The input docs will + * remain separate. For input doc i, each media sheet will consist of + * ni impressions from the input doc. Since the input docs + * are separate, the first impression of each input doc will always start on + * a new media sheet; this means the last media sheet of an input doc may + * have only one impression on it. + *
        + *
      + *

      + * IPP Compatibility: The category name returned by {@code getName()} is + * the IPP attribute name. The enumeration's integer value is the IPP enum + * value. The {@code toString()} method returns the IPP string representation of + * the attribute value. * - *

    • - * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together - * into one output document. Each media sheet will consist of n - * impressions from the output document. However, the first impression of each - * input doc will always start on a new media sheet; this means the last media - * sheet of an input doc may have only one impression on it. - * - *
    • - * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate. - * Each media sheet will consist of n impressions from the input doc. - * Since the input docs are separate, the first impression of each input doc - * will always start on a new media sheet; this means the last media sheet of - * an input doc may have only one impression on it. - * - *
    • - * SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate. - * Each media sheet will consist of n impressions from the input doc. - * Since the input docs are separate, the first impression of each input doc - * will always start on a new media sheet; this means the last media sheet of - * an input doc may have only one impression on it. - *
    - * - *
      - *
    • - * SINGLE_DOCUMENT -- All the input docs will be combined together into one - * output document. Each media sheet will consist of ni - * impressions from the output document, where i is the number of the - * input doc corresponding to that point in the output document. When the next - * input doc has a different sides value from the previous input doc, the first - * print-stream page of the next input doc goes at the start of the next media - * sheet, possibly leaving only one impression on the previous media sheet. - * - *
    • - * SINGLE_DOCUMENT_NEW_SHEET -- All the input docs will be combined together - * into one output document. Each media sheet will consist of n - * impressions from the output document. However, the first impression of each - * input doc will always start on a new media sheet; this means the last - * impression of an input doc may have only one impression on it. - * - *
    • - * SEPARATE_DOCUMENTS_UNCOLLATED_COPIES -- The input docs will remain separate. - * For input doc i, each media sheet will consist of ni - * impressions from the input doc. Since the input docs are separate, the first - * impression of each input doc will always start on a new media sheet; this - * means the last media sheet of an input doc may have only one impression on - * it. - * - *
    • - * SEPARATE_DOCUMENTS_COLLATED_COPIES -- The input docs will remain separate. - * For input doc i, each media sheet will consist of ni - * impressions from the input doc. Since the input docs are separate, the first - * impression of each input doc will always start on a new media sheet; this - * means the last media sheet of an input doc may have only one impression on - * it. - *
    - *
- *

- * IPP Compatibility: The category name returned by - * {@code getName()} is the IPP attribute name. The enumeration's - * integer value is the IPP enum value. The {@code toString()} method - * returns the IPP string representation of the attribute value. - * - * @author Alan Kaminsky + * @author Alan Kaminsky */ - public final class Sides extends EnumSyntax implements DocAttribute, PrintRequestAttribute, PrintJobAttribute { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -6890309414893262822L; /** @@ -130,49 +122,55 @@ public final class Sides extends EnumSyntax /** * Imposes each consecutive pair of print-stream pages upon front and back - * sides of consecutive media sheets, such that the orientation of each - * pair of print-stream pages on the medium would be correct for the - * reader as if for binding on the long edge. This imposition is also - * known as "duplex" (see {@link #DUPLEX DUPLEX}). + * sides of consecutive media sheets, such that the orientation of each pair + * of print-stream pages on the medium would be correct for the reader as if + * for binding on the long edge. This imposition is also known as "duplex" + * (see {@link #DUPLEX DUPLEX}). */ public static final Sides TWO_SIDED_LONG_EDGE = new Sides(1); /** * Imposes each consecutive pair of print-stream pages upon front and back - * sides of consecutive media sheets, such that the orientation of each - * pair of print-stream pages on the medium would be correct for the - * reader as if for binding on the short edge. This imposition is also - * known as "tumble" (see {@link #TUMBLE TUMBLE}). + * sides of consecutive media sheets, such that the orientation of each pair + * of print-stream pages on the medium would be correct for the reader as if + * for binding on the short edge. This imposition is also known as "tumble" + * (see {@link #TUMBLE TUMBLE}). */ public static final Sides TWO_SIDED_SHORT_EDGE = new Sides(2); /** - * An alias for "two sided long edge" (see {@link #TWO_SIDED_LONG_EDGE - * TWO_SIDED_LONG_EDGE}). + * An alias for "two sided long edge" (see + * {@link #TWO_SIDED_LONG_EDGE TWO_SIDED_LONG_EDGE}). */ public static final Sides DUPLEX = TWO_SIDED_LONG_EDGE; /** - * An alias for "two sided short edge" (see {@link #TWO_SIDED_SHORT_EDGE - * TWO_SIDED_SHORT_EDGE}). + * An alias for "two sided short edge" (see + * {@link #TWO_SIDED_SHORT_EDGE TWO_SIDED_SHORT_EDGE}). */ public static final Sides TUMBLE = TWO_SIDED_SHORT_EDGE; /** * Construct a new sides enumeration value with the given integer value. * - * @param value Integer value. + * @param value Integer value */ protected Sides(int value) { super (value); } + /** + * The string table for class {@code Sides}. + */ private static final String[] myStringTable = { "one-sided", "two-sided-long-edge", "two-sided-short-edge" }; + /** + * The enumeration value table for class {@code Sides}. + */ private static final Sides[] myEnumValueTable = { ONE_SIDED, TWO_SIDED_LONG_EDGE, @@ -180,14 +178,14 @@ public final class Sides extends EnumSyntax }; /** - * Returns the string table for class Sides. + * Returns the string table for class {@code Sides}. */ protected String[] getStringTable() { return myStringTable; } /** - * Returns the enumeration value table for class Sides. + * Returns the enumeration value table for class {@code Sides}. */ protected EnumSyntax[] getEnumValueTable() { return myEnumValueTable; @@ -196,11 +194,11 @@ public final class Sides extends EnumSyntax /** * Get the printing attribute class which is to be used as the "category" * for this printing attribute value. - *

- * For class Sides, the category is class Sides itself. + *

+ * For class {@code Sides}, the category is class {@code Sides} itself. * - * @return Printing attribute class (category), an instance of class - * {@link java.lang.Class java.lang.Class}. + * @return printing attribute class (category), an instance of class + * {@link Class java.lang.Class} */ public final Class getCategory() { return Sides.class; @@ -209,13 +207,12 @@ public final class Sides extends EnumSyntax /** * Get the name of the category of which this attribute value is an * instance. - *

- * For class Sides, the category name is {@code "sides"}. + *

+ * For class {@code Sides}, the category name is {@code "sides"}. * - * @return Attribute category name. + * @return attribute category name */ public final String getName() { return "sides"; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/package-info.java b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/package-info.java index 1e44ec9af61..9ded7f55cf2 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/package-info.java +++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/package-info.java @@ -24,8 +24,8 @@ */ /** - * Package javax.print.attribute.standard contains classes for specific printing - * attributes. The parent package, + * Package {@code javax.print.attribute.standard} contains classes for specific + * printing attributes. The parent package, * javax.print.attribute, provides classes and interfaces that describe the * types of Java Print Service attributes and how they can be collected into * attribute sets. @@ -43,19 +43,19 @@ * support them. These support requirements are recorded in the documentation * for each attribute class. *

- * Package javax.print.attribute.standard contains standard printing attributes - * and standard printing attribute values that are widely used in the printing - * domain. A print service vendor can provide new vendor-specific printing - * attributes in addition to the standard ones. A vendor can also provide - * vendor-specific extensions (subclasses) of the standard printing attributes - * -- for example, to provide additional vendor-specific values for an existing - * standard attribute. Of course, if a vendor wants clients to be able to use - * any added or extended attributes, the vendor must publish the new attribute - * classes. + * Package {@code javax.print.attribute.standard} contains standard printing + * attributes and standard printing attribute values that are widely used in the + * printing domain. A print service vendor can provide new vendor-specific + * printing attributes in addition to the standard ones. A vendor can also + * provide vendor-specific extensions (subclasses) of the standard printing + * attributes -- for example, to provide additional vendor-specific values for + * an existing standard attribute. Of course, if a vendor wants clients to be + * able to use any added or extended attributes, the vendor must publish the new + * attribute classes. *

* Many of the standard attribute classes extend one of the abstract syntax - * classes of the javax.print.attribute package. These abstract syntax classes - * each represent a different type. The + * classes of the {@code javax.print.attribute} package. These abstract syntax + * classes each represent a different type. The * EnumSyntax class, for example, represents a type-safe enumeration. The * abstract syntax class provides a wrapper for the attribute value. *

@@ -73,9 +73,9 @@ * attribute classes in package javax.print.attribute.standard, just the ones * that pertain to the application. *

- * The attribute classes in package javax.print.attribute.standard are based on - * the Internet Printing Protocol (IPP) attributes as defined in the Internet - * RFC document, RFC 2911 Internet Printing Protocol/1.1: Model and + * The attribute classes in package {@code javax.print.attribute.standard} are + * based on the Internet Printing Protocol (IPP) attributes as defined in the + * Internet RFC document, RFC 2911 Internet Printing Protocol/1.1: Model and * Semantics dated September 2000. See * RFC 2911 for more * information. The descriptive text for each attribute class was taken largely @@ -152,485 +152,418 @@ * indicates the supported values for that attribute category. * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
Attribute ClassDoc
Attribute
Print
Request
Attribute
Print
Job
Attribute
Print
Service
Attribute
SupportedValuesAttribute
CompressionX    
DocumentNameX    
ChromaticityXXX  
Copies XX CopiesSupported
FinishingsXXX  
JobHoldUntil XX  
JobImpressions XX  - * JobImpressionsSupported
JobKOctets XX JobKOctetsSupported
JobMediaSheets XX  - * JobMediaSheetsSupported
JobName XX  
JobPriority XX JobPrioritySupported
JobSheets XX  
MediaXXX  
MediaSize     
- * MultipleDocumentHandling XX  
NumberUpXXX NumberUpSupported
OrientationRequestedXXX  
PageRangesXXX  
- * PresentationDirectionXXX  
PrinterResolutionXXX  
PrintQualityXXX  
RequestingUserName XX  
SheetCollateXXX  
SidesXXX  
DateTimeAtCompleted  X  
DateTimeAtCreation  X  
DateTimeAtProcessing  X  
- * JobImpressionsCompleted  X  
JobKOctetsProcessed  X  
- * JobMediaSheetsCompleted  X  
- * JobMessageFromOperator  X  
- * JobOriginatingUserName  X  
JobState  X  
JobStateReasons
- * Contains zero or more --
  X  
-- JobStateReason     
NumberOfDocuments  X  
- * NumberOfInterveningJobs  X  
OutputDeviceAssigned  X  
ColorSupported   X 
PagesPerMinute   X 
PagesPerMinuteColor   X 
PDLOverrideSupported   X 
- * PrinterIsAcceptingJobs   X 
PrinterInfo   X 
PrinterLocation   X 
- * PrinterMessageFromOperator   X 
PrinterMakeAndModel   X 
PrinterMoreInfo   X 
- * PrinterMoreInfoManufacturer   X 
PrinterName   X 
PrinterState   X 
PrinterStateReasons
- * Contains zero or more --
   X 
-- PrinterStateReason     
-- Severity     
QueuedJobCount   X 
- * ReferenceUriSchemesSupported     
Attribute Class + * Doc
Attribute + *
Print
Request
Attribute + *
Print
Job
Attribute + *
Print
Service
Attribute + *
SupportedValuesAttribute + *
Compression + * X + *   + *   + *   + *   + *
DocumentName + * X + *   + *   + *   + *   + *
Chromaticity + * X + * X + * X + *   + *   + *
Copies + *   + * X + * X + *   + * CopiesSupported + *
Finishings + * X + * X + * X + *   + *   + *
JobHoldUntil + *   + * X + * X + *   + *   + *
JobImpressions + *   + * X + * X + *   + * JobImpressionsSupported + *
JobKOctets + *   + * X + * X + *   + * JobKOctetsSupported + *
JobMediaSheets + *   + * X + * X + *   + * JobMediaSheetsSupported + *
JobName + *   + * X + * X + *   + *   + *
JobPriority + *   + * X + * X + *   + * JobPrioritySupported + *
JobSheets + *   + * X + * X + *   + *   + *
Media + * X + * X + * X + *   + *   + *
MediaSize + *   + *   + *   + *   + *   + *
MultipleDocumentHandling + *   + * X + * X + *   + *   + *
NumberUp + * X + * X + * X + *   + * NumberUpSupported + *
OrientationRequested + * X + * X + * X + *   + *   + *
PageRanges + * X + * X + * X + *   + *   + *
PresentationDirection + * X + * X + * X + *   + *   + *
PrinterResolution + * X + * X + * X + *   + *   + *
PrintQuality + * X + * X + * X + *   + *   + *
RequestingUserName + *   + * X + * X + *   + *   + *
SheetCollate + * X + * X + * X + *   + *   + *
Sides + * X + * X + * X + *   + *   + *
DateTimeAtCompleted + *   + *   + * X + *   + *   + *
DateTimeAtCreation + *   + *   + * X + *   + *   + *
DateTimeAtProcessing + *   + *   + * X + *   + *   + *
JobImpressionsCompleted + *   + *   + * X + *   + *   + *
JobKOctetsProcessed + *   + *   + * X + *   + *   + *
JobMediaSheetsCompleted + *   + *   + * X + *   + *   + *
JobMessageFromOperator + *   + *   + * X + *   + *   + *
JobOriginatingUserName + *   + *   + * X + *   + *   + *
JobState + *   + *   + * X + *   + *   + *
JobStateReasons
+ * Contains zero or more -- + *
  + *   + * X + *   + *   + *
-- JobStateReason + *   + *   + *   + *   + *   + *
NumberOfDocuments + *   + *   + * X + *   + *   + *
NumberOfInterveningJobs + *   + *   + * X + *   + *   + *
OutputDeviceAssigned + *   + *   + * X + *   + *   + *
ColorSupported + *   + *   + *   + * X + *   + *
PagesPerMinute + *   + *   + *   + * X + *   + *
PagesPerMinuteColor + *   + *   + *   + * X + *   + *
PDLOverrideSupported + *   + *   + *   + * X + *   + *
PrinterIsAcceptingJobs + *   + *   + *   + * X + *   + *
PrinterInfo + *   + *   + *   + * X + *   + *
PrinterLocation + *   + *   + *   + * X + *   + *
+ * PrinterMessageFromOperator + *   + *   + *   + * X + *   + *
PrinterMakeAndModel + *   + *   + *   + * X + *   + *
PrinterMoreInfo + *   + *   + *   + * X + *   + *
+ * PrinterMoreInfoManufacturer + *   + *   + *   + * X + *   + *
PrinterName + *   + *   + *   + * X + *   + *
PrinterState + *   + *   + *   + * X + *   + *
PrinterStateReasons
+ * Contains zero or more -- + *
  + *   + *   + * X + *   + *
-- PrinterStateReason + *   + *   + *   + *   + *   + *
-- Severity + *   + *   + *   + *   + *   + *
QueuedJobCount + *   + *   + *   + * X + *   + *
+ * ReferenceUriSchemesSupported + *   + *   + *   + *   + *   *
*

- * Please note: In the javax.print APIs, a null reference parameter to methods - * is incorrect unless explicitly documented on the method as having a - * meaningful interpretation. Usage to the contrary is incorrect coding and may - * result in a run time exception either immediately or at some later time. - * IllegalArgumentException and NullPointerException are examples of typical and - * acceptable run time exceptions for such cases. + * Please note: In the {@code javax.print} APIs, a {@code null} reference + * parameter to methods is incorrect unless explicitly documented on the method + * as having a meaningful interpretation. Usage to the contrary is incorrect + * coding and may result in a run time exception either immediately or at some + * later time. {@code IllegalArgumentException} and {@code NullPointerException} + * are examples of typical and acceptable run time exceptions for such cases. * * @since 1.4 */ diff --git a/jdk/src/java.desktop/share/classes/javax/print/event/PrintEvent.java b/jdk/src/java.desktop/share/classes/javax/print/event/PrintEvent.java index 0732fb37231..aeffa0da51c 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/event/PrintEvent.java +++ b/jdk/src/java.desktop/share/classes/javax/print/event/PrintEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -26,29 +26,31 @@ package javax.print.event; /** - * - * Class PrintEvent is the super class of all Print Service API events. + * Class {@code PrintEvent} is the super class of all Print Service API events. */ - public class PrintEvent extends java.util.EventObject { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = 2286914924430763847L; /** - * Constructs a PrintEvent object. - * @param source is the source of the event - * @throws IllegalArgumentException if {@code source} is - * {@code null}. + * Constructs a {@code PrintEvent} object. + * + * @param source is the source of the event + * @throws IllegalArgumentException if {@code source} is {@code null} */ public PrintEvent (Object source) { super(source); } /** + * Returns a string representation of this {@code PrintEvent}. + * * @return a message describing the event */ public String toString() { return ("PrintEvent on " + getSource().toString()); } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobAdapter.java b/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobAdapter.java index 38ea4054075..989f275b383 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobAdapter.java +++ b/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -26,27 +26,23 @@ package javax.print.event; /** - * An abstract adapter class for receiving print job events. - * The methods in this class are empty. - * This class exists as a convenience for creating listener objects. - * Extend this class to create a {@link PrintJobEvent} listener and override - * the methods for the events of interest. Unlike the - * {@link java.awt.event.ComponentListener ComponentListener} - * interface, this abstract interface provides null methods so that you - * only need to define the methods you need, rather than all of the methods. - * - */ - + * An abstract adapter class for receiving print job events. The methods in this + * class are empty. This class exists as a convenience for creating listener + * objects. Extend this class to create a {@link PrintJobEvent} listener and + * override the methods for the events of interest. Unlike the + * {@link java.awt.event.ComponentListener ComponentListener} interface, this + * abstract interface provides empty methods so that you only need to define the + * methods you need, rather than all of the methods. + */ public abstract class PrintJobAdapter implements PrintJobListener { /** - * Called to notify the client that data has been successfully - * transferred to the print service, and the client may free - * local resources allocated for that data. The client should - * not assume that the data has been completely printed after - * receiving this event. + * Called to notify the client that data has been successfully transferred + * to the print service, and the client may free local resources allocated + * for that data. The client should not assume that the data has been + * completely printed after receiving this event. * - * @param pje the event being notified + * @param pje the event being notified */ public void printDataTransferCompleted(PrintJobEvent pje) { } @@ -54,52 +50,46 @@ public abstract class PrintJobAdapter implements PrintJobListener { /** * Called to notify the client that the job completed successfully. * - * @param pje the event being notified + * @param pje the event being notified */ public void printJobCompleted(PrintJobEvent pje) { } - /** - * Called to notify the client that the job failed to complete - * successfully and will have to be resubmitted. + * Called to notify the client that the job failed to complete successfully + * and will have to be resubmitted. * - * @param pje the event being notified + * @param pje the event being notified */ public void printJobFailed(PrintJobEvent pje) { } /** - * Called to notify the client that the job was canceled - * by user or program. + * Called to notify the client that the job was canceled by user or program. * - * @param pje the event being notified + * @param pje the event being notified */ public void printJobCanceled(PrintJobEvent pje) { } - /** - * Called to notify the client that no more events will be delivered. - * One cause of this event being generated is if the job - * has successfully completed, but the printing system - * is limited in capability and cannot verify this. - * This event is required to be delivered if none of the other + * Called to notify the client that no more events will be delivered. One + * cause of this event being generated is if the job has successfully + * completed, but the printing system is limited in capability and cannot + * verify this. This event is required to be delivered if none of the other * terminal events (completed/failed/canceled) are delivered. * - * @param pje the event being notified + * @param pje the event being notified */ public void printJobNoMoreEvents(PrintJobEvent pje) { } - /** - * Called to notify the client that some possibly user rectifiable - * problem occurs (eg printer out of paper). + * Called to notify the client that some possibly user rectifiable problem + * occurs (eg printer out of paper). * - * @param pje the event being notified + * @param pje the event being notified */ public void printJobRequiresAttention(PrintJobEvent pje) { } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobAttributeEvent.java b/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobAttributeEvent.java index efec2a761ca..2eef89f1b5a 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobAttributeEvent.java +++ b/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobAttributeEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -30,23 +30,28 @@ import javax.print.attribute.AttributeSetUtilities; import javax.print.attribute.PrintJobAttributeSet; /** - * Class PrintJobAttributeEvent encapsulates an event a PrintService - * reports to let the client know that one or more printing attributes for a - * PrintJob have changed. + * Class {@code PrintJobAttributeEvent} encapsulates an event a + * {@code PrintService} reports to let the client know that one or more printing + * attributes for a {@code PrintJob} have changed. */ - public class PrintJobAttributeEvent extends PrintEvent { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -6534469883874742101L; + /** + * The printing service attributes that changed. + */ private PrintJobAttributeSet attributes; /** - * Constructs a PrintJobAttributeEvent object. - * @param source the print job generating this event - * @param attributes the attribute changes being reported - * @throws IllegalArgumentException if {@code source} is - * {@code null}. + * Constructs a {@code PrintJobAttributeEvent} object. + * + * @param source the print job generating this event + * @param attributes the attribute changes being reported + * @throws IllegalArgumentException if {@code source} is {@code null} */ public PrintJobAttributeEvent (DocPrintJob source, PrintJobAttributeSet attributes) { @@ -55,28 +60,24 @@ public class PrintJobAttributeEvent extends PrintEvent { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } - /** - * Determine the Print Job to which this print job event pertains. + * Determine the {@code PrintJob} to which this print job event pertains. * - * @return Print Job object. + * @return {@code PrintJob} object */ public DocPrintJob getPrintJob() { return (DocPrintJob) getSource(); } - /** * Determine the printing attributes that changed and their new values. * - * @return Attributes containing the new values for the print job - * attributes that changed. The returned set may not be modifiable. + * @return attributes containing the new values for the print job attributes + * that changed. The returned set may not be modifiable. */ public PrintJobAttributeSet getAttributes() { return attributes; - } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobAttributeListener.java b/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobAttributeListener.java index 0f21e659a9b..478f4fedd9f 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobAttributeListener.java +++ b/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobAttributeListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -26,21 +26,19 @@ package javax.print.event; /** - * Implementations of this interface are attached to a - * {@link javax.print.DocPrintJob DocPrintJob} to monitor - * the status of attribute changes associated with the print job. - * - */ + * Implementations of this interface are attached to a + * {@link javax.print.DocPrintJob DocPrintJob} to monitor the status of + * attribute changes associated with the print job. + */ public interface PrintJobAttributeListener { /** - * Notifies the listener of a change in some print job attributes. - * One example of an occurrence triggering this event is if the - * {@link javax.print.attribute.standard.JobState JobState} - * attribute changed from - * {@code PROCESSING} to {@code PROCESSING_STOPPED}. - * @param pjae the event. + * Notifies the listener of a change in some print job attributes. One + * example of an occurrence triggering this event is if the + * {@link javax.print.attribute.standard.JobState JobState} attribute + * changed from {@code PROCESSING} to {@code PROCESSING_STOPPED}. + * + * @param pjae the event being notified */ public void attributeUpdate(PrintJobAttributeEvent pjae) ; - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobEvent.java b/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobEvent.java index 77424a07a91..66acdf8cd93 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobEvent.java +++ b/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -28,98 +28,95 @@ package javax.print.event; import javax.print.DocPrintJob; /** - * - * Class {@code PrintJobEvent} encapsulates common events a print job - * reports to let a listener know of progress in the processing of the - * {@link DocPrintJob}. - * + * Class {@code PrintJobEvent} encapsulates common events a print job reports to + * let a listener know of progress in the processing of the {@link DocPrintJob}. */ - public class PrintJobEvent extends PrintEvent { - private static final long serialVersionUID = -1711656903622072997L; + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ + private static final long serialVersionUID = -1711656903622072997L; - private int reason; + /** + * The reason of this event. + */ + private int reason; - /** - * The job was canceled by the {@link javax.print.PrintService PrintService}. - */ - public static final int JOB_CANCELED = 101; + /** + * The job was canceled by the + * {@link javax.print.PrintService PrintService}. + */ + public static final int JOB_CANCELED = 101; - /** - * The document cis completely printed. - */ - public static final int JOB_COMPLETE = 102; + /** + * The document is completely printed. + */ + public static final int JOB_COMPLETE = 102; - /** - * The print service reports that the job cannot be completed. - * The application must resubmit the job. - */ + /** + * The print service reports that the job cannot be completed. The + * application must resubmit the job. + */ + public static final int JOB_FAILED = 103; - public static final int JOB_FAILED = 103; + /** + * The print service indicates that a - possibly transient - problem may + * require external intervention before the print service can continue. One + * example of an event that can generate this message is when the printer + * runs out of paper. + */ + public static final int REQUIRES_ATTENTION = 104; - /** - * The print service indicates that a - possibly transient - problem - * may require external intervention before the print service can - * continue. One example of an event that can - * generate this message is when the printer runs out of paper. - */ - public static final int REQUIRES_ATTENTION = 104; + /** + * Not all print services may be capable of delivering interesting events, + * or even telling when a job is complete. This message indicates the print + * job has no further information or communication with the print service. + * This message should always be delivered if a terminal event + * (completed/failed/canceled) is not delivered. For example, if messages + * such as {@code JOB_COMPLETE} have NOT been received before receiving this + * message, the only inference that should be drawn is that the print + * service does not support delivering such an event. + */ + public static final int NO_MORE_EVENTS = 105; - /** - * Not all print services may be capable of delivering interesting - * events, or even telling when a job is complete. This message indicates - * the print job has no further information or communication - * with the print service. This message should always be delivered - * if a terminal event (completed/failed/canceled) is not delivered. - * For example, if messages such as JOB_COMPLETE have NOT been received - * before receiving this message, the only inference that should be drawn - * is that the print service does not support delivering such an event. - */ - public static final int NO_MORE_EVENTS = 105; + /** + * The job is not necessarily printed yet, but the data has been transferred + * successfully from the client to the print service. The client may free + * data resources. + */ + public static final int DATA_TRANSFER_COMPLETE = 106; - /** - * The job is not necessarily printed yet, but the data has been transferred - * successfully from the client to the print service. The client may - * free data resources. - */ - public static final int DATA_TRANSFER_COMPLETE = 106; - - /** + /** * Constructs a {@code PrintJobEvent} object. * - * @param source a {@code DocPrintJob} object - * @param reason an int specifying the reason. - * @throws IllegalArgumentException if {@code source} is - * {@code null}. + * @param source a {@code DocPrintJob} object + * @param reason an int specifying the reason + * @throws IllegalArgumentException if {@code source} is {@code null} */ - public PrintJobEvent( DocPrintJob source, int reason) { super(source); this.reason = reason; - } + } /** * Gets the reason for this event. - * @return reason int. + * + * @return reason int */ public int getPrintEventType() { return reason; } /** - * Determines the {@code DocPrintJob} to which this print job - * event pertains. - * - * @return the {@code DocPrintJob} object that represents the - * print job that reports the events encapsulated by this - * {@code PrintJobEvent}. + * Determines the {@code DocPrintJob} to which this print job event + * pertains. * + * @return the {@code DocPrintJob} object that represents the print job that + * reports the events encapsulated by this {@code PrintJobEvent} */ public DocPrintJob getPrintJob() { return (DocPrintJob) getSource(); } - - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobListener.java b/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobListener.java index 15339248f05..ca4e998010b 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobListener.java +++ b/jdk/src/java.desktop/share/classes/javax/print/event/PrintJobListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -26,70 +26,66 @@ package javax.print.event; /** - * Implementations of this listener interface should be attached to a - * {@link javax.print.DocPrintJob DocPrintJob} to monitor the status of - * the printer job. - * These callback methods may be invoked on the thread processing the - * print job, or a service created notification thread. In either case - * the client should not perform lengthy processing in these callbacks. - */ - + * Implementations of this listener interface should be attached to a + * {@link javax.print.DocPrintJob DocPrintJob} to monitor the status of the + * printer job. These callback methods may be invoked on the thread processing + * the print job, or a service created notification thread. In either case the + * client should not perform lengthy processing in these callbacks. + */ public interface PrintJobListener { /** - * Called to notify the client that data has been successfully - * transferred to the print service, and the client may free - * local resources allocated for that data. The client should - * not assume that the data has been completely printed after - * receiving this event. - * If this event is not received the client should wait for a terminal - * event (completed/canceled/failed) before freeing the resources. - * @param pje the job generating this event + * Called to notify the client that data has been successfully transferred + * to the print service, and the client may free local resources allocated + * for that data. The client should not assume that the data has been + * completely printed after receiving this event. If this event is not + * received the client should wait for a terminal event + * (completed/canceled/failed) before freeing the resources. + * + * @param pje the job generating this event */ public void printDataTransferCompleted(PrintJobEvent pje) ; - /** * Called to notify the client that the job completed successfully. - * @param pje the job generating this event + * + * @param pje the job generating this event */ public void printJobCompleted(PrintJobEvent pje) ; - /** - * Called to notify the client that the job failed to complete - * successfully and will have to be resubmitted. - * @param pje the job generating this event + * Called to notify the client that the job failed to complete successfully + * and will have to be resubmitted. + * + * @param pje the job generating this event */ public void printJobFailed(PrintJobEvent pje) ; - /** - * Called to notify the client that the job was canceled - * by a user or a program. - * @param pje the job generating this event + * Called to notify the client that the job was canceled by a user or a + * program. + * + * @param pje the job generating this event */ public void printJobCanceled(PrintJobEvent pje) ; - /** - * Called to notify the client that no more events will be delivered. - * One cause of this event being generated is if the job - * has successfully completed, but the printing system - * is limited in capability and cannot verify this. - * This event is required to be delivered if none of the other + * Called to notify the client that no more events will be delivered. One + * cause of this event being generated is if the job has successfully + * completed, but the printing system is limited in capability and cannot + * verify this. This event is required to be delivered if none of the other * terminal events (completed/failed/canceled) are delivered. - * @param pje the job generating this event + * + * @param pje the job generating this event */ public void printJobNoMoreEvents(PrintJobEvent pje) ; - /** - * Called to notify the client that an error has occurred that the - * user might be able to fix. One example of an error that can - * generate this event is when the printer runs out of paper. - * @param pje the job generating this event + * Called to notify the client that an error has occurred that the user + * might be able to fix. One example of an error that can generate this + * event is when the printer runs out of paper. + * + * @param pje the job generating this event */ public void printJobRequiresAttention(PrintJobEvent pje) ; - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/event/PrintServiceAttributeEvent.java b/jdk/src/java.desktop/share/classes/javax/print/event/PrintServiceAttributeEvent.java index 06998afd354..c96f8925363 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/event/PrintServiceAttributeEvent.java +++ b/jdk/src/java.desktop/share/classes/javax/print/event/PrintServiceAttributeEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -30,25 +30,28 @@ import javax.print.attribute.AttributeSetUtilities; import javax.print.attribute.PrintServiceAttributeSet; /** - * - * Class PrintServiceAttributeEvent encapsulates an event a - * Print Service instance reports to let the client know of - * changes in the print service state. + * Class {@code PrintServiceAttributeEvent} encapsulates an event a Print + * Service instance reports to let the client know of changes in the print + * service state. */ - public class PrintServiceAttributeEvent extends PrintEvent { + /** + * Use serialVersionUID from JDK 1.4 for interoperability. + */ private static final long serialVersionUID = -7565987018140326600L; + /** + * The printing service attributes that changed. + */ private PrintServiceAttributeSet attributes; /** - * Constructs a PrintServiceAttributeEvent object. + * Constructs a {@code PrintServiceAttributeEvent} object. * - * @param source the print job generating this event - * @param attributes the attribute changes being reported - * @throws IllegalArgumentException if {@code source} is - * {@code null}. + * @param source the print job generating this event + * @param attributes the attribute changes being reported + * @throws IllegalArgumentException if {@code source} is {@code null} */ public PrintServiceAttributeEvent(PrintService source, PrintServiceAttributeSet attributes) { @@ -57,28 +60,25 @@ public class PrintServiceAttributeEvent extends PrintEvent { this.attributes = AttributeSetUtilities.unmodifiableView(attributes); } - /** * Returns the print service. - - * @return Print Service object. + * + * @return {@code PrintService} object */ public PrintService getPrintService() { return (PrintService) getSource(); } - /** * Determine the printing service attributes that changed and their new * values. * - * @return Attributes containing the new values for the service - * attributes that changed. The returned set may be unmodifiable. + * @return attributes containing the new values for the service attributes + * that changed. The returned set may be unmodifiable. */ public PrintServiceAttributeSet getAttributes() { return attributes; } - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/event/PrintServiceAttributeListener.java b/jdk/src/java.desktop/share/classes/javax/print/event/PrintServiceAttributeListener.java index 3bc1329991a..8c3120222c2 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/event/PrintServiceAttributeListener.java +++ b/jdk/src/java.desktop/share/classes/javax/print/event/PrintServiceAttributeListener.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -26,23 +26,22 @@ package javax.print.event; /** - * Implementations of this listener interface are attached to a - * {@link javax.print.PrintService PrintService} to monitor - * the status of the print service. - *

- * To monitor a particular job see {@link PrintJobListener} and - * {@link PrintJobAttributeListener}. - */ - + * Implementations of this listener interface are attached to a + * {@link javax.print.PrintService PrintService} to monitor the status of the + * print service. + *

+ * To monitor a particular job see {@link PrintJobListener} and + * {@link PrintJobAttributeListener}. + */ public interface PrintServiceAttributeListener { /** - * Called to notify a listener of an event in the print service. - * The service will call this method on an event notification thread. - * The client should not perform lengthy processing in this callback - * or subsequent event notifications may be blocked. - * @param psae the event being notified + * Called to notify a listener of an event in the print service. The service + * will call this method on an event notification thread. The client should + * not perform lengthy processing in this callback or subsequent event + * notifications may be blocked. + * + * @param psae the event being notified */ public void attributeUpdate(PrintServiceAttributeEvent psae) ; - } diff --git a/jdk/src/java.desktop/share/classes/javax/print/event/package-info.java b/jdk/src/java.desktop/share/classes/javax/print/event/package-info.java index ca65f565da9..4cc09284836 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/event/package-info.java +++ b/jdk/src/java.desktop/share/classes/javax/print/event/package-info.java @@ -24,17 +24,18 @@ */ /** - * Package javax.print.event contains event classes and listener interfaces. + * Package {@code javax.print.event} contains event classes and listener + * interfaces. *

* They may be used to monitor both print services (such as printers going * on-line & off-line), and the progress of a specific print job. *

- * Please note: In the javax.print APIs, a null reference parameter to methods - * is incorrect unless explicitly documented on the method as having a - * meaningful interpretation. Usage to the contrary is incorrect coding and may - * result in a run time exception either immediately or at some later time. - * IllegalArgumentException and NullPointerException are examples of typical and - * acceptable run time exceptions for such cases. + * Please note: In the {@code javax.print} APIs, a {@code null} reference + * parameter to methods is incorrect unless explicitly documented on the method + * as having a meaningful interpretation. Usage to the contrary is incorrect + * coding and may result in a run time exception either immediately or at some + * later time. {@code IllegalArgumentException} and {@code NullPointerException} + * are examples of typical and acceptable run time exceptions for such cases. * * @since 1.4 */ diff --git a/jdk/src/java.desktop/share/classes/javax/print/package-info.java b/jdk/src/java.desktop/share/classes/javax/print/package-info.java index b2ef3d7e155..3d538afc14c 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/package-info.java +++ b/jdk/src/java.desktop/share/classes/javax/print/package-info.java @@ -28,10 +28,10 @@ * Service API. The Java Print Service API enables client and server * applications to: *

    - *
  • Discover and select print services based on their capabilities
  • - *
  • Specify the format of print data
  • - *
  • Submit print jobs to services that support the document type to be - * printed.
  • + *
  • Discover and select print services based on their capabilities + *
  • Specify the format of print data + *
  • Submit print jobs to services that support the document type to be + * printed. *
* *

Print Service Discovery

@@ -51,15 +51,15 @@ *

Attribute Definitions

* The {@link javax.print.attribute} and {@link javax.print.attribute.standard} * packages define print attributes, which describe the capabilities of a print - * service, specify the requirements of a print job, and track the progress of - * a print job. + * service, specify the requirements of a print job, and track the progress of a + * print job. *

* The {@code javax.print.attribute} package describes the types of attributes * and how they can be collected into sets. The * {@code javax.print.attribute.standard} package enumerates all of the standard * attributes supported by the API, most of which are implementations of * attributes specified in the IETF Specification, - * RFC 2911 Internet Printing + * RFC 2911 Internet Printing * Protocol, 1.1: Model and Semantics, dated September 2000. The attributes * specified in {@code javax.print.attribute.standard} include common * capabilities, such as: resolution, copies, media sizes, job priority, and @@ -78,16 +78,16 @@ * A typical application using the Java Print Service API performs these steps * to process a print request: *

    - *
  1. Chooses a {@code DocFlavor}.
  2. - *
  3. Creates a set of attributes.
  4. - *
  5. Locates a print service that can handle the print request as - * specified by the {@code DocFlavor} and the attribute set.
  6. - *
  7. Creates a {@link javax.print.Doc Doc} object encapsulating the - * {@code DocFlavor} and the actual print data, which can take many forms - * including: a Postscript file, a JPEG image, a URL, or plain text.
  8. - *
  9. Gets a print job, represented by - * {@link javax.print.DocPrintJob DocPrintJob}, from the print service.
  10. - *
  11. Calls the print method of the print job.
  12. + *
  13. Chooses a {@code DocFlavor}. + *
  14. Creates a set of attributes. + *
  15. Locates a print service that can handle the print request as specified + * by the {@code DocFlavor} and the attribute set. + *
  16. Creates a {@link javax.print.Doc Doc} object encapsulating the + * {@code DocFlavor} and the actual print data, which can take many forms + * including: a Postscript file, a JPEG image, a {@code URL}, or plain text. + *
  17. Gets a print job, represented by + * {@link javax.print.DocPrintJob DocPrintJob}, from the print service. + *
  18. Calls the print method of the print job. *
* The following code sample demonstrates a typical use of the Java Print * Service API: locating printers that can print five double-sided copies of a @@ -119,13 +119,13 @@ * } * } * - *

- * Please note: In the javax.print APIs, a null reference parameter to methods - * is incorrect unless explicitly documented on the method as having a - * meaningful interpretation. Usage to the contrary is incorrect coding and may - * result in a run time exception either immediately or at some later time. - * IllegalArgumentException and NullPointerException are examples of typical and - * acceptable run time exceptions for such cases. + *

+ * Please note: In the {@code javax.print} APIs, a {@code null} reference + * parameter to methods is incorrect unless explicitly documented on the method + * as having a meaningful interpretation. Usage to the contrary is incorrect + * coding and may result in a run time exception either immediately or at some + * later time. {@code IllegalArgumentException} and {@code NullPointerException} + * are examples of typical and acceptable run time exceptions for such cases. * * @since 1.4 */ From 795c9194af310887c889251a6b00dc59d60ab7b6 Mon Sep 17 00:00:00 2001 From: Gerard Ziemski Date: Thu, 31 Aug 2017 20:25:47 -0500 Subject: [PATCH 75/98] 8173715: Remove FlatProfiler Obsoleted Xprof flag, removed FlatProfiler code Reviewed-by: dholmes, erikj --- common/autoconf/generated-configure.sh | 6 +++--- common/autoconf/hotspot.m4 | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 43a1446ff2c..954e821f5cd 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -4300,7 +4300,7 @@ pkgadd_help() { # All valid JVM features, regardless of platform VALID_JVM_FEATURES="compiler1 compiler2 zero shark minimal dtrace jvmti jvmci \ - graal fprof vm-structs jni-check services management all-gcs nmt cds \ + graal vm-structs jni-check services management all-gcs nmt cds \ static-build link-time-opt aot" # All valid JVM variants @@ -5161,7 +5161,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1504214237 +DATE_WHEN_GENERATED=1504224733 ############################################################################### # @@ -65875,7 +65875,7 @@ $as_echo "no" >&6; } fi # All variants but minimal (and custom) get these features - NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti fprof vm-structs jni-check services management all-gcs nmt" + NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti vm-structs jni-check services management all-gcs nmt" if test "x$ENABLE_CDS" = "xtrue"; then NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES cds" fi diff --git a/common/autoconf/hotspot.m4 b/common/autoconf/hotspot.m4 index 2d224919185..636a7f43d01 100644 --- a/common/autoconf/hotspot.m4 +++ b/common/autoconf/hotspot.m4 @@ -25,7 +25,7 @@ # All valid JVM features, regardless of platform VALID_JVM_FEATURES="compiler1 compiler2 zero shark minimal dtrace jvmti jvmci \ - graal fprof vm-structs jni-check services management all-gcs nmt cds \ + graal vm-structs jni-check services management all-gcs nmt cds \ static-build link-time-opt aot" # All valid JVM variants @@ -397,7 +397,7 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES], fi # All variants but minimal (and custom) get these features - NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti fprof vm-structs jni-check services management all-gcs nmt" + NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti vm-structs jni-check services management all-gcs nmt" if test "x$ENABLE_CDS" = "xtrue"; then NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES cds" fi From 120f2c0077f1d9e0f0349c28d1bbd015545f5c29 Mon Sep 17 00:00:00 2001 From: Gerard Ziemski Date: Thu, 31 Aug 2017 20:25:52 -0500 Subject: [PATCH 76/98] 8173715: Remove FlatProfiler Obsoleted Xprof flag, removed FlatProfiler code Reviewed-by: mchung --- .../share/classes/sun/launcher/resources/launcher.properties | 1 - jdk/src/linux/doc/man/java.1 | 5 ----- jdk/src/solaris/doc/sun/man/man1/java.1 | 5 ----- 3 files changed, 11 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties index 5b8c09049c1..d12ad378bf3 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties @@ -137,7 +137,6 @@ java.launcher.X.usage=\n\ \ -Xms set initial Java heap size\n\ \ -Xmx set maximum Java heap size\n\ \ -Xnoclassgc disable class garbage collection\n\ -\ -Xprof output cpu profiling data (deprecated)\n\ \ -Xrs reduce use of OS signals by Java/VM (see documentation)\n\ \ -Xshare:auto use shared class data if possible (default)\n\ \ -Xshare:off do not attempt to use shared class data\n\ diff --git a/jdk/src/linux/doc/man/java.1 b/jdk/src/linux/doc/man/java.1 index 4615bad506a..afa5693cf7d 100644 --- a/jdk/src/linux/doc/man/java.1 +++ b/jdk/src/linux/doc/man/java.1 @@ -921,11 +921,6 @@ When you specify at startup, the class objects in the application will be left untouched during GC and will always be considered live\&. This can result in more memory being permanently occupied which, if not used carefully, will throw an out of memory exception\&. .RE .PP -\-Xprof -.RS 4 -Profiles the running program and sends profiling data to standard output\&. This option is provided as a utility that is useful in program development and is not intended to be used in production systems\&. -.RE -.PP \-Xrs .RS 4 Reduces the use of operating system signals by the JVM\&. diff --git a/jdk/src/solaris/doc/sun/man/man1/java.1 b/jdk/src/solaris/doc/sun/man/man1/java.1 index 4615bad506a..afa5693cf7d 100644 --- a/jdk/src/solaris/doc/sun/man/man1/java.1 +++ b/jdk/src/solaris/doc/sun/man/man1/java.1 @@ -921,11 +921,6 @@ When you specify at startup, the class objects in the application will be left untouched during GC and will always be considered live\&. This can result in more memory being permanently occupied which, if not used carefully, will throw an out of memory exception\&. .RE .PP -\-Xprof -.RS 4 -Profiles the running program and sends profiling data to standard output\&. This option is provided as a utility that is useful in program development and is not intended to be used in production systems\&. -.RE -.PP \-Xrs .RS 4 Reduces the use of operating system signals by the JVM\&. From 59445a845cab70467f2b626464d4b36b4bf8487f Mon Sep 17 00:00:00 2001 From: Gerard Ziemski Date: Thu, 31 Aug 2017 20:26:53 -0500 Subject: [PATCH 77/98] 8173715: Remove FlatProfiler Obsoleted Xprof flag, removed FlatProfiler code Reviewed-by: dholmes, coleenp, vlivanov, pliden --- hotspot/make/lib/JvmFeatures.gmk | 7 +- .../src/cpu/sparc/vm/macroAssembler_sparc.cpp | 6 +- hotspot/src/os/aix/vm/os_aix.cpp | 51 +- hotspot/src/os/bsd/vm/os_bsd.cpp | 53 +- hotspot/src/os/linux/vm/os_linux.cpp | 52 +- .../src/os/solaris/vm/osThread_solaris.hpp | 8 +- hotspot/src/os/solaris/vm/os_solaris.cpp | 74 +- hotspot/src/os/windows/vm/os_windows.cpp | 16 - .../src/os_cpu/aix_ppc/vm/thread_aix_ppc.hpp | 19 +- .../os_cpu/linux_ppc/vm/thread_linux_ppc.hpp | 21 +- .../linux_s390/vm/thread_linux_s390.hpp | 21 +- hotspot/src/share/vm/Xusage.txt | 1 - .../src/share/vm/classfile/classLoader.cpp | 2 - .../src/share/vm/compiler/disassembler.cpp | 32 +- hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp | 1 - hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.hpp | 1 - hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp | 1 - .../src/share/vm/gc/g1/g1RootProcessor.cpp | 10 +- .../src/share/vm/gc/g1/g1RootProcessor.hpp | 1 - hotspot/src/share/vm/gc/parallel/pcTasks.cpp | 7 +- hotspot/src/share/vm/gc/parallel/pcTasks.hpp | 13 +- .../src/share/vm/gc/parallel/psMarkSweep.cpp | 3 - .../vm/gc/parallel/psParallelCompact.cpp | 3 - .../src/share/vm/gc/parallel/psScavenge.cpp | 2 - hotspot/src/share/vm/gc/parallel/psTasks.cpp | 7 +- hotspot/src/share/vm/gc/parallel/psTasks.hpp | 13 +- .../src/share/vm/gc/serial/genMarkSweep.cpp | 1 - .../share/vm/gc/shared/genCollectedHeap.cpp | 5 - hotspot/src/share/vm/memory/universe.cpp | 1 - hotspot/src/share/vm/opto/runtime.cpp | 1 - hotspot/src/share/vm/prims/jni.cpp | 1 - hotspot/src/share/vm/runtime/arguments.cpp | 15 +- hotspot/src/share/vm/runtime/arguments.hpp | 4 - hotspot/src/share/vm/runtime/fprofiler.cpp | 1623 ----------------- hotspot/src/share/vm/runtime/fprofiler.hpp | 319 ---- hotspot/src/share/vm/runtime/java.cpp | 7 - hotspot/src/share/vm/runtime/os.hpp | 1 - hotspot/src/share/vm/runtime/thread.cpp | 60 +- hotspot/src/share/vm/runtime/thread.hpp | 18 - hotspot/src/share/vm/utilities/macros.hpp | 12 - hotspot/test/gc/g1/TestGCLogMessages.java | 1 - .../CommandLine/TestNullTerminatedFlags.java | 1 - hotspot/test/runtime/MinimalVM/Xprof.java | 44 - 43 files changed, 92 insertions(+), 2447 deletions(-) delete mode 100644 hotspot/src/share/vm/runtime/fprofiler.cpp delete mode 100644 hotspot/src/share/vm/runtime/fprofiler.hpp delete mode 100644 hotspot/test/runtime/MinimalVM/Xprof.java diff --git a/hotspot/make/lib/JvmFeatures.gmk b/hotspot/make/lib/JvmFeatures.gmk index c5e06af9ce2..db07898ce41 100644 --- a/hotspot/make/lib/JvmFeatures.gmk +++ b/hotspot/make/lib/JvmFeatures.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 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 @@ -88,11 +88,6 @@ ifneq ($(call check-jvm-feature, jvmci), true) JVM_EXCLUDE_FILES += jvmciCodeInstaller_$(HOTSPOT_TARGET_CPU_ARCH).cpp endif -ifneq ($(call check-jvm-feature, fprof), true) - JVM_CFLAGS_FEATURES += -DINCLUDE_FPROF=0 - JVM_EXCLUDE_FILES += fprofiler.cpp -endif - ifneq ($(call check-jvm-feature, vm-structs), true) JVM_CFLAGS_FEATURES += -DINCLUDE_VM_STRUCTS=0 JVM_EXCLUDE_FILES += vmStructs.cpp diff --git a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp index 1faa75f96f1..b667f1b1103 100644 --- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp @@ -292,7 +292,7 @@ void MacroAssembler::verify_thread() { if (VerifyThread) { // NOTE: this chops off the heads of the 64-bit O registers. // make sure G2_thread contains the right value - save_frame_and_mov(0, Lmethod, Lmethod); // to avoid clobbering O0 (and propagate Lmethod for -Xprof) + save_frame_and_mov(0, Lmethod, Lmethod); // to avoid clobbering O0 (and propagate Lmethod) mov(G1, L1); // avoid clobbering G1 // G2 saved below mov(G3, L3); // avoid clobbering G3 @@ -398,7 +398,7 @@ void MacroAssembler::reset_last_Java_frame(void) { #ifdef ASSERT // check that it WAS previously set - save_frame_and_mov(0, Lmethod, Lmethod); // Propagate Lmethod to helper frame for -Xprof + save_frame_and_mov(0, Lmethod, Lmethod); // Propagate Lmethod to helper frame ld_ptr(sp_addr, L0); tst(L0); breakpoint_trap(Assembler::zero, Assembler::ptr_cc); @@ -618,7 +618,7 @@ void MacroAssembler::set_vm_result(Register oop_result) { # ifdef ASSERT // Check that we are not overwriting any other oop. - save_frame_and_mov(0, Lmethod, Lmethod); // Propagate Lmethod for -Xprof + save_frame_and_mov(0, Lmethod, Lmethod); // Propagate Lmethod ld_ptr(vm_result_addr, L0); tst(L0); restore(); diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp index 9801e373308..68a206afd14 100644 --- a/hotspot/src/os/aix/vm/os_aix.cpp +++ b/hotspot/src/os/aix/vm/os_aix.cpp @@ -2607,11 +2607,10 @@ void os::hint_no_preempt() {} //////////////////////////////////////////////////////////////////////////////// // suspend/resume support -// the low-level signal-based suspend/resume support is a remnant from the +// The low-level signal-based suspend/resume support is a remnant from the // old VM-suspension that used to be for java-suspension, safepoints etc, -// within hotspot. Now there is a single use-case for this: -// - calling get_thread_pc() on the VMThread by the flat-profiler task -// that runs in the watcher thread. +// within hotspot. Currently used by JFR's OSThreadSampler +// // The remaining code is greatly simplified from the more general suspension // code that used to be used. // @@ -2627,7 +2626,13 @@ void os::hint_no_preempt() {} // // Note that the SR_lock plays no role in this suspend/resume protocol, // but is checked for NULL in SR_handler as a thread termination indicator. +// The SR_lock is, however, used by JavaThread::java_suspend()/java_resume() APIs. // +// Note that resume_clear_context() and suspend_save_context() are needed +// by SR_handler(), so that fetch_frame_from_ucontext() works, +// which in part is used by: +// - Forte Analyzer: AsyncGetCallTrace() +// - StackBanging: get_frame_at_stack_banging_point() static void resume_clear_context(OSThread *osthread) { osthread->set_ucontext(NULL); @@ -3634,44 +3639,6 @@ void os::SuspendedThreadTask::internal_do_task() { } } -class PcFetcher : public os::SuspendedThreadTask { -public: - PcFetcher(Thread* thread) : os::SuspendedThreadTask(thread) {} - ExtendedPC result(); -protected: - void do_task(const os::SuspendedThreadTaskContext& context); -private: - ExtendedPC _epc; -}; - -ExtendedPC PcFetcher::result() { - guarantee(is_done(), "task is not done yet."); - return _epc; -} - -void PcFetcher::do_task(const os::SuspendedThreadTaskContext& context) { - Thread* thread = context.thread(); - OSThread* osthread = thread->osthread(); - if (osthread->ucontext() != NULL) { - _epc = os::Aix::ucontext_get_pc((const ucontext_t *) context.ucontext()); - } else { - // NULL context is unexpected, double-check this is the VMThread. - guarantee(thread->is_VM_thread(), "can only be called for VMThread"); - } -} - -// Suspends the target using the signal mechanism and then grabs the PC before -// resuming the target. Used by the flat-profiler only -ExtendedPC os::get_thread_pc(Thread* thread) { - // Make sure that it is called by the watcher for the VMThread. - assert(Thread::current()->is_Watcher_thread(), "Must be watcher"); - assert(thread->is_VM_thread(), "Can only be called for VMThread"); - - PcFetcher fetcher(thread); - fetcher.run(); - return fetcher.result(); -} - //////////////////////////////////////////////////////////////////////////////// // debug support diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index 31b31574d81..ef83bf31130 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -2603,11 +2603,10 @@ void os::hint_no_preempt() {} //////////////////////////////////////////////////////////////////////////////// // suspend/resume support -// the low-level signal-based suspend/resume support is a remnant from the +// The low-level signal-based suspend/resume support is a remnant from the // old VM-suspension that used to be for java-suspension, safepoints etc, -// within hotspot. Now there is a single use-case for this: -// - calling get_thread_pc() on the VMThread by the flat-profiler task -// that runs in the watcher thread. +// within hotspot. Currently used by JFR's OSThreadSampler +// // The remaining code is greatly simplified from the more general suspension // code that used to be used. // @@ -2623,6 +2622,13 @@ void os::hint_no_preempt() {} // // Note that the SR_lock plays no role in this suspend/resume protocol, // but is checked for NULL in SR_handler as a thread termination indicator. +// The SR_lock is, however, used by JavaThread::java_suspend()/java_resume() APIs. +// +// Note that resume_clear_context() and suspend_save_context() are needed +// by SR_handler(), so that fetch_frame_from_ucontext() works, +// which in part is used by: +// - Forte Analyzer: AsyncGetCallTrace() +// - StackBanging: get_frame_at_stack_banging_point() static void resume_clear_context(OSThread *osthread) { osthread->set_ucontext(NULL); @@ -3521,45 +3527,6 @@ void os::SuspendedThreadTask::internal_do_task() { } } -/// -class PcFetcher : public os::SuspendedThreadTask { - public: - PcFetcher(Thread* thread) : os::SuspendedThreadTask(thread) {} - ExtendedPC result(); - protected: - void do_task(const os::SuspendedThreadTaskContext& context); - private: - ExtendedPC _epc; -}; - -ExtendedPC PcFetcher::result() { - guarantee(is_done(), "task is not done yet."); - return _epc; -} - -void PcFetcher::do_task(const os::SuspendedThreadTaskContext& context) { - Thread* thread = context.thread(); - OSThread* osthread = thread->osthread(); - if (osthread->ucontext() != NULL) { - _epc = os::Bsd::ucontext_get_pc((const ucontext_t *) context.ucontext()); - } else { - // NULL context is unexpected, double-check this is the VMThread - guarantee(thread->is_VM_thread(), "can only be called for VMThread"); - } -} - -// Suspends the target using the signal mechanism and then grabs the PC before -// resuming the target. Used by the flat-profiler only -ExtendedPC os::get_thread_pc(Thread* thread) { - // Make sure that it is called by the watcher for the VMThread - assert(Thread::current()->is_Watcher_thread(), "Must be watcher"); - assert(thread->is_VM_thread(), "Can only be called for VMThread"); - - PcFetcher fetcher(thread); - fetcher.run(); - return fetcher.result(); -} - //////////////////////////////////////////////////////////////////////////////// // debug support diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 7634fc773db..e6ebec3e53e 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -4000,11 +4000,10 @@ void os::hint_no_preempt() {} //////////////////////////////////////////////////////////////////////////////// // suspend/resume support -// the low-level signal-based suspend/resume support is a remnant from the +// The low-level signal-based suspend/resume support is a remnant from the // old VM-suspension that used to be for java-suspension, safepoints etc, -// within hotspot. Now there is a single use-case for this: -// - calling get_thread_pc() on the VMThread by the flat-profiler task -// that runs in the watcher thread. +// within hotspot. Currently used by JFR's OSThreadSampler +// // The remaining code is greatly simplified from the more general suspension // code that used to be used. // @@ -4020,6 +4019,13 @@ void os::hint_no_preempt() {} // // Note that the SR_lock plays no role in this suspend/resume protocol, // but is checked for NULL in SR_handler as a thread termination indicator. +// The SR_lock is, however, used by JavaThread::java_suspend()/java_resume() APIs. +// +// Note that resume_clear_context() and suspend_save_context() are needed +// by SR_handler(), so that fetch_frame_from_ucontext() works, +// which in part is used by: +// - Forte Analyzer: AsyncGetCallTrace() +// - StackBanging: get_frame_at_stack_banging_point() static void resume_clear_context(OSThread *osthread) { osthread->set_ucontext(NULL); @@ -5060,44 +5066,6 @@ void os::SuspendedThreadTask::internal_do_task() { } } -class PcFetcher : public os::SuspendedThreadTask { - public: - PcFetcher(Thread* thread) : os::SuspendedThreadTask(thread) {} - ExtendedPC result(); - protected: - void do_task(const os::SuspendedThreadTaskContext& context); - private: - ExtendedPC _epc; -}; - -ExtendedPC PcFetcher::result() { - guarantee(is_done(), "task is not done yet."); - return _epc; -} - -void PcFetcher::do_task(const os::SuspendedThreadTaskContext& context) { - Thread* thread = context.thread(); - OSThread* osthread = thread->osthread(); - if (osthread->ucontext() != NULL) { - _epc = os::Linux::ucontext_get_pc((const ucontext_t *) context.ucontext()); - } else { - // NULL context is unexpected, double-check this is the VMThread - guarantee(thread->is_VM_thread(), "can only be called for VMThread"); - } -} - -// Suspends the target using the signal mechanism and then grabs the PC before -// resuming the target. Used by the flat-profiler only -ExtendedPC os::get_thread_pc(Thread* thread) { - // Make sure that it is called by the watcher for the VMThread - assert(Thread::current()->is_Watcher_thread(), "Must be watcher"); - assert(thread->is_VM_thread(), "Can only be called for VMThread"); - - PcFetcher fetcher(thread); - fetcher.run(); - return fetcher.result(); -} - //////////////////////////////////////////////////////////////////////////////// // debug support diff --git a/hotspot/src/os/solaris/vm/osThread_solaris.hpp b/hotspot/src/os/solaris/vm/osThread_solaris.hpp index 4588bc415a9..597750adf5b 100644 --- a/hotspot/src/os/solaris/vm/osThread_solaris.hpp +++ b/hotspot/src/os/solaris/vm/osThread_solaris.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -65,12 +65,6 @@ void set_lwp_id(uint id) { _lwp_id = id; } void set_native_priority(int prio) { _native_priority = prio; } - // *************************************************************** - // interrupt support. interrupts (using signals) are used to get - // the thread context (get_thread_pc), to set the thread context - // (set_thread_pc), and to implement java.lang.Thread.interrupt. - // *************************************************************** - public: os::SuspendResume sr; diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index 03319f1c974..065fcb4e602 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -3442,6 +3442,37 @@ void os::hint_no_preempt() { schedctl_start(schedctl_init()); } +//////////////////////////////////////////////////////////////////////////////// +// suspend/resume support + +// The low-level signal-based suspend/resume support is a remnant from the +// old VM-suspension that used to be for java-suspension, safepoints etc, +// within hotspot. Currently used by JFR's OSThreadSampler +// +// The remaining code is greatly simplified from the more general suspension +// code that used to be used. +// +// The protocol is quite simple: +// - suspend: +// - sends a signal to the target thread +// - polls the suspend state of the osthread using a yield loop +// - target thread signal handler (SR_handler) sets suspend state +// and blocks in sigsuspend until continued +// - resume: +// - sets target osthread state to continue +// - sends signal to end the sigsuspend loop in the SR_handler +// +// Note that the SR_lock plays no role in this suspend/resume protocol, +// but is checked for NULL in SR_handler as a thread termination indicator. +// The SR_lock is, however, used by JavaThread::java_suspend()/java_resume() APIs. +// +// Note that resume_clear_context() and suspend_save_context() are needed +// by SR_handler(), so that fetch_frame_from_ucontext() works, +// which in part is used by: +// - Forte Analyzer: AsyncGetCallTrace() +// - StackBanging: get_frame_at_stack_banging_point() +// - JFR: get_topframe()-->....-->get_valid_uc_in_signal_handler() + static void resume_clear_context(OSThread *osthread) { osthread->set_ucontext(NULL); } @@ -3452,7 +3483,7 @@ static void suspend_save_context(OSThread *osthread, ucontext_t* context) { static PosixSemaphore sr_semaphore; -void os::Solaris::SR_handler(Thread* thread, ucontext_t* uc) { +void os::Solaris::SR_handler(Thread* thread, ucontext_t* context) { // Save and restore errno to avoid confusing native code with EINTR // after sigsuspend. int old_errno = errno; @@ -3462,7 +3493,7 @@ void os::Solaris::SR_handler(Thread* thread, ucontext_t* uc) { os::SuspendResume::State current = osthread->sr.state(); if (current == os::SuspendResume::SR_SUSPEND_REQUEST) { - suspend_save_context(osthread, uc); + suspend_save_context(osthread, context); // attempt to switch the state, we assume we had a SUSPEND_REQUEST os::SuspendResume::State state = osthread->sr.suspended(); @@ -3609,45 +3640,6 @@ void os::SuspendedThreadTask::internal_do_task() { } } -class PcFetcher : public os::SuspendedThreadTask { - public: - PcFetcher(Thread* thread) : os::SuspendedThreadTask(thread) {} - ExtendedPC result(); - protected: - void do_task(const os::SuspendedThreadTaskContext& context); - private: - ExtendedPC _epc; -}; - -ExtendedPC PcFetcher::result() { - guarantee(is_done(), "task is not done yet."); - return _epc; -} - -void PcFetcher::do_task(const os::SuspendedThreadTaskContext& context) { - Thread* thread = context.thread(); - OSThread* osthread = thread->osthread(); - if (osthread->ucontext() != NULL) { - _epc = os::Solaris::ucontext_get_pc((const ucontext_t *) context.ucontext()); - } else { - // NULL context is unexpected, double-check this is the VMThread - guarantee(thread->is_VM_thread(), "can only be called for VMThread"); - } -} - -// A lightweight implementation that does not suspend the target thread and -// thus returns only a hint. Used for profiling only! -ExtendedPC os::get_thread_pc(Thread* thread) { - // Make sure that it is called by the watcher and the Threads lock is owned. - assert(Thread::current()->is_Watcher_thread(), "Must be watcher and own Threads_lock"); - // For now, is only used to profile the VM Thread - assert(thread->is_VM_thread(), "Can only be called for VMThread"); - PcFetcher fetcher(thread); - fetcher.run(); - return fetcher.result(); -} - - // This does not do anything on Solaris. This is basically a hook for being // able to use structured exception handling (thread-local exception filters) on, e.g., Win32. void os::os_exception_wrapper(java_call_t f, JavaValue* value, diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 6ebba5dcb24..5c464768eea 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -3506,22 +3506,6 @@ bool os::is_interrupted(Thread* thread, bool clear_interrupted) { return interrupted; } -// Get's a pc (hint) for a running thread. Currently used only for profiling. -ExtendedPC os::get_thread_pc(Thread* thread) { - CONTEXT context; - context.ContextFlags = CONTEXT_CONTROL; - HANDLE handle = thread->osthread()->thread_handle(); - if (GetThreadContext(handle, &context)) { -#ifdef _M_AMD64 - return ExtendedPC((address) context.Rip); -#else - return ExtendedPC((address) context.Eip); -#endif - } else { - return ExtendedPC(NULL); - } -} - // GetCurrentThreadId() returns DWORD intx os::current_thread_id() { return GetCurrentThreadId(); } diff --git a/hotspot/src/os_cpu/aix_ppc/vm/thread_aix_ppc.hpp b/hotspot/src/os_cpu/aix_ppc/vm/thread_aix_ppc.hpp index ca649130a7d..932fdf9d004 100644 --- a/hotspot/src/os_cpu/aix_ppc/vm/thread_aix_ppc.hpp +++ b/hotspot/src/os_cpu/aix_ppc/vm/thread_aix_ppc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2013 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -29,7 +29,6 @@ private: void pd_initialize() { _anchor.clear(); - _last_interpreter_fp = NULL; } // The `last' frame is the youngest Java frame on the thread's stack. @@ -60,20 +59,4 @@ bool pd_get_top_frame_for_signal_handler(frame* fr_addr, void* ucontext, bool isInJava); - // -Xprof support - // - // In order to find the last Java fp from an async profile - // tick, we store the current interpreter fp in the thread. - // This value is only valid while we are in the C++ interpreter - // and profiling. - protected: - intptr_t *_last_interpreter_fp; - - public: - static ByteSize last_interpreter_fp_offset() { - return byte_offset_of(JavaThread, _last_interpreter_fp); - } - - intptr_t* last_interpreter_fp() { return _last_interpreter_fp; } - #endif // OS_CPU_AIX_PPC_VM_THREAD_AIX_PPC_HPP diff --git a/hotspot/src/os_cpu/linux_ppc/vm/thread_linux_ppc.hpp b/hotspot/src/os_cpu/linux_ppc/vm/thread_linux_ppc.hpp index 5caf4f33c16..7b3b31888b7 100644 --- a/hotspot/src/os_cpu/linux_ppc/vm/thread_linux_ppc.hpp +++ b/hotspot/src/os_cpu/linux_ppc/vm/thread_linux_ppc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2013 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -30,7 +30,6 @@ void pd_initialize() { _anchor.clear(); - _last_interpreter_fp = NULL; } // The `last' frame is the youngest Java frame on the thread's stack. @@ -62,22 +61,4 @@ bool pd_get_top_frame_for_signal_handler(frame* fr_addr, void* ucontext, bool isInJava); - protected: - - // -Xprof support - // - // In order to find the last Java fp from an async profile - // tick, we store the current interpreter fp in the thread. - // This value is only valid while we are in the C++ interpreter - // and profiling. - intptr_t *_last_interpreter_fp; - - public: - - static ByteSize last_interpreter_fp_offset() { - return byte_offset_of(JavaThread, _last_interpreter_fp); - } - - intptr_t* last_interpreter_fp() { return _last_interpreter_fp; } - #endif // OS_CPU_LINUX_PPC_VM_THREAD_LINUX_PPC_HPP diff --git a/hotspot/src/os_cpu/linux_s390/vm/thread_linux_s390.hpp b/hotspot/src/os_cpu/linux_s390/vm/thread_linux_s390.hpp index 6268700c277..585e1b25606 100644 --- a/hotspot/src/os_cpu/linux_s390/vm/thread_linux_s390.hpp +++ b/hotspot/src/os_cpu/linux_s390/vm/thread_linux_s390.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -30,7 +30,6 @@ void pd_initialize() { _anchor.clear(); - _last_interpreter_fp = NULL; } // The `last' frame is the youngest Java frame on the thread's stack. @@ -61,22 +60,4 @@ bool pd_get_top_frame_for_signal_handler(frame* fr_addr, void* ucontext, bool isInJava); - protected: - - // -Xprof support - // - // In order to find the last Java fp from an async profile - // tick, we store the current interpreter fp in the thread. - // This value is only valid while we are in the C++ interpreter - // and profiling. - intptr_t *_last_interpreter_fp; - - public: - - static ByteSize last_interpreter_fp_offset() { - return byte_offset_of(JavaThread, _last_interpreter_fp); - } - - intptr_t* last_interpreter_fp() { return _last_interpreter_fp; } - #endif // OS_CPU_LINUX_S390_VM_THREAD_LINUX_S390_HPP diff --git a/hotspot/src/share/vm/Xusage.txt b/hotspot/src/share/vm/Xusage.txt index 8c8eba19ace..e0990c32ac0 100644 --- a/hotspot/src/share/vm/Xusage.txt +++ b/hotspot/src/share/vm/Xusage.txt @@ -12,7 +12,6 @@ -Xms set initial Java heap size -Xmx set maximum Java heap size -Xss set java thread stack size - -Xprof output cpu profiling data (deprecated) -Xfuture enable strictest checks, anticipating future default -Xrs reduce use of OS signals by Java/VM (see documentation) -Xcheck:jni perform additional checks for JNI functions diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index 57eb704a904..8592616311f 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -57,7 +57,6 @@ #include "prims/jvm_misc.hpp" #include "runtime/arguments.hpp" #include "runtime/compilationPolicy.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/handles.hpp" #include "runtime/handles.inline.hpp" #include "runtime/init.hpp" @@ -1442,7 +1441,6 @@ InstanceKlass* ClassLoader::load_class(Symbol* name, bool search_append_only, TR const char* const class_name = name->as_C_string(); EventMark m("loading class %s", class_name); - ThreadProfilerMark tpm(ThreadProfilerMark::classLoaderRegion); const char* const file_name = file_name_for_class_name(class_name, name->utf8_length()); diff --git a/hotspot/src/share/vm/compiler/disassembler.cpp b/hotspot/src/share/vm/compiler/disassembler.cpp index e5f878c98d5..d5e6f66f440 100644 --- a/hotspot/src/share/vm/compiler/disassembler.cpp +++ b/hotspot/src/share/vm/compiler/disassembler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -30,7 +30,6 @@ #include "gc/shared/collectedHeap.hpp" #include "memory/resourceArea.hpp" #include "oops/oop.inline.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/handles.inline.hpp" #include "runtime/os.hpp" #include "runtime/stubCodeGenerator.hpp" @@ -163,7 +162,6 @@ class decode_env { bool _print_pc; bool _print_bytes; address _cur_insn; - int _total_ticks; int _bytes_per_line; // arch-specific formatting option static bool match(const char* event, const char* tag) { @@ -213,18 +211,6 @@ class decode_env { _nm->print_code_comment_on(st, COMMENT_COLUMN, pc0, pc); // this calls reloc_string_for which calls oop::print_value_on } - - // Output pc bucket ticks if we have any - if (total_ticks() != 0) { - address bucket_pc = FlatProfiler::bucket_start_for(pc); - if (bucket_pc != NULL && bucket_pc > pc0 && bucket_pc <= pc) { - int bucket_count = FlatProfiler::bucket_count_for(pc0); - if (bucket_count != 0) { - st->bol(); - st->print_cr("%3.1f%% [%d]", bucket_count*100.0/total_ticks(), bucket_count); - } - } - } // follow each complete insn by a nice newline st->cr(); } @@ -233,8 +219,6 @@ class decode_env { outputStream* output() { return _output; } address cur_insn() { return _cur_insn; } - int total_ticks() { return _total_ticks; } - void set_total_ticks(int n) { _total_ticks = n; } const char* options() { return _option_buf; } }; @@ -561,20 +545,6 @@ void Disassembler::decode(nmethod* nm, outputStream* st) { #endif env.output()->print_cr(" [" PTR_FORMAT ", " PTR_FORMAT "] " JLONG_FORMAT " bytes", p2i(p), p2i(end), ((jlong)(end - p))); - // If there has been profiling, print the buckets. - if (FlatProfiler::bucket_start_for(p) != NULL) { - unsigned char* p1 = p; - int total_bucket_count = 0; - while (p1 < end) { - unsigned char* p0 = p1; - p1 += pd_instruction_alignment(); - address bucket_pc = FlatProfiler::bucket_start_for(p1); - if (bucket_pc != NULL && bucket_pc > p0 && bucket_pc <= p1) - total_bucket_count += FlatProfiler::bucket_count_for(p0); - } - env.set_total_ticks(total_bucket_count); - } - // Print constant table. if (nm->consts_size() > 0) { nm->print_nmethod_labels(env.output(), nm->consts_begin()); diff --git a/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp b/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp index 4c646ed3330..c939a8459ab 100644 --- a/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp +++ b/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp @@ -54,7 +54,6 @@ G1GCPhaseTimes::G1GCPhaseTimes(STWGCTimer* gc_timer, uint max_gc_threads) : _gc_par_phases[UniverseRoots] = new WorkerDataArray(max_gc_threads, "Universe Roots (ms):"); _gc_par_phases[JNIRoots] = new WorkerDataArray(max_gc_threads, "JNI Handles Roots (ms):"); _gc_par_phases[ObjectSynchronizerRoots] = new WorkerDataArray(max_gc_threads, "ObjectSynchronizer Roots (ms):"); - _gc_par_phases[FlatProfilerRoots] = new WorkerDataArray(max_gc_threads, "FlatProfiler Roots (ms):"); _gc_par_phases[ManagementRoots] = new WorkerDataArray(max_gc_threads, "Management Roots (ms):"); _gc_par_phases[SystemDictionaryRoots] = new WorkerDataArray(max_gc_threads, "SystemDictionary Roots (ms):"); _gc_par_phases[CLDGRoots] = new WorkerDataArray(max_gc_threads, "CLDG Roots (ms):"); diff --git a/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.hpp b/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.hpp index 5ad59212197..602ddd90f28 100644 --- a/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.hpp +++ b/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.hpp @@ -49,7 +49,6 @@ class G1GCPhaseTimes : public CHeapObj { UniverseRoots, JNIRoots, ObjectSynchronizerRoots, - FlatProfilerRoots, ManagementRoots, SystemDictionaryRoots, CLDGRoots, diff --git a/hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp b/hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp index 7070a98c5f7..aad593b8c20 100644 --- a/hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp +++ b/hotspot/src/share/vm/gc/g1/g1MarkSweep.cpp @@ -48,7 +48,6 @@ #include "prims/jvmtiExport.hpp" #include "runtime/atomic.hpp" #include "runtime/biasedLocking.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/synchronizer.hpp" #include "runtime/thread.hpp" #include "runtime/vmThread.hpp" diff --git a/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp b/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp index d4cf52d73dd..2a585f19674 100644 --- a/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -38,7 +38,6 @@ #include "gc/g1/g1RootProcessor.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "memory/allocation.inline.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/mutex.hpp" #include "services/management.hpp" #include "utilities/macros.hpp" @@ -271,13 +270,6 @@ void G1RootProcessor::process_vm_roots(G1RootClosures* closures, } } - { - G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::FlatProfilerRoots, worker_i); - if (!_process_strong_tasks.is_task_claimed(G1RP_PS_FlatProfiler_oops_do)) { - FlatProfiler::oops_do(strong_roots); - } - } - { G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ManagementRoots, worker_i); if (!_process_strong_tasks.is_task_claimed(G1RP_PS_Management_oops_do)) { diff --git a/hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp b/hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp index 2ad4884c50d..84adab22ede 100644 --- a/hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp +++ b/hotspot/src/share/vm/gc/g1/g1RootProcessor.hpp @@ -57,7 +57,6 @@ class G1RootProcessor : public StackObj { G1RP_PS_Universe_oops_do, G1RP_PS_JNIHandles_oops_do, G1RP_PS_ObjectSynchronizer_oops_do, - G1RP_PS_FlatProfiler_oops_do, G1RP_PS_Management_oops_do, G1RP_PS_SystemDictionary_oops_do, G1RP_PS_ClassLoaderDataGraph_oops_do, diff --git a/hotspot/src/share/vm/gc/parallel/pcTasks.cpp b/hotspot/src/share/vm/gc/parallel/pcTasks.cpp index 1d48326818a..8cae47c23ef 100644 --- a/hotspot/src/share/vm/gc/parallel/pcTasks.cpp +++ b/hotspot/src/share/vm/gc/parallel/pcTasks.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -39,7 +39,6 @@ #include "oops/objArrayKlass.inline.hpp" #include "oops/oop.inline.hpp" #include "prims/jvmtiExport.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/jniHandles.hpp" #include "runtime/thread.hpp" #include "runtime/vmThread.hpp" @@ -105,10 +104,6 @@ void MarkFromRootsTask::do_it(GCTaskManager* manager, uint which) { ObjectSynchronizer::oops_do(&mark_and_push_closure); break; - case flat_profiler: - FlatProfiler::oops_do(&mark_and_push_closure); - break; - case management: Management::oops_do(&mark_and_push_closure); break; diff --git a/hotspot/src/share/vm/gc/parallel/pcTasks.hpp b/hotspot/src/share/vm/gc/parallel/pcTasks.hpp index 08bad720f3c..64f19e33997 100644 --- a/hotspot/src/share/vm/gc/parallel/pcTasks.hpp +++ b/hotspot/src/share/vm/gc/parallel/pcTasks.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -94,12 +94,11 @@ class MarkFromRootsTask : public GCTask { jni_handles = 2, threads = 3, object_synchronizer = 4, - flat_profiler = 5, - management = 6, - jvmti = 7, - system_dictionary = 8, - class_loader_data = 9, - code_cache = 10 + management = 5, + jvmti = 6, + system_dictionary = 7, + class_loader_data = 8, + code_cache = 9 }; private: RootType _root_type; diff --git a/hotspot/src/share/vm/gc/parallel/psMarkSweep.cpp b/hotspot/src/share/vm/gc/parallel/psMarkSweep.cpp index 6e6747ae7e6..76f0d444f6f 100644 --- a/hotspot/src/share/vm/gc/parallel/psMarkSweep.cpp +++ b/hotspot/src/share/vm/gc/parallel/psMarkSweep.cpp @@ -50,7 +50,6 @@ #include "logging/log.hpp" #include "oops/oop.inline.hpp" #include "runtime/biasedLocking.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/safepoint.hpp" #include "runtime/vmThread.hpp" #include "services/management.hpp" @@ -514,7 +513,6 @@ void PSMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) { MarkingCodeBlobClosure each_active_code_blob(mark_and_push_closure(), !CodeBlobToOopClosure::FixRelocations); Threads::oops_do(mark_and_push_closure(), &each_active_code_blob); ObjectSynchronizer::oops_do(mark_and_push_closure()); - FlatProfiler::oops_do(mark_and_push_closure()); Management::oops_do(mark_and_push_closure()); JvmtiExport::oops_do(mark_and_push_closure()); SystemDictionary::always_strong_oops_do(mark_and_push_closure()); @@ -607,7 +605,6 @@ void PSMarkSweep::mark_sweep_phase3() { JNIHandles::oops_do(adjust_pointer_closure()); // Global (strong) JNI handles Threads::oops_do(adjust_pointer_closure(), NULL); ObjectSynchronizer::oops_do(adjust_pointer_closure()); - FlatProfiler::oops_do(adjust_pointer_closure()); Management::oops_do(adjust_pointer_closure()); JvmtiExport::oops_do(adjust_pointer_closure()); SystemDictionary::oops_do(adjust_pointer_closure()); diff --git a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp index 5e60e241e60..ae04316cb3e 100644 --- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp @@ -60,7 +60,6 @@ #include "oops/objArrayKlass.inline.hpp" #include "oops/oop.inline.hpp" #include "runtime/atomic.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/safepoint.hpp" #include "runtime/vmThread.hpp" #include "services/management.hpp" @@ -2086,7 +2085,6 @@ void PSParallelCompact::marking_phase(ParCompactionManager* cm, // We scan the thread roots in parallel Threads::create_thread_roots_marking_tasks(q); q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::object_synchronizer)); - q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::flat_profiler)); q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::management)); q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::system_dictionary)); q->enqueue(new MarkFromRootsTask(MarkFromRootsTask::class_loader_data)); @@ -2169,7 +2167,6 @@ void PSParallelCompact::adjust_roots(ParCompactionManager* cm) { JNIHandles::oops_do(&oop_closure); // Global (strong) JNI handles Threads::oops_do(&oop_closure, NULL); ObjectSynchronizer::oops_do(&oop_closure); - FlatProfiler::oops_do(&oop_closure); Management::oops_do(&oop_closure); JvmtiExport::oops_do(&oop_closure); SystemDictionary::oops_do(&oop_closure); diff --git a/hotspot/src/share/vm/gc/parallel/psScavenge.cpp b/hotspot/src/share/vm/gc/parallel/psScavenge.cpp index 89f0c932a45..db50e7bcf7b 100644 --- a/hotspot/src/share/vm/gc/parallel/psScavenge.cpp +++ b/hotspot/src/share/vm/gc/parallel/psScavenge.cpp @@ -49,7 +49,6 @@ #include "logging/log.hpp" #include "oops/oop.inline.hpp" #include "runtime/biasedLocking.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/handles.inline.hpp" #include "runtime/threadCritical.hpp" #include "runtime/vmThread.hpp" @@ -381,7 +380,6 @@ bool PSScavenge::invoke_no_policy() { // We scan the thread roots in parallel Threads::create_thread_roots_tasks(q); q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::object_synchronizer)); - q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::flat_profiler)); q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::management)); q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::system_dictionary)); q->enqueue(new ScavengeRootsTask(ScavengeRootsTask::class_loader_data)); diff --git a/hotspot/src/share/vm/gc/parallel/psTasks.cpp b/hotspot/src/share/vm/gc/parallel/psTasks.cpp index 36290e7b5a1..35e63dc52c3 100644 --- a/hotspot/src/share/vm/gc/parallel/psTasks.cpp +++ b/hotspot/src/share/vm/gc/parallel/psTasks.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -38,7 +38,6 @@ #include "memory/resourceArea.hpp" #include "memory/universe.hpp" #include "oops/oop.inline.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/thread.hpp" #include "runtime/vmThread.hpp" #include "services/management.hpp" @@ -74,10 +73,6 @@ void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) { ObjectSynchronizer::oops_do(&roots_closure); break; - case flat_profiler: - FlatProfiler::oops_do(&roots_closure); - break; - case system_dictionary: SystemDictionary::oops_do(&roots_closure); break; diff --git a/hotspot/src/share/vm/gc/parallel/psTasks.hpp b/hotspot/src/share/vm/gc/parallel/psTasks.hpp index 8f01dacd66a..f527ead719c 100644 --- a/hotspot/src/share/vm/gc/parallel/psTasks.hpp +++ b/hotspot/src/share/vm/gc/parallel/psTasks.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -57,12 +57,11 @@ class ScavengeRootsTask : public GCTask { jni_handles = 2, threads = 3, object_synchronizer = 4, - flat_profiler = 5, - system_dictionary = 6, - class_loader_data = 7, - management = 8, - jvmti = 9, - code_cache = 10 + system_dictionary = 5, + class_loader_data = 6, + management = 7, + jvmti = 8, + code_cache = 9 }; private: RootType _root_type; diff --git a/hotspot/src/share/vm/gc/serial/genMarkSweep.cpp b/hotspot/src/share/vm/gc/serial/genMarkSweep.cpp index 7472cee27e1..e7c58edf722 100644 --- a/hotspot/src/share/vm/gc/serial/genMarkSweep.cpp +++ b/hotspot/src/share/vm/gc/serial/genMarkSweep.cpp @@ -46,7 +46,6 @@ #include "oops/instanceRefKlass.hpp" #include "oops/oop.inline.hpp" #include "prims/jvmtiExport.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/handles.inline.hpp" #include "runtime/synchronizer.hpp" #include "runtime/thread.inline.hpp" diff --git a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp index 6432b1034fc..eb98e3f2595 100644 --- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp @@ -47,7 +47,6 @@ #include "memory/resourceArea.hpp" #include "oops/oop.inline.hpp" #include "runtime/biasedLocking.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/handles.hpp" #include "runtime/handles.inline.hpp" #include "runtime/java.hpp" @@ -71,7 +70,6 @@ enum GCH_strong_roots_tasks { GCH_PS_Universe_oops_do, GCH_PS_JNIHandles_oops_do, GCH_PS_ObjectSynchronizer_oops_do, - GCH_PS_FlatProfiler_oops_do, GCH_PS_Management_oops_do, GCH_PS_SystemDictionary_oops_do, GCH_PS_ClassLoaderDataGraph_oops_do, @@ -606,9 +604,6 @@ void GenCollectedHeap::process_roots(StrongRootsScope* scope, if (!_process_strong_tasks->is_task_claimed(GCH_PS_ObjectSynchronizer_oops_do)) { ObjectSynchronizer::oops_do(strong_roots); } - if (!_process_strong_tasks->is_task_claimed(GCH_PS_FlatProfiler_oops_do)) { - FlatProfiler::oops_do(strong_roots); - } if (!_process_strong_tasks->is_task_claimed(GCH_PS_Management_oops_do)) { Management::oops_do(strong_roots); } diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index cab6cc96933..5d3a57b59fe 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -63,7 +63,6 @@ #include "runtime/atomic.hpp" #include "runtime/commandLineFlagConstraintList.hpp" #include "runtime/deoptimization.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/handles.inline.hpp" #include "runtime/init.hpp" #include "runtime/java.hpp" diff --git a/hotspot/src/share/vm/opto/runtime.cpp b/hotspot/src/share/vm/opto/runtime.cpp index 7b16c30214c..a7a5ee71cce 100644 --- a/hotspot/src/share/vm/opto/runtime.cpp +++ b/hotspot/src/share/vm/opto/runtime.cpp @@ -61,7 +61,6 @@ #include "opto/runtime.hpp" #include "opto/subnode.hpp" #include "runtime/atomic.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/javaCalls.hpp" diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index bf018a98a73..19910ed4734 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -62,7 +62,6 @@ #include "runtime/atomic.hpp" #include "runtime/compilationPolicy.hpp" #include "runtime/fieldDescriptor.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/java.hpp" diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index ffcdc4e9ba8..0213dbc3b1c 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -78,7 +78,6 @@ int Arguments::_num_jvm_args = 0; char* Arguments::_java_command = NULL; SystemProperty* Arguments::_system_properties = NULL; const char* Arguments::_gc_log_filename = NULL; -bool Arguments::_has_profile = false; size_t Arguments::_conservative_max_heap_alignment = 0; size_t Arguments::_min_heap_size = 0; Arguments::Mode Arguments::_mode = _mixed; @@ -3160,16 +3159,12 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m if (FLAG_SET_CMDLINE(bool, ReduceSignalUsage, true) != Flag::SUCCESS) { return JNI_EINVAL; } - // -Xprof + // -Xprof } else if (match_option(option, "-Xprof")) { -#if INCLUDE_FPROF - log_warning(arguments)("Option -Xprof was deprecated in version 9 and will likely be removed in a future release."); - _has_profile = true; -#else // INCLUDE_FPROF - jio_fprintf(defaultStream::error_stream(), - "Flat profiling is not supported in this VM.\n"); - return JNI_ERR; -#endif // INCLUDE_FPROF + char version[256]; + // Obsolete in JDK 10 + JDK_Version::jdk(10).to_string(version, sizeof(version)); + warning("Ignoring option %s; support was removed in %s", option->optionString, version); // -Xconcurrentio } else if (match_option(option, "-Xconcurrentio")) { if (FLAG_SET_CMDLINE(bool, UseLWPSynchronization, true) != Flag::SUCCESS) { diff --git a/hotspot/src/share/vm/runtime/arguments.hpp b/hotspot/src/share/vm/runtime/arguments.hpp index 56fd5ff4434..a6267d7a049 100644 --- a/hotspot/src/share/vm/runtime/arguments.hpp +++ b/hotspot/src/share/vm/runtime/arguments.hpp @@ -412,7 +412,6 @@ class Arguments : AllStatic { static bool _sun_java_launcher_is_altjvm; // Option flags - static bool _has_profile; static const char* _gc_log_filename; // Value of the conservative maximum heap alignment needed static size_t _conservative_max_heap_alignment; @@ -696,9 +695,6 @@ class Arguments : AllStatic { // -Dsun.java.launcher.pid static int sun_java_launcher_pid() { return _sun_java_launcher_pid; } - // -Xprof - static bool has_profile() { return _has_profile; } - // -Xms static size_t min_heap_size() { return _min_heap_size; } static void set_min_heap_size(size_t v) { _min_heap_size = v; } diff --git a/hotspot/src/share/vm/runtime/fprofiler.cpp b/hotspot/src/share/vm/runtime/fprofiler.cpp deleted file mode 100644 index fe19244d385..00000000000 --- a/hotspot/src/share/vm/runtime/fprofiler.cpp +++ /dev/null @@ -1,1623 +0,0 @@ -/* - * Copyright (c) 1997, 2016, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "classfile/classLoader.hpp" -#include "code/codeCache.hpp" -#include "code/vtableStubs.hpp" -#include "gc/shared/collectedHeap.inline.hpp" -#include "interpreter/interpreter.hpp" -#include "memory/allocation.inline.hpp" -#include "memory/resourceArea.hpp" -#include "memory/universe.inline.hpp" -#include "oops/oop.inline.hpp" -#include "oops/symbol.hpp" -#include "runtime/deoptimization.hpp" -#include "runtime/fprofiler.hpp" -#include "runtime/mutexLocker.hpp" -#include "runtime/stubCodeGenerator.hpp" -#include "runtime/stubRoutines.hpp" -#include "runtime/task.hpp" -#include "runtime/thread.inline.hpp" -#include "runtime/vframe.hpp" -#include "utilities/macros.hpp" - -// Static fields of FlatProfiler -int FlatProfiler::received_gc_ticks = 0; -int FlatProfiler::vm_operation_ticks = 0; -int FlatProfiler::threads_lock_ticks = 0; -int FlatProfiler::class_loader_ticks = 0; -int FlatProfiler::extra_ticks = 0; -int FlatProfiler::blocked_ticks = 0; -int FlatProfiler::deopt_ticks = 0; -int FlatProfiler::unknown_ticks = 0; -int FlatProfiler::interpreter_ticks = 0; -int FlatProfiler::compiler_ticks = 0; -int FlatProfiler::received_ticks = 0; -int FlatProfiler::delivered_ticks = 0; -int* FlatProfiler::bytecode_ticks = NULL; -int* FlatProfiler::bytecode_ticks_stub = NULL; -int FlatProfiler::all_int_ticks = 0; -int FlatProfiler::all_comp_ticks = 0; -int FlatProfiler::all_ticks = 0; -bool FlatProfiler::full_profile_flag = false; -ThreadProfiler* FlatProfiler::thread_profiler = NULL; -ThreadProfiler* FlatProfiler::vm_thread_profiler = NULL; -FlatProfilerTask* FlatProfiler::task = NULL; -elapsedTimer FlatProfiler::timer; -int FlatProfiler::interval_ticks_previous = 0; -IntervalData* FlatProfiler::interval_data = NULL; - -ThreadProfiler::ThreadProfiler() { - // Space for the ProfilerNodes - const int area_size = 1 * ProfilerNodeSize * 1024; - area_bottom = AllocateHeap(area_size, mtInternal); - area_top = area_bottom; - area_limit = area_bottom + area_size; - - // ProfilerNode pointer table - table = NEW_C_HEAP_ARRAY(ProfilerNode*, table_size, mtInternal); - initialize(); - engaged = false; -} - -ThreadProfiler::~ThreadProfiler() { - FreeHeap(area_bottom); - area_bottom = NULL; - area_top = NULL; - area_limit = NULL; - FreeHeap(table); - table = NULL; -} - -// Statics for ThreadProfiler -int ThreadProfiler::table_size = 1024; - -int ThreadProfiler::entry(int value) { - value = (value > 0) ? value : -value; - return value % table_size; -} - -ThreadProfilerMark::ThreadProfilerMark(ThreadProfilerMark::Region r) { - _r = r; - _pp = NULL; - assert(((r > ThreadProfilerMark::noRegion) && (r < ThreadProfilerMark::maxRegion)), "ThreadProfilerMark::Region out of bounds"); - Thread* tp = Thread::current(); - if (tp != NULL && tp->is_Java_thread()) { - JavaThread* jtp = (JavaThread*) tp; - ThreadProfiler* pp = jtp->get_thread_profiler(); - _pp = pp; - if (pp != NULL) { - pp->region_flag[r] = true; - } - } -} - -ThreadProfilerMark::~ThreadProfilerMark() { - if (_pp != NULL) { - _pp->region_flag[_r] = false; - } - _pp = NULL; -} - -// Random other statics -static const int col1 = 2; // position of output column 1 -static const int col2 = 11; // position of output column 2 -static const int col3 = 25; // position of output column 3 -static const int col4 = 55; // position of output column 4 - - -// Used for detailed profiling of nmethods. -class PCRecorder : AllStatic { - private: - static int* counters; - static address base; - enum { - bucket_size = 16 - }; - static int index_for(address pc) { return (pc - base)/bucket_size; } - static address pc_for(int index) { return base + (index * bucket_size); } - static int size() { - return ((int)CodeCache::max_capacity())/bucket_size * BytesPerWord; - } - public: - static address bucket_start_for(address pc) { - if (counters == NULL) return NULL; - return pc_for(index_for(pc)); - } - static int bucket_count_for(address pc) { return counters[index_for(pc)]; } - static void init(); - static void record(address pc); - static void print(); - static void print_blobs(CodeBlob* cb); -}; - -int* PCRecorder::counters = NULL; -address PCRecorder::base = NULL; - -void PCRecorder::init() { - MutexLockerEx lm(CodeCache_lock, Mutex::_no_safepoint_check_flag); - int s = size(); - counters = NEW_C_HEAP_ARRAY(int, s, mtInternal); - for (int index = 0; index < s; index++) { - counters[index] = 0; - } - base = CodeCache::low_bound(); -} - -void PCRecorder::record(address pc) { - if (counters == NULL) return; - assert(CodeCache::contains(pc), "must be in CodeCache"); - counters[index_for(pc)]++; -} - - -address FlatProfiler::bucket_start_for(address pc) { - return PCRecorder::bucket_start_for(pc); -} - -int FlatProfiler::bucket_count_for(address pc) { - return PCRecorder::bucket_count_for(pc); -} - -void PCRecorder::print() { - if (counters == NULL) return; - - tty->cr(); - tty->print_cr("Printing compiled methods with PC buckets having more than " INTX_FORMAT " ticks", ProfilerPCTickThreshold); - tty->print_cr("==================================================================="); - tty->cr(); - - GrowableArray* candidates = new GrowableArray(20); - - - int s; - { - MutexLockerEx lm(CodeCache_lock, Mutex::_no_safepoint_check_flag); - s = size(); - } - - for (int index = 0; index < s; index++) { - int count = counters[index]; - if (count > ProfilerPCTickThreshold) { - address pc = pc_for(index); - CodeBlob* cb = CodeCache::find_blob_unsafe(pc); - if (cb != NULL && candidates->find(cb) < 0) { - candidates->push(cb); - } - } - } - for (int i = 0; i < candidates->length(); i++) { - print_blobs(candidates->at(i)); - } -} - -void PCRecorder::print_blobs(CodeBlob* cb) { - if (cb != NULL) { - cb->print(); - if (cb->is_nmethod()) { - ((nmethod*)cb)->print_code(); - } - tty->cr(); - } else { - tty->print_cr("stub code"); - } -} - -class tick_counter { // holds tick info for one node - public: - int ticks_in_code; - int ticks_in_native; - - tick_counter() { ticks_in_code = ticks_in_native = 0; } - tick_counter(int code, int native) { ticks_in_code = code; ticks_in_native = native; } - - int total() const { - return (ticks_in_code + ticks_in_native); - } - - void add(tick_counter* a) { - ticks_in_code += a->ticks_in_code; - ticks_in_native += a->ticks_in_native; - } - - void update(TickPosition where) { - switch(where) { - case tp_code: ticks_in_code++; break; - case tp_native: ticks_in_native++; break; - } - } - - void print_code(outputStream* st, int total_ticks) { - st->print("%5.1f%% %5d ", total() * 100.0 / total_ticks, ticks_in_code); - } - - void print_native(outputStream* st) { - st->print(" + %5d ", ticks_in_native); - } -}; - -class ProfilerNode { - private: - ProfilerNode* _next; - public: - tick_counter ticks; - - public: - - void* operator new(size_t size, ThreadProfiler* tp) throw(); - void operator delete(void* p); - - ProfilerNode() { - _next = NULL; - } - - virtual ~ProfilerNode() { - if (_next) - delete _next; - } - - void set_next(ProfilerNode* n) { _next = n; } - ProfilerNode* next() { return _next; } - - void update(TickPosition where) { ticks.update(where);} - int total_ticks() { return ticks.total(); } - - virtual bool is_interpreted() const { return false; } - virtual bool is_compiled() const { return false; } - virtual bool is_stub() const { return false; } - virtual bool is_runtime_stub() const{ return false; } - virtual void oops_do(OopClosure* f) = 0; - - virtual bool interpreted_match(Method* m) const { return false; } - virtual bool compiled_match(Method* m ) const { return false; } - virtual bool stub_match(Method* m, const char* name) const { return false; } - virtual bool adapter_match() const { return false; } - virtual bool runtimeStub_match(const CodeBlob* stub, const char* name) const { return false; } - virtual bool unknown_compiled_match(const CodeBlob* cb) const { return false; } - - static void print_title(outputStream* st) { - st->print(" + native"); - st->fill_to(col3); - st->print("Method"); - st->fill_to(col4); - st->cr(); - } - - static void print_total(outputStream* st, tick_counter* t, int total, const char* msg) { - t->print_code(st, total); - st->fill_to(col2); - t->print_native(st); - st->fill_to(col3); - st->print("%s", msg); - st->cr(); - } - - virtual Method* method() = 0; - - virtual void print_method_on(outputStream* st) { - int limit; - int i; - Method* m = method(); - Symbol* k = m->klass_name(); - // Print the class name with dots instead of slashes - limit = k->utf8_length(); - for (i = 0 ; i < limit ; i += 1) { - char c = (char) k->byte_at(i); - if (c == '/') { - c = '.'; - } - st->print("%c", c); - } - if (limit > 0) { - st->print("."); - } - Symbol* n = m->name(); - limit = n->utf8_length(); - for (i = 0 ; i < limit ; i += 1) { - char c = (char) n->byte_at(i); - st->print("%c", c); - } - if (Verbose || WizardMode) { - // Disambiguate overloaded methods - Symbol* sig = m->signature(); - sig->print_symbol_on(st); - } else if (MethodHandles::is_signature_polymorphic(m->intrinsic_id())) - // compare with Method::print_short_name - MethodHandles::print_as_basic_type_signature_on(st, m->signature(), true); - } - - virtual void print(outputStream* st, int total_ticks) { - ticks.print_code(st, total_ticks); - st->fill_to(col2); - ticks.print_native(st); - st->fill_to(col3); - print_method_on(st); - st->cr(); - } - - // for hashing into the table - static int hash(Method* method) { - // The point here is to try to make something fairly unique - // out of the fields we can read without grabbing any locks - // since the method may be locked when we need the hash. - return ( - method->code_size() ^ - method->max_stack() ^ - method->max_locals() ^ - method->size_of_parameters()); - } - - // for sorting - static int compare(ProfilerNode** a, ProfilerNode** b) { - return (*b)->total_ticks() - (*a)->total_ticks(); - } -}; - -void* ProfilerNode::operator new(size_t size, ThreadProfiler* tp) throw() { - void* result = (void*) tp->area_top; - tp->area_top += size; - - if (tp->area_top > tp->area_limit) { - fatal("flat profiler buffer overflow"); - } - return result; -} - -void ProfilerNode::operator delete(void* p){ -} - -class interpretedNode : public ProfilerNode { - private: - Method* _method; - oop _class_loader; // needed to keep metadata for the method alive - public: - interpretedNode(Method* method, TickPosition where) : ProfilerNode() { - _method = method; - _class_loader = method->method_holder()->class_loader(); - update(where); - } - - bool is_interpreted() const { return true; } - - bool interpreted_match(Method* m) const { - return _method == m; - } - - void oops_do(OopClosure* f) { - f->do_oop(&_class_loader); - } - - Method* method() { return _method; } - - static void print_title(outputStream* st) { - st->fill_to(col1); - st->print("%11s", "Interpreted"); - ProfilerNode::print_title(st); - } - - void print(outputStream* st, int total_ticks) { - ProfilerNode::print(st, total_ticks); - } - - void print_method_on(outputStream* st) { - ProfilerNode::print_method_on(st); - MethodCounters* mcs = method()->method_counters(); - if (Verbose && mcs != NULL) mcs->invocation_counter()->print_short(); - } -}; - -class compiledNode : public ProfilerNode { - private: - Method* _method; - oop _class_loader; // needed to keep metadata for the method alive - public: - compiledNode(Method* method, TickPosition where) : ProfilerNode() { - _method = method; - _class_loader = method->method_holder()->class_loader(); - update(where); - } - bool is_compiled() const { return true; } - - bool compiled_match(Method* m) const { - return _method == m; - } - - Method* method() { return _method; } - - void oops_do(OopClosure* f) { - f->do_oop(&_class_loader); - } - - static void print_title(outputStream* st) { - st->fill_to(col1); - st->print("%11s", "Compiled"); - ProfilerNode::print_title(st); - } - - void print(outputStream* st, int total_ticks) { - ProfilerNode::print(st, total_ticks); - } - - void print_method_on(outputStream* st) { - ProfilerNode::print_method_on(st); - } -}; - -class stubNode : public ProfilerNode { - private: - Method* _method; - oop _class_loader; // needed to keep metadata for the method alive - const char* _symbol; // The name of the nearest VM symbol (for +ProfileVM). Points to a unique string - public: - stubNode(Method* method, const char* name, TickPosition where) : ProfilerNode() { - _method = method; - _class_loader = method->method_holder()->class_loader(); - _symbol = name; - update(where); - } - - bool is_stub() const { return true; } - - void oops_do(OopClosure* f) { - f->do_oop(&_class_loader); - } - - bool stub_match(Method* m, const char* name) const { - return (_method == m) && (_symbol == name); - } - - Method* method() { return _method; } - - static void print_title(outputStream* st) { - st->fill_to(col1); - st->print("%11s", "Stub"); - ProfilerNode::print_title(st); - } - - void print(outputStream* st, int total_ticks) { - ProfilerNode::print(st, total_ticks); - } - - void print_method_on(outputStream* st) { - ProfilerNode::print_method_on(st); - print_symbol_on(st); - } - - void print_symbol_on(outputStream* st) { - if(_symbol) { - st->print(" (%s)", _symbol); - } - } -}; - -class adapterNode : public ProfilerNode { - public: - adapterNode(TickPosition where) : ProfilerNode() { - update(where); - } - bool is_compiled() const { return true; } - - bool adapter_match() const { return true; } - - Method* method() { return NULL; } - - void oops_do(OopClosure* f) { - ; - } - - void print(outputStream* st, int total_ticks) { - ProfilerNode::print(st, total_ticks); - } - - void print_method_on(outputStream* st) { - st->print("%s", "adapters"); - } -}; - -class runtimeStubNode : public ProfilerNode { - private: - const RuntimeStub* _stub; - const char* _symbol; // The name of the nearest VM symbol when ProfileVM is on. Points to a unique string. - public: - runtimeStubNode(const CodeBlob* stub, const char* name, TickPosition where) : ProfilerNode(), _stub(NULL), _symbol(name) { - assert(stub->is_runtime_stub(), "wrong code blob"); - _stub = (RuntimeStub*) stub; - update(where); - } - - bool is_runtime_stub() const { return true; } - - bool runtimeStub_match(const CodeBlob* stub, const char* name) const { - assert(stub->is_runtime_stub(), "wrong code blob"); - return _stub->entry_point() == ((RuntimeStub*)stub)->entry_point() && - (_symbol == name); - } - - Method* method() { return NULL; } - - static void print_title(outputStream* st) { - st->fill_to(col1); - st->print("%11s", "Runtime stub"); - ProfilerNode::print_title(st); - } - - void oops_do(OopClosure* f) { - ; - } - - void print(outputStream* st, int total_ticks) { - ProfilerNode::print(st, total_ticks); - } - - void print_method_on(outputStream* st) { - st->print("%s", _stub->name()); - print_symbol_on(st); - } - - void print_symbol_on(outputStream* st) { - if(_symbol) { - st->print(" (%s)", _symbol); - } - } -}; - - -class unknown_compiledNode : public ProfilerNode { - const char *_name; - public: - unknown_compiledNode(const CodeBlob* cb, TickPosition where) : ProfilerNode() { - if ( cb->is_buffer_blob() ) - _name = ((const BufferBlob*)cb)->name(); - else - _name = ((const SingletonBlob*)cb)->name(); - update(where); - } - bool is_compiled() const { return true; } - - bool unknown_compiled_match(const CodeBlob* cb) const { - if ( cb->is_buffer_blob() ) - return !strcmp(((const BufferBlob*)cb)->name(), _name); - else - return !strcmp(((const SingletonBlob*)cb)->name(), _name); - } - - Method* method() { return NULL; } - - void oops_do(OopClosure* f) { - ; - } - - void print(outputStream* st, int total_ticks) { - ProfilerNode::print(st, total_ticks); - } - - void print_method_on(outputStream* st) { - st->print("%s", _name); - } -}; - -class vmNode : public ProfilerNode { - private: - const char* _name; // "optional" name obtained by os means such as dll lookup - public: - vmNode(const TickPosition where) : ProfilerNode() { - _name = NULL; - update(where); - } - - vmNode(const char* name, const TickPosition where) : ProfilerNode() { - _name = os::strdup(name); - update(where); - } - - ~vmNode() { - if (_name != NULL) { - os::free((void*)_name); - } - } - - const char *name() const { return _name; } - bool is_compiled() const { return true; } - - bool vm_match(const char* name) const { return strcmp(name, _name) == 0; } - - Method* method() { return NULL; } - - static int hash(const char* name){ - // Compute a simple hash - const char* cp = name; - int h = 0; - - if(name != NULL){ - while(*cp != '\0'){ - h = (h << 1) ^ *cp; - cp++; - } - } - return h; - } - - void oops_do(OopClosure* f) { - ; - } - - void print(outputStream* st, int total_ticks) { - ProfilerNode::print(st, total_ticks); - } - - void print_method_on(outputStream* st) { - if(_name==NULL){ - st->print("%s", "unknown code"); - } - else { - st->print("%s", _name); - } - } -}; - -void ThreadProfiler::interpreted_update(Method* method, TickPosition where) { - int index = entry(ProfilerNode::hash(method)); - if (!table[index]) { - table[index] = new (this) interpretedNode(method, where); - } else { - ProfilerNode* prev = table[index]; - for(ProfilerNode* node = prev; node; node = node->next()) { - if (node->interpreted_match(method)) { - node->update(where); - return; - } - prev = node; - } - prev->set_next(new (this) interpretedNode(method, where)); - } -} - -void ThreadProfiler::compiled_update(Method* method, TickPosition where) { - int index = entry(ProfilerNode::hash(method)); - if (!table[index]) { - table[index] = new (this) compiledNode(method, where); - } else { - ProfilerNode* prev = table[index]; - for(ProfilerNode* node = prev; node; node = node->next()) { - if (node->compiled_match(method)) { - node->update(where); - return; - } - prev = node; - } - prev->set_next(new (this) compiledNode(method, where)); - } -} - -void ThreadProfiler::stub_update(Method* method, const char* name, TickPosition where) { - int index = entry(ProfilerNode::hash(method)); - if (!table[index]) { - table[index] = new (this) stubNode(method, name, where); - } else { - ProfilerNode* prev = table[index]; - for(ProfilerNode* node = prev; node; node = node->next()) { - if (node->stub_match(method, name)) { - node->update(where); - return; - } - prev = node; - } - prev->set_next(new (this) stubNode(method, name, where)); - } -} - -void ThreadProfiler::adapter_update(TickPosition where) { - int index = 0; - if (!table[index]) { - table[index] = new (this) adapterNode(where); - } else { - ProfilerNode* prev = table[index]; - for(ProfilerNode* node = prev; node; node = node->next()) { - if (node->adapter_match()) { - node->update(where); - return; - } - prev = node; - } - prev->set_next(new (this) adapterNode(where)); - } -} - -void ThreadProfiler::runtime_stub_update(const CodeBlob* stub, const char* name, TickPosition where) { - int index = 0; - if (!table[index]) { - table[index] = new (this) runtimeStubNode(stub, name, where); - } else { - ProfilerNode* prev = table[index]; - for(ProfilerNode* node = prev; node; node = node->next()) { - if (node->runtimeStub_match(stub, name)) { - node->update(where); - return; - } - prev = node; - } - prev->set_next(new (this) runtimeStubNode(stub, name, where)); - } -} - - -void ThreadProfiler::unknown_compiled_update(const CodeBlob* cb, TickPosition where) { - int index = 0; - if (!table[index]) { - table[index] = new (this) unknown_compiledNode(cb, where); - } else { - ProfilerNode* prev = table[index]; - for(ProfilerNode* node = prev; node; node = node->next()) { - if (node->unknown_compiled_match(cb)) { - node->update(where); - return; - } - prev = node; - } - prev->set_next(new (this) unknown_compiledNode(cb, where)); - } -} - -void ThreadProfiler::vm_update(TickPosition where) { - vm_update(NULL, where); -} - -void ThreadProfiler::vm_update(const char* name, TickPosition where) { - int index = entry(vmNode::hash(name)); - assert(index >= 0, "Must be positive"); - // Note that we call strdup below since the symbol may be resource allocated - if (!table[index]) { - table[index] = new (this) vmNode(name, where); - } else { - ProfilerNode* prev = table[index]; - for(ProfilerNode* node = prev; node; node = node->next()) { - if (((vmNode *)node)->vm_match(name)) { - node->update(where); - return; - } - prev = node; - } - prev->set_next(new (this) vmNode(name, where)); - } -} - - -class FlatProfilerTask : public PeriodicTask { -public: - FlatProfilerTask(int interval_time) : PeriodicTask(interval_time) {} - void task(); -}; - -void FlatProfiler::record_vm_operation() { - if (Universe::heap()->is_gc_active()) { - FlatProfiler::received_gc_ticks += 1; - return; - } - - if (DeoptimizationMarker::is_active()) { - FlatProfiler::deopt_ticks += 1; - return; - } - - FlatProfiler::vm_operation_ticks += 1; -} - -void FlatProfiler::record_vm_tick() { - // Profile the VM Thread itself if needed - // This is done without getting the Threads_lock and we can go deep - // inside Safepoint, etc. - if( ProfileVM ) { - ResourceMark rm; - ExtendedPC epc; - const char *name = NULL; - char buf[256]; - buf[0] = '\0'; - - vm_thread_profiler->inc_thread_ticks(); - - // Get a snapshot of a current VMThread pc (and leave it running!) - // The call may fail in some circumstances - epc = os::get_thread_pc(VMThread::vm_thread()); - if(epc.pc() != NULL) { - if (os::dll_address_to_function_name(epc.pc(), buf, sizeof(buf), NULL)) { - name = buf; - } - } - if (name != NULL) { - vm_thread_profiler->vm_update(name, tp_native); - } - } -} - -void FlatProfiler::record_thread_ticks() { - - int maxthreads, suspendedthreadcount; - JavaThread** threadsList; - bool interval_expired = false; - - if (ProfileIntervals && - (FlatProfiler::received_ticks >= interval_ticks_previous + ProfileIntervalsTicks)) { - interval_expired = true; - interval_ticks_previous = FlatProfiler::received_ticks; - } - - // Try not to wait for the Threads_lock - if (Threads_lock->try_lock()) { - { // Threads_lock scope - maxthreads = Threads::number_of_threads(); - threadsList = NEW_C_HEAP_ARRAY(JavaThread *, maxthreads, mtInternal); - suspendedthreadcount = 0; - for (JavaThread* tp = Threads::first(); tp != NULL; tp = tp->next()) { - if (tp->is_Compiler_thread()) { - // Only record ticks for active compiler threads - CompilerThread* cthread = (CompilerThread*)tp; - if (cthread->task() != NULL) { - // The compiler is active. If we need to access any of the fields - // of the compiler task we should suspend the CompilerThread first. - FlatProfiler::compiler_ticks += 1; - continue; - } - } - - // First externally suspend all threads by marking each for - // external suspension - so it will stop at its next transition - // Then do a safepoint - ThreadProfiler* pp = tp->get_thread_profiler(); - if (pp != NULL && pp->engaged) { - MutexLockerEx ml(tp->SR_lock(), Mutex::_no_safepoint_check_flag); - if (!tp->is_external_suspend() && !tp->is_exiting()) { - tp->set_external_suspend(); - threadsList[suspendedthreadcount++] = tp; - } - } - } - Threads_lock->unlock(); - } - // Suspend each thread. This call should just return - // for any threads that have already self-suspended - // Net result should be one safepoint - for (int j = 0; j < suspendedthreadcount; j++) { - JavaThread *tp = threadsList[j]; - if (tp) { - tp->java_suspend(); - } - } - - // We are responsible for resuming any thread on this list - for (int i = 0; i < suspendedthreadcount; i++) { - JavaThread *tp = threadsList[i]; - if (tp) { - ThreadProfiler* pp = tp->get_thread_profiler(); - if (pp != NULL && pp->engaged) { - HandleMark hm; - FlatProfiler::delivered_ticks += 1; - if (interval_expired) { - FlatProfiler::interval_record_thread(pp); - } - // This is the place where we check to see if a user thread is - // blocked waiting for compilation. - if (tp->blocked_on_compilation()) { - pp->compiler_ticks += 1; - pp->interval_data_ref()->inc_compiling(); - } else { - pp->record_tick(tp); - } - } - MutexLocker ml(Threads_lock); - tp->java_resume(); - } - } - if (interval_expired) { - FlatProfiler::interval_print(); - FlatProfiler::interval_reset(); - } - - FREE_C_HEAP_ARRAY(JavaThread *, threadsList); - } else { - // Couldn't get the threads lock, just record that rather than blocking - FlatProfiler::threads_lock_ticks += 1; - } - -} - -void FlatProfilerTask::task() { - FlatProfiler::received_ticks += 1; - - if (ProfileVM) { - FlatProfiler::record_vm_tick(); - } - - VM_Operation* op = VMThread::vm_operation(); - if (op != NULL) { - FlatProfiler::record_vm_operation(); - if (SafepointSynchronize::is_at_safepoint()) { - return; - } - } - FlatProfiler::record_thread_ticks(); -} - -void ThreadProfiler::record_interpreted_tick(JavaThread* thread, frame fr, TickPosition where, int* ticks) { - FlatProfiler::all_int_ticks++; - if (!FlatProfiler::full_profile()) { - return; - } - - if (!fr.is_interpreted_frame_valid(thread)) { - // tick came at a bad time - interpreter_ticks += 1; - FlatProfiler::interpreter_ticks += 1; - return; - } - - // The frame has been fully validated so we can trust the method and bci - - Method* method = *fr.interpreter_frame_method_addr(); - - interpreted_update(method, where); - - // update byte code table - InterpreterCodelet* desc = Interpreter::codelet_containing(fr.pc()); - if (desc != NULL && desc->bytecode() >= 0) { - ticks[desc->bytecode()]++; - } -} - -void ThreadProfiler::record_compiled_tick(JavaThread* thread, frame fr, TickPosition where) { - const char *name = NULL; - TickPosition localwhere = where; - - FlatProfiler::all_comp_ticks++; - if (!FlatProfiler::full_profile()) return; - - CodeBlob* cb = fr.cb(); - - // For runtime stubs, record as native rather than as compiled - if (cb->is_runtime_stub()) { - RegisterMap map(thread, false); - fr = fr.sender(&map); - cb = fr.cb(); - localwhere = tp_native; - } - - Method* method = cb->is_compiled() ? cb->as_compiled_method()->method() : (Method*) NULL; - if (method == NULL) { - if (cb->is_runtime_stub()) - runtime_stub_update(cb, name, localwhere); - else - unknown_compiled_update(cb, localwhere); - } - else { - if (method->is_native()) { - stub_update(method, name, localwhere); - } else { - compiled_update(method, localwhere); - } - } -} - -extern "C" void find(int x); - - -void ThreadProfiler::record_tick_for_running_frame(JavaThread* thread, frame fr) { - // The tick happened in real code -> non VM code - if (fr.is_interpreted_frame()) { - interval_data_ref()->inc_interpreted(); - record_interpreted_tick(thread, fr, tp_code, FlatProfiler::bytecode_ticks); - return; - } - - if (CodeCache::contains(fr.pc())) { - interval_data_ref()->inc_compiled(); - PCRecorder::record(fr.pc()); - record_compiled_tick(thread, fr, tp_code); - return; - } - - if (VtableStubs::stub_containing(fr.pc()) != NULL) { - unknown_ticks_array[ut_vtable_stubs] += 1; - return; - } - - frame caller = fr.profile_find_Java_sender_frame(thread); - - if (caller.sp() != NULL && caller.pc() != NULL) { - record_tick_for_calling_frame(thread, caller); - return; - } - - unknown_ticks_array[ut_running_frame] += 1; - FlatProfiler::unknown_ticks += 1; -} - -void ThreadProfiler::record_tick_for_calling_frame(JavaThread* thread, frame fr) { - // The tick happened in VM code - interval_data_ref()->inc_native(); - if (fr.is_interpreted_frame()) { - record_interpreted_tick(thread, fr, tp_native, FlatProfiler::bytecode_ticks_stub); - return; - } - if (CodeCache::contains(fr.pc())) { - record_compiled_tick(thread, fr, tp_native); - return; - } - - frame caller = fr.profile_find_Java_sender_frame(thread); - - if (caller.sp() != NULL && caller.pc() != NULL) { - record_tick_for_calling_frame(thread, caller); - return; - } - - unknown_ticks_array[ut_calling_frame] += 1; - FlatProfiler::unknown_ticks += 1; -} - -void ThreadProfiler::record_tick(JavaThread* thread) { - FlatProfiler::all_ticks++; - thread_ticks += 1; - - // Here's another way to track global state changes. - // When the class loader starts it marks the ThreadProfiler to tell it it is in the class loader - // and we check that here. - // This is more direct, and more than one thread can be in the class loader at a time, - // but it does mean the class loader has to know about the profiler. - if (region_flag[ThreadProfilerMark::classLoaderRegion]) { - class_loader_ticks += 1; - FlatProfiler::class_loader_ticks += 1; - return; - } else if (region_flag[ThreadProfilerMark::extraRegion]) { - extra_ticks += 1; - FlatProfiler::extra_ticks += 1; - return; - } - // Note that the WatcherThread can now stop for safepoints - uint32_t debug_bits = 0; - if (!thread->wait_for_ext_suspend_completion(SuspendRetryCount, - SuspendRetryDelay, &debug_bits)) { - unknown_ticks_array[ut_unknown_thread_state] += 1; - FlatProfiler::unknown_ticks += 1; - return; - } - - frame fr; - - switch (thread->thread_state()) { - case _thread_in_native: - case _thread_in_native_trans: - case _thread_in_vm: - case _thread_in_vm_trans: - if (thread->profile_last_Java_frame(&fr)) { - if (fr.is_runtime_frame()) { - RegisterMap map(thread, false); - fr = fr.sender(&map); - } - record_tick_for_calling_frame(thread, fr); - } else { - unknown_ticks_array[ut_no_last_Java_frame] += 1; - FlatProfiler::unknown_ticks += 1; - } - break; - // handle_special_runtime_exit_condition self-suspends threads in Java - case _thread_in_Java: - case _thread_in_Java_trans: - if (thread->profile_last_Java_frame(&fr)) { - if (fr.is_safepoint_blob_frame()) { - RegisterMap map(thread, false); - fr = fr.sender(&map); - } - record_tick_for_running_frame(thread, fr); - } else { - unknown_ticks_array[ut_no_last_Java_frame] += 1; - FlatProfiler::unknown_ticks += 1; - } - break; - case _thread_blocked: - case _thread_blocked_trans: - if (thread->osthread() && thread->osthread()->get_state() == RUNNABLE) { - if (thread->profile_last_Java_frame(&fr)) { - if (fr.is_safepoint_blob_frame()) { - RegisterMap map(thread, false); - fr = fr.sender(&map); - record_tick_for_running_frame(thread, fr); - } else { - record_tick_for_calling_frame(thread, fr); - } - } else { - unknown_ticks_array[ut_no_last_Java_frame] += 1; - FlatProfiler::unknown_ticks += 1; - } - } else { - blocked_ticks += 1; - FlatProfiler::blocked_ticks += 1; - } - break; - case _thread_uninitialized: - case _thread_new: - // not used, included for completeness - case _thread_new_trans: - unknown_ticks_array[ut_no_last_Java_frame] += 1; - FlatProfiler::unknown_ticks += 1; - break; - default: - unknown_ticks_array[ut_unknown_thread_state] += 1; - FlatProfiler::unknown_ticks += 1; - break; - } - return; -} - -void ThreadProfiler::engage() { - engaged = true; - timer.start(); -} - -void ThreadProfiler::disengage() { - engaged = false; - timer.stop(); -} - -void ThreadProfiler::initialize() { - for (int index = 0; index < table_size; index++) { - table[index] = NULL; - } - thread_ticks = 0; - blocked_ticks = 0; - compiler_ticks = 0; - interpreter_ticks = 0; - for (int ut = 0; ut < ut_end; ut += 1) { - unknown_ticks_array[ut] = 0; - } - region_flag[ThreadProfilerMark::classLoaderRegion] = false; - class_loader_ticks = 0; - region_flag[ThreadProfilerMark::extraRegion] = false; - extra_ticks = 0; - timer.start(); - interval_data_ref()->reset(); -} - -void ThreadProfiler::reset() { - timer.stop(); - if (table != NULL) { - for (int index = 0; index < table_size; index++) { - ProfilerNode* n = table[index]; - if (n != NULL) { - delete n; - } - } - } - initialize(); -} - -void FlatProfiler::allocate_table() { - { // Bytecode table - bytecode_ticks = NEW_C_HEAP_ARRAY(int, Bytecodes::number_of_codes, mtInternal); - bytecode_ticks_stub = NEW_C_HEAP_ARRAY(int, Bytecodes::number_of_codes, mtInternal); - for(int index = 0; index < Bytecodes::number_of_codes; index++) { - bytecode_ticks[index] = 0; - bytecode_ticks_stub[index] = 0; - } - } - - if (ProfilerRecordPC) PCRecorder::init(); - - interval_data = NEW_C_HEAP_ARRAY(IntervalData, interval_print_size, mtInternal); - FlatProfiler::interval_reset(); -} - -void FlatProfiler::engage(JavaThread* mainThread, bool fullProfile) { - full_profile_flag = fullProfile; - if (bytecode_ticks == NULL) { - allocate_table(); - } - if(ProfileVM && (vm_thread_profiler == NULL)){ - vm_thread_profiler = new ThreadProfiler(); - } - if (task == NULL) { - task = new FlatProfilerTask(WatcherThread::delay_interval); - task->enroll(); - } - timer.start(); - if (mainThread != NULL) { - // When mainThread was created, it might not have a ThreadProfiler - ThreadProfiler* pp = mainThread->get_thread_profiler(); - if (pp == NULL) { - mainThread->set_thread_profiler(new ThreadProfiler()); - } else { - pp->reset(); - } - mainThread->get_thread_profiler()->engage(); - } - // This is where we would assign thread_profiler - // if we wanted only one thread_profiler for all threads. - thread_profiler = NULL; -} - -void FlatProfiler::disengage() { - if (!task) { - return; - } - timer.stop(); - task->disenroll(); - delete task; - task = NULL; - if (thread_profiler != NULL) { - thread_profiler->disengage(); - } else { - MutexLocker tl(Threads_lock); - for (JavaThread* tp = Threads::first(); tp != NULL; tp = tp->next()) { - ThreadProfiler* pp = tp->get_thread_profiler(); - if (pp != NULL) { - pp->disengage(); - } - } - } -} - -void FlatProfiler::reset() { - if (task) { - disengage(); - } - - class_loader_ticks = 0; - extra_ticks = 0; - received_gc_ticks = 0; - vm_operation_ticks = 0; - compiler_ticks = 0; - deopt_ticks = 0; - interpreter_ticks = 0; - blocked_ticks = 0; - unknown_ticks = 0; - received_ticks = 0; - delivered_ticks = 0; - timer.stop(); -} - -bool FlatProfiler::is_active() { - return task != NULL; -} - -void FlatProfiler::print_byte_code_statistics() { - GrowableArray * array = new GrowableArray(200); - - tty->print_cr(" Bytecode ticks:"); - for (int index = 0; index < Bytecodes::number_of_codes; index++) { - if (FlatProfiler::bytecode_ticks[index] > 0 || FlatProfiler::bytecode_ticks_stub[index] > 0) { - tty->print_cr(" %4d %4d = %s", - FlatProfiler::bytecode_ticks[index], - FlatProfiler::bytecode_ticks_stub[index], - Bytecodes::name( (Bytecodes::Code) index)); - } - } - tty->cr(); -} - -void print_ticks(const char* title, int ticks, int total) { - if (ticks > 0) { - tty->print("%5.1f%% %5d", ticks * 100.0 / total, ticks); - tty->fill_to(col3); - tty->print("%s", title); - tty->cr(); - } -} - -void ThreadProfiler::print(const char* thread_name) { - ResourceMark rm; - MutexLocker ppl(ProfilePrint_lock); - int index = 0; // Declared outside for loops for portability - - if (table == NULL) { - return; - } - - if (thread_ticks <= 0) { - return; - } - - const char* title = "too soon to tell"; - double secs = timer.seconds(); - - GrowableArray * array = new GrowableArray(200); - for(index = 0; index < table_size; index++) { - for(ProfilerNode* node = table[index]; node; node = node->next()) - array->append(node); - } - - array->sort(&ProfilerNode::compare); - - // compute total (sanity check) - int active = - class_loader_ticks + - compiler_ticks + - interpreter_ticks + - unknown_ticks(); - for (index = 0; index < array->length(); index++) { - active += array->at(index)->ticks.total(); - } - int total = active + blocked_ticks; - - tty->cr(); - tty->print_cr("Flat profile of %3.2f secs (%d total ticks): %s", secs, total, thread_name); - if (total != thread_ticks) { - print_ticks("Lost ticks", thread_ticks-total, thread_ticks); - } - tty->cr(); - - // print interpreted methods - tick_counter interpreted_ticks; - bool has_interpreted_ticks = false; - int print_count = 0; - for (index = 0; index < array->length(); index++) { - ProfilerNode* n = array->at(index); - if (n->is_interpreted()) { - interpreted_ticks.add(&n->ticks); - if (!has_interpreted_ticks) { - interpretedNode::print_title(tty); - has_interpreted_ticks = true; - } - if (print_count++ < ProfilerNumberOfInterpretedMethods) { - n->print(tty, active); - } - } - } - if (has_interpreted_ticks) { - if (print_count <= ProfilerNumberOfInterpretedMethods) { - title = "Total interpreted"; - } else { - title = "Total interpreted (including elided)"; - } - interpretedNode::print_total(tty, &interpreted_ticks, active, title); - tty->cr(); - } - - // print compiled methods - tick_counter compiled_ticks; - bool has_compiled_ticks = false; - print_count = 0; - for (index = 0; index < array->length(); index++) { - ProfilerNode* n = array->at(index); - if (n->is_compiled()) { - compiled_ticks.add(&n->ticks); - if (!has_compiled_ticks) { - compiledNode::print_title(tty); - has_compiled_ticks = true; - } - if (print_count++ < ProfilerNumberOfCompiledMethods) { - n->print(tty, active); - } - } - } - if (has_compiled_ticks) { - if (print_count <= ProfilerNumberOfCompiledMethods) { - title = "Total compiled"; - } else { - title = "Total compiled (including elided)"; - } - compiledNode::print_total(tty, &compiled_ticks, active, title); - tty->cr(); - } - - // print stub methods - tick_counter stub_ticks; - bool has_stub_ticks = false; - print_count = 0; - for (index = 0; index < array->length(); index++) { - ProfilerNode* n = array->at(index); - if (n->is_stub()) { - stub_ticks.add(&n->ticks); - if (!has_stub_ticks) { - stubNode::print_title(tty); - has_stub_ticks = true; - } - if (print_count++ < ProfilerNumberOfStubMethods) { - n->print(tty, active); - } - } - } - if (has_stub_ticks) { - if (print_count <= ProfilerNumberOfStubMethods) { - title = "Total stub"; - } else { - title = "Total stub (including elided)"; - } - stubNode::print_total(tty, &stub_ticks, active, title); - tty->cr(); - } - - // print runtime stubs - tick_counter runtime_stub_ticks; - bool has_runtime_stub_ticks = false; - print_count = 0; - for (index = 0; index < array->length(); index++) { - ProfilerNode* n = array->at(index); - if (n->is_runtime_stub()) { - runtime_stub_ticks.add(&n->ticks); - if (!has_runtime_stub_ticks) { - runtimeStubNode::print_title(tty); - has_runtime_stub_ticks = true; - } - if (print_count++ < ProfilerNumberOfRuntimeStubNodes) { - n->print(tty, active); - } - } - } - if (has_runtime_stub_ticks) { - if (print_count <= ProfilerNumberOfRuntimeStubNodes) { - title = "Total runtime stubs"; - } else { - title = "Total runtime stubs (including elided)"; - } - runtimeStubNode::print_total(tty, &runtime_stub_ticks, active, title); - tty->cr(); - } - - if (blocked_ticks + class_loader_ticks + interpreter_ticks + compiler_ticks + unknown_ticks() != 0) { - tty->fill_to(col1); - tty->print_cr("Thread-local ticks:"); - print_ticks("Blocked (of total)", blocked_ticks, total); - print_ticks("Class loader", class_loader_ticks, active); - print_ticks("Extra", extra_ticks, active); - print_ticks("Interpreter", interpreter_ticks, active); - print_ticks("Compilation", compiler_ticks, active); - print_ticks("Unknown: vtable stubs", unknown_ticks_array[ut_vtable_stubs], active); - print_ticks("Unknown: null method", unknown_ticks_array[ut_null_method], active); - print_ticks("Unknown: running frame", unknown_ticks_array[ut_running_frame], active); - print_ticks("Unknown: calling frame", unknown_ticks_array[ut_calling_frame], active); - print_ticks("Unknown: no pc", unknown_ticks_array[ut_no_pc], active); - print_ticks("Unknown: no last frame", unknown_ticks_array[ut_no_last_Java_frame], active); - print_ticks("Unknown: thread_state", unknown_ticks_array[ut_unknown_thread_state], active); - tty->cr(); - } - - if (WizardMode) { - tty->print_cr("Node area used: " INTX_FORMAT " Kb", (area_top - area_bottom) / 1024); - } - reset(); -} - -/* -ThreadProfiler::print_unknown(){ - if (table == NULL) { - return; - } - - if (thread_ticks <= 0) { - return; - } -} */ - -void FlatProfiler::print(int unused) { - ResourceMark rm; - if (thread_profiler != NULL) { - thread_profiler->print("All threads"); - } else { - MutexLocker tl(Threads_lock); - for (JavaThread* tp = Threads::first(); tp != NULL; tp = tp->next()) { - ThreadProfiler* pp = tp->get_thread_profiler(); - if (pp != NULL) { - pp->print(tp->get_thread_name()); - } - } - } - - if (ProfilerPrintByteCodeStatistics) { - print_byte_code_statistics(); - } - - if (non_method_ticks() > 0) { - tty->cr(); - tty->print_cr("Global summary of %3.2f seconds:", timer.seconds()); - print_ticks("Received ticks", received_ticks, received_ticks); - print_ticks("Received GC ticks", received_gc_ticks, received_ticks); - print_ticks("Compilation", compiler_ticks, received_ticks); - print_ticks("Deoptimization", deopt_ticks, received_ticks); - print_ticks("Other VM operations", vm_operation_ticks, received_ticks); -#ifndef PRODUCT - print_ticks("Blocked ticks", blocked_ticks, received_ticks); - print_ticks("Threads_lock blocks", threads_lock_ticks, received_ticks); - print_ticks("Delivered ticks", delivered_ticks, received_ticks); - print_ticks("All ticks", all_ticks, received_ticks); -#endif - print_ticks("Class loader", class_loader_ticks, received_ticks); - print_ticks("Extra ", extra_ticks, received_ticks); - print_ticks("Interpreter", interpreter_ticks, received_ticks); - print_ticks("Unknown code", unknown_ticks, received_ticks); - } - - PCRecorder::print(); - - if(ProfileVM){ - tty->cr(); - vm_thread_profiler->print("VM Thread"); - } -} - -void IntervalData::print_header(outputStream* st) { - st->print("i/c/n/g"); -} - -void IntervalData::print_data(outputStream* st) { - st->print("%d/%d/%d/%d", interpreted(), compiled(), native(), compiling()); -} - -void FlatProfiler::interval_record_thread(ThreadProfiler* tp) { - IntervalData id = tp->interval_data(); - int total = id.total(); - tp->interval_data_ref()->reset(); - - // Insertion sort the data, if it's relevant. - for (int i = 0; i < interval_print_size; i += 1) { - if (total > interval_data[i].total()) { - for (int j = interval_print_size - 1; j > i; j -= 1) { - interval_data[j] = interval_data[j-1]; - } - interval_data[i] = id; - break; - } - } -} - -void FlatProfiler::interval_print() { - if ((interval_data[0].total() > 0)) { - tty->stamp(); - tty->print("\t"); - IntervalData::print_header(tty); - for (int i = 0; i < interval_print_size; i += 1) { - if (interval_data[i].total() > 0) { - tty->print("\t"); - interval_data[i].print_data(tty); - } - } - tty->cr(); - } -} - -void FlatProfiler::interval_reset() { - for (int i = 0; i < interval_print_size; i += 1) { - interval_data[i].reset(); - } -} - -void ThreadProfiler::oops_do(OopClosure* f) { - if (table == NULL) return; - - for(int index = 0; index < table_size; index++) { - for(ProfilerNode* node = table[index]; node; node = node->next()) - node->oops_do(f); - } -} - -void FlatProfiler::oops_do(OopClosure* f) { - if (thread_profiler != NULL) { - thread_profiler->oops_do(f); - } else { - for (JavaThread* tp = Threads::first(); tp != NULL; tp = tp->next()) { - ThreadProfiler* pp = tp->get_thread_profiler(); - if (pp != NULL) { - pp->oops_do(f); - } - } - } -} diff --git a/hotspot/src/share/vm/runtime/fprofiler.hpp b/hotspot/src/share/vm/runtime/fprofiler.hpp deleted file mode 100644 index 18f3e5cfb6d..00000000000 --- a/hotspot/src/share/vm/runtime/fprofiler.hpp +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright (c) 1997, 2013, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_RUNTIME_FPROFILER_HPP -#define SHARE_VM_RUNTIME_FPROFILER_HPP - -#include "utilities/macros.hpp" -#include "runtime/timer.hpp" - -// a simple flat profiler for Java - - -// Forward declaration of classes defined in this header file -class ThreadProfiler; -class ThreadProfilerMark; -class FlatProfiler; -class IntervalData; - -// Declarations of classes defined only in the implementation. -class ProfilerNode; -class FlatProfilerTask; - -enum TickPosition { - tp_code, - tp_native -}; - -// One of these guys is constructed as we enter interesting regions -// and destructed as we exit the region. While we are in the region -// ticks are allotted to the region. -class ThreadProfilerMark: public StackObj { -public: - // For now, the only thread-specific region is the class loader. - enum Region { noRegion, classLoaderRegion, extraRegion, maxRegion }; - - ThreadProfilerMark(Region) NOT_FPROF_RETURN; - ~ThreadProfilerMark() NOT_FPROF_RETURN; - -private: - ThreadProfiler* _pp; - Region _r; -}; - -#if INCLUDE_FPROF - -class IntervalData VALUE_OBJ_CLASS_SPEC { - // Just to keep these things all together -private: - int _interpreted; - int _compiled; - int _native; - int _compiling; -public: - int interpreted() { - return _interpreted; - } - int compiled() { - return _compiled; - } - int native() { - return _native; - } - int compiling() { - return _compiling; - } - int total() { - return (interpreted() + compiled() + native() + compiling()); - } - void inc_interpreted() { - _interpreted += 1; - } - void inc_compiled() { - _compiled += 1; - } - void inc_native() { - _native += 1; - } - void inc_compiling() { - _compiling += 1; - } - void reset() { - _interpreted = 0; - _compiled = 0; - _native = 0; - _compiling = 0; - } - static void print_header(outputStream* st); - void print_data(outputStream* st); -}; -#endif // INCLUDE_FPROF - -class ThreadProfiler: public CHeapObj { -public: - ThreadProfiler() NOT_FPROF_RETURN; - ~ThreadProfiler() NOT_FPROF_RETURN; - - // Resets the profiler - void reset() NOT_FPROF_RETURN; - - // Activates the profiler for a certain thread - void engage() NOT_FPROF_RETURN; - - // Deactivates the profiler - void disengage() NOT_FPROF_RETURN; - - // Prints the collected profiling information - void print(const char* thread_name) NOT_FPROF_RETURN; - - // Garbage Collection Support - void oops_do(OopClosure* f) NOT_FPROF_RETURN; - -#if INCLUDE_FPROF -private: - // for recording ticks. - friend class ProfilerNode; - char* area_bottom; // preallocated area for pnodes - char* area_top; - char* area_limit; - static int table_size; - ProfilerNode** table; - -private: - void record_interpreted_tick(JavaThread* thread, frame fr, TickPosition where, int* ticks); - void record_compiled_tick (JavaThread* thread, frame fr, TickPosition where); - void interpreted_update(Method* method, TickPosition where); - void compiled_update (Method* method, TickPosition where); - void stub_update (Method* method, const char* name, TickPosition where); - void adapter_update (TickPosition where); - - void runtime_stub_update(const CodeBlob* stub, const char* name, TickPosition where); - void unknown_compiled_update (const CodeBlob* cb, TickPosition where); - - void vm_update (TickPosition where); - void vm_update (const char* name, TickPosition where); - - void record_tick_for_running_frame(JavaThread* thread, frame fr); - void record_tick_for_calling_frame(JavaThread* thread, frame fr); - - void initialize(); - - static int entry(int value); - - -private: - friend class FlatProfiler; - void record_tick(JavaThread* thread); - bool engaged; - // so we can do percentages for this thread, and quick checks for activity - int thread_ticks; - int compiler_ticks; - int interpreter_ticks; - -public: - void inc_thread_ticks() { thread_ticks += 1; } - -private: - friend class ThreadProfilerMark; - // counters for thread-specific regions - bool region_flag[ThreadProfilerMark::maxRegion]; - int class_loader_ticks; - int extra_ticks; - -private: - // other thread-specific regions - int blocked_ticks; - enum UnknownTickSites { - ut_null_method, - ut_vtable_stubs, - ut_running_frame, - ut_calling_frame, - ut_no_pc, - ut_no_last_Java_frame, - ut_unknown_thread_state, - ut_end - }; - int unknown_ticks_array[ut_end]; - int unknown_ticks() { - int result = 0; - for (int ut = 0; ut < ut_end; ut += 1) { - result += unknown_ticks_array[ut]; - } - return result; - } - - elapsedTimer timer; - - // For interval timing -private: - IntervalData _interval_data; - IntervalData interval_data() { - return _interval_data; - } - IntervalData* interval_data_ref() { - return &_interval_data; - } -#endif // INCLUDE_FPROF -}; - -class FlatProfiler: AllStatic { -public: - static void reset() NOT_FPROF_RETURN ; - static void engage(JavaThread* mainThread, bool fullProfile) NOT_FPROF_RETURN ; - static void disengage() NOT_FPROF_RETURN ; - static void print(int unused) NOT_FPROF_RETURN ; - static bool is_active() NOT_FPROF_RETURN_(false) ; - - // This is NULL if each thread has its own thread profiler, - // else this is the single thread profiler used by all threads. - // In particular it makes a difference during garbage collection, - // where you only want to traverse each thread profiler once. - static ThreadProfiler* get_thread_profiler() NOT_FPROF_RETURN_(NULL); - - // Garbage Collection Support - static void oops_do(OopClosure* f) NOT_FPROF_RETURN ; - - // Support for disassembler to inspect the PCRecorder - - // Returns the start address for a given pc - // NULL is returned if the PCRecorder is inactive - static address bucket_start_for(address pc) NOT_FPROF_RETURN_(NULL); - - enum { MillisecsPerTick = 10 }; // ms per profiling ticks - - // Returns the number of ticks recorded for the bucket - // pc belongs to. - static int bucket_count_for(address pc) NOT_FPROF_RETURN_(0); - -#if INCLUDE_FPROF - - private: - static bool full_profile() { - return full_profile_flag; - } - - friend class ThreadProfiler; - // the following group of ticks cover everything that's not attributed to individual Java methods - static int received_gc_ticks; // ticks during which gc was active - static int vm_operation_ticks; // total ticks in vm_operations other than GC - static int threads_lock_ticks; // the number of times we couldn't get the Threads_lock without blocking - static int blocked_ticks; // ticks when the thread was blocked. - static int class_loader_ticks; // total ticks in class loader - static int extra_ticks; // total ticks an extra temporary measuring - static int compiler_ticks; // total ticks in compilation - static int interpreter_ticks; // ticks in unknown interpreted method - static int deopt_ticks; // ticks in deoptimization - static int unknown_ticks; // ticks that cannot be categorized - static int received_ticks; // ticks that were received by task - static int delivered_ticks; // ticks that were delivered by task - static int non_method_ticks() { - return - ( received_gc_ticks - + vm_operation_ticks - + deopt_ticks - + threads_lock_ticks - + blocked_ticks - + compiler_ticks - + interpreter_ticks - + unknown_ticks ); - } - static elapsedTimer timer; - - // Counts of each of the byte codes - static int* bytecode_ticks; - static int* bytecode_ticks_stub; - static void print_byte_code_statistics(); - - // the ticks below are for continuous profiling (to adjust recompilation, etc.) - static int all_ticks; // total count of ticks received so far - static int all_int_ticks; // ticks in interpreter - static int all_comp_ticks; // ticks in compiled code (+ native) - static bool full_profile_flag; // collecting full profile? - - // to accumulate thread-specific data - // if we aren't profiling individual threads. - static ThreadProfiler* thread_profiler; - static ThreadProfiler* vm_thread_profiler; - - static void allocate_table(); - - // The task that periodically interrupts things. - friend class FlatProfilerTask; - static FlatProfilerTask* task; - static void record_vm_operation(); - static void record_vm_tick(); - static void record_thread_ticks(); - - // For interval analysis - private: - static int interval_ticks_previous; // delivered_ticks from the last interval - static void interval_record_thread(ThreadProfiler* tp); // extract ticks from ThreadProfiler. - static void interval_print(); // print interval data. - static void interval_reset(); // reset interval data. - enum {interval_print_size = 10}; - static IntervalData* interval_data; -#endif // INCLUDE_FPROF -}; - -#endif // SHARE_VM_RUNTIME_FPROFILER_HPP diff --git a/hotspot/src/share/vm/runtime/java.cpp b/hotspot/src/share/vm/runtime/java.cpp index 6b362a81078..16957fd3919 100644 --- a/hotspot/src/share/vm/runtime/java.cpp +++ b/hotspot/src/share/vm/runtime/java.cpp @@ -55,7 +55,6 @@ #include "runtime/biasedLocking.hpp" #include "runtime/compilationPolicy.hpp" #include "runtime/deoptimization.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/init.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/java.hpp" @@ -465,12 +464,6 @@ void before_exit(JavaThread* thread) { WatcherThread::stop(); } - // Print statistics gathered (profiling ...) - if (Arguments::has_profile()) { - FlatProfiler::disengage(); - FlatProfiler::print(10); - } - // shut down the StatSampler task StatSampler::disengage(); StatSampler::destroy(); diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index 2e11c1f6059..d5fbca9192d 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -476,7 +476,6 @@ class os: AllStatic { static frame fetch_frame_from_context(const void* ucVoid); static frame fetch_frame_from_ucontext(Thread* thread, void* ucVoid); - static ExtendedPC get_thread_pc(Thread *thread); static void breakpoint(); static bool start_debugging(char *buf, int buflen); diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index cbcc91c4180..b1e7da21c7f 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -63,7 +63,6 @@ #include "runtime/commandLineFlagWriteableList.hpp" #include "runtime/commandLineFlagRangeList.hpp" #include "runtime/deoptimization.hpp" -#include "runtime/fprofiler.hpp" #include "runtime/frame.inline.hpp" #include "runtime/globals.hpp" #include "runtime/init.hpp" @@ -748,19 +747,6 @@ void JavaThread::record_jump(address target, address instr, const char* file, } #endif // PRODUCT -// Called by flat profiler -// Callers have already called wait_for_ext_suspend_completion -// The assertion for that is currently too complex to put here: -bool JavaThread::profile_last_Java_frame(frame* _fr) { - bool gotframe = false; - // self suspension saves needed state. - if (has_last_Java_frame() && _anchor.walkable()) { - *_fr = pd_last_frame(); - gotframe = true; - } - return gotframe; -} - void Thread::interrupt(Thread* thread) { debug_only(check_for_dangling_thread_pointer(thread);) os::interrupt(thread); @@ -1381,14 +1367,6 @@ void WatcherThread::stop() { while (watcher_thread() != NULL) { // This wait should make safepoint checks, wait without a timeout, // and wait as a suspend-equivalent condition. - // - // Note: If the FlatProfiler is running, then this thread is waiting - // for the WatcherThread to terminate and the WatcherThread, via the - // FlatProfiler task, is waiting for the external suspend request on - // this thread to complete. wait_for_ext_suspend_completion() will - // eventually timeout, but that takes time. Making this wait a - // suspend-equivalent condition solves that timeout problem. - // Terminator_lock->wait(!Mutex::_no_safepoint_check_flag, 0, Mutex::_as_suspend_equivalent_flag); } @@ -1505,16 +1483,6 @@ void JavaThread::initialize() { } #endif // PRODUCT - set_thread_profiler(NULL); - if (FlatProfiler::is_active()) { - // This is where we would decide to either give each thread it's own profiler - // or use one global one from FlatProfiler, - // or up to some count of the number of profiled threads, etc. - ThreadProfiler* pp = new ThreadProfiler(); - pp->engage(); - set_thread_profiler(pp); - } - // Setup safepoint state info for this thread ThreadSafepointState::create(this); @@ -1660,7 +1628,6 @@ JavaThread::~JavaThread() { // All Java related clean up happens in exit ThreadSafepointState::destroy(this); - if (_thread_profiler != NULL) delete _thread_profiler; if (_thread_stat != NULL) delete _thread_stat; #if INCLUDE_JVMCI @@ -1775,13 +1742,6 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) { Handle threadObj(this, this->threadObj()); assert(threadObj.not_null(), "Java thread object should be created"); - if (get_thread_profiler() != NULL) { - get_thread_profiler()->disengage(); - ResourceMark rm; - get_thread_profiler()->print(get_thread_name()); - } - - // FIXIT: This code should be moved into else part, when reliable 1.2/1.3 check is in place { EXCEPTION_MARK; @@ -1983,12 +1943,6 @@ void JavaThread::initialize_queues() { #endif // INCLUDE_ALL_GCS void JavaThread::cleanup_failed_attach_current_thread() { - if (get_thread_profiler() != NULL) { - get_thread_profiler()->disengage(); - ResourceMark rm; - get_thread_profiler()->print(get_thread_name()); - } - if (active_handles() != NULL) { JNIHandleBlock* block = active_handles(); set_active_handles(NULL); @@ -2786,9 +2740,6 @@ void JavaThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { // Verify that the deferred card marks have been flushed. assert(deferred_card_mark().is_empty(), "Should be empty during GC"); - // The ThreadProfiler oops_do is done from FlatProfiler::oops_do - // since there may be more than one thread using each ThreadProfiler. - // Traverse the GCHandles Thread::oops_do(f, cf); @@ -3841,7 +3792,6 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { } #endif // INCLUDE_MANAGEMENT - if (Arguments::has_profile()) FlatProfiler::engage(main_thread, true); if (MemProfiling) MemProfiler::engage(); StatSampler::engage(); if (CheckJNICalls) JniPeriodicChecker::engage(); @@ -4136,7 +4086,7 @@ void JavaThread::invoke_shutdown_hooks() { // + Call before_exit(), prepare for VM exit // > run VM level shutdown hooks (they are registered through JVM_OnExit(), // currently the only user of this mechanism is File.deleteOnExit()) -// > stop flat profiler, StatSampler, watcher thread, CMS threads, +// > stop StatSampler, watcher thread, CMS threads, // post thread end and vm death events to JVMTI, // stop signal thread // + Call JavaThread::exit(), it will: @@ -4165,14 +4115,6 @@ bool Threads::destroy_vm() { while (Threads::number_of_non_daemon_threads() > 1) // This wait should make safepoint checks, wait without a timeout, // and wait as a suspend-equivalent condition. - // - // Note: If the FlatProfiler is running and this thread is waiting - // for another non-daemon thread to finish, then the FlatProfiler - // is waiting for the external suspend request on this thread to - // complete. wait_for_ext_suspend_completion() will eventually - // timeout, but that takes time. Making this wait a suspend- - // equivalent condition solves that timeout problem. - // Threads_lock->wait(!Mutex::_no_safepoint_check_flag, 0, Mutex::_as_suspend_equivalent_flag); } diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index 60ed6161c81..bb4483589c1 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -56,7 +56,6 @@ #endif class ThreadSafepointState; -class ThreadProfiler; class JvmtiThreadState; class JvmtiGetLoadedClassesClosure; @@ -1720,23 +1719,6 @@ class JavaThread: public Thread { void deoptimized_wrt_marked_nmethods(); - // Profiling operation (see fprofile.cpp) - public: - bool profile_last_Java_frame(frame* fr); - - private: - ThreadProfiler* _thread_profiler; - private: - friend class FlatProfiler; // uses both [gs]et_thread_profiler. - friend class FlatProfilerTask; // uses get_thread_profiler. - friend class ThreadProfilerMark; // uses get_thread_profiler. - ThreadProfiler* get_thread_profiler() { return _thread_profiler; } - ThreadProfiler* set_thread_profiler(ThreadProfiler* tp) { - ThreadProfiler* result = _thread_profiler; - _thread_profiler = tp; - return result; - } - public: // Returns the running thread as a JavaThread static inline JavaThread* current(); diff --git a/hotspot/src/share/vm/utilities/macros.hpp b/hotspot/src/share/vm/utilities/macros.hpp index 34afe750710..ce284a868c6 100644 --- a/hotspot/src/share/vm/utilities/macros.hpp +++ b/hotspot/src/share/vm/utilities/macros.hpp @@ -65,18 +65,6 @@ #define NOT_JVMTI_RETURN_(code) { return code; } #endif // INCLUDE_JVMTI -#ifndef INCLUDE_FPROF -#define INCLUDE_FPROF 1 -#endif - -#if INCLUDE_FPROF -#define NOT_FPROF_RETURN /* next token must be ; */ -#define NOT_FPROF_RETURN_(code) /* next token must be ; */ -#else -#define NOT_FPROF_RETURN {} -#define NOT_FPROF_RETURN_(code) { return code; } -#endif // INCLUDE_FPROF - #ifndef INCLUDE_VM_STRUCTS #define INCLUDE_VM_STRUCTS 1 #endif diff --git a/hotspot/test/gc/g1/TestGCLogMessages.java b/hotspot/test/gc/g1/TestGCLogMessages.java index 25b5d5696de..1f9029acf4b 100644 --- a/hotspot/test/gc/g1/TestGCLogMessages.java +++ b/hotspot/test/gc/g1/TestGCLogMessages.java @@ -110,7 +110,6 @@ public class TestGCLogMessages { new LogMessageWithLevel("Universe Roots", Level.TRACE), new LogMessageWithLevel("JNI Handles Roots", Level.TRACE), new LogMessageWithLevel("ObjectSynchronizer Roots", Level.TRACE), - new LogMessageWithLevel("FlatProfiler Roots", Level.TRACE), new LogMessageWithLevel("Management Roots", Level.TRACE), new LogMessageWithLevel("SystemDictionary Roots", Level.TRACE), new LogMessageWithLevel("CLDG Roots", Level.TRACE), diff --git a/hotspot/test/runtime/CommandLine/TestNullTerminatedFlags.java b/hotspot/test/runtime/CommandLine/TestNullTerminatedFlags.java index 007b507a2e4..2edda1fac12 100644 --- a/hotspot/test/runtime/CommandLine/TestNullTerminatedFlags.java +++ b/hotspot/test/runtime/CommandLine/TestNullTerminatedFlags.java @@ -42,7 +42,6 @@ public class TestNullTerminatedFlags { "-green", "-native", "-Xrs", - "-Xprof", "-Xconcurrentio", "-Xinternalversion", "-Xprintflags", diff --git a/hotspot/test/runtime/MinimalVM/Xprof.java b/hotspot/test/runtime/MinimalVM/Xprof.java deleted file mode 100644 index dd3e337cc66..00000000000 --- a/hotspot/test/runtime/MinimalVM/Xprof.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2016, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @requires vm.flavor == "minimal" - * @modules java.base/jdk.internal.misc - * @library /test/lib - * @run driver Xprof - */ - -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.process.ProcessTools; - -public class Xprof { - - public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-minimal", "-Xprof", "-version"); - new OutputAnalyzer(pb.start()) - .shouldContain("Flat profiling is not supported in this VM.") - .shouldHaveExitValue(1); - - } -} From 73320590894ac584e5615f23edd498115dc73c46 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Thu, 31 Aug 2017 21:31:51 -0700 Subject: [PATCH 78/98] 8061228: Allow JDWP socket connector to accept connections from certain ip addresses only Introduce new parameter for JDWP agent, that allows to restrict connection to certain ip addresses only Reviewed-by: dcubed, clanger, rehn, sspitsyn --- .../share/native/include/jdwpTransport.h | 19 +- .../native/libdt_socket/socketTransport.c | 227 ++++++++++++++++-- .../share/native/libjdwp/debugInit.c | 23 +- .../share/native/libjdwp/transport.c | 127 +++++++--- .../share/native/libjdwp/transport.h | 5 +- .../com/sun/jdi/BasicJDWPConnectionTest.java | 200 +++++++++++++++ 6 files changed, 547 insertions(+), 54 deletions(-) create mode 100644 jdk/test/com/sun/jdi/BasicJDWPConnectionTest.java diff --git a/jdk/src/jdk.jdwp.agent/share/native/include/jdwpTransport.h b/jdk/src/jdk.jdwp.agent/share/native/include/jdwpTransport.h index 32ccdeae87f..80f023f2b1b 100644 --- a/jdk/src/jdk.jdwp.agent/share/native/include/jdwpTransport.h +++ b/jdk/src/jdk.jdwp.agent/share/native/include/jdwpTransport.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -33,7 +33,8 @@ #include "jni.h" enum { - JDWPTRANSPORT_VERSION_1_0 = 0x00010000 + JDWPTRANSPORT_VERSION_1_0 = 0x00010000, + JDWPTRANSPORT_VERSION_1_1 = 0x00010001 }; #ifdef __cplusplus @@ -142,6 +143,13 @@ typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm, jint version, jdwpTransportEnv** env); +/* + * JDWP transport configuration from the agent. + */ +typedef struct jdwpTransportConfiguration { + /* Field added in JDWPTRANSPORT_VERSION_1_1: */ + const char* allowed_peers; /* Peers allowed for connection */ +} jdwpTransportConfiguration; /* Function Interface */ @@ -191,6 +199,9 @@ struct jdwpTransportNativeInterface_ { jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env, char** error); + /* 12: SetTransportConfiguration added in JDWPTRANSPORT_VERSION_1_1 */ + jdwpTransportError (JNICALL *SetTransportConfiguration)(jdwpTransportEnv* env, + jdwpTransportConfiguration *config); }; @@ -248,6 +259,10 @@ struct _jdwpTransportEnv { return functions->GetLastError(this, error); } + /* SetTransportConfiguration added in JDWPTRANSPORT_VERSION_1_1 */ + jdwpTransportError SetTransportConfiguration(jdwpTransportEnv* env, + return functions->SetTransportConfiguration(this, config); + } #endif /* __cplusplus */ }; diff --git a/jdk/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c b/jdk/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c index 97eecb3737c..ca179895557 100644 --- a/jdk/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c +++ b/jdk/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c @@ -34,6 +34,9 @@ #ifdef _WIN32 #include #include +#else + #include + #include #endif /* @@ -73,6 +76,19 @@ static jdwpTransportEnv single_env = (jdwpTransportEnv)&interface; static jint recv_fully(int, char *, int); static jint send_fully(int, char *, int); +/* version >= JDWPTRANSPORT_VERSION_1_1 */ +typedef struct { + uint32_t subnet; + uint32_t netmask; +} AllowedPeerInfo; + +#define STR(x) #x +#define MAX_PEER_ENTRIES 32 +#define MAX_PEERS_STR STR(MAX_PEER_ENTRIES) +static AllowedPeerInfo _peers[MAX_PEER_ENTRIES]; +static int _peers_cnt = 0; + + /* * Record the last error for this thread. */ @@ -260,7 +276,7 @@ parseAddress(const char *address, struct sockaddr_in *sa) { char *colon; int port; - memset((void *)sa,0,sizeof(struct sockaddr_in)); + memset((void *)sa, 0, sizeof(struct sockaddr_in)); sa->sin_family = AF_INET; /* check for host:port or port */ @@ -274,7 +290,7 @@ parseAddress(const char *address, struct sockaddr_in *sa) { if (colon == NULL) { // bind to localhost only if no address specified sa->sin_addr.s_addr = getLocalHostAddress(); - } else if (strncmp(address,"localhost:",10) == 0) { + } else if (strncmp(address, "localhost:", 10) == 0) { // optimize for common case sa->sin_addr.s_addr = getLocalHostAddress(); } else if (*address == '*' && *(address+1) == ':') { @@ -286,7 +302,7 @@ parseAddress(const char *address, struct sockaddr_in *sa) { char *hostname; uint32_t addr; - buf = (*callback->alloc)((int)strlen(address)+1); + buf = (*callback->alloc)((int)strlen(address) + 1); if (buf == NULL) { RETURN_ERROR(JDWPTRANSPORT_ERROR_OUT_OF_MEMORY, "out of memory"); } @@ -320,6 +336,131 @@ parseAddress(const char *address, struct sockaddr_in *sa) { return JDWPTRANSPORT_ERROR_NONE; } +static const char * +ip_s2u(const char *instr, uint32_t *ip) { + // Convert string representation of ip to integer + // in network byte order (big-endian) + char t[4] = { 0, 0, 0, 0 }; + const char *s = instr; + int i = 0; + + while (1) { + if (*s == '.') { + ++i; + ++s; + continue; + } + if (*s == 0 || *s == '+' || *s == '/') { + break; + } + if (*s < '0' || *s > '9') { + return instr; + } + t[i] = (t[i] * 10) + (*s - '0'); + ++s; + } + + *ip = *(uint32_t*)(t); + return s; +} + +static const char * +mask_s2u(const char *instr, uint32_t *mask) { + // Convert the number of bits to a netmask + // in network byte order (big-endian) + unsigned char m = 0; + const char *s = instr; + + while (1) { + if (*s == 0 || *s == '+') { + break; + } + if (*s < '0' || *s > '9') { + return instr; + } + m = (m * 10) + (*s - '0'); + ++s; + } + + if (m == 0 || m > 32) { + // Drop invalid input + return instr; + } + + *mask = htonl(-1 << (32 - m)); + return s; +} + +static int +ip_in_subnet(uint32_t subnet, uint32_t mask, uint32_t ipaddr) { + return (ipaddr & mask) == subnet; +} + +static jdwpTransportError +parseAllowedPeers(const char *allowed_peers) { + // Build a list of allowed peers from char string + // of format 192.168.0.10+192.168.0.0/24 + const char *s = NULL; + const char *p = allowed_peers; + uint32_t ip = 0; + uint32_t mask = 0xFFFFFFFF; + + while (1) { + s = ip_s2u(p, &ip); + if (s == p) { + _peers_cnt = 0; + fprintf(stderr, "Error in allow option: '%s'\n", s); + RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, + "invalid IP address in allow option"); + } + + if (*s == '/') { + // netmask specified + s = mask_s2u(s + 1, &mask); + if (*(s - 1) == '/') { + // Input is not consumed, something bad happened + _peers_cnt = 0; + fprintf(stderr, "Error in allow option: '%s'\n", s); + RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, + "invalid netmask in allow option"); + } + } else { + // reset netmask + mask = 0xFFFFFFFF; + } + + if (*s == '+' || *s == 0) { + if (_peers_cnt >= MAX_PEER_ENTRIES) { + fprintf(stderr, "Error in allow option: '%s'\n", allowed_peers); + RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, + "exceeded max number of allowed peers: " MAX_PEERS_STR); + } + _peers[_peers_cnt].subnet = ip; + _peers[_peers_cnt].netmask = mask; + _peers_cnt++; + if (*s == 0) { + // end of options + break; + } + // advance to next IP block + p = s + 1; + } + } + return JDWPTRANSPORT_ERROR_NONE; +} + +static int +isPeerAllowed(struct sockaddr_in *peer) { + int i; + for (i = 0; i < _peers_cnt; ++i) { + int peer_ip = peer->sin_addr.s_addr; + if (ip_in_subnet(_peers[i].subnet, _peers[i].netmask, peer_ip)) { + return 1; + } + } + + return 0; +} static jdwpTransportError JNICALL socketTransport_getCapabilities(jdwpTransportEnv* env, @@ -412,7 +553,7 @@ static jdwpTransportError JNICALL socketTransport_accept(jdwpTransportEnv* env, jlong acceptTimeout, jlong handshakeTimeout) { socklen_t socketLen; - int err; + int err = JDWPTRANSPORT_ERROR_NONE; struct sockaddr_in socket; jlong startTime = (jlong)0; @@ -474,14 +615,34 @@ socketTransport_accept(jdwpTransportEnv* env, jlong acceptTimeout, jlong handsha return JDWPTRANSPORT_ERROR_IO_ERROR; } - /* handshake with the debugger */ - err = handshake(socketFD, handshakeTimeout); + /* + * version >= JDWPTRANSPORT_VERSION_1_1: + * Verify that peer is allowed to connect. + */ + if (_peers_cnt > 0) { + if (!isPeerAllowed(&socket)) { + char ebuf[64] = { 0 }; + char buf[INET_ADDRSTRLEN] = { 0 }; + const char* addr_str = inet_ntop(AF_INET, &(socket.sin_addr), buf, INET_ADDRSTRLEN); + sprintf(ebuf, "ERROR: Peer not allowed to connect: %s\n", + (addr_str == NULL) ? "" : addr_str); + dbgsysSocketClose(socketFD); + socketFD = -1; + err = JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT; + setLastError(err, ebuf); + } + } + + if (socketFD > 0) { + /* handshake with the debugger */ + err = handshake(socketFD, handshakeTimeout); + } /* * If the handshake fails then close the connection. If there if an accept * timeout then we must adjust the timeout for the next poll. */ - if (err) { + if (err != JDWPTRANSPORT_ERROR_NONE) { fprintf(stderr, "Debugger failed to attach: %s\n", getLastError()); dbgsysSocketClose(socketFD); socketFD = -1; @@ -743,20 +904,20 @@ socketTransport_readPacket(jdwpTransportEnv* env, jdwpPacket* packet) { packet->type.cmd.len = length; - n = recv_fully(socketFD,(char *)&(packet->type.cmd.id),sizeof(jint)); + n = recv_fully(socketFD,(char *)&(packet->type.cmd.id), sizeof(jint)); if (n < (int)sizeof(jint)) { RETURN_RECV_ERROR(n); } packet->type.cmd.id = (jint)dbgsysNetworkToHostLong(packet->type.cmd.id); - n = recv_fully(socketFD,(char *)&(packet->type.cmd.flags),sizeof(jbyte)); + n = recv_fully(socketFD,(char *)&(packet->type.cmd.flags), sizeof(jbyte)); if (n < (int)sizeof(jbyte)) { RETURN_RECV_ERROR(n); } if (packet->type.cmd.flags & JDWPTRANSPORT_FLAGS_REPLY) { - n = recv_fully(socketFD,(char *)&(packet->type.reply.errorCode),sizeof(jbyte)); + n = recv_fully(socketFD,(char *)&(packet->type.reply.errorCode), sizeof(jbyte)); if (n < (int)sizeof(jshort)) { RETURN_RECV_ERROR(n); } @@ -765,12 +926,12 @@ socketTransport_readPacket(jdwpTransportEnv* env, jdwpPacket* packet) { } else { - n = recv_fully(socketFD,(char *)&(packet->type.cmd.cmdSet),sizeof(jbyte)); + n = recv_fully(socketFD,(char *)&(packet->type.cmd.cmdSet), sizeof(jbyte)); if (n < (int)sizeof(jbyte)) { RETURN_RECV_ERROR(n); } - n = recv_fully(socketFD,(char *)&(packet->type.cmd.cmd),sizeof(jbyte)); + n = recv_fully(socketFD,(char *)&(packet->type.cmd.cmd), sizeof(jbyte)); if (n < (int)sizeof(jbyte)) { RETURN_RECV_ERROR(n); } @@ -814,11 +975,44 @@ socketTransport_getLastError(jdwpTransportEnv* env, char** msgP) { return JDWPTRANSPORT_ERROR_NONE; } +static jdwpTransportError JNICALL +socketTransport_setConfiguration(jdwpTransportEnv* env, jdwpTransportConfiguration* cfg) { + const char* allowed_peers = NULL; + + if (cfg == NULL) { + RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, + "NULL pointer to transport configuration is invalid"); + } + allowed_peers = cfg->allowed_peers; + _peers_cnt = 0; + if (allowed_peers != NULL) { + size_t len = strlen(allowed_peers); + if (len == 0) { /* Impossible: parseOptions() would reject it */ + fprintf(stderr, "Error in allow option: '%s'\n", allowed_peers); + RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, + "allow option should not be empty"); + } else if (*allowed_peers == '*') { + if (len != 1) { + fprintf(stderr, "Error in allow option: '%s'\n", allowed_peers); + RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, + "allow option '*' cannot be expanded"); + } + } else { + int err = parseAllowedPeers(allowed_peers); + if (err != JDWPTRANSPORT_ERROR_NONE) { + return err; + } + } + } + return JDWPTRANSPORT_ERROR_NONE; +} + jint JNICALL jdwpTransport_OnLoad(JavaVM *vm, jdwpTransportCallback* cbTablePtr, - jint version, jdwpTransportEnv** result) + jint version, jdwpTransportEnv** env) { - if (version != JDWPTRANSPORT_VERSION_1_0) { + if (version < JDWPTRANSPORT_VERSION_1_0 || + version > JDWPTRANSPORT_VERSION_1_1) { return JNI_EVERSION; } if (initialized) { @@ -842,7 +1036,10 @@ jdwpTransport_OnLoad(JavaVM *vm, jdwpTransportCallback* cbTablePtr, interface.ReadPacket = &socketTransport_readPacket; interface.WritePacket = &socketTransport_writePacket; interface.GetLastError = &socketTransport_getLastError; - *result = &single_env; + if (version >= JDWPTRANSPORT_VERSION_1_1) { + interface.SetTransportConfiguration = &socketTransport_setConfiguration; + } + *env = &single_env; /* initialized TLS */ tlsIndex = dbgsysTlsAlloc(); diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c index 44596d6ee3e..075dedacbb1 100644 --- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c +++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -89,6 +89,7 @@ typedef struct TransportSpec { char *name; char *address; long timeout; + char *allow; } TransportSpec; /* @@ -564,7 +565,8 @@ startTransport(void *item, void *arg) LOG_MISC(("Begin startTransport")); serror = transport_startTransport(enumArg->isServer, transport->name, - transport->address, transport->timeout); + transport->address, transport->timeout, + transport->allow); if (serror != JDWP_ERROR(NONE)) { ERROR_MESSAGE(("JDWP Transport %s failed to initialize, %s(%d)", transport->name, jdwpErrorText(serror), serror)); @@ -1060,7 +1062,6 @@ parseOptions(char *options) if (transports == NULL) { EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"transports"); } - } current = names; @@ -1080,6 +1081,9 @@ parseOptions(char *options) goto syntax_error; } currentTransport->name = current; + currentTransport->address = NULL; + currentTransport->allow = NULL; + currentTransport->timeout = 0L; current += strlen(current) + 1; } else if (strcmp(buf, "address") == 0) { if (currentTransport == NULL) { @@ -1092,7 +1096,18 @@ parseOptions(char *options) } currentTransport->address = current; current += strlen(current) + 1; - } else if (strcmp(buf, "timeout") == 0) { + } else if (strcmp(buf, "allow") == 0) { + if (currentTransport == NULL) { + errmsg = "allow specified without transport"; + goto bad_option_with_errmsg; + } + /*LINTED*/ + if (!get_tok(&str, current, (int)(end - current), ',')) { + goto syntax_error; + } + currentTransport->allow = current; + current += strlen(current) + 1; + } else if (strcmp(buf, "timeout") == 0) { if (currentTransport == NULL) { errmsg = "timeout specified without transport"; goto bad_option_with_errmsg; diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/transport.c b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/transport.c index 1587393a509..32222138d95 100644 --- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/transport.c +++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/transport.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -29,7 +29,9 @@ #include "debugLoop.h" #include "sys.h" -static jdwpTransportEnv *transport; +static jdwpTransportEnv *transport = NULL; +static unsigned transportVersion = JDWPTRANSPORT_VERSION_1_0; + static jrawMonitorID listenerLock; static jrawMonitorID sendLock; @@ -41,6 +43,8 @@ typedef struct TransportInfo { jdwpTransportEnv *transport; char *address; long timeout; + char *allowed_peers; + unsigned transportVersion; } TransportInfo; static struct jdwpTransportCallback callback = {jvmtiAllocate, jvmtiDeallocate}; @@ -135,7 +139,7 @@ loadTransportLibrary(const char *libdir, const char *name) * JDK 1.2 javai.c v1.61 */ static jdwpError -loadTransport(const char *name, jdwpTransportEnv **transportPtr) +loadTransport(const char *name, TransportInfo *info) { JNIEnv *env; jdwpTransport_OnLoad_t onLoad; @@ -147,6 +151,10 @@ loadTransport(const char *name, jdwpTransportEnv **transportPtr) ERROR_MESSAGE(("library name is empty")); return JDWP_ERROR(TRANSPORT_LOAD); } + if (info == NULL) { + ERROR_MESSAGE(("internal error: info should not be NULL")); + return JDWP_ERROR(TRANSPORT_LOAD); + } /* First, look in sun.boot.library.path. This should find the standard * dt_socket and dt_shmem transport libraries, or any library @@ -192,22 +200,34 @@ loadTransport(const char *name, jdwpTransportEnv **transportPtr) /* Get transport interface */ env = getEnv(); - if ( env != NULL ) { - jdwpTransportEnv *t; - JavaVM *jvm; - jint ver; + if (env != NULL) { + jdwpTransportEnv *t = NULL; + JavaVM *jvm = NULL; + jint rc; + size_t i; + /* If a new version is added here, update 'case JNI_EVERSION' below. */ + jint supported_versions[2] = {JDWPTRANSPORT_VERSION_1_1, JDWPTRANSPORT_VERSION_1_0}; JNI_FUNC_PTR(env,GetJavaVM)(env, &jvm); - ver = (*onLoad)(jvm, &callback, JDWPTRANSPORT_VERSION_1_0, &t); - if (ver != JNI_OK) { - switch (ver) { + + /* Try version 1.1 first, fallback to 1.0 on error */ + for (i = 0; i < sizeof(supported_versions); ++i) { + rc = (*onLoad)(jvm, &callback, supported_versions[i], &t); + if (rc != JNI_EVERSION) { + info->transportVersion = supported_versions[i]; + break; + } + } + + if (rc != JNI_OK) { + switch (rc) { case JNI_ENOMEM : ERROR_MESSAGE(("insufficient memory to complete initialization")); break; case JNI_EVERSION : - ERROR_MESSAGE(("transport doesn't recognize version %x", - JDWPTRANSPORT_VERSION_1_0)); + ERROR_MESSAGE(("transport doesn't recognize all supported versions: " + "{ 1_1, 1_0 }")); break; case JNI_EEXIST : @@ -215,13 +235,19 @@ loadTransport(const char *name, jdwpTransportEnv **transportPtr) break; default: - ERROR_MESSAGE(("unrecognized error %d from transport", ver)); + ERROR_MESSAGE(("unrecognized error %d from transport", rc)); break; } return JDWP_ERROR(TRANSPORT_INIT); } - *transportPtr = t; + + /* Store transport version to global variable to be able to + * set correct transport version for subsequent connect, + * even if info is already deallocated. + */ + transportVersion = info->transportVersion; + info->transport = t; } else { return JDWP_ERROR(TRANSPORT_LOAD); } @@ -314,7 +340,6 @@ acceptThread(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg) info = (TransportInfo*)(void*)arg; t = info->transport; - rc = (*t)->Accept(t, info->timeout, 0); /* System property no longer needed */ @@ -339,8 +364,10 @@ acceptThread(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg) static void JNICALL attachThread(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg) { + TransportInfo *info = (TransportInfo*)(void*)arg; + LOG_MISC(("Begin attach thread")); - connectionInitiated((jdwpTransportEnv *)(void*)arg); + connectionInitiated(info->transport); LOG_MISC(("End attach thread")); } @@ -418,13 +445,26 @@ launch(char *command, char *name, char *address) jdwpError transport_startTransport(jboolean isServer, char *name, char *address, - long timeout) + long timeout, char *allowed_peers) { jvmtiStartFunction func; - jdwpTransportEnv *trans; char threadName[MAXPATHLEN + 100]; jint err; jdwpError serror; + jdwpTransportConfiguration cfg = {0}; + TransportInfo *info; + jdwpTransportEnv *trans; + + info = jvmtiAllocate(sizeof(*info)); + if (info == NULL) { + return JDWP_ERROR(OUT_OF_MEMORY); + } + + info->transport = transport; + info->transportVersion = transportVersion; + info->name = NULL; + info->address = NULL; + info->allowed_peers = NULL; /* * If the transport is already loaded then use it @@ -434,28 +474,24 @@ transport_startTransport(jboolean isServer, char *name, char *address, * That probably means we have a bag a transport environments * to correspond to the transports bag. */ - if (transport != NULL) { - trans = transport; - } else { - serror = loadTransport(name, &trans); + if (info->transport == NULL) { + serror = loadTransport(name, info); if (serror != JDWP_ERROR(NONE)) { + jvmtiDeallocate(info); return serror; } } - if (isServer) { + // Cache the value + trans = info->transport; + if (isServer) { char *retAddress; char *launchCommand; - TransportInfo *info; jvmtiError error; int len; char* prop_value; - info = jvmtiAllocate(sizeof(*info)); - if (info == NULL) { - return JDWP_ERROR(OUT_OF_MEMORY); - } info->timeout = timeout; info->name = jvmtiAllocate((int)strlen(name)+1); @@ -465,7 +501,6 @@ transport_startTransport(jboolean isServer, char *name, char *address, } (void)strcpy(info->name, name); - info->address = NULL; if (address != NULL) { info->address = jvmtiAllocate((int)strlen(address)+1); if (info->address == NULL) { @@ -475,7 +510,32 @@ transport_startTransport(jboolean isServer, char *name, char *address, (void)strcpy(info->address, address); } - info->transport = trans; + if (info->transportVersion == JDWPTRANSPORT_VERSION_1_0) { + if (allowed_peers != NULL) { + ERROR_MESSAGE(("Allow parameter is specified but transport doesn't support it")); + serror = JDWP_ERROR(TRANSPORT_INIT); + goto handleError; + } + } else { + /* Memory is allocated only for transport versions > 1.0 + * as the version 1.0 does not support the 'allow' option. + */ + if (allowed_peers != NULL) { + info->allowed_peers = jvmtiAllocate((int)strlen(allowed_peers) + 1); + if (info->allowed_peers == NULL) { + serror = JDWP_ERROR(OUT_OF_MEMORY); + goto handleError; + } + (void)strcpy(info->allowed_peers, allowed_peers); + } + cfg.allowed_peers = info->allowed_peers; + err = (*trans)->SetTransportConfiguration(trans, &cfg); + if (err != JDWPTRANSPORT_ERROR_NONE) { + printLastError(trans, err); + serror = JDWP_ERROR(TRANSPORT_INIT); + goto handleError; + } + } err = (*trans)->StartListening(trans, address, &retAddress); if (err != JDWPTRANSPORT_ERROR_NONE) { @@ -527,6 +587,7 @@ transport_startTransport(jboolean isServer, char *name, char *address, handleError: jvmtiDeallocate(info->name); jvmtiDeallocate(info->address); + jvmtiDeallocate(info->allowed_peers); jvmtiDeallocate(info); } else { /* @@ -543,6 +604,10 @@ handleError: if (err != JDWPTRANSPORT_ERROR_NONE) { printLastError(trans, err); serror = JDWP_ERROR(TRANSPORT_INIT); + /* The name, address and allowed_peers fields in 'info' + * are not allocated in the non-server case so + * they do not need to be freed. */ + jvmtiDeallocate(info); return serror; } @@ -553,7 +618,7 @@ handleError: (void)strcat(threadName, name); func = &attachThread; - err = spawnNewThread(func, (void*)trans, threadName); + err = spawnNewThread(func, (void*)info, threadName); serror = map2jdwpError(err); } return serror; diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/transport.h b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/transport.h index 2320c2b3dc0..ea40588932b 100644 --- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/transport.h +++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/transport.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -30,7 +30,8 @@ void transport_initialize(void); void transport_reset(void); -jdwpError transport_startTransport(jboolean isServer, char *name, char *address, long timeout); +jdwpError transport_startTransport(jboolean isServer, char *name, char *address, + long timeout, char *allowed_peers); jint transport_receivePacket(jdwpPacket *); jint transport_sendPacket(jdwpPacket *); diff --git a/jdk/test/com/sun/jdi/BasicJDWPConnectionTest.java b/jdk/test/com/sun/jdi/BasicJDWPConnectionTest.java new file mode 100644 index 00000000000..9270c053178 --- /dev/null +++ b/jdk/test/com/sun/jdi/BasicJDWPConnectionTest.java @@ -0,0 +1,200 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Smoke test for JDWP hardening + * @library /lib/testlibrary + * @library /test/lib + * @run driver BasicJDWPConnectionTest + */ + +import java.io.IOException; +import java.io.BufferedReader; +import java.io.InputStreamReader; + +import java.net.Socket; +import java.net.SocketException; + +import jdk.test.lib.apps.LingeredApp; +import jdk.testlibrary.Utils; + +import java.util.ArrayList; +import java.util.List; + + +public class BasicJDWPConnectionTest { + + public static int handshake(int port) throws IOException { + // Connect to the debuggee and handshake + int res = -1; + Socket s = null; + try { + s = new Socket("localhost", port); + s.getOutputStream().write("JDWP-Handshake".getBytes("UTF-8")); + byte[] buffer = new byte[24]; + res = s.getInputStream().read(buffer); + } + catch (SocketException ex) { + // pass + } finally { + if (s != null) { + s.close(); + } + } + return res; + } + + public static ArrayList prepareCmd(int port, String allowOpt) { + String address = "*:" + String.valueOf(port); + ArrayList cmd = new ArrayList<>(); + + String jdwpArgs = "-agentlib:jdwp=transport=dt_socket,server=y," + + "suspend=n,address=" + address + allowOpt; + cmd.add(jdwpArgs); + return cmd; + } + + public static void positiveTest(String testName, String allowOpt) + throws InterruptedException, IOException { + System.err.println("\nStarting " + testName); + int port = Utils.getFreePort(); + ArrayList cmd = prepareCmd(port, allowOpt); + + LingeredApp a = LingeredApp.startApp(cmd); + int res = handshake(port); + a.stopApp(); + if (res < 0) { + throw new RuntimeException(testName + " FAILED"); + } + System.err.println(testName + " PASSED"); + } + + public static void negativeTest(String testName, String allowOpt) + throws InterruptedException, IOException { + System.err.println("\nStarting " + testName); + int port = Utils.getFreePort(); + ArrayList cmd = prepareCmd(port, allowOpt); + + LingeredApp a = LingeredApp.startApp(cmd); + int res = handshake(port); + a.stopApp(); + if (res > 0) { + System.err.println(testName + ": res=" + res); + throw new RuntimeException(testName + " FAILED"); + } + System.err.println(testName + ": returned a negative code as expected: " + res); + System.err.println(testName + " PASSED"); + } + + public static void badAllowOptionTest(String testName, String allowOpt) + throws InterruptedException, IOException { + System.err.println("\nStarting " + testName); + int port = Utils.getFreePort(); + ArrayList cmd = prepareCmd(port, allowOpt); + + try { + LingeredApp a = LingeredApp.startApp(cmd); + } catch (IOException ex) { + System.err.println(testName + ": caught expected IOException"); + System.err.println(testName + " PASSED"); + return; + } + throw new RuntimeException(testName + " FAILED"); + } + + public static void DefaultTest() throws InterruptedException, IOException { + // No allow option is the same as the allow option ',allow=*' is passed + String allowOpt = ""; + positiveTest("DefaultTest", allowOpt); + } + + static void ExplicitDefaultTest() throws InterruptedException, IOException { + // Explicit permission for connections from everywhere + String allowOpt = ",allow=*"; + positiveTest("ExplicitDefaultTest" ,allowOpt); + } + + public static void AllowTest() throws InterruptedException, IOException { + String allowOpt = ",allow=127.0.0.1"; + positiveTest("AllowTest", allowOpt); + } + + public static void MultiAllowTest() throws InterruptedException, IOException { + String allowOpt = ",allow=127.0.0.1+10.0.0.0/8+172.16.0.0/12+192.168.0.0/24"; + positiveTest("MultiAllowTest", allowOpt); + } + + public static void DenyTest() throws InterruptedException, IOException { + // Bad allow address + String allowOpt = ",allow=0.0.0.0"; + negativeTest("DenyTest", allowOpt); + } + + public static void MultiDenyTest() throws InterruptedException, IOException { + // Wrong separator ';' is used for allow option + String allowOpt = ",allow=127.0.0.1;192.168.0.0/24"; + badAllowOptionTest("MultiDenyTest", allowOpt); + } + + public static void EmptyAllowOptionTest() throws InterruptedException, IOException { + // Empty allow option + String allowOpt = ",allow="; + badAllowOptionTest("EmptyAllowOptionTest", allowOpt); + } + + public static void ExplicitMultiDefault1Test() throws InterruptedException, IOException { + // Bad mix of allow option '*' with address value + String allowOpt = ",allow=*+allow=127.0.0.1"; + badAllowOptionTest("ExplicitMultiDefault1Test", allowOpt); + } + + public static void ExplicitMultiDefault2Test() throws InterruptedException, IOException { + // Bad mix of allow address value with '*' + String allowOpt = ",allow=allow=127.0.0.1+*"; + badAllowOptionTest("ExplicitMultiDefault2Test", allowOpt); + } + + public static void main(String[] args) { + try { + DefaultTest(); + ExplicitDefaultTest(); + AllowTest(); + MultiAllowTest(); + DenyTest(); + MultiDenyTest(); + EmptyAllowOptionTest(); + ExplicitMultiDefault1Test(); + ExplicitMultiDefault2Test(); + System.err.println("\nTest PASSED"); + } catch (InterruptedException ex) { + System.err.println("\nTest ERROR, getFreePort"); + ex.printStackTrace(); + System.exit(3); + } catch (IOException ex) { + System.err.println("\nTest ERROR"); + ex.printStackTrace(); + System.exit(3); + } + } +} From 9f4207e324f8c4d285d5cd84625a127729d9a7e9 Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Thu, 31 Aug 2017 22:21:20 -0700 Subject: [PATCH 79/98] 8187023: Cannot read pkcs11 config file in UTF-16 environment Reviewed-by: ascarpino --- .../classes/sun/security/pkcs11/Config.java | 6 ++- .../pkcs11/Config/ReadConfInUTF16Env.java | 40 +++++++++++++++++++ .../pkcs11/Config/ReadConfInUTF16Env.sh | 38 ++++++++++++++++++ 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 jdk/test/sun/security/pkcs11/Config/ReadConfInUTF16Env.java create mode 100644 jdk/test/sun/security/pkcs11/Config/ReadConfInUTF16Env.sh diff --git a/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java b/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java index 1635db730a5..a5d3f106f03 100644 --- a/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java +++ b/jdk/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -28,6 +28,7 @@ package sun.security.pkcs11; import java.io.*; import static java.io.StreamTokenizer.*; import java.math.BigInteger; +import java.nio.charset.StandardCharsets; import java.util.*; import java.security.*; @@ -202,7 +203,8 @@ final class Config { reader = new StringReader(config); } else { reader = new BufferedReader(new InputStreamReader - (new FileInputStream(expand(filename)))); + (new FileInputStream(expand(filename)), + StandardCharsets.ISO_8859_1)); } parsedKeywords = new HashSet(); st = new StreamTokenizer(reader); diff --git a/jdk/test/sun/security/pkcs11/Config/ReadConfInUTF16Env.java b/jdk/test/sun/security/pkcs11/Config/ReadConfInUTF16Env.java new file mode 100644 index 00000000000..4f924f96020 --- /dev/null +++ b/jdk/test/sun/security/pkcs11/Config/ReadConfInUTF16Env.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.security.Provider; +import java.security.Security; + +public class ReadConfInUTF16Env { + public static void main(String argv[]) { + Provider p = Security.getProvider("SunPKCS11"); + if (p == null) { + p = Security.getProvider("SunPKCS11-Solaris"); + if (p == null) { + System.out.println("Skipping test - no PKCS11 provider available"); + return; + } + } + + System.out.println(p.getName()); + } +} diff --git a/jdk/test/sun/security/pkcs11/Config/ReadConfInUTF16Env.sh b/jdk/test/sun/security/pkcs11/Config/ReadConfInUTF16Env.sh new file mode 100644 index 00000000000..c2a99f2862d --- /dev/null +++ b/jdk/test/sun/security/pkcs11/Config/ReadConfInUTF16Env.sh @@ -0,0 +1,38 @@ +# +# Copyright (c) 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 +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# @test +# @bug 8187023 +# @summary Pkcs11 config file should be assumed in ISO-8859-1 +# @build ReadConfInUTF16Env +# @run shell ReadConfInUTF16Env.sh + +# jtreg does not like -Dfile.encoding=UTF-16 inside a @run main line, +# testlibrary.ProcessTools.createJavaProcessBuilder() also had troubles +# executing a subprocess with -Dfile.encoding=UTF-16 option added, +# therefore a shell test is written. + +$TESTJAVA/bin/java $TESTVMOPTS -cp $TESTCLASSES \ + -Dfile.encoding=UTF-16 \ + ReadConfInUTF16Env + From 6c012b6381626775435d00aa6c0ea6e89a295ea1 Mon Sep 17 00:00:00 2001 From: Prahalad Narayanan Date: Fri, 1 Sep 2017 12:32:20 +0530 Subject: [PATCH 80/98] 8164971: PNG metadata does not handle ImageCreationTime Reviewed-by: prr, bpb, jdv --- .../imageio/plugins/png/PNGImageReader.java | 55 ++- .../sun/imageio/plugins/png/PNGMetadata.java | 280 ++++++++++++- .../plugins/png/PngCreationTimeTest.java | 370 ++++++++++++++++++ 3 files changed, 686 insertions(+), 19 deletions(-) create mode 100644 jdk/test/javax/imageio/plugins/png/PngCreationTimeTest.java diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java index a2d7e7ecafc..e531929cec6 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -472,6 +472,14 @@ public class PNGImageReader extends ImageReader { text = new String(b, "UTF8"); } metadata.iTXt_text.add(text); + + // Check if the text chunk contains image creation time + if (keyword.equals(PNGMetadata.tEXt_creationTimeKey)) { + // Update Standard/Document/ImageCreationTime from text chunk + int index = metadata.iTXt_text.size() - 1; + metadata.decodeImageCreationTimeFromTextChunk( + metadata.iTXt_text.listIterator(index)); + } } private void parse_pHYs_chunk() throws IOException { @@ -555,6 +563,14 @@ public class PNGImageReader extends ImageReader { byte[] b = new byte[chunkLength - keyword.length() - 1]; stream.readFully(b); metadata.tEXt_text.add(new String(b, "ISO-8859-1")); + + // Check if the text chunk contains image creation time + if (keyword.equals(PNGMetadata.tEXt_creationTimeKey)) { + // Update Standard/Document/ImageCreationTime from text chunk + int index = metadata.tEXt_text.size() - 1; + metadata.decodeImageCreationTimeFromTextChunk( + metadata.tEXt_text.listIterator(index)); + } } private void parse_tIME_chunk() throws IOException { @@ -644,6 +660,14 @@ public class PNGImageReader extends ImageReader { byte[] b = new byte[chunkLength - keyword.length() - 2]; stream.readFully(b); metadata.zTXt_text.add(new String(inflate(b), "ISO-8859-1")); + + // Check if the text chunk contains image creation time + if (keyword.equals(PNGMetadata.tEXt_creationTimeKey)) { + // Update Standard/Document/ImageCreationTime from text chunk + int index = metadata.zTXt_text.size() - 1; + metadata.decodeImageCreationTimeFromTextChunk( + metadata.zTXt_text.listIterator(index)); + } } private void readMetadata() throws IIOException { @@ -713,8 +737,32 @@ public class PNGImageReader extends ImageReader { switch (chunkType) { case IDAT_TYPE: // If chunk type is 'IDAT', we've reached the image data. - stream.skipBytes(-8); - imageStartPosition = stream.getStreamPosition(); + if (imageStartPosition == -1L) { + /* + * PNGs may contain multiple IDAT chunks containing + * a portion of image data. We store the position of + * the first IDAT chunk and continue with iteration + * of other chunks that follow image data. + */ + imageStartPosition = stream.getStreamPosition() - 8; + } + // Move to the CRC byte location. + stream.skipBytes(chunkLength); + break; + case IEND_TYPE: + /* + * If the chunk type is 'IEND', we've reached end of image. + * Seek to the first IDAT chunk for subsequent decoding. + */ + stream.seek(imageStartPosition); + + /* + * flushBefore discards the portion of the stream before + * the indicated position. Hence this should be used after + * we complete iteration over available chunks including + * those that appear after the IDAT. + */ + stream.flushBefore(stream.getStreamPosition()); break loop; case PLTE_TYPE: parse_PLTE_chunk(chunkLength); @@ -796,7 +844,6 @@ public class PNGImageReader extends ImageReader { throw new IIOException("Failed to read a chunk of type " + chunkType); } - stream.flushBefore(stream.getStreamPosition()); } } catch (IOException e) { throw new IIOException("Error reading PNG metadata", e); diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java index 2c7720c7f19..36ab8f97442 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -30,6 +30,14 @@ import java.awt.image.IndexColorModel; import java.awt.image.SampleModel; import java.util.ArrayList; import java.util.StringTokenizer; +import java.util.ListIterator; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.time.temporal.TemporalAccessor; import javax.imageio.ImageTypeSpecifier; import javax.imageio.metadata.IIOInvalidTreeException; import javax.imageio.metadata.IIOMetadata; @@ -212,7 +220,7 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { public ArrayList tEXt_keyword = new ArrayList(); // 1-79 characters public ArrayList tEXt_text = new ArrayList(); - // tIME chunk + // tIME chunk. Gives the image modification time. public boolean tIME_present; public int tIME_year; public int tIME_month; @@ -221,6 +229,41 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { public int tIME_minute; public int tIME_second; + // Specifies whether metadata contains Standard/Document/ImageCreationTime + public boolean creation_time_present; + + // Values that make up Standard/Document/ImageCreationTime + public int creation_time_year; + public int creation_time_month; + public int creation_time_day; + public int creation_time_hour; + public int creation_time_minute; + public int creation_time_second; + public ZoneOffset creation_time_offset; + + /* + * tEXt_creation_time_present- Specifies whether any text chunk (tEXt, iTXt, + * zTXt) exists with image creation time. The data structure corresponding + * to the last decoded text chunk with creation time is indicated by the + * iterator- tEXt_creation_time_iter. + * + * Any update to the text chunks with creation time is reflected on + * Standard/Document/ImageCreationTime after retrieving time from the text + * chunk. If there are multiple text chunks with creation time, the time + * retrieved from the last decoded text chunk will be used. A point to note + * is that, retrieval of time from text chunks is possible only if the + * encoded time in the chunk confirms to either the recommended RFC1123 + * format or ISO format. + * + * Similarly, any update to Standard/Document/ImageCreationTime is reflected + * on the last decoded text chunk's data structure with time encoded in + * RFC1123 format. By updating the text chunk's data structure, we also + * ensure that PNGImageWriter will write image creation time on the output. + */ + public boolean tEXt_creation_time_present; + private ListIterator tEXt_creation_time_iter = null; + public static final String tEXt_creationTimeKey = "Creation Time"; + // tRNS chunk // If external (non-PNG sourced) data has red = green = blue, // always store it as gray and promote when writing @@ -985,21 +1028,41 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { } public IIOMetadataNode getStandardDocumentNode() { - if (!tIME_present) { - return null; + IIOMetadataNode document_node = null; + + // Check if image modification time exists + if (tIME_present) { + // Create new document node + document_node = new IIOMetadataNode("Document"); + + // Node to hold image modification time + IIOMetadataNode node = new IIOMetadataNode("ImageModificationTime"); + node.setAttribute("year", Integer.toString(tIME_year)); + node.setAttribute("month", Integer.toString(tIME_month)); + node.setAttribute("day", Integer.toString(tIME_day)); + node.setAttribute("hour", Integer.toString(tIME_hour)); + node.setAttribute("minute", Integer.toString(tIME_minute)); + node.setAttribute("second", Integer.toString(tIME_second)); + document_node.appendChild(node); } - IIOMetadataNode document_node = new IIOMetadataNode("Document"); - IIOMetadataNode node = null; // scratch node + // Check if image creation time exists + if (creation_time_present) { + if (document_node == null) { + // Create new document node + document_node = new IIOMetadataNode("Document"); + } - node = new IIOMetadataNode("ImageModificationTime"); - node.setAttribute("year", Integer.toString(tIME_year)); - node.setAttribute("month", Integer.toString(tIME_month)); - node.setAttribute("day", Integer.toString(tIME_day)); - node.setAttribute("hour", Integer.toString(tIME_hour)); - node.setAttribute("minute", Integer.toString(tIME_minute)); - node.setAttribute("second", Integer.toString(tIME_second)); - document_node.appendChild(node); + // Node to hold image creation time + IIOMetadataNode node = new IIOMetadataNode("ImageCreationTime"); + node.setAttribute("year", Integer.toString(creation_time_year)); + node.setAttribute("month", Integer.toString(creation_time_month)); + node.setAttribute("day", Integer.toString(creation_time_day)); + node.setAttribute("hour", Integer.toString(creation_time_hour)); + node.setAttribute("minute", Integer.toString(creation_time_minute)); + node.setAttribute("second", Integer.toString(creation_time_second)); + document_node.appendChild(node); + } return document_node; } @@ -1437,6 +1500,13 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { String text = getAttribute(iTXt_node, "text"); iTXt_text.add(text); + // Check if the text chunk contains image creation time + if (keyword.equals(PNGMetadata.tEXt_creationTimeKey)) { + // Update Standard/Document/ImageCreationTime + int index = iTXt_text.size()-1; + decodeImageCreationTimeFromTextChunk( + iTXt_text.listIterator(index)); + } } // silently skip invalid text entry @@ -1564,6 +1634,13 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { String text = getAttribute(tEXt_node, "value"); tEXt_text.add(text); + // Check if the text chunk contains image creation time + if (keyword.equals(PNGMetadata.tEXt_creationTimeKey)) { + // Update Standard/Document/ImageCreationTime + int index = tEXt_text.size()-1; + decodeImageCreationTimeFromTextChunk( + tEXt_text.listIterator(index)); + } tEXt_node = tEXt_node.getNextSibling(); } } else if (name.equals("tIME")) { @@ -1652,6 +1729,13 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { String text = getAttribute(zTXt_node, "text"); zTXt_text.add(text); + // Check if the text chunk contains image creation time + if (keyword.equals(PNGMetadata.tEXt_creationTimeKey)) { + // Update Standard/Document/ImageCreationTime + int index = zTXt_text.size()-1; + decodeImageCreationTimeFromTextChunk( + zTXt_text.listIterator(index)); + } zTXt_node = zTXt_node.getNextSibling(); } } else if (name.equals("UnknownChunks")) { @@ -1952,7 +2036,22 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { tIME_second = getIntAttribute(child, "second", 0, false); // } else if (childName.equals("SubimageInterpretation")) { -// } else if (childName.equals("ImageCreationTime")) { + } else if (childName.equals("ImageCreationTime")) { + // Extract the creation time values + int year = getIntAttribute(child, "year"); + int month = getIntAttribute(child, "month"); + int day = getIntAttribute(child, "day"); + int hour = getIntAttribute(child, "hour", 0, false); + int mins = getIntAttribute(child, "minute", 0, false); + int sec = getIntAttribute(child, "second", 0, false); + + /* + * Update Standard/Document/ImageCreationTime and encode + * the same in the last decoded text chunk with creation + * time + */ + initImageCreationTime(year, month, day, hour, mins, sec); + encodeImageCreationTimeToTextChunk(); } child = child.getNextSibling(); } @@ -2014,6 +2113,152 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { } } + void initImageCreationTime(OffsetDateTime offsetDateTime) { + // Check for incoming arguments + if (offsetDateTime != null) { + // set values that make up Standard/Document/ImageCreationTime + creation_time_present = true; + creation_time_year = offsetDateTime.getYear(); + creation_time_month = offsetDateTime.getMonthValue(); + creation_time_day = offsetDateTime.getDayOfMonth(); + creation_time_hour = offsetDateTime.getHour(); + creation_time_minute = offsetDateTime.getMinute(); + creation_time_second = offsetDateTime.getSecond(); + creation_time_offset = offsetDateTime.getOffset(); + } + } + + void initImageCreationTime(int year, int month, int day, + int hour, int min,int second) { + /* + * Though LocalDateTime suffices the need to store Standard/Document/ + * ImageCreationTime, we require the zone offset to encode the same + * in the text chunk based on RFC1123 format. + */ + LocalDateTime locDT = LocalDateTime.of(year, month, day, hour, min, second); + ZoneOffset offset = ZoneId.systemDefault() + .getRules() + .getOffset(locDT); + OffsetDateTime offDateTime = OffsetDateTime.of(locDT,offset); + initImageCreationTime(offDateTime); + } + + void decodeImageCreationTimeFromTextChunk(ListIterator iterChunk) { + // Check for incoming arguments + if (iterChunk != null && iterChunk.hasNext()) { + /* + * Save the iterator to mark the last decoded text chunk with + * creation time. The contents of this chunk will be updated when + * user provides creation time by merging a standard tree with + * Standard/Document/ImageCreationTime. + */ + setCreationTimeChunk(iterChunk); + + // Parse encoded time and set Standard/Document/ImageCreationTime. + String encodedTime = getEncodedTime(); + initImageCreationTime(parseEncodedTime(encodedTime)); + } + } + + void encodeImageCreationTimeToTextChunk() { + // Check if Standard/Document/ImageCreationTime exists. + if (creation_time_present) { + // Check if a text chunk with creation time exists. + if (tEXt_creation_time_present == false) { + // No text chunk exists with image creation time. Add an entry. + this.tEXt_keyword.add(tEXt_creationTimeKey); + this.tEXt_text.add("Creation Time Place Holder"); + + // Update the iterator + int index = tEXt_text.size() - 1; + setCreationTimeChunk(tEXt_text.listIterator(index)); + } + + // Encode image creation time with RFC1123 formatter + OffsetDateTime offDateTime = OffsetDateTime.of(creation_time_year, + creation_time_month, creation_time_day, + creation_time_hour, creation_time_minute, + creation_time_second, 0, creation_time_offset); + DateTimeFormatter formatter = DateTimeFormatter.RFC_1123_DATE_TIME; + String encodedTime = offDateTime.format(formatter); + setEncodedTime(encodedTime); + } + } + + private void setCreationTimeChunk(ListIterator iter) { + // Check for iterator's valid state + if (iter != null && iter.hasNext()) { + tEXt_creation_time_iter = iter; + tEXt_creation_time_present = true; + } + } + + private void setEncodedTime(String encodedTime) { + if (tEXt_creation_time_iter != null + && tEXt_creation_time_iter.hasNext() + && encodedTime != null) { + // Set the value at the iterator and reset its state + tEXt_creation_time_iter.next(); + tEXt_creation_time_iter.set(encodedTime); + tEXt_creation_time_iter.previous(); + } + } + + private String getEncodedTime() { + String encodedTime = null; + if (tEXt_creation_time_iter != null + && tEXt_creation_time_iter.hasNext()) { + // Get the value at iterator and reset its state + encodedTime = tEXt_creation_time_iter.next(); + tEXt_creation_time_iter.previous(); + } + return encodedTime; + } + + private OffsetDateTime parseEncodedTime(String encodedTime) { + OffsetDateTime retVal = null; + boolean timeDecoded = false; + + /* + * PNG specification recommends that image encoders use RFC1123 format + * to represent time in String but doesn't mandate. Encoders could + * use any convenient format. Hence, we extract time provided the + * encoded time complies with either RFC1123 or ISO standards. + */ + try { + // Check if the encoded time complies with RFC1123 + retVal = OffsetDateTime.parse(encodedTime, + DateTimeFormatter.RFC_1123_DATE_TIME); + timeDecoded = true; + } catch (DateTimeParseException exception) { + // No Op. Encoded time did not comply with RFC1123 standard. + } + + if (timeDecoded == false) { + try { + // Check if the encoded time complies with ISO standard. + DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME; + TemporalAccessor dt = formatter.parseBest(encodedTime, + OffsetDateTime::from, LocalDateTime::from); + + if (dt instanceof OffsetDateTime) { + // Encoded time contains date time and zone offset + retVal = (OffsetDateTime) dt; + } else if (dt instanceof LocalDateTime) { + /* + * Encoded time contains only date and time. Since zone + * offset information isn't available, we set to the default + */ + LocalDateTime locDT = (LocalDateTime) dt; + retVal = OffsetDateTime.of(locDT, ZoneOffset.UTC); + } + } catch (DateTimeParseException exception) { + // No Op. Encoded time did not comply with ISO standard. + } + } + return retVal; + } + // Reset all instance variables to their initial state public void reset() { IHDR_present = false; @@ -2035,7 +2280,12 @@ public class PNGMetadata extends IIOMetadata implements Cloneable { sRGB_present = false; tEXt_keyword = new ArrayList(); tEXt_text = new ArrayList(); + // tIME chunk with Image modification time tIME_present = false; + // Text chunk with Image creation time + tEXt_creation_time_present = false; + tEXt_creation_time_iter = null; + creation_time_present = false; tRNS_present = false; zTXt_keyword = new ArrayList(); zTXt_compressionMethod = new ArrayList(); diff --git a/jdk/test/javax/imageio/plugins/png/PngCreationTimeTest.java b/jdk/test/javax/imageio/plugins/png/PngCreationTimeTest.java new file mode 100644 index 00000000000..3347aea1bb8 --- /dev/null +++ b/jdk/test/javax/imageio/plugins/png/PngCreationTimeTest.java @@ -0,0 +1,370 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8164971 + * @summary The test decodes a png file and checks if the metadata contains + * image creation time. In addition, the test also merges the custom + * metadata tree (both standard and native) and succeeds when the + * metadata contains expected image creation time. + * @run main PngCreationTimeTest + */ +import java.io.IOException; +import java.io.File; +import java.nio.file.Files; +import java.util.Iterator; +import java.awt.Graphics2D; +import java.awt.Color; +import java.awt.image.BufferedImage; +import javax.imageio.ImageIO; +import javax.imageio.IIOImage; +import javax.imageio.ImageTypeSpecifier; +import javax.imageio.stream.ImageInputStream; +import javax.imageio.stream.ImageOutputStream; +import javax.imageio.ImageReadParam; +import javax.imageio.ImageReader; +import javax.imageio.ImageWriter; +import javax.imageio.metadata.IIOMetadata; +import javax.imageio.metadata.IIOMetadataNode; +import org.w3c.dom.Node; +import org.w3c.dom.NamedNodeMap; + +public class PngCreationTimeTest { + // Members + private static IIOMetadata pngMetadata = null; + + public static void initializeTest() throws IOException { + ImageReader pngImageReader = null; + BufferedImage decImage = null; + ImageInputStream imageStream = null; + String fileName = "duke.png"; + String separator = System.getProperty("file.separator"); + String dirPath = System.getProperty("test.src", "."); + String filePath = dirPath + separator + fileName; + File file = new File(filePath); + + try { + Iterator iterR = ImageIO.getImageReadersBySuffix("PNG"); + if (iterR.hasNext()) { + pngImageReader = iterR.next(); + ImageReadParam param = pngImageReader.getDefaultReadParam(); + imageStream = ImageIO.createImageInputStream(file); + + /* + * Last argument- false, informs reader not to ignore the + * metadata from the image file + */ + pngImageReader.setInput(imageStream, false, false); + decImage = pngImageReader.read(0, param); + pngMetadata = pngImageReader.getImageMetadata(0); + + // Check if the metadata contains creation time + testImageMetadata(pngMetadata); + } + } finally { + // Release ther resources + if (imageStream != null) { + imageStream.close(); + } + if (pngImageReader != null) { + pngImageReader.dispose(); + } + } + } + + public static void testImageMetadata(IIOMetadata metadata) { + /* + * The source file contains Creation Time in its text chunk. Upon + * successful decoding, the Standard/Document/ImageCreationTime + * should exist in the metadata. + */ + if (metadata != null) { + Node keyNode = findNode(metadata.getAsTree("javax_imageio_1.0"), + "ImageCreationTime"); + if (keyNode == null) { + throw new RuntimeException("Test Failed: Reader could not" + + " find creation time in the metadata"); + } + } + } + + public static void testSaveCreationTime() throws IOException { + File file = null; + ImageWriter pngImageWriter = null; + ImageReader pngImageReader = null; + ImageInputStream inputStream = null; + ImageOutputStream outputStream = null; + try { + // Create a simple image and fill with a color + int imageSize = 200; + BufferedImage buffImage = new BufferedImage(imageSize, imageSize, + BufferedImage.TYPE_INT_ARGB); + Graphics2D g2d = buffImage.createGraphics(); + g2d.setColor(Color.red); + g2d.fillRect(0, 0, imageSize, imageSize); + + // Create a temporary file for the output png image + String fileName = "RoundTripTest"; + file = File.createTempFile(fileName, ".png"); + + // Create a PNG writer and write test image with metadata + Iterator iterW = ImageIO.getImageWritersBySuffix("PNG"); + if (iterW.hasNext()) { + pngImageWriter = iterW.next(); + outputStream = ImageIO.createImageOutputStream(file); + pngImageWriter.setOutput(outputStream); + + // Get the default metadata & add image creation time to it. + IIOMetadata metadata = pngImageWriter.getDefaultImageMetadata( + ImageTypeSpecifier.createFromRenderedImage(buffImage), + null); + IIOMetadataNode root = createStandardMetadataNodeTree(); + metadata.mergeTree("javax_imageio_1.0", root); + + // Write a png image using buffImage & metadata + IIOImage iioImage = new IIOImage(buffImage, null, metadata); + pngImageWriter.write(iioImage); + } + + // Create a PNG reader and check if metadata was written + Iterator iterR = ImageIO.getImageReadersBySuffix("PNG"); + if (iterR.hasNext()) { + pngImageReader = iterR.next(); + inputStream = ImageIO.createImageInputStream(file); + + // Read the image and get the metadata + pngImageReader.setInput(inputStream, false, false); + pngImageReader.read(0); + IIOMetadata imgMetadata = pngImageReader.getImageMetadata(0); + + // Test if the metadata contains creation time. + testImageMetadata(imgMetadata); + } + } finally { + // Release the resources held + if (inputStream != null) { + inputStream.close(); + } + if (outputStream != null) { + outputStream.close(); + } + if (pngImageWriter != null) { + pngImageWriter.dispose(); + } + if (pngImageReader != null) { + pngImageReader.dispose(); + } + // Delete the temp file as well + if (file != null) { + Files.delete(file.toPath()); + } + } + } + + public static void testMergeNativeTree() { + // Merge a custom native metadata tree and inspect creation time + if (pngMetadata != null) { + try { + IIOMetadataNode root = createNativeMetadataNodeTree(); + + /* + * Merge the native metadata tree created. The data should + * reflect in Standard/Document/ImageCreationTime Node + */ + pngMetadata.mergeTree("javax_imageio_png_1.0", root); + Node keyNode = findNode(pngMetadata.getAsTree("javax_imageio_1.0"), + "ImageCreationTime"); + + if (keyNode != null) { + // Query the attributes of the node and check for the value + NamedNodeMap attrMap = keyNode.getAttributes(); + String attrValue = attrMap.getNamedItem("year") + .getNodeValue(); + int decYear = Integer.parseInt(attrValue); + if (decYear != 2014) { + // Throw exception. Incorrect year value observed + throw new RuntimeException("Test Failed: Incorrect" + + " creation time value observed"); + } + } else { + // Throw exception. + throw new RuntimeException("Test Failed: Image creation" + + "time doesn't exist in metadata"); + } + } catch (IOException ex) { + // Throw exception. + throw new RuntimeException("Test Failed: While executing" + + " mergeTree on metadata."); + } + } + } + + public static void testMergeStandardTree() { + // Merge a standard metadata tree and inspect creation time + if (pngMetadata != null) { + try { + IIOMetadataNode root = createStandardMetadataNodeTree(); + + /* + * Merge the standard metadata tree created. The data should + * correctly reflect in the native tree + */ + pngMetadata.mergeTree("javax_imageio_1.0", root); + Node keyNode = findNode(pngMetadata.getAsTree("javax_imageio_png_1.0"), + "tEXtEntry"); + // Last text entry would contain the merged information + while (keyNode != null && keyNode.getNextSibling() != null) { + keyNode = keyNode.getNextSibling(); + } + + if (keyNode != null) { + // Query the attributes of the node and check for the value + NamedNodeMap attrMap = keyNode.getAttributes(); + String attrValue = attrMap.getNamedItem("value") + .getNodeValue(); + if (!attrValue.contains("2016")) { + // Throw exception. Incorrect year value observed + throw new RuntimeException("Test Failed: Incorrect" + + " creation time value observed"); + } + } else { + // Throw exception. + throw new RuntimeException("Test Failed: Image creation" + + "time doesn't exist in metadata"); + } + } catch (IOException ex) { + // Throw exception. + throw new RuntimeException("Test Failed: While executing" + + " mergeTree on metadata."); + } + } + } + + public static IIOMetadataNode createNativeMetadataNodeTree() { + // Create a text node to hold tEXtEntries + IIOMetadataNode tEXtNode = new IIOMetadataNode("tEXt"); + + // Create tEXt entry to hold random date time + IIOMetadataNode randomTimeEntry = new IIOMetadataNode("tEXtEntry"); + randomTimeEntry.setAttribute("keyword", "Creation Time"); + randomTimeEntry.setAttribute("value", "21 Dec 2015,Monday"); + tEXtNode.appendChild(randomTimeEntry); + + // Create a tEXt entry to hold time in RFC1123 format + IIOMetadataNode rfcTextEntry = new IIOMetadataNode("tEXtEntry"); + rfcTextEntry.setAttribute("keyword", "Creation Time"); + rfcTextEntry.setAttribute("value", "Mon, 21 Dec 2015 09:04:30 +0530"); + tEXtNode.appendChild(rfcTextEntry); + + // Create a tEXt entry to hold time in ISO format + IIOMetadataNode isoTextEntry = new IIOMetadataNode("tEXtEntry"); + isoTextEntry.setAttribute("keyword", "Creation Time"); + isoTextEntry.setAttribute("value", "2014-12-21T09:04:30+05:30"); + tEXtNode.appendChild(isoTextEntry); + + // Create a root node append the text node + IIOMetadataNode root = new IIOMetadataNode("javax_imageio_png_1.0"); + root.appendChild(tEXtNode); + + return root; + } + + public static IIOMetadataNode createStandardMetadataNodeTree() { + /* + * Create standard metadata tree with creation time in + * Standard(Root)/Document/ImageCreationTime node + */ + IIOMetadataNode createTimeNode = new IIOMetadataNode("ImageCreationTime"); + createTimeNode.setAttribute("year", "2016"); + createTimeNode.setAttribute("month", "12"); + createTimeNode.setAttribute("day", "21"); + createTimeNode.setAttribute("hour", "18"); + createTimeNode.setAttribute("minute", "30"); + createTimeNode.setAttribute("second", "00"); + + // Create the Document node + IIOMetadataNode documentNode = new IIOMetadataNode("Document"); + documentNode.appendChild(createTimeNode); + + // Create a root node append the Document node + IIOMetadataNode root = new IIOMetadataNode("javax_imageio_1.0"); + root.appendChild(documentNode); + + return root; + } + + public static Node findNode(Node root, String nodeName) { + // Return value + Node retVal = null; + + if (root != null ) { + // Check if the name of root node matches the key + String name = root.getNodeName(); + if (name.equalsIgnoreCase(nodeName)) { + return root; + } + + // Process all children + Node node = root.getFirstChild(); + while (node != null) { + retVal = findNode(node, nodeName); + if (retVal != null ) { + // We found the node. Stop the search + break; + } + node = node.getNextSibling(); + } + } + + return retVal; + } + + public static void main(String[] args) throws IOException { + /* + * Initialize the test by decoding a PNG image that has creation + * time in one of its text chunks and check if the metadata returned + * contains image creation time. + */ + initializeTest(); + + /* + * Test the round trip usecase. Write a PNG file with "Creation Time" + * in text chunk and decode the same to check if the creation time + * was indeed written to the PNG file. + */ + testSaveCreationTime(); + + /* + * Modify the metadata by merging a standard metadata tree and inspect + * the value in the native tree + */ + testMergeNativeTree(); + + /* + * Modify the metadata by merging a native metadata tree and inspect + * the value in the standard tree. + */ + testMergeStandardTree(); + } +} From 4309aa8780084392e2ffa237163fa96f2ac25806 Mon Sep 17 00:00:00 2001 From: Kevin Walls Date: Fri, 1 Sep 2017 01:03:20 -0700 Subject: [PATCH 81/98] 8186902: jcmd GC.run should not be blocked by DisableExplicitGC Reviewed-by: mgerdin, sspitsyn --- hotspot/src/share/vm/services/diagnosticCommand.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/services/diagnosticCommand.cpp b/hotspot/src/share/vm/services/diagnosticCommand.cpp index 8a7339bcad5..4d91e7da8a7 100644 --- a/hotspot/src/share/vm/services/diagnosticCommand.cpp +++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp @@ -414,11 +414,7 @@ void VMInfoDCmd::execute(DCmdSource source, TRAPS) { } void SystemGCDCmd::execute(DCmdSource source, TRAPS) { - if (!DisableExplicitGC) { - Universe::heap()->collect(GCCause::_dcmd_gc_run); - } else { - output()->print_cr("Explicit GC is disabled, no GC has been performed."); - } + Universe::heap()->collect(GCCause::_dcmd_gc_run); } void RunFinalizationDCmd::execute(DCmdSource source, TRAPS) { From d6eddd8f4a715334187539406dda41ddd7436e33 Mon Sep 17 00:00:00 2001 From: Abhijit Saha Date: Fri, 1 Sep 2017 14:13:05 +0000 Subject: [PATCH 82/98] Added tag jdk-10+22 for changeset 23c02a1b49ee --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 8fb046684e7..6bb033be77d 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -446,3 +446,4 @@ d2982a786f53814367698e63efe6349c9128e1db jdk-9+180 b656dea9398ef601f7fc08d1a5157a560e0ccbe0 jdk-9+181 682e2a6df836f4731f92eb2ddcd467075047f6ea jdk-10+20 90cdfe56f1543267a8005e638bd1b44551fda189 jdk-10+21 +8625e8491887bfd4310b2cfc2b84bac26312ba20 jdk-10+22 From 82f3c0131c517a8416a9699d4a7c947934356597 Mon Sep 17 00:00:00 2001 From: Abhijit Saha Date: Fri, 1 Sep 2017 14:13:07 +0000 Subject: [PATCH 83/98] Added tag jdk-10+22 for changeset 647709236722 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 08712009f2f..dc09494f034 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -446,3 +446,4 @@ a923b3f30e7bddb4f960059ddfc7978fc63e2e6e jdk-10+18 ba71941ad9dba53b8fffb30602ef673eee88696c jdk-9+181 7a54ec280513a33e49e60546c0cf9ca573925a43 jdk-10+20 68b5f8eeac3325c02aac2f4b452b8a37c20c970e jdk-10+21 +1f4456d51b07098af1848d0d968084b1e9b85a36 jdk-10+22 From edbf269b03d829aa27a075ff91d856bed07f32a9 Mon Sep 17 00:00:00 2001 From: Abhijit Saha Date: Fri, 1 Sep 2017 14:13:09 +0000 Subject: [PATCH 84/98] Added tag jdk-10+22 for changeset bf9c7464f8c5 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 495d9841695..51b6aa07416 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -606,3 +606,4 @@ d7baadc223e790c08bc69bf7e553bce65b4e7e40 jdk-9+180 4a443796f6f57842d6a0434ac27ca3d1033ccc20 jdk-9+181 e93ed1a092409351c90b3a76d80b9aa8b44d5e6a jdk-10+20 bdb2dbc43ff065b74c2121bdfb0d6e1fa8684b73 jdk-10+21 +71337910df60ff2b62daf10357f553def25e2d0b jdk-10+22 From 4d9fb6df9ea6b73e0548d5cdfe4fcc8a4d741dda Mon Sep 17 00:00:00 2001 From: Abhijit Saha Date: Fri, 1 Sep 2017 14:13:15 +0000 Subject: [PATCH 85/98] Added tag jdk-10+22 for changeset 70b6df26bd98 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 9a42de845f4..b7b311f8847 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -446,3 +446,4 @@ f5789425c26cee0274d0e2ebabb21faf268f218f jdk-10+19 ea18d767c9ec50ea7f40bbe6cf7379d3538110f1 jdk-9+181 f7d596aa57aece4e5f473b1ac97e26cd0aebc647 jdk-10+20 dcd49f380d7504a49769c26d7bd756623cb9b828 jdk-10+21 +47872600e78b509a15490fe009986d4969794f56 jdk-10+22 From 48cbb18e3da3dfac2cb91ce490cf096d9e570e3c Mon Sep 17 00:00:00 2001 From: Abhijit Saha Date: Fri, 1 Sep 2017 14:13:16 +0000 Subject: [PATCH 86/98] Added tag jdk-10+22 for changeset 65a9d2608cde --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 6af10602b9b..c7ac5114de7 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -449,3 +449,4 @@ f112f294a89ea61260b645f450bd37fd6578a5e8 jdk-9+180 4f852cc3a1c998e78a989ba4667ffa9b867d9d01 jdk-9+181 1658a5e7d171e9c3cc2462fac2789ec63294ecca jdk-10+20 30ed8fb6a1d17e4065d07bc031cf2368aeca8d1e jdk-10+21 +c162c9e4c9c0976c8de44d2377a16a452bb99126 jdk-10+22 From ffc2232a73642084620122268e741ab5cf6de117 Mon Sep 17 00:00:00 2001 From: Abhijit Saha Date: Fri, 1 Sep 2017 14:13:42 +0000 Subject: [PATCH 87/98] Added tag jdk-10+22 for changeset 4ed4c4eba60c --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index bddd43860a8..d13251bbab4 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -437,3 +437,4 @@ bece58f762168a6615bd036626a572a647f6b507 jdk-9+180 47f8d75b8765ff8410ebc89619e537321cc10c32 jdk-9+181 9133969febb50ec683bfd79fc506771fb4f7de6c jdk-10+20 03d3d3c6bc5a06c1c763ef4615bb43672efe6b3f jdk-10+21 +bd933afd9e2ea9b3ce0ebf8deee5a7f9c7dda76c jdk-10+22 From fbc639617afbe6b36a8f2f1618b8a6886b2a8051 Mon Sep 17 00:00:00 2001 From: Abhijit Saha Date: Fri, 1 Sep 2017 14:14:44 +0000 Subject: [PATCH 88/98] Added tag jdk-10+22 for changeset 98e444a1b204 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index d441455648e..3d7b0a4b8c3 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -446,3 +446,4 @@ b561eeca30decc6258b4aca8bb23beffbb6e2f7d jdk-10+19 bd66ea2fdde3d60a73b5272263a7b8b0ca926a33 jdk-9+181 6256e94781f55e6f9e04eb284298d00eb9c5e106 jdk-10+20 4e08a69241eab6e7a67a819a7b4fe29e7398855d jdk-10+21 +83720375178f919700dfbbd90650f8c8e0cf34f2 jdk-10+22 From b874c676ac0ddf9a3cb26618baf2479609b5a881 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Fri, 1 Sep 2017 08:15:52 -0700 Subject: [PATCH 89/98] 8186751: Add ISO-8859-16 Charset support Reviewed-by: alanb --- jdk/make/data/charsetmapping/ISO_8859_16.map | 258 ++++++++++++++++++ jdk/make/data/charsetmapping/charsets | 14 + .../share/classes/sun/nio/cs/Unicode.java | 1 + .../sun/nio/cs/ext/GB18030.java.template | 3 +- .../Charset/CharsetContainmentTest.java | 9 +- .../charset/Charset/RegisteredCharsets.java | 20 +- jdk/test/sun/nio/cs/TestCharsetMapping.java | 2 +- 7 files changed, 297 insertions(+), 10 deletions(-) create mode 100644 jdk/make/data/charsetmapping/ISO_8859_16.map diff --git a/jdk/make/data/charsetmapping/ISO_8859_16.map b/jdk/make/data/charsetmapping/ISO_8859_16.map new file mode 100644 index 00000000000..e8449ec0277 --- /dev/null +++ b/jdk/make/data/charsetmapping/ISO_8859_16.map @@ -0,0 +1,258 @@ +# Confirmed with the mapping at +# http://ftp.unicode.org/Public/MAPPINGS/ISO8859/8859-16.TXT +0x00 U+0000 +0x01 U+0001 +0x02 U+0002 +0x03 U+0003 +0x04 U+0004 +0x05 U+0005 +0x06 U+0006 +0x07 U+0007 +0x08 U+0008 +0x09 U+0009 +0x0A U+000A +0x0B U+000B +0x0C U+000C +0x0D U+000D +0x0E U+000E +0x0F U+000F +0x10 U+0010 +0x11 U+0011 +0x12 U+0012 +0x13 U+0013 +0x14 U+0014 +0x15 U+0015 +0x16 U+0016 +0x17 U+0017 +0x18 U+0018 +0x19 U+0019 +0x1A U+001A +0x1B U+001B +0x1C U+001C +0x1D U+001D +0x1E U+001E +0x1F U+001F +0x20 U+0020 +0x21 U+0021 +0x22 U+0022 +0x23 U+0023 +0x24 U+0024 +0x25 U+0025 +0x26 U+0026 +0x27 U+0027 +0x28 U+0028 +0x29 U+0029 +0x2A U+002A +0x2B U+002B +0x2C U+002C +0x2D U+002D +0x2E U+002E +0x2F U+002F +0x30 U+0030 +0x31 U+0031 +0x32 U+0032 +0x33 U+0033 +0x34 U+0034 +0x35 U+0035 +0x36 U+0036 +0x37 U+0037 +0x38 U+0038 +0x39 U+0039 +0x3A U+003A +0x3B U+003B +0x3C U+003C +0x3D U+003D +0x3E U+003E +0x3F U+003F +0x40 U+0040 +0x41 U+0041 +0x42 U+0042 +0x43 U+0043 +0x44 U+0044 +0x45 U+0045 +0x46 U+0046 +0x47 U+0047 +0x48 U+0048 +0x49 U+0049 +0x4A U+004A +0x4B U+004B +0x4C U+004C +0x4D U+004D +0x4E U+004E +0x4F U+004F +0x50 U+0050 +0x51 U+0051 +0x52 U+0052 +0x53 U+0053 +0x54 U+0054 +0x55 U+0055 +0x56 U+0056 +0x57 U+0057 +0x58 U+0058 +0x59 U+0059 +0x5A U+005A +0x5B U+005B +0x5C U+005C +0x5D U+005D +0x5E U+005E +0x5F U+005F +0x60 U+0060 +0x61 U+0061 +0x62 U+0062 +0x63 U+0063 +0x64 U+0064 +0x65 U+0065 +0x66 U+0066 +0x67 U+0067 +0x68 U+0068 +0x69 U+0069 +0x6A U+006A +0x6B U+006B +0x6C U+006C +0x6D U+006D +0x6E U+006E +0x6F U+006F +0x70 U+0070 +0x71 U+0071 +0x72 U+0072 +0x73 U+0073 +0x74 U+0074 +0x75 U+0075 +0x76 U+0076 +0x77 U+0077 +0x78 U+0078 +0x79 U+0079 +0x7A U+007A +0x7B U+007B +0x7C U+007C +0x7D U+007D +0x7E U+007E +0x7F U+007F +0x80 U+0080 +0x81 U+0081 +0x82 U+0082 +0x83 U+0083 +0x84 U+0084 +0x85 U+0085 +0x86 U+0086 +0x87 U+0087 +0x88 U+0088 +0x89 U+0089 +0x8A U+008A +0x8B U+008B +0x8C U+008C +0x8D U+008D +0x8E U+008E +0x8F U+008F +0x90 U+0090 +0x91 U+0091 +0x92 U+0092 +0x93 U+0093 +0x94 U+0094 +0x95 U+0095 +0x96 U+0096 +0x97 U+0097 +0x98 U+0098 +0x99 U+0099 +0x9A U+009A +0x9B U+009B +0x9C U+009C +0x9D U+009D +0x9E U+009E +0x9F U+009F +0xA0 U+00A0 +0xA1 U+0104 +0xA2 U+0105 +0xA3 U+0141 +0xA4 U+20AC +0xA5 U+201E +0xA6 U+0160 +0xA7 U+00A7 +0xA8 U+0161 +0xA9 U+00A9 +0xAA U+0218 +0xAB U+00AB +0xAC U+0179 +0xAD U+00AD +0xAE U+017A +0xAF U+017B +0xB0 U+00B0 +0xB1 U+00B1 +0xB2 U+010C +0xB3 U+0142 +0xB4 U+017D +0xB5 U+201D +0xB6 U+00B6 +0xB7 U+00B7 +0xB8 U+017E +0xB9 U+010D +0xBA U+0219 +0xBB U+00BB +0xBC U+0152 +0xBD U+0153 +0xBE U+0178 +0xBF U+017C +0xC0 U+00C0 +0xC1 U+00C1 +0xC2 U+00C2 +0xC3 U+0102 +0xC4 U+00C4 +0xC5 U+0106 +0xC6 U+00C6 +0xC7 U+00C7 +0xC8 U+00C8 +0xC9 U+00C9 +0xCA U+00CA +0xCB U+00CB +0xCC U+00CC +0xCD U+00CD +0xCE U+00CE +0xCF U+00CF +0xD0 U+0110 +0xD1 U+0143 +0xD2 U+00D2 +0xD3 U+00D3 +0xD4 U+00D4 +0xD5 U+0150 +0xD6 U+00D6 +0xD7 U+015A +0xD8 U+0170 +0xD9 U+00D9 +0xDA U+00DA +0xDB U+00DB +0xDC U+00DC +0xDD U+0118 +0xDE U+021A +0xDF U+00DF +0xE0 U+00E0 +0xE1 U+00E1 +0xE2 U+00E2 +0xE3 U+0103 +0xE4 U+00E4 +0xE5 U+0107 +0xE6 U+00E6 +0xE7 U+00E7 +0xE8 U+00E8 +0xE9 U+00E9 +0xEA U+00EA +0xEB U+00EB +0xEC U+00EC +0xED U+00ED +0xEE U+00EE +0xEF U+00EF +0xF0 U+0111 +0xF1 U+0144 +0xF2 U+00F2 +0xF3 U+00F3 +0xF4 U+00F4 +0xF5 U+0151 +0xF6 U+00F6 +0xF7 U+015B +0xF8 U+0171 +0xF9 U+00F9 +0xFA U+00FA +0xFB U+00FB +0xFC U+00FC +0xFD U+0119 +0xFE U+021B +0xFF U+00FF diff --git a/jdk/make/data/charsetmapping/charsets b/jdk/make/data/charsetmapping/charsets index 3582e161342..24d5962bc49 100644 --- a/jdk/make/data/charsetmapping/charsets +++ b/jdk/make/data/charsetmapping/charsets @@ -257,6 +257,8 @@ charset ISO-8859-15 ISO_8859_15 hisname ISO8859_15 ascii true alias ISO_8859-15 # IANA alias + alias Latin-9 + alias csISO885915 alias 8859_15 # Other aliases alias ISO-8859-15 alias ISO8859_15 @@ -272,6 +274,18 @@ charset ISO-8859-15 ISO_8859_15 alias csISOlatin9 alias ISO8859_15_FDIS +charset ISO-8859-16 ISO_8859_16 + package sun.nio.cs + type sbcs + hisname ISO8859_16 + ascii true + alias iso-ir-226 + alias ISO_8859-16:2001 + alias ISO_8859-16 + alias latin10 + alias l10 + alias csISO885916 + charset KOI8-R KOI8_R package sun.nio.cs type sbcs diff --git a/jdk/src/java.base/share/classes/sun/nio/cs/Unicode.java b/jdk/src/java.base/share/classes/sun/nio/cs/Unicode.java index ed8d6770265..54802b30947 100644 --- a/jdk/src/java.base/share/classes/sun/nio/cs/Unicode.java +++ b/jdk/src/java.base/share/classes/sun/nio/cs/Unicode.java @@ -38,6 +38,7 @@ abstract class Unicode extends Charset return ((cs instanceof US_ASCII) || (cs instanceof ISO_8859_1) || (cs instanceof ISO_8859_15) + || (cs instanceof ISO_8859_16) || (cs instanceof MS1252) || (cs instanceof UTF_8) || (cs instanceof UTF_16) diff --git a/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/GB18030.java.template b/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/GB18030.java.template index e993cf7f6c2..687b100fc27 100644 --- a/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/GB18030.java.template +++ b/jdk/src/jdk.charsets/share/classes/sun/nio/cs/ext/GB18030.java.template @@ -60,11 +60,12 @@ public class GB18030 || (cs.name().equals("ISO-8859-8")) || (cs.name().equals("ISO-8859-9")) || (cs.name().equals("ISO-8859-13")) + || (cs.name().equals("ISO-8859-15")) + || (cs.name().equals("ISO-8859-16")) || (cs.name().equals("UTF-8")) || (cs.name().equals("UTF-16")) || (cs.name().equals("UTF-16LE")) || (cs.name().equals("UTF-16BE")) - || (cs.name().equals("ISO-8859-15")) || (cs.name().equals("windows-1251")) || (cs.name().equals("windows-1252")) || (cs.name().equals("windows-1253")) diff --git a/jdk/test/java/nio/charset/Charset/CharsetContainmentTest.java b/jdk/test/java/nio/charset/Charset/CharsetContainmentTest.java index a3983f22ac2..7e763f7750c 100644 --- a/jdk/test/java/nio/charset/Charset/CharsetContainmentTest.java +++ b/jdk/test/java/nio/charset/Charset/CharsetContainmentTest.java @@ -32,9 +32,9 @@ import java.nio.charset.*; public class CharsetContainmentTest { static String[] encodings = { "US-ASCII", "UTF-16", "UTF-16BE", "UTF-16LE", "UTF-8", - "windows-1252", "ISO-8859-1", "ISO-8859-15", "ISO-8859-2", - "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", - "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", "ISO-8859-13", + "windows-1252", "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", + "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", + "ISO-8859-8", "ISO-8859-9", "ISO-8859-13", "ISO-8859-15", "ISO-8859-16", "ISO-2022-JP", "ISO-2022-KR", // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder @@ -57,7 +57,6 @@ public class CharsetContainmentTest { encodings, {"US-ASCII", "windows-1252"}, {"US-ASCII", "ISO-8859-1"}, - {"US-ASCII", "ISO-8859-15"}, {"US-ASCII", "ISO-8859-2"}, {"US-ASCII", "ISO-8859-3"}, {"US-ASCII", "ISO-8859-4"}, @@ -67,6 +66,8 @@ public class CharsetContainmentTest { {"US-ASCII", "ISO-8859-8"}, {"US-ASCII", "ISO-8859-9"}, {"US-ASCII", "ISO-8859-13"}, + {"US-ASCII", "ISO-8859-15"}, + {"US-ASCII", "ISO-8859-16"}, {"ISO-2022-JP"}, {"ISO-2022-KR"}, // Temporarily remove ISO-2022-CN-* charsets until full encoder/decoder diff --git a/jdk/test/java/nio/charset/Charset/RegisteredCharsets.java b/jdk/test/java/nio/charset/Charset/RegisteredCharsets.java index c501eb852a5..a943de87b07 100644 --- a/jdk/test/java/nio/charset/Charset/RegisteredCharsets.java +++ b/jdk/test/java/nio/charset/Charset/RegisteredCharsets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -23,7 +23,7 @@ /* @test * @bug 4473201 4696726 4652234 4482298 4784385 4966197 4267354 5015668 - 6911753 8071447 + 6911753 8071447 8186751 * @summary Check that registered charsets are actually registered * @modules jdk.charsets */ @@ -42,7 +42,8 @@ public class RegisteredCharsets { "ISO-8859-1", "ISO-8859-2", "ISO-8859-3", "ISO-8859-4", "ISO-8859-5", "ISO-8859-6", "ISO-8859-7", "ISO-8859-8", "ISO-8859-9", - "ISO-8859-13", "ISO-8859-15", "windows-1251", + "ISO-8859-13", "ISO-8859-15", "ISO-8859-16", + "windows-1251", "windows-1252", "windows-1253", "windows-1254", "windows-1255", "windows-1256", "windows-31j", "Shift_JIS", "JIS_X0201", "JIS_X0212-1990", @@ -416,6 +417,8 @@ public class RegisteredCharsets { new String[] { // IANA alias "ISO_8859-15", + "Latin-9", + "csISO885915", // JDK historical aliases "8859_15", "ISO-8859-15", @@ -432,9 +435,18 @@ public class RegisteredCharsets { "csISOlatin0", "csISOlatin9", "ISO8859_15_FDIS" - }); + aliasCheck("ISO-8859-16", + new String[] { + "iso-ir-226", + "ISO_8859-16:2001", + "ISO_8859-16", + "latin10", + "l10", + "csISO885916" + }); + aliasCheck("JIS_X0212-1990", new String[] { "iso-ir-159", diff --git a/jdk/test/sun/nio/cs/TestCharsetMapping.java b/jdk/test/sun/nio/cs/TestCharsetMapping.java index 83f1888c065..ba24651daa6 100644 --- a/jdk/test/sun/nio/cs/TestCharsetMapping.java +++ b/jdk/test/sun/nio/cs/TestCharsetMapping.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 8186801 + * @bug 8186801 8186751 * @summary Test the charset mappings */ From b85726c71e221f103321eaf7eaff86be52f1af7c Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Fri, 1 Sep 2017 18:18:09 +0100 Subject: [PATCH 90/98] 8187044: HttpClient ConnectionPool may spawn several concurrent CacheCleaner and prevent early GC of HttpClient Fixes CacheCleaner creation logic in ConnectionPool. Reviewed-by: chegar --- .../jdk/incubator/http/ConnectionPool.java | 94 +++++-- .../java/net/httpclient/whitebox/Driver.java | 5 +- .../incubator/http/ConnectionPoolTest.java | 252 ++++++++++++++++++ 3 files changed, 331 insertions(+), 20 deletions(-) create mode 100644 jdk/test/java/net/httpclient/whitebox/jdk.incubator.httpclient/jdk/incubator/http/ConnectionPoolTest.java diff --git a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ConnectionPool.java b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ConnectionPool.java index 0e3e6121889..df627809111 100644 --- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ConnectionPool.java +++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/ConnectionPool.java @@ -25,11 +25,14 @@ package jdk.incubator.http; +import java.lang.ref.WeakReference; import java.net.InetSocketAddress; import java.util.HashMap; import java.util.LinkedList; import java.util.ListIterator; import java.util.Objects; +import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import jdk.incubator.http.internal.common.Utils; /** @@ -37,6 +40,21 @@ import jdk.incubator.http.internal.common.Utils; */ final class ConnectionPool { + // These counters are used to distribute ids for debugging + // The ACTIVE_CLEANER_COUNTER will tell how many CacheCleaner + // are active at a given time. It will increase when a new + // CacheCleaner is started and decrease when it exits. + static final AtomicLong ACTIVE_CLEANER_COUNTER = new AtomicLong(); + // The POOL_IDS_COUNTER increases each time a new ConnectionPool + // is created. It may wrap and become negative but will never be + // decremented. + static final AtomicLong POOL_IDS_COUNTER = new AtomicLong(); + // The cleanerCounter is used to name cleaner threads within a + // a connection pool, and increments monotically. + // It may wrap and become negative but will never be + // decremented. + final AtomicLong cleanerCounter = new AtomicLong(); + static final long KEEP_ALIVE = Utils.getIntegerNetProperty( "jdk.httpclient.keepalive.timeout", 1200); // seconds @@ -44,7 +62,12 @@ final class ConnectionPool { final HashMap> plainPool; final HashMap> sslPool; - CacheCleaner cleaner; + // A monotically increasing id for this connection pool. + // It may be negative (that's OK) + // Mostly used for debugging purposes when looking at thread dumps. + // Global scope. + final long poolID = POOL_IDS_COUNTER.incrementAndGet(); + final AtomicReference cleanerRef; /** * Entries in connection pool are keyed by destination address and/or @@ -105,6 +128,7 @@ final class ConnectionPool { plainPool = new HashMap<>(); sslPool = new HashMap<>(); expiryList = new LinkedList<>(); + cleanerRef = new AtomicReference<>(); } void start() { @@ -143,7 +167,7 @@ final class ConnectionPool { findConnection(CacheKey key, HashMap> pool) { LinkedList l = pool.get(key); - if (l == null || l.size() == 0) { + if (l == null || l.isEmpty()) { return null; } else { HttpConnection c = l.removeFirst(); @@ -175,19 +199,36 @@ final class ConnectionPool { l.add(c); } - // only runs while entries exist in cache + static String makeCleanerName(long poolId, long cleanerId) { + return "HTTP-Cache-cleaner-" + poolId + "-" + cleanerId; + } - final class CacheCleaner extends Thread { + // only runs while entries exist in cache + final static class CacheCleaner extends Thread { volatile boolean stopping; + // A monotically increasing id. May wrap and become negative (that's OK) + // Mostly used for debugging purposes when looking at thread dumps. + // Scoped per connection pool. + final long cleanerID; + // A reference to the owning ConnectionPool. + // This reference's referent may become null if the HttpClientImpl + // that owns this pool is GC'ed. + final WeakReference ownerRef; - CacheCleaner() { - super(null, null, "HTTP-Cache-cleaner", 0, false); + CacheCleaner(ConnectionPool owner) { + this(owner, owner.cleanerCounter.incrementAndGet()); + } + + CacheCleaner(ConnectionPool owner, long cleanerID) { + super(null, null, makeCleanerName(owner.poolID, cleanerID), 0, false); + this.cleanerID = cleanerID; + this.ownerRef = new WeakReference<>(owner); setDaemon(true); } synchronized boolean stopping() { - return stopping; + return stopping || ownerRef.get() == null; } synchronized void stopCleaner() { @@ -196,11 +237,19 @@ final class ConnectionPool { @Override public void run() { - while (!stopping()) { - try { - Thread.sleep(3000); - } catch (InterruptedException e) {} - cleanCache(); + ACTIVE_CLEANER_COUNTER.incrementAndGet(); + try { + while (!stopping()) { + try { + Thread.sleep(3000); + } catch (InterruptedException e) {} + ConnectionPool owner = ownerRef.get(); + if (owner == null) return; + owner.cleanCache(this); + owner = null; + } + } finally { + ACTIVE_CLEANER_COUNTER.decrementAndGet(); } } } @@ -217,13 +266,15 @@ final class ConnectionPool { return; } } - if (expiryList.isEmpty()) { + CacheCleaner cleaner = this.cleanerRef.get(); + if (expiryList.isEmpty() && cleaner != null) { + this.cleanerRef.compareAndSet(cleaner, null); cleaner.stopCleaner(); - cleaner = null; + cleaner.interrupt(); } } - private void cleanCache() { + private void cleanCache(CacheCleaner cleaner) { long now = System.currentTimeMillis() / 1000; LinkedList closelist = new LinkedList<>(); @@ -242,6 +293,10 @@ final class ConnectionPool { } } } + if (expiryList.isEmpty() && cleaner != null) { + this.cleanerRef.compareAndSet(cleaner, null); + cleaner.stopCleaner(); + } } for (HttpConnection c : closelist) { //System.out.println ("KAC: closing " + c); @@ -252,10 +307,13 @@ final class ConnectionPool { private synchronized void addToExpiryList(HttpConnection conn) { long now = System.currentTimeMillis() / 1000; long then = now + KEEP_ALIVE; - if (expiryList.isEmpty()) { - cleaner = new CacheCleaner(); - cleaner.start(); + CacheCleaner cleaner = new CacheCleaner(this); + if (this.cleanerRef.compareAndSet(null, cleaner)) { + cleaner.start(); + } + expiryList.add(new ExpiryEntry(conn, then)); + return; } ListIterator li = expiryList.listIterator(); diff --git a/jdk/test/java/net/httpclient/whitebox/Driver.java b/jdk/test/java/net/httpclient/whitebox/Driver.java index 5b9e3438989..00f5b12bf94 100644 --- a/jdk/test/java/net/httpclient/whitebox/Driver.java +++ b/jdk/test/java/net/httpclient/whitebox/Driver.java @@ -23,9 +23,10 @@ /* * @test - * @bug 8151299 8164704 - * @modules jdk.incubator.httpclient + * @bug 8151299 8164704 8187044 + * @modules jdk.incubator.httpclient java.management * @run testng jdk.incubator.httpclient/jdk.incubator.http.SelectorTest * @run testng jdk.incubator.httpclient/jdk.incubator.http.RawChannelTest * @run testng jdk.incubator.httpclient/jdk.incubator.http.ResponseHeadersTest + * @run main/othervm --add-reads jdk.incubator.httpclient=java.management jdk.incubator.httpclient/jdk.incubator.http.ConnectionPoolTest */ diff --git a/jdk/test/java/net/httpclient/whitebox/jdk.incubator.httpclient/jdk/incubator/http/ConnectionPoolTest.java b/jdk/test/java/net/httpclient/whitebox/jdk.incubator.httpclient/jdk/incubator/http/ConnectionPoolTest.java new file mode 100644 index 00000000000..19e815fa286 --- /dev/null +++ b/jdk/test/java/net/httpclient/whitebox/jdk.incubator.httpclient/jdk/incubator/http/ConnectionPoolTest.java @@ -0,0 +1,252 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.incubator.http; + +import java.io.IOException; +import java.lang.management.ManagementFactory; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.net.Authenticator; +import java.net.CookieManager; +import java.net.InetSocketAddress; +import java.net.ProxySelector; +import java.nio.ByteBuffer; +import java.nio.channels.SocketChannel; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLParameters; +import jdk.incubator.http.internal.common.ByteBufferReference; + +/** + * @summary Verifies that the ConnectionPool won't prevent an HttpClient + * from being GC'ed. Verifies that the ConnectionPool has at most + * one CacheCleaner thread running. + * @bug 8187044 + * @author danielfuchs + */ +public class ConnectionPoolTest { + + static long getActiveCleaners() throws ClassNotFoundException { + // ConnectionPool.ACTIVE_CLEANER_COUNTER.get() + // ConnectionPoolTest.class.getModule().addReads( + // Class.forName("java.lang.management.ManagementFactory").getModule()); + return java.util.stream.Stream.of(ManagementFactory.getThreadMXBean() + .dumpAllThreads(false, false)) + .filter(t -> t.getThreadName().startsWith("HTTP-Cache-cleaner")) + .count(); + } + + public static void main(String[] args) throws Exception { + testCacheCleaners(); + } + + public static void testCacheCleaners() throws Exception { + ConnectionPool pool = new ConnectionPool(); + HttpClient client = new HttpClientStub(pool); + InetSocketAddress proxy = InetSocketAddress.createUnresolved("bar", 80); + System.out.println("Adding 10 connections to pool"); + for (int i=0; i<10; i++) { + InetSocketAddress addr = InetSocketAddress.createUnresolved("foo"+i, 80); + HttpConnection c1 = new HttpConnectionStub(client, addr, proxy, true); + pool.returnToPool(c1); + } + while (getActiveCleaners() == 0) { + System.out.println("Waiting for cleaner to start"); + Thread.sleep(10); + } + System.out.println("Active CacheCleaners: " + getActiveCleaners()); + if (getActiveCleaners() > 1) { + throw new RuntimeException("Too many CacheCleaner active: " + + getActiveCleaners()); + } + System.out.println("Removing 9 connections from pool"); + for (int i=0; i<9; i++) { + InetSocketAddress addr = InetSocketAddress.createUnresolved("foo"+i, 80); + HttpConnection c2 = pool.getConnection(true, addr, proxy); + if (c2 == null) { + throw new RuntimeException("connection not found for " + addr); + } + } + System.out.println("Active CacheCleaners: " + getActiveCleaners()); + if (getActiveCleaners() != 1) { + throw new RuntimeException("Wrong number of CacheCleaner active: " + + getActiveCleaners()); + } + System.out.println("Removing last connection from pool"); + for (int i=9; i<10; i++) { + InetSocketAddress addr = InetSocketAddress.createUnresolved("foo"+i, 80); + HttpConnection c2 = pool.getConnection(true, addr, proxy); + if (c2 == null) { + throw new RuntimeException("connection not found for " + addr); + } + } + System.out.println("Active CacheCleaners: " + getActiveCleaners() + + " (may be 0 or may still be 1)"); + if (getActiveCleaners() > 1) { + throw new RuntimeException("Too many CacheCleaner active: " + + getActiveCleaners()); + } + InetSocketAddress addr = InetSocketAddress.createUnresolved("foo", 80); + HttpConnection c = new HttpConnectionStub(client, addr, proxy, true); + System.out.println("Adding/Removing one connection from pool 20 times in a loop"); + for (int i=0; i<20; i++) { + pool.returnToPool(c); + HttpConnection c2 = pool.getConnection(true, addr, proxy); + if (c2 == null) { + throw new RuntimeException("connection not found for " + addr); + } + if (c2 != c) { + throw new RuntimeException("wrong connection found for " + addr); + } + } + if (getActiveCleaners() > 1) { + throw new RuntimeException("Too many CacheCleaner active: " + + getActiveCleaners()); + } + ReferenceQueue queue = new ReferenceQueue<>(); + WeakReference weak = new WeakReference<>(client, queue); + System.gc(); + Reference.reachabilityFence(pool); + client = null; pool = null; c = null; + while (true) { + long cleaners = getActiveCleaners(); + System.out.println("Waiting for GC to release stub HttpClient;" + + " active cache cleaners: " + cleaners); + System.gc(); + Reference ref = queue.remove(1000); + if (ref == weak) { + System.out.println("Stub HttpClient GC'ed"); + break; + } + } + while (getActiveCleaners() > 0) { + System.out.println("Waiting for CacheCleaner to stop"); + Thread.sleep(1000); + } + System.out.println("Active CacheCleaners: " + + getActiveCleaners()); + + if (getActiveCleaners() > 0) { + throw new RuntimeException("Too many CacheCleaner active: " + + getActiveCleaners()); + } + } + static T error() { + throw new InternalError("Should not reach here: wrong test assumptions!"); + } + + // Emulates an HttpConnection that has a strong reference to its HttpClient. + static class HttpConnectionStub extends HttpConnection { + + public HttpConnectionStub(HttpClient client, + InetSocketAddress address, + InetSocketAddress proxy, + boolean secured) { + super(address, null); + this.key = ConnectionPool.cacheKey(address, proxy); + this.address = address; + this.proxy = proxy; + this.secured = secured; + this.client = client; + } + + InetSocketAddress proxy; + InetSocketAddress address; + boolean secured; + ConnectionPool.CacheKey key; + HttpClient client; + + // All these return something + @Override boolean connected() {return true;} + @Override boolean isSecure() {return secured;} + @Override boolean isProxied() {return proxy!=null;} + @Override ConnectionPool.CacheKey cacheKey() {return key;} + @Override public void close() {} + @Override void shutdownInput() throws IOException {} + @Override void shutdownOutput() throws IOException {} + public String toString() { + return "HttpConnectionStub: " + address + " proxy: " + proxy; + } + + // All these throw errors + @Override + public void connect() throws IOException, InterruptedException {error();} + @Override public CompletableFuture connectAsync() {return error();} + @Override SocketChannel channel() {return error();} + @Override void flushAsync() throws IOException {error();} + @Override + protected ByteBuffer readImpl() throws IOException {return error();} + @Override CompletableFuture whenReceivingResponse() {return error();} + @Override + long write(ByteBuffer[] buffers, int start, int number) throws IOException { + throw (Error)error(); + } + @Override + long write(ByteBuffer buffer) throws IOException {throw (Error)error();} + @Override + void writeAsync(ByteBufferReference[] buffers) throws IOException { + error(); + } + @Override + void writeAsyncUnordered(ByteBufferReference[] buffers) + throws IOException { + error(); + } + } + // Emulates an HttpClient that has a strong reference to its connection pool. + static class HttpClientStub extends HttpClient { + public HttpClientStub(ConnectionPool pool) { + this.pool = pool; + } + final ConnectionPool pool; + @Override public Optional cookieManager() {return error();} + @Override public HttpClient.Redirect followRedirects() {return error();} + @Override public Optional proxy() {return error();} + @Override public SSLContext sslContext() {return error();} + @Override public Optional sslParameters() {return error();} + @Override public Optional authenticator() {return error();} + @Override public HttpClient.Version version() {return HttpClient.Version.HTTP_1_1;} + @Override public Executor executor() {return error();} + @Override + public HttpResponse send(HttpRequest req, + HttpResponse.BodyHandler responseBodyHandler) + throws IOException, InterruptedException { + return error(); + } + @Override + public CompletableFuture> sendAsync(HttpRequest req, + HttpResponse.BodyHandler responseBodyHandler) { + return error(); + } + @Override + public CompletableFuture sendAsync(HttpRequest req, + HttpResponse.MultiProcessor multiProcessor) { + return error(); + } + } + +} From 904f0938657a80ba4f45dc5a39cb1bc7a190e09c Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 1 Sep 2017 11:48:27 -0700 Subject: [PATCH 91/98] 8186924: Fix accessibility and other HTML issues in java.corba module Reviewed-by: mchung --- .../share/classes/org/omg/CORBA/ORB.java | 12 +- .../share/classes/org/omg/CORBA/TCKind.java | 68 ++--- .../org/omg/CORBA/doc-files/compliance.html | 4 +- .../omg/CORBA/doc-files/generatedfiles.html | 6 +- .../omg/PortableInterceptor/Interceptors.idl | 283 ++++++++++-------- 5 files changed, 195 insertions(+), 178 deletions(-) diff --git a/corba/src/java.corba/share/classes/org/omg/CORBA/ORB.java b/corba/src/java.corba/share/classes/org/omg/CORBA/ORB.java index eefcfba10d2..1139c11cc17 100644 --- a/corba/src/java.corba/share/classes/org/omg/CORBA/ORB.java +++ b/corba/src/java.corba/share/classes/org/omg/CORBA/ORB.java @@ -85,15 +85,15 @@ import java.security.PrivilegedAction; * three {@code init} methods. Two of the three methods use the properties * (associations of a name with a value) shown in the * table below.
- * - * + *
Standard Java CORBA Properties:
+ * * - * + * * - * - * + * + * * - * + * * * *
Standard Java CORBA Properties
Property Name Property Value
Property Name Property Value
org.omg.CORBA.ORBClass
org.omg.CORBA.ORBClassclass name of an ORB implementation
org.omg.CORBA.ORBSingletonClass
org.omg.CORBA.ORBSingletonClassclass name of the ORB returned by {@code init()}
diff --git a/corba/src/java.corba/share/classes/org/omg/CORBA/TCKind.java b/corba/src/java.corba/share/classes/org/omg/CORBA/TCKind.java index 60e89a82702..79c7039b28d 100644 --- a/corba/src/java.corba/share/classes/org/omg/CORBA/TCKind.java +++ b/corba/src/java.corba/share/classes/org/omg/CORBA/TCKind.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -237,175 +237,175 @@ public class TCKind { /** * The TCKind constant whose value field is - * initialized with TCKind._tk_null. + * initialized with {@code TCKind._tk_null}. */ public static final TCKind tk_null = new TCKind(_tk_null); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_void. + * initialized with {@code TCKind._tk_void}. */ public static final TCKind tk_void = new TCKind(_tk_void); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_short. + * initialized with {@code TCKind._tk_short}. */ public static final TCKind tk_short = new TCKind(_tk_short); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_long. + * initialized with {@code TCKind._tk_long}. */ public static final TCKind tk_long = new TCKind(_tk_long); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_ushort. + * initialized with {@code TCKind._tk_ushort}. */ public static final TCKind tk_ushort = new TCKind(_tk_ushort); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_ulong. + * initialized with {@code TCKind._tk_ulong}. */ public static final TCKind tk_ulong = new TCKind(_tk_ulong); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_float. + * initialized with {@code TCKind._tk_float}. */ public static final TCKind tk_float = new TCKind(_tk_float); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_double. + * initialized with {@code TCKind._tk_double}. */ public static final TCKind tk_double = new TCKind(_tk_double); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_boolean. + * initialized with {@code TCKind._tk_boolean}. */ public static final TCKind tk_boolean = new TCKind(_tk_boolean); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_char. + * initialized with {@code TCKind._tk_char}. */ public static final TCKind tk_char = new TCKind(_tk_char); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_octet. + * initialized with {@code TCKind._tk_octet}. */ public static final TCKind tk_octet = new TCKind(_tk_octet); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_any. + * initialized with {@code TCKind._tk_any}. */ public static final TCKind tk_any = new TCKind(_tk_any); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_TypeCode. + * initialized with {@code TCKind._tk_TypeCode}. */ public static final TCKind tk_TypeCode = new TCKind(_tk_TypeCode); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_Principal. + * initialized with {@code TCKind._tk_Principal}. */ public static final TCKind tk_Principal = new TCKind(_tk_Principal); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_objref. + * initialized with {@code TCKind._tk_objref}. */ public static final TCKind tk_objref = new TCKind(_tk_objref); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_struct. + * initialized with {@code TCKind._tk_struct}. */ public static final TCKind tk_struct = new TCKind(_tk_struct); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_union. + * initialized with {@code TCKind._tk_union}. */ public static final TCKind tk_union = new TCKind(_tk_union); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_enum. + * initialized with {@code TCKind._tk_enum}. */ public static final TCKind tk_enum = new TCKind(_tk_enum); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_string. + * initialized with {@code TCKind._tk_string}. */ public static final TCKind tk_string = new TCKind(_tk_string); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_sequence. + * initialized with {@code TCKind._tk_sequence}. */ public static final TCKind tk_sequence = new TCKind(_tk_sequence); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_array. + * initialized with {@code TCKind._tk_array}. */ public static final TCKind tk_array = new TCKind(_tk_array); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_alias. + * initialized with {@code TCKind._tk_alias}. */ public static final TCKind tk_alias = new TCKind(_tk_alias); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_except. + * initialized with {@code TCKind._tk_except}. */ public static final TCKind tk_except = new TCKind(_tk_except); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_longlong. + * initialized with {@code TCKind._tk_longlong}. */ public static final TCKind tk_longlong = new TCKind(_tk_longlong); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_ulonglong. + * initialized with {@code TCKind._tk_ulonglong}. */ public static final TCKind tk_ulonglong = new TCKind(_tk_ulonglong); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_longdouble. + * initialized with {@code TCKind._tk_longdouble}. */ public static final TCKind tk_longdouble = new TCKind(_tk_longdouble); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_wchar. + * initialized with {@code TCKind._tk_wchar}. */ public static final TCKind tk_wchar = new TCKind(_tk_wchar); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_wstring. + * initialized with {@code TCKind._tk_wstring}. */ public static final TCKind tk_wstring = new TCKind(_tk_wstring); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_fixed. + * initialized with {@code TCKind._tk_fixed}. */ public static final TCKind tk_fixed = new TCKind(_tk_fixed); @@ -413,26 +413,26 @@ public class TCKind { /** * The TCKind constant whose value field is - * initialized with TCKind._tk_value. + * initialized with {@code TCKind._tk_value}. */ public static final TCKind tk_value = new TCKind(_tk_value); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_value_box. + * initialized with {@code TCKind._tk_value_box}. */ public static final TCKind tk_value_box = new TCKind(_tk_value_box); // orbos 98-01-18: Objects By Value -- end /** * The TCKind constant whose value field is - * initialized with TCKind._tk_native. + * initialized with {@code TCKind._tk_native}. */ public static final TCKind tk_native = new TCKind(_tk_native); /** * The TCKind constant whose value field is - * initialized with TCKind._tk_abstract_interface. + * initialized with {@code TCKind._tk_abstract_interface}. */ public static final TCKind tk_abstract_interface = new TCKind(_tk_abstract_interface); diff --git a/corba/src/java.corba/share/classes/org/omg/CORBA/doc-files/compliance.html b/corba/src/java.corba/share/classes/org/omg/CORBA/doc-files/compliance.html index d78aa74f2d4..bd0a50c4b24 100644 --- a/corba/src/java.corba/share/classes/org/omg/CORBA/doc-files/compliance.html +++ b/corba/src/java.corba/share/classes/org/omg/CORBA/doc-files/compliance.html @@ -1,10 +1,10 @@ - + Official Specifications for CORBA support in Java[tm] SE 6 - +

Official Specifications for CORBA support in Java[tm] SE 6

diff --git a/corba/src/java.corba/share/classes/org/omg/CORBA/doc-files/generatedfiles.html b/corba/src/java.corba/share/classes/org/omg/CORBA/doc-files/generatedfiles.html index 39aa88463cf..9ad20165829 100644 --- a/corba/src/java.corba/share/classes/org/omg/CORBA/doc-files/generatedfiles.html +++ b/corba/src/java.corba/share/classes/org/omg/CORBA/doc-files/generatedfiles.html @@ -1,17 +1,17 @@ - + IDL-to-Java Generated Files - +

IDL-to-Java Generated Files

The files that are generated by the IDL-to-Java compiler, in accordance with the IDL-to-Java Language Mapping Specification, -which is implemented in JavaTM SE 6 +which is implemented in Java™ SE 6 according the compliance document. diff --git a/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/Interceptors.idl b/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/Interceptors.idl index ca2612e5719..13cf409837a 100644 --- a/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/Interceptors.idl +++ b/corba/src/java.corba/share/classes/org/omg/PortableInterceptor/Interceptors.idl @@ -584,7 +584,7 @@ module PortableInterceptor { * Shows the validity of each attribute or operation * * - *   + * * send_request * send_poll * receive_reply @@ -592,182 +592,176 @@ module PortableInterceptor { * receive_other * * - * + * * * - * Inherited from RequestInfo: + * Inherited from RequestInfo: * * - *

request_id

+ * request_id * yes * yes * yes * yes * yes * - *

operation

+ * operation * yes * yes * yes * yes * yes * - *

arguments

+ * arguments * yes1 * no * yes * no * no * - *

exceptions

+ * exceptions * yes * no * yes * yes * yes * - *

contexts

+ * contexts * yes * no * yes * yes * yes * - *

operation_context

+ * operation_context * yes * no * yes * yes - * yes - * + * yes * - *

result

+ * result * no * no * yes * no - * no - * + * no * - *

response_expected

+ * response_expected * yes * yes * yes * yes * yes * - *

sync_scope

+ * sync_scope * yes * no * yes * yes - * yes - * + * yes * - *

reply_status

+ * reply_status * no * no * yes * yes * yes * - *

forward_reference

+ * forward_reference * no * no * no * no - * yes2 - * + * yes2 * - *

get_slot

+ * get_slot * yes * yes * yes * yes * yes * - *

get_request_service_context

+ * get_request_service_context * yes * no * yes * yes * yes * - *

get_reply_service_context

+ * get_reply_service_context * no * no * yes * yes - * yes - * + * yes * * - * ClientRequestInfo-specific: + * ClientRequestInfo-specific: * * - *

target

+ * target * yes * yes * yes * yes * yes * - *

effective_target

+ * effective_target * yes * yes * yes * yes - * yes - * + * yes * - *

effective_profile

+ * effective_profile * yes * yes * yes * yes * yes * - *

received_exception

+ * received_exception * no * no * no * yes * no * - *

received_exception_id

+ * received_exception_id * no * no * no * yes * no * - *

get_effective_component

+ * get_effective_component * yes * no * yes * yes * yes * - *

get_effective_components

+ * get_effective_components * yes * no * yes * yes * yes * - *

get_request_policy

+ * get_request_policy * yes * no * yes * yes * yes * - *

add_request_service_context

- * yes - * no - * no - * no - * no + * add_request_service_context + * yes + * no + * no + * no + * no * * * @@ -940,7 +934,7 @@ module PortableInterceptor { * Shows the validity of each attribute or operation * * - *   + * * receive_request_
service_contexts * receive_request * send_reply @@ -948,28 +942,28 @@ module PortableInterceptor { * send_other * * - * + * * * * - * Inherited from RequestInfo: + * Inherited from RequestInfo: * * - *

request_id

+ * request_id * yes * yes * yes * yes * yes * - *

operation

+ * operation * yes * yes * yes * yes * yes * - *

arguments

+ * arguments * no * yes1 * yes @@ -977,21 +971,21 @@ module PortableInterceptor { * no2 * * - *

exceptions

+ * exceptions * no * yes * yes * yes * yes * - *

contexts

+ * contexts * no * yes * yes * yes * yes * - *

operation_context

+ * operation_context * no * yes * yes @@ -999,7 +993,7 @@ module PortableInterceptor { * no * * - *

result

+ * result * no * no * yes @@ -1007,113 +1001,136 @@ module PortableInterceptor { * no * * - *

response_expected

+ * response_expected * yes * yes * yes * yes * yes * - *

sync_scope

+ * sync_scope * yes * yes * yes * yes * yes * - * request_id - * yes yes yes yes yes + * reply_status + * no + * no + * yes + * yes + * yes * - * operation - * yes yes yes yes yes + * forward_reference + * no + * no + * no + * no + * yes2 * - * arguments - * no yes1 - * yes no2 - * no2 - * + * get_slot + * yes + * yes + * yes + * yes + * yes * - * exceptions - * no yes yes yes yes + * get_request_service_context + * yes + * no + * yes + * yes + * yes * - * contexts - * no yes yes yes yes + * get_reply_service_context + * no + * no + * yes + * yes + * yes * - * operation_context - * no yes yes no no + * + * ServerRequestInfo-specific: + * * - * result - * no no yes no no + * sending_exception + * no + * no + * no + * yes + * no * - * response_expected - * yes yes yes yes yes + * object_id + * no + * yes + * yes + * yes3 + * yes3 * - * sync_scope - * yes yes yes yes yes + * adapter_id + * no + * yes + * yes + * yes3 + * yes3 * - * reply_status - * no no yes yes yes - * - * forward_reference - * no no no no yes2 - * - * - * get_slot - * yes yes yes yes yes - * - * get_request_service_context - * yes no yes yes yes - * - * get_reply_service_context - * no no yes yes yes - * - * - * ServerRequestInfo-specific: - * - * - * sending_exception - * no no no yes no - * - * object_id - * no yes yes yes3 - * yes3 - * - * - * adapter_id - * no yes yes yes3 - * yes3 - * - * - * server_id - * no yes yes yes yes + * server_id + * no + * yes + * yes + * yes + * yes * - * orb_id - * no yes yes yes yes + * orb_id + * no + * yes + * yes + * yes + * yes * - * adapter_name - * no yes yes yes yes + * adapter_name + * no + * yes + * yes + * yes + * yes * - * target_most_derived_interface - * no yes no4 - * no4 - * no4 - * + * target_most_derived_interface + * no + * yes + * no4 + * no4 + * no4 * - * get_server_policy - * yes yes yes yes yes + * get_server_policy + * yes + * yes + * yes + * yes + * yes * - * set_slot - * yes yes yes yes yes + * set_slot + * yes + * yes + * yes + * yes + * yes * - * target_is_a - * no yes no4 - * no4 - * no4 - * + * target_is_a + * no + * yes + * no4 + * no4 + * no4 * - * add_reply_service_context - * yes yes yes yes yes - * + * add_reply_service_context + * yes + * yes + * yes + * yes + * yes + * * * *
    From 5ac708eed73d848c29fa3e5fa44c4bc212d9db9a Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 1 Sep 2017 11:54:58 -0700 Subject: [PATCH 92/98] 8187021: Remove 2 redundant

    tags in java.base API docs Reviewed-by: darcy --- jdk/src/java.base/share/classes/java/io/FileOutputStream.java | 2 +- jdk/src/java.base/share/classes/module-info.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/io/FileOutputStream.java b/jdk/src/java.base/share/classes/java/io/FileOutputStream.java index b98549bd11e..c72ac2b6f04 100644 --- a/jdk/src/java.base/share/classes/java/io/FileOutputStream.java +++ b/jdk/src/java.base/share/classes/java/io/FileOutputStream.java @@ -91,7 +91,7 @@ class FileOutputStream extends OutputStream * If the file exists but is a directory rather than a regular file, does * not exist but cannot be created, or cannot be opened for any other * reason then a FileNotFoundException is thrown. - *

    + * * @implSpec Invoking this constructor with the parameter {@code name} is * equivalent to invoking {@link #FileOutputStream(String,boolean) * new FileOutputStream(name, false)}. diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java index a74879d9311..7628aacf1b4 100644 --- a/jdk/src/java.base/share/classes/module-info.java +++ b/jdk/src/java.base/share/classes/module-info.java @@ -35,7 +35,7 @@ * The jrt file system can be created by calling * {@link java.nio.file.FileSystems#newFileSystem * FileSystems.newFileSystem(URI.create("jrt:/"))}. - *

    + * *

    Tool Guides:
    *
    {@extLink java_tool_reference java launcher}, * {@extLink keytool_tool_reference keytool}
    From fd552de5c55802968ecdd79423110c4df33be3c3 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 1 Sep 2017 14:06:12 -0700 Subject: [PATCH 93/98] 8186947: Fix accessibility and other issues in the java.xml.ws module Reviewed-by: lancea, mchung, darcy --- .../javax/xml/bind/JAXBPermission.java | 17 +- .../classes/javax/xml/bind/Marshaller.java | 22 +- .../classes/javax/xml/bind/Unmarshaller.java | 93 ++++--- .../javax/xml/bind/annotation/XmlNsForm.java | 27 +- .../javax/xml/bind/annotation/XmlType.java | 42 +-- .../annotation/adapters/package-info.java | 6 +- .../xml/bind/annotation/adapters/package.html | 57 ---- .../javax/xml/bind/annotation/package.html | 244 ++++++------------ .../attachment/AttachmentUnmarshaller.java | 25 +- .../javax/xml/bind/helpers/package-info.java | 8 +- .../javax/xml/bind/helpers/package.html | 64 ----- .../javax/xml/bind/util/package-info.java | 6 +- .../classes/javax/xml/bind/util/package.html | 59 ----- .../W3CEndpointReferenceBuilder.java | 4 +- 14 files changed, 210 insertions(+), 464 deletions(-) delete mode 100644 jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package.html delete mode 100644 jaxws/src/java.xml.bind/share/classes/javax/xml/bind/helpers/package.html delete mode 100644 jaxws/src/java.xml.bind/share/classes/javax/xml/bind/util/package.html diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBPermission.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBPermission.java index a4d221d1af3..59fba8da25d 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBPermission.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBPermission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -41,15 +41,19 @@ import java.security.BasicPermission; * and for each provides a description of what the permission allows * and a discussion of the risks of granting code the permission. * - * + *
    + * + * * - * - * - * + * + * + * * + * * + * * - * + * * * + * *
    Permission target name, what the permission allows, and associated risks"
    Permission Target NameWhat the Permission AllowsRisks of Allowing this PermissionPermission Target NameWhat the Permission AllowsRisks of Allowing this Permission
    setDatatypeConvertersetDatatypeConverter * Allows the code to set VM-wide {@link DatatypeConverterInterface} * via {@link DatatypeConverter#setDatatypeConverter(DatatypeConverterInterface) the setDatatypeConverter method} @@ -63,6 +67,7 @@ import java.security.BasicPermission; * another application running in the same JVM. *
    * * @see java.security.BasicPermission diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Marshaller.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Marshaller.java index ccb1b634d5c..5240a5771a9 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Marshaller.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Marshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -373,7 +373,7 @@ public interface Marshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Marshaller} is unable to marshal {@code jaxbElement} (or any - * object reachable from {@code jaxbElement}). See + * object reachable from {@code jaxbElement}). See * Marshalling a JAXB element. * @throws IllegalArgumentException * If any of the method parameters are null @@ -395,7 +395,7 @@ public interface Marshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Marshaller} is unable to marshal {@code jaxbElement} (or any - * object reachable from {@code jaxbElement}). See + * object reachable from {@code jaxbElement}). See * Marshalling a JAXB element. * @throws IllegalArgumentException * If any of the method parameters are null @@ -417,7 +417,7 @@ public interface Marshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Marshaller} is unable to marshal {@code jaxbElement} (or any - * object reachable from {@code jaxbElement}). See + * object reachable from {@code jaxbElement}). See * Marshalling a JAXB element. * @throws IllegalArgumentException * If any of the method parameters are null @@ -440,7 +440,7 @@ public interface Marshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Marshaller} is unable to marshal {@code jaxbElement} (or any - * object reachable from {@code jaxbElement}). See + * object reachable from {@code jaxbElement}). See * Marshalling a JAXB element. * @throws IllegalArgumentException * If any of the method parameters are null @@ -462,7 +462,7 @@ public interface Marshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Marshaller} is unable to marshal {@code jaxbElement} (or any - * object reachable from {@code jaxbElement}). See + * object reachable from {@code jaxbElement}). See * Marshalling a JAXB element. * @throws IllegalArgumentException * If any of the method parameters are null @@ -488,7 +488,7 @@ public interface Marshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Marshaller} is unable to marshal {@code jaxbElement} (or any - * object reachable from {@code jaxbElement}). See + * object reachable from {@code jaxbElement}). See * Marshalling a JAXB element. * @throws IllegalArgumentException * If any of the method parameters are null @@ -511,7 +511,7 @@ public interface Marshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Marshaller} is unable to marshal {@code jaxbElement} (or any - * object reachable from {@code jaxbElement}). See + * object reachable from {@code jaxbElement}). See * Marshalling a JAXB element. * @throws IllegalArgumentException * If any of the method parameters are null @@ -535,7 +535,7 @@ public interface Marshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Marshaller} is unable to marshal {@code jaxbElement} (or any - * object reachable from {@code jaxbElement}). See + * object reachable from {@code jaxbElement}). See * Marshalling a JAXB element. * @throws IllegalArgumentException * If any of the method parameters are null @@ -575,7 +575,7 @@ public interface Marshaller { * {@code Marshaller}. This method can only be used to set one of * the standard JAXB defined properties above or a provider specific * property. Attempting to set an undefined property will result in - * a PropertyException being thrown. See + * a PropertyException being thrown. See * Supported Properties. * * @param name the name of the property to be set. This value can either @@ -596,7 +596,7 @@ public interface Marshaller { * {@code Marshaller}. This method can only be used to get one of * the standard JAXB defined properties above or a provider specific * property. Attempting to get an undefined property will result in - * a PropertyException being thrown. See + * a PropertyException being thrown. See * Supported Properties. * * @param name the name of the property to retrieve diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java index f8424dd1881..a1668787f54 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java @@ -186,13 +186,13 @@ import java.io.Reader; * Unmarshalling can deserialize XML data that represents either an entire XML document * or a subtree of an XML document. Typically, it is sufficient to use the * unmarshalling methods described by - * Unmarshal root element that is declared globally. + * Unmarshal root element that is declared globally. * These unmarshal methods utilize {@link JAXBContext}'s mapping of global XML element * declarations and type definitions to JAXB mapped classes to initiate the * unmarshalling of the root element of XML data. When the {@link JAXBContext}'s * mappings are not sufficient to unmarshal the root element of XML data, * the application can assist the unmarshalling process by using the - * unmarshal by declaredType methods. + * unmarshal by declaredType methods. * These methods are useful for unmarshalling XML data where * the root element corresponds to a local element declaration in the schema. * @@ -245,32 +245,29 @@ import java.io.Reader; * instance are set. * * - * + *
    + * * * - * - * - * - * + * + * * * - * - * + * + * * * * * - * + * * * * - * + * * * * - * + * * * * @@ -279,7 +276,7 @@ import java.io.Reader; * *

    * The following is an example of - * unmarshal by declaredType method. + * unmarshal by declaredType method. *

    * Unmarshal by declaredType from a {@code org.w3c.dom.Node}: *

    @@ -414,7 +411,7 @@ public interface Unmarshaller { * content tree. * *

    - * Implements Unmarshal Global Root Element. + * Implements Unmarshal Global Root Element. * * @param f the file to unmarshal XML data from * @return the newly created root object of the java content tree @@ -425,7 +422,7 @@ public interface Unmarshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Unmarshaller} is unable to perform the XML to Java - * binding. See Unmarshalling XML Data + * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If the file parameter is null */ @@ -437,7 +434,7 @@ public interface Unmarshaller { * be incomplete when using this form of the unmarshal API. * *

    - * Implements Unmarshal Global Root Element. + * Implements Unmarshal Global Root Element. * * @param is the InputStream to unmarshal XML data from * @return the newly created root object of the java content tree @@ -448,7 +445,7 @@ public interface Unmarshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Unmarshaller} is unable to perform the XML to Java - * binding. See Unmarshalling XML Data + * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If the InputStream parameter is null */ @@ -461,7 +458,7 @@ public interface Unmarshaller { * because a Reader does not provide the system ID. * *

    - * Implements Unmarshal Global Root Element. + * Implements Unmarshal Global Root Element. * * @param reader the Reader to unmarshal XML data from * @return the newly created root object of the java content tree @@ -472,7 +469,7 @@ public interface Unmarshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Unmarshaller} is unable to perform the XML to Java - * binding. See Unmarshalling XML Data + * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If the InputStream parameter is null * @since 1.6, JAXB 2.0 @@ -484,7 +481,7 @@ public interface Unmarshaller { * content tree. * *

    - * Implements Unmarshal Global Root Element. + * Implements Unmarshal Global Root Element. * * @param url the url to unmarshal XML data from * @return the newly created root object of the java content tree @@ -495,7 +492,7 @@ public interface Unmarshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Unmarshaller} is unable to perform the XML to Java - * binding. See Unmarshalling XML Data + * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If the URL parameter is null */ @@ -506,7 +503,7 @@ public interface Unmarshaller { * resulting content tree. * *

    - * Implements Unmarshal Global Root Element. + * Implements Unmarshal Global Root Element. * * @param source the input source to unmarshal XML data from * @return the newly created root object of the java content tree @@ -517,7 +514,7 @@ public interface Unmarshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Unmarshaller} is unable to perform the XML to Java - * binding. See Unmarshalling XML Data + * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If the InputSource parameter is null */ @@ -528,7 +525,7 @@ public interface Unmarshaller { * content tree. * *

    - * Implements Unmarshal Global Root Element. + * Implements Unmarshal Global Root Element. * * @param node * the document/element to unmarshal XML data from. @@ -541,7 +538,7 @@ public interface Unmarshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Unmarshaller} is unable to perform the XML to Java - * binding. See Unmarshalling XML Data + * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If the Node parameter is null * @see #unmarshal(org.w3c.dom.Node, Class) @@ -553,7 +550,7 @@ public interface Unmarshaller { * and return the resulting content tree. * *

    - * Implements Unmarshal by Declared Type + * Implements Unmarshal by Declared Type * * @param node * the document/element to unmarshal XML data from. @@ -561,7 +558,7 @@ public interface Unmarshaller { * @param declaredType * appropriate JAXB mapped class to hold {@code node}'s XML data. * - * @return JAXB Element representation of {@code node} + * @return JAXB Element representation of {@code node} * * @throws JAXBException * If any unexpected errors occur while unmarshalling @@ -569,7 +566,7 @@ public interface Unmarshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Unmarshaller} is unable to perform the XML to Java - * binding. See Unmarshalling XML Data + * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If any parameter is null * @since 1.6, JAXB 2.0 @@ -581,7 +578,7 @@ public interface Unmarshaller { * resulting content tree. * *

    - * Implements Unmarshal Global Root Element. + * Implements Unmarshal Global Root Element. * *

    * @@ -627,7 +624,7 @@ public interface Unmarshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Unmarshaller} is unable to perform the XML to Java - * binding. See Unmarshalling XML Data + * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If the Source parameter is null * @see #unmarshal(javax.xml.transform.Source, Class) @@ -641,16 +638,16 @@ public interface Unmarshaller { * resulting content tree. * *

    - * Implements Unmarshal by Declared Type + * Implements Unmarshal by Declared Type * *

    - * See SAX 2.0 Parser Pluggability + * See SAX 2.0 Parser Pluggability * * @param source the XML Source to unmarshal XML data from (providers are * only required to support SAXSource, DOMSource, and StreamSource) * @param declaredType * appropriate JAXB mapped class to hold {@code source}'s xml root element - * @return Java content rooted by JAXB Element + * @return Java content rooted by JAXB Element * * @throws JAXBException * If any unexpected errors occur while unmarshalling @@ -658,7 +655,7 @@ public interface Unmarshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Unmarshaller} is unable to perform the XML to Java - * binding. See Unmarshalling XML Data + * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If any parameter is null * @since 1.6, JAXB 2.0 @@ -671,7 +668,7 @@ public interface Unmarshaller { * resulting content tree. * *

    - * Implements Unmarshal Global Root Element. + * Implements Unmarshal Global Root Element. * *

    * This method assumes that the parser is on a START_DOCUMENT or @@ -691,7 +688,7 @@ public interface Unmarshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Unmarshaller} is unable to perform the XML to Java - * binding. See Unmarshalling XML Data + * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If the {@code reader} parameter is null * @throws IllegalStateException @@ -708,7 +705,7 @@ public interface Unmarshaller { * and return the resulting content tree. * *

    - * This method implements unmarshal by declaredType. + * This method implements unmarshal by declaredType. *

    * This method assumes that the parser is on a START_DOCUMENT or * START_ELEMENT event. Unmarshalling will be done from this @@ -721,7 +718,7 @@ public interface Unmarshaller { * @param declaredType * appropriate JAXB mapped class to hold {@code reader}'s START_ELEMENT XML data. * - * @return content tree rooted by JAXB Element representation + * @return content tree rooted by JAXB Element representation * * @throws JAXBException * If any unexpected errors occur while unmarshalling @@ -729,7 +726,7 @@ public interface Unmarshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Unmarshaller} is unable to perform the XML to Java - * binding. See Unmarshalling XML Data + * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If any parameter is null * @since 1.6, JAXB 2.0 @@ -741,7 +738,7 @@ public interface Unmarshaller { * resulting content tree. * *

    - * This method is an Unmarshal Global Root method. + * This method is an Unmarshal Global Root method. * *

    * This method assumes that the parser is on a START_DOCUMENT or @@ -761,7 +758,7 @@ public interface Unmarshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Unmarshaller} is unable to perform the XML to Java - * binding. See Unmarshalling XML Data + * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If the {@code reader} parameter is null * @throws IllegalStateException @@ -778,7 +775,7 @@ public interface Unmarshaller { * and return the resulting content tree. * *

    - * This method implements unmarshal by declaredType. + * This method implements unmarshal by declaredType. * *

    * This method assumes that the parser is on a START_DOCUMENT or @@ -792,7 +789,7 @@ public interface Unmarshaller { * @param declaredType * appropriate JAXB mapped class to hold {@code reader}'s START_ELEMENT XML data. * - * @return content tree rooted by JAXB Element representation + * @return content tree rooted by JAXB Element representation * * @throws JAXBException * If any unexpected errors occur while unmarshalling @@ -800,7 +797,7 @@ public interface Unmarshaller { * If the {@link ValidationEventHandler ValidationEventHandler} * returns false from its {@code handleEvent} method or the * {@code Unmarshaller} is unable to perform the XML to Java - * binding. See Unmarshalling XML Data + * binding. See Unmarshalling XML Data * @throws IllegalArgumentException * If any parameter is null * @since 1.6, JAXB 2.0 @@ -913,7 +910,7 @@ public interface Unmarshaller { * {@code Unmarshaller}. This method can only be used to set one of * the standard JAXB defined properties above or a provider specific * property. Attempting to set an undefined property will result in - * a PropertyException being thrown. See + * a PropertyException being thrown. See * Supported Properties. * * @param name the name of the property to be set. This value can either @@ -934,7 +931,7 @@ public interface Unmarshaller { * {@code Unmarshaller}. This method can only be used to get one of * the standard JAXB defined properties above or a provider specific * property. Attempting to get an undefined property will result in - * a PropertyException being thrown. See + * a PropertyException being thrown. See * Supported Properties. * * @param name the name of the property to retrieve diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlNsForm.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlNsForm.java index 4dfd5fa1176..a9d405aa490 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlNsForm.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlNsForm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -36,23 +36,26 @@ package javax.xml.bind.annotation; * The namespace qualification values are used in the annotations * defined in this packge. The enumeration values are mapped as follows: * - *

    Unmarshal By Declared Type returned JAXBElement
    - * Unmarshal By Declared Type returned JAXBElement - *
    JAXBElement PropertyValueJAXBElement PropertyValue
    name{@code xml element name}name{@code xml element name}
    valuevalue{@code instanceof declaredType}
    declaredTypedeclaredTypeunmarshal method {@code declaredType} parameter
    scopescope{@code null} (actual scope is unknown)
    + *
    + * + * + * + * + * + * + * + * * * - * - * - * - * - * - * + * * * - * - * + * + * * * - * - * + * + * * * diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java index d2c9ea6d0f9..982185649f1 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -113,58 +113,60 @@ import java.lang.annotation.Target; * complex type or simple type. The notational symbols used in the table are: *
      *
    • {@literal ->} : represents a mapping
    • - *
    • [x]+ : one or more occurances of x
    • + *
    • [x]+ : one or more occurrences of x
    • *
    • [ {@code @XmlValue} property ]: JavaBean property annotated with * {@code @XmlValue}
    • *
    • X : don't care *
    *
    - *
    Mapping of enumeration values
    Enum ValueXML Schema Value
    Enum ValueXML Schema Value
    UNQUALIFIEDUNQUALIFIEDunqualified
    QUALIFIED
    QUALIFIEDqualified
    UNSET
    UNSETnamespace qualification attribute is absent from the * XML Schema fragment
    + *
    + * + * + * + * + * + * + * + * + * + * * * - * - * - * - * - * - * - * - * * * - * + * * * * * - * + * * * - * + * * * * * - * + * * * - * + * * * * * - * + * * * - * + * * * * * - * + * * * - * + * * * * diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package-info.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package-info.java index d52ab7fa2bd..b76b9411325 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package-info.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package-info.java @@ -26,13 +26,13 @@ /** * {@link javax.xml.bind.annotation.adapters.XmlAdapter} and its spec-defined * sub-classes to allow arbitrary Java classes to be used with JAXB. - *

    + * *

    Package Specification

    - *

    + * *

    - *

    + * *

    Related Documentation

    *

    * For overviews, tutorials, examples, guides, and tool documentation, diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package.html b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package.html deleted file mode 100644 index 02dbd93639d..00000000000 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/package.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - -

    - {@link javax.xml.bind.annotation.adapters.XmlAdapter} and its spec-defined - sub-classes to allow arbitrary Java classes to be used with JAXB. - -

    Package Specification

    - - - -

    Related Documentation

    - - For overviews, tutorials, examples, guides, and tool documentation, - please see: - - - - - - - - diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/package.html b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/package.html index 4fc54e34dc4..b249a29517c 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/package.html +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/package.html @@ -1,6 +1,6 @@ - + - - - - - - - - - -

    - JAXB Provider Use Only: Provides partial default implementations for - some of the javax.xml.bind interfaces. - -

    - JAXB Providers can extend these classes and implement the abstract - methods. - -

    Package Specification

    - - - -

    Related Documentation

    - - For overviews, tutorials, examples, guides, and tool documentation, - please see: - - - - - - - - diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/util/package-info.java b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/util/package-info.java index 229d4343fc2..d6b3b7bdd71 100644 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/util/package-info.java +++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/util/package-info.java @@ -25,13 +25,13 @@ /** * Useful client utility classes. - *

    + * *

    Package Specification

    - *

    + * *

    - *

    + * *

    Related Documentation

    *

    * For overviews, tutorials, examples, guides, and tool documentation, diff --git a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/util/package.html b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/util/package.html deleted file mode 100644 index 21569c6738e..00000000000 --- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/util/package.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - -

    - Useful client utility classes. - -

    Package Specification

    - - - -

    Related Documentation

    - - For overviews, tutorials, examples, guides, and tool documentation, - please see: - - - - - - - - diff --git a/jaxws/src/java.xml.ws/share/classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java b/jaxws/src/java.xml.ws/share/classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java index 6b54294c6f2..2028a863545 100644 --- a/jaxws/src/java.xml.ws/share/classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java +++ b/jaxws/src/java.xml.ws/share/classes/javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -145,7 +145,7 @@ public final class W3CEndpointReferenceBuilder { * Sets the {@code endpointName} as * {@code wsam:ServiceName/@EndpointName} in the * {@code wsa:Metadata} element. This method can only be called - * after the {@link #serviceName} method has been called. + * after the {@link #serviceName(QName)} method has been called. *

    * See * 2.1 Referencing WSDL Metadata from an EPR for more details. From 5f21305cc1534be881e7947de7c8bb9f948fef04 Mon Sep 17 00:00:00 2001 From: Priya Lakshmi Muthuswamy Date: Sat, 2 Sep 2017 14:26:29 +0200 Subject: [PATCH 94/98] 8169233: LengthNotWritableFilter extraElements.remove(index) has no effect Reviewed-by: sundar, jlaskey --- .../arrays/LengthNotWritableFilter.java | 2 +- .../test/script/basic/JDK-8035312.js.EXPECTED | 30 +++++++------- nashorn/test/script/basic/JDK-8169233.js | 41 +++++++++++++++++++ .../test/script/basic/JDK-8169233.js.EXPECTED | 4 ++ 4 files changed, 61 insertions(+), 16 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8169233.js create mode 100644 nashorn/test/script/basic/JDK-8169233.js.EXPECTED diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/LengthNotWritableFilter.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/LengthNotWritableFilter.java index 6f930327566..d4d3c597ac3 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/LengthNotWritableFilter.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/LengthNotWritableFilter.java @@ -143,7 +143,7 @@ final class LengthNotWritableFilter extends ArrayFilter { @Override public ArrayData delete(final int index) { - extraElements.remove(index); + extraElements.remove(ArrayIndex.toLongIndex(index)); underlying = underlying.delete(index); return this; } diff --git a/nashorn/test/script/basic/JDK-8035312.js.EXPECTED b/nashorn/test/script/basic/JDK-8035312.js.EXPECTED index 07d576f1165..3d2a057a643 100644 --- a/nashorn/test/script/basic/JDK-8035312.js.EXPECTED +++ b/nashorn/test/script/basic/JDK-8035312.js.EXPECTED @@ -58,37 +58,37 @@ x[4] === undefined (should be undefined) >>> Pop test Popping from 1,2,3 - array is now [1,2,3] length is = 3 + array is now [1,2,] length is = 3 class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter -Popping from 1,2,3 - array is now [1,2,3] length is = 3 +Popping from 1,2, + array is now [1,2,] length is = 3 class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter x.length === 3 (should be 3) -x === 1,2,3 -Popping from 1,2,3 - array is now [1,2,3] length is = 3 +x === 1,2, +Popping from 1,2, + array is now [1,2,] length is = 3 class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter -Popping from 1,2,3 - array is now [1,2,3] length is = 3 +Popping from 1,2, + array is now [1,2,] length is = 3 class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter -Popping from 1,2,3 - array is now [1,2,3] length is = 3 +Popping from 1,2, + array is now [1,2,] length is = 3 class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter -Popping from 1,2,3 - array is now [1,2,3] length is = 3 +Popping from 1,2, + array is now [1,2,] length is = 3 class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter -Popping from 1,2,3 - array is now [1,2,3] length is = 3 +Popping from 1,2, + array is now [1,2,] length is = 3 class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter x.length === 3 (should be 3) -x === 1,2,3 +x === 1,2, class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter Writing 0 class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter diff --git a/nashorn/test/script/basic/JDK-8169233.js b/nashorn/test/script/basic/JDK-8169233.js new file mode 100644 index 00000000000..3b09fd86e47 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8169233.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8169233 : LengthNotWritableFilter: extraElements.remove(index) has no effect + * + * @test + * @run + */ + +var array = ['a', 'b', 'c', 'd']; +Object.defineProperty(array, "length", {writable: false}); +try { + array.push('e'); +} catch (e) { +} +print("array : "+array); +print("length : " + array.length); +delete array[0]; +print("array : "+array); +print("length : " + array.length); diff --git a/nashorn/test/script/basic/JDK-8169233.js.EXPECTED b/nashorn/test/script/basic/JDK-8169233.js.EXPECTED new file mode 100644 index 00000000000..415d1bf2a56 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8169233.js.EXPECTED @@ -0,0 +1,4 @@ +array : a,b,c,d +length : 4 +array : ,b,c,d +length : 4 From 8284de27e2cb44255e1eb1e9bee1e9d28f8bd0d9 Mon Sep 17 00:00:00 2001 From: Prahalad Narayanan Date: Sun, 3 Sep 2017 19:31:11 +0530 Subject: [PATCH 95/98] 8187113: test/javax/imageio/plugins/png/PngCreationTimeTest.java fails Reviewed-by: serb, psadhukhan --- .../plugins/png/PngCreationTimeTest.java | 136 ++++++++++++------ jdk/test/javax/imageio/plugins/png/duke.png | Bin 0 -> 4241 bytes 2 files changed, 91 insertions(+), 45 deletions(-) create mode 100644 jdk/test/javax/imageio/plugins/png/duke.png diff --git a/jdk/test/javax/imageio/plugins/png/PngCreationTimeTest.java b/jdk/test/javax/imageio/plugins/png/PngCreationTimeTest.java index 3347aea1bb8..2028648f15a 100644 --- a/jdk/test/javax/imageio/plugins/png/PngCreationTimeTest.java +++ b/jdk/test/javax/imageio/plugins/png/PngCreationTimeTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8164971 + * @bug 8164971 8187113 * @summary The test decodes a png file and checks if the metadata contains * image creation time. In addition, the test also merges the custom * metadata tree (both standard and native) and succeeds when the @@ -55,6 +55,7 @@ public class PngCreationTimeTest { private static IIOMetadata pngMetadata = null; public static void initializeTest() throws IOException { + Iterator iterR = null; ImageReader pngImageReader = null; BufferedImage decImage = null; ImageInputStream imageStream = null; @@ -62,25 +63,43 @@ public class PngCreationTimeTest { String separator = System.getProperty("file.separator"); String dirPath = System.getProperty("test.src", "."); String filePath = dirPath + separator + fileName; - File file = new File(filePath); + File file = null; try { - Iterator iterR = ImageIO.getImageReadersBySuffix("PNG"); + // Open the required file and check if file exists. + file = new File(filePath); + if (file != null && !file.exists()) { + reportExceptionAndFail("Test Failed. Required image file was" + + " not found."); + } + + // Get PNG image reader + iterR = ImageIO.getImageReadersBySuffix("PNG"); if (iterR.hasNext()) { pngImageReader = iterR.next(); ImageReadParam param = pngImageReader.getDefaultReadParam(); imageStream = ImageIO.createImageInputStream(file); - - /* - * Last argument- false, informs reader not to ignore the - * metadata from the image file - */ - pngImageReader.setInput(imageStream, false, false); - decImage = pngImageReader.read(0, param); - pngMetadata = pngImageReader.getImageMetadata(0); - - // Check if the metadata contains creation time - testImageMetadata(pngMetadata); + if (imageStream != null) { + // Last argument informs reader not to ignore metadata + pngImageReader.setInput(imageStream, + false, + false); + decImage = pngImageReader.read(0, param); + pngMetadata = pngImageReader.getImageMetadata(0); + if (pngMetadata != null) { + // Check if the metadata contains creation time + testImageMetadata(pngMetadata); + } else { + reportExceptionAndFail("Test Failed. Reader could not" + + " generate image metadata."); + } + } else { + reportExceptionAndFail("Test Failed. Could not initialize" + + " image input stream."); + } + } else { + reportExceptionAndFail("Test Failed. Required image reader" + + " was not found."); } } finally { // Release ther resources @@ -103,14 +122,16 @@ public class PngCreationTimeTest { Node keyNode = findNode(metadata.getAsTree("javax_imageio_1.0"), "ImageCreationTime"); if (keyNode == null) { - throw new RuntimeException("Test Failed: Reader could not" - + " find creation time in the metadata"); + reportExceptionAndFail("Test Failed: Could not find image" + + " creation time in the metadata."); } } } public static void testSaveCreationTime() throws IOException { File file = null; + Iterator iterW = null; + Iterator iterR = null; ImageWriter pngImageWriter = null; ImageReader pngImageReader = null; ImageInputStream inputStream = null; @@ -127,39 +148,60 @@ public class PngCreationTimeTest { // Create a temporary file for the output png image String fileName = "RoundTripTest"; file = File.createTempFile(fileName, ".png"); + if (file == null) { + reportExceptionAndFail("Test Failed. Could not create a" + + " temporary file for round trip test."); + } // Create a PNG writer and write test image with metadata - Iterator iterW = ImageIO.getImageWritersBySuffix("PNG"); + iterW = ImageIO.getImageWritersBySuffix("PNG"); if (iterW.hasNext()) { pngImageWriter = iterW.next(); outputStream = ImageIO.createImageOutputStream(file); - pngImageWriter.setOutput(outputStream); + if (outputStream != null) { + pngImageWriter.setOutput(outputStream); - // Get the default metadata & add image creation time to it. - IIOMetadata metadata = pngImageWriter.getDefaultImageMetadata( - ImageTypeSpecifier.createFromRenderedImage(buffImage), - null); - IIOMetadataNode root = createStandardMetadataNodeTree(); - metadata.mergeTree("javax_imageio_1.0", root); + // Get the default metadata & add image creation time to it. + ImageTypeSpecifier imgType = + ImageTypeSpecifier.createFromRenderedImage(buffImage); + IIOMetadata metadata = + pngImageWriter.getDefaultImageMetadata(imgType, null); + IIOMetadataNode root = createStandardMetadataNodeTree(); + metadata.mergeTree("javax_imageio_1.0", root); - // Write a png image using buffImage & metadata - IIOImage iioImage = new IIOImage(buffImage, null, metadata); - pngImageWriter.write(iioImage); + // Write a png image using buffImage & metadata + IIOImage iioImage = new IIOImage(buffImage, null, metadata); + pngImageWriter.write(iioImage); + } else { + reportExceptionAndFail("Test Failed. Could not initialize" + + " image output stream for round trip test."); + } + } else { + reportExceptionAndFail("Test Failed. Could not find required" + + " image writer for the round trip test."); } // Create a PNG reader and check if metadata was written - Iterator iterR = ImageIO.getImageReadersBySuffix("PNG"); + iterR = ImageIO.getImageReadersBySuffix("PNG"); if (iterR.hasNext()) { pngImageReader = iterR.next(); inputStream = ImageIO.createImageInputStream(file); + if (inputStream != null) { + // Read the image and get the metadata + pngImageReader.setInput(inputStream, false, false); + pngImageReader.read(0); + IIOMetadata imgMetadata = + pngImageReader.getImageMetadata(0); - // Read the image and get the metadata - pngImageReader.setInput(inputStream, false, false); - pngImageReader.read(0); - IIOMetadata imgMetadata = pngImageReader.getImageMetadata(0); - - // Test if the metadata contains creation time. - testImageMetadata(imgMetadata); + // Test if the metadata contains creation time. + testImageMetadata(imgMetadata); + } else { + reportExceptionAndFail("Test Failed. Could not initialize" + + " image input stream for round trip test."); + } + } else { + reportExceptionAndFail("Test Failed. Cound not find the" + + " required image reader."); } } finally { // Release the resources held @@ -182,6 +224,11 @@ public class PngCreationTimeTest { } } + public static void reportExceptionAndFail(String message) { + // A common method to report exception. + throw new RuntimeException(message); + } + public static void testMergeNativeTree() { // Merge a custom native metadata tree and inspect creation time if (pngMetadata != null) { @@ -195,7 +242,6 @@ public class PngCreationTimeTest { pngMetadata.mergeTree("javax_imageio_png_1.0", root); Node keyNode = findNode(pngMetadata.getAsTree("javax_imageio_1.0"), "ImageCreationTime"); - if (keyNode != null) { // Query the attributes of the node and check for the value NamedNodeMap attrMap = keyNode.getAttributes(); @@ -204,17 +250,17 @@ public class PngCreationTimeTest { int decYear = Integer.parseInt(attrValue); if (decYear != 2014) { // Throw exception. Incorrect year value observed - throw new RuntimeException("Test Failed: Incorrect" - + " creation time value observed"); + reportExceptionAndFail("Test Failed: Incorrect" + + " creation time value observed."); } } else { // Throw exception. - throw new RuntimeException("Test Failed: Image creation" - + "time doesn't exist in metadata"); + reportExceptionAndFail("Test Failed: Image creation" + + " time doesn't exist in metadata."); } } catch (IOException ex) { // Throw exception. - throw new RuntimeException("Test Failed: While executing" + reportExceptionAndFail("Test Failed: While executing" + " mergeTree on metadata."); } } @@ -246,16 +292,16 @@ public class PngCreationTimeTest { if (!attrValue.contains("2016")) { // Throw exception. Incorrect year value observed throw new RuntimeException("Test Failed: Incorrect" - + " creation time value observed"); + + " creation time value observed."); } } else { // Throw exception. - throw new RuntimeException("Test Failed: Image creation" - + "time doesn't exist in metadata"); + reportExceptionAndFail("Test Failed: Image creation" + + " time doesn't exist in metadata."); } } catch (IOException ex) { // Throw exception. - throw new RuntimeException("Test Failed: While executing" + reportExceptionAndFail("Test Failed: While executing" + " mergeTree on metadata."); } } diff --git a/jdk/test/javax/imageio/plugins/png/duke.png b/jdk/test/javax/imageio/plugins/png/duke.png new file mode 100644 index 0000000000000000000000000000000000000000..f4b89e7fa13defaaf955e4a73ec8c60d397de200 GIT binary patch literal 4241 zcmY*c4LpCH1XCgky!Rn(|7?+YEvOYPv)^18B9tH?+{ zOOEEG&IpYo?Ua5^RLc>glXjfcNLuLlKb@b_|K4YxJ@@muulu^L@ArFO*S+J=R&QfN zb3+6IVeCVv1|bkS@T1Nqlpg%kL-(^sAoLKBUkFXEPzd=v5kTbQ{1`jryEtQD1WHyV*5{tzk2udUpjY_RitCav1g+OpP zTrH8bQ(%><8A_lKe z%E=@WmtUYIvlMJ8hs`dn5;GVKrAnn#D!Ft92_P{bh{a;^xCL-pEH+02!@^`J@&! z!db#7$~t;^oJ_S^wUGpB!Bn+M#TOL78<5E)2%^6vGrQzcNv%jK>ryJ^8jV)1Q85^h zO0C4>@l_(Bwze08!jMQLA|B7l<+ zVAg6hYCfM!v<2YJdgTf{3WLXB{sgERjY^}Q#9%PB61iG4sUVWHS~U@a(WsRQutBSZ z(}F)A2P{I=zUBHKPey9c)?frUqKy7HiSqTPB6#|iba;Yh)3>J}5JpQresvIMOY!ha zgH#`Xn!ylqDRQZsQ6A3;e&v)(W2AZ}?~6>0NlGM!#3bxPcqPX;64y8rDePq88j`ac zk@Veq(%SVdB;qQPs|%_1ko*j6Xc-d%8zv`P3ArwGKqo9x?5j5&Jyl5fe_yP~Mftji9 z%Efho2lTdAGG)fb$0@h;IVR4DK;DKTFMS(BRGCmp@G0AHSO-+pPPq#Y;=}Z~YPrjLtfa zb+&+wReFO5z(n?M69;51n8DgkFG2CPXS3sXhu-k=u`d3YF&hz?=q7C&(7EeIXm%Rj z{ZPB;PGL=bM)UXE#dG=p^~jW%hjqpUGp%%P=`^+(Pnj@U{WKvRdS?Ry;#TKk-8}M# zmh$3i##_hlmV8=t_qNWv1i^0N;oXH9A{LJGB6jwA{D1v_#!+ zlT0@~S?wv)$*9ouuKMH2@_oK3CF}^-ZBS~D-~V%EmYcr9-cgo&nkekPHaj&OJ8Syf z74?g?zfq*;(<=R6Y%Y%{2&`fm= zM4|Tuv7EB=FgHF4ZUMhoUyj^?48~siPswb0#=G5@>sM_toIwF5a^pmNt{!JNjq-#i z^%R%?u5Z|MDLr=1Ym?$@y;c{GV)uMXkLZTa@qtqjC_9+%e;Ge&*LKBPWZ$jO^%J|k zN;wxWz058wb7n)}a6Bn`(Tk8^heN zCYza>u>5LrkIjUj+syI_x3c0_G+R91%5(9&cQjZVFptnt3a%ohrarsUyWG1WVqm0a zKLjM5H7@sntXjW!27I%$6TwgsE3wb|3ry@hc2oz|;lk=@+Z013fm^|5T)hqJLb3kD zsV&dabjQnoxmeb|an^obuQ@Gxi)`9XQ=PsIIDT!oUxP*!&1}5ZxY<}xV0Z`lqqdCw z^L6ADrN7$zO6<4y7JWjmKyRJRb?ZL+Unw^_QvA{**EF20^Vvo1C-mQZPplNS&^NY! zJ|`skNu|x@1Lk=_RpF8QF0R5ty$3Z~K2RFI({u_8S?~${%-7tu=o~9Aagd-73Uz8mcjJiC zwY`5w|ADdiyAgfo+L+}tWv&)mX{C#tHzDB-)L{Oy+9S(Gi^|X5zV+b0D5vkOvQ;hE z`?R6*0+w}~6DDDZvighs*AaRf+uVs!g*|4Ny`EL>HY7qwnBLRh1^lg*L)%dogU}3+ zaP8z@Uwsi3T@%&u2GeY}s|*pm|8|I8vnyT~!amKT^FooN$(UzUr?KAFK(uznokm{j z8UvlYDZxyj%ayvx9kiL9u8BFx?j0kfSX__Wr&1!J(lat+jk<~k-vkN><2a~gjmOh$ zhlyFYyk$2A8HGng^x2iYzFUS({)rgk>U^dJXH9uKMygoZ=l($W)3lmtZBhH!XBJtJ ziWb`n+)%r)_g3DtLM$K_=|Zub%<#jv;QTI?rFZfPMJCgM0auF3n*|-fst@ex5m&9u|Q14}X-7%WmNPJvLZz-e}7iu~Dd3m7!st_o0du>$dZO zAB9Fj8EB$!9J5=Nx5B&l-AHHE?o$qdYnL}|f8%pdKmG3X(b(`FVa7tS5hdX=7e&S4 zjgHX34H#=V%JPuS3Ov{h-w+PR48+Ng;1Pq#|9`zXj|3vQf-_D{3 z^i#zWbP%H6AaCTzhGWwoZad%fy%Z2P*N5}NzJ3tTcI~xP-l}#-T`0*N(xqCr4gAZx zqJ_T2XsCfUi1Tl_)r_)B{7`K{q#kD3XR~wu@o_wv*W=;bZkT7dxX5c#_p>I!cT{zJ zZr?3xvt6$p7VFe~(H)Nt8W9p=)}fZ<&2{8<86A{DOaC)z9eOYH6YX%NY$_44??Ow4 z$}wI24aL;XQ`%^S%D|C ze!Qz~+O&oOga8}JsfnjA?;gb7c5_Qzz)fV2>t8lH72t=oZ$?IW?6CEF|DLt&{@c_< z09Q3LaOR$W*+Oeqx30!i#Plsf-YPBjJOgGpP>Y!DWzN36i%Y^@vJ$116r*TM`f-!v zlE2xQ(CLzpjmMh(e)C6Vwe!`@E6!U^rw@LiK6@N;H-%+v)NqCv|M+CYY{QDVi!oJw zF1I5*5==_Xync##8aaQr*>nJrb$*>lL9L0nyWR9J_sv%0s*Y69bu)K@*U^mlA_{4Z z{;Ie;@dD#phe}(sS_uMO0MB%Jc(cF@=pw78Y+BGkR${I)be!r29VadBQYf zl|Z{`SI@q?pe~Ivn?JmsF!d3<9FLYTw;`%V@WMUu1A2PHqjR)m|6{ysBUH~R|7WMo z7WiPAzvwb?^)a~W6zmy2TC71MjUrB0hVz(Xf3FdskA#*+#tv|j@lJ(lUtAh>pLU`1 z*10YTr*+SyJ}CIs|2?tsLtx0*wf*=qo!UoN#nO~=IY9mwnxoha77!?hK_-j zIhBhv?A<%Nz&}=nc3*xo;YYp@xYj4c{kitomLaj?MB&9xKv&qCC|A8VJ!ctDu`nMw zG`lmtu5)$Dp0aS~`ahXl$&QWJzu<4v2_hLyd2}J{o89@9&wp9+%<|0-4nr59Nw=VE zYjORfN3pY#`qb>t?O5cEYc|)JbI>uJ%evmugs-E9cV`CS#4VJS53X0RIpWVzRL34z z@nH$nn$Mg&^6U8Br)-O10rYxvqBm$X8v1bgLXAI9$GptelB4YE(>lLH?V{X7)9zhW z<~xo}rc*v%*x_THZrc_~Ie!S97oB5f_qgeQ70HtVj~}rA80`P%b-(R5uJs@P%=pl@ KQtLdJ+5ZPL5}~sI literal 0 HcmV?d00001 From 3287dcd2441e9a804492424fcf17897a60d3fbbf Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Mon, 4 Sep 2017 13:36:52 +0200 Subject: [PATCH 96/98] 8185928: Generate OpenJDK builds for Mac platform JDK 9.0.3 and beyond in Mach 5 Reviewed-by: ihse, tbell --- common/conf/jib-profiles.js | 46 ++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/common/conf/jib-profiles.js b/common/conf/jib-profiles.js index fd0e3f731b6..dcac9dcaa1d 100644 --- a/common/conf/jib-profiles.js +++ b/common/conf/jib-profiles.js @@ -818,6 +818,49 @@ var getJibProfilesProfiles = function (input, common, data) { } }, + "macosx-x64-open": { + artifacts: { + jdk: { + local: "bundles/\\(jdk.*bin.tar.gz\\)", + remote: [ + "bundles/openjdk/GPL/osx-x64/jdk-" + data.version + + "_osx-x64_bin.tar.gz", + "bundles/openjdk/GPL/osx-x64/\\1" + ], + subdir: "jdk-" + data.version + }, + jre: { + local: "bundles/\\(jre.*bin.tar.gz\\)", + remote: "bundles/openjdk/GPL/osx-x64/\\1", + }, + test: { + local: "bundles/\\(jdk.*bin-tests.tar.gz\\)", + remote: [ + "bundles/openjdk/GPL/osx-x64/jdk-" + data.version + + "_osx-x64_bin-tests.tar.gz", + "bundles/openjdk/GPL/osx-x64/\\1" + ] + }, + jdk_symbols: { + local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)", + remote: [ + "bundles/openjdk/GPL/osx-x64/jdk-" + data.version + + "_osx-x64_bin-symbols.tar.gz", + "bundles/openjdk/GPL/osx-x64/\\1" + ], + subdir: "jdk-" + data.version + }, + jre_symbols: { + local: "bundles/\\(jre.*bin-symbols.tar.gz\\)", + remote: "bundles/openjdk/GPL/osx-x64/\\1", + }, + doc_api_spec: { + local: "bundles/\\(jdk.*doc-api-spec.tar.gz\\)", + remote: "bundles/openjdk/GPL/osx-x64/\\1", + }, + } + }, + "windows-x86-open": { artifacts: { jdk: { @@ -884,10 +927,11 @@ var getJibProfilesProfiles = function (input, common, data) { profiles["linux-x64-ri"] = clone(profiles["linux-x64-open"]); profiles["linux-x86-ri"] = clone(profiles["linux-x86-open"]); profiles["linux-x86-ri-debug"] = clone(profiles["linux-x86-open-debug"]); + profiles["macosx-x64-ri"] = clone(profiles["macosx-x64-open"]); profiles["windows-x86-ri"] = clone(profiles["windows-x86-open"]); // Generate artifacts for ri profiles - [ "linux-x64-ri", "linux-x86-ri", "linux-x86-ri-debug", "windows-x86-ri" ] + [ "linux-x64-ri", "linux-x86-ri", "linux-x86-ri-debug", "macosx-x64-ri", "windows-x86-ri" ] .forEach(function (name) { // Rewrite all remote dirs to "bundles/openjdk/BCL/..." for (artifactName in profiles[name].artifacts) { From 136977337e3da1e02308519befd175a5975f9c7d Mon Sep 17 00:00:00 2001 From: Felix Yang Date: Mon, 4 Sep 2017 17:46:59 -0700 Subject: [PATCH 97/98] 8134989: java/net/MulticastSocket/TestInterfaces.java failed due to unexpected IP address Reviewed-by: rriggs, chegar, msheppar --- .../java/net/MulticastSocket/TestInterfaces.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/jdk/test/java/net/MulticastSocket/TestInterfaces.java b/jdk/test/java/net/MulticastSocket/TestInterfaces.java index 2d90cb8a58e..80ab98f594b 100644 --- a/jdk/test/java/net/MulticastSocket/TestInterfaces.java +++ b/jdk/test/java/net/MulticastSocket/TestInterfaces.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -24,10 +24,15 @@ /* * @test * @bug 4422122 - * @key intermittent * @summary Test that MulticastSocket.getInterface returns the * same InetAddress set by MulticastSocket.setInterface + * @library /test/lib + * @build jdk.test.lib.NetworkConfiguration + * jdk.test.lib.Platform + * @run main TestInterfaces */ +import jdk.test.lib.NetworkConfiguration; + import java.net.*; import java.util.Arrays; import java.util.Collections; @@ -52,6 +57,10 @@ public class TestInterfaces { if (isWindows && dName != null && dName.contains("Teredo")) continue; + // Skip those interfaces not up or not support multicast + if (!ni.isUp() || !ni.supportsMulticast()) + continue; + /* * Test MulticastSocket.getInterface */ @@ -115,6 +124,8 @@ public class TestInterfaces { } if (failures > 0) { + System.err.println("********************************"); + NetworkConfiguration.printSystemConfiguration(System.err); System.out.println("********************************"); throw new Exception(failures + " test(s) failed!!!"); } From 99489f2aa44fb49d705c3d77a65e6d333d937b1c Mon Sep 17 00:00:00 2001 From: Jason Yong Date: Wed, 6 Sep 2017 16:05:49 +0200 Subject: [PATCH 98/98] 8186983: CompileJavaModule.gmk overrides values from a custom extension gmk Reviewed-by: ihse, dholmes --- make/CompileJavaModules.gmk | 134 ++++++++++++++++++------------------ 1 file changed, 67 insertions(+), 67 deletions(-) diff --git a/make/CompileJavaModules.gmk b/make/CompileJavaModules.gmk index 2f2a44fa0ba..ed9fb56b042 100644 --- a/make/CompileJavaModules.gmk +++ b/make/CompileJavaModules.gmk @@ -42,9 +42,9 @@ java.activation_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS ################################################################################ -java.base_ADD_JAVAC_FLAGS := -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' -XDstringConcat=inline -java.base_COPY := .icu .dat .spp content-types.properties hijrah-config-islamic-umalqura.properties -java.base_CLEAN := intrinsic.properties +java.base_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' -XDstringConcat=inline +java.base_COPY += .icu .dat .spp content-types.properties hijrah-config-islamic-umalqura.properties +java.base_CLEAN += intrinsic.properties java.base_EXCLUDE_FILES += \ $(JDK_TOPDIR)/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java @@ -85,20 +85,20 @@ endif ################################################################################ -java.compiler_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' +java.compiler_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' ################################################################################ -java.datatransfer_ADD_JAVAC_FLAGS := -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' -java.datatransfer_COPY := flavormap.properties +java.datatransfer_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' +java.datatransfer_COPY += flavormap.properties ################################################################################ -java.desktop_ADD_JAVAC_FLAGS := -Xdoclint:all/protected,-reference \ +java.desktop_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference \ '-Xdoclint/package:java.*,javax.*' -Xlint:exports \ --doclint-format html4 -java.desktop_COPY := .gif .png .wav .txt .xml .css .pf -java.desktop_CLEAN := iio-plugin.properties cursors.properties +java.desktop_COPY += .gif .png .wav .txt .xml .css .pf +java.desktop_CLEAN += iio-plugin.properties cursors.properties java.desktop_EXCLUDES += \ java/awt/doc-files \ @@ -230,50 +230,50 @@ java.desktop_EXCLUDE_FILES += \ ################################################################################ -java.scripting_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' -java.scripting_COPY := .js -java.scripting_CLEAN := .properties +java.scripting_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' +java.scripting_COPY += .js +java.scripting_CLEAN += .properties ################################################################################ -java.instrument_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' +java.instrument_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' ################################################################################ -java.logging_ADD_JAVAC_FLAGS := -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' +java.logging_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' ################################################################################ -java.management_ADD_JAVAC_FLAGS := -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' +java.management_ADD_JAVAC_FLAGS += -Xdoclint:all/protected,-reference '-Xdoclint/package:java.*,javax.*' ################################################################################ -java.management.rmi_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:javax.*' +java.management.rmi_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:javax.*' ################################################################################ -java.prefs_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' +java.prefs_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' ################################################################################ -java.transaction_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' +java.transaction_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' ################################################################################ -java.sql_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' +java.sql_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' java.sql_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS ################################################################################ -java.sql.rowset_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' -java.sql.rowset_CLEAN_FILES := $(wildcard \ +java.sql.rowset_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' +java.sql.rowset_CLEAN_FILES += $(wildcard \ $(JDK_TOPDIR)/src/java.sql.rowset/share/classes/com/sun/rowset/*.properties \ $(JDK_TOPDIR)/src/java.sql.rowset/share/classes/javax/sql/rowset/*.properties) ################################################################################ -java.rmi_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' -java.rmi_CLEAN_FILES := $(wildcard \ +java.rmi_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' +java.rmi_CLEAN_FILES += $(wildcard \ $(JDK_TOPDIR)/src/java.rmi/share/classes/sun/rmi/registry/resources/*.properties \ $(JDK_TOPDIR)/src/java.rmi/share/classes/sun/rmi/server/resources/*.properties) @@ -281,8 +281,8 @@ java.rmi_CLEAN_FILES := $(wildcard \ java.corba_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS -java.corba_COPY := .prp -java.corba_CLEAN := .properties +java.corba_COPY += .prp +java.corba_CLEAN += .properties java.corba_EXCLUDES += \ com/sun/corba/se/PortableActivationIDL \ @@ -301,99 +301,99 @@ java.corba_EXCLUDE_FILES += \ ################################################################################ java.xml_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS -java.xml_CLEAN := .properties +java.xml_CLEAN += .properties ################################################################################ java.xml.bind_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS -java.xml.bind_CLEAN := .properties +java.xml.bind_CLEAN += .properties ################################################################################ java.xml.soap_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS -java.xml.soap_CLEAN := .properties +java.xml.soap_CLEAN += .properties ################################################################################ java.xml.ws_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS -java.xml.ws_COPY := .xml -java.xml.ws_CLEAN := .properties +java.xml.ws_COPY += .xml +java.xml.ws_CLEAN += .properties ################################################################################ -java.naming_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' -Xlint:-exports -java.naming_CLEAN := jndiprovider.properties +java.naming_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' -Xlint:-exports +java.naming_CLEAN += jndiprovider.properties ################################################################################ -java.security.saaj_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' -java.security.saaj_CLEAN := .properties +java.security.saaj_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' +java.security.saaj_CLEAN += .properties ################################################################################ -java.security.jgss_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' +java.security.jgss_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' ################################################################################ -java.smartcardio_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' +java.smartcardio_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' ################################################################################ -java.xml.crypto_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' -java.xml.crypto_COPY := .dtd .xml -java.xml.crypto_CLEAN := .properties +java.xml.crypto_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:java.*,javax.*' +java.xml.crypto_COPY += .dtd .xml +java.xml.crypto_CLEAN += .properties ################################################################################ -jdk.charsets_COPY := .dat +jdk.charsets_COPY += .dat ################################################################################ ################################################################################ -jdk.compiler_ADD_JAVAC_FLAGS := -Xdoclint:all/protected '-Xdoclint/package:-com.sun.tools.*,-jdk.internal.*' \ +jdk.compiler_ADD_JAVAC_FLAGS += -Xdoclint:all/protected '-Xdoclint/package:-com.sun.tools.*,-jdk.internal.*' \ -XDstringConcat=inline -jdk.compiler_CLEAN_FILES := $(wildcard \ +jdk.compiler_CLEAN_FILES += $(wildcard \ $(patsubst %, $(JDK_TOPDIR)/src/jdk.compiler/share/classes/%/*.properties, \ sun/tools/serialver/resources)) ################################################################################ -jdk.hotspot.agent_ADD_JAVAC_FLAGS := $(DISABLE_WARNINGS),-overrides -jdk.hotspot.agent_COPY := .gif .png sa.js .properties +jdk.hotspot.agent_ADD_JAVAC_FLAGS += $(DISABLE_WARNINGS),-overrides +jdk.hotspot.agent_COPY += .gif .png sa.js .properties ################################################################################ -jdk.editpad_COPY := .properties +jdk.editpad_COPY += .properties ################################################################################ -jdk.jshell_COPY := .jsh .properties +jdk.jshell_COPY += .jsh .properties ################################################################################ -jdk.internal.le_COPY := .properties +jdk.internal.le_COPY += .properties ################################################################################ -jdk.jcmd_COPY := _options +jdk.jcmd_COPY += _options ################################################################################ -jdk.dynalink_CLEAN := .properties +jdk.dynalink_CLEAN += .properties ################################################################################ -jdk.javadoc_COPY := .xml .css .js .png +jdk.javadoc_COPY += .xml .css .js .png ################################################################################ -jdk.jartool_ADD_JAVAC_FLAGS := -XDstringConcat=inline +jdk.jartool_ADD_JAVAC_FLAGS += -XDstringConcat=inline ################################################################################ jdk.rmic_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS -jdk.rmic_CLEAN := .properties +jdk.rmic_CLEAN += .properties ################################################################################ @@ -421,16 +421,16 @@ endif ################################################################################ -jdk.jconsole_COPY := .gif .png +jdk.jconsole_COPY += .gif .png -jdk.jconsole_CLEAN_FILES := $(wildcard \ +jdk.jconsole_CLEAN_FILES += $(wildcard \ $(JDK_TOPDIR)/src/jdk.jconsole/share/classes/sun/tools/jconsole/resources/*.properties) ################################################################################ -jdk.jdeps_COPY := .txt +jdk.jdeps_COPY += .txt -jdk.jdeps_CLEAN_FILES := $(wildcard \ +jdk.jdeps_CLEAN_FILES += $(wildcard \ $(JDK_TOPDIR)/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/resources/*.properties \ $(JDK_TOPDIR)/src/jdk.jdeps/share/classes/com/sun/tools/javap/resources/*.properties) @@ -447,15 +447,15 @@ jdk.jdi_EXCLUDE_FILES += jdi-overview.html ################################################################################ -jdk.dev_CLEAN_FILES := $(wildcard \ +jdk.dev_CLEAN_FILES += $(wildcard \ $(patsubst %, $(JDK_TOPDIR)/src/jdk.dev/share/classes/%/*.properties, \ com/sun/tools/script/shell)) -jdk.dev_COPY := .js oqlhelp.html .txt +jdk.dev_COPY += .js oqlhelp.html .txt ################################################################################ -jdk.internal.jvmstat_COPY := aliasmap +jdk.internal.jvmstat_COPY += aliasmap ################################################################################ @@ -465,11 +465,11 @@ jdk.internal.jvmstat_COPY := aliasmap # The exports are needed since JVMCI is dynamically exported (see # jdk.vm.ci.services.internal.ReflectionAccessJDK::openJVMCITo). -jdk.internal.vm.ci_ADD_JAVAC_FLAGS := -parameters -Xlint:-exports -XDstringConcat=inline +jdk.internal.vm.ci_ADD_JAVAC_FLAGS += -parameters -Xlint:-exports -XDstringConcat=inline ################################################################################ -jdk.internal.vm.compiler_ADD_JAVAC_FLAGS := -parameters -XDstringConcat=inline \ +jdk.internal.vm.compiler_ADD_JAVAC_FLAGS += -parameters -XDstringConcat=inline \ --add-exports jdk.internal.vm.ci/jdk.vm.ci.aarch64=jdk.internal.vm.compiler \ --add-exports jdk.internal.vm.ci/jdk.vm.ci.amd64=jdk.internal.vm.compiler \ --add-exports jdk.internal.vm.ci/jdk.vm.ci.code=jdk.internal.vm.compiler \ @@ -528,7 +528,7 @@ jdk.internal.vm.compiler_EXCLUDES += \ # The exports are needed since JVMCI is dynamically exported (see # jdk.vm.ci.services.internal.ReflectionAccessJDK::openJVMCITo). -jdk.aot_ADD_JAVAC_FLAGS := -parameters -XDstringConcat=inline \ +jdk.aot_ADD_JAVAC_FLAGS += -parameters -XDstringConcat=inline \ --add-exports jdk.internal.vm.ci/jdk.vm.ci.aarch64=jdk.internal.vm.compiler,jdk.aot \ --add-exports jdk.internal.vm.ci/jdk.vm.ci.amd64=jdk.internal.vm.compiler,jdk.aot \ --add-exports jdk.internal.vm.ci/jdk.vm.ci.code=jdk.internal.vm.compiler,jdk.aot \ @@ -547,21 +547,21 @@ jdk.aot_ADD_JAVAC_FLAGS := -parameters -XDstringConcat=inline \ ################################################################################ jdk.xml.bind_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS -jdk.xml.bind_CLEAN := .properties -jdk.xml.bind_COPY := .xsd JAXBContextFactory.java ZeroOneBooleanAdapter.java +jdk.xml.bind_CLEAN += .properties +jdk.xml.bind_COPY += .xsd JAXBContextFactory.java ZeroOneBooleanAdapter.java ################################################################################ jdk.xml.ws_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS -jdk.xml.ws_CLEAN := .properties +jdk.xml.ws_CLEAN += .properties ################################################################################ -sun.charsets_COPY := .dat +sun.charsets_COPY += .dat ################################################################################ -jdk.localedata_COPY := _dict _th +jdk.localedata_COPY += _dict _th # Exclude BreakIterator classes that are just used in compile process to generate # data files and shouldn't go in the product jdk.localedata_EXCLUDE_FILES += sun/text/resources/ext/BreakIteratorRules_th.java

    TargetpropOrderClassBodyComplexTypeSimpleType
    TargetpropOrderClassBodyComplexTypeSimpleType
    Class{}[property]+ {@literal ->} elements[property]+ {@literal ->} elementscomplexcontent
    xs:all
    Classnon empty[property]+ {@literal ->} elements[property]+ {@literal ->} elementscomplexcontent
    xs:sequence
    ClassXno property {@literal ->} elementno property {@literal ->} elementcomplexcontent
    empty sequence
    ClassX1 [{@code @XmlValue} property] {@literal &&}
    [property]+ {@literal ->} attributes
    1 [{@code @XmlValue} property] {@literal &&}
    [property]+ {@literal ->} attributes
    simplecontent
    ClassX1 [{@code @XmlValue} property] {@literal &&}
    no properties {@literal ->} attribute
    1 [{@code @XmlValue} property] {@literal &&}
    no properties {@literal ->} attribute
    simpletype