From 3b0e59e8d80c443d139d87389dc980b9f67981a0 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Mon, 11 Dec 2017 11:45:02 -0800 Subject: [PATCH 01/26] 8185582: Update Zip implementation to use Cleaner, not finalizers Reviewed-by: plevart, rriggs, mchung --- .../share/classes/java/util/zip/Deflater.java | 58 +-- .../share/classes/java/util/zip/Inflater.java | 61 +-- .../classes/java/util/zip/ZStreamRef.java | 79 +++- .../share/classes/java/util/zip/ZipFile.java | 388 ++++++++++++------ .../util/zip/ZipFile/FinalizeZipFile.java | 8 +- .../java/util/zip/ZipFile/TestCleaner.java | 246 +++++++++++ 6 files changed, 648 insertions(+), 192 deletions(-) create mode 100644 test/jdk/java/util/zip/ZipFile/TestCleaner.java diff --git a/src/java.base/share/classes/java/util/zip/Deflater.java b/src/java.base/share/classes/java/util/zip/Deflater.java index cff04b6cd19..bec7d460c84 100644 --- a/src/java.base/share/classes/java/util/zip/Deflater.java +++ b/src/java.base/share/classes/java/util/zip/Deflater.java @@ -67,12 +67,26 @@ package java.util.zip; * } * * + * @apiNote + * To release resources used by this {@code Deflater}, the {@link #end()} method + * should be called explicitly. Subclasses are responsible for the cleanup of resources + * acquired by the subclass. Subclasses that override {@link #finalize()} in order + * to perform cleanup should be modified to use alternative cleanup mechanisms such + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method. + * + * @implSpec + * If this {@code Deflater} has been subclassed and the {@code end} method has been + * overridden, the {@code end} method will be called by the finalization when the + * deflater is unreachable. But the subclasses should not depend on this specific + * implementation; the finalization is not reliable and the {@code finalize} method + * is deprecated to be removed. + * * @see Inflater * @author David Connelly * @since 1.1 */ -public -class Deflater { + +public class Deflater { private final ZStreamRef zsRef; private byte[] buf = new byte[0]; @@ -169,7 +183,9 @@ class Deflater { public Deflater(int level, boolean nowrap) { this.level = level; this.strategy = DEFAULT_STRATEGY; - this.zsRef = new ZStreamRef(init(level, DEFAULT_STRATEGY, nowrap)); + this.zsRef = ZStreamRef.get(this, + () -> init(level, DEFAULT_STRATEGY, nowrap), + Deflater::end); } /** @@ -534,38 +550,32 @@ class Deflater { /** * Closes the compressor and discards any unprocessed input. + * * This method should be called when the compressor is no longer - * being used, but will also be called automatically by the - * finalize() method. Once this method is called, the behavior - * of the Deflater object is undefined. + * being used. Once this method is called, the behavior of the + * Deflater object is undefined. */ public void end() { synchronized (zsRef) { - long addr = zsRef.address(); - zsRef.clear(); - if (addr != 0) { - end(addr); - buf = null; - } + zsRef.clean(); + buf = null; } } /** * Closes the compressor when garbage is collected. * - * @deprecated The {@code finalize} method has been deprecated. - * Subclasses that override {@code finalize} in order to perform cleanup - * should be modified to use alternative cleanup mechanisms and - * to remove the overriding {@code finalize} method. - * When overriding the {@code finalize} method, its implementation must explicitly - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. - * See the specification for {@link Object#finalize()} for further - * information about migration options. + * @deprecated The {@code finalize} method has been deprecated and will be + * removed. It is implemented as a no-op. Subclasses that override + * {@code finalize} in order to perform cleanup should be modified to use + * alternative cleanup mechanisms and to remove the overriding {@code finalize} + * method. The recommended cleanup for compressor is to explicitly call + * {@code end} method when it is no longer in use. If the {@code end} is + * not invoked explicitly the resource of the compressor will be released + * when the instance becomes unreachable. */ - @Deprecated(since="9") - protected void finalize() { - end(); - } + @Deprecated(since="9", forRemoval=true) + protected void finalize() {} private void ensureOpen() { assert Thread.holdsLock(zsRef); diff --git a/src/java.base/share/classes/java/util/zip/Inflater.java b/src/java.base/share/classes/java/util/zip/Inflater.java index 5a098d0c486..9e02f4dbc5c 100644 --- a/src/java.base/share/classes/java/util/zip/Inflater.java +++ b/src/java.base/share/classes/java/util/zip/Inflater.java @@ -66,13 +66,27 @@ package java.util.zip; * } * * + * @apiNote + * To release resources used by this {@code Inflater}, the {@link #end()} method + * should be called explicitly. Subclasses are responsible for the cleanup of resources + * acquired by the subclass. Subclasses that override {@link #finalize()} in order + * to perform cleanup should be modified to use alternative cleanup mechanisms such + * as {@link java.lang.ref.Cleaner} and remove the overriding {@code finalize} method. + * + * @implSpec + * If this {@code Inflater} has been subclassed and the {@code end} method has been + * overridden, the {@code end} method will be called by the finalization when the + * inflater is unreachable. But the subclasses should not depend on this specific + * implementation; the finalization is not reliable and the {@code finalize} method + * is deprecated to be removed. + * * @see Deflater * @author David Connelly * @since 1.1 * */ -public -class Inflater { + +public class Inflater { private final ZStreamRef zsRef; private byte[] buf = defaultBuf; @@ -101,7 +115,7 @@ class Inflater { * @param nowrap if true then support GZIP compatible compression */ public Inflater(boolean nowrap) { - zsRef = new ZStreamRef(init(nowrap)); + this.zsRef = ZStreamRef.get(this, () -> init(nowrap), Inflater::end); } /** @@ -361,38 +375,37 @@ class Inflater { /** * Closes the decompressor and discards any unprocessed input. + * * This method should be called when the decompressor is no longer - * being used, but will also be called automatically by the finalize() - * method. Once this method is called, the behavior of the Inflater - * object is undefined. + * being used. Once this method is called, the behavior of the + * Inflater object is undefined. */ public void end() { synchronized (zsRef) { - long addr = zsRef.address(); - zsRef.clear(); - if (addr != 0) { - end(addr); - buf = null; - } + zsRef.clean(); + buf = null; } } /** * Closes the decompressor when garbage is collected. * - * @deprecated The {@code finalize} method has been deprecated. - * Subclasses that override {@code finalize} in order to perform cleanup - * should be modified to use alternative cleanup mechanisms and - * to remove the overriding {@code finalize} method. - * When overriding the {@code finalize} method, its implementation must explicitly - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. - * See the specification for {@link Object#finalize()} for further - * information about migration options. + * @implSpec + * If this {@code Inflater} has been subclassed and the {@code end} method + * has been overridden, the {@code end} method will be called when the + * inflater is unreachable. + * + * @deprecated The {@code finalize} method has been deprecated and will be + * removed. It is implemented as a no-op. Subclasses that override + * {@code finalize} in order to perform cleanup should be modified to use + * alternative cleanup mechanisms and remove the overriding {@code finalize} + * method. The recommended cleanup for compressor is to explicitly call + * {@code end} method when it is no longer in use. If the {@code end} is + * not invoked explicitly the resource of the compressor will be released + * when the instance becomes unreachable, */ - @Deprecated(since="9") - protected void finalize() { - end(); - } + @Deprecated(since="9", forRemoval=true) + protected void finalize() {} private void ensureOpen () { assert Thread.holdsLock(zsRef); diff --git a/src/java.base/share/classes/java/util/zip/ZStreamRef.java b/src/java.base/share/classes/java/util/zip/ZStreamRef.java index 09b2f308dfc..2a32d7cd8a8 100644 --- a/src/java.base/share/classes/java/util/zip/ZStreamRef.java +++ b/src/java.base/share/classes/java/util/zip/ZStreamRef.java @@ -25,22 +25,89 @@ package java.util.zip; +import java.util.function.LongConsumer; +import java.util.function.LongSupplier; +import java.lang.ref.Cleaner.Cleanable; +import jdk.internal.ref.CleanerFactory; + /** - * A reference to the native zlib's z_stream structure. + * A reference to the native zlib's z_stream structure. It also + * serves as the "cleaner" to clean up the native resource when + * the deflater or infalter is ended, closed or cleaned. */ +class ZStreamRef implements Runnable { -class ZStreamRef { + private LongConsumer end; + private long address; + private final Cleanable cleanable; - private volatile long address; - ZStreamRef (long address) { - this.address = address; + private ZStreamRef (Object owner, LongSupplier addr, LongConsumer end) { + this.cleanable = CleanerFactory.cleaner().register(owner, this); + this.end = end; + this.address = addr.getAsLong(); } long address() { return address; } - void clear() { + void clean() { + cleanable.clean(); + } + + public synchronized void run() { + long addr = address; address = 0; + if (addr != 0) { + end.accept(addr); + } + } + + private ZStreamRef (LongSupplier addr, LongConsumer end) { + this.cleanable = null; + this.end = end; + this.address = addr.getAsLong(); + } + + /* + * If {@code Inflater/Deflater} has been subclassed and the {@code end} method + * is overridden, uses {@code finalizer} mechanism for resource cleanup. So + * {@code end} method can be called when the {@code Inflater/Deflater} is + * unreachable. This mechanism will be removed when the {@code finalize} method + * is removed from {@code Inflater/Deflater}. + */ + static ZStreamRef get(Object owner, LongSupplier addr, LongConsumer end) { + Class clz = owner.getClass(); + while (clz != Deflater.class && clz != Inflater.class) { + try { + clz.getDeclaredMethod("end"); + return new FinalizableZStreamRef(owner, addr, end); + } catch (NoSuchMethodException nsme) {} + clz = clz.getSuperclass(); + } + return new ZStreamRef(owner, addr, end); + } + + private static class FinalizableZStreamRef extends ZStreamRef { + final Object owner; + + FinalizableZStreamRef (Object owner, LongSupplier addr, LongConsumer end) { + super(addr, end); + this.owner = owner; + } + + @Override + void clean() { + run(); + } + + @Override + @SuppressWarnings("deprecation") + protected void finalize() { + if (owner instanceof Inflater) + ((Inflater)owner).end(); + else + ((Deflater)owner).end(); + } } } diff --git a/src/java.base/share/classes/java/util/zip/ZipFile.java b/src/java.base/share/classes/java/util/zip/ZipFile.java index db8f3ac5c0f..b34f11cc781 100644 --- a/src/java.base/share/classes/java/util/zip/ZipFile.java +++ b/src/java.base/share/classes/java/util/zip/ZipFile.java @@ -31,22 +31,24 @@ import java.io.IOException; import java.io.EOFException; import java.io.File; import java.io.RandomAccessFile; +import java.io.UncheckedIOException; +import java.lang.ref.Cleaner.Cleanable; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.attribute.BasicFileAttributes; -import java.nio.file.Path; import java.nio.file.Files; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Deque; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; -import java.util.Map; import java.util.Objects; import java.util.NoSuchElementException; +import java.util.Set; import java.util.Spliterator; import java.util.Spliterators; import java.util.WeakHashMap; @@ -61,8 +63,8 @@ import jdk.internal.misc.JavaUtilZipFileAccess; import jdk.internal.misc.SharedSecrets; import jdk.internal.misc.VM; import jdk.internal.perf.PerfCounter; +import jdk.internal.ref.CleanerFactory; -import static java.util.zip.ZipConstants.*; import static java.util.zip.ZipConstants64.*; import static java.util.zip.ZipUtils.*; @@ -73,6 +75,21 @@ import static java.util.zip.ZipUtils.*; * or method in this class will cause a {@link NullPointerException} to be * thrown. * + * @apiNote + * To release resources used by this {@code ZipFile}, the {@link #close()} method + * should be called explicitly or by try-with-resources. Subclasses are responsible + * for the cleanup of resources acquired by the subclass. Subclasses that override + * {@link #finalize()} in order to perform cleanup should be modified to use alternative + * cleanup mechanisms such as {@link java.lang.ref.Cleaner} and remove the overriding + * {@code finalize} method. + * + * @implSpec + * If this {@code ZipFile} has been subclassed and the {@code close} method has + * been overridden, the {@code close} method will be called by the finalization + * when {@code ZipFile} is unreachable. But the subclasses should not depend on + * this specific implementation; the finalization is not reliable and the + * {@code finalize} method is deprecated to be removed. + * * @author David Connelly * @since 1.1 */ @@ -81,9 +98,15 @@ class ZipFile implements ZipConstants, Closeable { private final String name; // zip file name private volatile boolean closeRequested; - private Source zsrc; private ZipCoder zc; + // The "resource" used by this zip file that needs to be + // cleaned after use. + // a) the input streams that need to be closed + // b) the list of cached Inflater objects + // c) the "native" source of this zip file. + private final CleanableResource res; + private static final int STORED = ZipEntry.STORED; private static final int DEFLATED = ZipEntry.DEFLATED; @@ -214,10 +237,13 @@ class ZipFile implements ZipConstants, Closeable { } } Objects.requireNonNull(charset, "charset"); + this.zc = ZipCoder.get(charset); this.name = name; long t0 = System.nanoTime(); - this.zsrc = Source.get(file, (mode & OPEN_DELETE) != 0); + + this.res = CleanableResource.get(this, file, mode); + PerfCounter.getZipFileOpenTime().addElapsedTimeFrom(t0); PerfCounter.getZipFileCount().increment(); } @@ -284,10 +310,10 @@ class ZipFile implements ZipConstants, Closeable { public String getComment() { synchronized (this) { ensureOpen(); - if (zsrc.comment == null) { + if (res.zsrc.comment == null) { return null; } - return zc.toString(zsrc.comment); + return zc.toString(res.zsrc.comment); } } @@ -318,7 +344,7 @@ class ZipFile implements ZipConstants, Closeable { synchronized (this) { ensureOpen(); byte[] bname = zc.getBytes(name); - int pos = zsrc.getEntryPos(bname, true); + int pos = res.zsrc.getEntryPos(bname, true); if (pos != -1) { return getZipEntry(name, bname, pos, func); } @@ -326,10 +352,6 @@ class ZipFile implements ZipConstants, Closeable { return null; } - // The outstanding inputstreams that need to be closed, - // mapped to the inflater objects they use. - private final Map streams = new WeakHashMap<>(); - /** * Returns an input stream for reading the contents of the specified * zip file entry. @@ -348,6 +370,8 @@ class ZipFile implements ZipConstants, Closeable { Objects.requireNonNull(entry, "entry"); int pos = -1; ZipFileInputStream in = null; + Source zsrc = res.zsrc; + Set istreams = res.istreams; synchronized (this) { ensureOpen(); if (Objects.equals(lastEntryName, entry.name)) { @@ -363,8 +387,8 @@ class ZipFile implements ZipConstants, Closeable { in = new ZipFileInputStream(zsrc.cen, pos); switch (CENHOW(zsrc.cen, pos)) { case STORED: - synchronized (streams) { - streams.put(in, null); + synchronized (istreams) { + istreams.add(in); } return in; case DEFLATED: @@ -377,10 +401,9 @@ class ZipFile implements ZipConstants, Closeable { if (size <= 0) { size = 4096; } - Inflater inf = getInflater(); - InputStream is = new ZipFileInflaterInputStream(in, inf, (int)size); - synchronized (streams) { - streams.put(is, inf); + InputStream is = new ZipFileInflaterInputStream(in, res, (int)size); + synchronized (istreams) { + istreams.add(is); } return is; default: @@ -392,25 +415,30 @@ class ZipFile implements ZipConstants, Closeable { private class ZipFileInflaterInputStream extends InflaterInputStream { private volatile boolean closeRequested; private boolean eof = false; + private final Cleanable cleanable; - ZipFileInflaterInputStream(ZipFileInputStream zfin, Inflater inf, - int size) { - super(zfin, inf, size); + ZipFileInflaterInputStream(ZipFileInputStream zfin, + CleanableResource res, int size) { + this(zfin, res, res.getInflater(), size); } + private ZipFileInflaterInputStream(ZipFileInputStream zfin, + CleanableResource res, + Inflater inf, int size) { + super(zfin, inf, size); + this.cleanable = CleanerFactory.cleaner().register(this, + () -> res.releaseInflater(inf)); + } + public void close() throws IOException { if (closeRequested) return; closeRequested = true; - super.close(); - Inflater inf; - synchronized (streams) { - inf = streams.remove(this); - } - if (inf != null) { - releaseInflater(inf); + synchronized (res.istreams) { + res.istreams.remove(this); } + cleanable.clean(); } // Override fill() method to provide an extra "dummy" byte @@ -436,44 +464,8 @@ class ZipFile implements ZipConstants, Closeable { return (avail > (long) Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) avail); } - - @SuppressWarnings("deprecation") - protected void finalize() throws Throwable { - close(); - } } - /* - * Gets an inflater from the list of available inflaters or allocates - * a new one. - */ - private Inflater getInflater() { - Inflater inf; - synchronized (inflaterCache) { - while ((inf = inflaterCache.poll()) != null) { - if (!inf.ended()) { - return inf; - } - } - } - return new Inflater(true); - } - - /* - * Releases the specified inflater to the list of available inflaters. - */ - private void releaseInflater(Inflater inf) { - if (!inf.ended()) { - inf.reset(); - synchronized (inflaterCache) { - inflaterCache.add(inf); - } - } - } - - // List of available Inflater objects for decompression - private final Deque inflaterCache = new ArrayDeque<>(); - /** * Returns the path name of the ZIP file. * @return the path name of the ZIP file @@ -518,7 +510,7 @@ class ZipFile implements ZipConstants, Closeable { throw new NoSuchElementException(); } // each "entry" has 3 ints in table entries - return (T)getZipEntry(null, null, zsrc.getEntryPos(i++ * 3), gen); + return (T)getZipEntry(null, null, res.zsrc.getEntryPos(i++ * 3), gen); } } @@ -536,14 +528,14 @@ class ZipFile implements ZipConstants, Closeable { public Enumeration entries() { synchronized (this) { ensureOpen(); - return new ZipEntryIterator(zsrc.total, ZipEntry::new); + return new ZipEntryIterator(res.zsrc.total, ZipEntry::new); } } private Enumeration entries(Function func) { synchronized (this) { ensureOpen(); - return new ZipEntryIterator(zsrc.total, func); + return new ZipEntryIterator(res.zsrc.total, func); } } @@ -568,7 +560,7 @@ class ZipFile implements ZipConstants, Closeable { if (index >= 0 && index < fence) { synchronized (ZipFile.this) { ensureOpen(); - action.accept(gen.apply(zsrc.getEntryPos(index++ * 3))); + action.accept(gen.apply(res.zsrc.getEntryPos(index++ * 3))); } return true; } @@ -589,13 +581,13 @@ class ZipFile implements ZipConstants, Closeable { public Stream stream() { synchronized (this) { ensureOpen(); - return StreamSupport.stream(new EntrySpliterator<>(0, zsrc.total, + return StreamSupport.stream(new EntrySpliterator<>(0, res.zsrc.total, pos -> getZipEntry(null, null, pos, ZipEntry::new)), false); } } private String getEntryName(int pos) { - byte[] cen = zsrc.cen; + byte[] cen = res.zsrc.cen; int nlen = CENNAM(cen, pos); int clen = CENCOM(cen, pos); int flag = CENFLG(cen, pos); @@ -620,7 +612,7 @@ class ZipFile implements ZipConstants, Closeable { synchronized (this) { ensureOpen(); return StreamSupport.stream( - new EntrySpliterator<>(0, zsrc.total, this::getEntryName), false); + new EntrySpliterator<>(0, res.zsrc.total, this::getEntryName), false); } } @@ -638,7 +630,7 @@ class ZipFile implements ZipConstants, Closeable { private Stream stream(Function func) { synchronized (this) { ensureOpen(); - return StreamSupport.stream(new EntrySpliterator<>(0, zsrc.total, + return StreamSupport.stream(new EntrySpliterator<>(0, res.zsrc.total, pos -> (JarEntry)getZipEntry(null, null, pos, func)), false); } } @@ -649,7 +641,7 @@ class ZipFile implements ZipConstants, Closeable { /* Checks ensureOpen() before invoke this method */ private ZipEntry getZipEntry(String name, byte[] bname, int pos, Function func) { - byte[] cen = zsrc.cen; + byte[] cen = res.zsrc.cen; int nlen = CENNAM(cen, pos); int elen = CENEXT(cen, pos); int clen = CENCOM(cen, pos); @@ -698,12 +690,170 @@ class ZipFile implements ZipConstants, Closeable { public int size() { synchronized (this) { ensureOpen(); - return zsrc.total; + return res.zsrc.total; + } + } + + private static class CleanableResource implements Runnable { + // The outstanding inputstreams that need to be closed + final Set istreams; + + // List of cached Inflater objects for decompression + Deque inflaterCache; + + final Cleanable cleanable; + + Source zsrc; + + CleanableResource(ZipFile zf, File file, int mode) throws IOException { + this.cleanable = CleanerFactory.cleaner().register(zf, this); + this.istreams = Collections.newSetFromMap(new WeakHashMap<>()); + this.inflaterCache = new ArrayDeque<>(); + this.zsrc = Source.get(file, (mode & OPEN_DELETE) != 0); + } + + void clean() { + cleanable.clean(); + } + + /* + * Gets an inflater from the list of available inflaters or allocates + * a new one. + */ + Inflater getInflater() { + Inflater inf; + synchronized (inflaterCache) { + if ((inf = inflaterCache.poll()) != null) { + return inf; + } + } + return new Inflater(true); + } + + /* + * Releases the specified inflater to the list of available inflaters. + */ + void releaseInflater(Inflater inf) { + Deque inflaters = this.inflaterCache; + if (inflaters != null) { + synchronized (inflaters) { + // double checked! + if (inflaters == this.inflaterCache) { + inf.reset(); + inflaters.add(inf); + return; + } + } + } + // inflaters cache already closed - just end it. + inf.end(); + } + + public void run() { + IOException ioe = null; + + // Release cached inflaters and close the cache first + Deque inflaters = this.inflaterCache; + if (inflaters != null) { + synchronized (inflaters) { + // no need to double-check as only one thread gets a + // chance to execute run() (Cleaner guarantee)... + Inflater inf; + while ((inf = inflaters.poll()) != null) { + inf.end(); + } + // close inflaters cache + this.inflaterCache = null; + } + } + + // Close streams, release their inflaters + if (istreams != null) { + synchronized (istreams) { + if (!istreams.isEmpty()) { + InputStream[] copy = istreams.toArray(new InputStream[0]); + istreams.clear(); + for (InputStream is : copy) { + try { + is.close(); + } catch (IOException e) { + if (ioe == null) ioe = e; + else ioe.addSuppressed(e); + } + } + } + } + } + + // Release zip src + if (zsrc != null) { + synchronized (zsrc) { + try { + Source.release(zsrc); + zsrc = null; + } catch (IOException e) { + if (ioe == null) ioe = e; + else ioe.addSuppressed(e); + } + } + } + if (ioe != null) { + throw new UncheckedIOException(ioe); + } + } + + CleanableResource(File file, int mode) + throws IOException { + this.cleanable = null; + this.istreams = Collections.newSetFromMap(new WeakHashMap<>()); + this.inflaterCache = new ArrayDeque<>(); + this.zsrc = Source.get(file, (mode & OPEN_DELETE) != 0); + } + + /* + * If {@code ZipFile} has been subclassed and the {@code close} method is + * overridden, uses the {@code finalizer} mechanism for resource cleanup. + * So {@code close} method can be called when the the {@code ZipFile} is + * unreachable. This mechanism will be removed when {@code finalize} method + * is removed from {@code ZipFile}. + */ + static CleanableResource get(ZipFile zf, File file, int mode) + throws IOException { + Class clz = zf.getClass(); + while (clz != ZipFile.class) { + try { + clz.getDeclaredMethod("close"); + return new FinalizableResource(zf, file, mode); + } catch (NoSuchMethodException nsme) {} + clz = clz.getSuperclass(); + } + return new CleanableResource(zf, file, mode); + } + + static class FinalizableResource extends CleanableResource { + ZipFile zf; + FinalizableResource(ZipFile zf, File file, int mode) + throws IOException { + super(file, mode); + this.zf = zf; + } + + @Override + void clean() { + run(); + } + + @Override + @SuppressWarnings("deprecation") + protected void finalize() throws IOException { + zf.close(); + } } } /** * Closes the ZIP file. + * *

Closing this ZIP file will close all of the input streams * previously returned by invocations of the {@link #getInputStream * getInputStream} method. @@ -717,31 +867,12 @@ class ZipFile implements ZipConstants, Closeable { closeRequested = true; synchronized (this) { - // Close streams, release their inflaters - synchronized (streams) { - if (!streams.isEmpty()) { - Map copy = new HashMap<>(streams); - streams.clear(); - for (Map.Entry e : copy.entrySet()) { - e.getKey().close(); - Inflater inf = e.getValue(); - if (inf != null) { - inf.end(); - } - } - } - } - // Release cached inflaters - synchronized (inflaterCache) { - Inflater inf; - while ((inf = inflaterCache.poll()) != null) { - inf.end(); - } - } - // Release zip src - if (zsrc != null) { - Source.close(zsrc); - zsrc = null; + // Close streams, release their inflaters, release cached inflaters + // and release zip source + try { + res.clean(); + } catch (UncheckedIOException ioe) { + throw ioe.getCause(); } } } @@ -750,34 +881,26 @@ class ZipFile implements ZipConstants, Closeable { * Ensures that the system resources held by this ZipFile object are * released when there are no more references to it. * - *

- * Since the time when GC would invoke this method is undetermined, - * it is strongly recommended that applications invoke the {@code close} - * method as soon they have finished accessing this {@code ZipFile}. - * This will prevent holding up system resources for an undetermined - * length of time. + * @deprecated The {@code finalize} method has been deprecated and will be + * removed. It is implemented as a no-op. Subclasses that override + * {@code finalize} in order to perform cleanup should be modified to + * use alternative cleanup mechanisms and to remove the overriding + * {@code finalize} method. The recommended cleanup for ZipFile object + * is to explicitly invoke {@code close} method when it is no longer in + * use, or use try-with-resources. If the {@code close} is not invoked + * explicitly the resources held by this object will be released when + * the instance becomes unreachable. * - * @deprecated The {@code finalize} method has been deprecated. - * Subclasses that override {@code finalize} in order to perform cleanup - * should be modified to use alternative cleanup mechanisms and - * to remove the overriding {@code finalize} method. - * When overriding the {@code finalize} method, its implementation must explicitly - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. - * See the specification for {@link Object#finalize()} for further - * information about migration options. * @throws IOException if an I/O error has occurred - * @see java.util.zip.ZipFile#close() */ - @Deprecated(since="9") - protected void finalize() throws IOException { - close(); - } + @Deprecated(since="9", forRemoval=true) + protected void finalize() throws IOException {} private void ensureOpen() { if (closeRequested) { throw new IllegalStateException("zip file closed"); } - if (zsrc == null) { + if (res.zsrc == null) { throw new IllegalStateException("The object is not initialized."); } } @@ -798,7 +921,7 @@ class ZipFile implements ZipConstants, Closeable { protected long rem; // number of remaining bytes within entry protected long size; // uncompressed size of this entry - ZipFileInputStream(byte[] cen, int cenpos) throws IOException { + ZipFileInputStream(byte[] cen, int cenpos) { rem = CENSIZ(cen, cenpos); size = CENLEN(cen, cenpos); pos = CENOFF(cen, cenpos); @@ -808,10 +931,10 @@ class ZipFile implements ZipConstants, Closeable { checkZIP64(cen, cenpos); } // negative for lazy initialization, see getDataOffset(); - pos = - (pos + ZipFile.this.zsrc.locpos); + pos = - (pos + ZipFile.this.res.zsrc.locpos); } - private void checkZIP64(byte[] cen, int cenpos) throws IOException { + private void checkZIP64(byte[] cen, int cenpos) { int off = cenpos + CENHDR + CENNAM(cen, cenpos); int end = off + CENEXT(cen, cenpos); while (off + 4 < end) { @@ -857,7 +980,7 @@ class ZipFile implements ZipConstants, Closeable { if (pos <= 0) { byte[] loc = new byte[LOCHDR]; pos = -pos; - int len = ZipFile.this.zsrc.readFullyAt(loc, 0, loc.length, pos); + int len = ZipFile.this.res.zsrc.readFullyAt(loc, 0, loc.length, pos); if (len != LOCHDR) { throw new ZipException("ZipFile error reading zip file"); } @@ -882,7 +1005,7 @@ class ZipFile implements ZipConstants, Closeable { if (len <= 0) { return 0; } - len = ZipFile.this.zsrc.readAt(b, off, len, pos); + len = ZipFile.this.res.zsrc.readAt(b, off, len, pos); if (len > 0) { pos += len; rem -= len; @@ -932,15 +1055,11 @@ class ZipFile implements ZipConstants, Closeable { } closeRequested = true; rem = 0; - synchronized (streams) { - streams.remove(this); + synchronized (res.istreams) { + res.istreams.remove(this); } } - @SuppressWarnings("deprecation") - protected void finalize() { - close(); - } } /** @@ -952,6 +1071,7 @@ class ZipFile implements ZipConstants, Closeable { private String[] getMetaInfEntryNames() { synchronized (this) { ensureOpen(); + Source zsrc = res.zsrc; if (zsrc.metanames == null) { return null; } @@ -972,7 +1092,7 @@ class ZipFile implements ZipConstants, Closeable { new JavaUtilZipFileAccess() { @Override public boolean startsWithLocHeader(ZipFile zip) { - return zip.zsrc.startsWithLoc; + return zip.res.zsrc.startsWithLoc; } @Override public String[] getMetaInfEntryNames(ZipFile zip) { @@ -1080,7 +1200,7 @@ class ZipFile implements ZipConstants, Closeable { private static final HashMap files = new HashMap<>(); - public static Source get(File file, boolean toDelete) throws IOException { + static Source get(File file, boolean toDelete) throws IOException { Key key = new Key(file, Files.readAttributes(file.toPath(), BasicFileAttributes.class)); Source src = null; @@ -1105,9 +1225,9 @@ class ZipFile implements ZipConstants, Closeable { } } - private static void close(Source src) throws IOException { + static void release(Source src) throws IOException { synchronized (files) { - if (--src.refs == 0) { + if (src != null && --src.refs == 0) { files.remove(src.key); src.close(); } diff --git a/test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java b/test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java index a5bd536a2d8..8641e183341 100644 --- a/test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java +++ b/test/jdk/java/util/zip/ZipFile/FinalizeZipFile.java @@ -31,6 +31,7 @@ import java.io.*; import java.util.Random; import java.util.zip.*; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; public class FinalizeZipFile { @@ -78,10 +79,9 @@ public class FinalizeZipFile { public static void realMain(String[] args) throws Throwable { makeGarbage(); - - System.gc(); - finalizersDone.await(); - + while (!finalizersDone.await(10, TimeUnit.MILLISECONDS)) { + System.gc(); + } // Not all ZipFiles were collected? equal(finalizersDone.getCount(), 0L); } diff --git a/test/jdk/java/util/zip/ZipFile/TestCleaner.java b/test/jdk/java/util/zip/ZipFile/TestCleaner.java new file mode 100644 index 00000000000..cdeea7ebf23 --- /dev/null +++ b/test/jdk/java/util/zip/ZipFile/TestCleaner.java @@ -0,0 +1,246 @@ +/* + * 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 8185582 + * @modules java.base/java.util.zip:open + * @summary Check the resources of Inflater, Deflater and ZipFile are always + * cleaned/released when the instance is not unreachable + */ + +import java.io.*; +import java.lang.reflect.*; +import java.util.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; +import java.util.zip.*; +import static java.nio.charset.StandardCharsets.US_ASCII; + +public class TestCleaner { + + public static void main(String[] args) throws Throwable { + testDeInflater(); + testZipFile(); + } + + private static long addrOf(Object obj) { + try { + Field addr = obj.getClass().getDeclaredField("address"); + if (!addr.trySetAccessible()) { + return -1; + } + return addr.getLong(obj); + } catch (Exception x) { + return -1; + } + } + + private static class SubclassedInflater extends Inflater { + CountDownLatch endCountDown; + + SubclassedInflater(CountDownLatch endCountDown) { + this.endCountDown = endCountDown; + } + + @Override + public void end() { + super.end(); + endCountDown.countDown(); + } + } + + private static class SubclassedDeflater extends Deflater { + CountDownLatch endCountDown; + + SubclassedDeflater(CountDownLatch endCountDown) { + this.endCountDown = endCountDown; + } + + @Override + public void end() { + super.end(); + endCountDown.countDown(); + } + } + + // verify the "native resource" of In/Deflater has been cleaned + private static void testDeInflater() throws Throwable { + Field zsRefDef = Deflater.class.getDeclaredField("zsRef"); + Field zsRefInf = Inflater.class.getDeclaredField("zsRef"); + if (!zsRefDef.trySetAccessible() || !zsRefInf.trySetAccessible()) { + throw new RuntimeException("'zsRef' is not accesible"); + } + if (addrOf(zsRefDef.get(new Deflater())) == -1 || + addrOf(zsRefInf.get(new Inflater())) == -1) { + throw new RuntimeException("'addr' is not accesible"); + } + List list = new ArrayList<>(); + byte[] buf1 = new byte[1024]; + byte[] buf2 = new byte[1024]; + for (int i = 0; i < 10; i++) { + var def = new Deflater(); + list.add(zsRefDef.get(def)); + def.setInput("hello".getBytes()); + def.finish(); + int n = def.deflate(buf1); + + var inf = new Inflater(); + list.add(zsRefInf.get(inf)); + inf.setInput(buf1, 0, n); + n = inf.inflate(buf2); + if (!"hello".equals(new String(buf2, 0, n))) { + throw new RuntimeException("compression/decompression failed"); + } + } + + int n = 10; + long cnt = list.size(); + while (n-- > 0 && cnt != 0) { + Thread.sleep(100); + System.gc(); + cnt = list.stream().filter(o -> addrOf(o) != 0).count(); + } + if (cnt != 0) + throw new RuntimeException("cleaner failed to clean : " + cnt); + + // test subclassed Deflater/Inflater, for behavioral compatibility. + // should be removed if the finalize() method is finally removed. + var endCountDown = new CountDownLatch(20); + for (int i = 0; i < 10; i++) { + var def = new SubclassedDeflater(endCountDown); + def.setInput("hello".getBytes()); + def.finish(); + n = def.deflate(buf1); + + var inf = new SubclassedInflater(endCountDown); + inf.setInput(buf1, 0, n); + n = inf.inflate(buf2); + if (!"hello".equals(new String(buf2, 0, n))) { + throw new RuntimeException("compression/decompression failed"); + } + } + while (!endCountDown.await(10, TimeUnit.MILLISECONDS)) { + System.gc(); + } + if (endCountDown.getCount() != 0) + throw new RuntimeException("finalizer failed to clean : " + + endCountDown.getCount()); + } + + private static class SubclassedZipFile extends ZipFile { + CountDownLatch closeCountDown; + + SubclassedZipFile(File f, CountDownLatch closeCountDown) + throws IOException { + super(f); + this.closeCountDown = closeCountDown; + } + + @Override + public void close() throws IOException { + closeCountDown.countDown(); + super.close(); + } + } + + private static void testZipFile() throws Throwable { + File dir = new File(System.getProperty("test.dir", ".")); + File zip = File.createTempFile("testzf", "zip", dir); + Object zsrc = null; + try { + try (var fos = new FileOutputStream(zip); + var zos = new ZipOutputStream(fos)) { + zos.putNextEntry(new ZipEntry("hello")); + zos.write("hello".getBytes(US_ASCII)); + zos.closeEntry(); + } + + var zf = new ZipFile(zip); + var es = zf.entries(); + while (es.hasMoreElements()) { + zf.getInputStream(es.nextElement()).read(); + } + + Field fieldRes = ZipFile.class.getDeclaredField("res"); + if (!fieldRes.trySetAccessible()) { + throw new RuntimeException("'ZipFile.res' is not accesible"); + } + Object zfRes = fieldRes.get(zf); + if (zfRes == null) { + throw new RuntimeException("'ZipFile.res' is null"); + } + Field fieldZsrc = zfRes.getClass().getDeclaredField("zsrc"); + if (!fieldZsrc.trySetAccessible()) { + throw new RuntimeException("'ZipFile.zsrc' is not accesible"); + } + zsrc = fieldZsrc.get(zfRes); + + } finally { + zip.delete(); + } + + if (zsrc != null) { + Field zfileField = zsrc.getClass().getDeclaredField("zfile"); + if (!zfileField.trySetAccessible()) { + throw new RuntimeException("'ZipFile.Source.zfile' is not accesible"); + } + //System.out.println("zffile: " + zfileField.get(zsrc)); + int n = 10; + while (n-- > 0 && zfileField.get(zsrc) != null) { + System.out.println("waiting gc ... " + n); + System.gc(); + Thread.sleep(100); + } + if (zfileField.get(zsrc) != null) { + throw new RuntimeException("cleaner failed to clean zipfile."); + } + } + + // test subclassed ZipFile, for behavioral compatibility. + // should be removed if the finalize() method is finally removed. + var closeCountDown = new CountDownLatch(1); + try { + try (var fos = new FileOutputStream(zip); + var zos = new ZipOutputStream(fos)) { + zos.putNextEntry(new ZipEntry("hello")); + zos.write("hello".getBytes(US_ASCII)); + zos.closeEntry(); + } + var zf = new SubclassedZipFile(zip, closeCountDown); + var es = zf.entries(); + while (es.hasMoreElements()) { + zf.getInputStream(es.nextElement()).read(); + } + es = null; + zf = null; + } finally { + zip.delete(); + } + while (!closeCountDown.await(10, TimeUnit.MILLISECONDS)) { + System.gc(); + } + if (closeCountDown.getCount() != 0) + throw new RuntimeException("finalizer failed to clean : " + + closeCountDown.getCount()); + } +} From 238ca2e781338dbe001853bd5274bd864bd99dcf Mon Sep 17 00:00:00 2001 From: Peter Levart Date: Tue, 12 Dec 2017 00:30:57 +0100 Subject: [PATCH 02/26] 8191216: SimpleTimeZone.clone() has a data race on cache fields Reviewed-by: alanb, naoto --- .../classes/java/util/SimpleTimeZone.java | 76 +++++----- .../TimeZone/SimpleTimeZoneCloneRaceTest.java | 137 ++++++++++++++++++ 2 files changed, 173 insertions(+), 40 deletions(-) create mode 100644 test/jdk/java/util/TimeZone/SimpleTimeZoneCloneRaceTest.java diff --git a/src/java.base/share/classes/java/util/SimpleTimeZone.java b/src/java.base/share/classes/java/util/SimpleTimeZone.java index 7ed6e71753f..7bc00bf6ddb 100644 --- a/src/java.base/share/classes/java/util/SimpleTimeZone.java +++ b/src/java.base/share/classes/java/util/SimpleTimeZone.java @@ -548,12 +548,11 @@ public class SimpleTimeZone extends TimeZone { computeOffset: if (useDaylight) { - synchronized (this) { - if (cacheStart != 0) { - if (date >= cacheStart && date < cacheEnd) { - offset += dstSavings; - break computeOffset; - } + Cache cache = this.cache; + if (cache != null) { + if (date >= cache.start && date < cache.end) { + offset += dstSavings; + break computeOffset; } } BaseCalendar cal = date >= GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER ? @@ -671,14 +670,13 @@ public class SimpleTimeZone extends TimeZone { } private int getOffset(BaseCalendar cal, BaseCalendar.Date cdate, int year, long time) { - synchronized (this) { - if (cacheStart != 0) { - if (time >= cacheStart && time < cacheEnd) { - return rawOffset + dstSavings; - } - if (year == cacheYear) { - return rawOffset; - } + Cache cache = this.cache; + if (cache != null) { + if (time >= cache.start && time < cache.end) { + return rawOffset + dstSavings; + } + if (year == cache.year) { + return rawOffset; } } @@ -689,11 +687,7 @@ public class SimpleTimeZone extends TimeZone { if (time >= start && time < end) { offset += dstSavings; } - synchronized (this) { - cacheYear = year; - cacheStart = start; - cacheEnd = end; - } + this.cache = new Cache(year, start, end); } else { if (time < end) { // TODO: support Gregorian cutover. The previous year @@ -711,12 +705,7 @@ public class SimpleTimeZone extends TimeZone { } } if (start <= end) { - synchronized (this) { - // The start and end transitions are in multiple years. - cacheYear = (long) startYear - 1; - cacheStart = start; - cacheEnd = end; - } + this.cache = new Cache((long) startYear - 1, start, end); } } return offset; @@ -876,7 +865,7 @@ public class SimpleTimeZone extends TimeZone { * Generates the hash code for the SimpleDateFormat object. * @return the hash code for this object */ - public synchronized int hashCode() + public int hashCode() { return startMonth ^ startDay ^ startDayOfWeek ^ startTime ^ endMonth ^ endDay ^ endDayOfWeek ^ endTime ^ rawOffset; @@ -1201,19 +1190,27 @@ public class SimpleTimeZone extends TimeZone { /** * Cache values representing a single period of daylight saving - * time. When the cache values are valid, cacheStart is the start - * time (inclusive) of daylight saving time and cacheEnd is the - * end time (exclusive). + * time. Cache.start is the start time (inclusive) of daylight + * saving time and Cache.end is the end time (exclusive). * - * cacheYear has a year value if both cacheStart and cacheEnd are - * in the same year. cacheYear is set to startYear - 1 if - * cacheStart and cacheEnd are in different years. cacheStart is 0 - * if the cache values are void. cacheYear is a long to support - * Integer.MIN_VALUE - 1 (JCK requirement). + * Cache.year has a year value if both Cache.start and Cache.end are + * in the same year. Cache.year is set to startYear - 1 if + * Cache.start and Cache.end are in different years. + * Cache.year is a long to support Integer.MIN_VALUE - 1 (JCK requirement). */ - private transient long cacheYear; - private transient long cacheStart; - private transient long cacheEnd; + private static final class Cache { + final long year; + final long start; + final long end; + + Cache(long year, long start, long end) { + this.year = year; + this.start = start; + this.end = end; + } + } + + private transient volatile Cache cache; /** * Constants specifying values of startMode and endMode. @@ -1282,9 +1279,8 @@ public class SimpleTimeZone extends TimeZone { // Maximum number of rules. private static final int MAX_RULE_NUM = 6; - private synchronized void invalidateCache() { - cacheYear = startYear - 1; - cacheStart = cacheEnd = 0; + private void invalidateCache() { + cache = null; } //---------------------------------------------------------------------- diff --git a/test/jdk/java/util/TimeZone/SimpleTimeZoneCloneRaceTest.java b/test/jdk/java/util/TimeZone/SimpleTimeZoneCloneRaceTest.java new file mode 100644 index 00000000000..c86ec9f7469 --- /dev/null +++ b/test/jdk/java/util/TimeZone/SimpleTimeZoneCloneRaceTest.java @@ -0,0 +1,137 @@ +/* + * 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.util.Calendar; +import java.util.Locale; +import java.util.SimpleTimeZone; +import java.util.TimeZone; +import java.util.function.Supplier; + +/* + * @test + * @bug 8191216 + * @summary test that provokes race between cloning and lazily initializing + * SimpleTimeZone cache fields + */ +public class SimpleTimeZoneCloneRaceTest { + + public static void main(String[] args) throws InterruptedException { + + // shared TZ user repeatedly samples sharedTZ and calculates offset + // using the shared instance + TimeZoneUser sharedTZuser = new TimeZoneUser(() -> sharedTZ); + + // cloned TZ user repeatedly samples sharedTZ then clones it and + // calculates offset using the clone... + TimeZoneUser clonedTZuser = new TimeZoneUser(() -> { + // sample shared TZ + TimeZone tz = sharedTZ; + // do some computation that takes roughly the same time as it takes + // sharedTZUser to start changing cache fields in shared TZ + cpuHogTZ.getOffset(time); + // now clone the sampled TZ and return it, hoping the clone is done + // at about the right time.... + return (TimeZone) tz.clone(); + }); + + // start threads + Thread t1 = new Thread(sharedTZuser); + Thread t2 = new Thread(clonedTZuser); + t1.start(); + t2.start(); + + // plant new SimpleTimeZone instances for 2 seconds + long t0 = System.currentTimeMillis(); + do { + TimeZone tz1 = createSTZ(); + TimeZone tz2 = createSTZ(); + cpuHogTZ = tz1; + sharedTZ = tz2; + } while (System.currentTimeMillis() - t0 < 2000L); + + sharedTZuser.stop = true; + clonedTZuser.stop = true; + t1.join(); + t2.join(); + + System.out.println( + String.format("shared TZ: %d correct, %d incorrect calculations", + sharedTZuser.correctCount, sharedTZuser.incorrectCount) + ); + System.out.println( + String.format("cloned TZ: %d correct, %d incorrect calculations", + clonedTZuser.correctCount, clonedTZuser.incorrectCount) + ); + if (clonedTZuser.incorrectCount > 0) { + throw new RuntimeException(clonedTZuser.incorrectCount + + " fatal data races detected"); + } + } + + static SimpleTimeZone createSTZ() { + return new SimpleTimeZone(-28800000, + "America/Los_Angeles", + Calendar.APRIL, 1, -Calendar.SUNDAY, + 7200000, + Calendar.OCTOBER, -1, Calendar.SUNDAY, + 7200000, + 3600000); + } + + static volatile TimeZone cpuHogTZ = createSTZ(); + static volatile TimeZone sharedTZ = createSTZ(); + static final long time; + static final long correctOffset; + + static { + TimeZone tz = createSTZ(); + Calendar cal = Calendar.getInstance(tz, Locale.ROOT); + cal.set(2000, Calendar.MAY, 1, 0, 0, 0); + time = cal.getTimeInMillis(); + correctOffset = tz.getOffset(time); + } + + static class TimeZoneUser implements Runnable { + private final Supplier tzSupplier; + + TimeZoneUser(Supplier tzSupplier) { + this.tzSupplier = tzSupplier; + } + + volatile boolean stop; + int correctCount, incorrectCount; + + @Override + public void run() { + while (!stop) { + TimeZone tz = tzSupplier.get(); + int offset = tz.getOffset(time); + if (offset == correctOffset) { + correctCount++; + } else { + incorrectCount++; + } + } + } + } +} From 869aa96aa3a2b9f3259b3c54d8c107ae7008bcc0 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Mon, 4 Dec 2017 10:23:08 +0900 Subject: [PATCH 03/26] 8192897: NPE occurs on clhsdb jstack Reviewed-by: dholmes, sspitsyn, jgeorge, sballal --- .../jvm/hotspot/runtime/CompiledVFrame.java | 3 +++ .../jtreg/serviceability/sa/ClhsdbJstack.java | 21 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java index a2d67b3fe3e..8e9f67a2cd4 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/CompiledVFrame.java @@ -128,6 +128,9 @@ public class CompiledVFrame extends JavaVFrame { /** Returns List */ public List getMonitors() { + if (getScope() == null) { + return new ArrayList<>(); + } List monitors = getScope().getMonitors(); if (monitors == null) { return new ArrayList<>(); diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java index bbbc81e1963..a3588e0e944 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java @@ -38,14 +38,17 @@ import jdk.test.lib.Platform; public class ClhsdbJstack { - public static void main(String[] args) throws Exception { - System.out.println("Starting ClhsdbJstack test"); - + private static void testJstack(boolean withXcomp) throws Exception { LingeredApp theApp = null; try { ClhsdbLauncher test = new ClhsdbLauncher(); - theApp = LingeredApp.startApp(); - System.out.println("Started LingeredApp with pid " + theApp.getPid()); + theApp = withXcomp ? LingeredApp.startApp(List.of("-Xcomp")) + : LingeredApp.startApp(); + System.out.print("Started LingeredApp "); + if (withXcomp) { + System.out.print("(-Xcomp) "); + } + System.out.println("with pid " + theApp.getPid()); List cmds = List.of("jstack -v"); @@ -61,10 +64,16 @@ public class ClhsdbJstack { test.run(theApp.getPid(), cmds, expStrMap, null); } catch (Exception ex) { - throw new RuntimeException("Test ERROR " + ex, ex); + throw new RuntimeException("Test ERROR (with -Xcomp=" + withXcomp + ") " + ex, ex); } finally { LingeredApp.stopApp(theApp); } + } + + public static void main(String[] args) throws Exception { + System.out.println("Starting ClhsdbJstack test"); + testJstack(false); + testJstack(true); System.out.println("Test PASSED"); } } From a76080835070378d0a2a45c950d82579a6d04f9a Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Mon, 11 Dec 2017 19:56:44 -0800 Subject: [PATCH 04/26] 8190823: Broken link in org/w3c/dom/ls/ Reviewed-by: lancea --- .../org/w3c/dom/ls/DOMImplementationLS.java | 17 +-- .../classes/org/w3c/dom/ls/LSParser.java | 119 +++++++++++------- .../org/w3c/dom/ls/LSParserFilter.java | 17 +-- .../classes/org/w3c/dom/ls/LSSerializer.java | 117 ++++++++++------- 4 files changed, 161 insertions(+), 109 deletions(-) diff --git a/src/java.xml/share/classes/org/w3c/dom/ls/DOMImplementationLS.java b/src/java.xml/share/classes/org/w3c/dom/ls/DOMImplementationLS.java index 13b863e7536..986db03f7d0 100644 --- a/src/java.xml/share/classes/org/w3c/dom/ls/DOMImplementationLS.java +++ b/src/java.xml/share/classes/org/w3c/dom/ls/DOMImplementationLS.java @@ -51,12 +51,13 @@ import org.w3c.dom.DOMException; * binding-specific casting methods on an instance of the * DOMImplementation interface or, if the Document * supports the feature "Core" version "3.0" - * defined in [DOM Level 3 Core] + * defined in + * [DOM Level 3 Core] * , by using the method DOMImplementation.getFeature with * parameter values "LS" (or "LS-Async") and * "3.0" (respectively). - *

See also the Document Object Model (DOM) Level 3 Load -and Save Specification. + *

See also the +Document Object Model (DOM) Level 3 Load and Save Specification. * * @since 1.5 */ @@ -90,9 +91,11 @@ public interface DOMImplementationLS { * LSParser for any kind of schema types (i.e. the * LSParser will be free to use any schema found), use the value * null. - *

Note: For W3C XML Schema [XML Schema Part 1] + *

Note: For W3C XML Schema + * [XML Schema Part 1] * , applications must use the value - * "http://www.w3.org/2001/XMLSchema". For XML DTD [XML 1.0], + * "http://www.w3.org/2001/XMLSchema". For XML DTD + * [XML 1.0], * applications must use the value * "http://www.w3.org/TR/REC-xml". Other Schema languages * are outside the scope of the W3C and therefore should recommend an @@ -102,8 +105,8 @@ public interface DOMImplementationLS { * depending on the value of the mode argument. *

Note: By default, the newly created LSParser * does not contain a DOMErrorHandler, i.e. the value of - * the " - * error-handler" configuration parameter is null. However, implementations + * the "error-handler" + * configuration parameter is null. However, implementations * may provide a default error handler at creation time. In that case, * the initial value of the "error-handler" configuration * parameter on the new LSParser object contains a diff --git a/src/java.xml/share/classes/org/w3c/dom/ls/LSParser.java b/src/java.xml/share/classes/org/w3c/dom/ls/LSParser.java index 0ddbd49ddfb..81db36edc09 100644 --- a/src/java.xml/share/classes/org/w3c/dom/ls/LSParser.java +++ b/src/java.xml/share/classes/org/w3c/dom/ls/LSParser.java @@ -53,7 +53,8 @@ import org.w3c.dom.DOMException; * corresponding DOM document structure. A LSParser instance * can be obtained by invoking the * DOMImplementationLS.createLSParser() method. - *

As specified in [DOM Level 3 Core] + *

As specified in + * [DOM Level 3 Core] * , when a document is first made available via the LSParser: *

    *
  • there will @@ -63,16 +64,18 @@ import org.w3c.dom.DOMException; *
  • it is expected that the value and * nodeValue attributes of an Attr node initially * return the XML 1.0 - * normalized value. However, if the parameters " - * validate-if-schema" and " - * datatype-normalization" are set to true, depending on the attribute normalization + * normalized value. However, if the parameters + * "validate-if-schema" and + * "datatype-normalization" + * are set to true, depending on the attribute normalization * used, the attribute values may differ from the ones obtained by the XML - * 1.0 attribute normalization. If the parameters " - * datatype-normalization" is set to false, the XML 1.0 attribute normalization is + * 1.0 attribute normalization. If the parameters + * "datatype-normalization" + * is set to false, the XML 1.0 attribute normalization is * guaranteed to occur, and if the attributes list does not contain * namespace declarations, the attributes attribute on - * Element node represents the property [attributes] defined in [XML Information Set] - * . + * Element node represents the property [attributes] defined in + * [XML Information Set]. *
  • *
*

Asynchronous LSParser objects are expected to also @@ -102,17 +105,18 @@ import org.w3c.dom.DOMException; *

Note: All events defined in this specification use the * namespace URI "http://www.w3.org/2002/DOMLS". *

While parsing an input source, errors are reported to the application - * through the error handler (LSParser.domConfig's " - * error-handler" parameter). This specification does in no way try to define all possible + * through the error handler (LSParser.domConfig's + * "error-handler" + * parameter). This specification does in no way try to define all possible * errors that can occur while parsing XML, or any other markup, but some * common error cases are defined. The types (DOMError.type) of * errors and warnings defined by this specification are: *

*
* "check-character-normalization-failure" [error]
- *
Raised if - * the parameter " - * check-character-normalization" is set to true and a string is encountered that fails normalization + *
Raised if the parameter + * "check-character-normalization" + * is set to true and a string is encountered that fails normalization * checking.
*
"doctype-not-allowed" [fatal]
*
Raised if the @@ -127,8 +131,9 @@ import org.w3c.dom.DOMException; *
Raised if a processing * instruction is encountered in a location where the base URI of the * processing instruction can not be preserved. One example of a case where - * this warning will be raised is if the configuration parameter " - * entities" is set to false and the following XML file is parsed: + * this warning will be raised is if the configuration parameter + * "entities" + * is set to false and the following XML file is parsed: *
  * <!DOCTYPE root [ <!ENTITY e SYSTEM 'subdir/myentity.ent' ]>
  * <root> &e; </root>
@@ -139,9 +144,9 @@ import org.w3c.dom.DOMException; *
*
"unbound-prefix-in-entity" [warning]
*
An - * implementation dependent warning that may be raised if the configuration - * parameter " - * namespaces" is set to true and an unbound namespace prefix is + * implementation dependent warning that may be raised if the configuration parameter + * "namespaces" + * is set to true and an unbound namespace prefix is * encountered in an entity's replacement text. Raising this warning is not * enforced since some existing parsers may not recognize unbound namespace * prefixes in the replacement text of entities.
@@ -164,8 +169,8 @@ import org.w3c.dom.DOMException; * are expected to raise implementation specific errors and warnings for any * other error and warning cases such as IO errors (file not found, * permission denied,...), XML well-formedness errors, and so on. - *

See also the Document Object Model (DOM) Level 3 Load -and Save Specification. + *

See also the + * Document Object Model (DOM) Level 3 Load and Save Specification. * * @since 1.5 */ @@ -180,8 +185,10 @@ public interface LSParser { * needed parameter values from this DOMConfiguration * object to the DOMConfiguration object referenced by the * Document object. - *
In addition to the parameters recognized in on the - * DOMConfiguration interface defined in [DOM Level 3 Core] + *
In addition to the parameters recognized in on the + * DOMConfiguration + * interface defined in + * [DOM Level 3 Core] * , the DOMConfiguration objects for LSParser * add or modify the following parameters: *

@@ -190,7 +197,8 @@ public interface LSParser { *
*
*
true
- *
[optional] (default) If a higher level protocol such as HTTP [IETF RFC 2616] provides an + *
[optional] (default) If a higher level protocol such as HTTP + * [IETF RFC 2616] provides an * indication of the character encoding of the input stream being * processed, that will override any encoding specified in the XML * declaration or the Text declaration (see also section 4.3.3, @@ -206,7 +214,8 @@ public interface LSParser { *
*
* true
- *
[optional] Throw a fatal "doctype-not-allowed" error if a doctype node is found while parsing the document. This is + *
[optional] Throw a fatal "doctype-not-allowed" error + * if a doctype node is found while parsing the document. This is * useful when dealing with things like SOAP envelopes where doctype * nodes are not allowed.
*
false
@@ -218,14 +227,17 @@ public interface LSParser { *
*
* true
- *
[required] (default) If, while verifying full normalization when [XML 1.1] is + *
[required] (default) If, while verifying full normalization when + * [XML 1.1] is * supported, a processor encounters characters for which it cannot * determine the normalization properties, then the processor will * ignore any possible denormalizations caused by these characters. - * This parameter is ignored for [XML 1.0].
+ * This parameter is ignored for [XML 1.0]. + *
*
* false
- *
[optional] Report an fatal "unknown-character-denormalization" error if a character is encountered for which the processor cannot + *
[optional] Report an fatal "unknown-character-denormalization" + * error if a character is encountered for which the processor cannot * determine the normalization properties.
*
*
"infoset"
@@ -238,7 +250,8 @@ public interface LSParser { *
*
*
true
- *
[required] (default) Perform the namespace processing as defined in [XML Namespaces] + *
[required] (default) Perform the namespace processing as defined in + * [XML Namespaces] * and [XML Namespaces 1.1] * .
*
false
@@ -259,7 +272,8 @@ public interface LSParser { * true *
[optional] Check that the media type of the parsed resource is a supported media * type. If an unsupported media type is encountered, a fatal error of - * type "unsupported-media-type" will be raised. The media types defined in [IETF RFC 3023] must always + * type "unsupported-media-type" will be raised. The media types defined in + * [IETF RFC 3023] must always * be accepted.
*
false
*
[required] (default) Accept any media type.
@@ -294,8 +308,8 @@ public interface LSParser { * terminate the parsing early. *
The filter is invoked after the operations requested by the * DOMConfiguration parameters have been applied. For - * example, if " - * validate" is set to true, the validation is done before invoking the + * example, if "validate" + * is set to true, the validation is done before invoking the * filter. */ public LSParserFilter getFilter(); @@ -306,8 +320,8 @@ public interface LSParser { * terminate the parsing early. *
The filter is invoked after the operations requested by the * DOMConfiguration parameters have been applied. For - * example, if " - * validate" is set to true, the validation is done before invoking the + * example, if "validate" + * is set to true, the validation is done before invoking the * filter. */ public void setFilter(LSParserFilter filter); @@ -340,15 +354,18 @@ public interface LSParser { * @exception LSException * PARSE_ERR: Raised if the LSParser was unable to load * the XML document. DOM applications should attach a - * DOMErrorHandler using the parameter " - * error-handler" if they wish to get details on the error. + * DOMErrorHandler using the parameter + * "error-handler" + * if they wish to get details on the error. */ public Document parse(LSInput input) throws DOMException, LSException; /** - * Parse an XML document from a location identified by a URI reference [IETF RFC 2396]. If the URI - * contains a fragment identifier (see section 4.1 in [IETF RFC 2396]), the + * Parse an XML document from a location identified by a URI reference + * [IETF RFC 2396]. If the URI + * contains a fragment identifier (see section 4.1 in + * [IETF RFC 2396]), the * behavior is not defined by this specification, future versions of * this specification may define the behavior. * @param uri The location of the XML document to be read. @@ -364,8 +381,9 @@ public interface LSParser { * @exception LSException * PARSE_ERR: Raised if the LSParser was unable to load * the XML document. DOM applications should attach a - * DOMErrorHandler using the parameter " - * error-handler" if they wish to get details on the error. + * DOMErrorHandler using the parameter + * "error-handler" + * if they wish to get details on the error. */ public Document parseURI(String uri) throws DOMException, LSException; @@ -431,14 +449,17 @@ public interface LSParser { * LSParser is asynchronous (LSParser.async is * true). *
If an error occurs while parsing, the caller is notified through - * the ErrorHandler instance associated with the " - * error-handler" parameter of the DOMConfiguration. + * the ErrorHandler instance associated with the + * "error-handler" + * parameter of the DOMConfiguration. *
When calling parseWithContext, the values of the * following configuration parameters will be ignored and their default - * values will always be used instead: " - * validate", " - * validate-if-schema", and " - * element-content-whitespace". Other parameters will be treated normally, and the parser is expected + * values will always be used instead: + * "validate", + * "validate-if-schema", + * and + * "element-content-whitespace". + * Other parameters will be treated normally, and the parser is expected * to call the LSParserFilter just as if a whole document * was parsed. * @param input The LSInput from which the source document @@ -463,7 +484,8 @@ public interface LSParser { * @exception DOMException * HIERARCHY_REQUEST_ERR: Raised if the content cannot replace, be * inserted before, after, or as a child of the context node (see also - * Node.insertBefore or Node.replaceChild in [DOM Level 3 Core] + * Node.insertBefore or Node.replaceChild in + * [DOM Level 3 Core] * ). *
NOT_SUPPORTED_ERR: Raised if the LSParser doesn't * support this method, or if the context node is of type @@ -479,8 +501,9 @@ public interface LSParser { * @exception LSException * PARSE_ERR: Raised if the LSParser was unable to load * the XML fragment. DOM applications should attach a - * DOMErrorHandler using the parameter " - * error-handler" if they wish to get details on the error. + * DOMErrorHandler using the parameter + * "error-handler" + * if they wish to get details on the error. */ public Node parseWithContext(LSInput input, Node contextArg, diff --git a/src/java.xml/share/classes/org/w3c/dom/ls/LSParserFilter.java b/src/java.xml/share/classes/org/w3c/dom/ls/LSParserFilter.java index 96797bbb3cf..e592841f476 100644 --- a/src/java.xml/share/classes/org/w3c/dom/ls/LSParserFilter.java +++ b/src/java.xml/share/classes/org/w3c/dom/ls/LSParserFilter.java @@ -56,10 +56,11 @@ import org.w3c.dom.Element; * Document, DocumentType, Notation, * Entity, and Attr nodes are never passed to the * acceptNode method on the filter. The child nodes of an - * EntityReference node are passed to the filter if the - * parameter " - * entities" is set to false. Note that, as described by the parameter " - * entities", unexpanded entity reference nodes are never discarded and are always + * EntityReference node are passed to the filter if the parameter + * "entities" + * is set to false. Note that, as described by the parameter + * "entities", + * unexpanded entity reference nodes are never discarded and are always * passed to the filter. *

All validity checking while parsing a document occurs on the source * document as it appears on the input stream, not on the DOM document as it @@ -71,8 +72,8 @@ import org.w3c.dom.Element; * passed to the filter methods. *

DOM applications must not raise exceptions in a filter. The effect of * throwing exceptions from a filter is DOM implementation dependent. - *

See also the Document Object Model (DOM) Level 3 Load -and Save Specification. + *

See also the +Document Object Model (DOM) Level 3 Load and Save Specification. * * @since 1.5 */ @@ -195,8 +196,8 @@ public interface LSParserFilter { * SHOW_NOTATION, SHOW_ENTITY, and * SHOW_DOCUMENT_FRAGMENT are meaningless here. Those nodes * will never be passed to LSParserFilter.acceptNode. - *
The constants used here are defined in [DOM Level 2 Traversal and Range] - * . + *
The constants used here are defined in + * [DOM Level 2 Traversal and Range]. */ public int getWhatToShow(); diff --git a/src/java.xml/share/classes/org/w3c/dom/ls/LSSerializer.java b/src/java.xml/share/classes/org/w3c/dom/ls/LSSerializer.java index 772a8d3f6d7..2d34d29f634 100644 --- a/src/java.xml/share/classes/org/w3c/dom/ls/LSSerializer.java +++ b/src/java.xml/share/classes/org/w3c/dom/ls/LSSerializer.java @@ -51,7 +51,8 @@ import org.w3c.dom.DOMException; * output stream. Any changes or fixups made during the serialization affect * only the serialized data. The Document object and its * children are never altered by the serialization operation. - *

During serialization of XML data, namespace fixup is done as defined in [DOM Level 3 Core] + *

During serialization of XML data, namespace fixup is done as defined in + * [DOM Level 3 Core] * , Appendix B. [DOM Level 2 Core] * allows empty strings as a real namespace URI. If the * namespaceURI of a Node is empty string, the @@ -80,12 +81,14 @@ import org.w3c.dom.DOMException; * namespace fixup is done. The resulting output will be valid as an * external entity. * - *

  • If the parameter " - * entities" is set to true, EntityReference nodes are + *
  • If the parameter + * "entities" + * is set to true, EntityReference nodes are * serialized as an entity reference of the form " * &entityName;" in the output. Child nodes (the expansion) - * of the entity reference are ignored. If the parameter " - * entities" is set to false, only the children of the entity reference + * of the entity reference are ignored. If the parameter + * "entities" + * is set to false, only the children of the entity reference * are serialized. EntityReference nodes with no children (no * corresponding Entity node or the corresponding * Entity nodes have no children) are always serialized. @@ -93,15 +96,16 @@ import org.w3c.dom.DOMException; *
  • * CDATAsections containing content characters that cannot be * represented in the specified output encoding are handled according to the - * " - * split-cdata-sections" parameter. If the parameter is set to true, + * "split-cdata-sections" + * parameter. If the parameter is set to true, * CDATAsections are split, and the unrepresentable characters * are serialized as numeric character references in ordinary content. The * exact position and number of splits is not specified. If the parameter * is set to false, unrepresentable characters in a * CDATAsection are reported as - * "wf-invalid-character" errors if the parameter " - * well-formed" is set to true. The error is not recoverable - there is no + * "wf-invalid-character" errors if the parameter + * "well-formed" + * is set to true. The error is not recoverable - there is no * mechanism for supplying alternative characters and continuing with the * serialization. *
  • @@ -138,12 +142,15 @@ import org.w3c.dom.DOMException; * as a DOMError fatal error. An example would be serializing * the element <LaCañada/> with encoding="us-ascii". * This will result with a generation of a DOMError - * "wf-invalid-character-in-node-name" (as proposed in " - * well-formed"). - *

    When requested by setting the parameter " - * normalize-characters" on LSSerializer to true, character normalization is - * performed according to the definition of fully - * normalized characters included in appendix E of [XML 1.1] on all + * "wf-invalid-character-in-node-name" (as proposed in + * "well-formed"). + *

    When requested by setting the parameter + * "normalize-characters" + * on LSSerializer to true, character normalization is + * performed according to the definition of + * fully + * normalized characters included in appendix E of + * [XML 1.1] on all * data to be serialized, both markup and character data. The character * normalization process affects only the data as it is being written; it * does not alter the DOM's view of the document after serialization has @@ -170,13 +177,15 @@ import org.w3c.dom.DOMException; * inconsistencies are found, the serialized form of the document will be * altered to remove them. The method used for doing the namespace fixup * while serializing a document is the algorithm defined in Appendix B.1, - * "Namespace normalization", of [DOM Level 3 Core] + * "Namespace normalization", of + * [DOM Level 3 Core] * . *

    While serializing a document, the parameter "discard-default-content" * controls whether or not non-specified data is serialized. *

    While serializing, errors and warnings are reported to the application - * through the error handler (LSSerializer.domConfig's " - * error-handler" parameter). This specification does in no way try to define all possible + * through the error handler (LSSerializer.domConfig's + * "error-handler" + * parameter). This specification does in no way try to define all possible * errors and warnings that can occur while serializing a DOM node, but some * common error and warning cases are defined. The types ( * DOMError.type) of errors and warnings defined by this @@ -189,8 +198,9 @@ import org.w3c.dom.DOMException; *

    * "unbound-prefix-in-entity-reference" [fatal]
    *
    Raised if the - * configuration parameter " - * namespaces" is set to true and an entity whose replacement text + * configuration parameter + * "namespaces" + * is set to true and an entity whose replacement text * contains unbound namespace prefixes is referenced in a location where * there are no bindings for the namespace prefixes.
    *
    @@ -202,8 +212,9 @@ import org.w3c.dom.DOMException; * are expected to raise implementation specific errors and warnings for any * other error and warning cases such as IO errors (file not found, * permission denied,...) and so on. - *

    See also the Document Object Model (DOM) Level 3 Load -and Save Specification. + *

    See also the + * +Document Object Model (DOM) Level 3 Load and Save Specification. * * @since 1.5 */ @@ -211,8 +222,10 @@ public interface LSSerializer { /** * The DOMConfiguration object used by the * LSSerializer when serializing a DOM node. - *
    In addition to the parameters recognized by the - * DOMConfiguration interface defined in [DOM Level 3 Core] + *
    In addition to the parameters recognized by the + * DOMConfiguration + * interface defined in + * [DOM Level 3 Core] * , the DOMConfiguration objects for * LSSerializer adds, or modifies, the following * parameters: @@ -221,9 +234,11 @@ public interface LSSerializer { *

    *
    *
    true
    - *
    [optional] Writes the document according to the rules specified in [Canonical XML]. - * In addition to the behavior described in " - * canonical-form" [DOM Level 3 Core] + *
    [optional] Writes the document according to the rules specified in + * [Canonical XML]. + * In addition to the behavior described in + * "canonical-form" + * [DOM Level 3 Core] * , setting this parameter to true will set the parameters * "format-pretty-print", "discard-default-content", and "xml-declaration * ", to false. Setting one of those parameters to @@ -267,7 +282,8 @@ public interface LSSerializer { *
    *
    * true
    - *
    [required] (default) If, while verifying full normalization when [XML 1.1] is + *
    [required] (default) If, while verifying full normalization when + * [XML 1.1] is * supported, a character is encountered for which the normalization * properties cannot be determined, then raise a * "unknown-character-denormalization" warning (instead of @@ -281,18 +297,21 @@ public interface LSSerializer { *
    * "normalize-characters"
    *
    This parameter is equivalent to - * the one defined by DOMConfiguration in [DOM Level 3 Core] + * the one defined by DOMConfiguration in + * [DOM Level 3 Core] * . Unlike in the Core, the default value for this parameter is * true. While DOM implementations are not required to * support fully - * normalizing the characters in the document according to appendix E of [XML 1.1], this + * normalizing the characters in the document according to appendix E of + * [XML 1.1], this * parameter must be activated by default if supported.
    *
    * "xml-declaration"
    *
    *
    *
    true
    - *
    [required] (default) If a Document, Element, or Entity + *
    [required] (default) If a Document, + * Element, or Entity * node is serialized, the XML declaration, or text declaration, should * be included. The version (Document.xmlVersion if the * document is a Level 3 document and the version is non-null, otherwise @@ -303,7 +322,8 @@ public interface LSSerializer { * false *
    [required] Do not serialize the XML and text declarations. Report a * "xml-declaration-needed" warning if this will cause - * problems (i.e. the serialized data is of an XML version other than [XML 1.0], or an + * problems (i.e. the serialized data is of an XML version other than + * [XML 1.0], or an * encoding would be needed to be able to re-parse the serialized data).
    *
    *
    @@ -314,8 +334,8 @@ public interface LSSerializer { * The end-of-line sequence of characters to be used in the XML being * written out. Any string is supported, but XML treats only a certain * set of characters sequence as end-of-line (See section 2.11, - * "End-of-Line Handling" in [XML 1.0], if the - * serialized content is XML 1.0 or section 2.11, "End-of-Line Handling" + * "End-of-Line Handling" in [XML 1.0], + * if the serialized content is XML 1.0 or section 2.11, "End-of-Line Handling" * in [XML 1.1], if the * serialized content is XML 1.1). Using other character sequences than * the recommended ones can result in a document that is either not @@ -335,8 +355,8 @@ public interface LSSerializer { * The end-of-line sequence of characters to be used in the XML being * written out. Any string is supported, but XML treats only a certain * set of characters sequence as end-of-line (See section 2.11, - * "End-of-Line Handling" in [XML 1.0], if the - * serialized content is XML 1.0 or section 2.11, "End-of-Line Handling" + * "End-of-Line Handling" in [XML 1.0], + * if the serialized content is XML 1.0 or section 2.11, "End-of-Line Handling" * in [XML 1.1], if the * serialized content is XML 1.1). Using other character sequences than * the recommended ones can result in a document that is either not @@ -360,8 +380,9 @@ public interface LSSerializer { * serialization early. *
    The filter is invoked after the operations requested by the * DOMConfiguration parameters have been applied. For - * example, CDATA sections won't be passed to the filter if " - * cdata-sections" is set to false. + * example, CDATA sections won't be passed to the filter if + * "cdata-sections" + * is set to false. */ public LSSerializerFilter getFilter(); /** @@ -371,8 +392,9 @@ public interface LSSerializer { * serialization early. *
    The filter is invoked after the operations requested by the * DOMConfiguration parameters have been applied. For - * example, CDATA sections won't be passed to the filter if " - * cdata-sections" is set to false. + * example, CDATA sections won't be passed to the filter if + * "cdata-sections" + * is set to false. */ public void setFilter(LSSerializerFilter filter); @@ -414,8 +436,9 @@ public interface LSSerializer { * @exception LSException * SERIALIZE_ERR: Raised if the LSSerializer was unable to * serialize the node. DOM applications should attach a - * DOMErrorHandler using the parameter " - * error-handler" if they wish to get details on the error. + * DOMErrorHandler using the parameter + * "error-handler" + * if they wish to get details on the error. */ public boolean write(Node nodeArg, LSOutput destination) @@ -436,8 +459,9 @@ public interface LSSerializer { * @exception LSException * SERIALIZE_ERR: Raised if the LSSerializer was unable to * serialize the node. DOM applications should attach a - * DOMErrorHandler using the parameter " - * error-handler" if they wish to get details on the error. + * DOMErrorHandler using the parameter + * "error-handler" + * if they wish to get details on the error. */ public boolean writeToURI(Node nodeArg, String uri) @@ -458,8 +482,9 @@ public interface LSSerializer { * @exception LSException * SERIALIZE_ERR: Raised if the LSSerializer was unable to * serialize the node. DOM applications should attach a - * DOMErrorHandler using the parameter " - * error-handler" if they wish to get details on the error. + * DOMErrorHandler using the parameter + * "error-handler" + * if they wish to get details on the error. */ public String writeToString(Node nodeArg) throws DOMException, LSException; From 4b41440094da1a1383dfbe66a42ed8a3bb87bd29 Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Tue, 12 Dec 2017 09:16:12 +0100 Subject: [PATCH 05/26] 8193258: Better usage of JDWP HEADER SIZE Reviewed-by: sspitsyn, cjplummer --- .../native/libdt_shmem/SharedMemoryConnection.c | 8 ++++---- .../share/native/libdt_shmem/shmemBack.c | 4 ++-- .../share/native/libdt_shmem/shmemBase.c | 6 +++--- .../share/native/include/jdwpTransport.h | 2 ++ .../share/native/libdt_socket/socketTransport.c | 17 ++++++++--------- .../share/native/libjdwp/inStream.c | 13 ++++--------- .../share/native/libjdwp/inStream.h | 3 +-- .../share/native/libjdwp/outStream.c | 6 +++--- 8 files changed, 27 insertions(+), 32 deletions(-) diff --git a/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryConnection.c b/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryConnection.c index e28efe63128..af78969e316 100644 --- a/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryConnection.c +++ b/src/jdk.jdi/share/native/libdt_shmem/SharedMemoryConnection.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2003, 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 @@ -111,7 +111,7 @@ packetToByteArray(JNIEnv *env, jdwpPacket *str) jint tmpInt; total_length = str->type.cmd.len; - data_length = total_length - 11; + data_length = total_length - JDWP_HEADER_SIZE; /* total packet length is header + data */ array = (*env)->NewByteArray(env, total_length); @@ -142,7 +142,7 @@ packetToByteArray(JNIEnv *env, jdwpPacket *str) /* finally the data */ if (data_length > 0) { - (*env)->SetByteArrayRegion(env, array, 11, + (*env)->SetByteArrayRegion(env, array, JDWP_HEADER_SIZE, data_length, str->type.cmd.data); if ((*env)->ExceptionOccurred(env)) { return NULL; @@ -168,7 +168,7 @@ byteArrayToPacket(JNIEnv *env, jbyteArray b, jdwpPacket *str) { jsize total_length, data_length; jbyte *data; - unsigned char pktHeader[11]; /* sizeof length + id + flags + cmdSet + cmd */ + unsigned char pktHeader[JDWP_HEADER_SIZE]; /* * Get the packet header diff --git a/src/jdk.jdi/share/native/libdt_shmem/shmemBack.c b/src/jdk.jdi/share/native/libdt_shmem/shmemBack.c index 81419a9d6a7..ff9c9ae9581 100644 --- a/src/jdk.jdi/share/native/libdt_shmem/shmemBack.c +++ b/src/jdk.jdi/share/native/libdt_shmem/shmemBack.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, 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 @@ -270,7 +270,7 @@ shmemWritePacket(jdwpTransportEnv* env, const jdwpPacket *packet) if (packet == NULL) { RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, "packet is null"); } - if (packet->type.cmd.len < 11) { + if (packet->type.cmd.len < JDWP_HEADER_SIZE) { RETURN_ERROR(JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT, "invalid length"); } if (connection == NULL) { diff --git a/src/jdk.jdi/share/native/libdt_shmem/shmemBase.c b/src/jdk.jdi/share/native/libdt_shmem/shmemBase.c index fbe15b465f7..1001ef3a912 100644 --- a/src/jdk.jdi/share/native/libdt_shmem/shmemBase.c +++ b/src/jdk.jdi/share/native/libdt_shmem/shmemBase.c @@ -1049,7 +1049,7 @@ shmemBase_sendPacket(SharedMemoryConnection *connection, const jdwpPacket *packe CHECK_ERROR(sendBytes(connection, &packet->type.cmd.cmd, sizeof(jbyte))); } - data_length = packet->type.cmd.len - 11; + data_length = packet->type.cmd.len - JDWP_HEADER_SIZE; SHMEM_GUARANTEE(data_length >= 0); CHECK_ERROR(sendBytes(connection, &data_length, sizeof(jint))); @@ -1125,10 +1125,10 @@ shmemBase_receivePacket(SharedMemoryConnection *connection, jdwpPacket *packet) if (data_length < 0) { return SYS_ERR; } else if (data_length == 0) { - packet->type.cmd.len = 11; + packet->type.cmd.len = JDWP_HEADER_SIZE; packet->type.cmd.data = NULL; } else { - packet->type.cmd.len = data_length + 11; + packet->type.cmd.len = data_length + JDWP_HEADER_SIZE; packet->type.cmd.data = (*callback->alloc)(data_length); if (packet->type.cmd.data == NULL) { return SYS_ERR; diff --git a/src/jdk.jdwp.agent/share/native/include/jdwpTransport.h b/src/jdk.jdwp.agent/share/native/include/jdwpTransport.h index 80f023f2b1b..cdbd04d429c 100644 --- a/src/jdk.jdwp.agent/share/native/include/jdwpTransport.h +++ b/src/jdk.jdwp.agent/share/native/include/jdwpTransport.h @@ -96,6 +96,8 @@ typedef struct { * See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html */ +#define JDWP_HEADER_SIZE 11 + enum { /* * If additional flags are added that apply to jdwpCmdPacket, diff --git a/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c b/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c index ca179895557..fbd8ba6859e 100644 --- a/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c +++ b/src/jdk.jdwp.agent/share/native/libdt_socket/socketTransport.c @@ -70,7 +70,6 @@ static jdwpTransportEnv single_env = (jdwpTransportEnv)&interface; RETURN_IO_ERROR("recv error"); \ } -#define HEADER_SIZE 11 #define MAX_DATA_SIZE 1000 static jint recv_fully(int, char *, int); @@ -790,7 +789,7 @@ socketTransport_writePacket(jdwpTransportEnv* env, const jdwpPacket *packet) /* * room for header and up to MAX_DATA_SIZE data bytes */ - char header[HEADER_SIZE + MAX_DATA_SIZE]; + char header[JDWP_HEADER_SIZE + MAX_DATA_SIZE]; jbyte *data; /* packet can't be null */ @@ -799,7 +798,7 @@ socketTransport_writePacket(jdwpTransportEnv* env, const jdwpPacket *packet) } len = packet->type.cmd.len; /* includes header */ - data_len = len - HEADER_SIZE; + data_len = len - JDWP_HEADER_SIZE; /* bad packet */ if (data_len < 0) { @@ -825,15 +824,15 @@ socketTransport_writePacket(jdwpTransportEnv* env, const jdwpPacket *packet) data = packet->type.cmd.data; /* Do one send for short packets, two for longer ones */ if (data_len <= MAX_DATA_SIZE) { - memcpy(header + HEADER_SIZE, data, data_len); - if (send_fully(socketFD, (char *)&header, HEADER_SIZE + data_len) != - HEADER_SIZE + data_len) { + memcpy(header + JDWP_HEADER_SIZE, data, data_len); + if (send_fully(socketFD, (char *)&header, JDWP_HEADER_SIZE + data_len) != + JDWP_HEADER_SIZE + data_len) { RETURN_IO_ERROR("send failed"); } } else { - memcpy(header + HEADER_SIZE, data, MAX_DATA_SIZE); - if (send_fully(socketFD, (char *)&header, HEADER_SIZE + MAX_DATA_SIZE) != - HEADER_SIZE + MAX_DATA_SIZE) { + memcpy(header + JDWP_HEADER_SIZE, data, MAX_DATA_SIZE); + if (send_fully(socketFD, (char *)&header, JDWP_HEADER_SIZE + MAX_DATA_SIZE) != + JDWP_HEADER_SIZE + MAX_DATA_SIZE) { RETURN_IO_ERROR("send failed"); } /* Send the remaining data bytes right out of the data area. */ diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/inStream.c b/src/jdk.jdwp.agent/share/native/libjdwp/inStream.c index 3624e7eacd1..e9853afb200 100644 --- a/src/jdk.jdwp.agent/share/native/libjdwp/inStream.c +++ b/src/jdk.jdwp.agent/share/native/libjdwp/inStream.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 @@ -43,7 +43,7 @@ inStream_init(PacketInputStream *stream, jdwpPacket packet) { stream->packet = packet; stream->error = JDWP_ERROR(NONE); - stream->left = packet.type.cmd.len; + stream->left = packet.type.cmd.len - JDWP_HEADER_SIZE; stream->current = packet.type.cmd.data; stream->refs = bagCreateBag(sizeof(jobject), INITIAL_REF_ALLOC); if (stream->refs == NULL) { @@ -411,12 +411,6 @@ inStream_readString(PacketInputStream *stream) return string; } -jboolean -inStream_endOfInput(PacketInputStream *stream) -{ - return (stream->left > 0); -} - jdwpError inStream_error(PacketInputStream *stream) { @@ -424,7 +418,8 @@ inStream_error(PacketInputStream *stream) } void -inStream_clearError(PacketInputStream *stream) { +inStream_clearError(PacketInputStream *stream) +{ stream->error = JDWP_ERROR(NONE); } diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/inStream.h b/src/jdk.jdwp.agent/share/native/libjdwp/inStream.h index f017a01bbe4..4a409fe19c1 100644 --- a/src/jdk.jdwp.agent/share/native/libjdwp/inStream.h +++ b/src/jdk.jdwp.agent/share/native/libjdwp/inStream.h @@ -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 @@ -74,7 +74,6 @@ jvalue inStream_readValue(struct PacketInputStream *in, jbyte *typeKeyPtr); jdwpError inStream_skipBytes(PacketInputStream *stream, jint count); -jboolean inStream_endOfInput(PacketInputStream *stream); jdwpError inStream_error(PacketInputStream *stream); void inStream_clearError(PacketInputStream *stream); void inStream_destroy(PacketInputStream *stream); diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/outStream.c b/src/jdk.jdwp.agent/share/native/libjdwp/outStream.c index f1bf5c743bf..1ba2e167559 100644 --- a/src/jdk.jdwp.agent/share/native/libjdwp/outStream.c +++ b/src/jdk.jdwp.agent/share/native/libjdwp/outStream.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 @@ -418,7 +418,7 @@ outStream_send(PacketOutputStream *stream) { * packet. */ if (stream->firstSegment.next == NULL) { - stream->packet.type.cmd.len = 11 + stream->firstSegment.length; + stream->packet.type.cmd.len = JDWP_HEADER_SIZE + stream->firstSegment.length; stream->packet.type.cmd.data = stream->firstSegment.data; rc = transport_sendPacket(&stream->packet); return rc; @@ -447,7 +447,7 @@ outStream_send(PacketOutputStream *stream) { segment = segment->next; } - stream->packet.type.cmd.len = 11 + len; + stream->packet.type.cmd.len = JDWP_HEADER_SIZE + len; stream->packet.type.cmd.data = data; rc = transport_sendPacket(&stream->packet); stream->packet.type.cmd.data = NULL; From 64f569ad1bfee5a6f6d710c1f380dd681afcf742 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Tue, 12 Dec 2017 14:04:05 +0100 Subject: [PATCH 06/26] 8193298: Don't run javadoc with test.single Reviewed-by: hannesw, sundar --- make/nashorn/build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/nashorn/build.xml b/make/nashorn/build.xml index e3897b82a60..6b6683a3003 100644 --- a/make/nashorn/build.xml +++ b/make/nashorn/build.xml @@ -265,7 +265,7 @@ - + From 9d938860766357d7fcbd441e3f858e80d00ead40 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Tue, 12 Dec 2017 14:04:57 +0100 Subject: [PATCH 07/26] 8191905: Add a REMOVE StandardOperation to Dynalink Reviewed-by: hannesw, sundar --- .../jdk/dynalink/StandardOperation.java | 9 ++ .../jdk/dynalink/beans/BeanLinker.java | 57 +++++++++--- .../jdk/dynalink/beans/BeansLinker.java | 2 + .../dynalink/beans/test/BeanLinkerTest.java | 89 ++++++++++++++++++- 4 files changed, 145 insertions(+), 12 deletions(-) diff --git a/src/jdk.dynalink/share/classes/jdk/dynalink/StandardOperation.java b/src/jdk.dynalink/share/classes/jdk/dynalink/StandardOperation.java index 7b7865d8ed7..989b003de1b 100644 --- a/src/jdk.dynalink/share/classes/jdk/dynalink/StandardOperation.java +++ b/src/jdk.dynalink/share/classes/jdk/dynalink/StandardOperation.java @@ -110,6 +110,15 @@ public enum StandardOperation implements Operation { * or reference). This operation must always be used as part of a {@link NamespaceOperation}. */ SET, + /** + * Removes the value from a namespace defined on an object. Call sites with this + * operation should have a signature of + * (receiver, name)→void or + * (receiver)→void when used with {@link NamedOperation}, + * with all parameters being of any type (either primitive + * or reference). This operation must always be used as part of a {@link NamespaceOperation}. + */ + REMOVE, /** * Call a callable object. Call sites with this operation should have a * signature of (callable, receiver, arguments...)→value, diff --git a/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java b/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java index b2389d61066..cff9cc12df6 100644 --- a/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java +++ b/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java @@ -107,7 +107,8 @@ import jdk.dynalink.linker.support.TypeUtilities; /** * A class that provides linking capabilities for a single POJO class. Normally not used directly, but managed by - * {@link BeansLinker}. + * {@link BeansLinker}. Most of the functionality is provided by the {@link AbstractJavaLinker} superclass; this + * class adds length and element operations for arrays and collections. */ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicLinker { BeanLinker(final Class clazz) { @@ -147,6 +148,8 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL return getElementGetter(req.popNamespace()); } else if (op == StandardOperation.SET) { return getElementSetter(req.popNamespace()); + } else if (op == StandardOperation.REMOVE) { + return getElementRemover(req.popNamespace()); } } } @@ -228,7 +231,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL // dealing with an array, or a list or map, but hey... // Note that for arrays and lists, using LinkerServices.asType() will ensure that any language specific linkers // in use will get a chance to perform any (if there's any) implicit conversion to integer for the indices. - if(declaredType.isArray()) { + if(declaredType.isArray() && arrayMethod != null) { return new GuardedInvocationComponentAndCollectionType( createInternalFilteredGuardedInvocationComponent(arrayMethod.apply(declaredType), linkerServices), CollectionType.ARRAY); @@ -240,7 +243,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL return new GuardedInvocationComponentAndCollectionType( createInternalFilteredGuardedInvocationComponent(mapMethod, linkerServices), CollectionType.MAP); - } else if(clazz.isArray()) { + } else if(clazz.isArray() && arrayMethod != null) { return new GuardedInvocationComponentAndCollectionType( getClassGuardedInvocationComponent(linkerServices.filterInternalObjects(arrayMethod.apply(clazz)), callSiteType), CollectionType.ARRAY); @@ -450,7 +453,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL } @SuppressWarnings("unused") - private static void noOpSetter() { + private static void noOp() { } private static final MethodHandle SET_LIST_ELEMENT = Lookup.PUBLIC.findVirtual(List.class, "set", @@ -459,12 +462,14 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL private static final MethodHandle PUT_MAP_ELEMENT = Lookup.PUBLIC.findVirtual(Map.class, "put", MethodType.methodType(Object.class, Object.class, Object.class)); - private static final MethodHandle NO_OP_SETTER_2; - private static final MethodHandle NO_OP_SETTER_3; + private static final MethodHandle NO_OP_1; + private static final MethodHandle NO_OP_2; + private static final MethodHandle NO_OP_3; static { - final MethodHandle noOpSetter = Lookup.findOwnStatic(MethodHandles.lookup(), "noOpSetter", void.class); - NO_OP_SETTER_2 = dropObjectArguments(noOpSetter, 2); - NO_OP_SETTER_3 = dropObjectArguments(noOpSetter, 3); + final MethodHandle noOp = Lookup.findOwnStatic(MethodHandles.lookup(), "noOp", void.class); + NO_OP_1 = dropObjectArguments(noOp, 1); + NO_OP_2 = dropObjectArguments(noOp, 2); + NO_OP_3 = dropObjectArguments(noOp, 3); } private GuardedInvocationComponent getElementSetter(final ComponentLinkRequest req) throws Exception { @@ -503,7 +508,39 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL return gic.replaceInvocation(binder.bind(invocation)); } - return guardComponentWithRangeCheck(gicact, callSiteType, nextComponent, binder, isFixedKey ? NO_OP_SETTER_2 : NO_OP_SETTER_3); + return guardComponentWithRangeCheck(gicact, callSiteType, nextComponent, binder, isFixedKey ? NO_OP_2 : NO_OP_3); + } + + private static final MethodHandle REMOVE_LIST_ELEMENT = Lookup.PUBLIC.findVirtual(List.class, "remove", + MethodType.methodType(Object.class, int.class)); + + private static final MethodHandle REMOVE_MAP_ELEMENT = Lookup.PUBLIC.findVirtual(Map.class, "remove", + MethodType.methodType(Object.class, Object.class)); + + private GuardedInvocationComponent getElementRemover(final ComponentLinkRequest req) throws Exception { + final CallSiteDescriptor callSiteDescriptor = req.getDescriptor(); + final Object name = req.name; + final boolean isFixedKey = name != null; + assertParameterCount(callSiteDescriptor, isFixedKey ? 1 : 2); + final LinkerServices linkerServices = req.linkerServices; + final MethodType callSiteType = callSiteDescriptor.getMethodType(); + final GuardedInvocationComponent nextComponent = getNextComponent(req); + + final GuardedInvocationComponentAndCollectionType gicact = guardedInvocationComponentAndCollectionType( + callSiteType, linkerServices, null, REMOVE_LIST_ELEMENT, REMOVE_MAP_ELEMENT); + + if (gicact == null) { + // Can't remove elements for objects that are neither lists, nor maps. + return nextComponent; + } + + final Object typedName = getTypedName(name, gicact.collectionType == CollectionType.MAP, linkerServices); + if (typedName == INVALID_NAME) { + return nextComponent; + } + + return guardComponentWithRangeCheck(gicact, callSiteType, nextComponent, + new Binder(linkerServices, callSiteType, typedName), isFixedKey ? NO_OP_1: NO_OP_2); } private static final MethodHandle GET_COLLECTION_LENGTH = Lookup.PUBLIC.findVirtual(Collection.class, "size", diff --git a/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeansLinker.java b/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeansLinker.java index 5ba5626a443..e7394b13e64 100644 --- a/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeansLinker.java +++ b/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeansLinker.java @@ -113,6 +113,8 @@ import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker; *
  • expose elements of native Java arrays, {@link java.util.List} and {@link java.util.Map} objects as * {@link StandardOperation#GET} and {@link StandardOperation#SET} operations in the * {@link StandardNamespace#ELEMENT} namespace;
  • + *
  • expose removal of elements of {@link java.util.List} and {@link java.util.Map} objects as + * {@link StandardOperation#REMOVE} operation in the {@link StandardNamespace#ELEMENT} namespace;
  • *
  • expose a virtual property named {@code length} on Java arrays, {@link java.util.Collection} and * {@link java.util.Map} objects;
  • *
  • expose {@link StandardOperation#NEW} on instances of {@link StaticClass} diff --git a/test/nashorn/src/jdk/dynalink/beans/test/BeanLinkerTest.java b/test/nashorn/src/jdk/dynalink/beans/test/BeanLinkerTest.java index 00bf14ee92f..47da785c28f 100644 --- a/test/nashorn/src/jdk/dynalink/beans/test/BeanLinkerTest.java +++ b/test/nashorn/src/jdk/dynalink/beans/test/BeanLinkerTest.java @@ -30,6 +30,7 @@ import static jdk.dynalink.StandardNamespace.PROPERTY; import static jdk.dynalink.StandardOperation.CALL; import static jdk.dynalink.StandardOperation.GET; import static jdk.dynalink.StandardOperation.NEW; +import static jdk.dynalink.StandardOperation.REMOVE; import static jdk.dynalink.StandardOperation.SET; import java.lang.invoke.CallSite; @@ -39,7 +40,9 @@ import java.lang.invoke.MethodType; import java.security.AccessControlException; import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import jdk.dynalink.CallSiteDescriptor; import jdk.dynalink.DynamicLinker; import jdk.dynalink.DynamicLinkerFactory; @@ -90,6 +93,7 @@ public class BeanLinkerTest { private static final Operation GET_ELEMENT = GET.withNamespace(ELEMENT); private static final Operation GET_METHOD = GET.withNamespace(METHOD); private static final Operation SET_ELEMENT = SET.withNamespace(ELEMENT); + private static final Operation REMOVE_ELEMENT = REMOVE.withNamespace(ELEMENT); private static final MethodHandle findThrower(final String name) { try { @@ -121,8 +125,8 @@ public class BeanLinkerTest { final CallSiteDescriptor desc = req.getCallSiteDescriptor(); final Operation op = desc.getOperation(); final Operation baseOp = NamedOperation.getBaseOperation(op); - if (baseOp != GET_ELEMENT && baseOp != SET_ELEMENT) { - // We only handle GET_ELEMENT and SET_ELEMENT. + if (baseOp != GET_ELEMENT && baseOp != SET_ELEMENT && baseOp != REMOVE_ELEMENT) { + // We only handle GET_ELEMENT, SET_ELEMENT and REMOVE_ELEMENT. return null; } @@ -538,4 +542,85 @@ public class BeanLinkerTest { } } } + + @Test(dataProvider = "flags") + public void removeElementFromListTest(final boolean publicLookup) throws Throwable { + final MethodType mt = MethodType.methodType(void.class, Object.class, int.class); + final CallSite cs = createCallSite(publicLookup, REMOVE_ELEMENT, mt); + + final List list = new ArrayList<>(List.of(23, 430, -4354)); + + cs.getTarget().invoke(list, 1); + Assert.assertEquals(list, List.of(23, -4354)); + cs.getTarget().invoke(list, 1); + Assert.assertEquals(list, List.of(23)); + cs.getTarget().invoke(list, 0); + Assert.assertEquals(list, List.of()); + try { + cs.getTarget().invoke(list, -1); + throw new RuntimeException("expected IndexOutOfBoundsException"); + } catch (final IndexOutOfBoundsException ex) { + } + + try { + cs.getTarget().invoke(list, list.size()); + throw new RuntimeException("expected IndexOutOfBoundsException"); + } catch (final IndexOutOfBoundsException ex) { + } + } + + @Test(dataProvider = "flags") + public void removeElementFromListWithFixedKeyTest(final boolean publicLookup) throws Throwable { + final MethodType mt = MethodType.methodType(void.class, Object.class); + + final List list = new ArrayList<>(List.of(23, 430, -4354)); + + createCallSite(publicLookup, REMOVE_ELEMENT.named(1), mt).getTarget().invoke(list); + Assert.assertEquals(list, List.of(23, -4354)); + createCallSite(publicLookup, REMOVE_ELEMENT.named(1), mt).getTarget().invoke(list); + Assert.assertEquals(list, List.of(23)); + createCallSite(publicLookup, REMOVE_ELEMENT.named(0), mt).getTarget().invoke(list); + Assert.assertEquals(list, List.of()); + try { + createCallSite(publicLookup, REMOVE_ELEMENT.named(-1), mt).getTarget().invoke(list); + throw new RuntimeException("expected IndexOutOfBoundsException"); + } catch (final IndexOutOfBoundsException ex) { + } + + try { + createCallSite(publicLookup, REMOVE_ELEMENT.named(list.size()), mt).getTarget().invoke(list); + throw new RuntimeException("expected IndexOutOfBoundsException"); + } catch (final IndexOutOfBoundsException ex) { + } + } + + @Test(dataProvider = "flags") + public void removeElementFromMapTest(final boolean publicLookup) throws Throwable { + final MethodType mt = MethodType.methodType(void.class, Object.class, Object.class); + final CallSite cs = createCallSite(publicLookup, REMOVE_ELEMENT, mt); + + final Map map = new HashMap<>(Map.of("k1", "v1", "k2", "v2", "k3", "v3")); + + cs.getTarget().invoke(map, "k2"); + Assert.assertEquals(map, Map.of("k1", "v1", "k3", "v3")); + cs.getTarget().invoke(map, "k4"); + Assert.assertEquals(map, Map.of("k1", "v1", "k3", "v3")); + cs.getTarget().invoke(map, "k1"); + Assert.assertEquals(map, Map.of("k3", "v3")); + } + + + @Test(dataProvider = "flags") + public void removeElementFromMapWithFixedKeyTest(final boolean publicLookup) throws Throwable { + final MethodType mt = MethodType.methodType(void.class, Object.class); + + final Map map = new HashMap<>(Map.of("k1", "v1", "k2", "v2", "k3", "v3")); + + createCallSite(publicLookup, REMOVE_ELEMENT.named("k2"), mt).getTarget().invoke(map); + Assert.assertEquals(map, Map.of("k1", "v1", "k3", "v3")); + createCallSite(publicLookup, REMOVE_ELEMENT.named("k4"), mt).getTarget().invoke(map); + Assert.assertEquals(map, Map.of("k1", "v1", "k3", "v3")); + createCallSite(publicLookup, REMOVE_ELEMENT.named("k1"), mt).getTarget().invoke(map); + Assert.assertEquals(map, Map.of("k3", "v3")); + } } From 2f125c1bd558d092a568cb28e66feaff943a6aad Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Tue, 12 Dec 2017 13:08:22 +0000 Subject: [PATCH 08/26] 8185027: Typo in java.net.URLClassLoader.findResources(String) method documentation Reviewed-by: alanb --- src/java.base/share/classes/java/net/URLClassLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/classes/java/net/URLClassLoader.java b/src/java.base/share/classes/java/net/URLClassLoader.java index d6bd9546750..4b0ce17b743 100644 --- a/src/java.base/share/classes/java/net/URLClassLoader.java +++ b/src/java.base/share/classes/java/net/URLClassLoader.java @@ -658,8 +658,8 @@ public class URLClassLoader extends SecureClassLoader implements Closeable { * * @param name the resource name * @exception IOException if an I/O exception occurs - * @return an {@code Enumeration} of {@code URL}s - * If the loader is closed, the Enumeration will be empty. + * @return An {@code Enumeration} of {@code URL}s. + * If the loader is closed, the Enumeration contains no elements. */ public Enumeration findResources(final String name) throws IOException From ac4e5933a682e43f5ffbd053508719db07bc54f7 Mon Sep 17 00:00:00 2001 From: Srikanth Adayapalam Date: Tue, 12 Dec 2017 18:40:31 +0530 Subject: [PATCH 09/26] 8193142: Regression: ClassCastException: Type$ErrorType cannot be cast to Type$ArrayType Reviewed-by: mcimadamore --- .../share/classes/com/sun/tools/javac/comp/Attr.java | 3 --- .../tools/javac/varargs/ElementTypeMissingTest.java | 8 ++++++++ .../tools/javac/varargs/ElementTypeMissingTest.out | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 test/langtools/tools/javac/varargs/ElementTypeMissingTest.java create mode 100644 test/langtools/tools/javac/varargs/ElementTypeMissingTest.out diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java index 4fda61979f4..62b47d8af19 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java @@ -4238,9 +4238,6 @@ public class Attr extends JCTree.Visitor { public void visitTypeArray(JCArrayTypeTree tree) { Type etype = attribType(tree.elemtype, env); Type type = new ArrayType(etype, syms.arrayClass); - if (etype.isErroneous()) { - type = types.createErrorType(type); - } result = check(tree, type, KindSelector.TYP, resultInfo); } diff --git a/test/langtools/tools/javac/varargs/ElementTypeMissingTest.java b/test/langtools/tools/javac/varargs/ElementTypeMissingTest.java new file mode 100644 index 00000000000..4e24f4d74a0 --- /dev/null +++ b/test/langtools/tools/javac/varargs/ElementTypeMissingTest.java @@ -0,0 +1,8 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8193142 + * @summary Regression: ClassCastException: Type$ErrorType cannot be cast to Type$ArrayType + * @compile/fail/ref=ElementTypeMissingTest.out -XDrawDiagnostics -XDdev ElementTypeMissingTest.java + */ + +public class ElementTypeMissingTest { void m(Unkn... own) { } } \ No newline at end of file diff --git a/test/langtools/tools/javac/varargs/ElementTypeMissingTest.out b/test/langtools/tools/javac/varargs/ElementTypeMissingTest.out new file mode 100644 index 00000000000..aa40d2b96ac --- /dev/null +++ b/test/langtools/tools/javac/varargs/ElementTypeMissingTest.out @@ -0,0 +1,2 @@ +ElementTypeMissingTest.java:8:46: compiler.err.cant.resolve.location: kindname.class, Unkn, , , (compiler.misc.location: kindname.class, ElementTypeMissingTest, null) +1 error \ No newline at end of file From 225ec213e48f0bf8b81ce981157e1bfa459bf0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Tue, 12 Dec 2017 15:38:18 +0100 Subject: [PATCH 10/26] 8069338: Implement sharedScopeCall for optimistic types Reviewed-by: attila, sundar --- .../internal/codegen/CodeGenerator.java | 108 ++++++------- .../codegen/CodeGeneratorLexicalContext.java | 16 +- .../internal/codegen/MethodEmitter.java | 14 +- .../internal/codegen/SharedScopeCall.java | 147 +++++++++++------- .../internal/runtime/ScriptObject.java | 5 +- .../runtime/UnwarrantedOptimismException.java | 13 +- test/nashorn/script/basic/JDK-8069338.js | 85 ++++++++++ 7 files changed, 260 insertions(+), 128 deletions(-) create mode 100644 test/nashorn/script/basic/JDK-8069338.js diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java index f775050541e..43074a2c735 100644 --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java @@ -346,28 +346,30 @@ final class CodeGenerator extends NodeOperatorVisitor SharedScopeCall.FAST_SCOPE_GET_THRESHOLD && !identNode.isOptimistic()) { - // As shared scope vars are only used with non-optimistic identifiers, we switch from using TypeBounds to - // just a single definitive type, resultBounds.widest. - new OptimisticOperation(identNode, TypeBounds.OBJECT) { - @Override - void loadStack() { - method.loadCompilerConstant(SCOPE); - } - - @Override - void consumeStack() { - loadSharedScopeVar(resultBounds.widest, symbol, flags); - } - }.emit(); - } else { - new LoadFastScopeVar(identNode, resultBounds, flags).emit(); - } - } else { - //slow scope load, we have no proto depth + if (!isFastScope(symbol)) { + // slow scope load, prototype chain must be inspected at runtime new LoadScopeVar(identNode, resultBounds, flags).emit(); + } else if (identNode.isCompileTimePropertyName() || symbol.getUseCount() < SharedScopeCall.SHARED_GET_THRESHOLD) { + // fast scope load with known prototype depth + new LoadFastScopeVar(identNode, resultBounds, flags).emit(); + } else { + // Only generate shared scope getter for often used fast-scope symbols. + new OptimisticOperation(identNode, resultBounds) { + @Override + void loadStack() { + method.loadCompilerConstant(SCOPE); + final int depth = getScopeProtoDepth(lc.getCurrentBlock(), symbol); + assert depth >= 0; + method.load(depth); + method.load(getProgramPoint()); + } + + @Override + void consumeStack() { + final Type resultType = isOptimistic ? getOptimisticCoercedType() : resultBounds.widest; + lc.getScopeGet(unit, symbol, resultType, flags, isOptimistic).generateInvoke(method); + } + }.emit(); } return method; @@ -467,12 +469,6 @@ final class CodeGenerator extends NodeOperatorVisitor 1) { - method.load(depth); - method.invoke(ScriptObject.GET_PROTO_DEPTH); - } else { - method.invoke(ScriptObject.GET_PROTO); - } + invokeGetProto(depth); if (swap) { method.swap(); } } } + private void invokeGetProto(final int depth) { + assert depth > 0; + if (depth > 1) { + method.load(depth); + method.invoke(ScriptObject.GET_PROTO_DEPTH); + } else { + method.invoke(ScriptObject.GET_PROTO); + } + } + /** * Generate code that loads this node to the stack, not constraining its type * @@ -1386,12 +1387,7 @@ final class CodeGenerator extends NodeOperatorVisitor 1) { - method.load(count); - method.invoke(ScriptObject.GET_PROTO_DEPTH); - } else { - method.invoke(ScriptObject.GET_PROTO); - } + invokeGetProto(count); method.storeCompilerConstant(SCOPE); } @@ -1444,20 +1440,22 @@ final class CodeGenerator extends NodeOperatorVisitor= 0; + method.load(depth); + method.load(getProgramPoint()); loadArgs(args); } + @Override void consumeStack() { final Type[] paramTypes = method.getTypesFromStack(args.size()); @@ -1466,13 +1464,14 @@ final class CodeGenerator extends NodeOperatorVisitor clazz, final boolean isOptimismHandler) { recovery.joinFromTry(entry.getStack(), isOptimismHandler); + final String typeDescriptor = clazz == null ? null : CompilerConstants.className(clazz); method.visitTryCatchBlock(entry.getLabel(), exit.getLabel(), recovery.getLabel(), typeDescriptor); } @@ -727,7 +729,7 @@ public class MethodEmitter { * @param clazz exception class */ void _try(final Label entry, final Label exit, final Label recovery, final Class clazz) { - _try(entry, exit, recovery, CompilerConstants.className(clazz), clazz == UnwarrantedOptimismException.class); + _try(entry, exit, recovery, clazz, clazz == UnwarrantedOptimismException.class); } /** diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SharedScopeCall.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SharedScopeCall.java index eb4758f873d..0d7e54995c1 100644 --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SharedScopeCall.java +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/SharedScopeCall.java @@ -25,6 +25,7 @@ package jdk.nashorn.internal.codegen; +import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup; import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_OPTIMISTIC; import java.util.Arrays; @@ -32,39 +33,52 @@ import java.util.EnumSet; import jdk.nashorn.internal.codegen.types.Type; import jdk.nashorn.internal.ir.Symbol; import jdk.nashorn.internal.runtime.ScriptObject; +import jdk.nashorn.internal.runtime.UnwarrantedOptimismException; +import jdk.nashorn.internal.runtime.options.Options; /** - * A scope call or get operation that can be shared by several callsites. This generates a static + * A scope call or get operation that can be shared by several call sites. This generates a static * method that wraps the invokedynamic instructions to get or call scope variables. - * The rationale for this is that initial linking of invokedynamic callsites is expensive, - * so by sharing them we can reduce startup overhead and allow very large scripts to run that otherwise wouldn't. + * The reason for this is to reduce memory footprint and initial linking overhead of huge scripts. * - *

    Static methods generated by this class expect two parameters in addition to the parameters of the - * function call: The current scope object and the depth of the target scope relative to the scope argument - * for when this is known at compile-time (fast-scope access).

    + *

    Static methods generated by this class expect three parameters in addition to the parameters of the + * function call: The current scope object, the depth of the target scope relative to the scope argument, + * and the program point in case the target operation is optimistic.

    * - *

    The second argument may be -1 for non-fast-scope symbols, in which case the scope chain is checked - * for each call. This may cause callsite invalidation when the shared method is used from different - * scopes, but such sharing of non-fast scope calls may still be necessary for very large scripts.

    + *

    Optimistic operations are called with program point 0. If an UnwarrentedOptimismException + * is thrown, it is caught by the shared call method and rethrown with the program point of the invoking call site.

    * - *

    Scope calls must not be shared between normal callsites and callsites contained in a with - * statement as this condition is not handled by current guards and will cause a runtime error.

    + *

    Shared scope calls are not used if the scope contains a with statement or a call to + * eval.

    */ class SharedScopeCall { - /** Threshold for using shared scope calls with fast scope access. */ - public static final int FAST_SCOPE_CALL_THRESHOLD = 4; - /** Threshold for using shared scope calls with slow scope access. */ - public static final int SLOW_SCOPE_CALL_THRESHOLD = 500; - /** Threshold for using shared scope gets with fast scope access. */ - public static final int FAST_SCOPE_GET_THRESHOLD = 200; + /** + * Threshold for using shared scope function calls. + */ + public static final int SHARED_CALL_THRESHOLD = + Options.getIntProperty("nashorn.shared.scope.call.threshold", 5); + /** + * Threshold for using shared scope variable getter. This is higher than for calls as lower values + * degrade performance on many scripts. + */ + public static final int SHARED_GET_THRESHOLD = + Options.getIntProperty("nashorn.shared.scope.get.threshold", 100); - final Type valueType; - final Symbol symbol; - final Type returnType; - final Type[] paramTypes; - final int flags; - final boolean isCall; + private static final CompilerConstants.Call REPLACE_PROGRAM_POINT = virtualCallNoLookup( + UnwarrantedOptimismException.class, "replaceProgramPoint", + UnwarrantedOptimismException.class, int.class); + + /** Number of fixed parameters */ + private static final int FIXED_PARAM_COUNT = 3; + + private final Type valueType; + private final Symbol symbol; + private final Type returnType; + private final Type[] paramTypes; + private final int flags; + private final boolean isCall; + private final boolean isOptimistic; private CompileUnit compileUnit; private String methodName; private String staticSignature; @@ -77,21 +91,22 @@ class SharedScopeCall { * @param returnType the return type * @param paramTypes the function parameter types * @param flags the callsite flags + * @param isOptimistic whether target call is optimistic and we need to handle UnwarrentedOptimismException */ - SharedScopeCall(final Symbol symbol, final Type valueType, final Type returnType, final Type[] paramTypes, final int flags) { + SharedScopeCall(final Symbol symbol, final Type valueType, final Type returnType, final Type[] paramTypes, + final int flags, final boolean isOptimistic) { this.symbol = symbol; this.valueType = valueType; this.returnType = returnType; this.paramTypes = paramTypes; - assert (flags & CALLSITE_OPTIMISTIC) == 0; this.flags = flags; - // If paramTypes is not null this is a call, otherwise it's just a get. - this.isCall = paramTypes != null; + this.isCall = paramTypes != null; // If paramTypes is not null this is a call, otherwise it's just a get. + this.isOptimistic = isOptimistic; } @Override public int hashCode() { - return symbol.hashCode() ^ returnType.hashCode() ^ Arrays.hashCode(paramTypes) ^ flags; + return symbol.hashCode() ^ returnType.hashCode() ^ Arrays.hashCode(paramTypes) ^ flags ^ Boolean.hashCode(isOptimistic); } @Override @@ -101,7 +116,8 @@ class SharedScopeCall { return symbol.equals(c.symbol) && flags == c.flags && returnType.equals(c.returnType) - && Arrays.equals(paramTypes, c.paramTypes); + && Arrays.equals(paramTypes, c.paramTypes) + && isOptimistic == c.isOptimistic; } return false; } @@ -119,10 +135,9 @@ class SharedScopeCall { /** * Generate the invoke instruction for this shared scope call. * @param method the method emitter - * @return the method emitter */ - public MethodEmitter generateInvoke(final MethodEmitter method) { - return method.invokestatic(compileUnit.getUnitClassName(), methodName, getStaticSignature()); + public void generateInvoke(final MethodEmitter method) { + method.invokestatic(compileUnit.getUnitClassName(), methodName, getStaticSignature()); } /** @@ -140,51 +155,79 @@ class SharedScopeCall { final MethodEmitter method = classEmitter.method(methodFlags, methodName, getStaticSignature()); method.begin(); - // Load correct scope by calling getProto() on the scope argument as often as specified - // by the second argument. - final Label parentLoopStart = new Label("parent_loop_start"); - final Label parentLoopDone = new Label("parent_loop_done"); + // Load correct scope by calling getProto(int) on the scope argument with the supplied depth argument method.load(Type.OBJECT, 0); - method.label(parentLoopStart); method.load(Type.INT, 1); - method.iinc(1, -1); - method.ifle(parentLoopDone); - method.invoke(ScriptObject.GET_PROTO); - method._goto(parentLoopStart); - method.label(parentLoopDone); + method.invoke(ScriptObject.GET_PROTO_DEPTH); - assert !isCall || valueType.isObject(); // Callables are always objects - // If flags are optimistic, but we're doing a call, remove optimistic flags from the getter, as they obviously - // only apply to the call. - method.dynamicGet(valueType, symbol.getName(), isCall ? CodeGenerator.nonOptimisticFlags(flags) : flags, isCall, false); + assert !isCall || valueType.isObject(); // Callables are always loaded as object + + // Labels for catch of UnsupportedOptimismException + final Label beginTry; + final Label endTry; + final Label catchLabel; + + if(isOptimistic) { + beginTry = new Label("begin_try"); + endTry = new Label("end_try"); + catchLabel = new Label("catch_label"); + method.label(beginTry); + method._try(beginTry, endTry, catchLabel, UnwarrantedOptimismException.class, false); + } else { + beginTry = endTry = catchLabel = null; + } + + // If this is an optimistic get we set the optimistic flag but don't set the program point, + // which implies a program point of 0. If optimism fails we'll replace it with the actual + // program point which caller supplied as third argument. + final int getFlags = isOptimistic && !isCall ? flags | CALLSITE_OPTIMISTIC : flags; + method.dynamicGet(valueType, symbol.getName(), getFlags, isCall, false); // If this is a get we're done, otherwise call the value as function. if (isCall) { method.convert(Type.OBJECT); // ScriptFunction will see CALLSITE_SCOPE and will bind scope accordingly. method.loadUndefined(Type.OBJECT); - int slot = 2; + int slot = FIXED_PARAM_COUNT; for (final Type type : paramTypes) { method.load(type, slot); slot += type.getSlots(); } - // Shared scope calls disabled in optimistic world. TODO is this right? - method.dynamicCall(returnType, 2 + paramTypes.length, flags, symbol.getName()); + + // Same as above, set optimistic flag but leave program point as 0. + final int callFlags = isOptimistic ? flags | CALLSITE_OPTIMISTIC : flags; + + method.dynamicCall(returnType, 2 + paramTypes.length, callFlags, symbol.getName()); + + } + + if (isOptimistic) { + method.label(endTry); } method._return(returnType); + + if (isOptimistic) { + // We caught a UnwarrantedOptimismException, replace 0 program point with actual program point + method._catch(catchLabel); + method.load(Type.INT, 2); + method.invoke(REPLACE_PROGRAM_POINT); + method.athrow(); + } + method.end(); } private String getStaticSignature() { if (staticSignature == null) { if (paramTypes == null) { - staticSignature = Type.getMethodDescriptor(returnType, Type.typeFor(ScriptObject.class), Type.INT); + staticSignature = Type.getMethodDescriptor(returnType, Type.typeFor(ScriptObject.class), Type.INT, Type.INT); } else { - final Type[] params = new Type[paramTypes.length + 2]; + final Type[] params = new Type[paramTypes.length + FIXED_PARAM_COUNT]; params[0] = Type.typeFor(ScriptObject.class); params[1] = Type.INT; - System.arraycopy(paramTypes, 0, params, 2, paramTypes.length); + params[2] = Type.INT; + System.arraycopy(paramTypes, 0, params, FIXED_PARAM_COUNT, paramTypes.length); staticSignature = Type.getMethodDescriptor(returnType, params); } } diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java index 2b0ac1b7f55..40b8c67d9a6 100644 --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java @@ -1229,9 +1229,8 @@ public abstract class ScriptObject implements PropertyAccess, Cloneable { * @return proto at given depth */ public final ScriptObject getProto(final int n) { - assert n > 0; - ScriptObject p = getProto(); - for (int i = n; --i > 0;) { + ScriptObject p = this; + for (int i = n; i > 0; i--) { p = p.getProto(); } return p; diff --git a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/UnwarrantedOptimismException.java b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/UnwarrantedOptimismException.java index a92a0cccad8..f9deaf0fccc 100644 --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/UnwarrantedOptimismException.java +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/UnwarrantedOptimismException.java @@ -153,12 +153,15 @@ public final class UnwarrantedOptimismException extends RuntimeException { } /** - * Check if we ended up with a primitive return value (even though it may be - * too wide for what we tried to do, e.g. double instead of int) - * @return true if return value is primitive + * Return a new {@code UnwarrantedOptimismException} with the same return value and the + * new program point. + * + * @param newProgramPoint new new program point + * @return the new exception instance */ - public boolean hasPrimitiveReturnValue() { - return returnValue instanceof Number || returnValue instanceof Boolean; + public UnwarrantedOptimismException replaceProgramPoint(final int newProgramPoint) { + assert isValid(newProgramPoint); + return new UnwarrantedOptimismException(returnValue, newProgramPoint, returnType); } @Override diff --git a/test/nashorn/script/basic/JDK-8069338.js b/test/nashorn/script/basic/JDK-8069338.js new file mode 100644 index 00000000000..d242f13937a --- /dev/null +++ b/test/nashorn/script/basic/JDK-8069338.js @@ -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. + */ + +/** + * JDK-8069338: Implement sharedScopeCall for optimistic types + * + * @test + * @run + */ + +var c = 0; +var n = 1; + +function f() { + return c++ > 10 ? 'f' : 1; +} + +function h() { + var x = 0; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + n = 'b'; + x += n; + x += n; + x += n; + x += n; + x += n; + x += n; + return x; +} + +function g() { + var x = 0; + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + x += f(); + return x; +} + +Assert.assertEquals(h(), '11bbbbbb'); +Assert.assertEquals(g(), '11ffffff'); + From f1212e26c3126297268374142cf285ee66fe4e60 Mon Sep 17 00:00:00 2001 From: Martin Balao Date: Wed, 13 Dec 2017 01:29:58 +0800 Subject: [PATCH 11/26] 8165996: PKCS11 using NSS throws an error regarding secmod.db when NSS uses sqlite Reviewed-by: weijun --- .../classes/sun/security/pkcs11/Secmod.java | 22 ++- test/jdk/sun/security/pkcs11/PKCS11Test.java | 17 ++- .../sun/security/pkcs11/Secmod/README-SQLITE | 8 ++ .../pkcs11/Secmod/TestNssDbSqlite.java | 134 ++++++++++++++++++ test/jdk/sun/security/pkcs11/Secmod/cert9.db | Bin 0 -> 9216 bytes test/jdk/sun/security/pkcs11/Secmod/key4.db | Bin 0 -> 11264 bytes .../sun/security/pkcs11/Secmod/nss-sqlite.cfg | 13 ++ test/jdk/sun/security/pkcs11/SecmodTest.java | 23 ++- 8 files changed, 201 insertions(+), 16 deletions(-) create mode 100644 test/jdk/sun/security/pkcs11/Secmod/README-SQLITE create mode 100644 test/jdk/sun/security/pkcs11/Secmod/TestNssDbSqlite.java create mode 100644 test/jdk/sun/security/pkcs11/Secmod/cert9.db create mode 100644 test/jdk/sun/security/pkcs11/Secmod/key4.db create mode 100644 test/jdk/sun/security/pkcs11/Secmod/nss-sqlite.cfg diff --git a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Secmod.java b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Secmod.java index 2059e4bc5bf..c26c79c7209 100644 --- a/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Secmod.java +++ b/src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Secmod.java @@ -196,13 +196,23 @@ public final class Secmod { } if (configDir != null) { - File configBase = new File(configDir); - if (configBase.isDirectory() == false ) { - throw new IOException("configDir must be a directory: " + configDir); + String configDirPath = null; + String sqlPrefix = "sql:/"; + if (!configDir.startsWith(sqlPrefix)) { + configDirPath = configDir; + } else { + StringBuilder configDirPathSB = new StringBuilder(configDir); + configDirPath = configDirPathSB.substring(sqlPrefix.length()); } - File secmodFile = new File(configBase, "secmod.db"); - if (secmodFile.isFile() == false) { - throw new FileNotFoundException(secmodFile.getPath()); + File configBase = new File(configDirPath); + if (configBase.isDirectory() == false ) { + throw new IOException("configDir must be a directory: " + configDirPath); + } + if (!configDir.startsWith(sqlPrefix)) { + File secmodFile = new File(configBase, "secmod.db"); + if (secmodFile.isFile() == false) { + throw new FileNotFoundException(secmodFile.getPath()); + } } } diff --git a/test/jdk/sun/security/pkcs11/PKCS11Test.java b/test/jdk/sun/security/pkcs11/PKCS11Test.java index 7b23e808e77..49d0a0edbb3 100644 --- a/test/jdk/sun/security/pkcs11/PKCS11Test.java +++ b/test/jdk/sun/security/pkcs11/PKCS11Test.java @@ -741,13 +741,18 @@ public abstract class PKCS11Test { } private static String distro() { - try (BufferedReader in = - new BufferedReader(new InputStreamReader( - Runtime.getRuntime().exec("uname -v").getInputStream()))) { + if (props.getProperty("os.name").equals("SunOS")) { + try (BufferedReader in = + new BufferedReader(new InputStreamReader( + Runtime.getRuntime().exec("uname -v").getInputStream()))) { - return in.readLine(); - } catch (Exception e) { - throw new RuntimeException("Failed to determine distro.", e); + return in.readLine(); + } catch (Exception e) { + throw new RuntimeException("Failed to determine distro.", e); + } + } else { + // Not used outside Solaris + return null; } } diff --git a/test/jdk/sun/security/pkcs11/Secmod/README-SQLITE b/test/jdk/sun/security/pkcs11/Secmod/README-SQLITE new file mode 100644 index 00000000000..761866258c6 --- /dev/null +++ b/test/jdk/sun/security/pkcs11/Secmod/README-SQLITE @@ -0,0 +1,8 @@ +// How to create key4.db and cert9.db +cd +echo "" > 1 +echo "test12" > 2 +modutil -create -force -dbdir sql:/$(pwd) +modutil -list "NSS Internal PKCS #11 Module" -dbdir sql:/$(pwd) +modutil -changepw "NSS Certificate DB" -force -dbdir sql:/$(pwd) -pwfile $(pwd)/1 -newpwfile $(pwd)/2 + diff --git a/test/jdk/sun/security/pkcs11/Secmod/TestNssDbSqlite.java b/test/jdk/sun/security/pkcs11/Secmod/TestNssDbSqlite.java new file mode 100644 index 00000000000..ab503aeb94f --- /dev/null +++ b/test/jdk/sun/security/pkcs11/Secmod/TestNssDbSqlite.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. + * + * 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 8165996 + * @summary Test NSS DB Sqlite + * @library ../ + * @modules java.base/sun.security.rsa + * java.base/sun.security.provider + * java.base/sun.security.jca + * java.base/sun.security.tools.keytool + * java.base/sun.security.x509 + * java.base/com.sun.crypto.provider + * jdk.crypto.cryptoki/sun.security.pkcs11:+open + * @run main/othervm/timeout=120 TestNssDbSqlite + * @author Martin Balao (mbalao@redhat.com) + */ + +import java.security.PrivateKey; +import java.security.cert.Certificate; +import java.security.KeyStore; +import java.security.Provider; +import java.security.Signature; + +import sun.security.rsa.SunRsaSign; +import sun.security.jca.ProviderList; +import sun.security.jca.Providers; +import sun.security.tools.keytool.CertAndKeyGen; +import sun.security.x509.X500Name; + +public final class TestNssDbSqlite extends SecmodTest { + + private static final boolean enableDebug = true; + + private static Provider sunPKCS11NSSProvider; + private static Provider sunRsaSignProvider; + private static Provider sunJCEProvider; + private static KeyStore ks; + private static char[] passphrase = "test12".toCharArray(); + private static PrivateKey privateKey; + private static Certificate certificate; + + public static void main(String[] args) throws Exception { + + initialize(); + + if (enableDebug) { + System.out.println("SunPKCS11 provider: " + + sunPKCS11NSSProvider); + } + + testRetrieveKeysFromKeystore(); + + System.out.println("Test PASS - OK"); + } + + private static void testRetrieveKeysFromKeystore() throws Exception { + + String plainText = "known plain text"; + + ks.setKeyEntry("root_ca_1", privateKey, passphrase, + new Certificate[]{certificate}); + PrivateKey k1 = (PrivateKey) ks.getKey("root_ca_1", passphrase); + + Signature sS = Signature.getInstance( + "SHA256withRSA", sunPKCS11NSSProvider); + sS.initSign(k1); + sS.update(plainText.getBytes()); + byte[] generatedSignature = sS.sign(); + + if (enableDebug) { + System.out.println("Generated signature: "); + for (byte b : generatedSignature) { + System.out.printf("0x%02x, ", (int)(b) & 0xFF); + } + System.out.println(""); + } + + Signature sV = Signature.getInstance("SHA256withRSA", sunRsaSignProvider); + sV.initVerify(certificate); + sV.update(plainText.getBytes()); + if(!sV.verify(generatedSignature)){ + throw new Exception("Couldn't verify signature"); + } + } + + private static void initialize() throws Exception { + initializeProvider(); + } + + private static void initializeProvider () throws Exception { + useSqlite(true); + if (!initSecmod()) { + return; + } + + sunPKCS11NSSProvider = getSunPKCS11(BASE + SEP + "nss-sqlite.cfg"); + sunJCEProvider = new com.sun.crypto.provider.SunJCE(); + sunRsaSignProvider = new SunRsaSign(); + Providers.setProviderList(ProviderList.newList( + sunJCEProvider, sunPKCS11NSSProvider, + new sun.security.provider.Sun(), sunRsaSignProvider)); + + ks = KeyStore.getInstance("PKCS11-NSS-Sqlite", sunPKCS11NSSProvider); + ks.load(null, passphrase); + + CertAndKeyGen gen = new CertAndKeyGen("RSA", "SHA256withRSA"); + gen.generate(2048); + privateKey = gen.getPrivateKey(); + certificate = gen.getSelfCertificate(new X500Name("CN=Me"), 365); + } +} diff --git a/test/jdk/sun/security/pkcs11/Secmod/cert9.db b/test/jdk/sun/security/pkcs11/Secmod/cert9.db new file mode 100644 index 0000000000000000000000000000000000000000..a202bea21e99c8063fdce58c3fedff9c29bcc306 GIT binary patch literal 9216 zcmeHL&r2IY6y9}{s0HyDN)MT%ffnY+?z*8+jJkzT8#Rqk4@Gv971E|kO#=N73O)4i z>ABEj|CpY8>AY`eH|j+MEvC%EynHk7y>H%pJClsQIoumfGj@7@@iCb)Pvwo|9Rp9;=sJLr1$>mdh|C8Do ztO8bn2cp0us>7cD2l6&-8CHRRtH7G~Q(xrQ9cNtw$N8e%<$9yxeha2aI?m1}lY?10 z9t}#cw9|{*{h0OJ+j}u9huOwx$PRj)*X`ahdletEqi*N$C}#UzwzJ=Tx!2k0v-b9W zum6-KTsNVc)J+k_0F4M5il`e=H$s;}BA-k^CM2^-CL+@!laNWZX@QF87L1%Y1kdLo z7Qu-|aN-f1hy*7l!HG(6;u4(51Rsz!<>mE(S>_nb63i0J63i0J63i0J3RwzS3RwzS z3Rxk%A-o~HA-rMk1!oA(O+-Q;0f8h|Dmmp!tW=^}pX)~o8a9x46`~cQ6{58hA$cIh z_)yB{G`A0>d?@8(Rv)wacrO8R1F!{P3y?d=0_CfKC=DcD18HFf(hLUD5)Gtv8b|^f zNGj$Kq8K<&gFI$*o)#8q;k+CTi*ht9%F(bWN5g_w!=fAw3tkN`@zS25iS;OL90O_h z7)V>lz~LNbb9h=pY=k^EotKkRIl~~~!xV}~^lmw1r&wQwt)@P>&u{;=u|g^K_y6|7 z*$k_||Dpi>{a;=B;dsBiuima#(a=6tfdx`vt5&Pm8}9MwY?yr>d`L#a@>aTPE~}mH zZv2+PM>o>a&o=ZWPc~mv!EgkIagt`^GGgTl1ANyRRCBjdt3PSD?~p&4rSG%Bv}9Pm z!eG4DIRqEYwpXh^F4i%cOlH|dNm9K+k~^<+M4~B{YW29`I(Z?V#`-_|C&_Gjj{Zr> sb|OmX+28*K+UmActH2#AV9);@3u@`C0t=*oJ^u^zvTUhVfjd^zQB-lYi7PmC0V2VJxRYskE~qM-KR$|rvGyHobniBo zxvZB8NCp0$0uj;4igs_mmw|_FjhbfhpH?*X5lf5k6@CupvXXB zL(v6A7K&~t94IQH=te5$mB`3|gEKDih;5-#7Aj?7R12e8_+B#T zn?be=vSrYB)XkWdnE^^40_81M=hq$6O!E8sL<7&8!9)WX2=A&ed$!VvOdHH2;mkNt)?5IoyT zm`(-Ksb(Bjt)Svrc()8?2V2XuyVG+0U%*#Sx=ICFT!D7=ff7?Y6z!!prEODxsE^bR z^+JnxN~S-51?sU_BAFzYHsVHZ%xyY5oTd}pm(JM41+{;&g)0??`g8fhCMte6kBKE7 zZbo`bTu!P;oOg6{yxg7A9d4S-5bR0U@qw9%8iX2A6(GyOs8ty2U z_(>KAb`%a!Y=qrpXh1u~4$Vk!k0Qr@8_^SMQl#vqKUq2M zjy6M%*bI(_*F1}bGoH?CdSZ3Zn_8nW=}v?+(HS&e>nxTmPn)Wq*qNG3%aE_kL#)a5 zfBsWNdP)UaT>&}&Tm22n{G|f(S3u7H`D-UVr2?(40RI2i?kM7vhg3i+@NX$lCefsI zDSpanG|rAsRJUGx`r`8YyI+rVK3lPFWcjQ6yKcT_TUn>xwqdGo>PtIW79|>69a;7H zaq-RbL+d}B|Fr*N?#j=1N89?os)R&VJX!np;SKB7x4x?{?!|kDZo~Rdv`>mS Date: Tue, 12 Dec 2017 09:33:35 -0800 Subject: [PATCH 12/26] 8171826: Comparator.reverseOrder(c) mishandles singleton comparators Reviewed-by: rriggs --- .../share/classes/java/util/Collections.java | 24 +++++++----- test/jdk/java/util/Comparator/BasicTest.java | 38 +++++++++++++++---- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/src/java.base/share/classes/java/util/Collections.java b/src/java.base/share/classes/java/util/Collections.java index 4904ef56c18..6d35e074280 100644 --- a/src/java.base/share/classes/java/util/Collections.java +++ b/src/java.base/share/classes/java/util/Collections.java @@ -24,9 +24,10 @@ */ package java.util; -import java.io.Serializable; -import java.io.ObjectOutputStream; + import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.Serializable; import java.lang.reflect.Array; import java.util.function.BiConsumer; import java.util.function.BiFunction; @@ -5164,14 +5165,19 @@ public class Collections { * specified comparator. * @since 1.5 */ + @SuppressWarnings("unchecked") public static Comparator reverseOrder(Comparator cmp) { - if (cmp == null) - return reverseOrder(); - - if (cmp instanceof ReverseComparator2) - return ((ReverseComparator2)cmp).cmp; - - return new ReverseComparator2<>(cmp); + if (cmp == null) { + return (Comparator) ReverseComparator.REVERSE_ORDER; + } else if (cmp == ReverseComparator.REVERSE_ORDER) { + return (Comparator) Comparators.NaturalOrderComparator.INSTANCE; + } else if (cmp == Comparators.NaturalOrderComparator.INSTANCE) { + return (Comparator) ReverseComparator.REVERSE_ORDER; + } else if (cmp instanceof ReverseComparator2) { + return ((ReverseComparator2) cmp).cmp; + } else { + return new ReverseComparator2<>(cmp); + } } /** diff --git a/test/jdk/java/util/Comparator/BasicTest.java b/test/jdk/java/util/Comparator/BasicTest.java index b4eb5d4ac40..47cd4f983ea 100644 --- a/test/jdk/java/util/Comparator/BasicTest.java +++ b/test/jdk/java/util/Comparator/BasicTest.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 @@ -23,22 +23,21 @@ /** * @test + * @bug 8171826 * @summary Comparator default method tests * @run testng BasicTest */ -import java.util.TreeMap; -import java.util.Comparator; import org.testng.annotations.Test; +import java.util.Collections; +import java.util.Comparator; import java.util.function.Function; +import java.util.function.ToDoubleFunction; import java.util.function.ToIntFunction; import java.util.function.ToLongFunction; -import java.util.function.ToDoubleFunction; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import static org.testng.Assert.*; @Test(groups = "unit") public class BasicTest { @@ -366,4 +365,29 @@ public class BasicTest { fail("comparing(null) should throw NPE"); } catch (NullPointerException npe) {} } + + public void testNaturalAndReverseIdentity() { + var naturalOrder = Comparator.naturalOrder(); + var reverseOrder = Comparator.reverseOrder(); + + assertEquals( + naturalOrder, + Collections.reverseOrder(reverseOrder), + "Comparator.naturalOrder() and Collections.reverseOrder(Comparator.reverseOrder()) not equal"); + + assertEquals( + reverseOrder, + Collections.reverseOrder(naturalOrder), + "Comparator.reverseOrder() and Collections.reverseOrder(Comparator.naturalOrder()) not equal"); + + assertEquals( + naturalOrder.reversed(), + reverseOrder, + "Comparator.naturalOrder().reversed() amd Comparator.reverseOrder() not equal"); + + assertEquals( + reverseOrder.reversed(), + naturalOrder, + "Comparator.reverseOrder().reversed() and Comparator.naturalOrder() not equal"); + } } From 3246c46f41eead3cfb00d57d7f5d3b6d31319f92 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Tue, 12 Dec 2017 09:33:37 -0800 Subject: [PATCH 13/26] 8187254: MethodType allows unvalidated parameter types Reviewed-by: mchung, jrose --- .../classes/java/lang/invoke/MethodType.java | 28 ++++++------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/java.base/share/classes/java/lang/invoke/MethodType.java b/src/java.base/share/classes/java/lang/invoke/MethodType.java index c7582e2c1ec..f3346bc21c6 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodType.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodType.java @@ -105,23 +105,10 @@ class MethodType implements java.io.Serializable { private @Stable String methodDescriptor; // cache for toMethodDescriptorString /** - * Check the given parameters for validity and store them into the final fields. + * Constructor that performs no copying or validation. + * Should only be called from the factory method makeImpl */ - private MethodType(Class rtype, Class[] ptypes, boolean trusted) { - checkRtype(rtype); - checkPtypes(ptypes); - this.rtype = rtype; - // defensively copy the array passed in by the user - this.ptypes = trusted ? ptypes : Arrays.copyOf(ptypes, ptypes.length); - } - - /** - * Construct a temporary unchecked instance of MethodType for use only as a key to the intern table. - * Does not check the given parameters for validity, and must discarded (if untrusted) or checked - * (if trusted) after it has been used as a searching key. - * The parameters are reversed for this constructor, so that it is not accidentally used. - */ - private MethodType(Class[] ptypes, Class rtype) { + private MethodType(Class rtype, Class[] ptypes) { this.rtype = rtype; this.ptypes = ptypes; } @@ -308,18 +295,21 @@ class MethodType implements java.io.Serializable { if (ptypes.length == 0) { ptypes = NO_PTYPES; trusted = true; } - MethodType primordialMT = new MethodType(ptypes, rtype); + MethodType primordialMT = new MethodType(rtype, ptypes); MethodType mt = internTable.get(primordialMT); if (mt != null) return mt; // promote the object to the Real Thing, and reprobe + MethodType.checkRtype(rtype); if (trusted) { - MethodType.checkRtype(rtype); MethodType.checkPtypes(ptypes); mt = primordialMT; } else { - mt = new MethodType(rtype, ptypes, false); + // Make defensive copy then validate + ptypes = Arrays.copyOf(ptypes, ptypes.length); + MethodType.checkPtypes(ptypes); + mt = new MethodType(rtype, ptypes); } mt.form = MethodTypeForm.findForm(mt); return internTable.add(mt); From f065141ddc23ab4cf8436af719042d0faf52b04b Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Tue, 12 Dec 2017 10:21:58 -0800 Subject: [PATCH 14/26] 8176841: Additional Unicode Language-Tag Extensions 8189134: New system properties for the default Locale extensions 8190918: Retrieve the region specific data regardless of language in locale 8191349: Add a new method in j.t.f.DateTimeFormatter to reflect Unicode extensions Reviewed-by: scolebourne, lancea, rriggs, rgoel, nishjain --- .../tools/cldrconverter/CLDRConverter.java | 269 +++--- .../tools/cldrconverter/LDMLParseHandler.java | 90 +- .../NumberingSystemsParseHandler.java | 31 +- .../ResourceBundleGenerator.java | 55 +- .../SupplementDataParseHandler.java | 81 +- .../cldrconverter/TimeZoneParseHandler.java | 64 ++ .../share/classes/java/text/DateFormat.java | 7 + .../classes/java/text/DateFormatSymbols.java | 14 +- .../java/text/DecimalFormatSymbols.java | 16 +- .../share/classes/java/text/NumberFormat.java | 9 +- .../classes/java/text/SimpleDateFormat.java | 2 +- .../java/time/format/DateTimeFormatter.java | 58 +- .../time/format/DateTimeFormatterBuilder.java | 10 +- .../time/format/DateTimeTextProvider.java | 3 +- .../java/time/format/DecimalStyle.java | 5 + .../java/time/temporal/ChronoField.java | 7 +- .../classes/java/time/temporal/IsoFields.java | 5 +- .../java/time/temporal/WeekFields.java | 9 +- .../share/classes/java/util/Calendar.java | 42 +- .../share/classes/java/util/Currency.java | 38 +- .../share/classes/java/util/Locale.java | 241 +++-- .../java/util/spi/LocaleNameProvider.java | 53 +- .../classes/sun/launcher/LauncherHelper.java | 2 +- .../cldr/CLDRCalendarDataProviderImpl.java | 106 +++ .../util/cldr/CLDRLocaleProviderAdapter.java | 35 +- .../provider/CalendarDataProviderImpl.java | 13 +- .../locale/provider/CalendarDataUtility.java | 59 +- .../provider/DateFormatProviderImpl.java | 19 +- .../provider/JRELocaleProviderAdapter.java | 4 +- .../locale/provider/LocaleDataMetaInfo.java | 13 +- .../provider/LocaleNameProviderImpl.java | 24 +- .../util/locale/provider/LocaleResources.java | 14 +- .../provider/NumberFormatProviderImpl.java | 11 +- .../provider/SPILocaleProviderAdapter.java | 40 +- .../locale/provider/TimeZoneNameUtility.java | 17 +- .../sun/util/resources/LocaleNames.properties | 5 +- .../cldr/resources/common/bcp47/timezone.xml | 470 ++++++++++ .../cldr/resources/common/dtd/ldmlBCP47.dtd | 74 ++ test/java/util/Calendar/Bug8185841.java | 278 ------ .../time/format/TestUnicodeExtension.java | 852 ++++++++++++++++++ test/jdk/java/util/Calendar/Bug4302966.java | 6 +- .../java/util/Calendar/CalendarDataTest.java | 108 +++ .../util/Locale/bcp47u/CalendarTests.java | 158 ++++ .../util/Locale/bcp47u/CurrencyTests.java | 106 +++ .../util/Locale/bcp47u/DefaultLocaleTest.java | 46 + .../util/Locale/bcp47u/DisplayNameTests.java | 109 +++ .../java/util/Locale/bcp47u/FormatTests.java | 167 ++++ .../java/util/Locale/bcp47u/SymbolsTests.java | 91 ++ .../Locale/bcp47u/SystemPropertyTests.java | 99 ++ .../bcp47u/spi/LocaleNameProviderTests.java | 52 ++ .../provider/foo/LocaleNameProviderImpl.java | 65 ++ .../bcp47u/spi/provider/module-info.java | 27 + test/jdk/sun/text/resources/LocaleData.cldr | 294 +++--- .../sun/text/resources/LocaleDataTest.java | 2 +- .../plugins/IncludeLocalesPluginTest.java | 46 +- 55 files changed, 3631 insertions(+), 890 deletions(-) create mode 100644 make/jdk/src/classes/build/tools/cldrconverter/TimeZoneParseHandler.java create mode 100644 src/java.base/share/classes/sun/util/cldr/CLDRCalendarDataProviderImpl.java create mode 100644 src/jdk.localedata/share/classes/sun/util/cldr/resources/common/bcp47/timezone.xml create mode 100644 src/jdk.localedata/share/classes/sun/util/cldr/resources/common/dtd/ldmlBCP47.dtd delete mode 100644 test/java/util/Calendar/Bug8185841.java create mode 100644 test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java create mode 100644 test/jdk/java/util/Calendar/CalendarDataTest.java create mode 100644 test/jdk/java/util/Locale/bcp47u/CalendarTests.java create mode 100644 test/jdk/java/util/Locale/bcp47u/CurrencyTests.java create mode 100644 test/jdk/java/util/Locale/bcp47u/DefaultLocaleTest.java create mode 100644 test/jdk/java/util/Locale/bcp47u/DisplayNameTests.java create mode 100644 test/jdk/java/util/Locale/bcp47u/FormatTests.java create mode 100644 test/jdk/java/util/Locale/bcp47u/SymbolsTests.java create mode 100644 test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java create mode 100644 test/jdk/java/util/Locale/bcp47u/spi/LocaleNameProviderTests.java create mode 100644 test/jdk/java/util/Locale/bcp47u/spi/provider/foo/LocaleNameProviderImpl.java create mode 100644 test/jdk/java/util/Locale/bcp47u/spi/provider/module-info.java diff --git a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java index 8743efcb5ac..4eb0e0ace8e 100644 --- a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java +++ b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java @@ -37,6 +37,7 @@ import java.util.ResourceBundle.Control; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; +import java.util.stream.IntStream; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.SAXNotRecognizedException; @@ -52,21 +53,32 @@ public class CLDRConverter { static final String LDML_DTD_SYSTEM_ID = "http://www.unicode.org/cldr/dtd/2.0/ldml.dtd"; static final String SPPL_LDML_DTD_SYSTEM_ID = "http://www.unicode.org/cldr/dtd/2.0/ldmlSupplemental.dtd"; + static final String BCP47_LDML_DTD_SYSTEM_ID = "http://www.unicode.org/cldr/dtd/2.0/ldmlBCP47.dtd"; + private static String CLDR_BASE = "../CLDR/21.0.1/"; static String LOCAL_LDML_DTD; static String LOCAL_SPPL_LDML_DTD; + static String LOCAL_BCP47_LDML_DTD; private static String SOURCE_FILE_DIR; private static String SPPL_SOURCE_FILE; private static String NUMBERING_SOURCE_FILE; private static String METAZONES_SOURCE_FILE; private static String LIKELYSUBTAGS_SOURCE_FILE; + private static String TIMEZONE_SOURCE_FILE; static String DESTINATION_DIR = "build/gensrc"; static final String LOCALE_NAME_PREFIX = "locale.displayname."; + static final String LOCALE_SEPARATOR = LOCALE_NAME_PREFIX + "separator"; + static final String LOCALE_KEYTYPE = LOCALE_NAME_PREFIX + "keytype"; + static final String LOCALE_KEY_PREFIX = LOCALE_NAME_PREFIX + "key."; + static final String LOCALE_TYPE_PREFIX = LOCALE_NAME_PREFIX + "type."; + static final String LOCALE_TYPE_PREFIX_CA = LOCALE_TYPE_PREFIX + "ca."; static final String CURRENCY_SYMBOL_PREFIX = "currency.symbol."; static final String CURRENCY_NAME_PREFIX = "currency.displayname."; static final String CALENDAR_NAME_PREFIX = "calendarname."; + static final String CALENDAR_FIRSTDAY_PREFIX = "firstDay."; + static final String CALENDAR_MINDAYS_PREFIX = "minDays."; static final String TIMEZONE_ID_PREFIX = "timezone.id."; static final String ZONE_NAME_PREFIX = "timezone.displayname."; static final String METAZONE_ID_PREFIX = "metazone.id."; @@ -76,6 +88,7 @@ public class CLDRConverter { private static LikelySubtagsParseHandler handlerLikelySubtags; static NumberingSystemsParseHandler handlerNumbering; static MetaZonesParseHandler handlerMetaZones; + static TimeZoneParseHandler handlerTimeZone; private static BundleGenerator bundleGenerator; // java.base module related @@ -201,11 +214,13 @@ public class CLDRConverter { // Set up path names LOCAL_LDML_DTD = CLDR_BASE + "/dtd/ldml.dtd"; LOCAL_SPPL_LDML_DTD = CLDR_BASE + "/dtd/ldmlSupplemental.dtd"; + LOCAL_BCP47_LDML_DTD = CLDR_BASE + "/dtd/ldmlBCP47.dtd"; SOURCE_FILE_DIR = CLDR_BASE + "/main"; SPPL_SOURCE_FILE = CLDR_BASE + "/supplemental/supplementalData.xml"; LIKELYSUBTAGS_SOURCE_FILE = CLDR_BASE + "/supplemental/likelySubtags.xml"; NUMBERING_SOURCE_FILE = CLDR_BASE + "/supplemental/numberingSystems.xml"; METAZONES_SOURCE_FILE = CLDR_BASE + "/supplemental/metaZones.xml"; + TIMEZONE_SOURCE_FILE = CLDR_BASE + "/bcp47/timezone.xml"; if (BASE_LOCALES.isEmpty()) { setupBaseLocales("en-US"); @@ -215,10 +230,10 @@ public class CLDRConverter { // Parse data independent of locales parseSupplemental(); + parseBCP47(); List bundles = readBundleList(); convertBundles(bundles); - convertBundles(addedBundles); } private static void usage() { @@ -314,34 +329,19 @@ public class CLDRConverter { } private static final Map> cldrBundles = new HashMap<>(); - // this list will contain additional bundles to be generated for Region dependent Data. - private static List addedBundles = new ArrayList<>(); private static Map> metaInfo = new HashMap<>(); static { // For generating information on supported locales. - metaInfo.put("LocaleNames", new TreeSet<>()); - metaInfo.put("CurrencyNames", new TreeSet<>()); - metaInfo.put("TimeZoneNames", new TreeSet<>()); - metaInfo.put("CalendarData", new TreeSet<>()); - metaInfo.put("FormatData", new TreeSet<>()); metaInfo.put("AvailableLocales", new TreeSet<>()); } - - private static Set calendarDataFields = Set.of("firstDayOfWeek", "minimalDaysInFirstWeek"); - static Map getCLDRBundle(String id) throws Exception { Map bundle = cldrBundles.get(id); if (bundle != null) { return bundle; } - SAXParserFactory factory = SAXParserFactory.newInstance(); - factory.setValidating(true); - SAXParser parser = factory.newSAXParser(); - enableFileAccess(parser); - LDMLParseHandler handler = new LDMLParseHandler(id); File file = new File(SOURCE_FILE_DIR + File.separator + id + ".xml"); if (!file.exists()) { // Skip if the file doesn't exist. @@ -349,14 +349,15 @@ public class CLDRConverter { } info("..... main directory ....."); - info("Reading file " + file); - parser.parse(file, handler); + LDMLParseHandler handler = new LDMLParseHandler(id); + parseLDMLFile(file, handler); bundle = handler.getData(); cldrBundles.put(id, bundle); - String country = getCountryCode(id); - if (country != null) { - bundle = handlerSuppl.getData(country); + + if (id.equals("root")) { + // Calendar data (firstDayOfWeek & minDaysInFirstWeek) + bundle = handlerSuppl.getData("root"); if (bundle != null) { //merge two maps into one map Map temp = cldrBundles.remove(id); @@ -379,98 +380,44 @@ public class CLDRConverter { // SupplementalData file also provides the "parent" locales which // are othrwise not to be fallen back. Process them here as well. // - info("..... Parsing supplementalData.xml ....."); - SAXParserFactory factorySuppl = SAXParserFactory.newInstance(); - factorySuppl.setValidating(true); - SAXParser parserSuppl = factorySuppl.newSAXParser(); - enableFileAccess(parserSuppl); handlerSuppl = new SupplementDataParseHandler(); - File fileSupply = new File(SPPL_SOURCE_FILE); - parserSuppl.parse(fileSupply, handlerSuppl); + parseLDMLFile(new File(SPPL_SOURCE_FILE), handlerSuppl); Map parentData = handlerSuppl.getData("root"); - parentData.keySet().forEach(key -> { + parentData.keySet().stream() + .filter(key -> key.startsWith(PARENT_LOCALE_PREFIX)) + .forEach(key -> { parentLocalesMap.put(key, new TreeSet( Arrays.asList(((String)parentData.get(key)).split(" ")))); }); // Parse numberingSystems to get digit zero character information. - SAXParserFactory numberingParser = SAXParserFactory.newInstance(); - numberingParser.setValidating(true); - SAXParser parserNumbering = numberingParser.newSAXParser(); - enableFileAccess(parserNumbering); handlerNumbering = new NumberingSystemsParseHandler(); - File fileNumbering = new File(NUMBERING_SOURCE_FILE); - parserNumbering.parse(fileNumbering, handlerNumbering); + parseLDMLFile(new File(NUMBERING_SOURCE_FILE), handlerNumbering); // Parse metaZones to create mappings between Olson tzids and CLDR meta zone names - info("..... Parsing metaZones.xml ....."); - SAXParserFactory metazonesParser = SAXParserFactory.newInstance(); - metazonesParser.setValidating(true); - SAXParser parserMetaZones = metazonesParser.newSAXParser(); - enableFileAccess(parserMetaZones); handlerMetaZones = new MetaZonesParseHandler(); - File fileMetaZones = new File(METAZONES_SOURCE_FILE); - parserMetaZones.parse(fileMetaZones, handlerMetaZones); + parseLDMLFile(new File(METAZONES_SOURCE_FILE), handlerMetaZones); // Parse likelySubtags - info("..... Parsing likelySubtags.xml ....."); - SAXParserFactory likelySubtagsParser = SAXParserFactory.newInstance(); - likelySubtagsParser.setValidating(true); - SAXParser parserLikelySubtags = likelySubtagsParser.newSAXParser(); - enableFileAccess(parserLikelySubtags); handlerLikelySubtags = new LikelySubtagsParseHandler(); - File fileLikelySubtags = new File(LIKELYSUBTAGS_SOURCE_FILE); - parserLikelySubtags.parse(fileLikelySubtags, handlerLikelySubtags); + parseLDMLFile(new File(LIKELYSUBTAGS_SOURCE_FILE), handlerLikelySubtags); } - /** - * This method will check if a new region dependent Bundle needs to be - * generated for this Locale id and targetMap. New Bundle will be generated - * when Locale id has non empty script and country code and targetMap - * contains region dependent data. This method will also remove region - * dependent data from this targetMap after candidate locales check. E.g. It - * will call genRegionDependentBundle() in case of az_Latn_AZ locale and - * remove region dependent data from this targetMap so that az_Latn_AZ - * bundle will not be created. For az_Cyrl_AZ, new Bundle will be generated - * but region dependent data will not be removed from targetMap as its candidate - * locales are [az_Cyrl_AZ, az_Cyrl, root], which does not include az_AZ for - * fallback. - * - */ - - private static void checkRegionDependentBundle(Map targetMap, String id) { - if ((CLDRConverter.getScript(id) != "") - && (CLDRConverter.getCountryCode(id) != "")) { - Map regionDepDataMap = targetMap - .keySet() - .stream() - .filter(calendarDataFields::contains) - .collect(Collectors.toMap(k -> k, targetMap::get)); - if (!regionDepDataMap.isEmpty()) { - Locale cldrLoc = new Locale(CLDRConverter.getLanguageCode(id), - CLDRConverter.getCountryCode(id)); - genRegionDependentBundle(regionDepDataMap, cldrLoc); - if (checkCandidateLocales(id, cldrLoc)) { - // Remove matchedKeys from this targetMap only if checkCandidateLocales() returns true. - regionDepDataMap.keySet().forEach(targetMap::remove); - } - } - } + // Parsers for data in "bcp47" directory + // + private static void parseBCP47() throws Exception { + // Parse timezone + handlerTimeZone = new TimeZoneParseHandler(); + parseLDMLFile(new File(TIMEZONE_SOURCE_FILE), handlerTimeZone); } - /** - * This method will generate a new Bundle for region dependent data, - * minimalDaysInFirstWeek and firstDayOfWeek. Newly generated Bundle will be added - * to addedBundles list. - */ - private static void genRegionDependentBundle(Map targetMap, Locale cldrLoc) { - String localeId = cldrLoc.toString(); - StringBuilder sb = getCandLocales(cldrLoc); - if (sb.indexOf(localeId) == -1) { - sb.append(localeId); - } - Bundle bundle = new Bundle(localeId, sb.toString(), null, null); - cldrBundles.put(localeId, targetMap); - addedBundles.add(bundle); + + private static void parseLDMLFile(File srcfile, AbstractLDMLHandler handler) throws Exception { + info("..... Parsing " + srcfile.getName() + " ....."); + SAXParserFactory pf = SAXParserFactory.newInstance(); + pf.setValidating(true); + SAXParser parser = pf.newSAXParser(); + enableFileAccess(parser); + parser.parse(srcfile, handler); } private static StringBuilder getCandLocales(Locale cldrLoc) { @@ -491,16 +438,6 @@ public class CLDRConverter { return candList; } - /** - * This method will return true, if for a given locale, its language and - * country specific locale will exist in runtime lookup path. E.g. it will - * return true for bs_Latn_BA. - */ - private static boolean checkCandidateLocales(String id, Locale cldrLoc) { - return(getCandidateLocales(Locale.forLanguageTag(id.replaceAll("_", "-"))) - .contains(cldrLoc)); - } - private static void convertBundles(List bundles) throws Exception { // parent locales map. The mappings are put in base metaInfo file // for now. @@ -514,8 +451,6 @@ public class CLDRConverter { Map targetMap = bundle.getTargetMap(); - // check if new region DependentBundle needs to be generated for this Locale. - checkRegionDependentBundle(targetMap, bundle.getID()); EnumSet bundleTypes = bundle.getBundleTypes(); if (bundle.isRoot()) { @@ -528,40 +463,30 @@ public class CLDRConverter { if (bundleTypes.contains(Bundle.Type.LOCALENAMES)) { Map localeNamesMap = extractLocaleNames(targetMap, bundle.getID()); if (!localeNamesMap.isEmpty() || bundle.isRoot()) { - metaInfo.get("LocaleNames").add(toLanguageTag(bundle.getID())); - addLikelySubtags(metaInfo, "LocaleNames", bundle.getID()); bundleGenerator.generateBundle("util", "LocaleNames", bundle.getJavaID(), true, localeNamesMap, BundleType.OPEN); } } if (bundleTypes.contains(Bundle.Type.CURRENCYNAMES)) { Map currencyNamesMap = extractCurrencyNames(targetMap, bundle.getID(), bundle.getCurrencies()); if (!currencyNamesMap.isEmpty() || bundle.isRoot()) { - metaInfo.get("CurrencyNames").add(toLanguageTag(bundle.getID())); - addLikelySubtags(metaInfo, "CurrencyNames", bundle.getID()); bundleGenerator.generateBundle("util", "CurrencyNames", bundle.getJavaID(), true, currencyNamesMap, BundleType.OPEN); } } if (bundleTypes.contains(Bundle.Type.TIMEZONENAMES)) { Map zoneNamesMap = extractZoneNames(targetMap, bundle.getID()); if (!zoneNamesMap.isEmpty() || bundle.isRoot()) { - metaInfo.get("TimeZoneNames").add(toLanguageTag(bundle.getID())); - addLikelySubtags(metaInfo, "TimeZoneNames", bundle.getID()); bundleGenerator.generateBundle("util", "TimeZoneNames", bundle.getJavaID(), true, zoneNamesMap, BundleType.TIMEZONE); } } if (bundleTypes.contains(Bundle.Type.CALENDARDATA)) { Map calendarDataMap = extractCalendarData(targetMap, bundle.getID()); if (!calendarDataMap.isEmpty() || bundle.isRoot()) { - metaInfo.get("CalendarData").add(toLanguageTag(bundle.getID())); - addLikelySubtags(metaInfo, "CalendarData", bundle.getID()); bundleGenerator.generateBundle("util", "CalendarData", bundle.getJavaID(), true, calendarDataMap, BundleType.PLAIN); } } if (bundleTypes.contains(Bundle.Type.FORMATDATA)) { Map formatDataMap = extractFormatData(targetMap, bundle.getID()); if (!formatDataMap.isEmpty() || bundle.isRoot()) { - metaInfo.get("FormatData").add(toLanguageTag(bundle.getID())); - addLikelySubtags(metaInfo, "FormatData", bundle.getID()); bundleGenerator.generateBundle("text", "FormatData", bundle.getJavaID(), true, formatDataMap, BundleType.PLAIN); } } @@ -570,43 +495,9 @@ public class CLDRConverter { metaInfo.get("AvailableLocales").add(toLanguageTag(bundle.getID())); addLikelySubtags(metaInfo, "AvailableLocales", bundle.getID()); } - addCldrImplicitLocales(metaInfo); bundleGenerator.generateMetaInfo(metaInfo); } - /** - * These are the Locales that are implicitly supported by CLDR. - * Adding them explicitly as likelySubtags here, will ensure that - * COMPAT locales do not precede them during ResourceBundle search path. - */ - private static void addCldrImplicitLocales(Map> metaInfo) { - metaInfo.get("LocaleNames").add("zh-Hans-CN"); - metaInfo.get("LocaleNames").add("zh-Hans-SG"); - metaInfo.get("LocaleNames").add("zh-Hant-HK"); - metaInfo.get("LocaleNames").add("zh-Hant-MO"); - metaInfo.get("LocaleNames").add("zh-Hant-TW"); - metaInfo.get("CurrencyNames").add("zh-Hans-CN"); - metaInfo.get("CurrencyNames").add("zh-Hans-SG"); - metaInfo.get("CurrencyNames").add("zh-Hant-HK"); - metaInfo.get("CurrencyNames").add("zh-Hant-MO"); - metaInfo.get("CurrencyNames").add("zh-Hant-TW"); - metaInfo.get("TimeZoneNames").add("zh-Hans-CN"); - metaInfo.get("TimeZoneNames").add("zh-Hans-SG"); - metaInfo.get("TimeZoneNames").add("zh-Hant-HK"); - metaInfo.get("TimeZoneNames").add("zh-Hant-MO"); - metaInfo.get("TimeZoneNames").add("zh-Hant-TW"); - metaInfo.get("TimeZoneNames").add("zh-HK"); - metaInfo.get("CalendarData").add("zh-Hans-CN"); - metaInfo.get("CalendarData").add("zh-Hans-SG"); - metaInfo.get("CalendarData").add("zh-Hant-HK"); - metaInfo.get("CalendarData").add("zh-Hant-MO"); - metaInfo.get("CalendarData").add("zh-Hant-TW"); - metaInfo.get("FormatData").add("zh-Hans-CN"); - metaInfo.get("FormatData").add("zh-Hans-SG"); - metaInfo.get("FormatData").add("zh-Hant-HK"); - metaInfo.get("FormatData").add("zh-Hant-MO"); - metaInfo.get("FormatData").add("zh-Hant-TW"); - } static final Map aliases = new HashMap<>(); /** @@ -656,14 +547,6 @@ public class CLDRConverter { return Locale.forLanguageTag(id.replaceAll("_", "-")).getCountry(); } - /* - * Returns the script portion of the given id. - * If id is "root", "" is returned. - */ - static String getScript(String id) { - return "root".equals(id) ? "" : Locale.forLanguageTag(id.replaceAll("_", "-")).getScript(); - } - private static class KeyComparator implements Comparator { static KeyComparator INSTANCE = new KeyComparator(); @@ -695,9 +578,25 @@ public class CLDRConverter { Map localeNames = new TreeMap<>(KeyComparator.INSTANCE); for (String key : map.keySet()) { if (key.startsWith(LOCALE_NAME_PREFIX)) { - localeNames.put(key.substring(LOCALE_NAME_PREFIX.length()), map.get(key)); + switch (key) { + case LOCALE_SEPARATOR: + localeNames.put("ListCompositionPattern", map.get(key)); + break; + case LOCALE_KEYTYPE: + localeNames.put("ListKeyTypePattern", map.get(key)); + break; + default: + localeNames.put(key.substring(LOCALE_NAME_PREFIX.length()), map.get(key)); + break; + } } } + + if (id.equals("root")) { + // Add display name pattern, which is not in CLDR + localeNames.put("DisplayNamePattern", "{0,choice,0#|1#{1}|2#{1} ({2})}"); + } + return localeNames; } @@ -778,10 +677,30 @@ public class CLDRConverter { return names; } + /** + * Extracts the language independent calendar data. Each of the two keys, + * "firstDayOfWeek" and "minimalDaysInFirstWeek" has a string value consists of + * one or multiple occurrences of: + * i: rg1 rg2 ... rgn; + * where "i" is the data for the following regions (delimited by a space) after + * ":", and ends with a ";". + */ private static Map extractCalendarData(Map map, String id) { Map calendarData = new LinkedHashMap<>(); - copyIfPresent(map, "firstDayOfWeek", calendarData); - copyIfPresent(map, "minimalDaysInFirstWeek", calendarData); + if (id.equals("root")) { + calendarData.put("firstDayOfWeek", + IntStream.range(1, 8) + .mapToObj(String::valueOf) + .filter(d -> map.keySet().contains(CALENDAR_FIRSTDAY_PREFIX + d)) + .map(d -> d + ": " + map.get(CALENDAR_FIRSTDAY_PREFIX + d)) + .collect(Collectors.joining(";"))); + calendarData.put("minimalDaysInFirstWeek", + IntStream.range(0, 7) + .mapToObj(String::valueOf) + .filter(d -> map.keySet().contains(CALENDAR_MINDAYS_PREFIX + d)) + .map(d -> d + ": " + map.get(CALENDAR_MINDAYS_PREFIX + d)) + .collect(Collectors.joining(";"))); + } return calendarData; } @@ -844,17 +763,19 @@ public class CLDRConverter { for (String key : map.keySet()) { // Copy available calendar names - if (key.startsWith(CLDRConverter.CALENDAR_NAME_PREFIX)) { - String type = key.substring(CLDRConverter.CALENDAR_NAME_PREFIX.length()); + if (key.startsWith(CLDRConverter.LOCALE_TYPE_PREFIX_CA)) { + String type = key.substring(CLDRConverter.LOCALE_TYPE_PREFIX_CA.length()); for (CalendarType calendarType : CalendarType.values()) { if (calendarType == CalendarType.GENERIC) { continue; } if (type.equals(calendarType.lname())) { Object value = map.get(key); - formatData.put(key, value); - String ukey = CLDRConverter.CALENDAR_NAME_PREFIX + calendarType.uname(); - if (!key.equals(ukey)) { + String dataKey = key.replace(LOCALE_TYPE_PREFIX_CA, + CALENDAR_NAME_PREFIX); + formatData.put(dataKey, value); + String ukey = CALENDAR_NAME_PREFIX + calendarType.uname(); + if (!dataKey.equals(ukey)) { formatData.put(ukey, value); } } @@ -874,6 +795,18 @@ public class CLDRConverter { copyIfPresent(map, "NumberElements", formatData); } copyIfPresent(map, "NumberPatterns", formatData); + + // put extra number elements for available scripts into formatData, if it is "root" + if (id.equals("root")) { + handlerNumbering.keySet().stream() + .filter(k -> !numberingScripts.contains(k)) + .forEach(k -> { + String[] ne = (String[])map.get("latn.NumberElements"); + String[] neNew = Arrays.copyOf(ne, ne.length); + neNew[4] = handlerNumbering.get(k).substring(0, 1); + formatData.put(k + ".NumberElements", neNew); + }); + } return formatData; } diff --git a/make/jdk/src/classes/build/tools/cldrconverter/LDMLParseHandler.java b/make/jdk/src/classes/build/tools/cldrconverter/LDMLParseHandler.java index b229c91731f..34cf8a2d4d3 100644 --- a/make/jdk/src/classes/build/tools/cldrconverter/LDMLParseHandler.java +++ b/make/jdk/src/classes/build/tools/cldrconverter/LDMLParseHandler.java @@ -76,12 +76,16 @@ class LDMLParseHandler extends AbstractLDMLHandler { // ignore this element - it has language and territory elements that aren't locale data pushIgnoredContainer(qName); break; - case "type": - if ("calendar".equals(attributes.getValue("key"))) { - pushStringEntry(qName, attributes, CLDRConverter.CALENDAR_NAME_PREFIX + attributes.getValue("type")); - } else { - pushIgnoredContainer(qName); - } + + // for LocaleNames + // copy string + case "localeSeparator": + pushStringEntry(qName, attributes, + CLDRConverter.LOCALE_SEPARATOR); + break; + case "localeKeyTypePattern": + pushStringEntry(qName, attributes, + CLDRConverter.LOCALE_KEYTYPE); break; case "language": @@ -96,6 +100,24 @@ class LDMLParseHandler extends AbstractLDMLHandler { attributes.getValue("type")); break; + case "key": + // for LocaleNames + // copy string + pushStringEntry(qName, attributes, + CLDRConverter.LOCALE_KEY_PREFIX + + convertOldKeyName(attributes.getValue("type"))); + break; + + case "type": + // for LocaleNames/CalendarNames + // copy string + pushStringEntry(qName, attributes, + CLDRConverter.LOCALE_TYPE_PREFIX + + convertOldKeyName(attributes.getValue("key")) + "." + + attributes.getValue("type")); + + break; + // // Currency information // @@ -515,26 +537,10 @@ class LDMLParseHandler extends AbstractLDMLHandler { currentNumberingSystem = script + "."; String digits = CLDRConverter.handlerNumbering.get(script); if (digits == null) { - throw new InternalError("null digits for " + script); - } - if (Character.isSurrogate(digits.charAt(0))) { - // DecimalFormatSymbols doesn't support supplementary characters as digit zero. pushIgnoredContainer(qName); break; } - // in case digits are in the reversed order, reverse back the order. - if (digits.charAt(0) > digits.charAt(digits.length() - 1)) { - StringBuilder sb = new StringBuilder(digits); - digits = sb.reverse().toString(); - } - // Check if the order is sequential. - char c0 = digits.charAt(0); - for (int i = 1; i < digits.length(); i++) { - if (digits.charAt(i) != c0 + i) { - pushIgnoredContainer(qName); - break symbols; - } - } + @SuppressWarnings("unchecked") List numberingScripts = (List) get("numberingScripts"); if (numberingScripts == null) { @@ -924,17 +930,35 @@ class LDMLParseHandler extends AbstractLDMLHandler { } } } else if (currentContainer instanceof Entry) { - Entry entry = (Entry) currentContainer; - Object value = entry.getValue(); - if (value != null) { - String key = entry.getKey(); - // Tweak for MonthNames for the root locale, Needed for - // SimpleDateFormat.format()/parse() roundtrip. - if (id.equals("root") && key.startsWith("MonthNames")) { - value = new DateFormatSymbols(Locale.US).getShortMonths(); - } - put(entry.getKey(), value); + Entry entry = (Entry) currentContainer; + Object value = entry.getValue(); + if (value != null) { + String key = entry.getKey(); + // Tweak for MonthNames for the root locale, Needed for + // SimpleDateFormat.format()/parse() roundtrip. + if (id.equals("root") && key.startsWith("MonthNames")) { + value = new DateFormatSymbols(Locale.US).getShortMonths(); } + put(entry.getKey(), value); } } } + + public String convertOldKeyName(String key) { + // Explicitly obtained from "alias" attribute in each "key" element. + switch (key) { + case "calendar": + return "ca"; + case "currency": + return "cu"; + case "collation": + return "co"; + case "numbers": + return "nu"; + case "timezone": + return "tz"; + default: + return key; + } + } +} diff --git a/make/jdk/src/classes/build/tools/cldrconverter/NumberingSystemsParseHandler.java b/make/jdk/src/classes/build/tools/cldrconverter/NumberingSystemsParseHandler.java index 64f83d01e8b..11e43e49fc0 100644 --- a/make/jdk/src/classes/build/tools/cldrconverter/NumberingSystemsParseHandler.java +++ b/make/jdk/src/classes/build/tools/cldrconverter/NumberingSystemsParseHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -54,9 +54,32 @@ class NumberingSystemsParseHandler extends AbstractLDMLHandler { public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { switch (qName) { case "numberingSystem": - if ("numeric".equals(attributes.getValue("type"))) { - // eg, - put(attributes.getValue("id"), attributes.getValue("digits")); + numberingSystem: { + if ("numeric".equals(attributes.getValue("type"))) { + // eg, + String script = attributes.getValue("id"); + String digits = attributes.getValue("digits"); + + if (Character.isSurrogate(digits.charAt(0))) { + // DecimalFormatSymbols doesn't support supplementary characters as digit zero. + break numberingSystem; + } + // in case digits are in the reversed order, reverse back the order. + if (digits.charAt(0) > digits.charAt(digits.length() - 1)) { + StringBuilder sb = new StringBuilder(digits); + digits = sb.reverse().toString(); + } + // Check if the order is sequential. + char c0 = digits.charAt(0); + for (int i = 1; i < digits.length(); i++) { + if (digits.charAt(i) != c0 + i) { + break numberingSystem; + } + } + + // script/digits are acceptable. + put(script, digits); + } } pushIgnoredContainer(qName); break; diff --git a/make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java b/make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java index b291758402f..7a882e650f3 100644 --- a/make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java +++ b/make/jdk/src/classes/build/tools/cldrconverter/ResourceBundleGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, 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 @@ -256,20 +256,21 @@ class ResourceBundleGenerator implements BundleGenerator { CLDRConverter.info("Generating file " + file); try (PrintWriter out = new PrintWriter(file, "us-ascii")) { - out.println(CopyrightHeaders.getOpenJDKCopyright()); + out.printf(CopyrightHeaders.getOpenJDKCopyright()); - out.println((CLDRConverter.isBaseModule ? "package sun.util.cldr;\n\n" : + out.printf((CLDRConverter.isBaseModule ? "package sun.util.cldr;\n\n" : "package sun.util.resources.cldr.provider;\n\n") + "import java.util.HashMap;\n" + "import java.util.Locale;\n" + "import java.util.Map;\n" - + "import sun.util.locale.provider.LocaleProviderAdapter;\n" - + "import sun.util.locale.provider.LocaleDataMetaInfo;\n"); + + "import sun.util.locale.provider.LocaleDataMetaInfo;\n" + + "import sun.util.locale.provider.LocaleProviderAdapter;\n\n"); out.printf("public class %s implements LocaleDataMetaInfo {\n", className); - out.println(" private static final Map resourceNameToLocales = new HashMap<>();\n" + - (CLDRConverter.isBaseModule ? - " private static final Map parentLocalesMap = new HashMap<>();\n\n" : "\n") + - " static {\n"); + out.printf(" private static final Map resourceNameToLocales = new HashMap<>();\n" + + (CLDRConverter.isBaseModule ? + " private static final Map parentLocalesMap = new HashMap<>();\n\n" : + "\n") + + " static {\n"); for (String key : metaInfo.keySet()) { if (key.startsWith(CLDRConverter.PARENT_LOCALE_PREFIX)) { @@ -296,30 +297,50 @@ class ResourceBundleGenerator implements BundleGenerator { } out.printf("\n });\n"); } else { - out.printf(" resourceNameToLocales.put(\"%s\",\n", key); - out.printf(" \"%s\");\n", - toLocaleList(key.equals("FormatData") ? metaInfo.get("AvailableLocales") : - metaInfo.get(key), false)); + if ("AvailableLocales".equals(key)) { + out.printf(" resourceNameToLocales.put(\"%s\",\n", key); + out.printf(" \"%s\");\n", toLocaleList(metaInfo.get(key), false)); + } } } - out.println(" }\n\n"); - out.println(" @Override\n" + + out.printf(" }\n\n"); + + // end of static initializer block. + + // Short TZ names for delayed initialization + if (CLDRConverter.isBaseModule) { + out.printf(" private static class TZShortIDMapHolder {\n"); + out.printf(" static final Map tzShortIDMap = new HashMap<>();\n"); + out.printf(" static {\n"); + CLDRConverter.handlerTimeZone.getData().entrySet().stream() + .forEach(e -> { + out.printf(" tzShortIDMap.put(\"%s\", \"%s\");\n", e.getKey(), + ((String)e.getValue())); + }); + out.printf(" }\n }\n\n"); + } + + out.printf(" @Override\n" + " public LocaleProviderAdapter.Type getType() {\n" + " return LocaleProviderAdapter.Type.CLDR;\n" + " }\n\n"); - out.println(" @Override\n" + + out.printf(" @Override\n" + " public String availableLanguageTags(String category) {\n" + " return resourceNameToLocales.getOrDefault(category, \"\");\n" + " }\n\n"); if (CLDRConverter.isBaseModule) { + out.printf(" @Override\n" + + " public Map tzShortIDs() {\n" + + " return TZShortIDMapHolder.tzShortIDMap;\n" + + " }\n\n"); out.printf(" public Map parentLocales() {\n" + " return parentLocalesMap;\n" + " }\n}"); } else { - out.println("}"); + out.printf("}"); } } } diff --git a/make/jdk/src/classes/build/tools/cldrconverter/SupplementDataParseHandler.java b/make/jdk/src/classes/build/tools/cldrconverter/SupplementDataParseHandler.java index c5941d35e95..fdc8a977766 100644 --- a/make/jdk/src/classes/build/tools/cldrconverter/SupplementDataParseHandler.java +++ b/make/jdk/src/classes/build/tools/cldrconverter/SupplementDataParseHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -84,53 +84,18 @@ class SupplementDataParseHandler extends AbstractLDMLHandler { values.put(CLDRConverter.PARENT_LOCALE_PREFIX+key, parentLocalesMap.get(key)); }); - } else { - String countryData = getWeekData(id, JAVA_FIRSTDAY, firstDayMap); - if (countryData != null) { - values.put(JAVA_FIRSTDAY, countryData); - } - String minDaysData = getWeekData(id, JAVA_MINDAY, minDaysMap); - if (minDaysData != null) { - values.put(JAVA_MINDAY, minDaysData); - } + firstDayMap.keySet().forEach(key -> { + values.put(CLDRConverter.CALENDAR_FIRSTDAY_PREFIX+firstDayMap.get(key), + key); + }); + minDaysMap.keySet().forEach(key -> { + values.put(CLDRConverter.CALENDAR_MINDAYS_PREFIX+minDaysMap.get(key), + key); + }); } return values.isEmpty() ? null : values; } - /** - * It returns either firstDay or minDays in the JRE format for the country. - * - * @param country territory code of the requested data - * @param jreDataName JAVA_FIRSTDAY or JAVA_MINDAY - * @param dataMap firstDayMap or minDaysMap - * @return the value for the given jreDataName, or null if requested value - * (firstDay/minDays) is not available although that is highly unlikely - * because of the default value for the world (001). - */ - String getWeekData(String country, final String jreDataName, final Map dataMap) { - String countryValue = null; - String defaultWorldValue = null; - for (String key : dataMap.keySet()) { - if (key.contains(country)) { - if (jreDataName.equals(JAVA_FIRSTDAY)) { - countryValue = DAY_OF_WEEK_MAP.get((String) dataMap.get(key)); - } else if (jreDataName.equals(JAVA_MINDAY)) { - countryValue = (String) dataMap.get(key); - } - if (countryValue != null) { - return countryValue; - } - } else if (key.contains(WORLD)) { - if (jreDataName.equals(JAVA_FIRSTDAY)) { - defaultWorldValue = DAY_OF_WEEK_MAP.get((String) dataMap.get(key)); - } else if (jreDataName.equals(JAVA_MINDAY)) { - defaultWorldValue = (String) dataMap.get(key); - } - } - } - return defaultWorldValue; - } - @Override public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException { // avoid HTTP traffic to unicode.org @@ -152,7 +117,33 @@ class SupplementDataParseHandler extends AbstractLDMLHandler { switch (qName) { case "firstDay": if (!isIgnored(attributes)) { - firstDayMap.put(attributes.getValue("territories"), attributes.getValue("day")); + String fd; + + switch (attributes.getValue("day")) { + case "sun": + fd = "1"; + break; + default: + case "mon": + fd = "2"; + break; + case "tue": + fd = "3"; + break; + case "wed": + fd = "4"; + break; + case "thu": + fd = "5"; + break; + case "fri": + fd = "6"; + break; + case "sat": + fd = "7"; + break; + } + firstDayMap.put(attributes.getValue("territories"), fd); } break; case "minDays": diff --git a/make/jdk/src/classes/build/tools/cldrconverter/TimeZoneParseHandler.java b/make/jdk/src/classes/build/tools/cldrconverter/TimeZoneParseHandler.java new file mode 100644 index 00000000000..ad0bd2ebd69 --- /dev/null +++ b/make/jdk/src/classes/build/tools/cldrconverter/TimeZoneParseHandler.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. 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 build.tools.cldrconverter; + +import java.io.File; +import java.io.IOException; +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/** + * Handles parsing of timezone.xml and produces a map from short timezone IDs to + * tz database IDs. + */ + +class TimeZoneParseHandler extends AbstractLDMLHandler { + + @Override + public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException { + // avoid HTTP traffic to unicode.org + if (systemID.startsWith(CLDRConverter.BCP47_LDML_DTD_SYSTEM_ID)) { + return new InputSource((new File(CLDRConverter.LOCAL_BCP47_LDML_DTD)).toURI().toString()); + } + return null; + } + + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + switch (qName) { + case "type": + if (!isIgnored(attributes) && !attributes.getValue("deprecated").equals("true")) { + put(attributes.getValue("name"), attributes.getValue("alias")); + } + break; + default: + // treat anything else as a container + pushContainer(qName, attributes); + break; + } + } +} diff --git a/src/java.base/share/classes/java/text/DateFormat.java b/src/java.base/share/classes/java/text/DateFormat.java index a6bfe3232ec..2ee443c6638 100644 --- a/src/java.base/share/classes/java/text/DateFormat.java +++ b/src/java.base/share/classes/java/text/DateFormat.java @@ -97,6 +97,13 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * DateFormat df = DateFormat.getDateInstance(DateFormat.LONG, Locale.FRANCE); * } * + * + *

    If the specified locale contains "ca" (calendar), "rg" (region override), + * and/or "tz" (timezone) Unicode + * extensions, the calendar, the country and/or the time zone for formatting + * are overridden. If both "ca" and "rg" are specified, the calendar from the "ca" + * extension supersedes the implicit one from the "rg" extension. + * *

    You can use a DateFormat to parse also. *

    *
    {@code
    diff --git a/src/java.base/share/classes/java/text/DateFormatSymbols.java b/src/java.base/share/classes/java/text/DateFormatSymbols.java
    index 724c1e71ac3..774b64ca1b5 100644
    --- a/src/java.base/share/classes/java/text/DateFormatSymbols.java
    +++ b/src/java.base/share/classes/java/text/DateFormatSymbols.java
    @@ -1,5 +1,5 @@
     /*
    - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
    + * Copyright (c) 1996, 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,6 +49,7 @@ import java.util.Objects;
     import java.util.ResourceBundle;
     import java.util.concurrent.ConcurrentHashMap;
     import java.util.concurrent.ConcurrentMap;
    +import sun.util.locale.provider.CalendarDataUtility;
     import sun.util.locale.provider.LocaleProviderAdapter;
     import sun.util.locale.provider.LocaleServiceProviderPool;
     import sun.util.locale.provider.ResourceBundleBasedAdapter;
    @@ -82,6 +83,10 @@ import sun.util.locale.provider.TimeZoneNameUtility;
      * 
    *
    * + *

    If the locale contains "rg" (region override) + * Unicode extension, + * the symbols are overridden for the designated region. + * *

    * DateFormatSymbols objects are cloneable. When you obtain * a DateFormatSymbols object, feel free to modify the @@ -716,15 +721,18 @@ public class DateFormatSymbols implements Serializable, Cloneable { } dfs = new DateFormatSymbols(false); + // check for region override + Locale override = CalendarDataUtility.findRegionOverride(locale); + // Initialize the fields from the ResourceBundle for locale. LocaleProviderAdapter adapter - = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, locale); + = LocaleProviderAdapter.getAdapter(DateFormatSymbolsProvider.class, override); // Avoid any potential recursions if (!(adapter instanceof ResourceBundleBasedAdapter)) { adapter = LocaleProviderAdapter.getResourceBundleBased(); } ResourceBundle resource - = ((ResourceBundleBasedAdapter)adapter).getLocaleData().getDateFormatData(locale); + = ((ResourceBundleBasedAdapter)adapter).getLocaleData().getDateFormatData(override); dfs.locale = locale; // JRE and CLDR use different keys diff --git a/src/java.base/share/classes/java/text/DecimalFormatSymbols.java b/src/java.base/share/classes/java/text/DecimalFormatSymbols.java index 989d6f26377..59e68600589 100644 --- a/src/java.base/share/classes/java/text/DecimalFormatSymbols.java +++ b/src/java.base/share/classes/java/text/DecimalFormatSymbols.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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,6 +44,7 @@ import java.io.Serializable; import java.text.spi.DecimalFormatSymbolsProvider; import java.util.Currency; import java.util.Locale; +import sun.util.locale.provider.CalendarDataUtility; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleServiceProviderPool; import sun.util.locale.provider.ResourceBundleBasedAdapter; @@ -56,6 +57,10 @@ import sun.util.locale.provider.ResourceBundleBasedAdapter; * of these symbols, you can get the DecimalFormatSymbols object from * your DecimalFormat and modify it. * + *

    If the locale contains "rg" (region override) + * Unicode extension, + * the symbols are overridden for the designated region. + * * @see java.util.Locale * @see DecimalFormat * @author Mark Davis @@ -609,13 +614,18 @@ public class DecimalFormatSymbols implements Cloneable, Serializable { private void initialize( Locale locale ) { this.locale = locale; + // check for region override + Locale override = locale.getUnicodeLocaleType("nu") == null ? + CalendarDataUtility.findRegionOverride(locale) : + locale; + // get resource bundle data - LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, locale); + LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DecimalFormatSymbolsProvider.class, override); // Avoid potential recursions if (!(adapter instanceof ResourceBundleBasedAdapter)) { adapter = LocaleProviderAdapter.getResourceBundleBased(); } - Object[] data = adapter.getLocaleResources(locale).getDecimalFormatSymbolsData(); + Object[] data = adapter.getLocaleResources(override).getDecimalFormatSymbolsData(); String[] numberElements = (String[]) data[0]; decimalSeparator = numberElements[0].charAt(0); diff --git a/src/java.base/share/classes/java/text/NumberFormat.java b/src/java.base/share/classes/java/text/NumberFormat.java index aab8eab226a..a1de3fe8f2f 100644 --- a/src/java.base/share/classes/java/text/NumberFormat.java +++ b/src/java.base/share/classes/java/text/NumberFormat.java @@ -96,7 +96,14 @@ import sun.util.locale.provider.LocaleServiceProviderPool; * NumberFormat nf = NumberFormat.getInstance(Locale.FRENCH); * } * - * You can also use a NumberFormat to parse numbers: + * + *

    If the locale contains "nu" (numbers) and/or "rg" (region override) + * Unicode extensions, + * the decimal digits, and/or the country used for formatting are overridden. + * If both "nu" and "rg" are specified, the decimal digits from the "nu" + * extension supersedes the implicit one from the "rg" extension. + * + *

    You can also use a {@code NumberFormat} to parse numbers: *

    *
    {@code
      * myNumber = nf.parse(myString);
    diff --git a/src/java.base/share/classes/java/text/SimpleDateFormat.java b/src/java.base/share/classes/java/text/SimpleDateFormat.java
    index eb070c68da5..0f36386cbbf 100644
    --- a/src/java.base/share/classes/java/text/SimpleDateFormat.java
    +++ b/src/java.base/share/classes/java/text/SimpleDateFormat.java
    @@ -672,7 +672,7 @@ public class SimpleDateFormat extends DateFormat {
                 // However, the calendar should use the current default TimeZone.
                 // If this is not contained in the locale zone strings, then the zone
                 // will be formatted using generic GMT+/-H:MM nomenclature.
    -            calendar = Calendar.getInstance(TimeZone.getDefault(), loc);
    +            calendar = Calendar.getInstance(loc);
             }
         }
     
    diff --git a/src/java.base/share/classes/java/time/format/DateTimeFormatter.java b/src/java.base/share/classes/java/time/format/DateTimeFormatter.java
    index c73d0bb0c26..199313df7e1 100644
    --- a/src/java.base/share/classes/java/time/format/DateTimeFormatter.java
    +++ b/src/java.base/share/classes/java/time/format/DateTimeFormatter.java
    @@ -97,6 +97,7 @@ import java.util.Locale;
     import java.util.Map;
     import java.util.Objects;
     import java.util.Set;
    +import sun.util.locale.provider.TimeZoneNameUtility;
     
     /**
      * Formatter for printing and parsing date-time objects.
    @@ -548,7 +549,7 @@ public final class DateTimeFormatter {
          * For example, {@code d MMM uuuu} will format 2011-12-03 as '3 Dec 2011'.
          * 

    * The formatter will use the {@link Locale#getDefault(Locale.Category) default FORMAT locale}. - * This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter + * This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter. * Alternatively use the {@link #ofPattern(String, Locale)} variant of this method. *

    * The returned formatter has no override chronology or zone. @@ -572,7 +573,7 @@ public final class DateTimeFormatter { * For example, {@code d MMM uuuu} will format 2011-12-03 as '3 Dec 2011'. *

    * The formatter will use the specified locale. - * This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter + * This can be changed using {@link DateTimeFormatter#withLocale(Locale)} on the returned formatter. *

    * The returned formatter has no override chronology or zone. * It uses {@link ResolverStyle#SMART SMART} resolver style. @@ -1443,10 +1444,17 @@ public final class DateTimeFormatter { * This is used to lookup any part of the formatter needing specific * localization, such as the text or localized pattern. *

    + * The locale is stored as passed in, without further processing. + * If the locale has + * Unicode extensions, they may be used later in text + * processing. To set the chronology, time-zone and decimal style from + * unicode extensions, see {@link #localizedBy localizedBy()}. + *

    * This instance is immutable and unaffected by this method call. * * @param locale the new locale, not null * @return a formatter based on this formatter with the requested locale, not null + * @see #localizedBy(Locale) */ public DateTimeFormatter withLocale(Locale locale) { if (this.locale.equals(locale)) { @@ -1455,6 +1463,52 @@ public final class DateTimeFormatter { return new DateTimeFormatter(printerParser, locale, decimalStyle, resolverStyle, resolverFields, chrono, zone); } + /** + * Returns a copy of this formatter with localized values of the locale, + * calendar, region, decimal style and/or timezone, that supercede values in + * this formatter. + *

    + * This is used to lookup any part of the formatter needing specific + * localization, such as the text or localized pattern. If the locale contains the + * "ca" (calendar), "nu" (numbering system), "rg" (region override), and/or + * "tz" (timezone) + * Unicode extensions, + * the chronology, numbering system and/or the zone are overridden. If both "ca" + * and "rg" are specified, the chronology from the "ca" extension supersedes the + * implicit one from the "rg" extension. Same is true for the "nu" extension. + *

    + * Unlike the {@link #withLocale withLocale} method, the call to this method may + * produce a different formatter depending on the order of method chaining with + * other withXXXX() methods. + *

    + * This instance is immutable and unaffected by this method call. + * + * @param locale the locale, not null + * @return a formatter based on this formatter with localized values of + * the calendar, decimal style and/or timezone, that supercede values in this + * formatter. + * @see #withLocale(Locale) + * @since 10 + */ + public DateTimeFormatter localizedBy(Locale locale) { + if (this.locale.equals(locale)) { + return this; + } + + // Check for decimalStyle/chronology/timezone in locale object + Chronology c = locale.getUnicodeLocaleType("ca") != null ? + Chronology.ofLocale(locale) : chrono; + DecimalStyle ds = locale.getUnicodeLocaleType("nu") != null ? + DecimalStyle.of(locale) : decimalStyle; + String tzType = locale.getUnicodeLocaleType("tz"); + ZoneId z = tzType != null ? + TimeZoneNameUtility.convertLDMLShortID(tzType) + .map(ZoneId::of) + .orElse(zone) : + zone; + return new DateTimeFormatter(printerParser, locale, ds, resolverStyle, resolverFields, c, z); + } + //----------------------------------------------------------------------- /** * Gets the DecimalStyle to be used during formatting. diff --git a/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java b/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java index ebf044919a4..5735325f30f 100644 --- a/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java +++ b/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, 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 @@ -120,6 +120,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import sun.text.spi.JavaTimeDateTimePatternProvider; +import sun.util.locale.provider.CalendarDataUtility; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleResources; import sun.util.locale.provider.TimeZoneNameUtility; @@ -198,6 +199,10 @@ public final class DateTimeFormatterBuilder { * Gets the formatting pattern for date and time styles for a locale and chronology. * The locale and chronology are used to lookup the locale specific format * for the requested dateStyle and/or timeStyle. + *

    + * If the locale contains the "rg" (region override) + * Unicode extensions, + * the formatting pattern is overridden with the one appropriate for the region. * * @param dateStyle the FormatStyle for the date, null for time-only pattern * @param timeStyle the FormatStyle for the time, null for date-only pattern @@ -216,7 +221,8 @@ public final class DateTimeFormatterBuilder { LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(JavaTimeDateTimePatternProvider.class, locale); JavaTimeDateTimePatternProvider provider = adapter.getJavaTimeDateTimePatternProvider(); String pattern = provider.getJavaTimeDateTimePattern(convertStyle(timeStyle), - convertStyle(dateStyle), chrono.getCalendarType(), locale); + convertStyle(dateStyle), chrono.getCalendarType(), + CalendarDataUtility.findRegionOverride(locale)); return pattern; } diff --git a/src/java.base/share/classes/java/time/format/DateTimeTextProvider.java b/src/java.base/share/classes/java/time/format/DateTimeTextProvider.java index d3fa2161f2b..1db9edb4275 100644 --- a/src/java.base/share/classes/java/time/format/DateTimeTextProvider.java +++ b/src/java.base/share/classes/java/time/format/DateTimeTextProvider.java @@ -510,7 +510,8 @@ class DateTimeTextProvider { @SuppressWarnings("unchecked") static T getLocalizedResource(String key, Locale locale) { LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() - .getLocaleResources(locale); + .getLocaleResources( + CalendarDataUtility.findRegionOverride(locale)); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey(key) ? (T) rb.getObject(key) : null; } diff --git a/src/java.base/share/classes/java/time/format/DecimalStyle.java b/src/java.base/share/classes/java/time/format/DecimalStyle.java index 197e47d96b8..73f3cb23160 100644 --- a/src/java.base/share/classes/java/time/format/DecimalStyle.java +++ b/src/java.base/share/classes/java/time/format/DecimalStyle.java @@ -147,6 +147,11 @@ public final class DecimalStyle { * Obtains the DecimalStyle for the specified locale. *

    * This method provides access to locale sensitive decimal style symbols. + * If the locale contains "nu" (Numbering System) and/or "rg" + * (Region Override) + * Unicode extensions, returned instance will reflect the values specified with + * those extensions. If both "nu" and "rg" are specified, the value from + * the "nu" extension supersedes the implicit one from the "rg" extension. * * @param locale the locale, not null * @return the decimal style, not null diff --git a/src/java.base/share/classes/java/time/temporal/ChronoField.java b/src/java.base/share/classes/java/time/temporal/ChronoField.java index f124b114fa7..f1ef04ee07d 100644 --- a/src/java.base/share/classes/java/time/temporal/ChronoField.java +++ b/src/java.base/share/classes/java/time/temporal/ChronoField.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, 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 @@ -79,6 +79,7 @@ import java.time.chrono.Chronology; import java.util.Locale; import java.util.Objects; import java.util.ResourceBundle; +import sun.util.locale.provider.CalendarDataUtility; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleResources; @@ -632,7 +633,9 @@ public enum ChronoField implements TemporalField { } LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() - .getLocaleResources(locale); + .getLocaleResources( + CalendarDataUtility + .findRegionOverride(locale)); ResourceBundle rb = lr.getJavaTimeFormatData(); String key = "field." + displayNameKey; return rb.containsKey(key) ? rb.getString(key) : name; diff --git a/src/java.base/share/classes/java/time/temporal/IsoFields.java b/src/java.base/share/classes/java/time/temporal/IsoFields.java index 0b910830126..1294bb1e8be 100644 --- a/src/java.base/share/classes/java/time/temporal/IsoFields.java +++ b/src/java.base/share/classes/java/time/temporal/IsoFields.java @@ -81,6 +81,7 @@ import java.util.Map; import java.util.Objects; import java.util.ResourceBundle; +import sun.util.locale.provider.CalendarDataUtility; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleResources; @@ -430,7 +431,9 @@ public final class IsoFields { public String getDisplayName(Locale locale) { Objects.requireNonNull(locale, "locale"); LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() - .getLocaleResources(locale); + .getLocaleResources( + CalendarDataUtility + .findRegionOverride(locale)); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : toString(); } diff --git a/src/java.base/share/classes/java/time/temporal/WeekFields.java b/src/java.base/share/classes/java/time/temporal/WeekFields.java index 0046bef9b68..b7a473f3b59 100644 --- a/src/java.base/share/classes/java/time/temporal/WeekFields.java +++ b/src/java.base/share/classes/java/time/temporal/WeekFields.java @@ -286,13 +286,17 @@ public final class WeekFields implements Serializable { * Obtains an instance of {@code WeekFields} appropriate for a locale. *

    * This will look up appropriate values from the provider of localization data. + * If the locale contains "fw" (First day of week) and/or "rg" + * (Region Override) + * Unicode extensions, returned instance will reflect the values specified with + * those extensions. If both "fw" and "rg" are specified, the value from + * the "fw" extension supersedes the implicit one from the "rg" extension. * * @param locale the locale to use, not null * @return the week-definition, not null */ public static WeekFields of(Locale locale) { Objects.requireNonNull(locale, "locale"); - locale = new Locale(locale.getLanguage(), locale.getCountry()); // elminate variants int calDow = CalendarDataUtility.retrieveFirstDayOfWeek(locale); DayOfWeek dow = DayOfWeek.SUNDAY.plus(calDow - 1); @@ -1041,7 +1045,8 @@ public final class WeekFields implements Serializable { Objects.requireNonNull(locale, "locale"); if (rangeUnit == YEARS) { // only have values for week-of-year LocaleResources lr = LocaleProviderAdapter.getResourceBundleBased() - .getLocaleResources(locale); + .getLocaleResources( + CalendarDataUtility.findRegionOverride(locale)); ResourceBundle rb = lr.getJavaTimeFormatData(); return rb.containsKey("field.week") ? rb.getString("field.week") : name; } diff --git a/src/java.base/share/classes/java/util/Calendar.java b/src/java.base/share/classes/java/util/Calendar.java index d3731291c82..3debbb62cd2 100644 --- a/src/java.base/share/classes/java/util/Calendar.java +++ b/src/java.base/share/classes/java/util/Calendar.java @@ -58,6 +58,7 @@ import sun.util.BuddhistCalendar; import sun.util.calendar.ZoneInfo; import sun.util.locale.provider.CalendarDataUtility; import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.TimeZoneNameUtility; import sun.util.spi.CalendarProvider; /** @@ -128,9 +129,14 @@ import sun.util.spi.CalendarProvider; * * Calendar defines a locale-specific seven day week using two * parameters: the first day of the week and the minimal days in first week - * (from 1 to 7). These numbers are taken from the locale resource data when a - * Calendar is constructed. They may also be specified explicitly - * through the methods for setting their values. + * (from 1 to 7). These numbers are taken from the locale resource data or the + * locale itself when a {@code Calendar} is constructed. If the designated + * locale contains "fw" and/or "rg" + * Unicode extensions, the first day of the week will be obtained according to + * those extensions. If both "fw" and "rg" are specified, the value from the "fw" + * extension supersedes the implicit one from the "rg" extension. + * They may also be specified explicitly through the methods for setting their + * values. * *

    When setting or getting the WEEK_OF_MONTH or * WEEK_OF_YEAR fields, Calendar must determine the @@ -1444,6 +1450,11 @@ public abstract class Calendar implements Serializable, Cloneable, ComparableThe default values are used for locale and time zone if these * parameters haven't been given explicitly. + *

    + * If the locale contains the time zone with "tz" + * Unicode extension, + * and time zone hasn't been given explicitly, time zone in the locale + * is used. * *

    Any out of range field values are either normalized in lenient * mode or detected as an invalid value in non-lenient mode. @@ -1463,7 +1474,7 @@ public abstract class Calendar implements Serializable, Cloneable, ComparableCalendar returned is based on the current time * in the default time zone with the default * {@link Locale.Category#FORMAT FORMAT} locale. + *

    + * If the locale contains the time zone with "tz" + * Unicode extension, + * that time zone is used instead. * * @return a Calendar. */ public static Calendar getInstance() { - return createCalendar(TimeZone.getDefault(), Locale.getDefault(Locale.Category.FORMAT)); + Locale aLocale = Locale.getDefault(Locale.Category.FORMAT); + return createCalendar(defaultTimeZone(aLocale), aLocale); } /** @@ -1631,13 +1647,17 @@ public abstract class Calendar implements Serializable, Cloneable, ComparableCalendar returned is based on the current time * in the default time zone with the given locale. + *

    + * If the locale contains the time zone with "tz" + * Unicode extension, + * that time zone is used instead. * * @param aLocale the locale for the week data * @return a Calendar. */ public static Calendar getInstance(Locale aLocale) { - return createCalendar(TimeZone.getDefault(), aLocale); + return createCalendar(defaultTimeZone(aLocale), aLocale); } /** @@ -1655,6 +1675,16 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable + * If the specified {@code locale} contains "cu" and/or "rg" + * Unicode extensions, + * the instance returned from this method reflects + * the values specified with those extensions. If both "cu" and "rg" are + * specified, the currency from the "cu" extension supersedes the implicit one + * from the "rg" extension. + *

    * The method returns null for territories that don't * have a currency, such as Antarctica. * @@ -361,12 +368,19 @@ public final class Currency implements Serializable { * is not a supported ISO 3166 country code. */ public static Currency getInstance(Locale locale) { - String country = locale.getCountry(); - if (country == null) { - throw new NullPointerException(); + // check for locale overrides + String override = locale.getUnicodeLocaleType("cu"); + if (override != null) { + try { + return getInstance(override.toUpperCase(Locale.ROOT)); + } catch (IllegalArgumentException iae) { + // override currency is invalid. Fall through. + } } - if (country.length() != 2) { + String country = CalendarDataUtility.findRegionOverride(locale).getCountry(); + + if (country == null || !country.matches("^[a-zA-Z]{2}$")) { throw new IllegalArgumentException(); } @@ -482,6 +496,12 @@ public final class Currency implements Serializable { * locale is the US, while for other locales it may be "US$". If no * symbol can be determined, the ISO 4217 currency code is returned. *

    + * If the default {@link Locale.Category#DISPLAY DISPLAY} locale + * contains "rg" (region override) + * Unicode extension, + * the symbol returned from this method reflects + * the value specified with that extension. + *

    * This is equivalent to calling * {@link #getSymbol(Locale) * getSymbol(Locale.getDefault(Locale.Category.DISPLAY))}. @@ -498,6 +518,11 @@ public final class Currency implements Serializable { * For example, for the US Dollar, the symbol is "$" if the specified * locale is the US, while for other locales it may be "US$". If no * symbol can be determined, the ISO 4217 currency code is returned. + *

    + * If the specified {@code locale} contains "rg" (region override) + * Unicode extension, + * the symbol returned from this method reflects + * the value specified with that extension. * * @param locale the locale for which a display name for this currency is * needed @@ -507,6 +532,7 @@ public final class Currency implements Serializable { public String getSymbol(Locale locale) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CurrencyNameProvider.class); + locale = CalendarDataUtility.findRegionOverride(locale); String symbol = pool.getLocalizedObject( CurrencyNameGetter.INSTANCE, locale, currencyCode, SYMBOL); diff --git a/src/java.base/share/classes/java/util/Locale.java b/src/java.base/share/classes/java/util/Locale.java index 3bca8916052..d22183874d7 100644 --- a/src/java.base/share/classes/java/util/Locale.java +++ b/src/java.base/share/classes/java/util/Locale.java @@ -48,6 +48,7 @@ import java.io.Serializable; import java.text.MessageFormat; import java.util.concurrent.ConcurrentHashMap; import java.util.spi.LocaleNameProvider; +import java.util.stream.Collectors; import sun.security.action.GetPropertyAction; import sun.util.locale.BaseLocale; @@ -62,6 +63,7 @@ import sun.util.locale.ParseStatus; import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleResources; import sun.util.locale.provider.LocaleServiceProviderPool; +import sun.util.locale.provider.TimeZoneNameUtility; /** * A Locale object represents a specific geographical, political, @@ -665,10 +667,12 @@ public final class Locale implements Cloneable, Serializable { /** * Display types for retrieving localized names from the name providers. */ - private static final int DISPLAY_LANGUAGE = 0; - private static final int DISPLAY_COUNTRY = 1; - private static final int DISPLAY_VARIANT = 2; - private static final int DISPLAY_SCRIPT = 3; + private static final int DISPLAY_LANGUAGE = 0; + private static final int DISPLAY_COUNTRY = 1; + private static final int DISPLAY_VARIANT = 2; + private static final int DISPLAY_SCRIPT = 3; + private static final int DISPLAY_UEXT_KEY = 4; + private static final int DISPLAY_UEXT_TYPE = 5; /** * Private constructor used by getInstance method @@ -942,11 +946,14 @@ public final class Locale implements Cloneable, Serializable { variant = props.getProperty("user.variant", ""); } - return getInstance(language, script, country, variant, null); + return getInstance(language, script, country, variant, + getDefaultExtensions(props.getProperty("user.extensions", "")) + .orElse(null)); } private static Locale initDefault(Locale.Category category) { Properties props = GetPropertyAction.privilegedGetProperties(); + return getInstance( props.getProperty(category.languageKey, defaultLocale.getLanguage()), @@ -956,7 +963,22 @@ public final class Locale implements Cloneable, Serializable { defaultLocale.getCountry()), props.getProperty(category.variantKey, defaultLocale.getVariant()), - null); + getDefaultExtensions(props.getProperty(category.extensionsKey, "")) + .orElse(defaultLocale.getLocaleExtensions())); + } + + private static Optional getDefaultExtensions(String extensionsProp) { + LocaleExtensions exts = null; + + try { + exts = new InternalLocaleBuilder() + .setExtensions(extensionsProp) + .getLocaleExtensions(); + } catch (LocaleSyntaxException e) { + // just ignore this incorrect property + } + + return Optional.ofNullable(exts); } /** @@ -1771,7 +1793,7 @@ public final class Locale implements Cloneable, Serializable { * @exception NullPointerException if inLocale is null */ public String getDisplayLanguage(Locale inLocale) { - return getDisplayString(baseLocale.getLanguage(), inLocale, DISPLAY_LANGUAGE); + return getDisplayString(baseLocale.getLanguage(), null, inLocale, DISPLAY_LANGUAGE); } /** @@ -1801,7 +1823,7 @@ public final class Locale implements Cloneable, Serializable { * @since 1.7 */ public String getDisplayScript(Locale inLocale) { - return getDisplayString(baseLocale.getScript(), inLocale, DISPLAY_SCRIPT); + return getDisplayString(baseLocale.getScript(), null, inLocale, DISPLAY_SCRIPT); } /** @@ -1844,29 +1866,24 @@ public final class Locale implements Cloneable, Serializable { * @exception NullPointerException if inLocale is null */ public String getDisplayCountry(Locale inLocale) { - return getDisplayString(baseLocale.getRegion(), inLocale, DISPLAY_COUNTRY); + return getDisplayString(baseLocale.getRegion(), null, inLocale, DISPLAY_COUNTRY); } - private String getDisplayString(String code, Locale inLocale, int type) { - if (code.length() == 0) { - return ""; - } + private String getDisplayString(String code, String cat, Locale inLocale, int type) { + Objects.requireNonNull(inLocale); + Objects.requireNonNull(code); - if (inLocale == null) { - throw new NullPointerException(); + if (code.isEmpty()) { + return ""; } LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(LocaleNameProvider.class); - String key = (type == DISPLAY_VARIANT ? "%%"+code : code); + String rbKey = (type == DISPLAY_VARIANT ? "%%"+code : code); String result = pool.getLocalizedObject( LocaleNameGetter.INSTANCE, - inLocale, key, type, code); - if (result != null) { - return result; - } - - return code; + inLocale, rbKey, type, code, cat); + return result != null ? result : code; } /** @@ -1894,29 +1911,31 @@ public final class Locale implements Cloneable, Serializable { if (baseLocale.getVariant().length() == 0) return ""; - LocaleResources lr = LocaleProviderAdapter.forJRE().getLocaleResources(inLocale); + LocaleResources lr = LocaleProviderAdapter + .getResourceBundleBased() + .getLocaleResources(inLocale); String names[] = getDisplayVariantArray(inLocale); // Get the localized patterns for formatting a list, and use // them to format the list. return formatList(names, - lr.getLocaleName("ListPattern"), lr.getLocaleName("ListCompositionPattern")); } /** * Returns a name for the locale that is appropriate for display to the * user. This will be the values returned by getDisplayLanguage(), - * getDisplayScript(), getDisplayCountry(), and getDisplayVariant() assembled - * into a single string. The non-empty values are used in order, - * with the second and subsequent names in parentheses. For example: + * getDisplayScript(), getDisplayCountry(), getDisplayVariant() and + * optional Unicode extensions + * assembled into a single string. The non-empty values are used in order, with + * the second and subsequent names in parentheses. For example: *

    - * language (script, country, variant)
    - * language (country)
    - * language (variant)
    - * script (country)
    - * country
    + * language (script, country, variant(, extension)*)
    + * language (country(, extension)*)
    + * language (variant(, extension)*)
    + * script (country(, extension)*)
    + * country (extension)*
    *
    * depending on which fields are specified in the locale. If the * language, script, country, and variant fields are all empty, @@ -1931,16 +1950,17 @@ public final class Locale implements Cloneable, Serializable { /** * Returns a name for the locale that is appropriate for display * to the user. This will be the values returned by - * getDisplayLanguage(), getDisplayScript(),getDisplayCountry(), - * and getDisplayVariant() assembled into a single string. - * The non-empty values are used in order, - * with the second and subsequent names in parentheses. For example: + * getDisplayLanguage(), getDisplayScript(),getDisplayCountry() + * getDisplayVariant(), and optional + * Unicode extensions assembled into a single string. The non-empty + * values are used in order, with the second and subsequent names in + * parentheses. For example: *
    - * language (script, country, variant)
    - * language (country)
    - * language (variant)
    - * script (country)
    - * country
    + * language (script, country, variant(, extension)*)
    + * language (country(, extension)*)
    + * language (variant(, extension)*)
    + * script (country(, extension)*)
    + * country (extension)*
    *
    * depending on which fields are specified in the locale. If the * language, script, country, and variant fields are all empty, @@ -1951,7 +1971,9 @@ public final class Locale implements Cloneable, Serializable { * @throws NullPointerException if inLocale is null */ public String getDisplayName(Locale inLocale) { - LocaleResources lr = LocaleProviderAdapter.forJRE().getLocaleResources(inLocale); + LocaleResources lr = LocaleProviderAdapter + .getResourceBundleBased() + .getLocaleResources(inLocale); String languageName = getDisplayLanguage(inLocale); String scriptName = getDisplayScript(inLocale); @@ -1960,7 +1982,6 @@ public final class Locale implements Cloneable, Serializable { // Get the localized patterns for formatting a display name. String displayNamePattern = lr.getLocaleName("DisplayNamePattern"); - String listPattern = lr.getLocaleName("ListPattern"); String listCompositionPattern = lr.getLocaleName("ListCompositionPattern"); // The display name consists of a main name, followed by qualifiers. @@ -1977,7 +1998,7 @@ public final class Locale implements Cloneable, Serializable { if (variantNames.length == 0) { return ""; } else { - return formatList(variantNames, listPattern, listCompositionPattern); + return formatList(variantNames, listCompositionPattern); } } ArrayList names = new ArrayList<>(4); @@ -1994,6 +2015,16 @@ public final class Locale implements Cloneable, Serializable { names.addAll(Arrays.asList(variantNames)); } + // add Unicode extensions + if (localeExtensions != null) { + localeExtensions.getUnicodeLocaleAttributes().stream() + .map(key -> getDisplayString(key, null, inLocale, DISPLAY_UEXT_KEY)) + .forEach(names::add); + localeExtensions.getUnicodeLocaleKeys().stream() + .map(key -> getDisplayKeyTypeExtensionString(key, lr, inLocale)) + .forEach(names::add); + } + // The first one in the main name mainName = names.get(0); @@ -2014,7 +2045,7 @@ public final class Locale implements Cloneable, Serializable { // list case, but this is more efficient, and we want it to be // efficient since all the language-only locales will not have any // qualifiers. - qualifierNames.length != 0 ? formatList(qualifierNames, listPattern, listCompositionPattern) : null + qualifierNames.length != 0 ? formatList(qualifierNames, listCompositionPattern) : null }; if (displayNamePattern != null) { @@ -2121,74 +2152,78 @@ public final class Locale implements Cloneable, Serializable { // For each variant token, lookup the display name. If // not found, use the variant name itself. for (int i=0; i 3) { - MessageFormat format = new MessageFormat(listCompositionPattern); - stringList = composeList(format, stringList); + switch (stringList.length) { + case 0: + return ""; + case 1: + return stringList[0]; + default: + return Arrays.stream(stringList).reduce("", + (s1, s2) -> { + if (s1.equals("")) { + return s2; + } + if (s2.equals("")) { + return s1; + } + return MessageFormat.format(pattern, s1, s2); + }); } - - // Rebuild the argument list with the list length as the first element - Object[] args = new Object[stringList.length + 1]; - System.arraycopy(stringList, 0, args, 1, stringList.length); - args[0] = stringList.length; - - // Format it using the pattern in the resource - MessageFormat format = new MessageFormat(listPattern); - return format.format(args); - } - - /** - * Given a list of strings, return a list shortened to three elements. - * Shorten it by applying the given format to the first two elements - * recursively. - * @param format a format which takes two arguments - * @param list a list of strings - * @return if the list is three elements or shorter, the same list; - * otherwise, a new list of three elements. - */ - private static String[] composeList(MessageFormat format, String[] list) { - if (list.length <= 3) return list; - - // Use the given format to compose the first two elements into one - String[] listItems = { list[0], list[1] }; - String newItem = format.format(listItems); - - // Form a new list one element shorter - String[] newList = new String[list.length-1]; - System.arraycopy(list, 2, newList, 1, newList.length-1); - newList[0] = newItem; - - // Recurse - return composeList(format, newList); } // Duplicate of sun.util.locale.UnicodeLocaleExtension.isKey in order to @@ -2345,9 +2380,10 @@ public final class Locale implements Cloneable, Serializable { Locale locale, String key, Object... params) { - assert params.length == 2; + assert params.length == 3; int type = (Integer)params[0]; String code = (String)params[1]; + String cat = (String)params[2]; switch(type) { case DISPLAY_LANGUAGE: @@ -2358,6 +2394,10 @@ public final class Locale implements Cloneable, Serializable { return localeNameProvider.getDisplayVariant(code, locale); case DISPLAY_SCRIPT: return localeNameProvider.getDisplayScript(code, locale); + case DISPLAY_UEXT_KEY: + return localeNameProvider.getDisplayUnicodeExtensionKey(code, locale); + case DISPLAY_UEXT_TYPE: + return localeNameProvider.getDisplayUnicodeExtensionType(code, cat, locale); default: assert false; // shouldn't happen } @@ -2384,7 +2424,8 @@ public final class Locale implements Cloneable, Serializable { DISPLAY("user.language.display", "user.script.display", "user.country.display", - "user.variant.display"), + "user.variant.display", + "user.extensions.display"), /** * Category used to represent the default locale for @@ -2393,19 +2434,23 @@ public final class Locale implements Cloneable, Serializable { FORMAT("user.language.format", "user.script.format", "user.country.format", - "user.variant.format"); + "user.variant.format", + "user.extensions.format"); - Category(String languageKey, String scriptKey, String countryKey, String variantKey) { + Category(String languageKey, String scriptKey, String countryKey, + String variantKey, String extensionsKey) { this.languageKey = languageKey; this.scriptKey = scriptKey; this.countryKey = countryKey; this.variantKey = variantKey; + this.extensionsKey = extensionsKey; } final String languageKey; final String scriptKey; final String countryKey; final String variantKey; + final String extensionsKey; } /** diff --git a/src/java.base/share/classes/java/util/spi/LocaleNameProvider.java b/src/java.base/share/classes/java/util/spi/LocaleNameProvider.java index 499aa0dac1d..3701ddf84ca 100644 --- a/src/java.base/share/classes/java/util/spi/LocaleNameProvider.java +++ b/src/java.base/share/classes/java/util/spi/LocaleNameProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2011, 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 @@ -26,6 +26,7 @@ package java.util.spi; import java.util.Locale; +import java.util.Objects; /** * An abstract class for service providers that @@ -141,4 +142,54 @@ public abstract class LocaleNameProvider extends LocaleServiceProvider { * @see java.util.Locale#getDisplayVariant(java.util.Locale) */ public abstract String getDisplayVariant(String variant, Locale locale); + + /** + * Returns a localized name for the given + * Unicode extension key, + * and the given locale that is appropriate for display to the user. + * If the name returned cannot be localized according to {@code locale}, + * this method returns null. + * @implSpec the default implementation returns {@code null}. + * @param key the Unicode Extension key, not null. + * @param locale the desired locale, not null. + * @return the name of the given key string for the specified locale, + * or null if it's not available. + * @exception NullPointerException if {@code key} or {@code locale} is null + * @exception IllegalArgumentException if {@code locale} isn't + * one of the locales returned from + * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() + * getAvailableLocales()}. + * @since 10 + */ + public String getDisplayUnicodeExtensionKey(String key, Locale locale) { + Objects.requireNonNull(key); + Objects.requireNonNull(locale); + return null; + } + + /** + * Returns a localized name for the given + * Unicode extension type, + * and the given locale that is appropriate for display to the user. + * If the name returned cannot be localized according to {@code locale}, + * this method returns null. + * @implSpec the default implementation returns {@code null}. + * @param type the Unicode Extension type, not null. + * @param key the Unicode Extension key for this {@code type}, not null. + * @param locale the desired locale, not null. + * @return the name of the given type string for the specified locale, + * or null if it's not available. + * @exception NullPointerException if {@code key}, {@code type} or {@code locale} is null + * @exception IllegalArgumentException if {@code locale} isn't + * one of the locales returned from + * {@link java.util.spi.LocaleServiceProvider#getAvailableLocales() + * getAvailableLocales()}. + * @since 10 + */ + public String getDisplayUnicodeExtensionType(String type, String key, Locale locale) { + Objects.requireNonNull(type); + Objects.requireNonNull(key); + Objects.requireNonNull(locale); + return null; + } } diff --git a/src/java.base/share/classes/sun/launcher/LauncherHelper.java b/src/java.base/share/classes/sun/launcher/LauncherHelper.java index 59a178e6cf7..38f9e3a6784 100644 --- a/src/java.base/share/classes/sun/launcher/LauncherHelper.java +++ b/src/java.base/share/classes/sun/launcher/LauncherHelper.java @@ -268,7 +268,7 @@ public final class LauncherHelper { Locale locale = Locale.getDefault(); ostream.println(LOCALE_SETTINGS); ostream.println(INDENT + "default locale = " + - locale.getDisplayLanguage()); + locale.getDisplayName()); ostream.println(INDENT + "default display locale = " + Locale.getDefault(Category.DISPLAY).getDisplayName()); ostream.println(INDENT + "default format locale = " + diff --git a/src/java.base/share/classes/sun/util/cldr/CLDRCalendarDataProviderImpl.java b/src/java.base/share/classes/sun/util/cldr/CLDRCalendarDataProviderImpl.java new file mode 100644 index 00000000000..212bdc6b6e5 --- /dev/null +++ b/src/java.base/share/classes/sun/util/cldr/CLDRCalendarDataProviderImpl.java @@ -0,0 +1,106 @@ +/* + * 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.util.cldr; + +import static sun.util.locale.provider.LocaleProviderAdapter.Type; + +import java.util.Arrays; +import java.util.Map; +import java.util.Locale; +import java.util.Set; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.LocaleResources; +import sun.util.locale.provider.CalendarDataProviderImpl; +import sun.util.locale.provider.CalendarDataUtility; + +/** + * Concrete implementation of the + * {@link java.util.spi.CalendarDataProvider CalendarDataProvider} class + * for the CLDR LocaleProviderAdapter. + * + * @author Naoto Sato + */ +public class CLDRCalendarDataProviderImpl extends CalendarDataProviderImpl { + + private static Map firstDay = new ConcurrentHashMap<>(); + private static Map minDays = new ConcurrentHashMap<>(); + + public CLDRCalendarDataProviderImpl(Type type, Set langtags) { + super(type, langtags); + } + + @Override + public int getFirstDayOfWeek(Locale locale) { + return findValue(CalendarDataUtility.FIRST_DAY_OF_WEEK, locale); + } + + @Override + public int getMinimalDaysInFirstWeek(Locale locale) { + return findValue(CalendarDataUtility.MINIMAL_DAYS_IN_FIRST_WEEK, locale); + } + + /** + * Finds the requested integer value for the locale. + * Each resource consists of the following: + * + * (n: cc1 cc2 ... ccx;)* + * + * where 'n' is the integer for the following region codes, terminated by + * a ';'. + * + */ + private static int findValue(String key, Locale locale) { + Map map = CalendarDataUtility.FIRST_DAY_OF_WEEK.equals(key) ? + firstDay : minDays; + String region = locale.getCountry(); + + if (region.isEmpty()) { + return 0; + } + + Integer val = map.get(region); + if (val == null) { + String valStr = + LocaleProviderAdapter.forType(Type.CLDR).getLocaleResources(Locale.ROOT) + .getCalendarData(key); + val = retrieveInteger(valStr, region) + .orElse(retrieveInteger(valStr, "001").orElse(0)); + map.putIfAbsent(region, val); + } + + return val; + } + + private static Optional retrieveInteger(String src, String region) { + return Arrays.stream(src.split(";")) + .filter(entry -> entry.contains(region)) + .map(entry -> entry.substring(0, entry.indexOf(":"))) + .findAny() + .map(Integer::parseInt); + } +} diff --git a/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java b/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java index d1a92b8feb6..7bd7454bde1 100644 --- a/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java +++ b/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java @@ -27,6 +27,7 @@ package sun.util.cldr; import java.security.AccessController; import java.security.AccessControlException; +import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.text.spi.BreakIteratorProvider; @@ -37,15 +38,16 @@ import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Objects; +import java.util.Optional; import java.util.ServiceLoader; import java.util.ServiceConfigurationError; import java.util.Set; import java.util.StringTokenizer; import java.util.concurrent.ConcurrentHashMap; +import java.util.spi.CalendarDataProvider; import sun.util.locale.provider.JRELocaleProviderAdapter; -import sun.util.locale.provider.LocaleProviderAdapter; import sun.util.locale.provider.LocaleDataMetaInfo; +import sun.util.locale.provider.LocaleProviderAdapter; /** * LocaleProviderAdapter implementation for the CLDR locale data. @@ -105,6 +107,24 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter { return null; } + @Override + public CalendarDataProvider getCalendarDataProvider() { + if (calendarDataProvider == null) { + CalendarDataProvider provider = AccessController.doPrivileged( + (PrivilegedAction) () -> + new CLDRCalendarDataProviderImpl( + getAdapterType(), + getLanguageTagSet("CalendarData"))); + + synchronized (this) { + if (calendarDataProvider == null) { + calendarDataProvider = provider; + } + } + } + return calendarDataProvider; + } + @Override public CollatorProvider getCollatorProvider() { return null; @@ -123,6 +143,10 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter { @Override protected Set createLanguageTagSet(String category) { + // Assume all categories support the same set as AvailableLocales + // in CLDR adapter. + category = "AvailableLocales"; + // Directly call Base tags, as we know it's in the base module. String supportedLocaleString = baseMetaInfo.availableLanguageTags(category); String nonBaseTags = null; @@ -220,4 +244,11 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter { || langtags.contains(locale.stripExtensions().toLanguageTag()) || langtags.contains(getEquivalentLoc(locale).toLanguageTag()); } + + /** + * Returns the time zone ID from an LDML's short ID + */ + public Optional getTimeZoneID(String shortID) { + return Optional.ofNullable(baseMetaInfo.tzShortIDs().get(shortID)); + } } diff --git a/src/java.base/share/classes/sun/util/locale/provider/CalendarDataProviderImpl.java b/src/java.base/share/classes/sun/util/locale/provider/CalendarDataProviderImpl.java index f8efe5234b3..ea1470b7974 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/CalendarDataProviderImpl.java +++ b/src/java.base/share/classes/sun/util/locale/provider/CalendarDataProviderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -46,14 +46,16 @@ public class CalendarDataProviderImpl extends CalendarDataProvider implements Av @Override public int getFirstDayOfWeek(Locale locale) { - return LocaleProviderAdapter.forType(type).getLocaleResources(locale) + String fw = LocaleProviderAdapter.forType(type).getLocaleResources(locale) .getCalendarData(CalendarDataUtility.FIRST_DAY_OF_WEEK); + return convertToCalendarData(fw); } @Override public int getMinimalDaysInFirstWeek(Locale locale) { - return LocaleProviderAdapter.forType(type).getLocaleResources(locale) + String md = LocaleProviderAdapter.forType(type).getLocaleResources(locale) .getCalendarData(CalendarDataUtility.MINIMAL_DAYS_IN_FIRST_WEEK); + return convertToCalendarData(md); } @Override @@ -65,4 +67,9 @@ public class CalendarDataProviderImpl extends CalendarDataProvider implements Av public Set getAvailableLanguageTags() { return langtags; } + + private int convertToCalendarData(String src) { + int val = Integer.parseInt(src); + return (src.isEmpty() || val <= 0 || val > 7) ? 0 : val; + } } diff --git a/src/java.base/share/classes/sun/util/locale/provider/CalendarDataUtility.java b/src/java.base/share/classes/sun/util/locale/provider/CalendarDataUtility.java index 2d2cc3e9d84..f6ee3d26912 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/CalendarDataUtility.java +++ b/src/java.base/share/classes/sun/util/locale/provider/CalendarDataUtility.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -47,10 +47,34 @@ public class CalendarDataUtility { } public static int retrieveFirstDayOfWeek(Locale locale) { + // Look for the Unicode Extension in the locale parameter + if (locale.hasExtensions()) { + String fw = locale.getUnicodeLocaleType("fw"); + if (fw != null) { + switch (fw.toLowerCase(Locale.ROOT)) { + case "mon": + return MONDAY; + case "tue": + return TUESDAY; + case "wed": + return WEDNESDAY; + case "thu": + return THURSDAY; + case "fri": + return FRIDAY; + case "sat": + return SATURDAY; + case "sun": + return SUNDAY; + } + } + } + LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CalendarDataProvider.class); Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE, - locale, true, FIRST_DAY_OF_WEEK); + findRegionOverride(locale), + true, FIRST_DAY_OF_WEEK); return (value != null && (value >= SUNDAY && value <= SATURDAY)) ? value : SUNDAY; } @@ -58,7 +82,8 @@ public class CalendarDataUtility { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(CalendarDataProvider.class); Integer value = pool.getLocalizedObject(CalendarWeekParameterGetter.INSTANCE, - locale, true, MINIMAL_DAYS_IN_FIRST_WEEK); + findRegionOverride(locale), + true, MINIMAL_DAYS_IN_FIRST_WEEK); return (value != null && (value >= 1 && value <= 7)) ? value : 1; } @@ -102,6 +127,32 @@ public class CalendarDataUtility { return map; } + /** + * Utility to look for a region override extension. + * If no region override is found, returns the original locale. + */ + public static Locale findRegionOverride(Locale l) { + String rg = l.getUnicodeLocaleType("rg"); + Locale override = l; + + if (rg != null && rg.length() == 6) { + // UN M.49 code should not be allowed here + // cannot use regex here, as it could be a recursive call + rg = rg.toUpperCase(Locale.ROOT); + if (rg.charAt(0) >= 0x0041 && + rg.charAt(0) <= 0x005A && + rg.charAt(1) >= 0x0041 && + rg.charAt(1) <= 0x005A && + rg.substring(2).equals("ZZZZ")) { + override = new Locale.Builder().setLocale(l) + .setRegion(rg.substring(0, 2)) + .build(); + } + } + + return override; + } + static String normalizeCalendarType(String requestID) { String type; if (requestID.equals("gregorian") || requestID.equals("iso8601")) { @@ -179,7 +230,7 @@ public class CalendarDataUtility { } } - private static class CalendarWeekParameterGetter + private static class CalendarWeekParameterGetter implements LocaleServiceProviderPool.LocalizedObjectGetter { private static final CalendarWeekParameterGetter INSTANCE = diff --git a/src/java.base/share/classes/sun/util/locale/provider/DateFormatProviderImpl.java b/src/java.base/share/classes/sun/util/locale/provider/DateFormatProviderImpl.java index 87fc11ce05f..f9a8d4c346e 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/DateFormatProviderImpl.java +++ b/src/java.base/share/classes/sun/util/locale/provider/DateFormatProviderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, 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 @@ -32,6 +32,7 @@ import java.util.Calendar; import java.util.Locale; import java.util.MissingResourceException; import java.util.Set; +import java.util.TimeZone; /** * Concrete implementation of the {@link java.text.spi.DateFormatProvider @@ -147,11 +148,14 @@ public class DateFormatProviderImpl extends DateFormatProvider implements Availa throw new NullPointerException(); } - SimpleDateFormat sdf = new SimpleDateFormat("", locale); + // Check for region override + Locale rg = CalendarDataUtility.findRegionOverride(locale); + + SimpleDateFormat sdf = new SimpleDateFormat("", rg); Calendar cal = sdf.getCalendar(); try { String pattern = LocaleProviderAdapter.forType(type) - .getLocaleResources(locale).getDateTimePattern(timeStyle, dateStyle, + .getLocaleResources(rg).getDateTimePattern(timeStyle, dateStyle, cal); sdf.applyPattern(pattern); } catch (MissingResourceException mre) { @@ -159,6 +163,15 @@ public class DateFormatProviderImpl extends DateFormatProvider implements Availa sdf.applyPattern("M/d/yy h:mm a"); } + // Check for timezone override + String tz = locale.getUnicodeLocaleType("tz"); + if (tz != null) { + sdf.setTimeZone( + TimeZoneNameUtility.convertLDMLShortID(tz) + .map(TimeZone::getTimeZone) + .orElseGet(sdf::getTimeZone)); + } + return sdf; } diff --git a/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java b/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java index aca1dfe4e01..de0cd3aa473 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java +++ b/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, 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 @@ -130,7 +130,7 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R private volatile CurrencyNameProvider currencyNameProvider; private volatile LocaleNameProvider localeNameProvider; private volatile TimeZoneNameProvider timeZoneNameProvider; - private volatile CalendarDataProvider calendarDataProvider; + protected volatile CalendarDataProvider calendarDataProvider; private volatile CalendarNameProvider calendarNameProvider; private volatile CalendarProvider calendarProvider; diff --git a/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo.java b/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo.java index 149348f66d0..fa104df60b8 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo.java +++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo.java @@ -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 @@ -25,6 +25,8 @@ package sun.util.locale.provider; +import java.util.Map; + /** * LocaleData meta info SPI * @@ -46,4 +48,13 @@ public interface LocaleDataMetaInfo { * @return concatenated language tags, separated by a space. */ public String availableLanguageTags(String category); + + /** + * Returns a map for short time zone ids in BCP47 Unicode extension and + * the long time zone ids. + * @return map of short id to long ids, separated by a space. + */ + default public Map tzShortIDs() { + return null; + } } diff --git a/src/java.base/share/classes/sun/util/locale/provider/LocaleNameProviderImpl.java b/src/java.base/share/classes/sun/util/locale/provider/LocaleNameProviderImpl.java index aa2c18935c2..708eb11fc32 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/LocaleNameProviderImpl.java +++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleNameProviderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -168,6 +168,28 @@ public class LocaleNameProviderImpl extends LocaleNameProvider implements Availa return getDisplayString("%%"+vrnt, locale); } + /** + * @inheritDoc + */ + @Override + public String getDisplayUnicodeExtensionKey(String key, Locale locale) { + super.getDisplayUnicodeExtensionKey(key, locale); // null check + String rbKey = "key." + key; + String name = getDisplayString(rbKey, locale); + return rbKey.equals(name) ? key : name; + } + + /** + * @inheritDoc + */ + @Override + public String getDisplayUnicodeExtensionType(String extType, String key, Locale locale) { + super.getDisplayUnicodeExtensionType(extType, key, locale); // null check + String rbKey = "type." + key + "." + extType; + String name = getDisplayString(rbKey, locale); + return rbKey.equals(name) ? extType : name; + } + private String getDisplayString(String key, Locale locale) { if (key == null || locale == null) { throw new NullPointerException(); diff --git a/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java b/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java index a6f3bc53bb0..533eb315992 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java +++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, 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 @@ -122,23 +122,21 @@ public class LocaleResources { return (byte[]) localeData.getBreakIteratorResources(locale).getObject(key); } - int getCalendarData(String key) { - Integer caldata; + public String getCalendarData(String key) { + String caldata = ""; String cacheKey = CALENDAR_DATA + key; removeEmptyReferences(); ResourceReference data = cache.get(cacheKey); - if (data == null || ((caldata = (Integer) data.get()) == null)) { + if (data == null || ((caldata = (String) data.get()) == null)) { ResourceBundle rb = localeData.getCalendarData(locale); if (rb.containsKey(key)) { - caldata = Integer.parseInt(rb.getString(key)); - } else { - caldata = 0; + caldata = rb.getString(key); } cache.put(cacheKey, - new ResourceReference(cacheKey, (Object) caldata, referenceQueue)); + new ResourceReference(cacheKey, caldata, referenceQueue)); } return caldata; diff --git a/src/java.base/share/classes/sun/util/locale/provider/NumberFormatProviderImpl.java b/src/java.base/share/classes/sun/util/locale/provider/NumberFormatProviderImpl.java index f1edd5843a7..c2f6e593338 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/NumberFormatProviderImpl.java +++ b/src/java.base/share/classes/sun/util/locale/provider/NumberFormatProviderImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, 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 @@ -173,9 +173,14 @@ public class NumberFormatProviderImpl extends NumberFormatProvider implements Av throw new NullPointerException(); } + // Check for region override + Locale override = locale.getUnicodeLocaleType("nu") == null ? + CalendarDataUtility.findRegionOverride(locale) : + locale; + LocaleProviderAdapter adapter = LocaleProviderAdapter.forType(type); - String[] numberPatterns = adapter.getLocaleResources(locale).getNumberPatterns(); - DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(locale); + String[] numberPatterns = adapter.getLocaleResources(override).getNumberPatterns(); + DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(override); int entry = (choice == INTEGERSTYLE) ? NUMBERSTYLE : choice; DecimalFormat format = new DecimalFormat(numberPatterns[entry], symbols); diff --git a/src/java.base/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java b/src/java.base/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java index 4066fcdabfd..82dbee0230e 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java +++ b/src/java.base/share/classes/sun/util/locale/provider/SPILocaleProviderAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, 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 @@ -160,28 +160,24 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { @Override public BreakIterator getWordInstance(Locale locale) { BreakIteratorProvider bip = getImpl(locale); - assert bip != null; return bip.getWordInstance(locale); } @Override public BreakIterator getLineInstance(Locale locale) { BreakIteratorProvider bip = getImpl(locale); - assert bip != null; return bip.getLineInstance(locale); } @Override public BreakIterator getCharacterInstance(Locale locale) { BreakIteratorProvider bip = getImpl(locale); - assert bip != null; return bip.getCharacterInstance(locale); } @Override public BreakIterator getSentenceInstance(Locale locale) { BreakIteratorProvider bip = getImpl(locale); - assert bip != null; return bip.getSentenceInstance(locale); } @@ -215,7 +211,6 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { @Override public Collator getInstance(Locale locale) { CollatorProvider cp = getImpl(locale); - assert cp != null; return cp.getInstance(locale); } } @@ -249,21 +244,18 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { @Override public DateFormat getTimeInstance(int style, Locale locale) { DateFormatProvider dfp = getImpl(locale); - assert dfp != null; return dfp.getTimeInstance(style, locale); } @Override public DateFormat getDateInstance(int style, Locale locale) { DateFormatProvider dfp = getImpl(locale); - assert dfp != null; return dfp.getDateInstance(style, locale); } @Override public DateFormat getDateTimeInstance(int dateStyle, int timeStyle, Locale locale) { DateFormatProvider dfp = getImpl(locale); - assert dfp != null; return dfp.getDateTimeInstance(dateStyle, timeStyle, locale); } } @@ -297,7 +289,6 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { @Override public DateFormatSymbols getInstance(Locale locale) { DateFormatSymbolsProvider dfsp = getImpl(locale); - assert dfsp != null; return dfsp.getInstance(locale); } } @@ -331,7 +322,6 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { @Override public DecimalFormatSymbols getInstance(Locale locale) { DecimalFormatSymbolsProvider dfsp = getImpl(locale); - assert dfsp != null; return dfsp.getInstance(locale); } } @@ -365,28 +355,24 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { @Override public NumberFormat getCurrencyInstance(Locale locale) { NumberFormatProvider nfp = getImpl(locale); - assert nfp != null; return nfp.getCurrencyInstance(locale); } @Override public NumberFormat getIntegerInstance(Locale locale) { NumberFormatProvider nfp = getImpl(locale); - assert nfp != null; return nfp.getIntegerInstance(locale); } @Override public NumberFormat getNumberInstance(Locale locale) { NumberFormatProvider nfp = getImpl(locale); - assert nfp != null; return nfp.getNumberInstance(locale); } @Override public NumberFormat getPercentInstance(Locale locale) { NumberFormatProvider nfp = getImpl(locale); - assert nfp != null; return nfp.getPercentInstance(locale); } } @@ -420,14 +406,12 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { @Override public int getFirstDayOfWeek(Locale locale) { CalendarDataProvider cdp = getImpl(locale); - assert cdp != null; return cdp.getFirstDayOfWeek(locale); } @Override public int getMinimalDaysInFirstWeek(Locale locale) { CalendarDataProvider cdp = getImpl(locale); - assert cdp != null; return cdp.getMinimalDaysInFirstWeek(locale); } } @@ -463,7 +447,6 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { int field, int value, int style, Locale locale) { CalendarNameProvider cdp = getImpl(locale); - assert cdp != null; return cdp.getDisplayName(calendarType, field, value, style, locale); } @@ -472,7 +455,6 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { int field, int style, Locale locale) { CalendarNameProvider cdp = getImpl(locale); - assert cdp != null; return cdp.getDisplayNames(calendarType, field, style, locale); } } @@ -506,14 +488,12 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { @Override public String getSymbol(String currencyCode, Locale locale) { CurrencyNameProvider cnp = getImpl(locale); - assert cnp != null; return cnp.getSymbol(currencyCode, locale); } @Override public String getDisplayName(String currencyCode, Locale locale) { CurrencyNameProvider cnp = getImpl(locale); - assert cnp != null; return cnp.getDisplayName(currencyCode, locale); } } @@ -547,30 +527,38 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { @Override public String getDisplayLanguage(String languageCode, Locale locale) { LocaleNameProvider lnp = getImpl(locale); - assert lnp != null; return lnp.getDisplayLanguage(languageCode, locale); } @Override public String getDisplayScript(String scriptCode, Locale locale) { LocaleNameProvider lnp = getImpl(locale); - assert lnp != null; return lnp.getDisplayScript(scriptCode, locale); } @Override public String getDisplayCountry(String countryCode, Locale locale) { LocaleNameProvider lnp = getImpl(locale); - assert lnp != null; return lnp.getDisplayCountry(countryCode, locale); } @Override public String getDisplayVariant(String variant, Locale locale) { LocaleNameProvider lnp = getImpl(locale); - assert lnp != null; return lnp.getDisplayVariant(variant, locale); } + + @Override + public String getDisplayUnicodeExtensionKey(String key, Locale locale) { + LocaleNameProvider lnp = getImpl(locale); + return lnp.getDisplayUnicodeExtensionKey(key, locale); + } + + @Override + public String getDisplayUnicodeExtensionType(String extType, String key, Locale locale) { + LocaleNameProvider lnp = getImpl(locale); + return lnp.getDisplayUnicodeExtensionType(extType, key, locale); + } } static class TimeZoneNameProviderDelegate extends TimeZoneNameProvider @@ -602,14 +590,12 @@ public class SPILocaleProviderAdapter extends AuxLocaleProviderAdapter { @Override public String getDisplayName(String ID, boolean daylight, int style, Locale locale) { TimeZoneNameProvider tznp = getImpl(locale); - assert tznp != null; return tznp.getDisplayName(ID, daylight, style, locale); } @Override public String getGenericDisplayName(String ID, int style, Locale locale) { TimeZoneNameProvider tznp = getImpl(locale); - assert tznp != null; return tznp.getGenericDisplayName(ID, style, locale); } } diff --git a/src/java.base/share/classes/sun/util/locale/provider/TimeZoneNameUtility.java b/src/java.base/share/classes/sun/util/locale/provider/TimeZoneNameUtility.java index 9fc1502787a..57cfa1b05c6 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/TimeZoneNameUtility.java +++ b/src/java.base/share/classes/sun/util/locale/provider/TimeZoneNameUtility.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 @@ -31,10 +31,13 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.spi.TimeZoneNameProvider; import sun.util.calendar.ZoneInfo; +import sun.util.cldr.CLDRLocaleProviderAdapter; +import static sun.util.locale.provider.LocaleProviderAdapter.Type; /** * Utility class that deals with the localized time zone names @@ -152,6 +155,18 @@ public final class TimeZoneNameUtility { } } + /** + * Converts the time zone id from LDML's 5-letter id to tzdb's id + * + * @param shortID time zone short ID defined in LDML + * @return the tzdb's time zone ID + */ + public static Optional convertLDMLShortID(String shortID) { + return ((CLDRLocaleProviderAdapter)LocaleProviderAdapter.forType(Type.CLDR)) + .getTimeZoneID(shortID) + .map(id -> id.replaceAll("\\s.*", "")); + } + private static String[] retrieveDisplayNamesImpl(String id, Locale locale) { LocaleServiceProviderPool pool = LocaleServiceProviderPool.getPool(TimeZoneNameProvider.class); diff --git a/src/java.base/share/classes/sun/util/resources/LocaleNames.properties b/src/java.base/share/classes/sun/util/resources/LocaleNames.properties index 9b3fdda25d3..459241331f4 100644 --- a/src/java.base/share/classes/sun/util/resources/LocaleNames.properties +++ b/src/java.base/share/classes/sun/util/resources/LocaleNames.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2012, 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 @@ -1164,8 +1164,7 @@ ZW=Zimbabwe # locale name patterns -# rarely localized DisplayNamePattern={0,choice,0#|1#{1}|2#{1} ({2})} -ListPattern={0,choice,0#|1#{1}|2#{1},{2}|3#{1},{2},{3}} +ListKeyTypePattern={0}:{1} ListCompositionPattern={0},{1} diff --git a/src/jdk.localedata/share/classes/sun/util/cldr/resources/common/bcp47/timezone.xml b/src/jdk.localedata/share/classes/sun/util/cldr/resources/common/bcp47/timezone.xml new file mode 100644 index 00000000000..ea7ff1b55f4 --- /dev/null +++ b/src/jdk.localedata/share/classes/sun/util/cldr/resources/common/bcp47/timezone.xml @@ -0,0 +1,470 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/jdk.localedata/share/classes/sun/util/cldr/resources/common/dtd/ldmlBCP47.dtd b/src/jdk.localedata/share/classes/sun/util/cldr/resources/common/dtd/ldmlBCP47.dtd new file mode 100644 index 00000000000..6fdced3efda --- /dev/null +++ b/src/jdk.localedata/share/classes/sun/util/cldr/resources/common/dtd/ldmlBCP47.dtd @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/java/util/Calendar/Bug8185841.java b/test/java/util/Calendar/Bug8185841.java deleted file mode 100644 index bb795512a6e..00000000000 --- a/test/java/util/Calendar/Bug8185841.java +++ /dev/null @@ -1,278 +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. - * - * 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 8185841 - * @summary Test that Region dependent Bundles are added/removed correctly. - * @modules jdk.localedata - */ - - /* -This test is dependent on a particular version of CLDR. - */ -import java.net.URI; -import java.nio.file.FileSystem; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; - -public class Bug8185841 { - // Golden data for Region dependent Bundles in CLDR29. - - private static final Set expectedBundles - = Set.of("CalendarData_af_NA.class", "CalendarData_af_ZA.class", "CalendarData_agq_CM.class", - "CalendarData_ak_GH.class", "CalendarData_am_ET.class", "CalendarData_ar_AE.class", - "CalendarData_ar_BH.class", "CalendarData_ar_DJ.class", "CalendarData_ar_DZ.class", - "CalendarData_ar_EG.class", "CalendarData_ar_EH.class", "CalendarData_ar_ER.class", - "CalendarData_ar_IL.class", "CalendarData_ar_IQ.class", "CalendarData_ar_JO.class", - "CalendarData_ar_KM.class", "CalendarData_ar_KW.class", "CalendarData_ar_LB.class", - "CalendarData_ar_LY.class", "CalendarData_ar_MA.class", "CalendarData_ar_MR.class", - "CalendarData_ar_OM.class", "CalendarData_ar_PS.class", "CalendarData_ar_QA.class", - "CalendarData_ar_SA.class", "CalendarData_ar_SD.class", "CalendarData_ar_SO.class", - "CalendarData_ar_SS.class", "CalendarData_ar_SY.class", "CalendarData_ar_TD.class", - "CalendarData_ar_TN.class", "CalendarData_ar_YE.class", "CalendarData_as_IN.class", - "CalendarData_asa_TZ.class", "CalendarData_ast_ES.class", "CalendarData_az_AZ.class", - "CalendarData_az_Cyrl_AZ.class", "CalendarData_bas_CM.class", "CalendarData_be_BY.class", - "CalendarData_bem_ZM.class", "CalendarData_bez_TZ.class", "CalendarData_bg_BG.class", - "CalendarData_bm_ML.class", "CalendarData_bn_BD.class", "CalendarData_bn_IN.class", - "CalendarData_bo_CN.class", "CalendarData_bo_IN.class", "CalendarData_br_FR.class", - "CalendarData_brx_IN.class", "CalendarData_bs_BA.class", "CalendarData_bs_Cyrl_BA.class", - "CalendarData_ca_AD.class", "CalendarData_ca_ES.class", "CalendarData_ca_FR.class", - "CalendarData_ca_IT.class", "CalendarData_ce_RU.class", "CalendarData_cgg_UG.class", - "CalendarData_chr_US.class", "CalendarData_ckb_IQ.class", "CalendarData_ckb_IR.class", - "CalendarData_cs_CZ.class", "CalendarData_cu_RU.class", "CalendarData_cy_GB.class", - "CalendarData_da_DK.class", "CalendarData_da_GL.class", "CalendarData_dav_KE.class", - "CalendarData_de_AT.class", "CalendarData_de_BE.class", "CalendarData_de_CH.class", - "CalendarData_de_DE.class", "CalendarData_de_LI.class", "CalendarData_de_LU.class", - "CalendarData_dje_NE.class", "CalendarData_dsb_DE.class", "CalendarData_dua_CM.class", - "CalendarData_dyo_SN.class", "CalendarData_dz_BT.class", "CalendarData_ebu_KE.class", - "CalendarData_ee_GH.class", "CalendarData_ee_TG.class", "CalendarData_el_CY.class", - "CalendarData_el_GR.class", "CalendarData_en_AG.class", "CalendarData_en_AI.class", - "CalendarData_en_AS.class", "CalendarData_en_AT.class", "CalendarData_en_AU.class", - "CalendarData_en_BB.class", "CalendarData_en_BE.class", "CalendarData_en_BI.class", - "CalendarData_en_BM.class", "CalendarData_en_BS.class", "CalendarData_en_BW.class", - "CalendarData_en_BZ.class", "CalendarData_en_CA.class", "CalendarData_en_CC.class", - "CalendarData_en_CH.class", "CalendarData_en_CK.class", "CalendarData_en_CM.class", - "CalendarData_en_CX.class", "CalendarData_en_CY.class", "CalendarData_en_DE.class", - "CalendarData_en_DG.class", "CalendarData_en_DK.class", "CalendarData_en_DM.class", - "CalendarData_en_ER.class", "CalendarData_en_FI.class", "CalendarData_en_FJ.class", - "CalendarData_en_FK.class", "CalendarData_en_FM.class", "CalendarData_en_GB.class", - "CalendarData_en_GD.class", "CalendarData_en_GG.class", "CalendarData_en_GH.class", - "CalendarData_en_GI.class", "CalendarData_en_GM.class", "CalendarData_en_GU.class", - "CalendarData_en_GY.class", "CalendarData_en_HK.class", "CalendarData_en_IE.class", - "CalendarData_en_IL.class", "CalendarData_en_IM.class", "CalendarData_en_IN.class", - "CalendarData_en_IO.class", "CalendarData_en_JE.class", "CalendarData_en_JM.class", - "CalendarData_en_KE.class", "CalendarData_en_KI.class", "CalendarData_en_KN.class", - "CalendarData_en_KY.class", "CalendarData_en_LC.class", "CalendarData_en_LR.class", - "CalendarData_en_LS.class", "CalendarData_en_MG.class", "CalendarData_en_MH.class", - "CalendarData_en_MO.class", "CalendarData_en_MP.class", "CalendarData_en_MS.class", - "CalendarData_en_MT.class", "CalendarData_en_MU.class", "CalendarData_en_MW.class", - "CalendarData_en_MY.class", "CalendarData_en_NA.class", "CalendarData_en_NF.class", - "CalendarData_en_NG.class", "CalendarData_en_NL.class", "CalendarData_en_NR.class", - "CalendarData_en_NU.class", "CalendarData_en_NZ.class", "CalendarData_en_PG.class", - "CalendarData_en_PH.class", "CalendarData_en_PK.class", "CalendarData_en_PN.class", - "CalendarData_en_PR.class", "CalendarData_en_PW.class", "CalendarData_en_RW.class", - "CalendarData_en_SB.class", "CalendarData_en_SC.class", "CalendarData_en_SD.class", - "CalendarData_en_SE.class", "CalendarData_en_SG.class", "CalendarData_en_SH.class", - "CalendarData_en_SI.class", "CalendarData_en_SL.class", "CalendarData_en_SS.class", - "CalendarData_en_SX.class", "CalendarData_en_SZ.class", "CalendarData_en_TC.class", - "CalendarData_en_TK.class", "CalendarData_en_TO.class", "CalendarData_en_TT.class", - "CalendarData_en_TV.class", "CalendarData_en_TZ.class", "CalendarData_en_UG.class", - "CalendarData_en_UM.class", "CalendarData_en_VC.class", "CalendarData_en_VG.class", - "CalendarData_en_VI.class", "CalendarData_en_VU.class", "CalendarData_en_WS.class", - "CalendarData_en_ZA.class", "CalendarData_en_ZM.class", "CalendarData_en_ZW.class", - "CalendarData_es_AR.class", "CalendarData_es_BO.class", "CalendarData_es_BR.class", - "CalendarData_es_CL.class", "CalendarData_es_CO.class", "CalendarData_es_CR.class", - "CalendarData_es_CU.class", "CalendarData_es_DO.class", "CalendarData_es_EA.class", - "CalendarData_es_EC.class", "CalendarData_es_ES.class", "CalendarData_es_GQ.class", - "CalendarData_es_GT.class", "CalendarData_es_HN.class", "CalendarData_es_IC.class", - "CalendarData_es_MX.class", "CalendarData_es_NI.class", "CalendarData_es_PA.class", - "CalendarData_es_PE.class", "CalendarData_es_PH.class", "CalendarData_es_PR.class", - "CalendarData_es_PY.class", "CalendarData_es_SV.class", "CalendarData_es_US.class", - "CalendarData_es_UY.class", "CalendarData_es_VE.class", "CalendarData_et_EE.class", - "CalendarData_eu_ES.class", "CalendarData_ewo_CM.class", "CalendarData_fa_AF.class", - "CalendarData_fa_IR.class", "CalendarData_ff_CM.class", "CalendarData_ff_GN.class", - "CalendarData_ff_MR.class", "CalendarData_ff_SN.class", "CalendarData_fi_FI.class", - "CalendarData_fil_PH.class", "CalendarData_fo_DK.class", "CalendarData_fo_FO.class", - "CalendarData_fr_BE.class", "CalendarData_fr_BF.class", "CalendarData_fr_BI.class", - "CalendarData_fr_BJ.class", "CalendarData_fr_BL.class", "CalendarData_fr_CA.class", - "CalendarData_fr_CD.class", "CalendarData_fr_CF.class", "CalendarData_fr_CG.class", - "CalendarData_fr_CH.class", "CalendarData_fr_CI.class", "CalendarData_fr_CM.class", - "CalendarData_fr_DJ.class", "CalendarData_fr_DZ.class", "CalendarData_fr_FR.class", - "CalendarData_fr_GA.class", "CalendarData_fr_GF.class", "CalendarData_fr_GN.class", - "CalendarData_fr_GP.class", "CalendarData_fr_GQ.class", "CalendarData_fr_HT.class", - "CalendarData_fr_KM.class", "CalendarData_fr_LU.class", "CalendarData_fr_MA.class", - "CalendarData_fr_MC.class", "CalendarData_fr_MF.class", "CalendarData_fr_MG.class", - "CalendarData_fr_ML.class", "CalendarData_fr_MQ.class", "CalendarData_fr_MR.class", - "CalendarData_fr_MU.class", "CalendarData_fr_NC.class", "CalendarData_fr_NE.class", - "CalendarData_fr_PF.class", "CalendarData_fr_PM.class", "CalendarData_fr_RE.class", - "CalendarData_fr_RW.class", "CalendarData_fr_SC.class", "CalendarData_fr_SN.class", - "CalendarData_fr_SY.class", "CalendarData_fr_TD.class", "CalendarData_fr_TG.class", - "CalendarData_fr_TN.class", "CalendarData_fr_VU.class", "CalendarData_fr_WF.class", - "CalendarData_fr_YT.class", "CalendarData_fur_IT.class", "CalendarData_fy_NL.class", - "CalendarData_ga_IE.class", "CalendarData_gd_GB.class", "CalendarData_gl_ES.class", - "CalendarData_gsw_CH.class", "CalendarData_gsw_FR.class", "CalendarData_gsw_LI.class", - "CalendarData_gu_IN.class", "CalendarData_guz_KE.class", "CalendarData_gv_IM.class", - "CalendarData_ha_GH.class", "CalendarData_ha_NE.class", "CalendarData_ha_NG.class", - "CalendarData_haw_US.class", "CalendarData_hi_IN.class", "CalendarData_hr_BA.class", - "CalendarData_hr_HR.class", "CalendarData_hsb_DE.class", "CalendarData_hu_HU.class", - "CalendarData_hy_AM.class", "CalendarData_ig_NG.class", "CalendarData_ii_CN.class", - "CalendarData_in_ID.class", "CalendarData_is_IS.class", "CalendarData_it_CH.class", - "CalendarData_it_IT.class", "CalendarData_it_SM.class", "CalendarData_iw_IL.class", - "CalendarData_ja_JP.class", "CalendarData_jgo_CM.class", "CalendarData_jmc_TZ.class", - "CalendarData_ka_GE.class", "CalendarData_kab_DZ.class", "CalendarData_kam_KE.class", - "CalendarData_kde_TZ.class", "CalendarData_kea_CV.class", "CalendarData_khq_ML.class", - "CalendarData_ki_KE.class", "CalendarData_kk_KZ.class", "CalendarData_kkj_CM.class", - "CalendarData_kl_GL.class", "CalendarData_kln_KE.class", "CalendarData_km_KH.class", - "CalendarData_kn_IN.class", "CalendarData_ko_KP.class", "CalendarData_ko_KR.class", - "CalendarData_kok_IN.class", "CalendarData_ks_IN.class", "CalendarData_ksb_TZ.class", - "CalendarData_ksf_CM.class", "CalendarData_ksh_DE.class", "CalendarData_kw_GB.class", - "CalendarData_ky_KG.class", "CalendarData_lag_TZ.class", "CalendarData_lb_LU.class", - "CalendarData_lg_UG.class", "CalendarData_lkt_US.class", "CalendarData_ln_AO.class", - "CalendarData_ln_CD.class", "CalendarData_ln_CF.class", "CalendarData_ln_CG.class", - "CalendarData_lo_LA.class", "CalendarData_lrc_IQ.class", "CalendarData_lrc_IR.class", - "CalendarData_lt_LT.class", "CalendarData_lu_CD.class", "CalendarData_luo_KE.class", - "CalendarData_luy_KE.class", "CalendarData_lv_LV.class", "CalendarData_mas_KE.class", - "CalendarData_mas_TZ.class", "CalendarData_mer_KE.class", "CalendarData_mfe_MU.class", - "CalendarData_mg_MG.class", "CalendarData_mgh_MZ.class", "CalendarData_mgo_CM.class", - "CalendarData_mk_MK.class", "CalendarData_ml_IN.class", "CalendarData_mn_MN.class", - "CalendarData_mr_IN.class", "CalendarData_ms_BN.class", "CalendarData_ms_MY.class", - "CalendarData_ms_SG.class", "CalendarData_mt_MT.class", "CalendarData_mua_CM.class", - "CalendarData_my_MM.class", "CalendarData_mzn_IR.class", "CalendarData_naq_NA.class", - "CalendarData_nb_NO.class", "CalendarData_nb_SJ.class", "CalendarData_nd_ZW.class", - "CalendarData_ne_IN.class", "CalendarData_ne_NP.class", "CalendarData_nl_AW.class", - "CalendarData_nl_BE.class", "CalendarData_nl_BQ.class", "CalendarData_nl_CW.class", - "CalendarData_nl_NL.class", "CalendarData_nl_SR.class", "CalendarData_nl_SX.class", - "CalendarData_nmg_CM.class", "CalendarData_nnh_CM.class", "CalendarData_nus_SS.class", - "CalendarData_nyn_UG.class", "CalendarData_om_ET.class", "CalendarData_om_KE.class", - "CalendarData_or_IN.class", "CalendarData_os_GE.class", "CalendarData_os_RU.class", - "CalendarData_pa_Arab_PK.class", "CalendarData_pa_IN.class", "CalendarData_pa_PK.class", - "CalendarData_pl_PL.class", "CalendarData_ps_AF.class", "CalendarData_pt_AO.class", - "CalendarData_pt_BR.class", "CalendarData_pt_CV.class", "CalendarData_pt_GQ.class", - "CalendarData_pt_GW.class", "CalendarData_pt_MO.class", "CalendarData_pt_MZ.class", - "CalendarData_pt_PT.class", "CalendarData_pt_ST.class", "CalendarData_pt_TL.class", - "CalendarData_qu_BO.class", "CalendarData_qu_EC.class", "CalendarData_qu_PE.class", - "CalendarData_rm_CH.class", "CalendarData_rn_BI.class", "CalendarData_ro_MD.class", - "CalendarData_ro_RO.class", "CalendarData_rof_TZ.class", "CalendarData_ru_BY.class", - "CalendarData_ru_KG.class", "CalendarData_ru_KZ.class", "CalendarData_ru_MD.class", - "CalendarData_ru_RU.class", "CalendarData_ru_UA.class", "CalendarData_rw_RW.class", - "CalendarData_rwk_TZ.class", "CalendarData_sah_RU.class", "CalendarData_saq_KE.class", - "CalendarData_sbp_TZ.class", "CalendarData_se_FI.class", "CalendarData_se_NO.class", - "CalendarData_se_SE.class", "CalendarData_seh_MZ.class", "CalendarData_ses_ML.class", - "CalendarData_sg_CF.class", "CalendarData_shi_Latn_MA.class", "CalendarData_shi_MA.class", - "CalendarData_si_LK.class", "CalendarData_sk_SK.class", "CalendarData_sl_SI.class", - "CalendarData_smn_FI.class", "CalendarData_sn_ZW.class", "CalendarData_so_DJ.class", - "CalendarData_so_ET.class", "CalendarData_so_KE.class", "CalendarData_so_SO.class", - "CalendarData_sq_AL.class", "CalendarData_sq_MK.class", "CalendarData_sq_XK.class", - "CalendarData_sr_BA.class", "CalendarData_sr_Latn_BA.class", "CalendarData_sr_Latn_ME.class", - "CalendarData_sr_Latn_RS.class", "CalendarData_sr_Latn_XK.class", "CalendarData_sr_ME.class", - "CalendarData_sr_RS.class", "CalendarData_sr_XK.class", "CalendarData_sv_AX.class", - "CalendarData_sv_FI.class", "CalendarData_sv_SE.class", "CalendarData_sw_CD.class", - "CalendarData_sw_KE.class", "CalendarData_sw_TZ.class", "CalendarData_sw_UG.class", - "CalendarData_ta_IN.class", "CalendarData_ta_LK.class", "CalendarData_ta_MY.class", - "CalendarData_ta_SG.class", "CalendarData_te_IN.class", "CalendarData_teo_KE.class", - "CalendarData_teo_UG.class", "CalendarData_th_TH.class", "CalendarData_ti_ER.class", - "CalendarData_ti_ET.class", "CalendarData_tk_TM.class", "CalendarData_to_TO.class", - "CalendarData_tr_CY.class", "CalendarData_tr_TR.class", "CalendarData_twq_NE.class", - "CalendarData_tzm_MA.class", "CalendarData_ug_CN.class", "CalendarData_uk_UA.class", - "CalendarData_ur_IN.class", "CalendarData_ur_PK.class", "CalendarData_uz_AF.class", - "CalendarData_uz_Arab_AF.class", "CalendarData_uz_Cyrl_UZ.class", "CalendarData_uz_UZ.class", - "CalendarData_vai_LR.class", "CalendarData_vai_Latn_LR.class", "CalendarData_vi_VN.class", - "CalendarData_vun_TZ.class", "CalendarData_wae_CH.class", "CalendarData_xog_UG.class", - "CalendarData_yav_CM.class", "CalendarData_yo_BJ.class", "CalendarData_yo_NG.class", - "CalendarData_yue_HK.class", "CalendarData_zgh_MA.class", "CalendarData_zh_CN.class", - "CalendarData_zh_HK.class", "CalendarData_zh_Hant_HK.class", "CalendarData_zh_Hant_TW.class", - "CalendarData_zh_MO.class", "CalendarData_zh_SG.class", "CalendarData_zh_TW.class", "CalendarData_zu_ZA.class"); - - private static Set removedBundles = Set.of( - "CalendarData_az_Latn_AZ.class", "CalendarData_bs_Latn_BA.class", - "CalendarData_pa_Guru_IN.class", "CalendarData_shi_Tfng_MA.class", - "CalendarData_sr_Cyrl_BA.class", "CalendarData_sr_Cyrl_ME.class", - "CalendarData_sr_Cyrl_RS.class", "CalendarData_sr_Cyrl_XK.class", - "CalendarData_uz_Latn_UZ.class", "CalendarData_vai_Vaii_LR.class", - "CalendarData_zh_Hans_CN.class", "CalendarData_zh_Hans_HK.class", - "CalendarData_zh_Hans_MO.class", "CalendarData_zh_Hans_SG.class"); - - private static Set addedBundles = Set.of( - "CalendarData_az_AZ.class", "CalendarData_bs_BA.class", - "CalendarData_pa_IN.class", "CalendarData_pa_PK.class", - "CalendarData_shi_MA.class", "CalendarData_sr_BA.class", - "CalendarData_sr_ME.class", "CalendarData_sr_RS.class", - "CalendarData_sr_XK.class", "CalendarData_uz_UZ.class", - "CalendarData_uz_AF.class", "CalendarData_vai_LR.class", - "CalendarData_zh_CN.class", "CalendarData_zh_HK.class", - "CalendarData_zh_MO.class", "CalendarData_zh_SG.class", "CalendarData_zh_TW.class"); - - private static Set retrievedBundles = Collections.EMPTY_SET; - - public static void main(String[] args) throws Exception { - FileSystem fs = FileSystems.newFileSystem(URI.create("jrt:/"), - Collections.emptyMap()); - Path path = fs.getPath("/", "modules", "jdk.localedata", "sun/util/resources/cldr/ext"); - retrievedBundles = Files.walk(path) - .map(p -> p.getFileName().toString()) - .filter(p -> p.startsWith("CalendarData_")) - .collect(Collectors.toSet()); - if (!retrievedBundles.equals(expectedBundles)) { - checkAddedBundles(); - checkRemovedBundles(); - Set retrievedBundlesSet = new HashSet<>(retrievedBundles); - retrievedBundlesSet.removeAll(expectedBundles); - throw new RuntimeException("Unexpected " - + " bundles " + retrievedBundlesSet + " are present in jdk.localedata module "); - - } - } - - /** - * This method checks that bundles which have been additionally generated - * are present in jdk.localedata module. - */ - private static void checkAddedBundles() { - Set addedBundlesSet = new HashSet<>(addedBundles); - addedBundlesSet.removeAll(retrievedBundles); - if (!addedBundlesSet.isEmpty()) { - throw new RuntimeException("expected CalendarData" - + " bundles " + addedBundlesSet + " are not present in jdk.localedata module "); - } - - } - - /** - * This method checks that bundles which have been removed are not present - * in jdk.localedata module. - */ - private static void checkRemovedBundles() { - Set unexpectedBundles = removedBundles.stream(). - filter(retrievedBundles::contains).collect(Collectors.toSet()); - if (!unexpectedBundles.isEmpty()) { - throw new RuntimeException("Unexpected CalendarData" - + " bundles " + unexpectedBundles + " are present in jdk.localedata module "); - } - } -} diff --git a/test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java b/test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java new file mode 100644 index 00000000000..18768c8f01e --- /dev/null +++ b/test/jdk/java/time/test/java/time/format/TestUnicodeExtension.java @@ -0,0 +1,852 @@ +/* + * 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 8176841 + * @summary Tests java.time classes deals with Unicode extensions + * correctly. + * @modules jdk.localedata + */ +package test.java.time.format; + +import static org.testng.Assert.assertEquals; + +import java.time.DayOfWeek; +import java.time.ZonedDateTime; +import java.time.ZoneId; +import java.time.chrono.Chronology; +import java.time.chrono.HijrahChronology; +import java.time.chrono.IsoChronology; +import java.time.chrono.JapaneseChronology; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.format.FormatStyle; +import java.time.temporal.ChronoField; +import java.time.temporal.TemporalField; +import java.time.temporal.WeekFields; +import java.util.Locale; +import java.util.TimeZone; + +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test JavaTime with BCP47 U extensions + */ +@Test +public class TestUnicodeExtension { + private static TimeZone defaultTZ; + + private static final Chronology JAPANESE = JapaneseChronology.INSTANCE; + private static final Chronology HIJRAH = HijrahChronology.INSTANCE; + + private static final ZoneId ASIATOKYO = ZoneId.of("Asia/Tokyo"); + private static final ZoneId AMLA = ZoneId.of("America/Los_Angeles"); + + private static final Locale JPTYO = Locale.forLanguageTag("en-u-tz-jptyo"); + private static final Locale JCAL = Locale.forLanguageTag("en-u-ca-japanese"); + private static final Locale HCAL = Locale.forLanguageTag("en-u-ca-islamic-umalqura"); + + private static final Locale FW_SUN = Locale.forLanguageTag("en-US-u-fw-sun"); + private static final Locale FW_MON = Locale.forLanguageTag("en-US-u-fw-mon"); + private static final Locale FW_TUE = Locale.forLanguageTag("en-US-u-fw-tue"); + private static final Locale FW_WED = Locale.forLanguageTag("en-US-u-fw-wed"); + private static final Locale FW_THU = Locale.forLanguageTag("en-US-u-fw-thu"); + private static final Locale FW_FRI = Locale.forLanguageTag("en-US-u-fw-fri"); + private static final Locale FW_SAT = Locale.forLanguageTag("en-US-u-fw-sat"); + + private static final Locale RG_GB = Locale.forLanguageTag("en-US-u-rg-gbzzzz"); + + private static final ZonedDateTime ZDT = ZonedDateTime.of(2017, 8, 10, 15, 15, 0, 0, AMLA); + + private static final String PATTERN = "GGGG MMMM-dd-uu HH:mm:ss zzzz"; + + @BeforeTest + public void beforeTest() { + defaultTZ = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone(AMLA)); + } + + @AfterTest + public void afterTest() { + TimeZone.setDefault(defaultTZ); + } + + @DataProvider(name="localizedBy") + Object[][] localizedBy() { + return new Object[][] { + // Locale, Chrono override, Zone override, Expected Chrono, Expected Zone, + // Expected formatted string + {Locale.JAPAN, null, null, null, null, + "2017\u5e748\u670810\u65e5\u6728\u66dc\u65e5 15\u664215\u520600\u79d2 \u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u590f\u6642\u9593" + }, + {Locale.JAPAN, JAPANESE, null, JAPANESE, null, + "\u5e73\u621029\u5e748\u670810\u65e5\u6728\u66dc\u65e5 15\u664215\u520600\u79d2 \u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u590f\u6642\u9593" + }, + {Locale.JAPAN, JAPANESE, ASIATOKYO, JAPANESE, ASIATOKYO, + "\u5e73\u621029\u5e748\u670811\u65e5\u91d1\u66dc\u65e5 7\u664215\u520600\u79d2 \u65e5\u672c\u6a19\u6e96\u6642" + }, + + {JCAL, null, null, JAPANESE, null, + "Thursday, August 10, 29 Heisei at 3:15:00 PM Pacific Daylight Time" + }, + {JCAL, HIJRAH, null, JAPANESE, null, + "Thursday, August 10, 29 Heisei at 3:15:00 PM Pacific Daylight Time" + }, + {HCAL, JAPANESE, null, HIJRAH, null, + "Thursday, Dhu\u02bbl-Qi\u02bbdah 18, 1438 AH at 3:15:00 PM Pacific Daylight Time" + }, + + + {JPTYO, null, null, null, ASIATOKYO, + "Friday, August 11, 2017 at 7:15:00 AM Japan Standard Time" + }, + {JPTYO, null, AMLA, null, ASIATOKYO, + "Friday, August 11, 2017 at 7:15:00 AM Japan Standard Time" + }, + // invalid tz + {Locale.forLanguageTag("en-US-u-tz-jpzzz"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + {Locale.forLanguageTag("en-US-u-tz-jpzzz"), null, AMLA, null, AMLA, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + + {RG_GB, null, null, null, null, + "Thursday, 10 August 2017 at 15:15:00 Pacific Daylight Time" + }, + + // DecimalStyle + {Locale.forLanguageTag("en-US-u-nu-thai"), null, null, null, null, + "Thursday, August \u0e51\u0e50, \u0e52\u0e50\u0e51\u0e57 at \u0e53:\u0e51\u0e55:\u0e50\u0e50 PM Pacific Daylight Time" + }, + // DecimalStyle, "nu" vs "rg" + {Locale.forLanguageTag("en-US-u-nu-thai-rg-uszzzz"), null, null, null, null, + "Thursday, August \u0e51\u0e50, \u0e52\u0e50\u0e51\u0e57 at \u0e53:\u0e51\u0e55:\u0e50\u0e50 PM Pacific Daylight Time" + }, + // DecimalStyle, invalid + {Locale.forLanguageTag("en-US-u-nu-foo"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + }; + } + + @DataProvider(name="withLocale") + Object[][] withLocale() { + return new Object[][] { + // Locale, Chrono override, Zone override, Expected Chrono, Expected Zone, + // Expected formatted string + {Locale.JAPAN, null, null, null, null, + "2017\u5e748\u670810\u65e5\u6728\u66dc\u65e5 15\u664215\u520600\u79d2 \u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u590f\u6642\u9593" + }, + {Locale.JAPAN, JAPANESE, null, JAPANESE, null, + "\u5e73\u621029\u5e748\u670810\u65e5\u6728\u66dc\u65e5 15\u664215\u520600\u79d2 \u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u590f\u6642\u9593" + }, + {Locale.JAPAN, JAPANESE, ASIATOKYO, JAPANESE, ASIATOKYO, + "\u5e73\u621029\u5e748\u670811\u65e5\u91d1\u66dc\u65e5 7\u664215\u520600\u79d2 \u65e5\u672c\u6a19\u6e96\u6642" + }, + + {JCAL, null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + {JCAL, HIJRAH, null, HIJRAH, null, + "Thursday, Dhu\u02bbl-Qi\u02bbdah 18, 1438 AH at 3:15:00 PM Pacific Daylight Time" + }, + {HCAL, JAPANESE, null, JAPANESE, null, + "Thursday, August 10, 29 Heisei at 3:15:00 PM Pacific Daylight Time" + }, + + + {JPTYO, null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + {JPTYO, null, AMLA, null, AMLA, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + // invalid tz + {Locale.forLanguageTag("en-US-u-tz-jpzzz"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + {Locale.forLanguageTag("en-US-u-tz-jpzzz"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + + {RG_GB, null, null, null, null, + "Thursday, 10 August 2017 at 15:15:00 Pacific Daylight Time" + }, + + // DecimalStyle + {Locale.forLanguageTag("en-US-u-nu-thai"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + // DecimalStyle, "nu" vs "rg" + {Locale.forLanguageTag("en-US-u-nu-thai-rg-uszzzz"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + // DecimalStyle, invalid + {Locale.forLanguageTag("en-US-u-nu-foo"), null, null, null, null, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + }; + } + + @DataProvider(name="firstDayOfWeek") + Object[][] firstDayOfWeek () { + return new Object[][] { + // Locale, Expected DayOfWeek, + {Locale.US, DayOfWeek.SUNDAY}, + {FW_SUN, DayOfWeek.SUNDAY}, + {FW_MON, DayOfWeek.MONDAY}, + {FW_TUE, DayOfWeek.TUESDAY}, + {FW_WED, DayOfWeek.WEDNESDAY}, + {FW_THU, DayOfWeek.THURSDAY}, + {FW_FRI, DayOfWeek.FRIDAY}, + {FW_SAT, DayOfWeek.SATURDAY}, + + // invalid case + {Locale.forLanguageTag("en-US-u-fw-xxx"), DayOfWeek.SUNDAY}, + + // region override + {RG_GB, DayOfWeek.MONDAY}, + {Locale.forLanguageTag("zh-CN-u-rg-eszzzz"), DayOfWeek.MONDAY}, + + // "fw" and "rg". + {Locale.forLanguageTag("en-US-u-fw-wed-rg-gbzzzz"), DayOfWeek.WEDNESDAY}, + {Locale.forLanguageTag("en-US-u-fw-xxx-rg-gbzzzz"), DayOfWeek.MONDAY}, + {Locale.forLanguageTag("en-US-u-fw-xxx-rg-zzzz"), DayOfWeek.SUNDAY}, + }; + } + + @DataProvider(name="minDaysInFirstWeek") + Object[][] minDaysInFrstWeek () { + return new Object[][] { + // Locale, Expected minDay, + {Locale.US, 1}, + + // region override + {RG_GB, 4}, + {Locale.forLanguageTag("zh-CN-u-rg-eszzzz"), 4}, + }; + } + + @DataProvider(name="ofPattern") + Object[][] ofPattern() { + return new Object[][] { + // Locale, Expected Chrono, Expected Zone, + // Expected formatted string + {JCAL, null, null, + "Anno Domini August-10-17 15:15:00 Pacific Daylight Time" + }, + {HCAL, null, null, + "Anno Domini August-10-17 15:15:00 Pacific Daylight Time" + }, + + {JPTYO, null, null, + "Anno Domini August-10-17 15:15:00 Pacific Daylight Time" + }, + {Locale.forLanguageTag("en-US-u-tz-jpzzz"), null, null, + "Anno Domini August-10-17 15:15:00 Pacific Daylight Time" + }, + + {RG_GB, null, null, + "Anno Domini August-10-17 15:15:00 Pacific Daylight Time" + }, + + }; + } + + @DataProvider(name="shortTZID") + Object[][] shortTZID() { + return new Object[][] { + // LDML's short ID, Expected Zone, + {"adalv", "Europe/Andorra"}, + {"aedxb", "Asia/Dubai"}, + {"afkbl", "Asia/Kabul"}, + {"aganu", "America/Antigua"}, + {"aiaxa", "America/Anguilla"}, + {"altia", "Europe/Tirane"}, + {"amevn", "Asia/Yerevan"}, + {"ancur", "America/Curacao"}, + {"aolad", "Africa/Luanda"}, + {"aqcas", "Antarctica/Casey"}, + {"aqdav", "Antarctica/Davis"}, + {"aqddu", "Antarctica/DumontDUrville"}, + {"aqmaw", "Antarctica/Mawson"}, + {"aqmcm", "Antarctica/McMurdo"}, + {"aqplm", "Antarctica/Palmer"}, + {"aqrot", "Antarctica/Rothera"}, + {"aqsyw", "Antarctica/Syowa"}, + {"aqtrl", "Antarctica/Troll"}, + {"aqvos", "Antarctica/Vostok"}, + {"arbue", "America/Buenos_Aires"}, + {"arcor", "America/Cordoba"}, + {"arctc", "America/Catamarca"}, + {"arirj", "America/Argentina/La_Rioja"}, + {"arjuj", "America/Jujuy"}, + {"arluq", "America/Argentina/San_Luis"}, + {"armdz", "America/Mendoza"}, + {"arrgl", "America/Argentina/Rio_Gallegos"}, + {"arsla", "America/Argentina/Salta"}, + {"artuc", "America/Argentina/Tucuman"}, + {"aruaq", "America/Argentina/San_Juan"}, + {"arush", "America/Argentina/Ushuaia"}, + {"asppg", "Pacific/Pago_Pago"}, + {"atvie", "Europe/Vienna"}, + {"auadl", "Australia/Adelaide"}, + {"aubhq", "Australia/Broken_Hill"}, + {"aubne", "Australia/Brisbane"}, + {"audrw", "Australia/Darwin"}, + {"aueuc", "Australia/Eucla"}, + {"auhba", "Australia/Hobart"}, + {"aukns", "Australia/Currie"}, + {"auldc", "Australia/Lindeman"}, + {"auldh", "Australia/Lord_Howe"}, + {"aumel", "Australia/Melbourne"}, + {"aumqi", "Antarctica/Macquarie"}, + {"auper", "Australia/Perth"}, + {"ausyd", "Australia/Sydney"}, + {"awaua", "America/Aruba"}, + {"azbak", "Asia/Baku"}, + {"basjj", "Europe/Sarajevo"}, + {"bbbgi", "America/Barbados"}, + {"bddac", "Asia/Dhaka"}, + {"bebru", "Europe/Brussels"}, + {"bfoua", "Africa/Ouagadougou"}, + {"bgsof", "Europe/Sofia"}, + {"bhbah", "Asia/Bahrain"}, + {"bibjm", "Africa/Bujumbura"}, + {"bjptn", "Africa/Porto-Novo"}, + {"bmbda", "Atlantic/Bermuda"}, + {"bnbwn", "Asia/Brunei"}, + {"bolpb", "America/La_Paz"}, + {"bqkra", "America/Kralendijk"}, + {"braux", "America/Araguaina"}, + {"brbel", "America/Belem"}, + {"brbvb", "America/Boa_Vista"}, + {"brcgb", "America/Cuiaba"}, + {"brcgr", "America/Campo_Grande"}, + {"brern", "America/Eirunepe"}, + {"brfen", "America/Noronha"}, + {"brfor", "America/Fortaleza"}, + {"brmao", "America/Manaus"}, + {"brmcz", "America/Maceio"}, + {"brpvh", "America/Porto_Velho"}, + {"brrbr", "America/Rio_Branco"}, + {"brrec", "America/Recife"}, + {"brsao", "America/Sao_Paulo"}, + {"brssa", "America/Bahia"}, + {"brstm", "America/Santarem"}, + {"bsnas", "America/Nassau"}, + {"btthi", "Asia/Thimphu"}, + {"bwgbe", "Africa/Gaborone"}, + {"bymsq", "Europe/Minsk"}, + {"bzbze", "America/Belize"}, + {"cacfq", "America/Creston"}, + {"caedm", "America/Edmonton"}, + {"caffs", "America/Rainy_River"}, + {"cafne", "America/Fort_Nelson"}, + {"caglb", "America/Glace_Bay"}, + {"cagoo", "America/Goose_Bay"}, + {"cahal", "America/Halifax"}, + {"caiql", "America/Iqaluit"}, + {"camon", "America/Moncton"}, + {"capnt", "America/Pangnirtung"}, + {"careb", "America/Resolute"}, + {"careg", "America/Regina"}, + {"casjf", "America/St_Johns"}, + {"canpg", "America/Nipigon"}, + {"cathu", "America/Thunder_Bay"}, + {"cator", "America/Toronto"}, + {"cavan", "America/Vancouver"}, + {"cawnp", "America/Winnipeg"}, + {"caybx", "America/Blanc-Sablon"}, + {"caycb", "America/Cambridge_Bay"}, + {"cayda", "America/Dawson"}, + {"caydq", "America/Dawson_Creek"}, + {"cayek", "America/Rankin_Inlet"}, + {"cayev", "America/Inuvik"}, + {"cayxy", "America/Whitehorse"}, + {"cayyn", "America/Swift_Current"}, + {"cayzf", "America/Yellowknife"}, + {"cayzs", "America/Coral_Harbour"}, + {"cccck", "Indian/Cocos"}, + {"cdfbm", "Africa/Lubumbashi"}, + {"cdfih", "Africa/Kinshasa"}, + {"cfbgf", "Africa/Bangui"}, + {"cgbzv", "Africa/Brazzaville"}, + {"chzrh", "Europe/Zurich"}, + {"ciabj", "Africa/Abidjan"}, + {"ckrar", "Pacific/Rarotonga"}, + {"clipc", "Pacific/Easter"}, + {"clscl", "America/Santiago"}, + {"cmdla", "Africa/Douala"}, + {"cnsha", "Asia/Shanghai"}, + {"cnurc", "Asia/Urumqi"}, + {"cobog", "America/Bogota"}, + {"crsjo", "America/Costa_Rica"}, + {"cst6cdt", "CST6CDT"}, + {"cuhav", "America/Havana"}, + {"cvrai", "Atlantic/Cape_Verde"}, + {"cxxch", "Indian/Christmas"}, + {"cynic", "Asia/Nicosia"}, + {"czprg", "Europe/Prague"}, + {"deber", "Europe/Berlin"}, + {"debsngn", "Europe/Busingen"}, + {"djjib", "Africa/Djibouti"}, + {"dkcph", "Europe/Copenhagen"}, + {"dmdom", "America/Dominica"}, + {"dosdq", "America/Santo_Domingo"}, + {"dzalg", "Africa/Algiers"}, + {"ecgps", "Pacific/Galapagos"}, + {"ecgye", "America/Guayaquil"}, + {"eetll", "Europe/Tallinn"}, + {"egcai", "Africa/Cairo"}, + {"eheai", "Africa/El_Aaiun"}, + {"erasm", "Africa/Asmera"}, + {"esceu", "Africa/Ceuta"}, + {"eslpa", "Atlantic/Canary"}, + {"esmad", "Europe/Madrid"}, + {"est5edt", "EST5EDT"}, + {"etadd", "Africa/Addis_Ababa"}, + {"fihel", "Europe/Helsinki"}, + {"fimhq", "Europe/Mariehamn"}, + {"fjsuv", "Pacific/Fiji"}, + {"fkpsy", "Atlantic/Stanley"}, + {"fmksa", "Pacific/Kosrae"}, + {"fmpni", "Pacific/Ponape"}, + {"fmtkk", "Pacific/Truk"}, + {"fotho", "Atlantic/Faeroe"}, + {"frpar", "Europe/Paris"}, + {"galbv", "Africa/Libreville"}, + {"gaza", "Asia/Gaza"}, + {"gblon", "Europe/London"}, + {"gdgnd", "America/Grenada"}, + {"getbs", "Asia/Tbilisi"}, + {"gfcay", "America/Cayenne"}, + {"gggci", "Europe/Guernsey"}, + {"ghacc", "Africa/Accra"}, + {"gigib", "Europe/Gibraltar"}, + {"gldkshvn", "America/Danmarkshavn"}, + {"glgoh", "America/Godthab"}, + {"globy", "America/Scoresbysund"}, + {"glthu", "America/Thule"}, + {"gmbjl", "Africa/Banjul"}, + {"gncky", "Africa/Conakry"}, + {"gpbbr", "America/Guadeloupe"}, + {"gpmsb", "America/Marigot"}, + {"gpsbh", "America/St_Barthelemy"}, + {"gqssg", "Africa/Malabo"}, + {"grath", "Europe/Athens"}, + {"gsgrv", "Atlantic/South_Georgia"}, + {"gtgua", "America/Guatemala"}, + {"gugum", "Pacific/Guam"}, + {"gwoxb", "Africa/Bissau"}, + {"gygeo", "America/Guyana"}, + {"hebron", "Asia/Hebron"}, + {"hkhkg", "Asia/Hong_Kong"}, + {"hntgu", "America/Tegucigalpa"}, + {"hrzag", "Europe/Zagreb"}, + {"htpap", "America/Port-au-Prince"}, + {"hubud", "Europe/Budapest"}, + {"iddjj", "Asia/Jayapura"}, + {"idjkt", "Asia/Jakarta"}, + {"idmak", "Asia/Makassar"}, + {"idpnk", "Asia/Pontianak"}, + {"iedub", "Europe/Dublin"}, + {"imdgs", "Europe/Isle_of_Man"}, + {"inccu", "Asia/Calcutta"}, + {"iodga", "Indian/Chagos"}, + {"iqbgw", "Asia/Baghdad"}, + {"irthr", "Asia/Tehran"}, + {"isrey", "Atlantic/Reykjavik"}, + {"itrom", "Europe/Rome"}, + {"jeruslm", "Asia/Jerusalem"}, + {"jesth", "Europe/Jersey"}, + {"jmkin", "America/Jamaica"}, + {"joamm", "Asia/Amman"}, + {"jptyo", "Asia/Tokyo"}, + {"kenbo", "Africa/Nairobi"}, + {"kgfru", "Asia/Bishkek"}, + {"khpnh", "Asia/Phnom_Penh"}, + {"kicxi", "Pacific/Kiritimati"}, + {"kipho", "Pacific/Enderbury"}, + {"kitrw", "Pacific/Tarawa"}, + {"kmyva", "Indian/Comoro"}, + {"knbas", "America/St_Kitts"}, + {"kpfnj", "Asia/Pyongyang"}, + {"krsel", "Asia/Seoul"}, + {"kwkwi", "Asia/Kuwait"}, + {"kygec", "America/Cayman"}, + {"kzaau", "Asia/Aqtau"}, + {"kzakx", "Asia/Aqtobe"}, + {"kzala", "Asia/Almaty"}, + {"kzkzo", "Asia/Qyzylorda"}, + {"kzura", "Asia/Oral"}, + {"lavte", "Asia/Vientiane"}, + {"lbbey", "Asia/Beirut"}, + {"lccas", "America/St_Lucia"}, + {"livdz", "Europe/Vaduz"}, + {"lkcmb", "Asia/Colombo"}, + {"lrmlw", "Africa/Monrovia"}, + {"lsmsu", "Africa/Maseru"}, + {"ltvno", "Europe/Vilnius"}, + {"lulux", "Europe/Luxembourg"}, + {"lvrix", "Europe/Riga"}, + {"lytip", "Africa/Tripoli"}, + {"macas", "Africa/Casablanca"}, + {"mcmon", "Europe/Monaco"}, + {"mdkiv", "Europe/Chisinau"}, + {"metgd", "Europe/Podgorica"}, + {"mgtnr", "Indian/Antananarivo"}, + {"mhkwa", "Pacific/Kwajalein"}, + {"mhmaj", "Pacific/Majuro"}, + {"mkskp", "Europe/Skopje"}, + {"mlbko", "Africa/Bamako"}, + {"mmrgn", "Asia/Rangoon"}, + {"mncoq", "Asia/Choibalsan"}, + {"mnhvd", "Asia/Hovd"}, + {"mnuln", "Asia/Ulaanbaatar"}, + {"momfm", "Asia/Macau"}, + {"mpspn", "Pacific/Saipan"}, + {"mqfdf", "America/Martinique"}, + {"mrnkc", "Africa/Nouakchott"}, + {"msmni", "America/Montserrat"}, + {"mst7mdt", "MST7MDT"}, + {"mtmla", "Europe/Malta"}, + {"muplu", "Indian/Mauritius"}, + {"mvmle", "Indian/Maldives"}, + {"mwblz", "Africa/Blantyre"}, + {"mxchi", "America/Chihuahua"}, + {"mxcun", "America/Cancun"}, + {"mxhmo", "America/Hermosillo"}, + {"mxmam", "America/Matamoros"}, + {"mxmex", "America/Mexico_City"}, + {"mxmid", "America/Merida"}, + {"mxmty", "America/Monterrey"}, + {"mxmzt", "America/Mazatlan"}, + {"mxoji", "America/Ojinaga"}, + {"mxpvr", "America/Bahia_Banderas"}, + {"mxstis", "America/Santa_Isabel"}, + {"mxtij", "America/Tijuana"}, + {"mykch", "Asia/Kuching"}, + {"mykul", "Asia/Kuala_Lumpur"}, + {"mzmpm", "Africa/Maputo"}, + {"nawdh", "Africa/Windhoek"}, + {"ncnou", "Pacific/Noumea"}, + {"nenim", "Africa/Niamey"}, + {"nfnlk", "Pacific/Norfolk"}, + {"nglos", "Africa/Lagos"}, + {"nimga", "America/Managua"}, + {"nlams", "Europe/Amsterdam"}, + {"noosl", "Europe/Oslo"}, + {"npktm", "Asia/Katmandu"}, + {"nrinu", "Pacific/Nauru"}, + {"nuiue", "Pacific/Niue"}, + {"nzakl", "Pacific/Auckland"}, + {"nzcht", "Pacific/Chatham"}, + {"ommct", "Asia/Muscat"}, + {"papty", "America/Panama"}, + {"pelim", "America/Lima"}, + {"pfgmr", "Pacific/Gambier"}, + {"pfnhv", "Pacific/Marquesas"}, + {"pfppt", "Pacific/Tahiti"}, + {"pgpom", "Pacific/Port_Moresby"}, + {"pgraw", "Pacific/Bougainville"}, + {"phmnl", "Asia/Manila"}, + {"pkkhi", "Asia/Karachi"}, + {"plwaw", "Europe/Warsaw"}, + {"pmmqc", "America/Miquelon"}, + {"pnpcn", "Pacific/Pitcairn"}, + {"prsju", "America/Puerto_Rico"}, + {"pst8pdt", "PST8PDT"}, + {"ptfnc", "Atlantic/Madeira"}, + {"ptlis", "Europe/Lisbon"}, + {"ptpdl", "Atlantic/Azores"}, + {"pwror", "Pacific/Palau"}, + {"pyasu", "America/Asuncion"}, + {"qadoh", "Asia/Qatar"}, + {"rereu", "Indian/Reunion"}, + {"robuh", "Europe/Bucharest"}, + {"rsbeg", "Europe/Belgrade"}, + {"ruchita", "Asia/Chita"}, + {"rudyr", "Asia/Anadyr"}, + {"rugdx", "Asia/Magadan"}, + {"ruikt", "Asia/Irkutsk"}, + {"rukgd", "Europe/Kaliningrad"}, + {"rukhndg", "Asia/Khandyga"}, + {"rukra", "Asia/Krasnoyarsk"}, + {"rukuf", "Europe/Samara"}, + {"rumow", "Europe/Moscow"}, + {"runoz", "Asia/Novokuznetsk"}, + {"ruoms", "Asia/Omsk"}, + {"ruovb", "Asia/Novosibirsk"}, + {"rupkc", "Asia/Kamchatka"}, + {"rusred", "Asia/Srednekolymsk"}, + {"ruunera", "Asia/Ust-Nera"}, + {"ruuus", "Asia/Sakhalin"}, + {"ruvog", "Europe/Volgograd"}, + {"ruvvo", "Asia/Vladivostok"}, + {"ruyek", "Asia/Yekaterinburg"}, + {"ruyks", "Asia/Yakutsk"}, + {"rwkgl", "Africa/Kigali"}, + {"saruh", "Asia/Riyadh"}, + {"sbhir", "Pacific/Guadalcanal"}, + {"scmaw", "Indian/Mahe"}, + {"sdkrt", "Africa/Khartoum"}, + {"sesto", "Europe/Stockholm"}, + {"sgsin", "Asia/Singapore"}, + {"shshn", "Atlantic/St_Helena"}, + {"silju", "Europe/Ljubljana"}, + {"sjlyr", "Arctic/Longyearbyen"}, + {"skbts", "Europe/Bratislava"}, + {"slfna", "Africa/Freetown"}, + {"smsai", "Europe/San_Marino"}, + {"sndkr", "Africa/Dakar"}, + {"somgq", "Africa/Mogadishu"}, + {"srpbm", "America/Paramaribo"}, + {"ssjub", "Africa/Juba"}, + {"sttms", "Africa/Sao_Tome"}, + {"svsal", "America/El_Salvador"}, + {"sxphi", "America/Lower_Princes"}, + {"sydam", "Asia/Damascus"}, + {"szqmn", "Africa/Mbabane"}, + {"tcgdt", "America/Grand_Turk"}, + {"tdndj", "Africa/Ndjamena"}, + {"tfpfr", "Indian/Kerguelen"}, + {"tglfw", "Africa/Lome"}, + {"thbkk", "Asia/Bangkok"}, + {"tjdyu", "Asia/Dushanbe"}, + {"tkfko", "Pacific/Fakaofo"}, + {"tldil", "Asia/Dili"}, + {"tmasb", "Asia/Ashgabat"}, + {"tntun", "Africa/Tunis"}, + {"totbu", "Pacific/Tongatapu"}, + {"trist", "Europe/Istanbul"}, + {"ttpos", "America/Port_of_Spain"}, + {"tvfun", "Pacific/Funafuti"}, + {"twtpe", "Asia/Taipei"}, + {"tzdar", "Africa/Dar_es_Salaam"}, + {"uaiev", "Europe/Kiev"}, + {"uaozh", "Europe/Zaporozhye"}, + {"uasip", "Europe/Simferopol"}, + {"uauzh", "Europe/Uzhgorod"}, + {"ugkla", "Africa/Kampala"}, + {"umawk", "Pacific/Wake"}, + {"umjon", "Pacific/Johnston"}, + {"ummdy", "Pacific/Midway"}, +// {"unk", "Etc/Unknown"}, + {"usadk", "America/Adak"}, + {"usaeg", "America/Indiana/Marengo"}, + {"usanc", "America/Anchorage"}, + {"usboi", "America/Boise"}, + {"uschi", "America/Chicago"}, + {"usden", "America/Denver"}, + {"usdet", "America/Detroit"}, + {"ushnl", "Pacific/Honolulu"}, + {"usind", "America/Indianapolis"}, + {"usinvev", "America/Indiana/Vevay"}, + {"usjnu", "America/Juneau"}, + {"usknx", "America/Indiana/Knox"}, + {"uslax", "America/Los_Angeles"}, + {"uslui", "America/Louisville"}, + {"usmnm", "America/Menominee"}, + {"usmtm", "America/Metlakatla"}, + {"usmoc", "America/Kentucky/Monticello"}, + {"usndcnt", "America/North_Dakota/Center"}, + {"usndnsl", "America/North_Dakota/New_Salem"}, + {"usnyc", "America/New_York"}, + {"usoea", "America/Indiana/Vincennes"}, + {"usome", "America/Nome"}, + {"usphx", "America/Phoenix"}, + {"ussit", "America/Sitka"}, + {"ustel", "America/Indiana/Tell_City"}, + {"uswlz", "America/Indiana/Winamac"}, + {"uswsq", "America/Indiana/Petersburg"}, + {"usxul", "America/North_Dakota/Beulah"}, + {"usyak", "America/Yakutat"}, + {"utc", "Etc/GMT"}, + {"utce01", "Etc/GMT-1"}, + {"utce02", "Etc/GMT-2"}, + {"utce03", "Etc/GMT-3"}, + {"utce04", "Etc/GMT-4"}, + {"utce05", "Etc/GMT-5"}, + {"utce06", "Etc/GMT-6"}, + {"utce07", "Etc/GMT-7"}, + {"utce08", "Etc/GMT-8"}, + {"utce09", "Etc/GMT-9"}, + {"utce10", "Etc/GMT-10"}, + {"utce11", "Etc/GMT-11"}, + {"utce12", "Etc/GMT-12"}, + {"utce13", "Etc/GMT-13"}, + {"utce14", "Etc/GMT-14"}, + {"utcw01", "Etc/GMT+1"}, + {"utcw02", "Etc/GMT+2"}, + {"utcw03", "Etc/GMT+3"}, + {"utcw04", "Etc/GMT+4"}, + {"utcw05", "Etc/GMT+5"}, + {"utcw06", "Etc/GMT+6"}, + {"utcw07", "Etc/GMT+7"}, + {"utcw08", "Etc/GMT+8"}, + {"utcw09", "Etc/GMT+9"}, + {"utcw10", "Etc/GMT+10"}, + {"utcw11", "Etc/GMT+11"}, + {"utcw12", "Etc/GMT+12"}, + {"uymvd", "America/Montevideo"}, + {"uzskd", "Asia/Samarkand"}, + {"uztas", "Asia/Tashkent"}, + {"vavat", "Europe/Vatican"}, + {"vcsvd", "America/St_Vincent"}, + {"veccs", "America/Caracas"}, + {"vgtov", "America/Tortola"}, + {"vistt", "America/St_Thomas"}, + {"vnsgn", "Asia/Saigon"}, + {"vuvli", "Pacific/Efate"}, + {"wfmau", "Pacific/Wallis"}, + {"wsapw", "Pacific/Apia"}, + {"yeade", "Asia/Aden"}, + {"ytmam", "Indian/Mayotte"}, + {"zajnb", "Africa/Johannesburg"}, + {"zmlun", "Africa/Lusaka"}, + {"zwhre", "Africa/Harare"}, + + }; + } + + @DataProvider(name="getLocalizedDateTimePattern") + Object[][] getLocalizedDateTimePattern() { + return new Object[][] { + // Locale, Expected pattern, + {Locale.US, FormatStyle.FULL, "EEEE, MMMM d, y 'at' h:mm:ss a zzzz"}, + {Locale.US, FormatStyle.LONG, "MMMM d, y 'at' h:mm:ss a z"}, + {Locale.US, FormatStyle.MEDIUM, "MMM d, y, h:mm:ss a"}, + {Locale.US, FormatStyle.SHORT, "M/d/yy, h:mm a"}, + {RG_GB, FormatStyle.FULL, "EEEE, d MMMM y 'at' HH:mm:ss zzzz"}, + {RG_GB, FormatStyle.LONG, "d MMMM y 'at' HH:mm:ss z"}, + {RG_GB, FormatStyle.MEDIUM, "d MMM y, HH:mm:ss"}, + {RG_GB, FormatStyle.SHORT, "dd/MM/y, HH:mm"}, + }; + } + + @DataProvider(name="getDisplayName") + Object[][] getDisplayName() { + return new Object[][] { + // Locale, field, Expected name, + {Locale.US, ChronoField.AMPM_OF_DAY, "AM/PM"}, + {RG_GB, ChronoField.AMPM_OF_DAY, "am/pm"}, + }; + } + + @Test(dataProvider="localizedBy") + public void test_localizedBy(Locale locale, Chronology chrono, ZoneId zone, + Chronology chronoExpected, ZoneId zoneExpected, + String formatExpected) { + DateTimeFormatter dtf = + DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL) + .withChronology(chrono).withZone(zone).localizedBy(locale); + assertEquals(dtf.getChronology(), chronoExpected); + assertEquals(dtf.getZone(), zoneExpected); + String formatted = dtf.format(ZDT); + assertEquals(formatted, formatExpected); + assertEquals(dtf.parse(formatted, ZonedDateTime::from), + zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + } + + @Test(dataProvider="withLocale") + public void test_withLocale(Locale locale, Chronology chrono, ZoneId zone, + Chronology chronoExpected, ZoneId zoneExpected, + String formatExpected) { + DateTimeFormatter dtf = + DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL) + .withChronology(chrono).withZone(zone).withLocale(locale); + assertEquals(dtf.getChronology(), chronoExpected); + assertEquals(dtf.getZone(), zoneExpected); + String formatted = dtf.format(ZDT); + assertEquals(formatted, formatExpected); + assertEquals(dtf.parse(formatted, ZonedDateTime::from), + zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + } + + @Test(dataProvider="firstDayOfWeek") + public void test_firstDayOfWeek(Locale locale, DayOfWeek dowExpected) { + DayOfWeek dow = WeekFields.of(locale).getFirstDayOfWeek(); + assertEquals(dow, dowExpected); + } + + @Test(dataProvider="minDaysInFirstWeek") + public void test_minDaysInFirstWeek(Locale locale, int minDaysExpected) { + int minDays = WeekFields.of(locale).getMinimalDaysInFirstWeek(); + assertEquals(minDays, minDaysExpected); + } + + @Test(dataProvider="ofPattern") + public void test_ofPattern(Locale locale, + Chronology chronoExpected, ZoneId zoneExpected, + String formatExpected) { + DateTimeFormatter dtf = + DateTimeFormatter.ofPattern(PATTERN, locale); + assertEquals(dtf.getChronology(), chronoExpected); + assertEquals(dtf.getZone(), zoneExpected); + String formatted = dtf.format(ZDT); + assertEquals(formatted, formatExpected); + assertEquals(dtf.parse(formatted, ZonedDateTime::from), + zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + } + + @Test(dataProvider="ofPattern") + public void test_toFormatter(Locale locale, + Chronology chronoExpected, ZoneId zoneExpected, + String formatExpected) { + DateTimeFormatter dtf = + new DateTimeFormatterBuilder().appendPattern(PATTERN).toFormatter(locale); + assertEquals(dtf.getChronology(), chronoExpected); + assertEquals(dtf.getZone(), zoneExpected); + String formatted = dtf.format(ZDT); + assertEquals(formatted, formatExpected); + assertEquals(dtf.parse(formatted, ZonedDateTime::from), + zoneExpected != null ? ZDT.withZoneSameInstant(zoneExpected) : ZDT); + } + + @Test(dataProvider="shortTZID") + public void test_shortTZID(String shortID, String expectedZone) { + Locale l = Locale.forLanguageTag("en-US-u-tz-" + shortID); + DateTimeFormatter dtf = + DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL) + .localizedBy(l); + assertEquals(dtf.getZone(), ZoneId.of(expectedZone)); + } + + @Test(dataProvider="getLocalizedDateTimePattern") + public void test_getLocalizedDateTimePattern(Locale l, FormatStyle s, String expectedPattern) { + DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder(); + assertEquals(dtfb.getLocalizedDateTimePattern(s, s, IsoChronology.INSTANCE, l), + expectedPattern); + } + + @Test(dataProvider="getDisplayName") + public void test_getDisplayName(Locale l, TemporalField f, String expectedName) { + assertEquals(f.getDisplayName(l), expectedName); + } +} diff --git a/test/jdk/java/util/Calendar/Bug4302966.java b/test/jdk/java/util/Calendar/Bug4302966.java index 0dce8e2b367..03ed8c4eaac 100644 --- a/test/jdk/java/util/Calendar/Bug4302966.java +++ b/test/jdk/java/util/Calendar/Bug4302966.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 @@ -23,7 +23,7 @@ /* * @test - * @bug 4302966 + * @bug 4302966 8176841 * @modules jdk.localedata * @summary In Czech Republic first day of week is Monday not Sunday */ @@ -34,7 +34,7 @@ import java.util.Locale; public class Bug4302966 { public static void main(String[] args) { - Calendar czechCalendar = Calendar.getInstance(new Locale("cs")); + Calendar czechCalendar = Calendar.getInstance(new Locale("cs", "CZ")); int firstDayOfWeek = czechCalendar.getFirstDayOfWeek(); if (firstDayOfWeek != Calendar.MONDAY) { throw new RuntimeException(); diff --git a/test/jdk/java/util/Calendar/CalendarDataTest.java b/test/jdk/java/util/Calendar/CalendarDataTest.java new file mode 100644 index 00000000000..fbd4b986a45 --- /dev/null +++ b/test/jdk/java/util/Calendar/CalendarDataTest.java @@ -0,0 +1,108 @@ +/* + * 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 8190918 + * @summary Tests for region dependent calendar data, i.e., + * firstDayOfWeek and minimalDaysInFirstWeek. + * @modules jdk.localedata + * @run main CalendarDataTest + */ + +import java.util.Calendar; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import java.util.stream.IntStream; + +public class CalendarDataTest { + + // golden data from CLDR + private static final List> FIRSTDAYDATA = List.of( + List.of("1", "AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT " + + "GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ " + + "NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE " + + "VI WS YE ZA ZW"), + List.of("2", "001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY " + + "CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP " + + "GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ " + + "MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ " + + "VA VN XK"), + List.of("6", "BD MV"), + List.of("7", "AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY")); + + private static final List> MINDAYSDATA = List.of( + List.of("1", "001 GU UM US VI"), + List.of("4", "AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR " + + "GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO " + + "PL PT RE SE SJ SK SM VA")); + + public static void main(String... args) throws Exception { + // world + Calendar cal = Calendar.getInstance(new Locale("", "001")); + checkResult("001", + cal.getFirstDayOfWeek(), + cal.getMinimalDaysInFirstWeek()); + + // two letter country codes + IntStream.range(0x41, 0x5b) + .forEach(c1 -> { + IntStream.range(0x41, 0x5b) + .mapToObj(c2 -> String.valueOf((char)c1) + String.valueOf((char)c2)) + .forEach(region -> { + Calendar c = Calendar.getInstance(new Locale("", region)); + checkResult(region, + c.getFirstDayOfWeek(), + c.getMinimalDaysInFirstWeek()); + }); + }); + } + + private static void checkResult(String region, int firstDay, int minDays) { + // first day of week + int expected = Integer.parseInt(findEntry(region, FIRSTDAYDATA) + .orElse(findEntry("001", FIRSTDAYDATA).orElse(List.of("1"))) + .get(0)); + if (firstDay != expected) { + throw new RuntimeException("firstDayOfWeek is incorrect for the region: " + + region + ". Returned: " + firstDay + ", Expected: " + expected); + } + + // minimal days in first week + expected = Integer.parseInt(findEntry(region, MINDAYSDATA) + .orElse(findEntry("001", MINDAYSDATA).orElse(List.of("1"))) + .get(0)); + if (minDays != expected) { + throw new RuntimeException("minimalDaysInFirstWeek is incorrect for the region: " + + region + ". Returned: " + firstDay + ", Expected: " + expected); + } + } + + private static Optional> findEntry(String region, List> data) { + return data.stream() + .filter(l -> l.get(1).contains(region)) + .findAny(); + } +} + diff --git a/test/jdk/java/util/Locale/bcp47u/CalendarTests.java b/test/jdk/java/util/Locale/bcp47u/CalendarTests.java new file mode 100644 index 00000000000..92cfc6581c5 --- /dev/null +++ b/test/jdk/java/util/Locale/bcp47u/CalendarTests.java @@ -0,0 +1,158 @@ +/* + * 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 8176841 + * @summary Tests Calendar class deals with Unicode extensions + * correctly. + * @modules jdk.localedata + * @run testng/othervm CalendarTests + */ + +import static org.testng.Assert.assertEquals; + +import java.text.DateFormat; +import java.util.Calendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test Calendar with BCP47 U extensions + */ +@Test +public class CalendarTests { + private static TimeZone defaultTZ; + + private static final TimeZone ASIATOKYO = TimeZone.getTimeZone("Asia/Tokyo"); + private static final TimeZone AMLA = TimeZone.getTimeZone("America/Los_Angeles"); + + private static final Locale JPTYO = Locale.forLanguageTag("en-u-tz-jptyo"); + private static final Locale USLAX = Locale.forLanguageTag("en-u-tz-uslax"); + + private static final Locale FW_SUN = Locale.forLanguageTag("en-US-u-fw-sun"); + private static final Locale FW_MON = Locale.forLanguageTag("en-US-u-fw-mon"); + private static final Locale FW_TUE = Locale.forLanguageTag("en-US-u-fw-tue"); + private static final Locale FW_WED = Locale.forLanguageTag("en-US-u-fw-wed"); + private static final Locale FW_THU = Locale.forLanguageTag("en-US-u-fw-thu"); + private static final Locale FW_FRI = Locale.forLanguageTag("en-US-u-fw-fri"); + private static final Locale FW_SAT = Locale.forLanguageTag("en-US-u-fw-sat"); + + @BeforeTest + public void beforeTest() { + defaultTZ = TimeZone.getDefault(); + TimeZone.setDefault(AMLA); + } + + @AfterTest + public void afterTest() { + TimeZone.setDefault(defaultTZ); + } + + @DataProvider(name="tz") + Object[][] tz() { + return new Object[][] { + // Locale, Expected Zone, + {JPTYO, ASIATOKYO}, + {USLAX, AMLA}, + + // invalid + {Locale.forLanguageTag("en-US-u-tz-jpzzz"), AMLA} + }; + } + + @DataProvider(name="firstDayOfWeek") + Object[][] firstDayOfWeek () { + return new Object[][] { + // Locale, Expected DayOfWeek, + {Locale.US, Calendar.SUNDAY}, + {FW_SUN, Calendar.SUNDAY}, + {FW_MON, Calendar.MONDAY}, + {FW_TUE, Calendar.TUESDAY}, + {FW_WED, Calendar.WEDNESDAY}, + {FW_THU, Calendar.THURSDAY}, + {FW_FRI, Calendar.FRIDAY}, + {FW_SAT, Calendar.SATURDAY}, + + // invalid case + {Locale.forLanguageTag("en-US-u-fw-xxx"), Calendar.SUNDAY}, + + // region override + {Locale.forLanguageTag("en-US-u-rg-gbzzzz"), Calendar.MONDAY}, + {Locale.forLanguageTag("zh-CN-u-rg-eszzzz"), Calendar.MONDAY}, + + // "fw" and "rg". + {Locale.forLanguageTag("en-US-u-fw-wed-rg-gbzzzz"), Calendar.WEDNESDAY}, + {Locale.forLanguageTag("en-US-u-fw-xxx-rg-gbzzzz"), Calendar.MONDAY}, + {Locale.forLanguageTag("en-US-u-fw-xxx-rg-zzzz"), Calendar.SUNDAY}, + }; + } + + @DataProvider(name="minDaysInFirstWeek") + Object[][] minDaysInFrstWeek () { + return new Object[][] { + // Locale, Expected minDay, + {Locale.US, 1}, + + // region override + {Locale.forLanguageTag("en-US-u-rg-gbzzzz"), 4}, + {Locale.forLanguageTag("zh-CN-u-rg-eszzzz"), 4}, + }; + } + + @Test(dataProvider="tz") + public void test_tz(Locale locale, TimeZone zoneExpected) { + DateFormat df = DateFormat.getTimeInstance(DateFormat.FULL, locale); + assertEquals(df.getTimeZone(), zoneExpected); + + Calendar c = Calendar.getInstance(locale); + assertEquals(c.getTimeZone(), zoneExpected); + + c = new Calendar.Builder().setLocale(locale).build(); + assertEquals(c.getTimeZone(), zoneExpected); + } + + @Test(dataProvider="firstDayOfWeek") + public void test_firstDayOfWeek(Locale locale, int dowExpected) { + Calendar c = Calendar.getInstance(locale); + assertEquals(c.getFirstDayOfWeek(), dowExpected); + + c = new Calendar.Builder().setLocale(locale).build(); + assertEquals(c.getFirstDayOfWeek(), dowExpected); + } + + @Test(dataProvider="minDaysInFirstWeek") + public void test_minDaysInFirstWeek(Locale locale, int minDaysExpected) { + Calendar c = Calendar.getInstance(locale); + assertEquals(c.getMinimalDaysInFirstWeek(), minDaysExpected); + + c = new Calendar.Builder().setLocale(locale).build(); + assertEquals(c.getMinimalDaysInFirstWeek(), minDaysExpected); + } +} diff --git a/test/jdk/java/util/Locale/bcp47u/CurrencyTests.java b/test/jdk/java/util/Locale/bcp47u/CurrencyTests.java new file mode 100644 index 00000000000..d807a0e4da3 --- /dev/null +++ b/test/jdk/java/util/Locale/bcp47u/CurrencyTests.java @@ -0,0 +1,106 @@ +/* + * 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 8176841 + * @summary Tests Currency class instantiates correctly with Unicode + * extensions + * @modules jdk.localedata + * @run testng/othervm CurrencyTests + */ + +import static org.testng.Assert.assertEquals; + +import java.util.Currency; +import java.util.Locale; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test Currency with BCP47 U extensions + */ +@Test +public class CurrencyTests { + private static final Currency USD = Currency.getInstance("USD"); + private static final Currency CAD = Currency.getInstance("CAD"); + private static final Currency JPY = Currency.getInstance("JPY"); + + @DataProvider(name="getInstanceData") + Object[][] getInstanceData() { + return new Object[][] { + // Locale, Expected Currency + // "cu" + {Locale.forLanguageTag("en-US-u-cu-jpy"), JPY}, + {Locale.forLanguageTag("ja-JP-u-cu-usd"), USD}, + {Locale.forLanguageTag("en-US-u-cu-foobar"), USD}, + {Locale.forLanguageTag("en-US-u-cu-zzz"), USD}, + + // "rg" + {Locale.forLanguageTag("en-US-u-rg-jpzzzz"), JPY}, + {Locale.forLanguageTag("ja-JP-u-rg-uszzzz"), USD}, + {Locale.forLanguageTag("ja-JP-u-rg-001zzzz"), JPY}, + {Locale.forLanguageTag("en-US-u-rg-jpz"), USD}, + + // "cu" and "rg". "cu" should win + {Locale.forLanguageTag("en-CA-u-cu-jpy-rg-uszzzz"), JPY}, + + // invaid "cu" and valid "rg". "rg" should win + {Locale.forLanguageTag("en-CA-u-cu-jpyy-rg-uszzzz"), USD}, + {Locale.forLanguageTag("en-CA-u-cu-zzz-rg-uszzzz"), USD}, + + // invaid "cu" and invalid "rg". both should be ignored + {Locale.forLanguageTag("en-CA-u-cu-jpyy-rg-jpzz"), CAD}, + }; + } + + @DataProvider(name="getSymbolData") + Object[][] getSymbolData() { + return new Object[][] { + // Currency, DisplayLocale, expected Symbol + {USD, Locale.forLanguageTag("en-US-u-rg-jpzzzz"), "$"}, + {USD, Locale.forLanguageTag("en-US-u-rg-cazzzz"), "US$"}, + {USD, Locale.forLanguageTag("en-CA-u-rg-uszzzz"), "$"}, + + {CAD, Locale.forLanguageTag("en-US-u-rg-jpzzzz"), "CA$"}, + {CAD, Locale.forLanguageTag("en-US-u-rg-cazzzz"), "$"}, + {CAD, Locale.forLanguageTag("en-CA-u-rg-uszzzz"), "CA$"}, + + {JPY, Locale.forLanguageTag("ja-JP-u-rg-uszzzz"), "\uffe5"}, + {JPY, Locale.forLanguageTag("en-US-u-rg-jpzzzz"), "\u00a5"}, + {JPY, Locale.forLanguageTag("ko-KR-u-rg-jpzzzz"), "JP\u00a5"}, + }; + } + + @Test(dataProvider="getInstanceData") + public void test_getInstance(Locale locale, Currency currencyExpected) { + assertEquals(Currency.getInstance(locale), currencyExpected); + } + + @Test(dataProvider="getSymbolData") + public void test_getSymbol(Currency c, Locale locale, String expected) { + assertEquals(c.getSymbol(locale), expected); + } +} diff --git a/test/jdk/java/util/Locale/bcp47u/DefaultLocaleTest.java b/test/jdk/java/util/Locale/bcp47u/DefaultLocaleTest.java new file mode 100644 index 00000000000..9e07a64e767 --- /dev/null +++ b/test/jdk/java/util/Locale/bcp47u/DefaultLocaleTest.java @@ -0,0 +1,46 @@ +/* + * 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.util.Locale; + +/* + * Test application that verifies default locales. Invoked from + * SystemPropertyTests + */ +public class DefaultLocaleTest { + public static void main(String... args) { + String defLoc = Locale.getDefault().toString(); + String defFmtLoc = Locale.getDefault(Locale.Category.FORMAT).toString(); + String defDspLoc = Locale.getDefault(Locale.Category.DISPLAY).toString(); + + if (!defLoc.equals(args[0]) || + !defFmtLoc.equals(args[1]) || + !defDspLoc.equals(args[2])) { + System.err.println("Some default locale(s) don't match.\n" + + "Default Locale expected: " + args[0] + ", result: " + defLoc + "\n" + + "Default Format Locale expected: " + args[1] + ", result: " + defFmtLoc + "\n" + + "Default Display Locale expected: " + args[2] + ", result: " + defDspLoc); + System.exit(-1); + } + } +} diff --git a/test/jdk/java/util/Locale/bcp47u/DisplayNameTests.java b/test/jdk/java/util/Locale/bcp47u/DisplayNameTests.java new file mode 100644 index 00000000000..a6b7776ec43 --- /dev/null +++ b/test/jdk/java/util/Locale/bcp47u/DisplayNameTests.java @@ -0,0 +1,109 @@ +/* + * 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 8176841 + * @summary Tests the display names for BCP 47 U extensions + * @modules jdk.localedata + * @run testng/othervm -Djava.locale.providers=CLDR DisplayNameTests + */ + +import static org.testng.Assert.assertEquals; + +import java.util.Locale; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test Locale.getDisplayName() with BCP47 U extensions. Note that the + * result may change depending on the CLDR releases. + */ +@Test +public class DisplayNameTests { + private static final Locale loc1 = Locale.forLanguageTag("en-Latn-US-u" + + "-ca-japanese" + + "-cf-account" + + "-co-pinyin" + + "-cu-jpy" + + "-em-emoji" + + "-fw-wed" + + "-hc-h23" + + "-lb-loose" + + "-lw-breakall" + + "-ms-uksystem" + + "-nu-roman" + + "-rg-gbzzzz" + + "-sd-gbsct" + + "-ss-standard" + + "-tz-jptyo" + + "-va-posix"); + private static final Locale loc2 = new Locale("ja", "JP", "JP"); + private static final Locale loc3 = new Locale.Builder() + .setRegion("US") + .setScript("Latn") + .setUnicodeLocaleKeyword("ca", "japanese") + .build(); + private static final Locale loc4 = new Locale.Builder() + .setRegion("US") + .setUnicodeLocaleKeyword("ca", "japanese") + .build(); + private static final Locale loc5 = new Locale.Builder() + .setUnicodeLocaleKeyword("ca", "japanese") + .build(); + private static final Locale loc6 = Locale.forLanguageTag( "zh-CN-u-ca-dddd-nu-ddd-cu-ddd-fw-moq-tz-unknown-rg-twzz"); + + @DataProvider(name="locales") + Object[][] tz() { + return new Object[][] { + // Locale for display, Test Locale, Expected output, + {Locale.US, loc1, + "English (Latin, United States, Japanese Calendar, Accounting Currency Format, Pinyin Sort Order, Currency: Japanese Yen, Prefer Emoji Presentation For Emoji Characters, First Day of Week Is Wednesday, 24 Hour System (0\u201323), Loose Line Break Style, Allow Line Breaks In All Words, Imperial Measurement System, Roman Numerals, Region For Supplemental Data: United Kingdom, Region Subdivision: gbsct, Suppress Sentence Breaks After Standard Abbreviations, Time Zone: Japan Time, POSIX Compliant Locale)"}, + {Locale.JAPAN, loc1, + "\u82f1\u8a9e (\u30e9\u30c6\u30f3\u6587\u5b57\u3001\u30a2\u30e1\u30ea\u30ab\u5408\u8846\u56fd\u3001\u548c\u66a6\u3001cf: account\u3001\u30d4\u30f3\u30a4\u30f3\u9806\u3001\u901a\u8ca8: \u65e5\u672c\u5186\u3001em: emoji\u3001fw: wed\u300124\u6642\u9593\u5236(0\u301c23)\u3001\u7981\u5247\u51e6\u7406(\u5f31)\u3001lw: breakall\u3001\u30e4\u30fc\u30c9\u30fb\u30dd\u30f3\u30c9\u6cd5\u3001\u30ed\u30fc\u30de\u6570\u5b57\u3001rg: \u30a4\u30ae\u30ea\u30b9\u3001sd: gbsct\u3001ss: standard\u3001\u30bf\u30a4\u30e0\u30be\u30fc\u30f3: \u65e5\u672c\u6642\u9593\u3001\u30ed\u30b1\u30fc\u30eb\u306e\u30d0\u30ea\u30a2\u30f3\u30c8: posix)"}, + {Locale.forLanguageTag("hi-IN"), loc1, + "\u0905\u0902\u0917\u094d\u0930\u0947\u091c\u093c\u0940 (\u0932\u0948\u091f\u093f\u0928, \u0938\u0902\u092f\u0941\u0915\u094d\u0924 \u0930\u093e\u091c\u094d\u092f, \u091c\u093e\u092a\u093e\u0928\u0940 \u092a\u0902\u091a\u093e\u0902\u0917, cf: account, \u092a\u093f\u0928\u092f\u0940\u0928 \u0935\u0930\u094d\u0917\u0940\u0915\u0930\u0923, \u092e\u0941\u0926\u094d\u0930\u093e: \u091c\u093e\u092a\u093e\u0928\u0940 \u092f\u0947\u0928, em: emoji, fw: wed, 24 \u0918\u0902\u091f\u094b\u0902 \u0915\u0940 \u092a\u094d\u0930\u0923\u093e\u0932\u0940 (0\u201323), \u0922\u0940\u0932\u0940 \u092a\u0902\u0915\u094d\u0924\u093f \u0935\u093f\u091a\u094d\u091b\u0947\u0926 \u0936\u0948\u0932\u0940, lw: breakall, \u0907\u092e\u094d\u092a\u0940\u0930\u093f\u092f\u0932 \u092e\u093e\u092a\u0928 \u092a\u094d\u0930\u0923\u093e\u0932\u0940, \u0930\u094b\u092e\u0928 \u0938\u0902\u0916\u094d\u092f\u093e\u090f\u0901, rg: \u092f\u0942\u0928\u093e\u0907\u091f\u0947\u0921 \u0915\u093f\u0902\u0917\u0921\u092e, sd: gbsct, ss: standard, \u0938\u092e\u092f \u0915\u094d\u0937\u0947\u0924\u094d\u0930: \u091c\u093e\u092a\u093e\u0928 \u0938\u092e\u092f, \u0938\u094d\u0925\u093e\u0928\u0940\u092f \u092a\u094d\u0930\u0915\u093e\u0930: posix)"}, + + // cases where no localized types are available. fall back to "key: type" + {Locale.US, Locale.forLanguageTag("en-u-ca-unknown"), "English (Calendar: unknown)"}, + + // cases with variant, w/o language, script + {Locale.US, loc2, "Japanese (Japan, JP, Japanese Calendar)"}, + {Locale.US, loc3, "Latin (United States, Japanese Calendar)"}, + {Locale.US, loc4, "United States (Japanese Calendar)"}, + {Locale.US, loc5, ""}, + + // invalid cases + {loc6, loc6, "\u4e2d\u6587 (\u4e2d\u56fd\u3001\u65e5\u5386\uff1adddd\u3001\u8d27\u5e01\uff1addd\u3001fw\uff1amoq\u3001\u6570\u5b57\uff1addd\u3001rg\uff1atwzz\u3001\u65f6\u533a\uff1aunknown)"}, + {Locale.US, loc6, "Chinese (China, Calendar: dddd, Currency: ddd, First day of week: moq, Numbers: ddd, Region For Supplemental Data: twzz, Time Zone: unknown)"}, + }; + } + + @Test(dataProvider="locales") + public void test_locales(Locale inLocale, Locale testLocale, String expected) { + String result = testLocale.getDisplayName(inLocale); + assertEquals(result, expected); + } +} diff --git a/test/jdk/java/util/Locale/bcp47u/FormatTests.java b/test/jdk/java/util/Locale/bcp47u/FormatTests.java new file mode 100644 index 00000000000..6c64a00c8a6 --- /dev/null +++ b/test/jdk/java/util/Locale/bcp47u/FormatTests.java @@ -0,0 +1,167 @@ +/* + * 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 8176841 + * @summary Tests *Format class deals with Unicode extensions + * correctly. + * @modules jdk.localedata + * @run testng/othervm -Djava.locale.providers=CLDR FormatTests + */ + +import static org.testng.Assert.assertEquals; + +import java.text.DateFormat; +import java.text.NumberFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test *Format classes with BCP47 U extensions + */ +@Test +public class FormatTests { + private static TimeZone defaultTZ; + + private static final TimeZone ASIATOKYO = TimeZone.getTimeZone("Asia/Tokyo"); + private static final TimeZone AMLA = TimeZone.getTimeZone("America/Los_Angeles"); + + private static final Locale JPTYO = Locale.forLanguageTag("en-u-tz-jptyo"); + private static final Locale JCAL = Locale.forLanguageTag("en-u-ca-japanese"); + private static final Locale USLAX = Locale.forLanguageTag("en-u-tz-uslax"); + + private static final Locale RG_GB = Locale.forLanguageTag("en-US-u-rg-gbzzzz"); + private static final Locale RG_DE = Locale.forLanguageTag("en-US-u-rg-dezzzz"); + + private static final Locale NU_DEVA = Locale.forLanguageTag("en-US-u-nu-deva"); + private static final Locale NU_SINH = Locale.forLanguageTag("en-US-u-nu-sinh"); + private static final Locale NU_ZZZZ = Locale.forLanguageTag("en-US-u-nu-zzzz"); + + private static final double testNum = 12345.6789; + private static final String NUM_US = "12,345.6789"; + private static final String NUM_DE = "12.345,6789"; + private static final String NUM_DEVA = "\u0967\u0968,\u0969\u096a\u096b.\u096c\u096d\u096e\u096f"; + private static final String NUM_SINH = "\u0de7\u0de8,\u0de9\u0dea\u0deb.\u0dec\u0ded\u0dee\u0def"; + + private static final Date testDate = new Calendar.Builder() + .setDate(2017, 7, 10) + .setTimeOfDay(15, 15, 0) + .setTimeZone(AMLA) + .build() + .getTime(); + + @BeforeTest + public void beforeTest() { + defaultTZ = TimeZone.getDefault(); + TimeZone.setDefault(AMLA); + } + + @AfterTest + public void afterTest() { + TimeZone.setDefault(defaultTZ); + } + + @DataProvider(name="dateFormatData") + Object[][] dateFormatData() { + return new Object[][] { + // Locale, Expected calendar, Expected timezone, Expected formatted string + + // -ca + {JCAL, "java.util.JapaneseImperialCalendar", null, + "Thursday, August 10, 29 Heisei at 3:15:00 PM Pacific Daylight Time" + }, + + // -tz + {JPTYO, null, ASIATOKYO, + "Friday, August 11, 2017 at 7:15:00 AM Japan Standard Time" + }, + {USLAX, null, AMLA, + "Thursday, August 10, 2017 at 3:15:00 PM Pacific Daylight Time" + }, + + // -rg + {RG_GB, null, null, + "Thursday, 10 August 2017 at 15:15:00 Pacific Daylight Time" + }, + }; + } + + @DataProvider(name="numberFormatData") + Object[][] numberFormatData() { + return new Object[][] { + // Locale, number, expected format + + // -nu + {NU_DEVA, testNum, NUM_DEVA}, + {NU_SINH, testNum, NUM_SINH}, + {NU_ZZZZ, testNum, NUM_US}, + + // -rg + {RG_DE, testNum, NUM_DE}, + + // -nu & -rg, valid & invalid + {Locale.forLanguageTag("en-US-u-nu-deva-rg-dezzzz"), testNum, NUM_DEVA}, + {Locale.forLanguageTag("en-US-u-nu-zzzz-rg-dezzzz"), testNum, NUM_US}, + {Locale.forLanguageTag("en-US-u-nu-zzzz-rg-zzzz"), testNum, NUM_US}, + }; + } + + @Test(dataProvider="dateFormatData") + public void test_DateFormat(Locale locale, String calClass, TimeZone tz, + String formatExpected) throws Exception { + DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, locale); + if (calClass != null) { + try { + Class expected = Class.forName(calClass); + assertEquals(df.getCalendar().getClass(), expected); + } catch (Exception e) { + throw e; + } + } + if (tz != null) { + assertEquals(df.getTimeZone(), tz); + } + String formatted = df.format(testDate); + assertEquals(formatted, formatExpected); + assertEquals(df.parse(formatted), testDate); + } + + @Test(dataProvider="numberFormatData") + public void test_NumberFormat(Locale locale, double num, + String formatExpected) throws Exception { + NumberFormat nf = NumberFormat.getNumberInstance(locale); + nf.setMaximumFractionDigits(4); + String formatted = nf.format(num); + assertEquals(nf.format(num), formatExpected); + assertEquals(nf.parse(formatted), num); + } +} diff --git a/test/jdk/java/util/Locale/bcp47u/SymbolsTests.java b/test/jdk/java/util/Locale/bcp47u/SymbolsTests.java new file mode 100644 index 00000000000..d8824ed4811 --- /dev/null +++ b/test/jdk/java/util/Locale/bcp47u/SymbolsTests.java @@ -0,0 +1,91 @@ +/* + * 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 8176841 + * @summary Tests *FormatSymbols class deals with Unicode extensions + * correctly. + * @modules jdk.localedata + * @run testng/othervm -Djava.locale.providers=CLDR FormatTests + */ + +import static org.testng.Assert.assertEquals; + +import java.text.DateFormatSymbols; +import java.text.DecimalFormatSymbols; +import java.util.Locale; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test *FormatSymbols classes with BCP47 U extensions + */ +@Test +public class SymbolsTests { + + private static final Locale RG_GB = Locale.forLanguageTag("en-US-u-rg-gbzzzz"); + private static final Locale RG_IE = Locale.forLanguageTag("en-US-u-rg-iezzzz"); + private static final Locale RG_AT = Locale.forLanguageTag("en-US-u-rg-atzzzz"); + + @DataProvider(name="dateFormatSymbolsData") + Object[][] dateFormatSymbolsData() { + return new Object[][] { + // Locale, expected AM string, expected PM string + + {RG_GB, "am", "pm"}, + {RG_IE, "a.m.", "p.m."}, + {Locale.US, "AM", "PM"}, + }; + } + + @DataProvider(name="decimalFormatSymbolsData") + Object[][] decimalFormatSymbolsData() { + return new Object[][] { + // Locale, expected decimal separator, expected grouping separator + + {RG_AT, ",", "."}, + {Locale.US, ".", ","}, + + // -nu & -rg mixed. -nu should win + {Locale.forLanguageTag("ar-EG-u-nu-latn-rg-mazzzz"), ".", ","}, + }; + } + + @Test(dataProvider="dateFormatSymbolsData") + public void test_DateFormatSymbols(Locale locale, String amExpected, String pmExpected) { + DateFormatSymbols dfs = DateFormatSymbols.getInstance(locale); + String[] ampm = dfs.getAmPmStrings(); + assertEquals(ampm[0], amExpected); + assertEquals(ampm[1], pmExpected); + } + + @Test(dataProvider="decimalFormatSymbolsData") + public void test_DecimalFormatSymbols(Locale locale, char decimal, char grouping) { + DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(locale); + assertEquals(dfs.getDecimalSeparator(), decimal); + assertEquals(dfs.getGroupingSeparator(), grouping); + } +} diff --git a/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java b/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java new file mode 100644 index 00000000000..e7cecf3bfd5 --- /dev/null +++ b/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.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 + * @library /lib/testlibrary + * @bug 8189134 + * @summary Tests the system properties + * @modules jdk.localedata + * @build DefaultLocaleTest jdk.testlibrary.* + * @run testng/othervm SystemPropertyTests + */ + +import static jdk.testlibrary.ProcessTools.executeTestJava; +import static org.testng.Assert.assertTrue; + +import java.util.Locale; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * Test Locale.getDefault() reflects the system property. Note that the + * result may change depending on the CLDR releases. + */ +@Test +public class SystemPropertyTests { + + private static String LANGPROP = "-Duser.language=en"; + private static String CTRYPROP = "-Duser.country=US"; + + @DataProvider(name="data") + Object[][] data() { + return new Object[][] { + // system property, expected default, expected format, expected display + {"-Duser.extensions=u-ca-japanese", + "en_US_#u-ca-japanese", + "en_US_#u-ca-japanese", + "en_US_#u-ca-japanese", + }, + + {"-Duser.extensions=u-ca-japanese-nu-thai", + "en_US_#u-ca-japanese-nu-thai", + "en_US_#u-ca-japanese-nu-thai", + "en_US_#u-ca-japanese-nu-thai", + }, + + {"-Duser.extensions=foo", + "en_US", + "en_US", + "en_US", + }, + + {"-Duser.extensions.format=u-ca-japanese", + "en_US", + "en_US_#u-ca-japanese", + "en_US", + }, + + {"-Duser.extensions.display=u-ca-japanese", + "en_US", + "en_US", + "en_US_#u-ca-japanese", + }, + }; + } + + @Test(dataProvider="data") + public void runTest(String extprop, String defLoc, + String defFmtLoc, String defDspLoc) throws Exception { + int exitValue = executeTestJava(LANGPROP, CTRYPROP, + extprop, "DefaultLocaleTest", defLoc, defFmtLoc, defDspLoc) + .outputTo(System.out) + .errorTo(System.out) + .getExitValue(); + + assertTrue(exitValue == 0); + } +} diff --git a/test/jdk/java/util/Locale/bcp47u/spi/LocaleNameProviderTests.java b/test/jdk/java/util/Locale/bcp47u/spi/LocaleNameProviderTests.java new file mode 100644 index 00000000000..98933dac253 --- /dev/null +++ b/test/jdk/java/util/Locale/bcp47u/spi/LocaleNameProviderTests.java @@ -0,0 +1,52 @@ +/* + * 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 8176841 + * @summary Tests LocaleNameProvider SPIs + * @library provider + * @build provider/module-info provider/foo.LocaleNameProviderImpl + * @run main/othervm -Djava.locale.providers=SPI LocaleNameProviderTests + */ + +import java.util.Locale; + +/** + * Test LocaleNameProvider SPI with BCP47 U extensions + * + * Verifies getUnicodeExtensionKey() and getUnicodeExtensionType() methods in + * LocaleNameProvider works. + */ +public class LocaleNameProviderTests { + private static final String expected = "foo (foo_ca:foo_japanese)"; + + public static void main(String... args) { + String name = Locale.forLanguageTag("foo-u-ca-japanese").getDisplayName(new Locale("foo")); + if (!name.equals(expected)) { + throw new RuntimeException("Unicode extension key and/or type name(s) is incorrect. " + + "Expected: \"" + expected + "\", got: \"" + name + "\""); + } + } +} diff --git a/test/jdk/java/util/Locale/bcp47u/spi/provider/foo/LocaleNameProviderImpl.java b/test/jdk/java/util/Locale/bcp47u/spi/provider/foo/LocaleNameProviderImpl.java new file mode 100644 index 00000000000..ce63fec7742 --- /dev/null +++ b/test/jdk/java/util/Locale/bcp47u/spi/provider/foo/LocaleNameProviderImpl.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. + */ + +package foo; + +import java.util.Locale; +import java.util.spi.LocaleNameProvider; + +/* + * Implements LocaleNameProvider SPI, augmenting the default + * values for Unicode Locale Extension key/type names. + */ +public class LocaleNameProviderImpl extends LocaleNameProvider { + private static final Locale[] avail = {new Locale("foo")}; + + @Override + public Locale[] getAvailableLocales() { + return avail; + } + + @Override + public String getDisplayLanguage(String lang, Locale target) { + return null; + } + + @Override + public String getDisplayCountry(String ctry, Locale target) { + return null; + } + + @Override + public String getDisplayVariant(String vrnt, Locale target) { + return null; + } + + @Override + public String getDisplayUnicodeExtensionKey(String key, Locale target) { + return "foo_" + key; + } + + @Override + public String getDisplayUnicodeExtensionType(String extType, String key, Locale target) { + return "foo_" + key + ":foo_" + extType; + } +} diff --git a/test/jdk/java/util/Locale/bcp47u/spi/provider/module-info.java b/test/jdk/java/util/Locale/bcp47u/spi/provider/module-info.java new file mode 100644 index 00000000000..0010072614a --- /dev/null +++ b/test/jdk/java/util/Locale/bcp47u/spi/provider/module-info.java @@ -0,0 +1,27 @@ +/* + * 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. + */ + +module provider { + exports foo; + provides java.util.spi.LocaleNameProvider with foo.LocaleNameProviderImpl; +} diff --git a/test/jdk/sun/text/resources/LocaleData.cldr b/test/jdk/sun/text/resources/LocaleData.cldr index ad4bcadd020..2d368167a23 100644 --- a/test/jdk/sun/text/resources/LocaleData.cldr +++ b/test/jdk/sun/text/resources/LocaleData.cldr @@ -34,8 +34,8 @@ FormatData/pt_BR/DayAbbreviations/2=ter FormatData/pt_BR/DayNames/0=domingo FormatData/pt_BR/DayNames/1=segunda-feira FormatData/pt_BR/DayNames/2=ter\u00e7a-feira -CalendarData/pt_BR/firstDayOfWeek=1 -CalendarData/pt_BR/minimalDaysInFirstWeek=1 +CalendarData/pt_BR/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/pt_BR/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/pt_BR/MonthNames/0=janeiro FormatData/pt_BR/MonthNames/1=fevereiro FormatData/pt_BR/MonthNames/2=mar\u00e7o @@ -189,8 +189,8 @@ FormatData/pl_PL/MonthAbbreviations/9=pa\u017a FormatData/pl_PL/MonthAbbreviations/10=lis FormatData/pl_PL/MonthAbbreviations/11=gru FormatData/pl_PL/MonthAbbreviations/12= -CalendarData/pl_PL/firstDayOfWeek=2 -CalendarData/pl_PL/minimalDaysInFirstWeek=4 +CalendarData/pl_PL/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/pl_PL/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/pl_PL/AmPmMarkers/0=AM FormatData/pl_PL/AmPmMarkers/1=PM @@ -320,8 +320,8 @@ FormatData/ru_RU/DayAbbreviations/5=\u043f\u0442 FormatData/ru_RU/DayAbbreviations/6=\u0441\u0431 FormatData/ru_RU/AmPmMarkers/0=\u0414\u041f FormatData/ru_RU/AmPmMarkers/1=\u041f\u041f -CalendarData/ru_RU/firstDayOfWeek=2 -CalendarData/ru_RU/minimalDaysInFirstWeek=1 +CalendarData/ru_RU/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ru_RU/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA # bug #4094371, 4098518, 4290801, 6558863 FormatData/en_AU/TimePatterns/0=h:mm:ss a zzzz @@ -745,8 +745,8 @@ FormatData/ar_AE/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_AE/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_AE/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_AE/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_AE/firstDayOfWeek=7 -CalendarData/ar_AE/minimalDaysInFirstWeek=1 +CalendarData/ar_AE/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_AE/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_AE/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_AE/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_AE/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -833,8 +833,8 @@ FormatData/ar_BH/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_BH/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_BH/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_BH/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_BH/firstDayOfWeek=7 -CalendarData/ar_BH/minimalDaysInFirstWeek=1 +CalendarData/ar_BH/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_BH/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_BH/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_BH/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_BH/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -921,8 +921,8 @@ FormatData/ar_DZ/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_DZ/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_DZ/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_DZ/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_DZ/firstDayOfWeek=7 -CalendarData/ar_DZ/minimalDaysInFirstWeek=1 +CalendarData/ar_DZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_DZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_DZ/MonthAbbreviations/0=\u062c\u0627\u0646\u0641\u064a FormatData/ar_DZ/MonthAbbreviations/1=\u0641\u064a\u0641\u0631\u064a FormatData/ar_DZ/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1009,8 +1009,8 @@ FormatData/ar_EG/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_EG/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_EG/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_EG/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_EG/firstDayOfWeek=7 -CalendarData/ar_EG/minimalDaysInFirstWeek=1 +CalendarData/ar_EG/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_EG/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_EG/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_EG/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_EG/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1097,8 +1097,8 @@ FormatData/ar_IQ/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_IQ/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_IQ/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_IQ/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_IQ/firstDayOfWeek=7 -CalendarData/ar_IQ/minimalDaysInFirstWeek=1 +CalendarData/ar_IQ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_IQ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_IQ/MonthAbbreviations/0=\u0643\u0627\u0646\u0648\u0646 \u0627\u0644\u062b\u0627\u0646\u064a FormatData/ar_IQ/MonthAbbreviations/1=\u0634\u0628\u0627\u0637 FormatData/ar_IQ/MonthAbbreviations/2=\u0622\u0630\u0627\u0631 @@ -1218,8 +1218,8 @@ FormatData/ar_JO/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_JO/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_JO/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_JO/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_JO/firstDayOfWeek=7 -CalendarData/ar_JO/minimalDaysInFirstWeek=1 +CalendarData/ar_JO/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_JO/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_JO/Eras/0=\u0642.\u0645 FormatData/ar_JO/Eras/1=\u0645 LocaleNames/ar_JO/ar=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 @@ -1273,8 +1273,8 @@ FormatData/ar_KW/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_KW/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_KW/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_KW/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_KW/firstDayOfWeek=7 -CalendarData/ar_KW/minimalDaysInFirstWeek=1 +CalendarData/ar_KW/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_KW/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_KW/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_KW/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_KW/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1394,8 +1394,8 @@ FormatData/ar_LB/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_LB/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_LB/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_LB/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_LB/firstDayOfWeek=2 -CalendarData/ar_LB/minimalDaysInFirstWeek=1 +CalendarData/ar_LB/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_LB/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_LB/Eras/0=\u0642.\u0645 FormatData/ar_LB/Eras/1=\u0645 LocaleNames/ar_LB/ar=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 @@ -1449,8 +1449,8 @@ FormatData/ar_LY/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_LY/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_LY/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_LY/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_LY/firstDayOfWeek=7 -CalendarData/ar_LY/minimalDaysInFirstWeek=1 +CalendarData/ar_LY/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_LY/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_LY/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_LY/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_LY/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1537,8 +1537,8 @@ FormatData/ar_MA/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_MA/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_MA/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_MA/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_MA/firstDayOfWeek=7 -CalendarData/ar_MA/minimalDaysInFirstWeek=1 +CalendarData/ar_MA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_MA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_MA/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_MA/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_MA/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1625,8 +1625,8 @@ FormatData/ar_OM/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_OM/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_OM/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_OM/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_OM/firstDayOfWeek=7 -CalendarData/ar_OM/minimalDaysInFirstWeek=1 +CalendarData/ar_OM/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_OM/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_OM/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_OM/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_OM/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1713,8 +1713,8 @@ FormatData/ar_QA/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_QA/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_QA/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_QA/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_QA/firstDayOfWeek=7 -CalendarData/ar_QA/minimalDaysInFirstWeek=1 +CalendarData/ar_QA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_QA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_QA/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_QA/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_QA/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1801,8 +1801,8 @@ FormatData/ar_SA/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_SA/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_SA/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_SA/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_SA/firstDayOfWeek=1 -CalendarData/ar_SA/minimalDaysInFirstWeek=1 +CalendarData/ar_SA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_SA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_SA/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_SA/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_SA/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -1890,8 +1890,8 @@ FormatData/ar_SD/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_SD/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_SD/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_SD/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_SD/firstDayOfWeek=7 -CalendarData/ar_SD/minimalDaysInFirstWeek=1 +CalendarData/ar_SD/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_SD/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_SD/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_SD/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_SD/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -2011,8 +2011,8 @@ FormatData/ar_SY/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_SY/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_SY/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_SY/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_SY/firstDayOfWeek=7 -CalendarData/ar_SY/minimalDaysInFirstWeek=1 +CalendarData/ar_SY/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_SY/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_SY/Eras/0=\u0642.\u0645 FormatData/ar_SY/Eras/1=\u0645 LocaleNames/ar_SY/ar=\u0627\u0644\u0639\u0631\u0628\u064a\u0629 @@ -2066,8 +2066,8 @@ FormatData/ar_TN/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_TN/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_TN/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_TN/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_TN/firstDayOfWeek=1 -CalendarData/ar_TN/minimalDaysInFirstWeek=1 +CalendarData/ar_TN/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_TN/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_TN/MonthAbbreviations/0=\u062c\u0627\u0646\u0641\u064a FormatData/ar_TN/MonthAbbreviations/1=\u0641\u064a\u0641\u0631\u064a FormatData/ar_TN/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -2154,8 +2154,8 @@ FormatData/ar_YE/DayNames/3=\u0627\u0644\u0623\u0631\u0628\u0639\u0627\u0621 FormatData/ar_YE/DayNames/4=\u0627\u0644\u062e\u0645\u064a\u0633 FormatData/ar_YE/DayNames/5=\u0627\u0644\u062c\u0645\u0639\u0629 FormatData/ar_YE/DayNames/6=\u0627\u0644\u0633\u0628\u062a -CalendarData/ar_YE/firstDayOfWeek=1 -CalendarData/ar_YE/minimalDaysInFirstWeek=1 +CalendarData/ar_YE/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/ar_YE/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/ar_YE/MonthAbbreviations/0=\u064a\u0646\u0627\u064a\u0631 FormatData/ar_YE/MonthAbbreviations/1=\u0641\u0628\u0631\u0627\u064a\u0631 FormatData/ar_YE/MonthAbbreviations/2=\u0645\u0627\u0631\u0633 @@ -2341,9 +2341,9 @@ FormatData/fr_FR/MonthAbbreviations/9=oct. FormatData/fr_FR/MonthAbbreviations/10=nov. FormatData/fr_FR/MonthAbbreviations/11=d\u00e9c. FormatData/fr_FR/MonthAbbreviations/12= -CalendarData/fr_FR/firstDayOfWeek=2 +CalendarData/fr_FR/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY # next line changed according the 4518811 bug -CalendarData/fr_FR/minimalDaysInFirstWeek=4 +CalendarData/fr_FR/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA FormatData/fr_FR/AmPmMarkers/0=AM FormatData/fr_FR/AmPmMarkers/1=PM @@ -2488,19 +2488,19 @@ CurrencyNames/ru_RU/RUB=\u20bd LocaleNames/ru_RU/MM=\u041c\u044c\u044f\u043d\u043c\u0430 (\u0411\u0438\u0440\u043c\u0430) #bug 4518811 -CalendarData/ca_ES/minimalDaysInFirstWeek=4 -CalendarData/cs_CZ/minimalDaysInFirstWeek=4 -CalendarData/da_DK/minimalDaysInFirstWeek=4 -CalendarData/de_AT/minimalDaysInFirstWeek=4 -CalendarData/el_GR/minimalDaysInFirstWeek=4 -CalendarData/en_IE/minimalDaysInFirstWeek=4 -CalendarData/es_ES/minimalDaysInFirstWeek=4 -CalendarData/et_EE/minimalDaysInFirstWeek=4 -CalendarData/fi_FI/minimalDaysInFirstWeek=4 -CalendarData/is_IS/minimalDaysInFirstWeek=4 -CalendarData/lt_LT/minimalDaysInFirstWeek=4 -CalendarData/pl_PL/minimalDaysInFirstWeek=4 -CalendarData/pt_PT/minimalDaysInFirstWeek=4 +CalendarData/ca_ES/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/cs_CZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/da_DK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/de_AT/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/el_GR/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/en_IE/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/es_ES/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/et_EE/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/fi_FI/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/is_IS/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/lt_LT/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/pl_PL/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/pt_PT/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA #bug 4945388 CurrencyNames/be_BY/BYR=\u0440. @@ -2523,7 +2523,7 @@ FormatData/bg/DayNames/4=\u0447\u0435\u0442\u0432\u044a\u0440\u0442\u044a\u043a LocaleNames/zh/tw=\u7279\u5a01\u6587 #bug 6277020 -CalendarData/ca_ES/firstDayOfWeek=2 +CalendarData/ca_ES/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY #bug 6277696 #zh_SG, id, id_ID, en_MT, mt_MT, en_PH, el, el_CY, ms, ms_MY @@ -3324,7 +3324,7 @@ LocaleNames/el_CY/ZM=\u0396\u03ac\u03bc\u03c0\u03b9\u03b1 LocaleNames/el_CY/ZW=\u0396\u03b9\u03bc\u03c0\u03ac\u03bc\u03c0\u03bf\u03c5\u03b5 #CurrencyNames/el_CY/CYP= CurrencyNames/el_CY/EUR=\u20ac -CalendarData/el_CY/minimalDaysInFirstWeek=1 +CalendarData/el_CY/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA #ms_MY and ms FormatData/ms_MY/NumberPatterns/0=#,##0.### @@ -3538,7 +3538,7 @@ LocaleNames/es_US/TK=Tokelau LocaleNames/es_US/TT=Trinidad y Tobago LocaleNames/es_US/VI=Islas V\u00edrgenes de EE. UU. CurrencyNames/es_US/USD=$ -CalendarData/es_US/firstDayOfWeek=1 +CalendarData/es_US/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY #bug 4400849 LocaleNames/pt/aa=afar LocaleNames/pt/ab=abc\u00e1zio @@ -5389,13 +5389,13 @@ FormatData/mt/AmPmMarkers/0=AM FormatData/mt/AmPmMarkers/1=PM FormatData/mt/DatePatterns/0=EEEE, d 'ta'\u2019 MMMM y # bug# 6483191 -CalendarData/ga_IE/firstDayOfWeek=1 -CalendarData/en_PH/firstDayOfWeek=1 -CalendarData/en_SG/firstDayOfWeek=1 -CalendarData/zh_SG/firstDayOfWeek=1 -CalendarData/mt_MT/firstDayOfWeek=1 -CalendarData/en_MT/firstDayOfWeek=1 -CalendarData/es_US/firstDayOfWeek=1 +CalendarData/ga_IE/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/en_PH/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/en_SG/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_SG/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/mt_MT/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/en_MT/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/es_US/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY #CalendarData/es_CY/firstDayOfWeek= #CalendarData/in_ID/firstDayOfWeek= #CalendarData/ms_MY/firstDayOfWeek= @@ -6122,14 +6122,14 @@ LocaleNames/nl/ZM=Zambia # bug 6998391 #CalendarData/sr-Latn/firstDayOfWeek= -CalendarData/sr-Latn-BA/firstDayOfWeek=2 -CalendarData/sr-Latn-ME/firstDayOfWeek=2 -CalendarData/sr-Latn-RS/firstDayOfWeek=2 +CalendarData/sr-Latn-BA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr-Latn-ME/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr-Latn-RS/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY # #CalendarData/sr-Latn/minimalDaysInFirstWeek= -CalendarData/sr-Latn-BA/minimalDaysInFirstWeek=1 -CalendarData/sr-Latn-ME/minimalDaysInFirstWeek=1 -CalendarData/sr-Latn-RS/minimalDaysInFirstWeek=1 +CalendarData/sr-Latn-BA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr-Latn-ME/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr-Latn-RS/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA # LocaleNames/sr-Latn/SR=Surinam LocaleNames/sr-Latn-BA/SR=Surinam @@ -8303,79 +8303,79 @@ FormatData/kea_CV/latn.NumberElements/1=\u00a0 # bug #8185841 -CalendarData/az-Latn-AZ/firstDayOfWeek=2 -CalendarData/az-Latn-AZ/minimalDaysInFirstWeek=1 -CalendarData/az-Cyrl-AZ/firstDayOfWeek=2 -CalendarData/az-Cyrl-AZ/minimalDaysInFirstWeek=1 -CalendarData/az_AZ/firstDayOfWeek=2 -CalendarData/az-AZ/minimalDaysInFirstWeek=1 -CalendarData/bs-Cyrl-BA/firstDayOfWeek=2 -CalendarData/bs-Cyrl-BA/minimalDaysInFirstWeek=1 -CalendarData/bs_BA/firstDayOfWeek=2 -CalendarData/bs_BA/minimalDaysInFirstWeek=1 -CalendarData/pa-Arab-PK/firstDayOfWeek=1 -CalendarData/pa-Arab-PK/minimalDaysInFirstWeek=1 -CalendarData/pa_PK/firstDayOfWeek=1 -CalendarData/pa_PK/minimalDaysInFirstWeek=1 -CalendarData/pa-Guru-IN/firstDayOfWeek=1 -CalendarData/pa-Guru-IN/minimalDaysInFirstWeek=1 -CalendarData/pa_IN/firstDayOfWeek=1 -CalendarData/pa_IN/minimalDaysInFirstWeek=1 -CalendarData/shi-Latn-MA/firstDayOfWeek=7 -CalendarData/shi-Latn-MA/minimalDaysInFirstWeek=1 -CalendarData/shi-Tfng-MA/firstDayOfWeek=7 -CalendarData/shi-Tfng-MA/minimalDaysInFirstWeek=1 -CalendarData/shi_MA/firstDayOfWeek=7 -CalendarData/shi_MA/minimalDaysInFirstWeek=1 -CalendarData/sr-Cyrl-BA/firstDayOfWeek=2 -CalendarData/sr-Cyrl-BA/minimalDaysInFirstWeek=1 -CalendarData/sr-Cyrl-ME/firstDayOfWeek=2 -CalendarData/sr-Cyrl-ME/minimalDaysInFirstWeek=1 -CalendarData/sr-Cyrl-RS/firstDayOfWeek=2 -CalendarData/sr-Cyrl-RS/minimalDaysInFirstWeek=1 -CalendarData/sr-Cyrl-XK/firstDayOfWeek=2 -CalendarData/sr-Cyrl-XK/minimalDaysInFirstWeek=1 -CalendarData/sr_RS/firstDayOfWeek=2 -CalendarData/sr_RS/minimalDaysInFirstWeek=1 -CalendarData/sr_BA/firstDayOfWeek=2 -CalendarData/sr_BA/minimalDaysInFirstWeek=1 -CalendarData/sr_ME/firstDayOfWeek=2 -CalendarData/sr_ME/minimalDaysInFirstWeek=1 -CalendarData/sr_XK/firstDayOfWeek=2 -CalendarData/sr_XK/minimalDaysInFirstWeek=1 -CalendarData/uz-Arab-AF/firstDayOfWeek=7 -CalendarData/uz-Arab-AF/minimalDaysInFirstWeek=1 -CalendarData/uz-Cyrl-UZ/firstDayOfWeek=2 -CalendarData/uz-Cyrl-UZ/minimalDaysInFirstWeek=1 -CalendarData/uz-Latn-UZ/firstDayOfWeek=2 -CalendarData/uz-Latn-UZ/minimalDaysInFirstWeek=1 -CalendarData/vai-Latn-LR/firstDayOfWeek=2 -CalendarData/vai-Latn-LR/minimalDaysInFirstWeek=1 -CalendarData/vai-Vaii-LR/firstDayOfWeek=2 -CalendarData/vai-Vaii-LR/minimalDaysInFirstWeek=1 -CalendarData/vai_LR/firstDayOfWeek=2 -CalendarData/vai_LR/minimalDaysInFirstWeek=1 -CalendarData/uz_UZ/firstDayOfWeek=2 -CalendarData/uz_UZ/minimalDaysInFirstWeek=1 -CalendarData/zh_CN/firstDayOfWeek=1 -CalendarData/zh_CN/minimalDaysInFirstWeek=1 -CalendarData/zh-Hans-CN/minimalDaysInFirstWeek=1 -CalendarData/zh-Hans-CN/firstDayOfWeek=1 -CalendarData/zh-Hans-HK/firstDayOfWeek=1 -CalendarData/zh-Hans-HK/minimalDaysInFirstWeek=1 -CalendarData/zh-Hans-MO/minimalDaysInFirstWeek=1 -CalendarData/zh-Hans-MO/firstDayOfWeek=1 -CalendarData/zh-Hans-SG/firstDayOfWeek=1 -CalendarData/zh-Hans-SG/minimalDaysInFirstWeek=1 -CalendarData/zh-Hant-HK/minimalDaysInFirstWeek=1 -CalendarData/zh-Hant-HK/firstDayOfWeek=1 -CalendarData/zh-Hant-TW/minimalDaysInFirstWeek=1 -CalendarData/zh-Hant-TW/firstDayOfWeek=1 -CalendarData/zh_HK/minimalDaysInFirstWeek=1 -CalendarData/zh_HK/firstDayOfWeek=1 -CalendarData/zh_MO/minimalDaysInFirstWeek=1 -CalendarData/zh_MO/firstDayOfWeek=1 -CalendarData/zh_SG/minimalDaysInFirstWeek=1 -CalendarData/zh_SG/firstDayOfWeek=1 -CalendarData/zh_TW/firstDayOfWeek=1 -CalendarData/zh_TW/minimalDaysInFirstWeek=1 +CalendarData/az-Latn-AZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/az-Latn-AZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/az-Cyrl-AZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/az-Cyrl-AZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/az_AZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/az-AZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/bs-Cyrl-BA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/bs-Cyrl-BA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/bs_BA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/bs_BA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/pa-Arab-PK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/pa-Arab-PK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/pa_PK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/pa_PK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/pa-Guru-IN/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/pa-Guru-IN/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/pa_IN/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/pa_IN/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/shi-Latn-MA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/shi-Latn-MA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/shi-Tfng-MA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/shi-Tfng-MA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/shi_MA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/shi_MA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr-Cyrl-BA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr-Cyrl-BA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr-Cyrl-ME/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr-Cyrl-ME/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr-Cyrl-RS/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr-Cyrl-RS/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr-Cyrl-XK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr-Cyrl-XK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr_RS/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr_RS/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr_BA/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr_BA/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr_ME/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr_ME/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/sr_XK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/sr_XK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/uz-Arab-AF/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/uz-Arab-AF/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/uz-Cyrl-UZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/uz-Cyrl-UZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/uz-Latn-UZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/uz-Latn-UZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/vai-Latn-LR/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/vai-Latn-LR/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/vai-Vaii-LR/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/vai-Vaii-LR/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/vai_LR/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/vai_LR/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/uz_UZ/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/uz_UZ/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh_CN/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_CN/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hans-CN/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hans-CN/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh-Hans-HK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh-Hans-HK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hans-MO/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hans-MO/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh-Hans-SG/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh-Hans-SG/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hant-HK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hant-HK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh-Hant-TW/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh-Hant-TW/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_HK/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh_HK/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_MO/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh_MO/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_SG/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA +CalendarData/zh_SG/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_TW/firstDayOfWeek=1: AG AR AS AU BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IE IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP NZ PA PE PH PK PR PY SA SG SV TH TN TT TW UM US VE VI WS YE ZA ZW;2: 001 AD AI AL AM AN AT AX AZ BA BE BG BM BN BY CH CL CM CR CY CZ DE DK EC EE ES FI FJ FO FR GB GE GF GP GR HR HU IS IT KG KZ LB LI LK LT LU LV MC MD ME MK MN MQ MY NL NO PL PT RE RO RS RU SE SI SK SM TJ TM TR UA UY UZ VA VN XK;6: BD MV;7: AE AF BH DJ DZ EG IQ IR JO KW LY MA OM QA SD SY +CalendarData/zh_TW/minimalDaysInFirstWeek=1: 001 GU UM US VI;4: AD AN AT AX BE BG CH CZ DE DK EE ES FI FJ FO FR GB GF GG GI GP GR HU IE IM IS IT JE LI LT LU MC MQ NL NO PL PT RE SE SJ SK SM VA diff --git a/test/jdk/sun/text/resources/LocaleDataTest.java b/test/jdk/sun/text/resources/LocaleDataTest.java index 1549b65d911..3a0f969875f 100644 --- a/test/jdk/sun/text/resources/LocaleDataTest.java +++ b/test/jdk/sun/text/resources/LocaleDataTest.java @@ -37,7 +37,7 @@ * 7003124 7085757 7028073 7171028 7189611 8000983 7195759 8004489 8006509 * 7114053 7074882 7040556 8008577 8013836 8021121 6192407 6931564 8027695 * 8017142 8037343 8055222 8042126 8074791 8075173 8080774 8129361 8134916 - * 8145136 8145952 8164784 8037111 8081643 7037368 8178872 8185841 + * 8145136 8145952 8164784 8037111 8081643 7037368 8178872 8185841 8190918 * @summary Verify locale data * @modules java.base/sun.util.resources * @modules jdk.localedata diff --git a/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java b/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java index c6863202991..26f97966a47 100644 --- a/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java +++ b/test/jdk/tools/jlink/plugins/IncludeLocalesPluginTest.java @@ -40,7 +40,7 @@ import tests.Result; /* * @test - * @bug 8152143 8152704 8155649 8165804 8185841 + * @bug 8152143 8152704 8155649 8165804 8185841 8176841 8190918 * @summary IncludeLocalesPlugin tests * @author Naoto Sato * @library ../../lib @@ -70,6 +70,14 @@ public class IncludeLocalesPluginTest { private static int errors; private final static Object[][] testData = { + // Test data should include: + // - --include-locales command line option + // - --add-modules command line option values + // - List of required resources in the result image + // - List of resources that should not exist in the result image + // - List of available locales in the result image + // - Error message + // without --include-locales option: should include all locales { "", @@ -227,11 +235,8 @@ public class IncludeLocalesPluginTest { List.of( "/jdk.localedata/sun/text/resources/ext/FormatData_en_IN.class", "/jdk.localedata/sun/text/resources/ext/FormatData_hi_IN.class", - "/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_as_IN.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class", - "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_IN.class", - "/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_kok_IN.class", - "/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_pa_IN.class"), + "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_IN.class"), List.of( "/jdk.localedata/sun/text/resources/ext/LineBreakIteratorData_th", "/jdk.localedata/sun/text/resources/ext/thai_dict", @@ -242,6 +247,7 @@ public class IncludeLocalesPluginTest { "/jdk.localedata/sun/text/resources/ext/FormatData_ja.class", "/jdk.localedata/sun/text/resources/ext/FormatData_th.class", "/jdk.localedata/sun/text/resources/ext/FormatData_zh.class", + "/jdk.localedata/sun/util/resources/cldr/ext/CalendarData_as_IN.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class", "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_zh.class"), @@ -327,7 +333,7 @@ public class IncludeLocalesPluginTest { "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_th.class"), List.of( "(root)", "en", "en_US", "en_US_POSIX", "zh", "zh__#Hans", "zh_CN", - "zh_HK", "zh_MO", "zh_CN_#Hans", "zh_HK_#Hans", "zh_MO_#Hans", "zh_SG", "zh_SG_#Hans"), + "zh_CN_#Hans", "zh_HK_#Hans", "zh_MO_#Hans", "zh_SG", "zh_SG_#Hans"), "", }, @@ -387,6 +393,34 @@ public class IncludeLocalesPluginTest { "", }, + // Langtag including extensions. Should be ignored. + { + "--include-locales=en,ja-u-nu-thai", + "jdk.localedata", + List.of( + "/jdk.localedata/sun/text/resources/ext/FormatData_en_GB.class", + "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_en_001.class"), + List.of( + "/jdk.localedata/sun/text/resources/cldr/ext/FormatData_ja.class", + "/jdk.localedata/sun/text/resources/ext/FormatData_th.class"), + List.of( + "(root)", "en", "en_001", "en_150", "en_AG", "en_AI", "en_AS", "en_AT", + "en_AU", "en_BB", "en_BE", "en_BI", "en_BM", "en_BS", "en_BW", "en_BZ", + "en_CA", "en_CC", "en_CH", "en_CK", "en_CM", "en_CX", "en_CY", "en_DE", + "en_DG", "en_DK", "en_DM", "en_ER", "en_FI", "en_FJ", "en_FK", "en_FM", + "en_GB", "en_GD", "en_GG", "en_GH", "en_GI", "en_GM", "en_GU", "en_GY", + "en_HK", "en_IE", "en_IL", "en_IM", "en_IN", "en_IO", "en_JE", "en_JM", + "en_KE", "en_KI", "en_KN", "en_KY", "en_LC", "en_LR", "en_LS", "en_MG", + "en_MH", "en_MO", "en_MP", "en_MS", "en_MT", "en_MU", "en_MW", "en_MY", + "en_NA", "en_NF", "en_NG", "en_NL", "en_NR", "en_NU", "en_NZ", "en_PG", + "en_PH", "en_PK", "en_PN", "en_PR", "en_PW", "en_RW", "en_SB", "en_SC", + "en_SD", "en_SE", "en_SG", "en_SH", "en_SI", "en_SL", "en_SS", "en_SX", + "en_SZ", "en_TC", "en_TK", "en_TO", "en_TT", "en_TV", "en_TZ", "en_UG", + "en_UM", "en_US", "en_US_POSIX", "en_VC", "en_VG", "en_VI", "en_VU", + "en_WS", "en_ZA", "en_ZM", "en_ZW"), + "", + }, + // Error case: No matching locales { "--include-locales=xyz", From 4f080a83af63fe275a273e369657bc1de42e74f9 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Tue, 12 Dec 2017 11:10:12 -0800 Subject: [PATCH 15/26] 8183743: Umbrella: add overloads that take a Charset parameter Reviewed-by: alanb, rriggs --- .../java/io/ByteArrayOutputStream.java | 57 +++- .../share/classes/java/io/PrintStream.java | 111 ++++++-- .../share/classes/java/io/PrintWriter.java | 88 +++++- .../share/classes/java/net/URLDecoder.java | 76 +++-- .../share/classes/java/net/URLEncoder.java | 61 ++-- .../classes/java/nio/channels/Channels.java | 70 ++++- .../share/classes/java/util/Formatter.java | 90 ++++++ .../share/classes/java/util/Properties.java | 66 ++++- .../share/classes/java/util/Scanner.java | 82 +++++- .../util/xml/PropertiesDefaultHandler.java | 7 +- .../internal/util/xml/XMLStreamWriter.java | 6 +- .../util/xml/impl/XMLStreamWriterImpl.java | 39 ++- .../ByteArrayOutputStream/EncodingTest.java | 84 ++++++ .../jdk/java/io/PrintStream/EncodingTest.java | 134 +++++++++ .../io/PrintStream/FailingConstructors.java | 8 +- .../jdk/java/io/PrintWriter/EncodingTest.java | 135 +++++++++ .../io/PrintWriter/FailingConstructors.java | 4 +- .../jdk/java/net/URLDecoder/EncodingTest.java | 122 ++++++++ .../java/net/URLDecoder/URLDecoderArgs.java | 6 +- .../jdk/java/net/URLEncoder/EncodingTest.java | 97 +++++++ .../net/URLEncoder/URLEncoderEncodeArgs.java | 2 +- .../jdk/java/nio/channels/Channels/Basic.java | 28 +- .../nio/channels/Channels/EncodingTest.java | 266 ++++++++++++++++++ .../jdk/java/util/Formatter/Constructors.java | 81 +++++- .../jdk/java/util/Formatter/EncodingTest.java | 133 +++++++++ .../java/util/Properties/EncodingTest.java | 79 ++++++ test/jdk/java/util/Scanner/EncodingTest.java | 135 +++++++++ .../util/Scanner/FailingConstructors.java | 23 +- 28 files changed, 1959 insertions(+), 131 deletions(-) create mode 100644 test/jdk/java/io/ByteArrayOutputStream/EncodingTest.java create mode 100644 test/jdk/java/io/PrintStream/EncodingTest.java create mode 100644 test/jdk/java/io/PrintWriter/EncodingTest.java create mode 100644 test/jdk/java/net/URLDecoder/EncodingTest.java create mode 100644 test/jdk/java/net/URLEncoder/EncodingTest.java create mode 100644 test/jdk/java/nio/channels/Channels/EncodingTest.java create mode 100644 test/jdk/java/util/Formatter/EncodingTest.java create mode 100644 test/jdk/java/util/Properties/EncodingTest.java create mode 100644 test/jdk/java/util/Scanner/EncodingTest.java diff --git a/src/java.base/share/classes/java/io/ByteArrayOutputStream.java b/src/java.base/share/classes/java/io/ByteArrayOutputStream.java index bd867c08d76..7448eac2560 100644 --- a/src/java.base/share/classes/java/io/ByteArrayOutputStream.java +++ b/src/java.base/share/classes/java/io/ByteArrayOutputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 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,6 +25,7 @@ package java.io; +import java.nio.charset.Charset; import java.util.Arrays; /** @@ -223,14 +224,27 @@ public class ByteArrayOutputStream extends OutputStream { /** * Converts the buffer's contents into a string by decoding the bytes using - * the named {@link java.nio.charset.Charset charset}. The length of the new - * {@code String} is a function of the charset, and hence may not be equal - * to the length of the byte array. + * the named {@link java.nio.charset.Charset charset}. + * + *

    This method is equivalent to {@code #toString(charset)} that takes a + * {@link java.nio.charset.Charset charset}. + * + *

    An invocation of this method of the form + * + *

     {@code
    +     *      ByteArrayOutputStream b = ...
    +     *      b.toString("UTF-8")
    +     *      }
    +     * 
    + * + * behaves in exactly the same way as the expression + * + *
     {@code
    +     *      ByteArrayOutputStream b = ...
    +     *      b.toString(StandardCharsets.UTF_8)
    +     *      }
    +     * 
    * - *

    This method always replaces malformed-input and unmappable-character - * sequences with this charset's default replacement string. The {@link - * java.nio.charset.CharsetDecoder} class should be used when more control - * over the decoding process is required. * * @param charsetName the name of a supported * {@link java.nio.charset.Charset charset} @@ -245,6 +259,26 @@ public class ByteArrayOutputStream extends OutputStream { return new String(buf, 0, count, charsetName); } + /** + * Converts the buffer's contents into a string by decoding the bytes using + * the specified {@link java.nio.charset.Charset charset}. The length of the new + * {@code String} is a function of the charset, and hence may not be equal + * to the length of the byte array. + * + *

    This method always replaces malformed-input and unmappable-character + * sequences with the charset's default replacement string. The {@link + * java.nio.charset.CharsetDecoder} class should be used when more control + * over the decoding process is required. + * + * @param charset the {@linkplain java.nio.charset.Charset charset} + * to be used to decode the {@code bytes} + * @return String decoded from the buffer's contents. + * @since 10 + */ + public synchronized String toString(Charset charset) { + return new String(buf, 0, count, charset); + } + /** * Creates a newly allocated string. Its size is the current size of * the output stream and the valid contents of the buffer have been @@ -257,9 +291,10 @@ public class ByteArrayOutputStream extends OutputStream { * * @deprecated This method does not properly convert bytes into characters. * As of JDK 1.1, the preferred way to do this is via the - * {@code toString(String enc)} method, which takes an encoding-name - * argument, or the {@code toString()} method, which uses the - * platform's default character encoding. + * {@link #toString(String charsetName)} or {@link #toString(Charset charset)} + * method, which takes an encoding-name or charset argument, + * or the {@code toString()} method, which uses the platform's default + * character encoding. * * @param hibyte the high byte of each resulting Unicode character. * @return the current contents of the output stream, as a string. diff --git a/src/java.base/share/classes/java/io/PrintStream.java b/src/java.base/share/classes/java/io/PrintStream.java index 09028de7358..ae041697826 100644 --- a/src/java.base/share/classes/java/io/PrintStream.java +++ b/src/java.base/share/classes/java/io/PrintStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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,10 +45,16 @@ import java.nio.charset.UnsupportedCharsetException; * ({@code '\n'}) is written. * *

    All characters printed by a {@code PrintStream} are converted into - * bytes using the platform's default character encoding. + * bytes using the given encoding or charset, or platform's default character + * encoding if not specified. * The {@link PrintWriter} class should be used in situations that require * writing characters rather than bytes. * + *

    This class always replaces malformed and unmappable character sequences with + * the charset's default replacement string. + * The {@linkplain java.nio.charset.CharsetEncoder} class should be used when more + * control over the encoding process is required. + * * @author Frank Yellin * @author Mark Reinhold * @since 1.0 @@ -105,22 +111,13 @@ public class PrintStream extends FilterOutputStream this.textOut = new BufferedWriter(charOut); } - private PrintStream(boolean autoFlush, OutputStream out, Charset charset) { - super(out); - this.autoFlush = autoFlush; - this.charOut = new OutputStreamWriter(this, charset); - this.textOut = new BufferedWriter(charOut); - } - /* Variant of the private constructor so that the given charset name * can be verified before evaluating the OutputStream argument. Used * by constructors creating a FileOutputStream that also take a * charset name. */ - private PrintStream(boolean autoFlush, Charset charset, OutputStream out) - throws UnsupportedEncodingException - { - this(autoFlush, out, charset); + private PrintStream(boolean autoFlush, Charset charset, OutputStream out) { + this(out, autoFlush, charset); } /** @@ -172,9 +169,30 @@ public class PrintStream extends FilterOutputStream public PrintStream(OutputStream out, boolean autoFlush, String encoding) throws UnsupportedEncodingException { - this(autoFlush, - requireNonNull(out, "Null output stream"), - toCharset(encoding)); + this(requireNonNull(out, "Null output stream"), autoFlush, toCharset(encoding)); + } + + /** + * Creates a new print stream, with the specified OutputStream, automatic line + * flushing and charset. This convenience constructor creates the necessary + * intermediate {@link java.io.OutputStreamWriter OutputStreamWriter}, + * which will encode characters using the provided charset. + * + * @param out The output stream to which values and objects will be + * printed + * @param autoFlush A boolean; if true, the output buffer will be flushed + * whenever a byte array is written, one of the + * {@code println} methods is invoked, or a newline + * character or byte ({@code '\n'}) is written + * @param charset A {@linkplain java.nio.charset.Charset charset} + * + * @since 10 + */ + public PrintStream(OutputStream out, boolean autoFlush, Charset charset) { + super(out); + this.autoFlush = autoFlush; + this.charOut = new OutputStreamWriter(this, charset); + this.textOut = new BufferedWriter(charOut); } /** @@ -248,6 +266,36 @@ public class PrintStream extends FilterOutputStream this(false, toCharset(csn), new FileOutputStream(fileName)); } + /** + * Creates a new print stream, without automatic line flushing, with the + * specified file name and charset. This convenience constructor creates + * the necessary intermediate {@link java.io.OutputStreamWriter + * OutputStreamWriter}, which will encode characters using the provided + * charset. + * + * @param fileName + * The name of the file to use as the destination of this print + * stream. If the file exists, then it will be truncated to + * zero size; otherwise, a new file will be created. The output + * will be written to the file and is buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @throws IOException + * if an I/O error occurs while opening or creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(fileName)} denies write + * access to the file + * + * @since 10 + */ + public PrintStream(String fileName, Charset charset) throws IOException { + this(false, requireNonNull(charset, "charset"), new FileOutputStream(fileName)); + } + /** * Creates a new print stream, without automatic line flushing, with the * specified file. This convenience constructor creates the necessary @@ -319,6 +367,37 @@ public class PrintStream extends FilterOutputStream this(false, toCharset(csn), new FileOutputStream(file)); } + + /** + * Creates a new print stream, without automatic line flushing, with the + * specified file and charset. This convenience constructor creates + * the necessary intermediate {@link java.io.OutputStreamWriter + * OutputStreamWriter}, which will encode characters using the provided + * charset. + * + * @param file + * The file to use as the destination of this print stream. If the + * file exists, then it will be truncated to zero size; otherwise, + * a new file will be created. The output will be written to the + * file and is buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @throws IOException + * if an I/O error occurs while opening or creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(file.getPath())} + * denies write access to the file + * + * @since 10 + */ + public PrintStream(File file, Charset charset) throws IOException { + this(false, requireNonNull(charset, "charset"), new FileOutputStream(file)); + } + /** Check to make sure that the stream has not been closed */ private void ensureOpen() throws IOException { if (out == null) diff --git a/src/java.base/share/classes/java/io/PrintWriter.java b/src/java.base/share/classes/java/io/PrintWriter.java index 0513312781b..e5ecc79c555 100644 --- a/src/java.base/share/classes/java/io/PrintWriter.java +++ b/src/java.base/share/classes/java/io/PrintWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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,6 +48,11 @@ import java.nio.charset.UnsupportedCharsetException; * constructors may. The client may inquire as to whether any errors have * occurred by invoking {@link #checkError checkError()}. * + *

    This class always replaces malformed and unmappable character sequences with + * the charset's default replacement string. + * The {@linkplain java.nio.charset.CharsetEncoder} class should be used when more + * control over the encoding process is required. + * * @author Frank Yellin * @author Mark Reinhold * @since 1.1 @@ -137,7 +142,26 @@ public class PrintWriter extends Writer { * @see java.io.OutputStreamWriter#OutputStreamWriter(java.io.OutputStream) */ public PrintWriter(OutputStream out, boolean autoFlush) { - this(new BufferedWriter(new OutputStreamWriter(out)), autoFlush); + this(out, autoFlush, Charset.defaultCharset()); + } + + /** + * Creates a new PrintWriter from an existing OutputStream. This + * convenience constructor creates the necessary intermediate + * OutputStreamWriter, which will convert characters into bytes using the + * specified charset. + * + * @param out An output stream + * @param autoFlush A boolean; if true, the {@code println}, + * {@code printf}, or {@code format} methods will + * flush the output buffer + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @since 10 + */ + public PrintWriter(OutputStream out, boolean autoFlush, Charset charset) { + this(new BufferedWriter(new OutputStreamWriter(out, charset)), autoFlush); // save print stream for error propagation if (out instanceof java.io.PrintStream) { @@ -224,6 +248,36 @@ public class PrintWriter extends Writer { this(toCharset(csn), new File(fileName)); } + /** + * Creates a new PrintWriter, without automatic line flushing, with the + * specified file name and charset. This convenience constructor creates + * the necessary intermediate {@link java.io.OutputStreamWriter + * OutputStreamWriter}, which will encode characters using the provided + * charset. + * + * @param fileName + * The name of the file to use as the destination of this writer. + * If the file exists then it will be truncated to zero size; + * otherwise, a new file will be created. The output will be + * written to the file and is buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @throws IOException + * if an I/O error occurs while opening or creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(fileName)} denies write + * access to the file + * + * @since 10 + */ + public PrintWriter(String fileName, Charset charset) throws IOException { + this(Objects.requireNonNull(charset, "charset"), new File(fileName)); + } + /** * Creates a new PrintWriter, without automatic line flushing, with the * specified file. This convenience constructor creates the necessary @@ -295,6 +349,36 @@ public class PrintWriter extends Writer { this(toCharset(csn), file); } + /** + * Creates a new PrintWriter, without automatic line flushing, with the + * specified file and charset. This convenience constructor creates the + * necessary intermediate {@link java.io.OutputStreamWriter + * OutputStreamWriter}, which will encode characters using the provided + * charset. + * + * @param file + * The file to use as the destination of this writer. If the file + * exists then it will be truncated to zero size; otherwise, a new + * file will be created. The output will be written to the file + * and is buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @throws IOException + * if an I/O error occurs while opening or creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(file.getPath())} + * denies write access to the file + * + * @since 10 + */ + public PrintWriter(File file, Charset charset) throws IOException { + this(Objects.requireNonNull(charset, "charset"), file); + } + /** Checks to make sure that the stream has not been closed */ private void ensureOpen() throws IOException { if (out == null) diff --git a/src/java.base/share/classes/java/net/URLDecoder.java b/src/java.base/share/classes/java/net/URLDecoder.java index 0832d9161d6..69330299673 100644 --- a/src/java.base/share/classes/java/net/URLDecoder.java +++ b/src/java.base/share/classes/java/net/URLDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, 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 @@ -26,6 +26,10 @@ package java.net; import java.io.*; +import java.nio.charset.Charset; +import java.nio.charset.IllegalCharsetNameException; +import java.nio.charset.UnsupportedCharsetException; +import java.util.Objects; /** * Utility class for HTML form decoding. This class contains static methods @@ -108,7 +112,43 @@ public class URLDecoder { /** * Decodes an {@code application/x-www-form-urlencoded} string using * a specific encoding scheme. - * The supplied encoding is used to determine + * + *

    + * This method behaves the same as {@linkplain decode(String s, Charset charset)} + * except that it will {@linkplain java.nio.charset.Charset#forName look up the charset} + * using the given encoding name. + * + * @implNote This implementation will throw an {@link java.lang.IllegalArgumentException} + * when illegal strings are encountered. + * + * @param s the {@code String} to decode + * @param enc The name of a supported + * character + * encoding. + * @return the newly decoded {@code String} + * @throws UnsupportedEncodingException + * If character encoding needs to be consulted, but + * named character encoding is not supported + * @see URLEncoder#encode(java.lang.String, java.lang.String) + * @since 1.4 + */ + public static String decode(String s, String enc) throws UnsupportedEncodingException { + if (enc.length() == 0) { + throw new UnsupportedEncodingException ("URLDecoder: empty string enc parameter"); + } + + try { + Charset charset = Charset.forName(enc); + return decode(s, charset); + } catch (IllegalCharsetNameException | UnsupportedCharsetException e) { + throw new UnsupportedEncodingException(enc); + } + } + + /** + * Decodes an {@code application/x-www-form-urlencoded} string using + * a specific {@linkplain java.nio.charset.Charset Charset}. + * The supplied charset is used to determine * what characters are represented by any consecutive sequences of the * form "{@code %xy}". *

    @@ -118,29 +158,25 @@ public class URLDecoder { * UTF-8 should be used. Not doing so may introduce * incompatibilities. * + * @implNote This implementation will throw an {@link java.lang.IllegalArgumentException} + * when illegal strings are encountered. + * * @param s the {@code String} to decode - * @param enc The name of a supported - * character - * encoding. + * @param charset the given charset * @return the newly decoded {@code String} - * @exception UnsupportedEncodingException - * If character encoding needs to be consulted, but - * named character encoding is not supported - * @see URLEncoder#encode(java.lang.String, java.lang.String) - * @since 1.4 + * @throws NullPointerException if {@code s} or {@code charset} is {@code null} + * @throws IllegalArgumentException if the implementation encounters illegal + * characters + * @see URLEncoder#encode(java.lang.String, java.nio.charset.Charset) + * @since 10 */ - public static String decode(String s, String enc) - throws UnsupportedEncodingException{ - + public static String decode(String s, Charset charset) { + Objects.requireNonNull(charset, "Charset"); boolean needToChange = false; int numChars = s.length(); StringBuilder sb = new StringBuilder(numChars > 500 ? numChars / 2 : numChars); int i = 0; - if (enc.length() == 0) { - throw new UnsupportedEncodingException ("URLDecoder: empty string enc parameter"); - } - char c; byte[] bytes = null; while (i < numChars) { @@ -173,7 +209,9 @@ public class URLDecoder { (c=='%')) { int v = Integer.parseInt(s, i + 1, i + 3, 16); if (v < 0) - throw new IllegalArgumentException("URLDecoder: Illegal hex characters in escape (%) pattern - negative value"); + throw new IllegalArgumentException( + "URLDecoder: Illegal hex characters in escape " + + "(%) pattern - negative value"); bytes[pos++] = (byte) v; i+= 3; if (i < numChars) @@ -187,7 +225,7 @@ public class URLDecoder { throw new IllegalArgumentException( "URLDecoder: Incomplete trailing escape (%) pattern"); - sb.append(new String(bytes, 0, pos, enc)); + sb.append(new String(bytes, 0, pos, charset)); } catch (NumberFormatException e) { throw new IllegalArgumentException( "URLDecoder: Illegal hex characters in escape (%) pattern - " diff --git a/src/java.base/share/classes/java/net/URLEncoder.java b/src/java.base/share/classes/java/net/URLEncoder.java index 81eaa957cca..0a14c6b5f42 100644 --- a/src/java.base/share/classes/java/net/URLEncoder.java +++ b/src/java.base/share/classes/java/net/URLEncoder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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,6 +31,7 @@ import java.nio.charset.Charset; import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.UnsupportedCharsetException ; import java.util.BitSet; +import java.util.Objects; import sun.security.action.GetPropertyAction; /** @@ -168,45 +169,61 @@ public class URLEncoder { /** * Translates a string into {@code application/x-www-form-urlencoded} - * format using a specific encoding scheme. This method uses the - * supplied encoding scheme to obtain the bytes for unsafe - * characters. + * format using a specific encoding scheme. *

    - * Note: The - * World Wide Web Consortium Recommendation states that - * UTF-8 should be used. Not doing so may introduce - * incompatibilities. + * This method behaves the same as {@linkplain encode(String s, Charset charset)} + * except that it will {@linkplain java.nio.charset.Charset#forName look up the charset} + * using the given encoding name. * * @param s {@code String} to be translated. * @param enc The name of a supported * character * encoding. * @return the translated {@code String}. - * @exception UnsupportedEncodingException + * @throws UnsupportedEncodingException * If the named encoding is not supported * @see URLDecoder#decode(java.lang.String, java.lang.String) * @since 1.4 */ public static String encode(String s, String enc) throws UnsupportedEncodingException { + if (enc == null) { + throw new NullPointerException("charsetName"); + } + + try { + Charset charset = Charset.forName(enc); + return encode(s, charset); + } catch (IllegalCharsetNameException | UnsupportedCharsetException e) { + throw new UnsupportedEncodingException(enc); + } + } + + /** + * Translates a string into {@code application/x-www-form-urlencoded} + * format using a specific {@linkplain java.nio.charset.Charset Charset}. + * This method uses the supplied charset to obtain the bytes for unsafe + * characters. + *

    + * Note: The + * World Wide Web Consortium Recommendation states that + * UTF-8 should be used. Not doing so may introduce incompatibilities. + * + * @param s {@code String} to be translated. + * @param charset the given charset + * @return the translated {@code String}. + * @throws NullPointerException if {@code s} or {@code charset} is {@code null}. + * @see URLDecoder#decode(java.lang.String, java.nio.charset.Charset) + * @since 10 + */ + public static String encode(String s, Charset charset) { + Objects.requireNonNull(charset, "charset"); boolean needToChange = false; StringBuilder out = new StringBuilder(s.length()); - Charset charset; CharArrayWriter charArrayWriter = new CharArrayWriter(); - if (enc == null) - throw new NullPointerException("charsetName"); - - try { - charset = Charset.forName(enc); - } catch (IllegalCharsetNameException e) { - throw new UnsupportedEncodingException(enc); - } catch (UnsupportedCharsetException e) { - throw new UnsupportedEncodingException(enc); - } - for (int i = 0; i < s.length();) { int c = (int) s.charAt(i); //System.out.println("Examining character: " + c); diff --git a/src/java.base/share/classes/java/nio/channels/Channels.java b/src/java.base/share/classes/java/nio/channels/Channels.java index 2a4254711b3..dba3534053c 100644 --- a/src/java.base/share/classes/java/nio/channels/Channels.java +++ b/src/java.base/share/classes/java/nio/channels/Channels.java @@ -527,7 +527,7 @@ public final class Channels { * behaves in exactly the same way as the expression * *

     {@code
    -     *     Channels.newReader(ch, Charset.forName(csName).newDecoder(), -1)
    +     *     Channels.newReader(ch, Charset.forName(csName))
          * } 
    * * @param ch @@ -549,6 +549,38 @@ public final class Channels { return newReader(ch, Charset.forName(csName).newDecoder(), -1); } + /** + * Constructs a reader that decodes bytes from the given channel according + * to the given charset. + * + *

    An invocation of this method of the form + * + *

     {@code
    +     *     Channels.newReader(ch, charset)
    +     * } 
    + * + * behaves in exactly the same way as the expression + * + *
     {@code
    +     *     Channels.newReader(ch, Charset.forName(csName).newDecoder(), -1)
    +     * } 
    + * + *

    The reader's default action for malformed-input and unmappable-character + * errors is to {@linkplain java.nio.charset.CodingErrorAction#REPORT report} + * them. When more control over the error handling is required, the constructor + * that takes a {@linkplain java.nio.charset.CharsetDecoder} should be used. + * + * @param ch The channel from which bytes will be read + * + * @param charset The charset to be used + * + * @return A new reader + */ + public static Reader newReader(ReadableByteChannel ch, Charset charset) { + Objects.requireNonNull(charset, "charset"); + return newReader(ch, charset.newDecoder(), -1); + } + /** * Constructs a writer that encodes characters using the given encoder and * writes the resulting bytes to the given channel. @@ -595,7 +627,7 @@ public final class Channels { * behaves in exactly the same way as the expression * *

     {@code
    -     *     Channels.newWriter(ch, Charset.forName(csName).newEncoder(), -1)
    +     *     Channels.newWriter(ch, Charset.forName(csName))
          * } 
    * * @param ch @@ -616,4 +648,38 @@ public final class Channels { Objects.requireNonNull(csName, "csName"); return newWriter(ch, Charset.forName(csName).newEncoder(), -1); } + + /** + * Constructs a writer that encodes characters according to the given + * charset and writes the resulting bytes to the given channel. + * + *

    An invocation of this method of the form + * + *

     {@code
    +     *     Channels.newWriter(ch, charset)
    +     * } 
    + * + * behaves in exactly the same way as the expression + * + *
     {@code
    +     *     Channels.newWriter(ch, Charset.forName(csName).newEncoder(), -1)
    +     * } 
    + * + *

    The writer's default action for malformed-input and unmappable-character + * errors is to {@linkplain java.nio.charset.CodingErrorAction#REPORT report} + * them. When more control over the error handling is required, the constructor + * that takes a {@linkplain java.nio.charset.CharsetEncoder} should be used. + * + * @param ch + * The channel to which bytes will be written + * + * @param charset + * The charset to be used + * + * @return A new writer + */ + public static Writer newWriter(WritableByteChannel ch, Charset charset) { + Objects.requireNonNull(charset, "charset"); + return newWriter(ch, charset.newEncoder(), -1); +} } diff --git a/src/java.base/share/classes/java/util/Formatter.java b/src/java.base/share/classes/java/util/Formatter.java index 3c2abe2bcfb..9bbf068489b 100644 --- a/src/java.base/share/classes/java/util/Formatter.java +++ b/src/java.base/share/classes/java/util/Formatter.java @@ -2136,6 +2136,39 @@ public final class Formatter implements Closeable, Flushable { this(toCharset(csn), l, new File(fileName)); } + /** + * Constructs a new formatter with the specified file name, charset, and + * locale. + * + * @param fileName + * The name of the file to use as the destination of this + * formatter. If the file exists then it will be truncated to + * zero size; otherwise, a new file will be created. The output + * will be written to the file and is buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @param l + * The {@linkplain java.util.Locale locale} to apply during + * formatting. If {@code l} is {@code null} then no localization + * is applied. + * + * @throws IOException + * if an I/O error occurs while opening or creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(fileName)} denies write + * access to the file + * + * @throws NullPointerException + * if {@code fileName} or {@code charset} is {@code null}. + */ + public Formatter(String fileName, Charset charset, Locale l) throws IOException { + this(Objects.requireNonNull(charset, "charset"), l, new File(fileName)); + } + /** * Constructs a new formatter with the specified file. * @@ -2247,6 +2280,40 @@ public final class Formatter implements Closeable, Flushable { this(toCharset(csn), l, file); } + /** + * Constructs a new formatter with the specified file, charset, and + * locale. + * + * @param file + * The file to use as the destination of this formatter. If the + * file exists then it will be truncated to zero size; otherwise, + * a new file will be created. The output will be written to the + * file and is buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @param l + * The {@linkplain java.util.Locale locale} to apply during + * formatting. If {@code l} is {@code null} then no localization + * is applied. + * + * @throws IOException + * if an I/O error occurs while opening or creating the file + * + * @throws SecurityException + * If a security manager is present and {@link + * SecurityManager#checkWrite checkWrite(file.getPath())} denies + * write access to the file + * + * @throws NullPointerException + * if {@code file} or {@code charset} is {@code null}. + */ + public Formatter(File file, Charset charset, Locale l) throws IOException { + this(Objects.requireNonNull(charset, "charset"), l, file); + } + + /** * Constructs a new formatter with the specified print stream. * @@ -2340,6 +2407,29 @@ public final class Formatter implements Closeable, Flushable { this(l, new BufferedWriter(new OutputStreamWriter(os, csn))); } + /** + * Constructs a new formatter with the specified output stream, charset, + * and locale. + * + * @param os + * The output stream to use as the destination of this formatter. + * The output will be buffered. + * + * @param charset + * A {@linkplain java.nio.charset.Charset charset} + * + * @param l + * The {@linkplain java.util.Locale locale} to apply during + * formatting. If {@code l} is {@code null} then no localization + * is applied. + * + * @throws NullPointerException + * if {@code os} or {@code charset} is {@code null}. + */ + public Formatter(OutputStream os, Charset charset, Locale l) { + this(l, new BufferedWriter(new OutputStreamWriter(os, charset))); + } + private static char getZero(Locale l) { if ((l != null) && !l.equals(Locale.US)) { DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(l); diff --git a/src/java.base/share/classes/java/util/Properties.java b/src/java.base/share/classes/java/util/Properties.java index 1ae9a49a028..9d024694135 100644 --- a/src/java.base/share/classes/java/util/Properties.java +++ b/src/java.base/share/classes/java/util/Properties.java @@ -37,6 +37,10 @@ import java.io.BufferedWriter; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.StreamCorruptedException; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +import java.nio.charset.IllegalCharsetNameException; +import java.nio.charset.UnsupportedCharsetException; import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiConsumer; import java.util.function.BiFunction; @@ -997,6 +1001,11 @@ class Properties extends Hashtable { * *

    The specified stream remains open after this method returns. * + *

    This method behaves the same as + * {@linkplain #storeToXML(OutputStream os, String comment, Charset charset)} + * except that it will {@linkplain java.nio.charset.Charset#forName look up the charset} + * using the given encoding name. + * * @param os the output stream on which to emit the XML document. * @param comment a description of the property list, or {@code null} * if no comment is desired. @@ -1011,20 +1020,67 @@ class Properties extends Hashtable { * @throws NullPointerException if {@code os} is {@code null}, * or if {@code encoding} is {@code null}. * @throws ClassCastException if this {@code Properties} object - * contains any keys or values that are not - * {@code Strings}. + * contains any keys or values that are not {@code Strings}. * @see #loadFromXML(InputStream) * @see Character * Encoding in Entities * @since 1.5 */ public void storeToXML(OutputStream os, String comment, String encoding) - throws IOException - { + throws IOException { Objects.requireNonNull(os); Objects.requireNonNull(encoding); + + try { + Charset charset = Charset.forName(encoding); + storeToXML(os, comment, charset); + } catch (IllegalCharsetNameException | UnsupportedCharsetException e) { + throw new UnsupportedEncodingException(encoding); + } + } + + /** + * Emits an XML document representing all of the properties contained + * in this table, using the specified encoding. + * + *

    The XML document will have the following DOCTYPE declaration: + *

    +     * <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
    +     * 
    + * + *

    If the specified comment is {@code null} then no comment + * will be stored in the document. + * + *

    An implementation is required to support writing of XML documents + * that use the "{@code UTF-8}" or "{@code UTF-16}" encoding. An + * implementation may support additional encodings. + * + *

    Unmappable characters for the specified charset will be encoded as + * numeric character references. + * + *

    The specified stream remains open after this method returns. + * + * @param os the output stream on which to emit the XML document. + * @param comment a description of the property list, or {@code null} + * if no comment is desired. + * @param charset the charset + * + * @throws IOException if writing to the specified output stream + * results in an {@code IOException}. + * @throws NullPointerException if {@code os} or {@code charset} is {@code null}. + * @throws ClassCastException if this {@code Properties} object + * contains any keys or values that are not {@code Strings}. + * @see #loadFromXML(InputStream) + * @see Character + * Encoding in Entities + * @since 10 + */ + public void storeToXML(OutputStream os, String comment, Charset charset) + throws IOException { + Objects.requireNonNull(os, "OutputStream"); + Objects.requireNonNull(charset, "Charset"); PropertiesDefaultHandler handler = new PropertiesDefaultHandler(); - handler.store(this, os, comment, encoding); + handler.store(this, os, comment, charset); } /** diff --git a/src/java.base/share/classes/java/util/Scanner.java b/src/java.base/share/classes/java/util/Scanner.java index 381bcf3e6cc..8ea0826faa7 100644 --- a/src/java.base/share/classes/java/util/Scanner.java +++ b/src/java.base/share/classes/java/util/Scanner.java @@ -575,7 +575,21 @@ public final class Scanner implements Iterator, Closeable { * does not exist */ public Scanner(InputStream source, String charsetName) { - this(makeReadable(Objects.requireNonNull(source, "source"), toCharset(charsetName)), + this(source, toCharset(charsetName)); + } + + /** + * Constructs a new {@code Scanner} that produces values scanned + * from the specified input stream. Bytes from the stream are converted + * into characters using the specified charset. + * + * @param source an input stream to be scanned + * @param charset the charset used to convert bytes from the file + * into characters to be scanned + * @since 10 + */ + public Scanner(InputStream source, Charset charset) { + this(makeReadable(Objects.requireNonNull(source, "source"), charset), WHITESPACE_PATTERN); } @@ -594,7 +608,18 @@ public final class Scanner implements Iterator, Closeable { } } + /* + * This method is added so that null-check on charset can be performed before + * creating InputStream as an existing test required it. + */ + private static Readable makeReadable(Path source, Charset charset) + throws IOException { + Objects.requireNonNull(charset, "charset"); + return makeReadable(Files.newInputStream(source), charset); + } + private static Readable makeReadable(InputStream source, Charset charset) { + Objects.requireNonNull(charset, "charset"); return new InputStreamReader(source, charset); } @@ -629,6 +654,22 @@ public final class Scanner implements Iterator, Closeable { this(Objects.requireNonNull(source), toDecoder(charsetName)); } + /** + * Constructs a new {@code Scanner} that produces values scanned + * from the specified file. Bytes from the file are converted into + * characters using the specified charset. + * + * @param source A file to be scanned + * @param charset The charset used to convert bytes from the file + * into characters to be scanned + * @throws IOException + * if an I/O error occurs opening the source + * @since 10 + */ + public Scanner(File source, Charset charset) throws IOException { + this(Objects.requireNonNull(source), charset.newDecoder()); + } + private Scanner(File source, CharsetDecoder dec) throws FileNotFoundException { @@ -649,6 +690,12 @@ public final class Scanner implements Iterator, Closeable { return Channels.newReader(source, dec, -1); } + private static Readable makeReadable(ReadableByteChannel source, + Charset charset) { + Objects.requireNonNull(charset, "charset"); + return Channels.newReader(source, charset); + } + /** * Constructs a new {@code Scanner} that produces values scanned * from the specified file. Bytes from the file are converted into @@ -688,8 +735,22 @@ public final class Scanner implements Iterator, Closeable { this(Objects.requireNonNull(source), toCharset(charsetName)); } - private Scanner(Path source, Charset charset) throws IOException { - this(makeReadable(Files.newInputStream(source), charset)); + /** + * Constructs a new {@code Scanner} that produces values scanned + * from the specified file. Bytes from the file are converted into + * characters using the specified charset. + * + * @param source + * the path to the file to be scanned + * @param charset + * the charset used to convert bytes from the file + * into characters to be scanned + * @throws IOException + * if an I/O error occurs opening the source + * @since 10 + */ + public Scanner(Path source, Charset charset) throws IOException { + this(makeReadable(source, charset)); } /** @@ -735,6 +796,21 @@ public final class Scanner implements Iterator, Closeable { WHITESPACE_PATTERN); } + /** + * Constructs a new {@code Scanner} that produces values scanned + * from the specified channel. Bytes from the source are converted into + * characters using the specified charset. + * + * @param source a channel to scan + * @param charset the encoding type used to convert bytes from the + * channel into characters to be scanned + * @since 10 + */ + public Scanner(ReadableByteChannel source, Charset charset) { + this(makeReadable(Objects.requireNonNull(source, "source"), charset), + WHITESPACE_PATTERN); + } + // Private primitives used to support scanning private void saveState() { diff --git a/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java b/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java index 932223819ac..b72deaccbee 100644 --- a/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java +++ b/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, 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 @@ -26,6 +26,7 @@ package jdk.internal.util.xml; import java.io.*; +import java.nio.charset.Charset; import java.util.InvalidPropertiesFormatException; import java.util.Map.Entry; import java.util.Properties; @@ -94,11 +95,11 @@ public class PropertiesDefaultHandler extends DefaultHandler { */ } - public void store(Properties props, OutputStream os, String comment, String encoding) + public void store(Properties props, OutputStream os, String comment, Charset charset) throws IOException { try { - XMLStreamWriter writer = new XMLStreamWriterImpl(os, encoding); + XMLStreamWriter writer = new XMLStreamWriterImpl(os, charset); writer.writeStartDocument(); writer.writeDTD(PROPS_DTD_DECL); writer.writeStartElement(ELEMENT_ROOT); diff --git a/src/java.base/share/classes/jdk/internal/util/xml/XMLStreamWriter.java b/src/java.base/share/classes/jdk/internal/util/xml/XMLStreamWriter.java index 494c071d73e..dd6e2ebd78b 100644 --- a/src/java.base/share/classes/jdk/internal/util/xml/XMLStreamWriter.java +++ b/src/java.base/share/classes/jdk/internal/util/xml/XMLStreamWriter.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 @@ -25,6 +25,9 @@ package jdk.internal.util.xml; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + /** * Basic XMLStreamWriter for writing simple XML files such as those * defined in java.util.Properties @@ -38,6 +41,7 @@ public interface XMLStreamWriter { //Defaults the XML version to 1.0, and the encoding to utf-8 public static final String DEFAULT_XML_VERSION = "1.0"; public static final String DEFAULT_ENCODING = "UTF-8"; + public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; /** * Writes a start tag to the output. All writeStartElement methods diff --git a/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java b/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java index 1dc26905c12..d0f5567c29d 100644 --- a/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.java +++ b/src/java.base/share/classes/jdk/internal/util/xml/impl/XMLStreamWriterImpl.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 @@ -66,7 +66,7 @@ public class XMLStreamWriterImpl implements XMLStreamWriter { private int _state = 0; private Element _currentEle; private XMLWriter _writer; - private String _encoding; + private Charset _charset; /** * This flag can be used to turn escaping off for content. It does * not apply to attribute content. @@ -79,26 +79,23 @@ public class XMLStreamWriterImpl implements XMLStreamWriter { System.getProperty("line.separator").toCharArray(); public XMLStreamWriterImpl(OutputStream os) throws XMLStreamException { - this(os, XMLStreamWriter.DEFAULT_ENCODING); + this(os, XMLStreamWriter.DEFAULT_CHARSET); } - public XMLStreamWriterImpl(OutputStream os, String encoding) + public XMLStreamWriterImpl(OutputStream os, Charset cs) throws XMLStreamException { - Charset cs = null; - if (encoding == null) { - _encoding = XMLStreamWriter.DEFAULT_ENCODING; + if (cs == null) { + _charset = XMLStreamWriter.DEFAULT_CHARSET; } else { try { - cs = getCharset(encoding); + _charset = checkCharset(cs); } catch (UnsupportedEncodingException e) { throw new XMLStreamException(e); } - - this._encoding = encoding; } - _writer = new XMLWriter(os, encoding, cs); + _writer = new XMLWriter(os, null, _charset); } /** @@ -108,7 +105,7 @@ public class XMLStreamWriterImpl implements XMLStreamWriter { * @throws XMLStreamException */ public void writeStartDocument() throws XMLStreamException { - writeStartDocument(_encoding, XMLStreamWriter.DEFAULT_XML_VERSION); + writeStartDocument(_charset.name(), XMLStreamWriter.DEFAULT_XML_VERSION); } /** @@ -118,7 +115,7 @@ public class XMLStreamWriterImpl implements XMLStreamWriter { * @throws XMLStreamException */ public void writeStartDocument(String version) throws XMLStreamException { - writeStartDocument(_encoding, version, null); + writeStartDocument(_charset.name(), version, null); } /** @@ -155,7 +152,7 @@ public class XMLStreamWriterImpl implements XMLStreamWriter { _state = STATE_XML_DECL; String enc = encoding; if (enc == null) { - enc = _encoding; + enc = _charset.name(); } else { //check if the encoding is supported try { @@ -564,6 +561,20 @@ public class XMLStreamWriterImpl implements XMLStreamWriter { return cs; } + /** + * Checks for charset support. + * @param charset the specified charset + * @return the charset + * @throws UnsupportedEncodingException if the charset is not supported + */ + private Charset checkCharset(Charset charset) throws UnsupportedEncodingException { + if (charset.name().equalsIgnoreCase("UTF-32")) { + throw new UnsupportedEncodingException("The basic XMLWriter does " + + "not support " + charset.name()); + } + return charset; + } + /* * Start of Internal classes. * diff --git a/test/jdk/java/io/ByteArrayOutputStream/EncodingTest.java b/test/jdk/java/io/ByteArrayOutputStream/EncodingTest.java new file mode 100644 index 00000000000..1a9d8d4c20b --- /dev/null +++ b/test/jdk/java/io/ByteArrayOutputStream/EncodingTest.java @@ -0,0 +1,84 @@ +/* + * 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.io.ByteArrayOutputStream; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the same + * as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + /* + * DataProvider for the toString method test. Provides the following fields: + * byte array, charset name string, charset object + */ + @DataProvider(name = "parameters") + public Object[][] getParameters() throws IOException { + byte[] data = getData(); + return new Object[][]{ + {data, StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8}, + {data, StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1}, + }; + } + + /** + * Verifies that the new overload method that takes a Charset is equivalent to + * the existing one that takes a charset name. + * @param data a byte array + * @param csn the charset name + * @param charset the charset + * @throws Exception if the test fails + */ + @Test(dataProvider = "parameters") + public void test(byte[] data, String csn, Charset charset) throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + baos.write(data); + String str1 = baos.toString(csn); + String str2 = baos.toString(charset); + Assert.assertEquals(str1, str2); + } + + /* + * Returns an array containing a character that's invalid for UTF-8 + * but valid for ISO-8859-1 + */ + byte[] getData() throws IOException { + String str1 = "A string that contains "; + String str2 = " , an invalid character for UTF-8."; + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + baos.write(str1.getBytes()); + baos.write(0xFA); + baos.write(str2.getBytes()); + return baos.toByteArray(); + } +} diff --git a/test/jdk/java/io/PrintStream/EncodingTest.java b/test/jdk/java/io/PrintStream/EncodingTest.java new file mode 100644 index 00000000000..d767b5801d3 --- /dev/null +++ b/test/jdk/java/io/PrintStream/EncodingTest.java @@ -0,0 +1,134 @@ +/* + * 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.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the same + * as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + static String USER_DIR = System.getProperty("user.dir", "."); + static boolean AUTOFLUSH = true; + public static enum ConstructorType { + STRING, + FILE, + OUTPUTSTREAM + } + + /* + * DataProvider fields: + * Type of the constructor, a file to be written with a charset name, + * a file to be written with a charset, charset name, charset. + */ + @DataProvider(name = "parameters") + public Object[][] getParameters() throws IOException { + String csn = StandardCharsets.UTF_8.name(); + Charset charset = StandardCharsets.UTF_8; + File file1 = new File(USER_DIR, "PSCharsetTest1.txt"); + File file2 = new File(USER_DIR, "PSCharsetTest2.txt"); + + return new Object[][]{ + {ConstructorType.STRING, file1, file2, csn, charset}, + {ConstructorType.FILE, file1, file2, csn, charset}, + {ConstructorType.OUTPUTSTREAM, file1, file2, csn, charset} + }; + } + + /** + * Verifies that the overloading constructor behaves the same as the existing + * one. + * @param type the type of the constructor + * @param file1 file1 written with the name of a charset + * @param file2 file2 written with a charset + * @param csn the charset name + * @param charset the charset + * @throws IOException + */ + @Test(dataProvider = "parameters") + public void test(ConstructorType type, File file1, File file2, String csn, Charset charset) + throws Exception { + createFile(getPrintStream(type, file1.getPath(), csn, null)); + createFile(getPrintStream(type, file2.getPath(), null, charset)); + + Assert.assertEquals(Files.readAllLines(Paths.get(file1.getPath()), charset), + Files.readAllLines(Paths.get(file2.getPath()), charset)); + } + + public void createFile(PrintStream out) throws IOException { + out.println("high surrogate"); + out.println(Character.MIN_HIGH_SURROGATE); + out.println("low surrogate"); + out.println(Character.MIN_LOW_SURROGATE); + out.flush(); + out.close(); + } + + PrintStream getPrintStream(ConstructorType type, String path, String csn, Charset charset) + throws IOException { + PrintStream out = null; + if (csn != null) { + switch (type) { + case STRING: + out = new PrintStream(path, csn); + break; + case FILE: + out = new PrintStream(new File(path), csn); + break; + case OUTPUTSTREAM: + FileOutputStream fout = new FileOutputStream(path); + out = new PrintStream(fout, AUTOFLUSH, csn); + break; + } + } else { + switch (type) { + case STRING: + out = new PrintStream(path, charset); + break; + case FILE: + out = new PrintStream(new File(path), charset); + break; + case OUTPUTSTREAM: + FileOutputStream fout = new FileOutputStream(path); + out = new PrintStream(fout, AUTOFLUSH, charset); + break; + } + } + + return out; + } + +} diff --git a/test/jdk/java/io/PrintStream/FailingConstructors.java b/test/jdk/java/io/PrintStream/FailingConstructors.java index 70f04b2ec14..a71adfc8852 100644 --- a/test/jdk/java/io/PrintStream/FailingConstructors.java +++ b/test/jdk/java/io/PrintStream/FailingConstructors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 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 @@ -23,7 +23,7 @@ /** * @test - * @bug 7000511 + * @bug 7000511 8190577 * @summary PrintStream, PrintWriter, Formatter, Scanner leave files open when * exception thrown */ @@ -68,7 +68,7 @@ public class FailingConstructors { check(exists, file); try { - new PrintStream(file, null); + new PrintStream(file, (String)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); @@ -87,7 +87,7 @@ public class FailingConstructors { check(exists, file); try { - new PrintStream(file.getName(), null); + new PrintStream(file.getName(), (String)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); diff --git a/test/jdk/java/io/PrintWriter/EncodingTest.java b/test/jdk/java/io/PrintWriter/EncodingTest.java new file mode 100644 index 00000000000..f02944d9900 --- /dev/null +++ b/test/jdk/java/io/PrintWriter/EncodingTest.java @@ -0,0 +1,135 @@ +/* + * 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.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the same + * as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + static String USER_DIR = System.getProperty("user.dir", "."); + static boolean AUTOFLUSH = true; + public static enum ConstructorType { + STRING, + FILE, + OUTPUTSTREAM + } + + /* + * DataProvider fields: + * Type of the constructor, a file to be written with a charset name, + * a file to be written with a charset, charset name, charset. + */ + @DataProvider(name = "parameters") + public Object[][] getParameters() throws IOException { + String csn = StandardCharsets.UTF_8.name(); + Charset charset = StandardCharsets.UTF_8; + File file1 = new File(USER_DIR, "PWCharsetTest1.txt"); + File file2 = new File(USER_DIR, "PWCharsetTest2.txt"); + + return new Object[][]{ + {ConstructorType.STRING, file1, file2, csn, charset}, + {ConstructorType.FILE, file1, file2, csn, charset}, + {ConstructorType.OUTPUTSTREAM, file1, file2, csn, charset} + }; + } + + /** + * Verifies that the overloading constructor behaves the same as the existing + * one. + * + * @param type the type of the constructor + * @param file1 file1 written with the name of a charset + * @param file2 file2 written with a charset + * @param csn the charset name + * @param charset the charset + * @throws IOException + */ + @Test(dataProvider = "parameters") + public void test(ConstructorType type, File file1, File file2, String csn, Charset charset) + throws Exception { + createFile(getWriter(type, file1.getPath(), csn, null)); + createFile(getWriter(type, file2.getPath(), null, charset)); + + Assert.assertEquals(Files.readAllLines(Paths.get(file1.getPath()), charset), + Files.readAllLines(Paths.get(file2.getPath()), charset)); + } + + void createFile(PrintWriter out) throws IOException { + out.println("high surrogate"); + out.println(Character.MIN_HIGH_SURROGATE); + out.println("low surrogate"); + out.println(Character.MIN_LOW_SURROGATE); + out.flush(); + out.close(); + } + + PrintWriter getWriter(ConstructorType type, String path, String csn, Charset charset) + throws IOException { + PrintWriter out = null; + if (csn != null) { + switch (type) { + case STRING: + out = new PrintWriter(path, csn); + break; + case FILE: + out = new PrintWriter(new File(path), csn); + break; + case OUTPUTSTREAM: + // No corresponding method with charset name + // compare with PrintWriter(path, csn) instead + out = new PrintWriter(path, csn); + break; + } + } else { + switch (type) { + case STRING: + out = new PrintWriter(path, charset); + break; + case FILE: + out = new PrintWriter(new File(path), charset); + break; + case OUTPUTSTREAM: + FileOutputStream fout = new FileOutputStream(path); + out = new PrintWriter(fout, AUTOFLUSH, charset); + break; + } + } + + return out; + } +} diff --git a/test/jdk/java/io/PrintWriter/FailingConstructors.java b/test/jdk/java/io/PrintWriter/FailingConstructors.java index af4fa108473..61659cc635a 100644 --- a/test/jdk/java/io/PrintWriter/FailingConstructors.java +++ b/test/jdk/java/io/PrintWriter/FailingConstructors.java @@ -67,7 +67,7 @@ public class FailingConstructors { check(exists, file); try { - new PrintWriter(file, null); + new PrintWriter(file, (String)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); @@ -86,7 +86,7 @@ public class FailingConstructors { check(exists, file); try { - new PrintWriter(file.getName(), null); + new PrintWriter(file.getName(), (String)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); diff --git a/test/jdk/java/net/URLDecoder/EncodingTest.java b/test/jdk/java/net/URLDecoder/EncodingTest.java new file mode 100644 index 00000000000..b01be15a446 --- /dev/null +++ b/test/jdk/java/net/URLDecoder/EncodingTest.java @@ -0,0 +1,122 @@ +/* + * 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.net.URLDecoder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the + * same as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + public static enum ParameterType { + STRING, + CHARSET + } + + @DataProvider(name = "illegalArgument") + public Object[][] getParameters() { + return new Object[][]{ + {ParameterType.STRING}, + {ParameterType.CHARSET} + }; + } + + @DataProvider(name = "decode") + public Object[][] getDecodeParameters() { + return new Object[][]{ + {"The string \u00FC@foo-bar"}, + // the string from javadoc example + + {""}, // an empty string + + {"x"}, // a string of length 1 + + {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.*"}, + // the string of characters should remain the same + + {charactersRange('\u0000', '\u007F')}, + // a string of characters from 0 to 127 + + {charactersRange('\u0080', '\u00FF')}, + // a string of characters from 128 to 255 + + {"\u0100 \u0101 \u0555 \u07FD \u07FF"}, + // a string of Unicode values can be expressed as 2 bytes + + {"\u8000 \u8001 \uA000 \uFFFD \uFFFF"}, // a string of Unicode values can be expressed as 3 bytes + }; + } + + /** + * Verifies that IAE is thrown when decoding an invalid string using the + * existing method or the new overload method. + * + * @param type the type of the argument, e.g a String charset name or + * charset + */ + @Test(dataProvider = "illegalArgument", expectedExceptions = IllegalArgumentException.class) + public void testIllegalArgument(ParameterType type) throws Exception { + String encoded = URLEncoder.encode("http://www.xyz.com/find?key=\u0100\u0101", + StandardCharsets.UTF_8.name()); + String illegal = "%" + encoded; + String returned; + if (type == ParameterType.STRING) { + returned = URLDecoder.decode(illegal, StandardCharsets.UTF_8.name()); + } else { + returned = URLDecoder.decode(illegal, StandardCharsets.UTF_8); + } + } + + /** + * Verifies that the returned values of decoding with the existing + * and the overload methods match. + * + * @param s the string to be encoded and then decoded with both existing + * and the overload methods. + * @throws Exception + */ + @Test(dataProvider = "decode") + public void decode(String s) throws Exception { + String encoded = URLEncoder.encode(s, StandardCharsets.UTF_8.name()); + String returned1 = URLDecoder.decode(encoded, StandardCharsets.UTF_8.name()); + String returned2 = URLDecoder.decode(encoded, StandardCharsets.UTF_8); + Assert.assertEquals(returned1, returned2); + } + + String charactersRange(char c1, char c2) { + StringBuilder sb = new StringBuilder(c2 - c1); + for (char c = c1; c < c2; c++) { + sb.append(c); + } + + return sb.toString(); + } +} diff --git a/test/jdk/java/net/URLDecoder/URLDecoderArgs.java b/test/jdk/java/net/URLDecoder/URLDecoderArgs.java index f8f6be1465e..30af346efac 100644 --- a/test/jdk/java/net/URLDecoder/URLDecoderArgs.java +++ b/test/jdk/java/net/URLDecoder/URLDecoderArgs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 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 @@ -23,7 +23,7 @@ /** * @test - * @bug 4444194 + * @bug 4444194 8190577 * @summary java.net.URLDecoder.decode(s, enc) treats an empty encoding name as "UTF-8" */ import java.net.URLDecoder; @@ -32,7 +32,7 @@ import java.io.UnsupportedEncodingException; public class URLDecoderArgs { public static void main (String[] args) { try { - String s1 = URLDecoder.decode ("Hello World", null); + String s1 = URLDecoder.decode ("Hello World", (String)null); } catch (UnsupportedEncodingException e) { throw new RuntimeException ("NPE should have been thrown"); } catch (NullPointerException e) { diff --git a/test/jdk/java/net/URLEncoder/EncodingTest.java b/test/jdk/java/net/URLEncoder/EncodingTest.java new file mode 100644 index 00000000000..f1b4f3ce3e9 --- /dev/null +++ b/test/jdk/java/net/URLEncoder/EncodingTest.java @@ -0,0 +1,97 @@ +/* + * 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.net.URLDecoder; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the same + * as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + public static enum ParameterType { + STRING, + CHARSET + } + + @DataProvider(name = "encode") + public Object[][] getDecodeParameters() { + return new Object[][]{ + {"The string \u00FC@foo-bar"}, + // the string from javadoc example + + {""}, // an empty string + + {"x"}, // a string of length 1 + + {"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.*"}, + // the string of characters should remain the same + + {charactersRange('\u0000', '\u007F')}, + // a string of characters from 0 to 127 + + {charactersRange('\u0080', '\u00FF')}, + // a string of characters from 128 to 255 + + {"\u0100 \u0101 \u0555 \u07FD \u07FF"}, + // a string of Unicode values can be expressed as 2 bytes + + {"\u8000 \u8001 \uA000 \uFFFD \uFFFF"}, // a string of Unicode values can be expressed as 3 bytes + }; + } + + /** + * Verifies that the new overload method returns the same result as the + * existing method. + * + * @param s the string to be encoded + * @throws Exception if the test fails + */ + @Test(dataProvider = "encode") + public void encode(String s) throws Exception { + String encoded1 = URLEncoder.encode(s, StandardCharsets.UTF_8.name()); + String encoded2 = URLEncoder.encode(s, StandardCharsets.UTF_8); + Assert.assertEquals(encoded1, encoded2); + + // cross check + String returned1 = URLDecoder.decode(encoded1, StandardCharsets.UTF_8.name()); + String returned2 = URLDecoder.decode(encoded2, StandardCharsets.UTF_8); + Assert.assertEquals(returned1, returned2); + } + + String charactersRange(char c1, char c2) { + StringBuilder sb = new StringBuilder(c2 - c1); + for (char c = c1; c < c2; c++) { + sb.append(c); + } + + return sb.toString(); + } +} diff --git a/test/jdk/java/net/URLEncoder/URLEncoderEncodeArgs.java b/test/jdk/java/net/URLEncoder/URLEncoderEncodeArgs.java index b04d34ebc3f..e5602864416 100644 --- a/test/jdk/java/net/URLEncoder/URLEncoderEncodeArgs.java +++ b/test/jdk/java/net/URLEncoder/URLEncoderEncodeArgs.java @@ -32,7 +32,7 @@ import java.io.UnsupportedEncodingException; public class URLEncoderEncodeArgs { public static void main (String[] args) { try { - String s1 = URLEncoder.encode ("Hello World", null); + String s1 = URLEncoder.encode ("Hello World", (String)null); } catch (UnsupportedEncodingException e) { throw new RuntimeException ("NPE should have been thrown"); } catch (NullPointerException e) { diff --git a/test/jdk/java/nio/channels/Channels/Basic.java b/test/jdk/java/nio/channels/Channels/Basic.java index 932f3123fdc..e7d5244adaa 100644 --- a/test/jdk/java/nio/channels/Channels/Basic.java +++ b/test/jdk/java/nio/channels/Channels/Basic.java @@ -108,13 +108,24 @@ public class Basic { } catch (NullPointerException npe) {} try { - Channels.newReader(rbc, null); + Channels.newReader(rbc, (String)null); failNpeExpected(); } catch (NullPointerException npe) {} try { - Channels.newReader(null, null); + Channels.newReader(null, (String)null); + failNpeExpected(); + } catch (NullPointerException npe) {} + + try { + Channels.newReader(rbc, (Charset)null); + failNpeExpected(); + } catch (NullPointerException npe) {} + + + try { + Channels.newReader(null, (Charset)null); failNpeExpected(); } catch (NullPointerException npe) {} @@ -142,15 +153,24 @@ public class Basic { } catch (NullPointerException npe) {} try { - Channels.newWriter(wbc, null); + Channels.newWriter(wbc, (String)null); failNpeExpected(); } catch (NullPointerException npe) {} try { - Channels.newWriter(null, null); + Channels.newWriter(null, (String)null); failNpeExpected(); } catch (NullPointerException npe) {} + try { + Channels.newWriter(wbc, (Charset)null); + failNpeExpected(); + } catch (NullPointerException npe) {} + + try { + Channels.newWriter(null, (Charset)null); + failNpeExpected(); + } catch (NullPointerException npe) {} try { blah = File.createTempFile("blah", null); diff --git a/test/jdk/java/nio/channels/Channels/EncodingTest.java b/test/jdk/java/nio/channels/Channels/EncodingTest.java new file mode 100644 index 00000000000..1f2530ae41b --- /dev/null +++ b/test/jdk/java/nio/channels/Channels/EncodingTest.java @@ -0,0 +1,266 @@ +/* + * 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.io.ByteArrayOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.nio.channels.WritableByteChannel; +import java.nio.charset.Charset; +import java.nio.charset.MalformedInputException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Paths; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the same + * as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + static final int ITERATIONS = 2; + public static final String CS_UTF8 = StandardCharsets.UTF_8.name(); + public static final String CS_ISO8859 = StandardCharsets.ISO_8859_1.name(); + static String USER_DIR = System.getProperty("user.dir", "."); + + // malformed input: a high surrogate without the low surrogate + static char[] illChars = { + '\u00fa', '\ud800' + }; + + static byte[] data = getData(); + + static byte[] getData() { + try { + String str1 = "A string that contains "; + String str2 = " , an invalid character for UTF-8."; + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + baos.write(str1.getBytes()); + baos.write(0xFA); + baos.write(str2.getBytes()); + return baos.toByteArray(); + } catch (IOException ex) { + return null; //shouldn't happen + } + } + + String testFile = Paths.get(USER_DIR, "channelsEncodingTest.txt").toString(); + String testIllegalInput = Paths.get(USER_DIR, "channelsIllegalInputTest.txt").toString(); + String testIllegalOutput = Paths.get(USER_DIR, "channelsIllegalOutputTest.txt").toString(); + + + /* + * DataProvider for read and write test. + * Writes and reads with the same encoding + */ + @DataProvider(name = "writeAndRead") + public Object[][] getWRParameters() { + return new Object[][]{ + {testFile, StandardCharsets.ISO_8859_1.name(), null, + StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1}, + {testFile, null, StandardCharsets.ISO_8859_1, + StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1}, + {testFile, StandardCharsets.UTF_8.name(), null, + StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8}, + {testFile, null, StandardCharsets.UTF_8, + StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8} + }; + } + + /* + * DataProvider for illegal input test + * Writes the data in ISO8859 and reads with UTF8, expects MalformedInputException + */ + @DataProvider(name = "illegalInput") + public Object[][] getParameters() { + return new Object[][]{ + {testIllegalInput, StandardCharsets.ISO_8859_1.name(), null, StandardCharsets.UTF_8.name(), null}, + {testIllegalInput, StandardCharsets.ISO_8859_1.name(), null, null, StandardCharsets.UTF_8}, + {testIllegalInput, null, StandardCharsets.ISO_8859_1, StandardCharsets.UTF_8.name(), null}, + {testIllegalInput, null, StandardCharsets.ISO_8859_1, null, StandardCharsets.UTF_8}, + }; + } + + /* + * DataProvider for illegal output test + * Attemps to write some malformed chars, expects MalformedInputException + */ + @DataProvider(name = "illegalOutput") + public Object[][] getWriteParameters() { + return new Object[][]{ + {testIllegalOutput, StandardCharsets.UTF_8.name(), null}, + {testIllegalOutput, null, StandardCharsets.UTF_8} + }; + } + + /** + * Verifies that the Readers created with the following methods are + * equivalent: + * newReader(ReadableByteChannel ch, String csName) + * newReader(ReadableByteChannel ch, Charset charset) + * + * The verification follows the following steps: + * Writes a file with a writer created with the specified charset + * Reads it with a reader created with newReader using the same charset; + * Compares that the results are the same. + * + * @param file the file name + * @param csnWriter the charset name for creating the writer + * @param charsetWriter the charset for creating the writer + * @param csnReader the charset name for creating the reader + * @param charsetReader the charset for creating the reader + * @throws Exception + */ + @Test(dataProvider = "writeAndRead") + public void testWriteAndRead(String file, String csnWriter, Charset charsetWriter, + String csnReader, Charset charsetReader) throws Exception { + writeToFile(data, file, csnWriter, charsetWriter); + // read using charset name + String result1 = readFileToString(file, csnReader, null); + String result2 = readFileToString(file, null, charsetReader); + + Assert.assertEquals(result1, result2); + } + + /** + * Verifies that MalformedInputException is thrown when an input byte sequence + * is illegal for given charset that is configured for the reader. + * + * @param file the file to be read + * @param csnWriter the charset name for creating the writer + * @param charsetWriter the charset for creating the writer + * @param csnReader the charset name for creating the reader + * @param charsetReader the charset for creating the reader + * @throws Exception + */ + @Test(dataProvider = "illegalInput", expectedExceptions = MalformedInputException.class) + void testMalformedInput(String file, String csnWriter, Charset charsetWriter, + String csnReader, Charset charsetReader) throws Exception { + writeToFile(data, file, csnWriter, charsetWriter); + readFileToString(file, csnReader, charsetReader); + } + + /** + * Attempts to write illegal characters using a writer created by calling + * the newWriter method and expects a MalformedInputException. + * + * @param fileName the file name + * @param csn the charset name + * @param charset the charset + * @throws Exception + */ + @Test(dataProvider = "illegalOutput", expectedExceptions = MalformedInputException.class) + public void testMalformedOutput(String fileName, String csn, Charset charset) + throws Exception { + try (FileOutputStream fos = new FileOutputStream(fileName); + WritableByteChannel wbc = (WritableByteChannel) fos.getChannel();) { + Writer writer; + if (csn != null) { + writer = Channels.newWriter(wbc, csn); + } else { + writer = Channels.newWriter(wbc, charset); + } + + for (int i = 0; i < ITERATIONS; i++) { + writer.write(illChars); + } + writer.flush(); + writer.close(); + } + } + + /** + * Writes the data to a file using a writer created by calling the newWriter + * method. + * + * @param data the data to be written + * @param fileName the file name + * @param csn the charset name + * @param charset the charset + * @throws Exception + */ + private void writeToFile(byte[] data, String fileName, String csn, Charset charset) throws Exception { + try (FileOutputStream fos = new FileOutputStream(fileName); + WritableByteChannel wbc = (WritableByteChannel) fos.getChannel()) { + Writer writer; + String temp; + if (csn != null) { + writer = Channels.newWriter(wbc, csn); + temp = new String(data, csn); + } else { + writer = Channels.newWriter(wbc, charset); + temp = new String(data, charset); + } + + for (int i = 0; i < ITERATIONS; i++) { + writer.write(temp); + } + writer.flush(); + writer.close(); + } + } + + /** + * Reads a file into a String. + * + * @param file the file to be read + * @param csn the charset name + * @param charset the charset + * @throws Exception + */ + String readFileToString(String file, String csn, Charset charset) throws Exception { + String result; + try (FileInputStream fis = new FileInputStream(file); + ReadableByteChannel rbc = (ReadableByteChannel) fis.getChannel()) { + Reader reader; + if (csn != null) { + reader = Channels.newReader(rbc, csn); + } else { + reader = Channels.newReader(rbc, charset); + } + + int messageSize = data.length * ITERATIONS; + char data1[] = new char[messageSize]; + int totalRead = 0; + int charsRead = 0; + while (totalRead < messageSize) { + totalRead += charsRead; + charsRead = reader.read(data1, totalRead, messageSize - totalRead); + } + + result = new String(data1, 0, totalRead); + reader.close(); + } + + return result; + } +} diff --git a/test/jdk/java/util/Formatter/Constructors.java b/test/jdk/java/util/Formatter/Constructors.java index c542e1bbfb8..c63a8f73f2a 100644 --- a/test/jdk/java/util/Formatter/Constructors.java +++ b/test/jdk/java/util/Formatter/Constructors.java @@ -401,12 +401,23 @@ public class Constructors { } try (PrintStream ps = new PrintStream("foo")) { - new Formatter(ps, null, Locale.UK); - fail("new Formatter(new PrintStream(\"foo\"), null, Locale.UK)"); + new Formatter(ps, (String)null, Locale.UK); + fail("new Formatter(new PrintStream(\"foo\"), (String)null, Locale.UK)"); } catch (NullPointerException x) { pass(); } catch (Exception x) { - fail("new Formatter(new PrintStream(\"foo\"), null, Locale.UK)", + fail("new Formatter(new PrintStream(\"foo\"), (String)null, Locale.UK)", + x); + } + + // Formatter(OutputStream os, Charset charset, Locale l) + try (PrintStream ps = new PrintStream("foo")) { + new Formatter(ps, (Charset)null, Locale.UK); + fail("new Formatter(new PrintStream(\"foo\"), (Charset)null, Locale.UK)"); + } catch (NullPointerException x) { + pass(); + } catch (Exception x) { + fail("new Formatter(new PrintStream(\"foo\"), (Charset)null, Locale.UK)", x); } @@ -438,12 +449,22 @@ public class Constructors { // PrintStream(String fileName, String csn) try { - new PrintStream("foo", null); - fail("new PrintStream(\"foo\", null)"); + new PrintStream("foo", (String)null); + fail("new PrintStream(\"foo\", (String)null)"); } catch (NullPointerException x) { pass(); } catch (Exception x) { - fail("new PrintStream(\"foo\", null)", x); + fail("new PrintStream(\"foo\", (String)null)", x); + } + + // PrintStream(String fileName, Charset charset) + try { + new PrintStream("foo", (Charset)null); + fail("new PrintStream(\"foo\", (Charset)null)"); + } catch (NullPointerException x) { + pass(); + } catch (Exception x) { + fail("new PrintStream(\"foo\", (Charset)null)", x); } // PrintStream(File file) @@ -455,12 +476,22 @@ public class Constructors { // PrintStream(File file, String csn) try { - new PrintStream(new File("foo"), null); - fail("new PrintStream(new File(\"foo\"), null)"); + new PrintStream(new File("foo"), (String)null); + fail("new PrintStream(new File(\"foo\"), (String)null)"); } catch (NullPointerException x) { pass(); } catch (Exception x) { - fail("new PrintStream(new File(\"foo\"), null)", x); + fail("new PrintStream(new File(\"foo\"), (String)null)", x); + } + + // PrintStream(File file, Charset charset) + try { + new PrintStream(new File("foo"), (Charset)null); + fail("new PrintStream(new File(\"foo\"), (Charset)null)"); + } catch (NullPointerException x) { + pass(); + } catch (Exception x) { + fail("new PrintStream(new File(\"foo\"), (Charset)null)", x); } // PrintWriter(String fileName) @@ -472,12 +503,22 @@ public class Constructors { // PrintWriter(String fileName, String csn) try { - new PrintWriter("foo", null); - fail("new PrintWriter(\"foo\"), null"); + new PrintWriter("foo", (String)null); + fail("new PrintWriter(\"foo\"), (String)null"); } catch (NullPointerException x) { pass(); } catch (Exception x) { - fail("new PrintWriter(\"foo\"), null", x); + fail("new PrintWriter(\"foo\"), (String)null", x); + } + + // PrintWriter(String fileName, Charset charset) + try { + new PrintWriter("foo", (Charset)null); + fail("new PrintWriter(\"foo\"), (Charset)null"); + } catch (NullPointerException x) { + pass(); + } catch (Exception x) { + fail("new PrintWriter(\"foo\"), (Charset)null", x); } // PrintWriter(File file) @@ -489,12 +530,22 @@ public class Constructors { // PrintWriter(File file, String csn) try { - new PrintWriter(new File("foo"), null); - fail("new PrintWriter(new File(\"foo\")), null"); + new PrintWriter(new File("foo"), (String)null); + fail("new PrintWriter(new File(\"foo\")), (String)null"); } catch (NullPointerException x) { pass(); } catch (Exception x) { - fail("new PrintWriter(new File(\"foo\")), null", x); + fail("new PrintWriter(new File(\"foo\")), (String)null", x); + } + + // PrintWriter(File file, Charset charset) + try { + new PrintWriter(new File("foo"), (Charset)null); + fail("new PrintWriter(new File(\"foo\")), (Charset)null"); + } catch (NullPointerException x) { + pass(); + } catch (Exception x) { + fail("new PrintWriter(new File(\"foo\")), (Charset)null", x); } if (fail != 0) diff --git a/test/jdk/java/util/Formatter/EncodingTest.java b/test/jdk/java/util/Formatter/EncodingTest.java new file mode 100644 index 00000000000..5e779f2576b --- /dev/null +++ b/test/jdk/java/util/Formatter/EncodingTest.java @@ -0,0 +1,133 @@ +/* + * 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.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Formatter; +import java.util.Locale; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the same + * as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + static String USER_DIR = System.getProperty("user.dir", "."); + + // Charset added only for the 3-parameter constructors + public static enum ConstructorType { + STRING3, + FILE3, + OUTPUTSTREAM3 + } + + @DataProvider(name = "parameters") + public Object[][] getParameters() throws IOException { + Locale l = Locale.getDefault(); + String csn1 = StandardCharsets.ISO_8859_1.name(); + Charset charset1 = StandardCharsets.ISO_8859_1; + String csn2 = StandardCharsets.UTF_8.name(); + Charset charset2 = StandardCharsets.UTF_8; + + File file1 = new File(USER_DIR, "FormatterCharsetTest1.txt"); + File file2 = new File(USER_DIR, "FormatterCharsetTest2.txt"); + + return new Object[][]{ + {ConstructorType.STRING3, file1, file2, csn1, charset1}, + {ConstructorType.FILE3, file1, file2, csn1, charset1}, + {ConstructorType.OUTPUTSTREAM3, file1, file2, csn1, charset1}, + {ConstructorType.STRING3, file1, file2, csn2, charset2}, + {ConstructorType.FILE3, file1, file2, csn2, charset2}, + {ConstructorType.OUTPUTSTREAM3, file1, file2, csn2, charset2}, + }; + } + + /** + * Verifies that the overloading constructor behaves the same as the existing + * one. + * @param type the type of the constructor + * @param file1 file1 written with the name of a charset + * @param file2 file2 written with a charset + * @param csn the charset name + * @param charset the charset + * @throws IOException + */ + @Test(dataProvider = "parameters") + public void testConstructor(ConstructorType type, File file1, File file2, + String csn, Charset charset) throws Exception { + format(getFormatter(type, file1.getPath(), csn, null)); + format(getFormatter(type, file2.getPath(), null, charset)); + Assert.assertEquals(Files.readAllLines(Paths.get(file1.getPath()), charset), + Files.readAllLines(Paths.get(file2.getPath()), charset)); + } + + void format(Formatter formatter) + throws IOException { + formatter.format("abcde \u00FA\u00FB\u00FC\u00FD"); + formatter.format("Java \uff08\u8ba1\u7b97\u673a\u7f16\u7a0b\u8bed\u8a00\uff09"); + formatter.flush(); + formatter.close(); + } + + + Formatter getFormatter(ConstructorType type, String path, String csn, Charset charset) + throws IOException { + Formatter formatter = null; + if (csn != null) { + switch (type) { + case STRING3: + formatter = new Formatter(path, csn, Locale.getDefault()); + break; + case FILE3: + formatter = new Formatter(new File(path), csn, Locale.getDefault()); + break; + case OUTPUTSTREAM3: + formatter = new Formatter(new FileOutputStream(path), csn, Locale.getDefault()); + break; + } + } else { + switch (type) { + case STRING3: + formatter = new Formatter(path, charset, Locale.getDefault()); + break; + case FILE3: + formatter = new Formatter(new File(path), charset, Locale.getDefault()); + break; + case OUTPUTSTREAM3: + formatter = new Formatter(new FileOutputStream(path), charset, Locale.getDefault()); + break; + } + } + return formatter; + } +} diff --git a/test/jdk/java/util/Properties/EncodingTest.java b/test/jdk/java/util/Properties/EncodingTest.java new file mode 100644 index 00000000000..d97730a37c7 --- /dev/null +++ b/test/jdk/java/util/Properties/EncodingTest.java @@ -0,0 +1,79 @@ +/* + * 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.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.Properties; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the + * same as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + @DataProvider(name = "parameters") + public Object[][] getParameters() throws IOException { + return new Object[][]{ + {StandardCharsets.UTF_8.name(), null}, + {null, StandardCharsets.UTF_8},}; + } + + /** + * Tests that properties saved with Properties#storeToXML with either an + * encoding name or a charset can be read with Properties#loadFromXML that + * returns the same Properties object. + */ + @Test(dataProvider = "parameters") + void testLoadAndStore(String encoding, Charset charset) throws IOException { + Properties props = new Properties(); + props.put("k0", "\u6C34"); + props.put("k1", "foo"); + props.put("k2", "bar"); + props.put("k3", "\u0020\u0391\u0392\u0393\u0394\u0395\u0396\u0397"); + props.put("k4", "\u7532\u9aa8\u6587"); + props.put("k5", "/conf/jaxp.properties"); + props.put("k6", "\ud800\u00fa"); + + Properties p; + try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { + if (encoding != null) { + props.storeToXML(out, null, encoding); + } else { + props.storeToXML(out, null, charset); + } p = new Properties(); + try (ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray())) { + p.loadFromXML(in); + } + } + + Assert.assertEquals(props, p); + } +} diff --git a/test/jdk/java/util/Scanner/EncodingTest.java b/test/jdk/java/util/Scanner/EncodingTest.java new file mode 100644 index 00000000000..2d89c438915 --- /dev/null +++ b/test/jdk/java/util/Scanner/EncodingTest.java @@ -0,0 +1,135 @@ +/* + * 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.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Paths; +import java.util.Scanner; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +/** + * @test + * @bug 8183743 + * @summary Test to verify the new overload method with Charset functions the + * same as the existing method that takes a charset name. + * @run testng EncodingTest + */ +public class EncodingTest { + static String USER_DIR = System.getProperty("user.dir", "."); + + public static enum ConstructorType { + FILE, + PATH, + INPUTSTREAM, + READABLEBYTECHANNEL + } + + static final String TEST_STRING = "abc \u0100 \u0101 \u0555 \u07FD \u07FF"; + + @DataProvider(name = "parameters") + public Object[][] getParameters() throws IOException { + String csn = StandardCharsets.UTF_8.name(); + Charset charset = StandardCharsets.UTF_8; + File file1 = new File(USER_DIR, "ScannerCharsetTest1.txt"); + File file2 = new File(USER_DIR, "ScannerCharsetTest2.txt"); + + return new Object[][]{ + {ConstructorType.FILE, file1, file2, csn, charset}, + {ConstructorType.PATH, file1, file2, csn, charset}, + {ConstructorType.INPUTSTREAM, file1, file2, csn, charset}, + {ConstructorType.READABLEBYTECHANNEL, file1, file2, csn, charset},}; + } + + /** + * Verifies that the overloading constructor behaves the same as the + * existing one. + * + * @param type the type of the constructor + * @param file1 file1 written with the name of a charset + * @param file2 file2 written with a charset + * @param csn the charset name + * @param charset the charset + * @throws IOException + */ + @Test(dataProvider = "parameters") + void test(ConstructorType type, File file1, File file2, String csn, Charset charset) + throws Exception { + prepareFile(file1, TEST_STRING); + prepareFile(file2, TEST_STRING); + + try (Scanner s1 = getScanner(type, file1.getPath(), csn, null); + Scanner s2 = getScanner(type, file2.getPath(), null, charset);) { + String result1 = s1.findInLine(TEST_STRING); + String result2 = s2.findInLine(TEST_STRING); + Assert.assertEquals(result1, result2); + } + } + + /* + * Creates a Scanner over the given input file. + */ + Scanner getScanner(ConstructorType type, String file, String csn, Charset charset) + throws Exception { + if (csn != null) { + switch (type) { + case FILE: + return new Scanner(new File(file), csn); + case PATH: + return new Scanner(Paths.get(file), csn); + case INPUTSTREAM: + FileInputStream fis = new FileInputStream(file); + return new Scanner(fis, csn); + case READABLEBYTECHANNEL: + FileInputStream fis1 = new FileInputStream(file); + return new Scanner(fis1.getChannel(), csn); + } + } else { + switch (type) { + case FILE: + return new Scanner(new File(file), charset); + case PATH: + return new Scanner(Paths.get(file), charset); + case INPUTSTREAM: + FileInputStream fis = new FileInputStream(file); + return new Scanner(fis, charset); + case READABLEBYTECHANNEL: + FileInputStream fis1 = new FileInputStream(file); + return new Scanner(fis1.getChannel(), charset); + } + } + + return null; + } + + void prepareFile(File file, String content) throws IOException { + try (FileWriter writer = new FileWriter(file);) { + writer.write(content); + } + } +} diff --git a/test/jdk/java/util/Scanner/FailingConstructors.java b/test/jdk/java/util/Scanner/FailingConstructors.java index d74f5c79cc4..43c78b24dd2 100644 --- a/test/jdk/java/util/Scanner/FailingConstructors.java +++ b/test/jdk/java/util/Scanner/FailingConstructors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 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 @@ -23,7 +23,7 @@ /** * @test - * @bug 7000511 + * @bug 7000511 8190577 * @summary PrintStream, PrintWriter, Formatter, Scanner leave files open when * exception thrown */ @@ -33,6 +33,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.nio.charset.Charset; import java.nio.file.Files; import java.util.Scanner; @@ -65,7 +66,14 @@ public class FailingConstructors { check(exists, file); try { - new Scanner(file, null); + new Scanner(file, (String)null); + fail(); + } catch(FileNotFoundException|NullPointerException e) { + pass(); + } + + try { + new Scanner(file, (Charset)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); @@ -84,7 +92,14 @@ public class FailingConstructors { check(exists, file); try { - new Scanner(file.toPath(), null); + new Scanner(file.toPath(), (String)null); + fail(); + } catch(FileNotFoundException|NullPointerException e) { + pass(); + } + + try { + new Scanner(file.toPath(), (Charset)null); fail(); } catch(FileNotFoundException|NullPointerException e) { pass(); From 0b0340fe0f6ad80e9a4bf0aef09dbd7b4bc8cbd6 Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Tue, 12 Dec 2017 11:31:38 -0800 Subject: [PATCH 16/26] 8193192: jdeps --generate-module-info does not look at module path Reviewed-by: dfuchs --- .../classes/com/sun/tools/jdeps/Graph.java | 27 ++---- .../sun/tools/jdeps/JdepsConfiguration.java | 64 ++++--------- .../com/sun/tools/jdeps/JdepsTask.java | 28 +++--- .../classes/com/sun/tools/jdeps/Profile.java | 3 +- test/langtools/tools/jdeps/lib/JdepsUtil.java | 2 +- .../tools/jdeps/modules/GenModuleInfo.java | 96 ++++++++++++++----- .../tools/jdeps/modules/GenOpenModule.java | 28 +++--- .../jdeps/modules/src/test/jdk/test/Main.java | 41 ++++++++ .../jdeps/modules/src/test/module-info.java | 29 ++++++ 9 files changed, 202 insertions(+), 116 deletions(-) create mode 100644 test/langtools/tools/jdeps/modules/src/test/jdk/test/Main.java create mode 100644 test/langtools/tools/jdeps/modules/src/test/module-info.java diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java index 3c463948c90..fb53653c9f7 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Graph.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 @@ -25,18 +25,14 @@ package com.sun.tools.jdeps; import java.io.PrintWriter; -import java.lang.module.ModuleDescriptor; -import java.lang.module.ModuleFinder; -import java.lang.module.ModuleReference; +import java.util.ArrayDeque; import java.util.Collections; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; import java.util.Map; import java.util.Set; import java.util.function.Consumer; -import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -161,7 +157,7 @@ public final class Graph { * Returns all nodes reachable from the given set of roots. */ public Set dfs(Set roots) { - Deque deque = new LinkedList<>(roots); + Deque deque = new ArrayDeque<>(roots); Set visited = new HashSet<>(); while (!deque.isEmpty()) { T u = deque.pop(); @@ -197,7 +193,7 @@ public final class Graph { if (includeAdjacent && isAdjacent(u, v)) { return true; } - Deque stack = new LinkedList<>(); + Deque stack = new ArrayDeque<>(); Set visited = new HashSet<>(); stack.push(u); while (!stack.isEmpty()) { @@ -292,12 +288,10 @@ public final class Graph { * Topological sort */ static class TopoSorter { - final Deque result = new LinkedList<>(); - final Deque nodes; + final Deque result = new ArrayDeque<>(); final Graph graph; TopoSorter(Graph graph) { this.graph = graph; - this.nodes = new LinkedList<>(graph.nodes); sort(); } @@ -310,17 +304,16 @@ public final class Graph { } private void sort() { - Deque visited = new LinkedList<>(); - Deque done = new LinkedList<>(); - T node; - while ((node = nodes.poll()) != null) { + Set visited = new HashSet<>(); + Set done = new HashSet<>(); + for (T node : graph.nodes()) { if (!visited.contains(node)) { visit(node, visited, done); } } } - private void visit(T node, Deque visited, Deque done) { + private void visit(T node, Set visited, Set done) { if (visited.contains(node)) { if (!done.contains(node)) { throw new IllegalArgumentException("Cyclic detected: " + @@ -330,7 +323,7 @@ public final class Graph { } visited.add(node); graph.edges().get(node).stream() - .forEach(x -> visit(x, visited, done)); + .forEach(x -> visit(x, visited, done)); done.add(node); result.addLast(node); } diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java index 81ad663457b..ebc78306fc8 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsConfiguration.java @@ -38,8 +38,6 @@ import java.io.InputStream; import java.io.UncheckedIOException; import java.lang.module.Configuration; import java.lang.module.ModuleDescriptor; -import java.lang.module.ModuleDescriptor.Exports; -import java.lang.module.ModuleDescriptor.Opens; import java.lang.module.ModuleFinder; import java.lang.module.ModuleReader; import java.lang.module.ModuleReference; @@ -71,6 +69,7 @@ public class JdepsConfiguration implements AutoCloseable { public static final String ALL_MODULE_PATH = "ALL-MODULE-PATH"; public static final String ALL_DEFAULT = "ALL-DEFAULT"; public static final String ALL_SYSTEM = "ALL-SYSTEM"; + public static final String MODULE_INFO = "module-info.class"; private final SystemModuleFinder system; @@ -91,8 +90,7 @@ public class JdepsConfiguration implements AutoCloseable { Set roots, List classpaths, List initialArchives, - boolean allDefaultModules, - boolean allSystemModules, + Set tokens, Runtime.Version version) throws IOException { @@ -104,16 +102,13 @@ public class JdepsConfiguration implements AutoCloseable { // build root set for resolution Set mods = new HashSet<>(roots); - - // add all system modules to the root set for unnamed module or set explicitly - boolean unnamed = !initialArchives.isEmpty() || !classpaths.isEmpty(); - if (allSystemModules || (unnamed && !allDefaultModules)) { + if (tokens.contains(ALL_SYSTEM)) { systemModulePath.findAll().stream() .map(mref -> mref.descriptor().name()) .forEach(mods::add); } - if (allDefaultModules) { + if (tokens.contains(ALL_DEFAULT)) { mods.addAll(systemModulePath.defaultSystemRoots()); } @@ -200,10 +195,10 @@ public class JdepsConfiguration implements AutoCloseable { return m!= null ? Optional.of(m.descriptor()) : Optional.empty(); } - boolean isValidToken(String name) { + public static boolean isToken(String name) { return ALL_MODULE_PATH.equals(name) || - ALL_DEFAULT.equals(name) || - ALL_SYSTEM.equals(name); + ALL_DEFAULT.equals(name) || + ALL_SYSTEM.equals(name); } /** @@ -482,13 +477,10 @@ public class JdepsConfiguration implements AutoCloseable { final List initialArchives = new ArrayList<>(); final List paths = new ArrayList<>(); final List classPaths = new ArrayList<>(); + final Set tokens = new HashSet<>(); ModuleFinder upgradeModulePath; ModuleFinder appModulePath; - boolean addAllApplicationModules; - boolean addAllDefaultModules; - boolean addAllSystemModules; - boolean allModules; Runtime.Version version; public Builder() { @@ -513,34 +505,15 @@ public class JdepsConfiguration implements AutoCloseable { public Builder addmods(Set addmods) { for (String mn : addmods) { - switch (mn) { - case ALL_MODULE_PATH: - this.addAllApplicationModules = true; - break; - case ALL_DEFAULT: - this.addAllDefaultModules = true; - break; - case ALL_SYSTEM: - this.addAllSystemModules = true; - break; - default: - this.rootModules.add(mn); + if (isToken(mn)) { + tokens.add(mn); + } else { + rootModules.add(mn); } } return this; } - /* - * This method is for --check option to find all target modules specified - * in qualified exports. - * - * Include all system modules and modules found on modulepath - */ - public Builder allModules() { - this.allModules = true; - return this; - } - public Builder multiRelease(Runtime.Version version) { this.version = version; return this; @@ -579,7 +552,9 @@ public class JdepsConfiguration implements AutoCloseable { .forEach(rootModules::add); } - if ((addAllApplicationModules || allModules) && appModulePath != null) { + // add all modules to the root set for unnamed module or set explicitly + boolean unnamed = !initialArchives.isEmpty() || !classPaths.isEmpty(); + if ((unnamed || tokens.contains(ALL_MODULE_PATH)) && appModulePath != null) { appModulePath.findAll().stream() .map(mref -> mref.descriptor().name()) .forEach(rootModules::add); @@ -587,7 +562,7 @@ public class JdepsConfiguration implements AutoCloseable { // no archive is specified for analysis // add all system modules as root if --add-modules ALL-SYSTEM is specified - if (addAllSystemModules && rootModules.isEmpty() && + if (tokens.contains(ALL_SYSTEM) && rootModules.isEmpty() && initialArchives.isEmpty() && classPaths.isEmpty()) { systemModulePath.findAll() .stream() @@ -595,13 +570,16 @@ public class JdepsConfiguration implements AutoCloseable { .forEach(rootModules::add); } + if (unnamed && !tokens.contains(ALL_DEFAULT)) { + tokens.add(ALL_SYSTEM); + } + return new JdepsConfiguration(systemModulePath, finder, rootModules, classPaths, initialArchives, - addAllDefaultModules, - allModules, + tokens, version); } diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java index 42d63b94ec5..f7ede3f1329 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/JdepsTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, 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 @@ -540,7 +540,7 @@ class JdepsTask { } boolean run() throws IOException { - try (JdepsConfiguration config = buildConfig(command.allModules())) { + try (JdepsConfiguration config = buildConfig()) { if (!options.nowarning) { // detect split packages config.splitPackages().entrySet() @@ -553,7 +553,7 @@ class JdepsTask { // check if any module specified in --add-modules, --require, and -m is missing options.addmods.stream() - .filter(mn -> !config.isValidToken(mn)) + .filter(mn -> !JdepsConfiguration.isToken(mn)) .forEach(mn -> config.findModule(mn).orElseThrow(() -> new UncheckedBadArgs(new BadArgs("err.module.not.found", mn)))); @@ -561,18 +561,14 @@ class JdepsTask { } } - private JdepsConfiguration buildConfig(boolean allModules) throws IOException { + private JdepsConfiguration buildConfig() throws IOException { JdepsConfiguration.Builder builder = new JdepsConfiguration.Builder(options.systemModulePath); builder.upgradeModulePath(options.upgradeModulePath) .appModulePath(options.modulePath) - .addmods(options.addmods); - - if (allModules) { - // check all system modules in the image - builder.allModules(); - } + .addmods(options.addmods) + .addmods(command.addModules()); if (options.classpath != null) builder.addClassPath(options.classpath); @@ -655,8 +651,8 @@ class JdepsTask { * only. The method should be overridden when this command should * analyze all modules instead. */ - boolean allModules() { - return false; + Set addModules() { + return Set.of(); } @Override @@ -871,8 +867,8 @@ class JdepsTask { * analyzed to find all modules that depend on the modules specified in the * --require option directly and indirectly */ - public boolean allModules() { - return options.requires.size() > 0; + Set addModules() { + return options.requires.size() > 0 ? Set.of("ALL-SYSTEM") : Set.of(); } } @@ -975,8 +971,8 @@ class JdepsTask { /* * Returns true to analyze all modules */ - public boolean allModules() { - return true; + Set addModules() { + return Set.of("ALL-SYSTEM", "ALL-MODULE-PATH"); } } diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java index f466a393e12..6b20035cdfa 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/Profile.java @@ -32,7 +32,6 @@ import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Map; -import java.util.Optional; import java.util.Set; /** @@ -138,7 +137,7 @@ enum Profile { // for debugging public static void main(String[] args) throws IOException { // initialize Profiles - new JdepsConfiguration.Builder().allModules().build(); + new JdepsConfiguration.Builder().addmods(Set.of("ALL-SYSTEM")).build(); // find platform modules if (Profile.getProfileCount() == 0) { diff --git a/test/langtools/tools/jdeps/lib/JdepsUtil.java b/test/langtools/tools/jdeps/lib/JdepsUtil.java index 606a37a5b6c..91950605f3d 100644 --- a/test/langtools/tools/jdeps/lib/JdepsUtil.java +++ b/test/langtools/tools/jdeps/lib/JdepsUtil.java @@ -175,7 +175,7 @@ public final class JdepsUtil { public ModuleAnalyzer getModuleAnalyzer(Set mods) throws IOException { // if --check is set, add to the root set and all modules are observable addmods(mods); - builder.allModules(); + builder.addmods(Set.of("ALL-SYSTEM", "ALL-MODULE-PATH")); return new ModuleAnalyzer(configuration(), pw, mods); } diff --git a/test/langtools/tools/jdeps/modules/GenModuleInfo.java b/test/langtools/tools/jdeps/modules/GenModuleInfo.java index b9e2a397ca7..6d3c405cac9 100644 --- a/test/langtools/tools/jdeps/modules/GenModuleInfo.java +++ b/test/langtools/tools/jdeps/modules/GenModuleInfo.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,11 +23,12 @@ /* * @test - * @summary Tests jdeps --generate-module-info option + * @bug 8193192 * @library ../lib * @build CompilerUtils JdepsUtil JdepsRunner * @modules jdk.jdeps/com.sun.tools.jdeps * @run testng GenModuleInfo + * @summary Tests jdeps --generate-module-info option */ import java.io.File; @@ -58,15 +59,21 @@ public class GenModuleInfo { private static final Path SRC_DIR = Paths.get(TEST_SRC, "src"); private static final Path MODS_DIR = Paths.get("mods"); private static final Path LIBS_DIR = Paths.get("libs"); + private static final Path MLIBS_DIR = Paths.get("mlibs"); private static final Path DEST_DIR = Paths.get("moduleinfosrc"); private static final Path NEW_MODS_DIR = Paths.get("new_mods"); // the names of the modules in this test public static final String UNSUPPORTED = "unsupported"; public static final Set MODULES = Set.of( - "mI", "mII", "mIII", "provider", UNSUPPORTED + "mI", "mII", "mIII", "provider", "test", UNSUPPORTED ); + @BeforeTest + public void setup() throws Exception { + compileAndCreateJars(); + } + /** * Compile modules */ @@ -78,6 +85,21 @@ public class GenModuleInfo { .forEach(mn -> assertTrue(CompilerUtils.compileModule(SRC_DIR, dest, mn))); } + /** + * Create JAR files with no module-info.class + */ + public static void createModularJARs(Path mods, Path dest, String... modules) throws IOException { + Files.createDirectory(dest); + // create modular JAR + for (String mn : modules) { + Path root = mods.resolve(mn); + try (Stream stream = Files.find(root, Integer.MAX_VALUE, + (p, attr) -> { return attr.isRegularFile(); })) { + JdepsUtil.createJar(dest.resolve(mn + ".jar"), root, stream); + } + } + } + /** * Create JAR files with no module-info.class */ @@ -141,18 +163,16 @@ public class GenModuleInfo { } - /** - * Compiles all modules used by the test - */ - @BeforeTest - public void compileAll() throws Exception { + public static void compileAndCreateJars() throws Exception { CompilerUtils.cleanDir(MODS_DIR); CompilerUtils.cleanDir(LIBS_DIR); - CompilerUtils.cleanDir(DEST_DIR); - CompilerUtils.cleanDir(NEW_MODS_DIR); compileModules(MODS_DIR); + // create modular JARs except test + createModularJARs(MODS_DIR, MLIBS_DIR, MODULES.stream().filter(mn -> !mn.equals("test")) + .toArray(String[]::new)); + // create non-modular JARs createJARFiles(MODS_DIR, LIBS_DIR); } @@ -166,35 +186,67 @@ public class GenModuleInfo { @Test public void test() throws IOException { - Files.createDirectory(DEST_DIR); + Path dest = DEST_DIR.resolve("case1"); + Path classes = NEW_MODS_DIR.resolve("case1"); + Files.createDirectories(dest); + Files.createDirectories(classes); Stream files = MODULES.stream() .map(mn -> LIBS_DIR.resolve(mn + ".jar")) .map(Path::toString); Stream options = Stream.concat( - Stream.of("--generate-module-info", DEST_DIR.toString()), files); + Stream.of("--generate-module-info", dest.toString()), files); JdepsRunner.run(options.toArray(String[]::new)); // check file exists MODULES.stream() - .map(mn -> DEST_DIR.resolve(mn).resolve("module-info.java")) + .map(mn -> dest.resolve(mn).resolve("module-info.java")) .forEach(f -> assertTrue(Files.exists(f))); // copy classes to a temporary directory // and then compile new module-info.java - copyClasses(MODS_DIR, NEW_MODS_DIR); - compileNewGenModuleInfo(DEST_DIR, NEW_MODS_DIR); + copyClasses(MODS_DIR, classes); + compileNewGenModuleInfo(dest, classes); for (String mn : MODULES) { - Path p1 = NEW_MODS_DIR.resolve(mn).resolve(MODULE_INFO); - Path p2 = MODS_DIR.resolve(mn).resolve(MODULE_INFO); + verify(mn, classes, MODS_DIR); + } + } - try (InputStream in1 = Files.newInputStream(p1); - InputStream in2 = Files.newInputStream(p2)) { - verify(ModuleDescriptor.read(in1), - ModuleDescriptor.read(in2, () -> packages(MODS_DIR.resolve(mn)))); - } + @Test + public void withModulePath() throws IOException { + Path dest = DEST_DIR.resolve("case2"); + Path classes = NEW_MODS_DIR.resolve("case2"); + Files.createDirectories(dest); + Files.createDirectories(classes); + + JdepsRunner.run("--module-path", MLIBS_DIR.toString(), + "--generate-module-info", dest.toString(), + LIBS_DIR.resolve("test.jar").toString()); + + String name = "test"; + Path gensrc = dest.resolve(name).resolve("module-info.java"); + assertTrue(Files.exists(gensrc)); + + // copy classes to a temporary directory + // and then compile new module-info.java + copyClasses(MODS_DIR.resolve(name), classes.resolve(name)); + assertTrue(CompilerUtils.compileModule(dest, classes, name, "-p", MLIBS_DIR.toString())); + + verify(name, classes, MODS_DIR); + } + + /** + * Verify the dependences from the given module-info.class files + */ + public void verify(String mn, Path mdir1, Path mdir2) throws IOException { + Path p1 = mdir1.resolve(mn).resolve(MODULE_INFO); + Path p2 = mdir2.resolve(mn).resolve(MODULE_INFO); + try (InputStream in1 = Files.newInputStream(p1); + InputStream in2 = Files.newInputStream(p2)) { + verify(ModuleDescriptor.read(in1), + ModuleDescriptor.read(in2, () -> packages(mdir2.resolve(mn)))); } } diff --git a/test/langtools/tools/jdeps/modules/GenOpenModule.java b/test/langtools/tools/jdeps/modules/GenOpenModule.java index b45204bdc10..9d7c1bc1b73 100644 --- a/test/langtools/tools/jdeps/modules/GenOpenModule.java +++ b/test/langtools/tools/jdeps/modules/GenOpenModule.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 @@ -54,41 +54,39 @@ public class GenOpenModule extends GenModuleInfo { private static final Path DEST_DIR = Paths.get("moduleinfosrc"); private static final Path NEW_MODS_DIR = Paths.get("new_mods"); - /** - * Compiles all modules used by the test - */ @BeforeTest - public void compileAll() throws Exception { - - compileModules(MODS_DIR); - - createJARFiles(MODS_DIR, LIBS_DIR); + public void setup() throws Exception { + compileAndCreateJars(); } @Test public void test() throws IOException { + Path dest = DEST_DIR.resolve("open"); + Path classes = NEW_MODS_DIR.resolve("open"); + Files.createDirectories(dest); + Files.createDirectories(classes); + Stream files = MODULES.stream() .map(mn -> LIBS_DIR.resolve(mn + ".jar")) .map(Path::toString); Stream options = Stream.concat( - Stream.of("--generate-open-module", DEST_DIR.toString()), files); + Stream.of("--generate-open-module", dest.toString()), files); JdepsRunner.run(options.toArray(String[]::new)); // check file exists MODULES.stream() - .map(mn -> DEST_DIR.resolve(mn).resolve("module-info.java")) + .map(mn -> dest.resolve(mn).resolve("module-info.java")) .forEach(f -> assertTrue(Files.exists(f))); // copy classes to a temporary directory // and then compile new module-info.java - copyClasses(MODS_DIR, NEW_MODS_DIR); - compileNewGenModuleInfo(DEST_DIR, NEW_MODS_DIR); + copyClasses(MODS_DIR, classes); + compileNewGenModuleInfo(dest, classes); for (String mn : MODULES) { - Path p1 = NEW_MODS_DIR.resolve(mn).resolve(MODULE_INFO); + Path p1 = classes.resolve(mn).resolve(MODULE_INFO); Path p2 = MODS_DIR.resolve(mn).resolve(MODULE_INFO); - try (InputStream in1 = Files.newInputStream(p1); InputStream in2 = Files.newInputStream(p2)) { verify(ModuleDescriptor.read(in1), diff --git a/test/langtools/tools/jdeps/modules/src/test/jdk/test/Main.java b/test/langtools/tools/jdeps/modules/src/test/jdk/test/Main.java new file mode 100644 index 00000000000..3c588c3e1d7 --- /dev/null +++ b/test/langtools/tools/jdeps/modules/src/test/jdk/test/Main.java @@ -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. + */ + +package jdk.test; + +import java.sql.Driver; + +import p1.Goo; +import p2.Bar; +import p3.Foo; + +public class Main { + public static void main(String... args) { + Goo goo = toGoo(new Bar()); + Driver driver = new Foo().getDriver(); + } + + public static Goo toGoo(Bar bar) { + return bar.toGoo(); + } +} diff --git a/test/langtools/tools/jdeps/modules/src/test/module-info.java b/test/langtools/tools/jdeps/modules/src/test/module-info.java new file mode 100644 index 00000000000..28901bec1aa --- /dev/null +++ b/test/langtools/tools/jdeps/modules/src/test/module-info.java @@ -0,0 +1,29 @@ +/* + * 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. + */ + +module test { + requires java.sql; + requires transitive mI; + requires transitive mII; + requires mIII; +} From ddb9702c140e51915d84332f8ed7c8c52f3446c2 Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Tue, 12 Dec 2017 14:16:24 -0800 Subject: [PATCH 17/26] 8193107: javadoc complains about empty module Reviewed-by: jjg --- .../doclets/formats/html/HtmlDoclet.java | 6 +- .../doclets/toolkit/AbstractDoclet.java | 6 +- .../doclet/testModules/TestEmptyModule.java | 71 +++++++++++++++++++ 3 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 test/langtools/jdk/javadoc/doclet/testModules/TestEmptyModule.java diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java index 571dbba5b07..161a5a1d292 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java @@ -117,8 +117,10 @@ public class HtmlDoclet extends AbstractDoclet { SourceToHTMLConverter.convertRoot(configuration, docEnv, DocPaths.SOURCE_OUTPUT); } - - if (configuration.topFile.isEmpty()) { + // Modules with no documented classes may be specified on the + // command line to specify a service provider, allow these. + if (configuration.getSpecifiedModuleElements().isEmpty() && + configuration.topFile.isEmpty()) { messages.error("doclet.No_Non_Deprecated_Classes_To_Document"); return; } diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java index 52ab1feeed1..d90ea3e118f 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java @@ -193,7 +193,11 @@ public abstract class AbstractDoclet implements Doclet { * @throws DocletException if there is a problem while generating the documentation */ private void startGeneration(DocletEnvironment docEnv) throws DocletException { - if (configuration.getIncludedTypeElements().isEmpty()) { + + // Modules with no documented classes may be specified on the + // command line to specify a service provider, allow these. + if (configuration.getSpecifiedModuleElements().isEmpty() && + configuration.getIncludedTypeElements().isEmpty()) { messages.error("doclet.No_Public_Classes_To_Document"); return; } diff --git a/test/langtools/jdk/javadoc/doclet/testModules/TestEmptyModule.java b/test/langtools/jdk/javadoc/doclet/testModules/TestEmptyModule.java new file mode 100644 index 00000000000..7044a07df48 --- /dev/null +++ b/test/langtools/jdk/javadoc/doclet/testModules/TestEmptyModule.java @@ -0,0 +1,71 @@ +/* + * 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 8193107 + * @summary test an empty module + * @modules jdk.javadoc/jdk.javadoc.internal.api + * jdk.javadoc/jdk.javadoc.internal.tool + * jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @library ../lib /tools/lib + * @build toolbox.ToolBox toolbox.ModuleBuilder JavadocTester + * @run main TestEmptyModule + */ + +import toolbox.ModuleBuilder; +import toolbox.ToolBox; + +import java.nio.file.Path; +import java.nio.file.Paths; + +public class TestEmptyModule extends JavadocTester { + + public final ToolBox tb; + public static void main(String... args) throws Exception { + TestEmptyModule tester = new TestEmptyModule(); + tester.runTests(m -> new Object[] { Paths.get(m.getName()) }); + } + + public TestEmptyModule() { + tb = new ToolBox(); + } + + @Test + public void checkEmptyModule(Path base) throws Exception { + ModuleBuilder mb = new ModuleBuilder(tb, "empty") + .comment("module empty."); + mb.write(base); + + javadoc("-d", base.resolve("out").toString(), + "-quiet", + "--module-source-path", base.toString(), + "--module", "empty"); + checkExit(Exit.OK); + + checkOutput("empty-summary.html", true, + "module empty."); + } + +} From ec54b10f21fc0468bab6a99c8316f4cdcfa1c539 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Tue, 12 Dec 2017 15:43:48 -0800 Subject: [PATCH 18/26] 8170495: JNI primitive type mismatch in SocketDispatcher.c:187 Cast DWORD 'written' to a jint before adding to 'count' Reviewed-by: alanb, rriggs --- src/java.base/windows/native/libnio/ch/SocketDispatcher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java.base/windows/native/libnio/ch/SocketDispatcher.c b/src/java.base/windows/native/libnio/ch/SocketDispatcher.c index e8a7186d36f..e2361d4a1ff 100644 --- a/src/java.base/windows/native/libnio/ch/SocketDispatcher.c +++ b/src/java.base/windows/native/libnio/ch/SocketDispatcher.c @@ -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 @@ -179,7 +179,7 @@ Java_sun_nio_ch_SocketDispatcher_write0(JNIEnv *env, jclass clazz, jobject fdo, } } - count += written; + count += (jint)written; address += written; } while ((count < total) && (written == MAX_BUFFER_SIZE)); From ac36725e20cac2314487873309aaf01026aacd8f Mon Sep 17 00:00:00 2001 From: Rajan Halade Date: Tue, 12 Dec 2017 19:20:39 -0800 Subject: [PATCH 19/26] 8189131: Open-source the Oracle JDK Root Certificates Integration for JEP 319: Root Certificates Reviewed-by: mullan, simonis, jnimeh, alanb --- src/java.base/share/lib/security/cacerts | Bin 32 -> 88998 bytes test/jdk/TEST.groups | 3 + .../lib/security/cacerts/VerifyCACerts.java | 314 ++++++++ .../certification/ActalisCA.java | 253 +++++++ .../certification/BuypassCA.java | 291 ++++++++ .../certification/ComodoCA.java | 674 ++++++++++++++++++ .../certification/DTrustCA.java | 280 ++++++++ .../certification/LetsEncryptCA.java | 181 +++++ .../certification/QuoVadisCA.java | 473 ++++++++++++ .../certification/ValidatePathWithParams.java | 354 +++++++++ 10 files changed, 2823 insertions(+) create mode 100644 test/jdk/lib/security/cacerts/VerifyCACerts.java create mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ActalisCA.java create mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/BuypassCA.java create mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ComodoCA.java create mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/DTrustCA.java create mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LetsEncryptCA.java create mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/QuoVadisCA.java create mode 100644 test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ValidatePathWithParams.java diff --git a/src/java.base/share/lib/security/cacerts b/src/java.base/share/lib/security/cacerts index c408465500cb0af9cfd1f7371422ef8899ae6725..606625d12d4e87141f02d20f062dfac365ae647b 100644 GIT binary patch literal 88998 zcmdqJ1z1&E*EURdcXvtdO@oAV2+}Rx-6`D-5>nD7-6bvEA&qp2bXX|zZ@|EF&hwn- zx&HS%*ZX~5ddXTl)?BP{-{YR+9&>&>_;vsW1_lB8Cx7!lo{O=AxudzMjiHskqa&*+ ztD!!bmW7d}HW(PV9_Hf$cra*nW)1)k7#Jihz#kG4;16L1fezNhqBk6xne8DC->7A0 z6S*1R?_9VIWnYU@#$6lz_MZ?CS#rOcYhn^^`!@Vy`|WcXw+!n&@!*T5-~r{+>h6juaU#tDY`_(=)q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+3MQ>i);UK!fvJkUc&0@ zm)kxc-W}dw!{AoGGnkg(h7cXrt zCtde9ru_rALSZCKMLqZjrOE>B#EF)t=UN}=4v{;?QqY23K9J|n2r=;b1(l?^4{U+U fPZg4uJ2N9&g@<(Q@0wiOYG#2@Y{bfoYPtLu0!w|9 literal 32 ncmezO_TO6u1_mY|W_Xm5=la|E{*s%M?mC{^wn--0;QAy0^AQhj diff --git a/test/jdk/TEST.groups b/test/jdk/TEST.groups index b4b1143a727..959e7fc4f61 100644 --- a/test/jdk/TEST.groups +++ b/test/jdk/TEST.groups @@ -202,6 +202,9 @@ jdk_security = \ :jdk_security3 \ :jdk_security4 +jdk_security_infra = \ + security/infra/java/security/cert/CertPathValidator/certification + jdk_text = \ java/text \ sun/text diff --git a/test/jdk/lib/security/cacerts/VerifyCACerts.java b/test/jdk/lib/security/cacerts/VerifyCACerts.java new file mode 100644 index 00000000000..6e104ee4ab4 --- /dev/null +++ b/test/jdk/lib/security/cacerts/VerifyCACerts.java @@ -0,0 +1,314 @@ +/* + * 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 8189131 + * @requires java.runtime.name ~= "OpenJDK.*" + * @summary Check root CA entries in cacerts file + */ +import java.io.File; +import java.io.FileInputStream; +import java.security.KeyStore; +import java.security.MessageDigest; +import java.security.cert.*; +import java.util.*; + +public class VerifyCACerts { + + private static final String CACERTS + = System.getProperty("java.home") + File.separator + "lib" + + File.separator + "security" + File.separator + "cacerts"; + + private static final String BASE = System.getProperty("test.src", "./"); + + // The numbers of certs now. + private static final int COUNT = 80; + + // map of cert alias to SHA-256 fingerprint + private static final Map FINGERPRINT_MAP + = new HashMap() {{ + put("actalisauthenticationrootca [jdk]", + "55:92:60:84:EC:96:3A:64:B9:6E:2A:BE:01:CE:0B:A8:6A:64:FB:FE:BC:C7:AA:B5:AF:C1:55:B3:7F:D7:60:66"); + put("buypassclass2ca [jdk]", + "9A:11:40:25:19:7C:5B:B9:5D:94:E6:3D:55:CD:43:79:08:47:B6:46:B2:3C:DF:11:AD:A4:A0:0E:FF:15:FB:48"); + put("buypassclass3ca [jdk]", + "ED:F7:EB:BC:A2:7A:2A:38:4D:38:7B:7D:40:10:C6:66:E2:ED:B4:84:3E:4C:29:B4:AE:1D:5B:93:32:E6:B2:4D"); + put("camerfirmachambersca [jdk]", + "06:3E:4A:FA:C4:91:DF:D3:32:F3:08:9B:85:42:E9:46:17:D8:93:D7:FE:94:4E:10:A7:93:7E:E2:9D:96:93:C0"); + put("camerfirmachambersignca [jdk]", + "13:63:35:43:93:34:A7:69:80:16:A0:D3:24:DE:72:28:4E:07:9D:7B:52:20:BB:8F:BD:74:78:16:EE:BE:BA:CA"); + put("camerfirmachamberscommerceca [jdk]", + "0C:25:8A:12:A5:67:4A:EF:25:F2:8B:A7:DC:FA:EC:EE:A3:48:E5:41:E6:F5:CC:4E:E6:3B:71:B3:61:60:6A:C3"); + put("certumca [jdk]", + "D8:E0:FE:BC:1D:B2:E3:8D:00:94:0F:37:D2:7D:41:34:4D:99:3E:73:4B:99:D5:65:6D:97:78:D4:D8:14:36:24"); + put("certumtrustednetworkca [jdk]", + "5C:58:46:8D:55:F5:8E:49:7E:74:39:82:D2:B5:00:10:B6:D1:65:37:4A:CF:83:A7:D4:A3:2D:B7:68:C4:40:8E"); + put("chunghwaepkirootca [jdk]", + "C0:A6:F4:DC:63:A2:4B:FD:CF:54:EF:2A:6A:08:2A:0A:72:DE:35:80:3E:2F:F5:FF:52:7A:E5:D8:72:06:DF:D5"); + put("comodorsaca [jdk]", + "52:F0:E1:C4:E5:8E:C6:29:29:1B:60:31:7F:07:46:71:B8:5D:7E:A8:0D:5B:07:27:34:63:53:4B:32:B4:02:34"); + put("comodoaaaca [jdk]", + "D7:A7:A0:FB:5D:7E:27:31:D7:71:E9:48:4E:BC:DE:F7:1D:5F:0C:3E:0A:29:48:78:2B:C8:3E:E0:EA:69:9E:F4"); + put("comodoeccca [jdk]", + "17:93:92:7A:06:14:54:97:89:AD:CE:2F:8F:34:F7:F0:B6:6D:0F:3A:E3:A3:B8:4D:21:EC:15:DB:BA:4F:AD:C7"); + put("usertrustrsaca [jdk]", + "E7:93:C9:B0:2F:D8:AA:13:E2:1C:31:22:8A:CC:B0:81:19:64:3B:74:9C:89:89:64:B1:74:6D:46:C3:D4:CB:D2"); + put("usertrusteccca [jdk]", + "4F:F4:60:D5:4B:9C:86:DA:BF:BC:FC:57:12:E0:40:0D:2B:ED:3F:BC:4D:4F:BD:AA:86:E0:6A:DC:D2:A9:AD:7A"); + put("utnuserfirstobjectca [jdk]", + "6F:FF:78:E4:00:A7:0C:11:01:1C:D8:59:77:C4:59:FB:5A:F9:6A:3D:F0:54:08:20:D0:F4:B8:60:78:75:E5:8F"); + put("utnuserfirstclientauthemailca [jdk]", + "43:F2:57:41:2D:44:0D:62:74:76:97:4F:87:7D:A8:F1:FC:24:44:56:5A:36:7A:E6:0E:DD:C2:7A:41:25:31:AE"); + put("utnuserfirsthardwareca [jdk]", + "6E:A5:47:41:D0:04:66:7E:ED:1B:48:16:63:4A:A3:A7:9E:6E:4B:96:95:0F:82:79:DA:FC:8D:9B:D8:81:21:37"); + put("addtrustclass1ca [jdk]", + "8C:72:09:27:9A:C0:4E:27:5E:16:D0:7F:D3:B7:75:E8:01:54:B5:96:80:46:E3:1F:52:DD:25:76:63:24:E9:A7"); + put("addtrustexternalca [jdk]", + "68:7F:A4:51:38:22:78:FF:F0:C8:B1:1F:8D:43:D5:76:67:1C:6E:B2:BC:EA:B4:13:FB:83:D9:65:D0:6D:2F:F2"); + put("addtrustqualifiedca [jdk]", + "80:95:21:08:05:DB:4B:BC:35:5E:44:28:D8:FD:6E:C2:CD:E3:AB:5F:B9:7A:99:42:98:8E:B8:F4:DC:D0:60:16"); + put("baltimorecybertrustca [jdk]", + "16:AF:57:A9:F6:76:B0:AB:12:60:95:AA:5E:BA:DE:F2:2A:B3:11:19:D6:44:AC:95:CD:4B:93:DB:F3:F2:6A:EB"); + put("baltimorecodesigningca [jdk]", + "A9:15:45:DB:D2:E1:9C:4C:CD:F9:09:AA:71:90:0D:18:C7:35:1C:89:B3:15:F0:F1:3D:05:C1:3A:8F:FB:46:87"); + put("digicertglobalrootca [jdk]", + "43:48:A0:E9:44:4C:78:CB:26:5E:05:8D:5E:89:44:B4:D8:4F:96:62:BD:26:DB:25:7F:89:34:A4:43:C7:01:61"); + put("digicertglobalrootg2 [jdk]", + "CB:3C:CB:B7:60:31:E5:E0:13:8F:8D:D3:9A:23:F9:DE:47:FF:C3:5E:43:C1:14:4C:EA:27:D4:6A:5A:B1:CB:5F"); + put("digicertglobalrootg3 [jdk]", + "31:AD:66:48:F8:10:41:38:C7:38:F3:9E:A4:32:01:33:39:3E:3A:18:CC:02:29:6E:F9:7C:2A:C9:EF:67:31:D0"); + put("digicerttrustedrootg4 [jdk]", + "55:2F:7B:DC:F1:A7:AF:9E:6C:E6:72:01:7F:4F:12:AB:F7:72:40:C7:8E:76:1A:C2:03:D1:D9:D2:0A:C8:99:88"); + put("digicertassuredidrootca [jdk]", + "3E:90:99:B5:01:5E:8F:48:6C:00:BC:EA:9D:11:1E:E7:21:FA:BA:35:5A:89:BC:F1:DF:69:56:1E:3D:C6:32:5C"); + put("digicertassuredidg2 [jdk]", + "7D:05:EB:B6:82:33:9F:8C:94:51:EE:09:4E:EB:FE:FA:79:53:A1:14:ED:B2:F4:49:49:45:2F:AB:7D:2F:C1:85"); + put("digicertassuredidg3 [jdk]", + "7E:37:CB:8B:4C:47:09:0C:AB:36:55:1B:A6:F4:5D:B8:40:68:0F:BA:16:6A:95:2D:B1:00:71:7F:43:05:3F:C2"); + put("digicerthighassuranceevrootca [jdk]", + "74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF"); + put("equifaxsecureca [jdk]", + "08:29:7A:40:47:DB:A2:36:80:C7:31:DB:6E:31:76:53:CA:78:48:E1:BE:BD:3A:0B:01:79:A7:07:F9:2C:F1:78"); + put("equifaxsecureebusinessca1 [jdk]", + "2E:3A:2B:B5:11:25:05:83:6C:A8:96:8B:E2:CB:37:27:CE:9B:56:84:5C:6E:E9:8E:91:85:10:4A:FB:9A:F5:96"); + put("equifaxsecureglobalebusinessca1 [jdk]", + "86:AB:5A:65:71:D3:32:9A:BC:D2:E4:E6:37:66:8B:A8:9C:73:1E:C2:93:B6:CB:A6:0F:71:63:40:A0:91:CE:AE"); + put("geotrustglobalca [jdk]", + "FF:85:6A:2D:25:1D:CD:88:D3:66:56:F4:50:12:67:98:CF:AB:AA:DE:40:79:9C:72:2D:E4:D2:B5:DB:36:A7:3A"); + put("geotrustprimaryca [jdk]", + "37:D5:10:06:C5:12:EA:AB:62:64:21:F1:EC:8C:92:01:3F:C5:F8:2A:E9:8E:E5:33:EB:46:19:B8:DE:B4:D0:6C"); + put("geotrustprimarycag2 [jdk]", + "5E:DB:7A:C4:3B:82:A0:6A:87:61:E8:D7:BE:49:79:EB:F2:61:1F:7D:D7:9B:F9:1C:1C:6B:56:6A:21:9E:D7:66"); + put("geotrustprimarycag3 [jdk]", + "B4:78:B8:12:25:0D:F8:78:63:5C:2A:A7:EC:7D:15:5E:AA:62:5E:E8:29:16:E2:CD:29:43:61:88:6C:D1:FB:D4"); + put("geotrustuniversalca [jdk]", + "A0:45:9B:9F:63:B2:25:59:F5:FA:5D:4C:6D:B3:F9:F7:2F:F1:93:42:03:35:78:F0:73:BF:1D:1B:46:CB:B9:12"); + put("gtecybertrustglobalca [jdk]", + "A5:31:25:18:8D:21:10:AA:96:4B:02:C7:B7:C6:DA:32:03:17:08:94:E5:FB:71:FF:FB:66:67:D5:E6:81:0A:36"); + put("thawteprimaryrootca [jdk]", + "8D:72:2F:81:A9:C1:13:C0:79:1D:F1:36:A2:96:6D:B2:6C:95:0A:97:1D:B4:6B:41:99:F4:EA:54:B7:8B:FB:9F"); + put("thawteprimaryrootcag2 [jdk]", + "A4:31:0D:50:AF:18:A6:44:71:90:37:2A:86:AF:AF:8B:95:1F:FB:43:1D:83:7F:1E:56:88:B4:59:71:ED:15:57"); + put("thawteprimaryrootcag3 [jdk]", + "4B:03:F4:58:07:AD:70:F2:1B:FC:2C:AE:71:C9:FD:E4:60:4C:06:4C:F5:FF:B6:86:BA:E5:DB:AA:D7:FD:D3:4C"); + put("thawtepremiumserverca [jdk]", + "3F:9F:27:D5:83:20:4B:9E:09:C8:A3:D2:06:6C:4B:57:D3:A2:47:9C:36:93:65:08:80:50:56:98:10:5D:BC:E9"); + put("verisigntsaca [jdk]", + "CB:6B:05:D9:E8:E5:7C:D8:82:B1:0B:4D:B7:0D:E4:BB:1D:E4:2B:A4:8A:7B:D0:31:8B:63:5B:F6:E7:78:1A:9D"); + put("verisignclass1ca [jdk]", + "51:84:7C:8C:BD:2E:9A:72:C9:1E:29:2D:2A:E2:47:D7:DE:1E:3F:D2:70:54:7A:20:EF:7D:61:0F:38:B8:84:2C"); + put("verisignclass1g2ca [jdk]", + "34:1D:E9:8B:13:92:AB:F7:F4:AB:90:A9:60:CF:25:D4:BD:6E:C6:5B:9A:51:CE:6E:D0:67:D0:0E:C7:CE:9B:7F"); + put("verisignclass1g3ca [jdk]", + "CB:B5:AF:18:5E:94:2A:24:02:F9:EA:CB:C0:ED:5B:B8:76:EE:A3:C1:22:36:23:D0:04:47:E4:F3:BA:55:4B:65"); + put("verisignclass2g2ca [jdk]", + "3A:43:E2:20:FE:7F:3E:A9:65:3D:1E:21:74:2E:AC:2B:75:C2:0F:D8:98:03:05:BC:50:2C:AF:8C:2D:9B:41:A1"); + put("verisignclass2g3ca [jdk]", + "92:A9:D9:83:3F:E1:94:4D:B3:66:E8:BF:AE:7A:95:B6:48:0C:2D:6C:6C:2A:1B:E6:5D:42:36:B6:08:FC:A1:BB"); + put("verisignclass3ca [jdk]", + "A4:B6:B3:99:6F:C2:F3:06:B3:FD:86:81:BD:63:41:3D:8C:50:09:CC:4F:A3:29:C2:CC:F0:E2:FA:1B:14:03:05"); + put("verisignclass3g2ca [jdk]", + "83:CE:3C:12:29:68:8A:59:3D:48:5F:81:97:3C:0F:91:95:43:1E:DA:37:CC:5E:36:43:0E:79:C7:A8:88:63:8B"); + put("verisignuniversalrootca [jdk]", + "23:99:56:11:27:A5:71:25:DE:8C:EF:EA:61:0D:DF:2F:A0:78:B5:C8:06:7F:4E:82:82:90:BF:B8:60:E8:4B:3C"); + put("verisignclass3g3ca [jdk]", + "EB:04:CF:5E:B1:F3:9A:FA:76:2F:2B:B1:20:F2:96:CB:A5:20:C1:B9:7D:B1:58:95:65:B8:1C:B9:A1:7B:72:44"); + put("verisignclass3g4ca [jdk]", + "69:DD:D7:EA:90:BB:57:C9:3E:13:5D:C8:5E:A6:FC:D5:48:0B:60:32:39:BD:C4:54:FC:75:8B:2A:26:CF:7F:79"); + put("verisignclass3g5ca [jdk]", + "9A:CF:AB:7E:43:C8:D8:80:D0:6B:26:2A:94:DE:EE:E4:B4:65:99:89:C3:D0:CA:F1:9B:AF:64:05:E4:1A:B7:DF"); + put("certplusclass2primaryca [jdk]", + "0F:99:3C:8A:EF:97:BA:AF:56:87:14:0E:D5:9A:D1:82:1B:B4:AF:AC:F0:AA:9A:58:B5:D5:7A:33:8A:3A:FB:CB"); + put("certplusclass3pprimaryca [jdk]", + "CC:C8:94:89:37:1B:AD:11:1C:90:61:9B:EA:24:0A:2E:6D:AD:D9:9F:9F:6E:1D:4D:41:E5:8E:D6:DE:3D:02:85"); + put("keynectisrootca [jdk]", + "42:10:F1:99:49:9A:9A:C3:3C:8D:E0:2B:A6:DB:AA:14:40:8B:DD:8A:6E:32:46:89:C1:92:2D:06:97:15:A3:32"); + put("dtrustclass3ca2 [jdk]", + "49:E7:A4:42:AC:F0:EA:62:87:05:00:54:B5:25:64:B6:50:E4:F4:9E:42:E3:48:D6:AA:38:E0:39:E9:57:B1:C1"); + put("dtrustclass3ca2ev [jdk]", + "EE:C5:49:6B:98:8C:E9:86:25:B9:34:09:2E:EC:29:08:BE:D0:B0:F3:16:C2:D4:73:0C:84:EA:F1:F3:D3:48:81"); + put("identrustdstx3 [jdk]", + "06:87:26:03:31:A7:24:03:D9:09:F1:05:E6:9B:CF:0D:32:E1:BD:24:93:FF:C6:D9:20:6D:11:BC:D6:77:07:39"); + put("identrustpublicca [jdk]", + "30:D0:89:5A:9A:44:8A:26:20:91:63:55:22:D1:F5:20:10:B5:86:7A:CA:E1:2C:78:EF:95:8F:D4:F4:38:9F:2F"); + put("identrustcommercial [jdk]", + "5D:56:49:9B:E4:D2:E0:8B:CF:CA:D0:8A:3E:38:72:3D:50:50:3B:DE:70:69:48:E4:2F:55:60:30:19:E5:28:AE"); + put("letsencryptisrgx1 [jdk]", + "96:BC:EC:06:26:49:76:F3:74:60:77:9A:CF:28:C5:A7:CF:E8:A3:C0:AA:E1:1A:8F:FC:EE:05:C0:BD:DF:08:C6"); + put("luxtrustglobalrootca [jdk]", + "A1:B2:DB:EB:64:E7:06:C6:16:9E:3C:41:18:B2:3B:AA:09:01:8A:84:27:66:6D:8B:F0:E2:88:91:EC:05:19:50"); + put("quovadisrootca [jdk]", + "A4:5E:DE:3B:BB:F0:9C:8A:E1:5C:72:EF:C0:72:68:D6:93:A2:1C:99:6F:D5:1E:67:CA:07:94:60:FD:6D:88:73"); + put("quovadisrootca1g3 [jdk]", + "8A:86:6F:D1:B2:76:B5:7E:57:8E:92:1C:65:82:8A:2B:ED:58:E9:F2:F2:88:05:41:34:B7:F1:F4:BF:C9:CC:74"); + put("quovadisrootca2 [jdk]", + "85:A0:DD:7D:D7:20:AD:B7:FF:05:F8:3D:54:2B:20:9D:C7:FF:45:28:F7:D6:77:B1:83:89:FE:A5:E5:C4:9E:86"); + put("quovadisrootca2g3 [jdk]", + "8F:E4:FB:0A:F9:3A:4D:0D:67:DB:0B:EB:B2:3E:37:C7:1B:F3:25:DC:BC:DD:24:0E:A0:4D:AF:58:B4:7E:18:40"); + put("quovadisrootca3 [jdk]", + "18:F1:FC:7F:20:5D:F8:AD:DD:EB:7F:E0:07:DD:57:E3:AF:37:5A:9C:4D:8D:73:54:6B:F4:F1:FE:D1:E1:8D:35"); + put("quovadisrootca3g3 [jdk]", + "88:EF:81:DE:20:2E:B0:18:45:2E:43:F8:64:72:5C:EA:5F:BD:1F:C2:D9:D2:05:73:07:09:C5:D8:B8:69:0F:46"); + put("secomscrootca1 [jdk]", + "E7:5E:72:ED:9F:56:0E:EC:6E:B4:80:00:73:A4:3F:C3:AD:19:19:5A:39:22:82:01:78:95:97:4A:99:02:6B:6C"); + put("secomscrootca2 [jdk]", + "51:3B:2C:EC:B8:10:D4:CD:E5:DD:85:39:1A:DF:C6:C2:DD:60:D8:7B:B7:36:D2:B5:21:48:4A:A4:7A:0E:BE:F6"); + put("secomevrootca1 [jdk]", + "A2:2D:BA:68:1E:97:37:6E:2D:39:7D:72:8A:AE:3A:9B:62:96:B9:FD:BA:60:BC:2E:11:F6:47:F2:C6:75:FB:37"); + put("swisssigngoldg2ca [jdk]", + "62:DD:0B:E9:B9:F5:0A:16:3E:A0:F8:E7:5C:05:3B:1E:CA:57:EA:55:C8:68:8F:64:7C:68:81:F2:C8:35:7B:95"); + put("swisssignplatinumg2ca [jdk]", + "3B:22:2E:56:67:11:E9:92:30:0D:C0:B1:5A:B9:47:3D:AF:DE:F8:C8:4D:0C:EF:7D:33:17:B4:C1:82:1D:14:36"); + put("swisssignsilverg2ca [jdk]", + "BE:6C:4D:A2:BB:B9:BA:59:B6:F3:93:97:68:37:42:46:C3:C0:05:99:3F:A9:8F:02:0D:1D:ED:BE:D4:8A:81:D5"); + put("soneraclass2ca [jdk]", + "79:08:B4:03:14:C1:38:10:0B:51:8D:07:35:80:7F:FB:FC:F8:51:8A:00:95:33:71:05:BA:38:6B:15:3D:D9:27"); + put("securetrustca [jdk]", + "F1:C1:B5:0A:E5:A2:0D:D8:03:0E:C9:F6:BC:24:82:3D:D3:67:B5:25:57:59:B4:E7:1B:61:FC:E9:F7:37:5D:73"); + put("xrampglobalca [jdk]", + "CE:CD:DC:90:50:99:D8:DA:DF:C5:B1:D2:09:B7:37:CB:E2:C1:8C:FB:2C:10:C0:FF:0B:CF:0D:32:86:FC:1A:A2"); + }}; + + // Ninety days in milliseconds + private static final long NINETY_DAYS = 7776000000L; + + private static boolean atLeastOneFailed = false; + + private static MessageDigest md; + + public static void main(String[] args) throws Exception { + System.out.println("cacerts file: " + CACERTS); + md = MessageDigest.getInstance("SHA-256"); + KeyStore ks = KeyStore.getInstance("JKS"); + ks.load(new FileInputStream(CACERTS), "changeit".toCharArray()); + + // check the count of certs inside + if (ks.size() != COUNT) { + atLeastOneFailed = true; + System.err.println("ERROR: " + ks.size() + " entries, should be " + + COUNT); + } + + // check that all entries in the map are in the keystore + for (String alias : FINGERPRINT_MAP.keySet()) { + if (!ks.isCertificateEntry(alias)) { + atLeastOneFailed = true; + System.err.println("ERROR: " + alias + " is not in cacerts"); + } + } + + // pull all the trusted self-signed CA certs out of the cacerts file + // and verify their signatures + Enumeration aliases = ks.aliases(); + while (aliases.hasMoreElements()) { + String alias = aliases.nextElement(); + System.out.println("\nVerifying " + alias); + if (!ks.isCertificateEntry(alias)) { + atLeastOneFailed = true; + System.err.println("ERROR: " + alias + + " is not a trusted cert entry"); + } + X509Certificate cert = (X509Certificate) ks.getCertificate(alias); + if (!checkFingerprint(alias, cert)) { + atLeastOneFailed = true; + System.err.println("ERROR: " + alias + " SHA-256 fingerprint is incorrect"); + } + // Make sure cert can be self-verified + try { + cert.verify(cert.getPublicKey()); + } catch (Exception e) { + atLeastOneFailed = true; + System.err.println("ERROR: cert cannot be verified:" + + e.getMessage()); + } + + // Make sure cert is not expired or not yet valid + try { + cert.checkValidity(); + } catch (CertificateExpiredException cee) { + atLeastOneFailed = true; + System.err.println("ERROR: cert is expired"); + } catch (CertificateNotYetValidException cne) { + atLeastOneFailed = true; + System.err.println("ERROR: cert is not yet valid"); + } + + // If cert is within 90 days of expiring, mark as failure so + // that cert can be scheduled to be removed/renewed. + Date notAfter = cert.getNotAfter(); + if (notAfter.getTime() - System.currentTimeMillis() < NINETY_DAYS) { + atLeastOneFailed = true; + System.err.println("WARNING: cert will expire within 90 days"); + } + } + + if (atLeastOneFailed) { + throw new Exception("At least one cacert test failed"); + } + } + + private static boolean checkFingerprint(String alias, Certificate cert) + throws Exception { + String fingerprint = FINGERPRINT_MAP.get(alias); + if (fingerprint == null) { + // no entry for alias + return true; + } + System.out.println("Checking fingerprint of " + alias); + byte[] digest = md.digest(cert.getEncoded()); + return fingerprint.equals(toHexString(digest)); + } + + private static String toHexString(byte[] block) { + StringBuilder buf = new StringBuilder(); + int len = block.length; + for (int i = 0; i < len; i++) { + buf.append(String.format("%02X", block[i])); + if (i < len - 1) { + buf.append(":"); + } + } + return buf.toString(); + } +} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ActalisCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ActalisCA.java new file mode 100644 index 00000000000..e76210b16d1 --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ActalisCA.java @@ -0,0 +1,253 @@ +/* + * 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 8189131 + * @summary Interoperability tests with Actalis CA + * @build ValidatePathWithParams + * @run main/othervm/timeout=180 -Djava.security.debug=certpath ActalisCA OCSP + * @run main/othervm/timeout=180 -Djava.security.debug=certpath ActalisCA CRL + */ + + /* + * Obtain test artifacts for Actalis CA from: + * + * Test web site with *active *TLS Server certificate: + * https://ssltest-a.actalis.it:8443 + * If doesn't work then use certificate of https://www.actalis.it + * + * Test web site with *revoked *TLS Server certificate: + * https://ssltest-r.actalis.it:8444 + * + * Test web site with *expired *TLS Server certificate: + * https://ssltest-e.actalis.it:8445 + */ +public class ActalisCA { + + // Owner: CN=Actalis Extended Validation Server CA G1, + // O=Actalis S.p.A./03358520967, L=Milano, ST=Milano, C=IT + // Issuer: CN=Actalis Authentication Root CA, O=Actalis S.p.A./03358520967, + // L=Milan, C=IT + private static final String INT_VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIGTDCCBDSgAwIBAgIIMtYr/GdQGsswDQYJKoZIhvcNAQELBQAwazELMAkGA1UE\n" + + "BhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8w\n" + + "MzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290\n" + + "IENBMB4XDTE1MDUx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2ciO3BpGuRxg=\n" + + "-----END CERTIFICATE-----"; + + // Owner: OID.1.3.6.1.4.1.311.60.2.1.3=IT, STREET=Via S. Clemente 53, + // OID.2.5.4.15=Private Organization, CN=www.actalis.it, + // SERIALNUMBER=03358520967, O=Actalis S.p.A., L=Ponte San Pietro, ST=Bergamo, C=IT + // Issuer: CN=Actalis Extended Validation Server CA G1, + // O=Actalis S.p.A./03358520967, L=Milano, ST=Milano, C=IT + // Serial number: eeeee6d6463bde2 + // Valid from: Sat Jun 17 05:59:17 PDT 2017 until: Mon Jun 17 05:59:17 PDT 2019 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIHwTCCBqmgAwIBAgIIDu7ubWRjveIwDQYJKoZIhvcNAQELBQAwgYcxCzAJBgNV\n" + + "BAYTAklUMQ8wDQYDVQQIDAZNaWxhbm8xDzANBgNVBAcMBk1pbGFubzEjMCEGA1UE\n" + + "CgwaQWN0YWxpcyBTLnAuQS4vMDMzNTg1MjA5NjcxMTAvBgNVBAMMKEFjdGFsaXMg\n" + + "RXh0ZW5kZWQgVmFsaWRhdGlvbiBTZXJ2ZXIgQ0EgRzEwHhcNMTcwNjE3MTI1OTE3\n" + + "WhcNMTkwNjE3MTI1OTE3WjCB0zELMAkGA1UEBhMCSVQxEDAOBgNVBAgMB0Jlcmdh\n" + + "bW8xGTAXBgNVBAcMEFBvbnRlIFNhbiBQaWV0cm8xFzAVBgNVBAoMDkFjdGFsaXMg\n" + + "Uy5wLkEuMRQwEgYDVQQFEwswMzM1ODUyMDk2NzEXMBUGA1UEAwwOd3d3LmFjdGFs\n" + + "aXMuaXQxHTAbBgNVBA8MFFByaXZhdGUgT3JnYW5pemF0aW9uMRswGQYDVQQJDBJW\n" + + "aWEgUy4gQ2xlbWVudGUgNTMxEzARBgsrBgEEAYI3PAIBAxMCSVQwggEiMA0GCSqG\n" + + "SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCwZ3++4pQYGfhXSqin1CKRJ6SOqkTcX3O0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GSp/ySjHMmT8PLO7NvhsT4XDDGTSeIYYpO++tbEIcLcjW9m2k5Gnh\n" + + "kmEenr0hdcpeLgsP3Fsy7JxyQNpL\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=Actalis Authentication CA G3, O=Actalis S.p.A./03358520967, L=Milano, ST=Milano, C=IT + // Issuer: CN=Actalis Authentication Root CA, O=Actalis S.p.A./03358520967, L=Milan, C=IT + // SN: 741d584a 72fc06bc + // Valid from: Wed Feb 12 22:32:23 PST 2014 + // Valid till: Mon Feb 12 22:32:23 PST 2024 + private static final String INT_REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIGTTCCBDWgAwIBAgIIdB1YSnL8BrwwDQYJKoZIhvcNAQELBQAwazELMAkGA1UE\n" + + "BhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8w\n" + + "MzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290\n" + + "IENBMB4XDTE0MDIxMzE1MDIyM1oXDTI0MDIxMzE1MDIyM1owezELMAkGA1UEBhMC\n" + + "SVQxDzANBgNVBAgMBk1pbGFubzEPMA0GA1UEBwwGTWlsYW5vMSMwIQYDVQQKDBpB\n" + + "Y3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzElMCMGA1UEAwwcQWN0YWxpcyBBdXRo\n" + + "ZW50aWNhdGlvbiBDQSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB\n" + + "AMzhDjmhNDym6ze3PegbIKmiavXpAjgVCZ344k1DOtdSCV6k3h3rqfHqFn3mrayA\n" + + "btmJ0NeC886WxUUsJwHJ3bOnNBQZIHxLV+1RVD/6TQqb6/bPJu4rDwEfhbJSmErc\n" + + "29wUJWqxXMhSAWTHi3Pq0vrkx59e5KTEyfB2kHo6InlR72sCCRdtCL9aDuDm8nYK\n" + + "pTSAJr36ultwME5NyCNSyN2JIK0wYbE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FIlazkHFTKGJqoUpsGoc7B9YmPchhE2FPb\n" + + "OZiOCg4Y2Qp43UJfnENgZ3gJFh16juQE1uS8Q/JJI7ZzJfJ/W0uQoDnCprOPUpLF\n" + + "G03e0asFxwQqhL84Jvf7rJZaWvwydHP4hH47nzpHWEGXwfJLXXoO7LHgqVB7K9Ar\n" + + "Zf3pY0S/3Fs+AN/PrEY3Z3rb7ypQLRiot1oJLl8matiGEF4aFL5DDkr9wfRAZ8S8\n" + + "WT69vN68ENGgEwyeZSlQxn+4g6quHRav0fmF2fGnLaq7tteSPVocT7XaMEpkHqNs\n" + + "x1q/PJbr39s/1QVZtS9CrdoCr0QAnBaX//PPB6ansSLFcvEqM9QcV9xQZex88ToX\n" + + "nk3TcHtA0ezWJlCkg626MhdQZrhHbkauHfIGSOmCkn3zHp0BZQ6Vo7UOdRMT7QS7\n" + + "y7AkET9Qmapwh2CFUdCJSXklVRd+06XhhOB37NQU0pGJQJ3xjEPrILZ8kLhW3Tyq\n" + + "Iv30LW7MXZ4yQn/JHEZbuiOOb4R45hsPZxe6gOq/e+sf\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=ssltest-r.actalis.it, O=Actalis S.p.A., L=Ponte San Pietro, ST=Bergamo, C=IT + // Issuer: CN=Actalis Authentication CA G3, O=Actalis S.p.A./03358520967, L=Milano, ST=Milano, C=IT + // SN: 0455de97 5c71c96f + // Valid from: Thu Jan 28 16:23:52 PST 2016 + // Valid till: Mon Jan 28 16:23:52 PST 2019 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIFmDCCBICgAwIBAgIIBFXel1xxyW8wDQYJKoZIhvcNAQELBQAwezELMAkGA1UE\n" + + "BhMCSVQxDzANBgNVBAgMBk1pbGFubzEPMA0GA1UEBwwGTWlsYW5vMSMwIQYDVQQK\n" + + "DBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzElMCMGA1UEAwwcQWN0YWxpcyBB\n" + + "dXRoZW50aWNhdGlvbiBDQ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GFwMDMuYWN0YWxpcy5pdC9jbiUzZEFj\n" + + "dGFsaXMlMjBBdXRoZW50aWNhdGlvbiUyMENBJTIwRzMsbyUzZEFjdGFsaXMlMjBT\n" + + "LnAuQS4lMmYwMzM1ODUyMDk2NyxjJTNkSVQ/Y2VydGlmaWNhdGVSZXZvY2F0aW9u\n" + + "TGlzdDtiaW5hcnkwO6A5oDeGNWh0dHA6Ly9jcmwwMy5hY3RhbGlzLml0L1JlcG9z\n" + + "aXRvcnkvQVVUSC1HMy9nZXRMYXN0Q1JMMA4GA1UdDwEB/wQEAwIFoDAdBgNVHSUE\n" + + "FjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwHwYDVR0RBBgwFoIUc3NsdGVzdC1yLmFj\n" + + "dGFsaXMuaXQwDQYJKoZIhvcNAQELBQADggEBAHZLND53/CZoMlDtfln0ZByCEhoF\n" + + "/XtA9cYy2azRGgS/VY4WUccvg99MM50cwn5GPRsJpoaFXeDrjV3DkOUK1jERzjx4\n" + + "5y83K/AkCGe7uU17aS+tweETizBAfHNj78oHmZDmkDSEY2STaeuHNDJ9ft0v3QTb\n" + + "VW54R5W3OBU7L/sJoEUdRxzGN7vO82PboGvyApMCWDRLKE7bPP4genQtF3XPcaFl\n" + + "ekuSiEVYS+KnM2v9tCWHqw6x7raWHFB9w1kAKNwv0hbEJkeC+a2bCdPwv8hs//sa\n" + + "gUF4p61mIpf+5qmQ6gcZOClPWyrbYdQdfCvKgbEdKhwB0v5KS0NIRRn41SE=\n" + + "-----END CERTIFICATE-----"; + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + boolean ocspEnabled = false; + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + ocspEnabled = true; + } + + // Validate valid + pathValidator.validate(new String[]{VALID, INT_VALID}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Revoked certificate is using SHA1 signature + if (ocspEnabled) { + // Revoked test certificate is expired + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("July 01, 2016"); + } + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT_REVOKED}, + ValidatePathWithParams.Status.REVOKED, + "Fri Jan 29 01:06:42 PST 2016", System.out); + + // reset validation date back to current date + pathValidator.resetValidationDate(); + } +} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/BuypassCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/BuypassCA.java new file mode 100644 index 00000000000..2a1a8461616 --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/BuypassCA.java @@ -0,0 +1,291 @@ +/* + * 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 8189131 + * @summary Interoperability tests with Buypass Class 2 and Class 3 CA + * @build ValidatePathWithParams + * @run main/othervm/timeout=180 -Djava.security.debug=certpath BuypassCA OCSP + * @run main/othervm/timeout=180 -Djava.security.debug=certpath BuypassCA CRL + */ + + /* + * Obtain test artifacts for Buypass Class 2 and Class 3 CAs from: + * Class 2: + * https://valid.domainplus.ca22.ssl.buypass.no/CA2Class2 (valid) + * https://revoked.domainplus.ca22.ssl.buypass.no (revoked) + * + * Class3: + * https://valid.business.ca23.ssl.buypass.no (valid) + * https://revoked.business.ca23.ssl.buypass.no (revoked) + */ +public class BuypassCA { + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + + boolean ocspEnabled = true; + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + ocspEnabled = false; + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + } + + new BuypassClass2().runTest(pathValidator); + new BuypassClass3().runTest(pathValidator, ocspEnabled); + } +} + +class BuypassClass2 { + + // Owner: CN=Buypass Class 2 CA 2, O=Buypass AS-983163327, C=NO + // Issuer: CN=Buypass Class 2 Root CA, O=Buypass AS-983163327, C=NO + private static final String INT_CLASS_2 = "-----BEGIN CERTIFICATE-----\n" + + "MIIFCzCCAvOgAwIBAgIBGDANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" + + "Q2xhc3MgMiBSb290IENBMB4XDTEwMTAyNjEwMTYxN1oXDTMwMTAyNjEwMTYxN1ow\n" + + "SzELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MR0w\n" + + "GwYDVQQDDBRCdXlwYXNzIENsYXNzIDIgQ0EgMjCCASIwDQYJKoZIhvcNAQEBBQAD\n" + + "ggEPADCCAQoCggEBAJyrZ8aWSw0PkdLsyswzK/Ny/A5/uU6EqQ99c6omDMpI+yNo\n" + + "HjUO42ryrATs4YHla+xj+MieWyvz9HYaCnrGL0CE4oX8M7WzD+g8h6tUCS0AakJx\n" + + "dC5PBocUkjQGZ5ZAoF92ms6C99qfQXhHx7lBP/AZT8sCWP0chOf9/cNxCplspYVJ\n" + + "HkQjKN3VGa+JISavCcBqf33ihbPZ+RaLjOTxoaRaWTvl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0QvqeV1yZ/Kf2+W4pa\n" + + "Wor82CuDZNfcf0lje3guk+oZexxpIO57eGJQh9iGLM5dBeEMF7+f5j/1/rGsf6vA\n" + + "KkudpjiTl1v/GoO2zMDTTQVcjEsLSYSV0+s2p5QTXuAXrL0/ER3KQRvewIAtmzFg\n" + + "IaPy7t2TV0olHISRMvaEz4Guh2biuO/N6SP3pkk3dsMxiEVw7Xc+ouCb03Rz3aA=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=valid.domainplus.ca22.ssl.buypass.no + // Issuer: CN=Buypass Class 2 CA 2, O=Buypass AS-983163327, C=NO + // Serial number: f0673c7183c95b38c93 + // Valid from: Mon Jan 25 00:20:55 PST 2016 until: Fri Jan 25 14:59:00 PST 2019 + private static final String VALID_CLASS_2 = "-----BEGIN CERTIFICATE-----\n" + + "MIIEgzCCA2ugAwIBAgIKDwZzxxg8lbOMkzANBgkqhkiG9w0BAQsFADBLMQswCQYD\n" + + "VQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMM\n" + + "FEJ1eXBhc3MgQ2xhc3MgMiBDQSAyMB4XDTE2MDEyNTA4MjA1NVoXDTE5MDEyNTIy\n" + + "NTkwMFowLzEtMCsGA1UEAwwkdmFsaWQuZG9tYWlucGx1cy5jYTIyLnNzbC5idXlw\n" + + "YXNzLm5vMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwhA0eVz8ADqx\n" + + "dcrIZUzCf1n+kaBFyEF4WteUMtM4ta7szTm19f1/O4LRwr+pI5qQDgWHnHMX9sit\n" + + "rKOJPfMRgWrViaQ5y9QCZ4h2BIuDe61XVGkEcUiOoNojLRvDrbjpknI69nb1wbjn\n" + + "fpmCQVjYXoandr7RsexdWG4e+s6rk5Jk/zAUzU3Vbi0lmDJ62Dd+Dk3/IVrSebOp\n" + + "eIDniRX4vjIeucnDDTQ1VqSIN+gYNR/bMxXKFbScGAG+BpgZMwetJB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+ + "f5e7ZlSJ6g==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=revoked.domainplus.ca22.ssl.buypass.no + // Issuer: CN=Buypass Class 2 CA 2, O=Buypass AS-983163327, C=NO + // Serial number: f07a517dfc19ea8bf8f + // Valid from: Mon Jan 25 00:22:09 PST 2016 until: Fri Jan 25 14:59:00 PST 2019 + private static final String REVOKED_CLASS_2 = "-----BEGIN CERTIFICATE-----\n" + + "MIIEhzCCA2+gAwIBAgIKDwelF9/Bnqi/jzANBgkqhkiG9w0BAQsFADBLMQswCQYD\n" + + "VQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMM\n" + + "FEJ1eXBhc3MgQ2xhc3MgMiBDQSAyMB4XDTE2MDEyNTA4MjIwOVoXDTE5MDEyNTIy\n" + + "NTkwMFowMTEvMC0GA1UEAwwmcmV2b2tlZC5kb21haW5wbHVzLmNhMjIuc3NsLmJ1\n" + + "eXBhc3Mubm8wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDjp/5BLRjH\n" + + "03XNNT2YXqg+txclRaUu88Rjbj4oEudFbkGTl+oBhmXX4QjM4WGvgw1AHW7nePWF\n" + + "/j3aR1kWJCl/ZOe097mb0V0dIwK6u6RVx9ERd4ITa/cmUJjy1+D+vCsT0elJY1vf\n" + + "vbwCdaloS7MZDG3wmJGxrUz7fo7t/JdsW481Ymau3xVTQ+45MusPmOE8RZ6nggIQ\n" + + "dZIA00XPhlQwg5ivuPwtcNNZIkk1fkU+5J+RUOI5qHA9zH2s1Hly6PzTATCxSDSi\n" + + "zqAmBH0ehrWqCWiKH5P3J8dCRA6qa2n5pD71CweLrUsbmztkBHUlYKlZ0fP6bGiI\n" + + "ZDMBLL/aFQybAgMBAAGjggGFMIIBgTAJBgNVHRMEAjAAMB8GA1UdIwQYMBaAFJKt\n" + + "ZYmyAA/LUQ3BI+yUTo/BBD93MB0GA1UdDgQWBBQZICByGObE/pJISOcMavbKRl2L\n" + + "+zAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMC\n" + + "MB8GA1UdIAQYMBYwCgYIYIRCARoBAgQwCAYGZ4EMAQIBMDoGA1UdHwQzMDEwL6At\n" + + "oCuGKWh0dHA6Ly9jcmwuYnV5cGFzcy5uby9jcmwvQlBDbGFzczJDQTIuY3JsMDEG\n" + + "A1UdEQQqMCiCJnJldm9rZWQuZG9tYWlucGx1cy5jYTIyLnNzbC5idXlwYXNzLm5v\n" + + "MHUGCCsGAQUFBwEBBGkwZzAuBggrBgEFBQcwAYYiaHR0cDovL29jc3AuYnV5cGFz\n" + + "cy5uby9vY3NwL0JQT2NzcDA1BggrBgEFBQcwAoYpaHR0cDovL2NydC5idXlwYXNz\n" + + "Lm5vL2NydC9CUENsYXNzMkNBMi5jZXIwDQYJKoZIhvcNAQELBQADggEBAAdjMdlP\n" + + "qYNK+YkrqTgQV0dblIazL/cIhMPByjnEkfxew9tDxpcMWafIFKcgM/QxYJG/mzoL\n" + + "sSQ9pzzuGLQX7eAPA3rlWoQBusOeOaC3HQqy73kGStd7H8HPa3m+q47Z6JG0w+Fb\n" + + "rk8odrml+8rAEPLBlldB39xJuNVHjmlyTEDSC4azEXjfV4+kj8uE86sm+AoTt4Ba\n" + + "tEZSbKp70oH63QKBAEHORMM4gXeP+WG276p3kTcL1VUfgQw7vVmGN0C8DjhK4BAC\n" + + "0PUChr8agu0F5YcqpGxjLemMnDrqW+Bi/JYmGhEjWTiLSyYSlvJb1dAFUyPlc958\n" + + "pmOu5xTMEatiPFI=\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID_CLASS_2, INT_CLASS_2}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED_CLASS_2, INT_CLASS_2}, + ValidatePathWithParams.Status.REVOKED, + "Mon Jan 25 00:24:47 PST 2016", System.out); + } +} + +class BuypassClass3 { + + // Owner: CN=Buypass Class 3 CA 2, O=Buypass AS-983163327, C=NO + // Issuer: CN=Buypass Class 3 Root CA, O=Buypass AS-983163327, C=NO + private static final String INT_CLASS_3 = "-----BEGIN CERTIFICATE-----\n" + + "MIIFCzCCAvOgAwIBAgIBGDANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEd\n" + + "MBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3Mg\n" + + "Q2xhc3MgMyBSb290IENBMB4XDTEwMTAyNjA5MTYxN1oXDTMwMTAyNjA5MTYxN1ow\n" + + "SzELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1eXBhc3MgQVMtOTgzMTYzMzI3MR0w\n" + + "GwYDVQQDDBRCdXlwYXNzIENsYXNzIDMgQ0EgMjCCASIwDQYJKoZIhvcNAQEBBQAD\n" + + "ggEPADCCAQoCggEBAL1OFdoURRXuCuwTBJpuCKDE8Euzcg0AeCRGq3VdagbChyCE\n" + + "CQ5vYWwmpHCyFl1b+r2KyWdQBBdG+msAcIYZal5cjZzrTWvbkfiAD/OneMjhqYB0\n" + + "pTQIXbTjpPUMOjFM8waNZcqGJqC9H+Z9NkjK5THAK0oOOfKNPHg1MeImbOHVw0fR\n" + + "48WnNrPpnQDt+SbPFSvw+dACDAybx1XgjMPq7pmZDWbkajOz4yCvrgZm6jvAPeT3\n" + + "qkBFh7zOZ3IZVdfmRjVahx0iXp5TJ1SsrRr/uCiae1O+NR//XDG3dl9j17HsFlhY\n" + + "Rl6EvEfVV0OcW94Ret9uBUF73ANZl0b+gwCXnV0CAwEAAaOB9jCB8zAPBgNVHRMB\n" + + "Af8EBTADAQH/MB8GA1UdIwQYMBaAFEe4zf/lb+74suwvTg75JbCOPGvDMB0GA1Ud\n" + + "DgQWBBQiMC7S+/ZLysC4O9IExOly5pebDDAOBgNVHQ8BAf8EBAMCAQYwEQYDVR0g\n" + + "BAowCDAGBgRVHSAAMD0GA1UdHwQ2MDQwMqAwoC6GLGh0dHA6Ly9jcmwuYnV5cGFz\n" + + "cy5uby9jcmwvQlBDbGFzczNSb290Q0EuY3JsMD4GCCsGAQUFBwEBBDIwMDAuBggr\n" + + "BgEFBQcwAYYiaHR0cDovL29jc3AuYnV5cGFzcy5uby9vY3NwL0JQT2NzcDANBgkq\n" + + "hkiG9w0BAQsFAAOCAgEAaOLyxpj2t9k9Rzkxkcj/teTNOWxBLPZDi+eFx3u7laf2\n" + + "mX/ZUSSE4g7OiKnD7ozWk9Qgocn3rBWGDKsp676RwWV97Elofz73Oebei6P3Gg/9\n" + + "CD8y6rf8xHRxru5d1ZQ1NkWdPwYI38jlt3LaDjJKZjJW7pOPIMRvw1Y1AY3mYgCJ\n" + + "Qqpw8jgukHIP0454DPzkUXzg/ZVJG0swmFmjYfARleSPidcs5BJx5ngpcUS4745g\n" + + "mN9PQ578+ROIbML4Jx83myivlyTQSPdYSwzSswb1RVBJmiF9qC0B1hivCrs4BATu\n" + + "YeaPV6CiNDr0jGnbxAskz7QDNR6uJSUKX3L9iY2TB/4/5hJ9TZ/YDI6OEG/wVtBz\n" + + "5FkU0ucztyQa4UG1mXR8Zbs/zt9Fj0Xn8f5IM3dB/s/r8c1AFDIcLRUqP/LkI9Wj\n" + + "XovWr79PEJcIfIln0AfzYfBBxCRE+4QHcVhci6p/mbyl2a+Rf8ZGNTiDLaWSZp5x\n" + + "jqdaq5UQaoZK8XQ+JVR0etep/KPgVMXq5Zv16YEb2vjs//RfxT8psDZLe/37+Bs4\n" + + "AG9sdT/bsH7HDQwodTon/HvMmxt4EiU/1Sjco4Fok9VmSE2UVjIghajbbTSKR3LV\n" + + "UuU19x12fKp+htO8L+wVlGgxXb9WvDBNHCe6RmR4jqavmvrAyCPtrx3cXwqGmXA=\n" + + "-----END CERTIFICATE-----"; + + // Owner: SERIALNUMBER=983163327, CN=valid.business.ca23.ssl.buypass.no, + // O=BUYPASS AS, L=OSLO, OID.2.5.4.17=0484, C=NO + // Issuer: CN=Buypass Class 3 CA 2, O=Buypass AS-983163327, C=NO + // Serial number: 97631b91e98293b35c8 + // Valid from: Fri Feb 06 00:57:04 PST 2015 until: Fri Feb 09 14:59:00 PST 2018 + private static final String VALID_CLASS_3 = "-----BEGIN CERTIFICATE-----\n" + + "MIIE1DCCA7ygAwIBAgIKCXYxuR6YKTs1yDANBgkqhkiG9w0BAQsFADBLMQswCQYD\n" + + "VQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMM\n" + + "FEJ1eXBhc3MgQ2xhc3MgMyBDQSAyMB4XDTE1MDIwNjA4NTcwNFoXDTE4MDIwOTIy\n" + + "NTkwMFowgYExCzAJBgNVBAYTAk5PMQ0wCwYDVQQRDAQwNDg0MQ0wCwYDVQQHDARP\n" + + "U0xPMRMwEQYDVQQKDApCVVlQQVNTIEFTMSswKQYDVQQDDCJ2YWxpZC5idXNpbmVz\n" + + "cy5jYTIzLnNzbC5idXlwYXNzLm5vMRIwEAYDVQQFEwk5ODMxNjMzMjcwggEiMA0G\n" + + "CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCbahUoF2A7upqIxDQKraZ+aEOzNkHF\n" + + "1fIQEtUMQS1OTB8la7pWsBnv1gk9Ja2ifIrwdSxAjefL3SXR47h4vxUMnufMnkTk\n" + + "PERXft/XR8/jZQZRpznnN/V89ctb8qcVhHCooTIELOBzF9QAmDnawZQogwhDNLNy\n" + + "kLtWsl75X547DS/Z5hsqCqXPyOiFzkHY59uamYu48TF9d7HwQ741H0YhehoxTl/O\n" + + "YqzW2wqYxqhQuCX5IuYER7G/P3G6UAm+VB9aujtWW+TBT9+iWh0aT+C7ezDtREse\n" + + "lwb44svf8S3iW18KlSF8EMT0qwqNpA8njOCQiSgluYD+Uk9E5f8505UzAgMBAAGj\n" + + "ggGBMIIBfTAJBgNVHRMEAjAAMB8GA1UdIwQYMBaAFCIwLtL79kvKwLg70gTE6XLm\n" + + "l5sMMB0GA1UdDgQWBBQncKIaP6HdQV8RIBO+dddWDSKvJjAOBgNVHQ8BAf8EBAMC\n" + + "BaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMB8GA1UdIAQYMBYwCgYI\n" + + "YIRCARoBAwQwCAYGZ4EMAQICMDoGA1UdHwQzMDEwL6AtoCuGKWh0dHA6Ly9jcmwu\n" + + "YnV5cGFzcy5uby9jcmwvQlBDbGFzczNDQTIuY3JsMC0GA1UdEQQmMCSCInZhbGlk\n" + + "LmJ1c2luZXNzLmNhMjMuc3NsLmJ1eXBhc3Mubm8wdQYIKwYBBQUHAQEEaTBnMC4G\n" + + "CCsGAQUFBzABhiJodHRwOi8vb2NzcC5idXlwYXNzLm5vL29jc3AvQlBPY3NwMDUG\n" + + "CCsGAQUFBzAChilodHRwOi8vY3J0LmJ1eXBhc3Mubm8vY3J0L0JQQ2xhc3MzQ0Ey\n" + + "LmNlcjANBgkqhkiG9w0BAQsFAAOCAQEAqeA3IqMPn/az52twbNnimXIhIb7tWj7U\n" + + "NSBqr+httoQvNo7NbtVCgO/fM3/t0YN7rgZfP07QTn7L7CwoddrgHbnuCuFr9UhD\n" + + "df7cfY3cwDhWx+YKgXTkRZpXXrOPqeY2+9gaJlcQCnw66t5EBa4lSBnN0ZtkB4lT\n" + + "ujFP6BAyzZAjRdXWUidtErDWZri1uLmWAP0kQNez2toOcQ0XpbrbL8+nQtvOVOJv\n" + + "b/c8WoaoC14C32mAeC5bx4dQ3mpf3hQv9man1SPjY/rsDsWWjsaJAijl3YPtP2bU\n" + + "JRCCM7qfZWrY8/uBLG2llfjviKV9I6sT76w7TnawPsz+SkDXFm/nwg==\n" + + "-----END CERTIFICATE-----"; + + // Owner: SERIALNUMBER=983163327, CN=revoked.business.ca23.ssl.buypass.no, + // O=BUYPASS AS, L=OSLO, OID.2.5.4.17=0402, C=NO + // Issuer: CN=Buypass Class 3 CA 2, O=Buypass AS-983163327, C=NO + private static final String REVOKED_CLASS_3 = "-----BEGIN CERTIFICATE-----\n" + + "MIIE2DCCA8CgAwIBAgIKARno/wYhPtNtmjANBgkqhkiG9w0BAQsFADBLMQswCQYD\n" + + "VQQGEwJOTzEdMBsGA1UECgwUQnV5cGFzcyBBUy05ODMxNjMzMjcxHTAbBgNVBAMM\n" + + "FEJ1eXBhc3MgQ2xhc3MgMyBDQSAyMB4XDTEzMDIwMTA5MTE0NFoXDTE2MDIwMTA5\n" + + "MTE0NFowgYMxCzAJBgNVBAYTAk5PMQ0wCwYDVQQRDAQwNDAyMQ0wCwYDVQQHDARP\n" + + "U0xPMRMwEQYDVQQKDApCVVlQQVNTIEFTMS0wKwYDVQQDDCRyZXZva2VkLmJ1c2lu\n" + + "ZXNzLmNhMjMuc3NsLmJ1eXBhc3Mubm8xEjAQBgNVBAUTCTk4MzE2MzMyNzCCASIw\n" + + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMmBUI0wNCz4kLikR5wog4QTUEmO\n" + + "XoGgjnQv0cKfDogbewK+0ngdyyR8dZOqSauQTGLlPTpo6DEWpD3Jqrr444MV6Vc1\n" + + "AGWnjk3T+KT5tKl6qJOQq17Y+HEnsTEzCo1kieVygpSu7FBa2OnhHNmLWThhGUEi\n" + + "mLqrEyfjMSb9zacvo06Zr7S8BauLRB3aM5BeMVF7Bj/9f/FvnB/y1cRDLG32WRCx\n" + + "K9IAFwCaJkfWsXx+bnaO4uEQwLFZ96p7L5mr+QNvI6QuweIY1hDM3RDM6HQkGTK9\n" + + "8iHSzGBSCGwOM24Ym3XM5vTbiV5uLno+QEYlJL/+qbYvarbO2gPF+6A6M10CAwEA\n" + + "AaOCAYMwggF/MAkGA1UdEwQCMAAwHwYDVR0jBBgwFoAUIjAu0vv2S8rAuDvSBMTp\n" + + "cuaXmwwwHQYDVR0OBBYEFNI2C2XKZkNRHZrHLkBhCMeDRN0KMA4GA1UdDwEB/wQE\n" + + "AwIFoDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwHwYDVR0gBBgwFjAK\n" + + "BghghEIBGgEDBDAIBgZngQwBAgIwOgYDVR0fBDMwMTAvoC2gK4YpaHR0cDovL2Ny\n" + + "bC5idXlwYXNzLm5vL2NybC9CUENsYXNzM0NBMi5jcmwwLwYDVR0RBCgwJoIkcmV2\n" + + "b2tlZC5idXNpbmVzcy5jYTIzLnNzbC5idXlwYXNzLm5vMHUGCCsGAQUFBwEBBGkw\n" + + "ZzAuBggrBgEFBQcwAYYiaHR0cDovL29jc3AuYnV5cGFzcy5uby9vY3NwL0JQT2Nz\n" + + "cDA1BggrBgEFBQcwAoYpaHR0cDovL2NydC5idXlwYXNzLm5vL2NydC9CUENsYXNz\n" + + "M0NBMi5jZXIwDQYJKoZIhvcNAQELBQADggEBAGNQe9cgrw/mN7bChof205NRS+TH\n" + + "A8f0JcKk1KrPYYW+ilyp6j3My26Sm9a4ZyKRhAS8fCxYUXWzfNvJNFYv2ttLuegl\n" + + "SFfeXjSJJZW9+wC5oRLta++62UTTxXp0Zf5UkMsHZCIjvnk0yGWZa0phyRCH89ca\n" + + "4vfRTOGNTNfX3d0jm/+fm70UNYHKZ/VcxVj0vH2Ij/kDUy7r2cw1gQ65RDUotnTu\n" + + "Yt59y3COyMZeYNMcuoss2XWnedFoD7fwCSkNqVbwjCxGVkL1+ivbWhqlCefaniZX\n" + + "Wy35oP1635RSxHbCMU9msmUO7FS8n1VH2edEC797gduK5pn2aBhy/MW0unU=\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) + throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID_CLASS_3, INT_CLASS_3}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + if (ocspEnabled) { + // Revoked test certificate is expired + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("July 01, 2013"); + } + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED_CLASS_3, INT_CLASS_3}, + ValidatePathWithParams.Status.REVOKED, + "Wed Feb 06 02:56:32 PST 2013", System.out); + } +} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ComodoCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ComodoCA.java new file mode 100644 index 00000000000..6707043b3da --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ComodoCA.java @@ -0,0 +1,674 @@ +/* + * 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 8189131 + * @summary Interoperability tests with Comodo RSA, ECC, userTrust RSA, and + * userTrust ECC CAs + * @build ValidatePathWithParams + * @run main/othervm -Djava.security.debug=certpath ComodoCA OCSP + * @run main/othervm -Djava.security.debug=certpath ComodoCA CRL + */ + + /* + * Obtain TLS test artifacts for Comodo CAs from: + * + * Valid TLS Certificates: + * https://comodorsacertificationauthority-ev.comodoca.com + * https://comodoecccertificationauthority-ev.comodoca.com + * https://usertrustrsacertificationauthority-ev.comodoca.com + * https://usertrustecccertificationauthority-ev.comodoca.com + * + * Revoked TLS Certificates: + * https://comodorsacertificationauthority-ev.comodoca.com:444 + * https://comodoecccertificationauthority-ev.comodoca.com:444 + * https://usertrustrsacertificationauthority-ev.comodoca.com:444 + * https://usertrustecccertificationauthority-ev.comodoca.com:444 + */ +public class ComodoCA { + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + } + + new ComodoRSA().runTest(pathValidator); + new ComodoECC().runTest(pathValidator); + new ComodoUserTrustRSA().runTest(pathValidator); + new ComodoUserTrustECC().runTest(pathValidator); + } +} + +class ComodoRSA { + + // Owner: CN=COMODO RSA Extended Validation Secure Server CA, + // O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB + // Issuer: CN=COMODO RSA Certification Authority, O=COMODO CA Limited, + // L=Salford, ST=Greater Manchester, C=GB + // Serial number: 6a74380d4ebfed435b5a3f7e16abdd8 + // Valid from: Sat Feb 11 16:00:00 PST 2012 until: Thu Feb 11 15:59:59 PST 2027 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIGDjCCA/agAwIBAgIQBqdDgNTr/tQ1taP34Wq92DANBgkqhkiG9w0BAQwFADCB\n" + + "hTELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G\n" + + "A1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNV\n" + + "BAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTIwMjEy\n" + + "MDAwMDAwWhcNMjcwMjExMjM1OTU5WjCBkjELMAkGA1UEBhMCR0IxGzAZBgNVBAgT\n" + + "EkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR\n" + + "Q09NT0RPIENBIExpbWl0ZWQxODA2BgNVBAMTL0NPTU9ETyBSU0EgRXh0ZW5kZWQg\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LMeJPNBy3IX6WK/VJeQT+FhlZ58N/1eLqYVeyqZLsKeyLeCMIs37/3mk\n" + + "jCuN/gI9JN6pXV/kD0fQ22YlPodHDK4ixVAihNftSlka9pOlk7DgG4HyVsTIEFPk\n" + + "1Hax0VtpS3ey4E/EhOfUoFDuPPpE/NBXueEoU/1Tzdy5H3pAvTA/2GzS8+cHnx8i\n" + + "teoiccsq8FZ8/qyo0QYPFBRSTP5kKwxpKrgNUG4+BAe/eiCL+O5lCeHHSQgyPQ0o\n" + + "fkkdt0rvAucNgBfIXOBhYsvss2B5JdoaZXOcOBCgJjqwyBZ9kzEi7nQLiMBciUEA\n" + + "KKlHMd99SUWa9eanRRrSjhMQ34Ovmw2tfn6dNVA0BM7pINae253UqNpktNEvWS5e\n" + + "ojZh1CSggjMziqHRbO9haKPl0latxf1eYusVqHQSTC8xjOnB3xBLAer2VBvNfzu9\n" + + "XJ/B288ByvK6YBIhMe2pZLiySVgXbVrXzYxtvp5/4gJYp9vDLVj2dAZqmvZh+fYA\n" + + "tmnYOosxWd2R5nwnI4fdAw+PKowegwFOAWEMUnNt/AiiuSpm5HZNMaBWm9lTjaK2\n" + + "jwLI5jqmBNFI+8NKAnb9L9K8E7bobTQk+p0pisehKxTxlgBzuRPpwLk6R1YCcYAn\n" + + "pLwltum95OmYdBbxN4SBB7SC\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=COMODO RSA Extended Validation Secure Server CA, + // O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB + // Issuer: CN=COMODO RSA Certification Authority, O=COMODO CA Limited, + // L=Salford, ST=Greater Manchester, C=GB + // Serial number: 6a74380d4ebfed435b5a3f7e16abdd8 + // Valid from: Sat Feb 11 16:00:00 PST 2012 until: Thu Feb 11 15:59:59 PST 2027 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIH8jCCBtqgAwIBAgIQcgqiz6QAlFISJPkBqYSxZzANBgkqhkiG9w0BAQsFADCB\n" + + "kjELMAkGA1U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fELfpIzRh1vW9HbYAdwBWFAaaL9fC7NP14b1E\n" + + "sj7HRna5vJkRXMDvlJhV1onQ3QAAAVz5cVybAAAEAwBIMEYCIQDdsgC4KZ++OP44\n" + + "X7LbUcNaxe0kFzbctF2L3bnmhp9nXQIhAM0/g+PrZBIBpYlOtzidePi8bBHrLWn2\n" + + "uBiP3pYIntl4AHcA7ku9t3XOYLrhQmkfq+GeZqMPfl+wctiDAMR7iXqo/csAAAFc\n" + + "+XFeoQAABAMASDBGAiEAoySTb/QKw7JwtZtPHnECEMzgENQSFy58Kl+Mvcd3SmcC\n" + + "IQD8cU66Ih3ejvt0OTX+lfxQPKyggQfm4Uk/lwn5LEJXbDANBgkqhkiG9w0BAQsF\n" + + "AAOCAQEAKEaSYWn3Hi8rfJS4cMTJoMkVp2vpPH2dGXySBEy67TEGRw9+f75w3q95\n" + + "r1m3P+xsR6dBoidTq/6wqUYI51lB4Fq9ylh1Stp5Gj54CuyT+S31l7lD7sl0KMsn\n" + + "HDUDQHId7hKeORYpiIZOcrKOglKdi1uiGwDgoiLKh98lUrZA6durrhH+sl69wqp2\n" + + "0XAu+3hurXzCoZFJfyngTO1kt9qcFUAxc5LofIa9QvC6VR7dI4aAh7dUpIRlnjG3\n" + + "jJ1mUMTqWO6TFTtddb+uQjDqNgkYYYNuSax1WMEIZWbIi13EjXK1GPQUXJe6gQin\n" + + "NUq9JH9NPK6m8A1YKT+wgzfTDeaV2Q==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=comodorsacertificationauthority-ev.comodoca.com, + // OU=COMODO EV SGC SSL, O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", + // STREET=Exchange Quay, STREET=Trafford Road, L=Salford, ST=Greater Manchester, + // OID.2.5.4.17=M5 3EQ, C=GB, OID.2.5.4.15=Private Organization, + // OID.1.3.6.1.4.1.311.60.2.1.3=GB, SERIALNUMBER=04058690 + // Issuer: CN=COMODO RSA Extended Validation Secure Server CA, + // O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB + // Serial number: ff6ecae8c73f9b5ca811a1d2b14768be + // Valid from: Tue Aug 16 17:00:00 PDT 2016 until: Fri Nov 16 15:59:59 PST 2018 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIIGzCCBwOgAwIBAgIRAP9uyujHP5tcqBGh0rFHaL4wDQYJKoZIhvcNAQELBQAw\n" + + "gZIxCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO\n" + + "BgNVBAcTB1NhbGZvcmQxGjAYBgNVBAoTEUNPTU9ETyBDQSBMaW1pdGVkMTgwNgYD\n" + + "VQQDEy9DT01PRE8gUlNBIEV4dGVuZGVkIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZl\n" + + "ciBDQTAeFw0xNjA4MTcwMDAwMDBaFw0xODExMTYyMzU5NTlaMIIBXTERMA8GA1UE\n" + + "BRMIMDQwNTg2OTAxEzARBgsrBgEEAYI3PAIBAxMCR0IxHTAbBgNVBA8TFFByaXZh\n" + + "dGUgT3JnYW5pemF0aW9uMQswCQYDVQQGEwJHQjEPMA0GA1UEERMGTTUgM0VRMRsw\n" + + "GQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQxFjAU\n" + + "BgNVBAkTDVRyYWZmb3JkIFJvYWQxFjAUBgNVBAkTDUV4Y2hhbmdlIFF1YXkxJTAj\n" + + "BgNVBAkTHDNyZCBGbG9vciwgMjYgT2ZmaWNlIFZpbGxhZ2UxGjAYBgNVBAoTEUNP\n" + + "TU9ETyBDQSBMaW1pdGVkMRowGAYDVQQLExFDT01PRE8gRVYgU0dDIFNTTDE4MDYG\n" + + "A1UEAxMvY29tb2RvcnNhY2VydGlmaWNhdGlvbmF1dGhvcml0eS1ldi5jb21vZG9j\n" + + "YS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDQ/3mUAU46QQ7L\n" + + "rX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-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Fri Jun 30 07:20:56 PDT 2017", System.out); + } +} + +class ComodoECC { + + // Owner: CN=COMODO ECC Extended Validation Secure Server CA, + // O=COMODO CA Limited, L=Salford, ST=Greater Manchester, C=GB + // Issuer: CN=COMODO ECC Certification Authority, O=COMODO CA Limited, + // L=Salford, ST=Greater Manchester, C=GB + // Serial number: 61d4643b412b5d8d715499d8553aa03 + // Valid from: Sun Apr 14 17:00:00 PDT 2013 until: Fri Apr 14 16:59:59 PDT 2028 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIDojCCAyigAwIBAgIQBh1GQ7QStdjXFUmdhVOqAzAKBggqhkjOPQQDAzCBhTEL\n" + + "MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + + "BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMT\n" + + "IkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTMwNDE1MDAw\n" + + "MDAwWhcNMjgwNDE0MjM1OTU5WjCBkjELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdy\n" + + "ZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMRQ09N\n" + + "T0RPIENBIExpbWl0ZWQxODA2BgNVBAMTL0NPTU9ETyBFQ0MgRXh0ZW5kZWQgVmFs\n" + + "aWRhdGlvbiBTZWN1cmUgU2VydmVyIENBMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD\n" + + "QgAEV3AaPyeTQy0aWXXkBJMR42DsJ5pnbliJe7ndaHzCDslVlY8ofpxeFiqluZrK\n" + + "KNcJeBU/Jl1YI9jLMyMZKsfSoaOCAWkwggFlMB8GA1UdIwQYMBaAFHVxpxlIGbyd\n" + + "nepBR9+UxEh3mdN5MB0GA1UdDgQWBBTTTsMZulhZ0Rxgt2FTRzund4/4ijAOBgNV\n" + + "HQ8BAf8EBAMCAYYwEgYDVR0TAQH/BAgwBgEB/wIBADA+BgNVHSAENzA1MDMGBFUd\n" + + "IAAwKzApBggrBgEFBQcCARYdaHR0cHM6Ly9zZWN1cmUuY29tb2RvLmNvbS9DUFMw\n" + + "TAYDVR0fBEUwQzBBoD+gPYY7aHR0cDovL2NybC5jb21vZG9jYS5jb20vQ09NT0RP\n" + + "RUNDQ2VydGlmaWNhdGlvbkF1dGhvcml0eS5jcmwwcQYIKwYBBQUHAQEEZTBjMDsG\n" + + "CCsGAQUFBzAChi9odHRwOi8vY3J0LmNvbW9kb2NhLmNvbS9DT01PRE9FQ0NBZGRU\n" + + "cnVzdENBLmNydDAkBggrBgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29t\n" + + "MAoGCCqGSM49BAMDA2gAMGUCMQDmPWS98nREWdt4xB83r9MVvgG5INpKHi6V1dUY\n" + + "lCqvSvXXjK0QvZSrOB7cj9RavGgCMG2xJNG+SvlTWEYpmK7eXSgmRUgoBDeQ0yDK\n" + + "lnxmeeOBnnCaDIxAcA3aCj2Gtdt3sA==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=comodoecccertificationauthority-ev.comodoca.com, OU=COMODO EV SSL, + // O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, + // STREET=Trafford Road, L=Salford, ST=Greater Manchester, OID.2.5.4.17=M5 3EQ, + // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, + // SERIALNUMBER=04058690 + // Issuer: CN=COMODO ECC Extended Validation Secure Server CA, O=COMODO CA Limited, + // L=Salford, ST=Greater Manchester, C=GB + // Serial number: 414e5d66ec7d15ca504213f2811d57af + // Valid from: Mon Jul 03 17:00:00 PDT 2017 until: Thu Oct 03 16:59:59 PDT 2019 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIGYDCCBgWgAwIBAgIQQU5dZux9FcpQQhPygR1XrzAKBggqhkjOPQQDAjCBkjEL\n" + + "MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + + "BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxODA2BgNVBAMT\n" + + "L0NPTU9ETyBFQ0MgRXh0ZW5kZWQgVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENB\n" + + "MB4XDTE3MDcwNDAwMDAwMFoXDTE5MTAwMzIzNTk1OVowggFZMREwDwYDVQQFEwgw\n" + + "NDA1ODY5MDETMBEGCysGAQQBgjc8AgEDEwJHQjEdMBsGA1UEDxMUUHJpdmF0ZSBP\n" + + "cmdhbml6YXRpb24xCzAJBgNVBAYTAkdCMQ8wDQYDVQQREwZNNSAzRVExGzAZBgNV\n" + + "BAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEWMBQGA1UE\n" + + "CRMNVHJhZmZvcmQgUm9hZDEWMBQGA1UECRMNRXhjaGFuZ2UgUXVheTElMCMGA1UE\n" + + "CRMcM3JkIEZsb29yLCAyNiBPZmZpY2UgVmlsbGFnZTEaMBgGA1UEChMRQ09NT0RP\n" + + "IENBIExpbWl0ZWQxFjAUBgNVBAsTDUNPTU9ETyBFViBTU0wxODA2BgNVBAMTL2Nv\n" + + "bW9kb2VjY2NlcnRpZmljYXRpb25hdXRob3JpdHktZXYuY29tb2RvY2EuY29tMFkw\n" + + "EwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEt26qBS7TRu/yfR+RiqLAzW2C+UspFZlO\n" + + "Rc4EhLfNYMgFko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AAAEAwBHMEUCIHRvPWKr7vPMBWx1gLPkt8inPINWPNSoax178e5A\n" + + "D0cPAiEAvRL/VP4DLiyHvcU9AOqTzQXGuWCzswWKG59hSm7gS4kAdQDuS723dc5g\n" + + "uuFCaR+r4Z5mow9+X7By2IMAxHuJeqj9ywAAAV0NLqsDAAAEAwBGMEQCIFALT043\n" + + "X5IffLsxIAGXTrWgkZHf12QKgrYKXVB629eOAiAIeci2xi3fUW6mU8tT4LwyjowV\n" + + "DkrSCw1ZMo0JApsfzTAKBggqhkjOPQQDAgNJADBGAiEA7HUxjwx0MBC+4PuPx4Z1\n" + + "WpKz7jdHOMTh1sdaoVV5hNoCIQDrnjBFUopXHTvm/rj+aMFIeYejggPqv14KJOqT\n" + + "gym+uA==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=comodoecccertificationauthority-ev.comodoca.com, OU=COMODO EV SSL, + // O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, + // STREET=Trafford Road, L=Salford, ST=Greater Manchester, OID.2.5.4.17=M5 3EQ, + // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, + // SERIALNUMBER=04058690 + // Issuer: CN=COMODO ECC Extended Validation Secure Server CA, O=COMODO CA Limited, + // L=Salford, ST=Greater Manchester, C=GB + // Serial number: 6923086d88824ee9800742fcb82fdaa + // Valid from: Tue Aug 16 17:00:00 PDT 2016 until: Fri Nov 16 15:59:59 PST 2018 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIGizCCBjGgAwIBAgIQBpIwhtiIJO6YAHQvy4L9qjAKBggqhkjOPQQDAjCBkjEL\n" + + "MAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UE\n" + + "BxMHU2FsZm9yZDEaMBgGA1UEChMRQ09NT0RPIENBIExpbWl0ZWQxODA2BgNVBAMT\n" + + "L0NPTU9ETyBFQ0MgRXh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BAMCA0gAMEUCIHL5pdruv0yoFggKHPN7PXT4BfRr\n" + + "1ksLXKgF/xANjsuFAiEA9bt7u96U5OrAzJBgSkJFmNE20vEdwoQDL+99JeX4bAc=\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Tue Jul 04 03:34:40 PDT 2017", System.out); + } +} + +class ComodoUserTrustRSA { + + // Owner: CN=USERTrust RSA Extended Validation Secure Server CA, + // O=The USERTRUST Network, L=Jersey City, ST=New Jersey, C=US + // Issuer: CN=USERTrust RSA Certification Authority, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Serial number: f6bb751efa7d2e8368e606407334f83 + // Valid from: Sat Feb 11 16:00:00 PST 2012 until: Thu Feb 11 15:59:59 PST 2027 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIGGTCCBAGgAwIBAgIQD2u3Ue+n0ug2jmBkBzNPgzANBgkqhkiG9w0BAQwFADCB\n" + + "iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl\n" + + "cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV\n" + + "BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTIw\n" + + "MjEyMDAwMDAwWhcNMjcwMjExMjM1OTU5WjCBlTELMAkGA1UEBhMCVVMxEzARBgNV\n" + + "BAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU\n" + + "aGUgVVNFUlRSVVNUIE5ldHdvcmsxOzA5BgNVBAMTMlVTRVJUcnVzdCBSU0EgRXh0\n" +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xf22zjY/QLzzdZwJ9JO86qH/czwCFPK4o9Cb7rixQL9S7zHw1dm3n/+Lx5kT9lqx\n" + + "wB0dqoZ8o0XwFgVcksGz7QRhEBjrB0nSUNYG8kuFaMxRWa9ze6Ovov44WDrq1uyF\n" + + "npi3eeQiwMr3xHmY76b1NX0WqvlTTFw4L5DrcIohBz1zKVkRp7LH/s5vxjDECM+/\n" + + "erdy1WTILNFv09gwz4iFyfu/WmYYNUKlQJaSoUqja/KHcqY8zYKKjq5o982Ji3Ti\n" + + "/Odkx1NJA1Yf5ivDxxRFQmij6knL1pi1wgQxGjd67V3/+HfHF7MCRWk8mXnT32B9\n" + + "1Hk3jm10GL0R6y/XFsLhv0mGkmKD1vTP7vz1hdMLlVgxEs1k5dLMybtjUJ3LuENz\n" + + "avmZ/G/vOi284ZRo/gA/YjT5CeeWgI11IHbpRDAqKy4BWhmtIi11u12i9ftPxxrD\n" + + "/VwHtC0hTTOBnYgbJAK9ZLvaJUBU22EimU4Jv3ELkeV7SWedbAdfjXolI1mCcAbq\n" + + "RgzRC+RaTloSmO2dWicDBW7KlRHmKZXrkDUAExSBY/1j9HmNcYzWv4NCTtK7t0en\n" + + "gsE/OP2b7zHrHWtC/F1JwOCrH1JkbPA7c/6nNJVY2AscGM16pIU89OL0Ez1PyZYG\n" + + "4fokbdNREXoShKClNIPbB5iY+WdSzb9CKLyb96g=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=usertrustrsacertificationauthority-ev.comodoca.com, OU=COMODO EV SGC SSL, + // O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, + // STREET=Trafford Road, L=Salford, ST=Greater Manchester, OID.2.5.4.17=M5 3EQ, + // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, + // SERIALNUMBER=04058690 + // Issuer: CN=USERTrust RSA Extended Validation Secure Server CA, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Serial number: ffcada019c9fb1155a32300083cb99c9 + // Valid from: Mon Jul 03 17:00:00 PDT 2017 until: Thu Oct 03 16:59:59 PDT 2019 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIIATCCBumgAwIBAgIRAP/K2gGcn7EVWjIwAIPLmckwDQYJKoZIhvcNAQELBQAw\n" + + "gZUxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpOZXcgSmVyc2V5MRQwEgYDVQQHEwtK\n" + + "ZXJzZXkgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMTswOQYD\n" + + "VQQDEzJVU0VSVHJ1c3QgUlNBIEV4dGVuZGVkIFZhbGlkYXRpb24gU2VjdXJlIFNl\n" + + "cnZlciBDQTAeFw0xNzA3MDQwMDAwMDBaFw0xOTEwMDMyMzU5NTlaMIIBYDERMA8G\n" + + "A1UEBRMIMDQwNTg2OTAxEzARBgsrBgEEAYI3PAIBAxMCR0IxHTAbBgNVBA8TFFBy\n" + + "aXZhdGUgT3JnYW5pemF0aW9uMQswCQYDVQQGEwJHQjEPMA0GA1UEERMGTTUgM0VR\n" + + "MRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQx\n" + + "FjAUBgNVBAkTDVRyYWZmb3JkIFJvYWQxFjAUBgNVBAkTDUV4Y2hhbmdlIFF1YXkx\n" + + "JTAjBgNVBAkTHDNyZCBGbG9vciwgMjYgT2ZmaWNlIFZpbGxhZ2UxGjAYBgNVBAoT\n" + + "EUNPTU9ETyBDQSBMaW1pdGVkMRowGAYDVQQLExFDT01PRE8gRVYgU0dDIFNTTDE7\n" + + "MDkGA1UEAxMydXNlcnRydXN0cnNhY2VydGlmaWNhdGlvbmF1dGhvcml0eS1ldi5j\n" + + "b21vZG9jYS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCeH+vF\n" + + "6JjCktrrnV4u8adH5ESuENaRNm2plwfD07Lskva4Qv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W9kb2NhLmNvbTCC\n" + + "AX8GCisGAQQB1nkCBAIEggFvBIIBawFpAHYApLkJkLQYWBSHuxOizGdwCjw1mAT5\n" + + "G9+443fNDsgN3BAAAAFdDU2iYQAABAMARzBFAiB0o4GnVHD8MeVQ32D0XYu+EQQW\n" + + "jvN78rmCfk0OEBxyFAIhAKgyctIn0IaDJiZzsrtAiqEnkcMtuh8o+R0Rqw1ygAjk\n" + + "AHcAVhQGmi/XwuzT9eG9RLI+x0Z2ubyZEVzA75SYVdaJ0N0AAAFdDU2gFgAABAMA\n" + + "SDBGAiEA7mcmZ8H5uHuNCdI0CVxsqDZQcZX/gVk94KckePkzQoACIQCHwm5hcvNC\n" + + "M8vNmFkboQN79DglRctHrlh143A6mUTk8QB2AO5Lvbd1zmC64UJpH6vhnmajD35f\n" + + "sHLYgwDEe4l6qP3LAAABXQ1NojoAAAQDAEcwRQIhAPqwijgE0Fr6uJ+yF+TvyXco\n" + + "Hduv9h7R5WWwJfghXiMyAiBB4+fJm4rIcOnJBZmOqFnRpIjPN0jwDqJT0nDHxaXA\n" + + "nDANBgkqhkiG9w0BAQsFAAOCAQEACXitF1bTEvV1HX11WrT/XuoMhsoPK4TS16rs\n" + + "FqztV4iXKlA1/h5qbsjYY1gVrM+/6kQkmEs5qrxsek2WNxY80NO3WAzroRJ3H9Sd\n" + + "mPn0No2P8LZ5Fs5hvaD/PfWO5xxey80c3kGyvWOej90P3IrL/1RiULyh95TrXBjI\n" + + "ddCBsZ28904wsQUrPBPMpiu0DKl1HR/em9WkcipMi+onJxxFWjucssz5PW/BzGYF\n" + + "jfWLDEI0tN5L4CWV3iVXFXOURY1Mwhtsey9jvlEyxSsys55QdKF40yGgtV9VC+os\n" + + "7hJP33+qA0cvCTaRytiPP6z/l2G/KSIXTyv6SxzGhsTFfzLAOg==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=usertrustrsacertificationauthority-ev.comodoca.com, OU=COMODO EV SGC SSL, + // O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, + // STREET=Trafford Road, L=Salford, ST=Greater Manchester, OID.2.5.4.17=M5 3EQ, + // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, + // SERIALNUMBER=04058690 + // Issuer: CN=USERTrust RSA Extended Validation Secure Server CA, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Serial number: 643d7e2b0112d51a05a4efb266ebd70d + // Valid from: Tue Aug 16 17:00:00 PDT 2016 until: Fri Nov 16 15:59:59 PST 2018 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIILjCCBxagAwIBAgIQZD1+KwES1RoFpO+yZuvXDTANBgkqhkiG9w0BAQsFADCB\n" + + "lTELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl\n" + + "cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxOzA5BgNV\n" + + "BAMTMlVTRVJUcnVzdCBSU0EgRXh0ZW5kZWQgVmFsaWRhdGlvbiBTZWN1cmUgU2Vy\n" + + "dmVyIENBMB4XDTE2MDgxNzAwMDAwMFoXDTE4MTExNjIzNTk1OVowggFgMREwDwYD\n" + + "VQQFEwgwNDA1ODY5MDETMBEGCysGAQQBgjc8AgEDEwJHQjEdMBsGA1UEDxMUUHJp\n" + + "dmF0ZSBPcmdhbml6YXRpb24xCzAJBgNVBAYTAkdCMQ8wDQYDVQQREwZNNSAzRVEx\n" + + "GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEW\n" + + "MBQGA1UECRMNVHJhZmZvcmQgUm9hZDEWMBQGA1UECRMNRXhjaGFuZ2UgUXVheTEl\n" + + "MCMGA1UECRMcM3JkIEZsb29yLCAyNiBPZmZpY2UgVmlsbGFnZTEaMBgGA1UEChMR\n" + + "Q09NT0RPIENBIExpbWl0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h/pyDBtsxED4r+Topb+QwVZCzIMtOr49/S9\n" + + "GHA7HJo6nwSoV6rfrnLDCtcJN4ezEzOs7MOOq9K1MiAoAOXa/maelXwqbNGVpN2p\n" + + "HihRuBRDqusdS8zNGPxhvbviCDf8mJRvFoPgk/5o6mxf6bKfjmtkWOxMApvJU3Nd\n" + + "ib1aMX9KArEiNFwHFxOSYmE8c8x/zhLlk1btOo7gQrVNyw==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Tue Jul 04 04:09:55 PDT 2017", System.out); + } +} + +class ComodoUserTrustECC { + + // Owner: CN=USERTrust ECC Extended Validation Secure Server CA, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Issuer: CN=USERTrust ECC Certification Authority, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Serial number: 3d09b24f5c08a7ce8eb85a51d3c1aa52 + // Valid from: Sun Apr 14 17:00:00 PDT 2013 until: Fri Apr 14 16:59:59 PDT 2028 + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIDwTCCA0igAwIBAgIQPQmyT1wIp86OuFpR08GqUjAKBggqhkjOPQQDAzCBiDEL\n" + + "MAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNl\n" + + "eSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMT\n" + + "JVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMTMwNDE1\n" + + "MDAwMDAwWhcNMjgwNDE0MjM1OTU5WjCBlTELMAkGA1UEBhMCVVMxEzARBgNVBAgT\n" + + "Ck5ldyBKZX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U=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=usertrustecccertificationauthority-ev.comodoca.com, OU=COMODO EV SGC SSL, + // O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, + // STREET=Trafford Road, L=Salford, ST=Greater Manchester, OID.2.5.4.17=M5 3EQ, + // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, + // SERIALNUMBER=04058690 + // Issuer: CN=USERTrust ECC Extended Validation Secure Server CA, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Serial number: 9bd0c93cac9ca2edc1a7dd923316b3c6 + // Valid from: Mon Jul 03 17:00:00 PDT 2017 until: Thu Oct 03 16:59:59 PDT 2019 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIGhzCCBi2gAwIBAgIRAJvQyTysnKLtwafdkjMWs8YwCgYIKoZIzj0EAwIwgZUx\n" + + "CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpOZXcgSmVyc2V5MRQwEgYDVQQHEwtKZXJz\n" + + "ZXkgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMTswOQYDVQQD\n" + + "EzJVU0VSVHJ1c3QgRUNDIEV4dGVuZGVkIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZl\n" + + "ciBDQTAeFw0xNzA3MDQwMDAwMDBaFw0xOTEwMDMyMzU5NTlaMIIBYDERMA8GA1UE\n" + + "BRMIMDQwNTg2OTAxEzARBgsrBgEEAYI3PAIBAxMCR0IxHTAbBgNVBA8TFFByaXZh\n" + + "dGUgT3JnYW5pemF0aW9uMQswCQYDVQQGEwJHQjEPMA0GA1UEERMGTTUgM0VRMRsw\n" + + "GQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAOBgNVBAcTB1NhbGZvcmQxFjAU\n" + + "BgNVBAkTDVRyYWZmb3JkIFJvYWQxFjAUBgNVBAkTDUV4Y2hhbmd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NIIydXNlcnRydXN0ZWNjY2VydGlmaWNhdGlvbmF1dGhvcml0eS1ldi5jb21vZG9j\n" + + "YS5jb20wggF8BgorBgEEAdZ5AgQCBIIBbASCAWgBZgB1AKS5CZC0GFgUh7sTosxn\n" + + "cAo8NZgE+RvfuON3zQ7IDdwQAAABXQ0/jQ0AAAQDAEYwRAIgPbaNWgoi6OfyNwL2\n" + + "+jiySsoLrkx+0d4NJE1WnZQcfzwCICW4yvsXaMxoOXpQp3EPgrYk5Ajfvy/dY3Ui\n" + + "0/dbQtHxAHYAVhQGmi/XwuzT9eG9RLI+x0Z2ubyZEVzA75SYVdaJ0N0AAAFdDT+K\n" + + "xwAABAMARzBFAiB3GQasrX+akoHX02ZvXCcvhWCqv6qQOhLCUqflPoRbuAIhALwe\n" + + "hrQo8S1Tm5vbMcxGiViq5ZcawxENWhxZ9hS0BZweAHUA7ku9t3XOYLrhQmkfq+Ge\n" + + "ZqMPfl+wctiDAMR7iXqo/csAAAFdDT+M4AAABAMARjBEAiAjvp8w/fdTVW1VGE0T\n" + + "I0YcCIXTYFDgzUMsEUiKHANAgwIgETQUcac7Hiis2fgQ+GdGF9yuh+xMo2Z8QXNu\n" + + "1Cknf+8wCgYIKoZIzj0EAwIDSAAwRQIgQ5UiUI7xodmmMYNs3CmqlZHw/04BQRAR\n" + + "4gRm7blZSIMCIQDHvIWTaPzSO6vwVzs6wSD6FqebLiFxoddC6aZG8Nm0wQ==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=usertrustecccertificationauthority-ev.comodoca.com, OU=COMODO EV SGC SSL, + // O=COMODO CA Limited, STREET="3rd Floor, 26 Office Village", STREET=Exchange Quay, + // STREET=Trafford Road, L=Salford, ST=Greater Manchester, OID.2.5.4.17=M5 3EQ, + // C=GB, OID.2.5.4.15=Private Organization, OID.1.3.6.1.4.1.311.60.2.1.3=GB, + // SERIALNUMBER=04058690 + // Issuer: CN=USERTrust ECC Extended Validation Secure Server CA, O=The USERTRUST Network, + // L=Jersey City, ST=New Jersey, C=US + // Serial number: 4a2545ad661540057c81281ff8c101b9 + // Valid from: Tue Aug 16 17:00:00 PDT 2016 until: Fri Nov 16 15:59:59 PST 2018 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIGtzCCBlygAwIBAgIQSiVFrWYVQAV8gSgf+MEBuTAKBggqhkjOPQQDAjCBlTEL\n" + + "MAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNl\n" + + "eSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxOzA5BgNVBAMT\n" + + "MlVTRVJUcnVzdCBFQ0MgRXh0ZW5kZWQgVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVy\n" + + "IENBMB4XDTE2MDgxNzAwMDAwMFoXDTE4MTExNjIzNTk1OVowggFgMREwDwYDVQQF\n" + + "EwgwNDA1ODY5MDETMBEGCysGAQQBgjc8AgEDEwJHQjEdMBsGA1UEDxMUUHJpdmF0\n" + + "ZSBPcmdhbml6YXRpb24xCzAJBgNVBAYTAkdCMQ8wDQYDVQQREwZNNSAzRVExGzAZ\n" + + "BgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEWMBQG\n" + + "A1UECRMNVHJhZmZvcmQgUm9hZDEWMBQGA1UECRMNRXhjaGFuZ2UgUXVheTElMCMG\n" + + "A1UECRMcM3JkIEZsb29yLCAyNiBPZmZpY2UgVmlsbGFnZTEaMBgGA1UEChMRQ09N\n" + + "T0RPIENBIExpbWl0ZWQxGjAYBgNVBAsTEUNPTU9ETyBFViBTR0MgU1NMMTswOQYD\n" + + "VQQDEzJ1c2VydHJ1c3RlY2NjZXJ0aWZpY2F0aW9uYXV0aG9yaXR5LWV2LmNvbW9k\n" + + "b2NhLmNvbTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABC0yXxHfdlpYPofwFbT7\n" + + "DJsF/T7r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Z\n" + + "TBJapGSqKHg1GBtlifmy+WB+AiACeljNAF3VK9Ma1bbJiRtB9ZRAN7mPbzaC3wha\n" + + "+5riaAB2AFYUBpov18Ls0/XhvUSyPsdGdrm8mRFcwO+UmFXWidDdAAABVpjL8F8A\n" + + "AAQDAEcwRQIgLq1mfWnNQWNTtQYtNCWm8wUm1Jez6AqfzmFLKJc4NC8CIQCsaHIH\n" + + "b/nKPPyKL9hxi2o5n0K3DpnHFv5V+0dtTBjOCgB2AO5Lvbd1zmC64UJpH6vhnmaj\n" + + "D35fsHLYgwDEe4l6qP3LAAABVpjL8RMAAAQDAEcwRQIhAOR5Hx0Mq6iX7lE6mfIR\n" + + "efJknMqXCnjcDsvzk6ZiXwSQAiB31TTkVHIVyscNYsup34Vcid7nWMuZiLjEElBo\n" + + "vYYh3jAKBggqhkjOPQQDAgNJADBGAiEA0CZ8Utr9boJ2y9mfVkOv2US4Nk9oWT/y\n" + + "P5YGb+ox/EICIQCBHZdD3tPNJ5BDkIdUCjnaFkNsHJchsU8e5a+1CV4knQ==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator) throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Tue Jul 04 03:51:20 PDT 2017", System.out); + } +} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/DTrustCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/DTrustCA.java new file mode 100644 index 00000000000..152e77907bb --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/DTrustCA.java @@ -0,0 +1,280 @@ +/* + * 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 8189131 + * @summary Interoperability tests with "D-Trust Root Class 3 CA 2 2009" and + * "D-Trust Root Class 3 CA 2 EV 2009" CAs + * @build ValidatePathWithParams + * @run main/othervm -Djava.security.debug=certpath DTrustCA OCSP + * @run main/othervm -Djava.security.debug=certpath DTrustCA CRL + */ +public class DTrustCA { + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + + boolean ocspEnabled = true; + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + ocspEnabled = false; + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + } + + new RootClass3CA2().runTest(pathValidator, ocspEnabled); + new RootClass3CA2EV().runTest(pathValidator, ocspEnabled); + } +} + +class RootClass3CA2 { + + // Owner: CN=D-TRUST SSL Class 3 CA 1 2009, O=D-Trust GmbH, C=DE + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIFMjCCBBqgAwIBAgIDCZBjMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRF\n" + + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBD\n" + + "bGFzcyAzIENBIDIgMjAwOTAeFw0wOTExMTIxMjQ2NTVaFw0yOTExMDUwODM1NTha\n" + + "MEwxCzAJBgNVBAYTAkRFMRUwEwYD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lMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZv\n" + + "Y2F0aW9ubGlzdDBDoEGgP4Y9aHR0cDovL3d3dy5kLXRydXN0Lm5ldC9jcmwvZC10\n" + + "cnVzdF9yb290X2NsYXNzXzNfY2FfMl8yMDA5LmNybDAdBgNVHQ4EFgQUUBkylJrE\n" + + "tQRNVtDAgyHVNVWwsXowDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8C\n" + + "AQAwDQYJKoZIhvcNAQELBQADggEBABM5QRHX/yInsmZLWVlvmWmKb3c4IB3hAIVR\n" + + "sAGhkvQJ/RD1GZjZUBBYMWkD1P37fTQxlqTOe3NecVvElkYZuCq7HSM6o7awzb3m\n" + + "yLn1kN+hDCsxX0EYbVSNjEjkW3QEkqJH9owH4qeMDxf7tfXB7BVKO+rarYPa2PR8\n" + + "Wz2KhjFDmAeFg2J89YcpeJJEEJXoweAkgJEEwwEIfJ2yLjYo78RD0Rvij/+zkfj9\n" + + "+dSvTiZTuqicyo37qNoYHgchuqXnKodhWkW89oo2NKhfeNHHbqvXEJmx0PbI6YyQ\n" + + "50GnYECZRHNKhgbPEtNy/QetU53aWlTlvu4NIwLW5XVsrxlQ2Zw=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=certdemo-ov-valid.ssl.d-trust.net, O=D-Trust GmbH, OU=IT, + // L=Berlin, ST=Berlin, C=DE, SERIALNUMBER=DTRWS354803406304201, DNQ=7223150018 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIF1jCCBL6gAwIBAgIDD07RMA0GCSqGSIb3DQEBCwUAMEwxCzAJBgNVBAYTAkRF\n" + + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxJjAkBgNVBAMMHUQtVFJVU1QgU1NMIENs\n" + + "YXNzIDMgQ0EgMSAyMDA5MB4XDTEyMTIxMTEwMTgzN1oXDTE1MTIyMTExMTgwOVow\n" + + "gbMxEzARBgNVBC4TCjcyMjMxNTAwMTg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ly9kaXJlY3RvcnkuZC10cnVz\n" + + "dC5uZXQvQ049RC1UUlVTVCUyMFNTTCUyMENsYXNzJTIwMyUyMENBJTIwMSUyMDIw\n" + + "MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxp\n" + + "c3SGQGh0dHA6Ly9jcmwuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfc3NsX2NsYXNz\n" + + "XzNfY2FfMV8yMDA5LmRlci5jcmwwMwYDVR0SBCwwKoEQaW5mb0BkLXRydXN0Lm5l\n" + + "dIYWaHR0cDovL3d3dy5kLXRydXN0Lm5ldDAdBgNVHQ4EFgQUHjGMR/EdDBRf+Ejf\n" + + "WW5a8beoBrwwDgYDVR0PAQH/BAQDAgSwMCwGA1UdEQQlMCOCIWNlcnRkZW1vLW92\n" + + "LXZhbGlkLnNzbC5kLXRydXN0Lm5ldDANBgkqhkiG9w0BAQsFAAOCAQEAGN4yxyF3\n" + + "sszODgDSkCNX1s4R874jmBmMYy4Af9/kwKNp2GtqPPhnDu8VFtq0bqs1e06XZ4/W\n" + + "6pUPRZIlynjPASkQl+aJGzyZlaH+K0Al80M/7FRRmLCW9Do/RszRihdhcjeyG+Bi\n" + + "2k+A35aVqKMAWzoH4M7TCPg4+ECltaFgJ+25loXl3j0yiP/DmBwATO80Nx78ILl5\n" + + "D6cDyftMKUwdKKlUsB2RMOJsVBcotBMGTB1i/YoSKIu6t7QnoVFMHEia2wZegPCj\n" + + "hBKhLf/Zde/VrSN3IIft93XRabqXWqjpDCvpb/b06/0o5aZIycrj+Kya54dsdXMO\n" + + "FRy9N0HZYzvt9g==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=certdemo-ov-revoked.ssl.d-trust.net, O=D-Trust GmbH, OU=IT, + // L=Berlin, ST=Berlin, C=DE, DNQ=5562882417 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIFuzCCBKOgAwIBAgIDExFnMA0GCSqGSI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/UmQkIQw==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) + throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + if (ocspEnabled) { + // Test certificates are expired in 2015 + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("Jan 01, 2015"); + } + + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Thu Jun 26 09:28:39 PDT 2014", System.out); + + // reset validation date back to current date + pathValidator.resetValidationDate(); + } +} + +class RootClass3CA2EV { + + // Owner: CN=D-TRUST SSL Class 3 CA 1 EV 2009, O=D-Trust GmbH, C=DE + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIFRTCCBC2gAwIBAgIDCZBkMA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRF\n" + + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBD\n" + + "bGFzcyAzIENBIDIgRVYgMjAwOTAeFw0wOTExMTIxMjUyNDNaFw0yOTExMDUwODUw\n" + + "NDZaME8xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKTAnBgNV\n" + + "BAMMIEQtVFJVU1QgU1NMIENsYXNzIDMgQ0EgMSBFViAyMDA5MIIBIjANBgkqhkiG\n" + + "9w0BAQEFAAOCAQ8AMIIBCgKCAQEAygp+ZziakFyPq80fk1QIT9UCcPy0R3UIyq56\n" + + "hXA6lhgfs1l9R9wRM9/DIVX2olb0gHCXdpnHRm+jwzeL3dHJO8Im5Om/c24ZfSVE\n" + + "zBcgKxS5X7X5e7oCYb9tozd9xs04WqYd5kWrvCJsSQf5gtv5gAeJt+QiU7dtXs3A\n" + + "YDflWv4g9eEaDExxM0VQmceEAo5qc7I7dk5ry356G14zQmr29cxie6YS0kH+7qn5\n" + + "g+c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IlpZGqPYU2rcwrelabJQZWAfoRnbkDx2aqofhp5u45dyQpM2t\n" + + "R93/oA36iuHYc9Ewq8CaLGolrpT138RD7i4nN7sZFuFH0IseNz0+EZm88NHi9WeJ\n" + + "UyshWFKBKARi+589Y4P/G2XnbckxFKUxa7uEroZcMwvKBy469K0Au0zVTxs1zNtf\n" + + "Ol3QkNgPwzOPeHhOnpzcenyPgNEm+HQ0FPTnB4HeKBqTeLpkM7h4gq5MZ2TPmfuX\n" + + "KDz3AHrWLLdH\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=certdemo-ev-revoked.ssl.d-trust.net, O=D-Trust GmbH, OU=IT, + // STREET=Berlin, OID.2.5.4.17=10969, L=Berlin, ST=Berlin, C=DE, + // SERIALNUMBER=HRB74346, OID.2.5.4.15=Private Organization, + // OID.1.3.6.1.4.1.311.60.2.1.1=Berlin, OID.1.3.6.1.4.1.311.60.2.1.2=Berlin, + // OID.1.3.6.1.4.1.311.60.2.1.3=DE, DNQ=4028175542 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIGZDCCBUygAwIBAgIDExFtMA0GCSqGSIb3DQEBCwUAME8xCzAJBgNVBAYTAkRF\n" + + "MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKTAnBgNVBAMMIEQtVFJVU1QgU1NMIENs\n" + + "YXNzIDMgQ0EgMSBFViAyMDA5MB4XDTE0MDYyNjE2NDMyOFoXDTE1MDYyOTE2NDMy\n" + + "OFowggEwMRMwEQYDVQQuEwo0MDI4MTc1NTQyMRMwEQYLKwYBBAGCNzwCAQMMAkRF\n" + + "MRcwFQYLKwYBBAGCNzwCAQIMBkJlcmxpbjEXMBUGCysGAQQBgjc8AgEBDAZCZXJs\n" + + "aW4xHTAbBgNVBA8MFFByaXZhdGUgT3JnYW5pemF0aW9uMREwDwYDVQQFEwhIUkI3\n" + + "NDM0NjELMAkGA1UEBhMCREUxDzANBgNVBAgTBkJlcmxpbjEPMA0GA1UEBxMGQmVy\n"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UyMENsYXNzJTIwMyUyMENBJTIwMSUyMEVWJTIwMjAwOSxPPUQt\n" + + "VHJ1c3QlMjBHbWJILEM9REU/Y2VydGlmaWNhdGVyZXZvY2F0aW9ubGlzdIZDaHR0\n" + + "cDovL2NybC5kLXRydXN0Lm5ldC9jcmwvZC10cnVzdF9zc2xfY2xhc3NfM19jYV8x\n" + + "X2V2XzIwMDkuZGVyLmNybDAzBgNVHRIELDAqgRBpbmZvQGQtdHJ1c3QubmV0hhZo\n" + + "dHRwOi8vd3d3LmQtdHJ1c3QubmV0MB0GA1UdDgQWBBTFei056yoNM1HWYbBCixQw\n" + + "wXnf0TAOBgNVHQ8BAf8EBAMCBLAwLgYDVR0RBCcwJYIjY2VydGRlbW8tZXYtcmV2\n" + + "b2tlZC5zc2wuZC10cnVzdC5uZXQwDQYJKoZIhvcNAQELBQADggEBALv0OA+x401T\n" + + "CvGQL1Ah7rclRgtxT3UjmphiLs9EE1YbweIUrN3R4tZuryyv9xslAoLCfMrHUe+f\n" + + "jv1hsKqw+gGlrA8d5VnAqKfUR+KCiZivdlQ2sl4PDTZWpUQYlBnjQrD8h6UrcgTA\n" + + "g1zUpDnioAKAQSWWxHVpcOX0IXCl3RgRz0GqUIZQ0Q8ZwYbIDEI+JzDEJgKkTzet\n" + + "uzin8P54PjuJO801gENp43z++xHVuBcEWkU0TMDbmdL9vPZqnxsaoL5e/llGzor5\n" + + "6JbU6Fc0MkuziaLPUsIxVVx3ZhZ6UFdv34swKyq6ycvKW2fgccwsQCFMrVjIo6HR\n" + + "qiZC9Z+23vM=\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) + throws Exception { + // Validate valid + // Valid cert received as test artifact was revoked so remove test + + // Validate Revoked + if (ocspEnabled) { + // Revoked certificates are expired in 2015 + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("Jan 01, 2015"); + } + + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Thu Jun 26 09:45:14 PDT 2014", System.out); + + // reset validation date back to current date + pathValidator.resetValidationDate(); + } +} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LetsEncryptCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LetsEncryptCA.java new file mode 100644 index 00000000000..f7cdbe06381 --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/LetsEncryptCA.java @@ -0,0 +1,181 @@ +/* + * 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 8189131 + * @summary Interoperability tests with Let's Encrypt CA + * @build ValidatePathWithParams + * @run main/othervm -Djava.security.debug=certpath LetsEncryptCA OCSP + * @run main/othervm -Djava.security.debug=certpath LetsEncryptCA CRL + */ + + /* + * "Lets Encrypt Authority X1" intermediate CA is retired. + * Test certs should be chained through "Lets Encrypt Authority X3" CA. + * + * Obtain TLS test artifacts for Let's Encrypt CA from: + * + * Valid TLS Certificates: + * https://valid-isrgrootx1.letsencrypt.org/ + * + * Revoked TLS Certificates: + * https://revoked-isrgrootx1.letsencrypt.org/ + * + * Test artifacts don't have CRLs listed. + */ +public class LetsEncryptCA { + + // Owner: CN=Let's Encrypt Authority X3, O=Let's Encrypt, C=US + // Issuer: CN=ISRG Root X1, O=Internet Security Research Group, C=US + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIFjTCCA3WgAwIBAgIRANOxciY0IzLc9AUoUSrsnGowDQYJKoZIhvcNAQELBQAw\n" + + "TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n" + + "cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTYxMDA2MTU0MzU1\n" + + "WhcNMjExMDA2MTU0MzU1WjBKMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNTGV0J3Mg\n" + + "RW5jcnlwdDEjMCEGA1UEAxMaTGV0J3MgRW5jcnlwdCBBdXRob3JpdHkgWDMwggEi\n" + + "MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCc0wzwWuUuR7dyXTeDs2hjMOrX\n" + + "NSYZJeG9vjXxcJIvt7hLQQWrqZ41CFjssSrEaIcLo+N15Obzp2JxunmBYB/XkZqf\n" + + "89B4Z3HIaQ6Vkc/+5pnpYDxIzH7KTXcSJJ1HG1rrueweNwAcnKx7pwXqzkrrvUHl\n" + + "Npi5y/1tPJZo3yMqQpAMhnRnyH+lmrhSYRQTP2XpgofL2/oOVvaGifOFP5eGr7Dc\n" + + "Gu9rDZUWfcQroGWymQQ2dYBrrErzG5BJeC+ilk8qICUpBMZ0wNAxzY8xOJUWuqgz\n" + + "uEPxsR/DMH+ieTETPS02+OP88jNquTkxxa/EjQ0dZBYzqvqEKbbUC8DYfcOTAgMB\n" + + "AAGjggFnMIIBYzAOBgNVHQ8BAf8EBAMCAYYwEgYDVR0TAQH/BAgwBgEB/wIBADBU\n" + + "BgNVHSAETTBLMAgGBmeBDAECATA/BgsrBgEEAYLfEwEBATAwMC4GCCsGAQUFBwIB\n" + + "FiJodHRwOi8vY3BzLnJvb3QteDEubGV0c2VuY3J5cHQub3JnMB0GA1UdDgQWBBSo\n" + + "SmpjBH3duubRObemRWXv86jsoTAzBgNVHR8ELDAqMCigJqAkhiJodHRwOi8vY3Js\n" + + "LnJvb3QteDEubGV0c2VuY3J5cHQub3JnMHIGCCsGAQUFBwEBBGYwZDAwBggrBgEF\n" + + "BQcwAYYkaHR0cDovL29jc3Aucm9vdC14MS5sZXRzZW5jcnlwdC5vcmcvMDAGCCsG\n" + + "AQUFBzAChiRodHRwOi8vY2VydC5yb290LXgxLmxldHNlbmNyeXB0Lm9yZy8wHwYD\n" + + "VR0jBBgwFoAUebRZ5nu25eQBc4AIiMgaWPbpm24wDQYJKoZIhvcNAQELBQADggIB\n" + + "ABnPdSA0LTqmRf/Q1eaM2jLonG4bQdEnqOJQ8nCqxOeTRrToEKtwT++36gTSlBGx\n" + + "A/5dut82jJQ2jxN8RI8L9QFXrWi4xXnA2EqA10yjHiR6H9cj6MFiOnb5In1eWsRM\n" + + "UM2v3e9tNsCAgBukPHAg1lQh07rvFKm/Bz9BCjaxorALINUfZ9DD64j2igLIxle2\n" + + "DPxW8dI/F2loHMjXZjqG8RkqZUdoxtID5+90FgsGIfkMpqgRS05f4zPbCEHqCXl1\n" + + "eO5HyELTgcVlLXXQDgAWnRzut1hFJeczY1tjQQno6f6s+nMydLN26WuU4s3UYvOu\n" + + "OsUxRlJu7TSRHqDC3lSE5XggVkzdaPkuKGQbGpny+01/47hfXXNB7HntWNZ6N2Vw\n" + + "p7G6OfY+YQrZwIaQmhrIqJZuigsrbe3W+gdn5ykE9+Ky0VgVUsfxo52mwFYs1JKY\n" + + "2PGDuWx8M6DlS6qQkvHaRUo0FMd8TsSlbF0/v965qGFKhSDeQoMpYnwcmQilRh/0\n" + + "ayLThlHLN81gSkJjVrPI0Y8xCVPB4twb1PFUd2fPM3sA1tJ83sZ5v8vgFv2yofKR\n" + + "PB0t6JzUA81mSqM3kxl5e+IZwhYAyO0OTg3/fs8HqGTNKd9BqoUwSRBzp06JMg5b\n" + + "rUCGwbCUDI0mxadJ3Bz4WxR6fyNpBK2yAinWEsikxqEt\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=valid-isrgrootx1.letsencrypt.org + // Issuer: CN=Let's Encrypt Authority X3, O=Let's Encrypt, C=US + // Serial number: 36916d6db9151ad4428d458a32eae518671 + // Valid from: Wed Nov 08 07:00:24 PST 2017 until: Tue Feb 06 07:00:24 PST 2018 + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIFIzCCBAugAwIBAgISA2kW1tuRUa1EKNRYoy6uUYZxMA0GCSqGSIb3DQEBCwUA\n" + + "MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD\n" + + "ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xNzExMDgxNTAwMjRaFw0x\n" + + "ODAyMDYxNTAwMjRaMCsxKTAnBgNVBAMTIHZhbGlkLWlzcmdyb290eDEubGV0c2Vu\n" + + "Y3J5cHQub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyugIOCxl\n" + + "4p0Rrs4aggnzKGYezhMyyvqlBgVBkf3DJV5uHbz/B/CxcoFo2rZzIetJEsb7Qnt1\n" + + "U8L2O5BKnBeOsI5eFv6WUAQs96VayQ09+xCV3jSNjVpbmKKp1TNWboF/V+EDFq6f\n" + + "fxK9h+b88RhBn4gfe+BorPnVTmZZQHgcZCjMGyzlXt68r45dXmZOuh0855Y7z6Et\n" + + "wCHTT8k/7VC0DTIs0+veKv+yblUqwGD0htdOh7POkQGfBeJ432FsCCcLCDjg2Jj2\n" + + "oYQNpLao55ZnVJGXfP8dJpHqJvuEQVuNT1TbHTs4x7IMftqGcPuhXKhA5FCVf0Hb\n" + + "osbVmZ/b2b/WswIDAQABo4ICIDCCAhwwDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQW\n" + + "MBQGCCsGAQUFBwMBBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMB0GA1UdDgQW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\n" + + "YsjjDbDFCmNN9FBqDwvXs7g86ttkdC8=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=revoked-isrgrootx1.letsencrypt.org + // Issuer: CN=Let's Encrypt Authority X3, O=Let's Encrypt, C=US + // Serial number: 3ddd39c0755648d6687a5d8ded37775657e + // Valid from: Wed Nov 08 07:00:32 PST 2017 until: Tue Feb 06 07:00:32 PST 2018 + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIFJzCCBA+gAwIBAgISA93TnAdVZI1mh6XY3tN3dWV+MA0GCSqGSIb3DQEBCwUA\n" + + "MEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD\n" + + "ExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xNzExMDgxNTAwMzJaFw0x\n" + + "ODAyMDYxNTAwMzJaMC0xKzApBgNVBAMTInJldm9rZWQtaXNyZ3Jvb3R4MS5sZXRz\n" + + "ZW5jcnlwdC5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC5qlZ0\n" + + "jslNLn/1uICdZPwflcvsoA2S2Nk+O7cPNew+KQmSIf+LK9AbaWHCkABKx1GdMtfN\n" + + "4Q/nKBtzqZ5jX1V1XbPqPd1eeyJo0rNaDFk/gEUHw/zIYi1AtsxVHztMqOXRcsw+\n" + + "6QHRKU2XFVsfSctMv+MKnMTEJZARyhr5ur9bQ4/LmxPMhrlHAst97hiSsXKXeyMK\n" + + "DWPHmUDn1vz/1mwLMaeYYmuhuRP5HNwYq+LdYvjMV580i6LHY72TwQCfVgOHfqI0\n" + + "larISk2p4q6DmTEEiAzJB3yEYaxDn0kEXbKhL9efDC+eirVFa0ta2OnH87s9L8z9\n" + + "fm9JIiSFM9ATQ16/AgMBAAGjggIiMIICHjAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0l\n" + + "BBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMAw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ZteJt+nqWFRj0e/7eCXIZuUBE\n" + + "aSsFCd5RNTHs6tioN9vYJqLojObgF75MgIAC\n" + + "-----END CERTIFICATE-----"; + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + + // Validate int, EE certs don't have CRLs + pathValidator.validate(new String[]{INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + return; + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + } + + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Wed Nov 08 08:00:35 PST 2017", System.out); + + } +} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/QuoVadisCA.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/QuoVadisCA.java new file mode 100644 index 00000000000..82b851b27b7 --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/QuoVadisCA.java @@ -0,0 +1,473 @@ +/* + * 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 8189131 + * @summary Interoperability tests with QuoVadis Root CA1, CA2, and CA3 CAs + * @build ValidatePathWithParams + * @run main/othervm -Djava.security.debug=certpath QuoVadisCA OCSP + * @run main/othervm -Djava.security.debug=certpath QuoVadisCA CRL + */ + + /* + * Obtain TLS test artifacts for QuoVadis CAs from: + * + * Valid TLS Certificates: + * CA1: https://qvica1g3-v.quovadisglobal.com + * CA2: https://qvsslicag3-v.quovadisglobal.com + * CA2 EV: https://evsslicag3-v.quovadisglobal.com + * CA3: https://qvica3g3-v.quovadisglobal.com + * + * Revoked TLS Certificates: + * CA1: https://qvica1g3-r.quovadisglobal.com + * CA2: https://qvsslicag3-r.quovadisglobal.com + * CA2 EV: https://evsslicag3-r.quovadisglobal.com + * CA3: https://qvica3g3-r.quovadisglobal.com + */ +public class QuoVadisCA { + + public static void main(String[] args) throws Exception { + + ValidatePathWithParams pathValidator = new ValidatePathWithParams(null); + + boolean ocspEnabled = true; + + if (args.length >= 1 && "CRL".equalsIgnoreCase(args[0])) { + pathValidator.enableCRLCheck(); + ocspEnabled = false; + } else { + // OCSP check by default + pathValidator.enableOCSPCheck(); + } + + new RootCA1().runTest(pathValidator, ocspEnabled); + new RootCA2().runTest(pathValidator, ocspEnabled); + new RootCA3().runTest(pathValidator, ocspEnabled); + } +} + +class RootCA1 { + + // Owner: CN=QuoVadis Issuing CA 1 G3, O=QuoVadis Limited, C=BM + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIGFTCCA/2gAwIBAgIUPybG62jqpxKYOV5MlXAGPJYDy9MwDQYJKoZIhvcNAQEL\n" + + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMSBHMzAeFw0xMjExMDYxNjA5NTJaFw0y\n" + + "MjExMDYxNjA5NTJaMEsxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBR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AWgBSjl9bzXqIQ4atFnzwXZDzuAXCczDA7BgNVHR8ENDAyMDCgLqAshipodHRw\n" + + "Oi8vY3JsLnF1b3ZhZGlzZ2xvYmFsLmNvbS9xdnJjYTFnMy5jcmwwHQYDVR0OBBYE\n" + + "FF0EGBL7w+p4fbRXCaH+bf6Cn2TNMA0GCSqGSIb3DQEBCwUAA4ICAQAF6qNCo3LP\n" + + "Qk8jthU1aiuo5WW9jQC+PqWeyVe4JjHK+5PRM+BtoErOItfZyPqoIBMedC/Ya9L1\n" + + "Sv0gncvifjtTD3jIBz0FVCbIMJLRp63b4qtmAGuB00XTXgCFcYoiIq5kyNedJnLe\n" + + "IxMqb0xx8IAqvP9kfEVNdGfvYraSswiGXADftZ3yM24zIc3Ysewi3JeTbzDhEGfb\n" + + "yv9eBplkfKfcoKyOds4sLcxj1QpUxcXgjX1mKTbfOSD5ac/Cjrz6Kqnl2+PNrc5N\n" + + "kXBVKhcCAjpqX5OyI86IUg9XY8i7Lz+tXzAQhllh+rPyTyAmieGf2iV9wrl//OZB\n" + + "l2nXwbgfA7QwQ2VdsmGJfW3a7Zc13GCNx0M2RUGJKLMJOavY72d41wAYPQ46AXls\n" + + "Ic7RJi6EWmwLi6lvw4kKFfWZ0c6vIJur1hLUUmLOt0UBZ226eIREVpmFbDGOLzfl\n" + + "gU0xKhqmU0aIOORzBGDfOrnctvaXORNNhCZ78zS96Egzu2w2OC47Zry7k+EOatzA\n" + + "5zrdJJM3UP7aMSNPvEygbcFUw2I04vpxUuPYTwCtogqNMHqFbCjLM9YxhzsGMdh/\n" + + "9aD1krboaSXUjrS9cOr5P2A9kFHCMsXBaDoaijQXNeyhu+oCeYsdv4S3djFwDW3+\n" + + "iPLo51aqZGsTZ1S22vYdkp+QFByLtArVMQ==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=qvica1g3-v.quovadisglobal.com, O=QuoVadis Limited, L=Hamilton, + // ST=Pembroke, C=BM + private static final String VALID = "-----BEGIN CERTIFICATE-----\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Zn98yX2Wh8Z95aGhdsHSJHsrlcUiWa+X2D1kF/dOKd\n" + + "R8rPqdPIPjUglrXS4yP+cJHx6fCJxW7me1R60lpuL6JNvHp54u7GGA==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=qvica1g3-r.quovadisglobal.com, O=QuoVadis Limited, L=Hamilton, + // ST=Pembroke, C=BM + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIF9DCCA9ygAwIBAgIUBAG4l0ZPYhEdLJSMWYCr7LHngvswDQYJKoZIhvcNAQEL\n" + + "BQAwSzELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxITAf\n" + + "BgNVBAMTGFF1b1ZhZGlzIElzc3VpbmcgQ0EgMSBHMzAeFw0xMjExMTQxMzQ4MDda\n" + + "Fw0xNDExMTQxMzQ4MDdaMHYxCzAJBgNVBAYTAkJNMREwDwYDVQQIEwhQZW1icm9r\n" + + "ZTERMA8GA1UEBxMISGFtaWx0b24xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQx\n" + + "JjAkBgNVBAMTHXF2aWNhMWczLXIucXVvdmFkaXNnbG9iYWwuY29tMIIBIjANBgkq\n" + + "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqlof1qJLTiqI7bf0IU7zOxy0HqjIn0pW\n" + + "lNIEVAjQRR1jnfpsMapicIGZfnnNaYpwdsIjGPwpvWXGA+30ezJNGfWMjhb/tiis\n" + + "qjrHdwXAob5MyXOXP5ZS8K34GwKeL45oJZZG0cf2FSta9/CSsRC9wnDUp/kA+VkH\n" + + "n5vlg7VpUExYO0CBXe4C4ehnvCZHjW5nqpVpm993f9i8E0W3vHPxjGuyuqVEEfma\n" + + "WfOV78+HF4hxALnr+73mp0i6Do2oa/v85mZzyKeBm2YHhwdQ6CC7UZtABlHyWuz9\n" + + "h/ocTGbX92rbUaW6icu9bKQkQ9jsomnQkU5b8CWseo2O0NXBevvCowIDAQABo4IB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dqxwihqILRmAZrI9p/6k/HqV9xMPKprUhnWDGQ/bYnPKyXoTx6uwamaonX4DpW83\n" + + "b3CJTvBHwKh5eJQoBykAkakPdrmbOhe4/XWnDqQVUgJNmEvkg33AexviJo4mW3HG\n" + + "K2MdM60GRIC3Lcnd+Q8SnSCCxp+YtuE/C3Fu8VI/8vz9MC159GGtDzyC7OeKPCpU\n" + + "7H1X0X/OhBkiv7anK/oIhtSw+4DrM2eaVjdWkEa+di2jvI/2us8TXxO1LL+eeSxT\n" + + "E+LbdNO0jSp8azw2Aw4zL+Q41Fzt7OlH7mTkw1mxLF3aWsUNUz/p4w==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) + throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + if (ocspEnabled) { + // Revoked certificates are expired in Nov 2014 + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("Jan 01, 2014"); + } + + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Thu Jan 03 23:47:34 PST 2013", System.out); + + // reset validation date back to current date + pathValidator.resetValidationDate(); + } +} + +class RootCA2 { + + // Owner: CN=QuoVadis Global SSL ICA G3, O=QuoVadis Limited, C=BM + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIGFzCCA/+gAwIBAgIUftbnnMmtgcTIGT75XUQodw40ExcwDQYJKoZIhvcNAQEL\n" + + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMiBHMzAeFw0xMjExMDYxNDUwMThaFw0y\n" + + "MjExMDYxNDUwMThaME0xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + + "aW1pdGVkMSMwIQYDVQQDExpRdW9WYWRp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oCyGKmh0\n" + + "dHA6Ly9jcmwucXVvdmFkaXNnbG9iYWwuY29tL3F2cmNhMmczLmNybDAdBgNVHQ4E\n" + + "FgQUsxKJtalLNbwVAPCA6dh4h/ETfHYwDQYJKoZIhvcNAQELBQADggIBAFGm1Fqp\n" + + "RMiKr7a6h707M+km36PVXZnX1NZocCn36MrfRvphotbOCDm+GmRkar9ZMGhc8c/A\n" + + "Vn7JSCjwF9jNOFIOUyNLq0w4luk+Pt2YFDbgF8IDdx53xIo8Gv05e9xpTvQYaIto\n" + + "qeHbQjGXfSGc91olfX6JUwZlxxbhdJH+rxTFAg0jcbqToJoScWTfXSr1QRcNbSTs\n" + + "Y4CPG6oULsnhVvrzgldGSK+DxFi2OKcDsOKkV7W4IGg8Do2L/M588AfBnV8ERzpl\n" + + "qgMBBQxC2+0N6RdFHbmZt0HQE/NIg1s0xcjGx1XW3YTOfje31rmAXKHOehm4Bu48\n" + + "gr8gePq5cdQ2W9tA0Dnytb9wzH2SyPPIXRI7yNxaX9H8wYeDeeiKSSmQtfh1v5cV\n" + + "7RXvm8F6hLJkkco/HOW3dAUwZFcKsUH+1eUJKLN18eDGwB8yGawjHvOKqcfg5Lf/\n" + + "TvC7hgcx7pDYaCCaqHaekgUwXbB2Enzqr1fdwoU1c01W5YuQAtAx5wk1bf34Yq/J\n" + + "ph7wNXGvo88N0/EfP9AdVGmJzy7VuRXeVAOyjKAIeADMlwpjBRhcbs9m3dkqvoMb\n" + + "SXKJxv/hFmNgEOvOlaFsXX1dbKg1v+C1AzKAFdiuAIa62JzASiEhigqNSdqdTsOh\n" + + "8W8hdONuKKpe9zKedhBFAvuxhDgKmnySglYc\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=qvsslicag3-v.quovadisglobal.com, O=QuoVadis Limited, L=Hamilton, + // ST=Pembroke, C=BM + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIF+DCCA+CgAwIBAgIUE3XHqPhbZc2CY3aRtVHRlQwm3tcwDQYJ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8rzBDmEFY317RWc8VBd8ZUxO/dYPWqsXNwBTdPMRQpYcN55po3g=\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=qvsslicag3-r.quovadisglobal.com, O=QuoVadis Limited, L=Hamilton, + // ST=Pembroke, C=BM + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIF+DCCA+CgAwIBAgIUMJWFWsVjz9o3zQoG9bZ/IsdRWDkwDQYJKoZIhvcNAQEL\n" + + "BQAwTTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxIzAh\n" + + "BgNVBAMTGlF1b1ZhZGlzIEdsb2JhbCBTU0wgSUNBIEczMB4XDTEyMTExNDEzMTI1\n" + + "NFoXDTE0MTExNDEzMTI1NFoweDELMAkGA1UEBhMCQk0xETAPBgNVBAgTCFBlbWJy\n" + + "b2tlMREwDwYDVQQHEwhIYW1pbHRvbjEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRl\n" + + "ZDEoMCYGA1UEAxMfcXZzc2xpY2FnMy1yLnF1b3ZhZGlzZ2xvYmFsLmNvbTCCASIw\n" + + "DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALlwpCyabhrQYeRzEn0O7S505Fv4\n" + + "ScJlJRHskcyZHBt0vt2tsDJNh2xJKJpnXzW14oGh+xrccEGeUw77qeFgfy+LTIHD\n" + + "YDkYVHVhfs4NJD5wdyWL9Fn3A7pMFpapPBPJdsAAwByfzYFjRJsPHMSlGcroyGNm\n" + + "+LquU5r965afaRkWQzZy+lY+OHO19Jis8EfUusYj2fQ3SXB8tBwFylDTnbCoM1HZ\n" + + "BlbksbtLjFYKtyaNeQuoA7NnB3Q9XEONNK9KZ0S87KIqEKjIWK7ThO6lvhMQy2Zk\n" + + "k+UVXVLpop7+Nkz3Fn08pE4OMfLjn1KVnk5l40WGabinfE6hz4vk0XREaKcCAwEA\n" + + "AaOCAaMwggGfMHMGCCsGAQUFBwEBBGcwZTAqBggrBgE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X444ZRFEGrSe4nO/MXt3iEcat\n" + + "fgYHOWoBunLIm7x/fd611xvyhifjqKVCPpqodpwFrXOlCQhXehhRvJSPDXWgDJeR\n" + + "cDLLIcit4Sn1uyebQcZafaxgYPWpaYHFd7dzkO+kTVqOVAm7LukC5QQ9qFY1z7a5\n" + + "IDUAFtEYg/c4XxX+pReOxydnnHeYZBrfRTTxOfMrg6dxsb1QcOeElXHgXRpHyiMh\n" + + "XYsZWE2WHT7of4wMfNzCUrVSN0tCGDRW0MI48RM4BYbRnz3YNKafjnszeXI=\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) + throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + if (ocspEnabled) { + // Revoked certificates are expired in Nov 2014 + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("Jan 01, 2014"); + } + + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Fri Jan 04 03:49:46 PST 2013", System.out); + + // reset validation date back to current date + pathValidator.resetValidationDate(); + } +} + +class RootCA3 { + + // wner: CN=QuoVadis Issuing CA 3 G3, O=QuoVadis Limited, C=BM + private static final String INT = "-----BEGIN CERTIFICATE-----\n" + + "MIIGFTCCA/2gAwIBAgIUHZxbikClihb+1PM2ck0SDEZ8/dIwDQYJKoZIhvcNAQEL\n" + + "BQAwSDELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAc\n" + + "BgNVBAMTFVF1b1ZhZGlzIFJvb3QgQ0EgMyBHMzAeFw0xMjExMDYxODM5MDVaFw0y\n" + + "MjExMDYxODM5MDVaMEsxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM\n" + + "aW1pdGVkMSEwHwYDVQQDExhRdW9WYWRpcyBJc3N1aW5nIENBIDMgRzMwggIiMA0G\n" + + "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vbS9xdnJjYTNnMy5jcmwwHQYDVR0OBBYE\n" + + "FBPyQfSNOURHBZ37q8ZaNQwelu9eMA0GCSqGSIb3DQEBCwUAA4ICAQAsbJU89ZB9\n" + + "1XVlOLmw8MaoWwOgI3DwM/g30YyIV1SERtDMKDOUnLVGTORTGv7Y8X789nGkMbKq\n" + + "OEEa9Hty4jwyTnt2OISpCAb4GwBtH+FxNcLkJwZU2qtpTX8zDndofE/JLGo0rte5\n" + + "bKchF2JTg+oby/Wpu2IO0CMd1phou3LLi8sWQGcY/f5vk+MUDnskH6NRXte4m8HW\n" + + "FtYb7nOgLzY5FOJDtQuUFFioNoQzUHuj3SpUjIBxXf4VRFXz+FKIQ4jqzD/SnHG6\n" + + "/7g/28x66LNpYjvaQ0T45EqxqPDCztfJO67GsNLXeSKq+BteqXcnKI77ZkqmwnWl\n" + + "cYt5qek0GBYRYVOM8dUIvDryWHZIEqbeI0DAu06dyPuvIJNQ6WweqxJ+hH++BqGh\n" + + "P4bViNNuP/Lqarb1RP7JiJW3wlyIUDD34JLzkusBgU++ptdYg1o0VnEB8KWDG8Of\n" + + "cABL+TMoUldUp9DFFgFJIfnPX5XjXyG9mw2wwiUvClo93qFvC8+rhEGeZFd29rKi\n" + + "dmmCc8FaCfBV9XdHHx/0ORTQp3HxnRDDiz+MN7p1Y4SXbHE3XXyQAUVTISGpPe3X\n" + + "TUhmoARNmBBPALDm3EAvEBikTUMBFGR63wtu0pjA2cF5nvOyY8mBSsNk0R6+ZJSl\n" + + "Cok3lH5oBM2H+KBk+sNZIBQ8BHcgbwlghg==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=qvica3g3-v.quovadisglobal.com, O=QuoVadis Limited, L=Hamilton, + // ST=Pembroke, C=BM + private static final String VALID = "-----BEGIN CERTIFICATE-----\n" + + "MIIF9DCCA9ygAwIBAgIUTkK7g7zoijtiLY/YV9ASX+pEsx0wDQYJKoZIhvcNAQEL\n" + + "BQAwSzELMAkGA1UEBhMCQk0xGTAX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LbuVhqMgdnWg==\n" + + "-----END CERTIFICATE-----"; + + // Owner: CN=qvica3g3-r.quovadisglobal.com, O=QuoVadis Limited, L=Hamilton, + // ST=Pembroke, C=BM + private static final String REVOKED = "-----BEGIN CERTIFICATE-----\n" + + "MIIF9DCCA9ygAwIBAgIUSTXTLsMPxg4n9YY6GASBcJsgcaEwDQYJKoZIhvcNAQEL\n" + + "BQAwSzELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxITAf\n" + + "BgNVBAMTGFF1b1ZhZGlzIElzc3VpbmcgQ0EgMyBHMzAeFw0xMjExMTQxMzQ4MTda\n" + + "Fw0xNDExMTQxMzQ4MTdaMHYxCzAJBgNVBAYTAkJNMREwDwYDVQQIEwhQZW1icm9r\n" + + "ZTERMA8GA1UEBxMISGFtaWx0b24xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQx\n" + + "JjAkBgNVBAMTHXF2aWNhM2czLXIucXVvdmFkaXNnbG9iYWwuY29tMIIBIjANBgkq\n" + + "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtaZUVAvasDtoFhZqL2fH+rI/IKeY0zj7\n" + + "hGuYpLlT32JZX8cmkWUywZt6VxA8A5o82Ay0xT9vHy4MPnmmZExEvmkaECBmOh6+\n" + + "WzWydYGKeeheUERJ1hLj2T7MKz/CCFY6NxD9XzvYOyhDpCUQKCOx4LMn0nMFrXrS\n" + + "6IVirDUmH26dpl3IfsdVXyn6N3wLSNf+UX7in/PXsfD/A6RVtqYsfx4fxFJIPIhv\n" + + "XG/cDOVIyfq6Oo1hthzGm8cnOSjvK/UfQV5iVBK68rqoGG+r9uBG9BfZtd7o0wrf\n" + + "SSJkJAPJVpWTLvnD8RYpJIBz01vNgEOCEgF54bvjhBOjx15mrH7roQIDAQABo4IB\n" + + "ozCCAZ8wdAYIKwYBBQUHAQEEaDBmMCoGCCsGAQUFBzABhh5odHRwOi8vb2NzcC5x\n" + + "dW92YW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PehFB/Mmi6g2tpiE0bmLkYj7MMJcmtUowa3FqA\n" + + "QHtqKrK8wOfHep6qPx6VMD6Ypaf6yq66/kkSg05i6VO7V371UTibHeVLTr7LPRQJ\n" + + "Emp8k/6qCXOtf5OdXwHBIDqvszf8ry85Rl3q813TntF0pPRvqLEYadC4Bwq7Snf+\n" + + "PR0MPNhuwZBCmxZcyZqhVG2PyvvEmhPxhEdbO5DWUFwUP17WHNlgeQ==\n" + + "-----END CERTIFICATE-----"; + + public void runTest(ValidatePathWithParams pathValidator, boolean ocspEnabled) + throws Exception { + // Validate valid + pathValidator.validate(new String[]{VALID, INT}, + ValidatePathWithParams.Status.GOOD, null, System.out); + + // Validate Revoked + if (ocspEnabled) { + // Revoked certificates are expired in Nov 2014 + // and backdated revocation check is only possible with OCSP + pathValidator.setValidationDate("Jan 01, 2014"); + } + + pathValidator.validate(new String[]{REVOKED, INT}, + ValidatePathWithParams.Status.REVOKED, + "Thu Jan 03 23:47:02 PST 2013", System.out); + + // reset validation date back to current date + pathValidator.resetValidationDate(); + } +} diff --git a/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ValidatePathWithParams.java b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ValidatePathWithParams.java new file mode 100644 index 00000000000..8572340121e --- /dev/null +++ b/test/jdk/security/infra/java/security/cert/CertPathValidator/certification/ValidatePathWithParams.java @@ -0,0 +1,354 @@ +/* + * 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.io.ByteArrayInputStream; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.Security; +import java.security.cert.CertPath; +import java.security.cert.CertPathValidator; +import java.security.cert.CertPathValidatorException; +import java.security.cert.CertificateException; +import java.security.cert.CertificateExpiredException; +import java.security.cert.CertificateFactory; +import java.security.cert.CertificateRevokedException; +import java.security.cert.PKIXParameters; +import java.security.cert.PKIXRevocationChecker; +import java.security.cert.X509Certificate; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.EnumSet; +import java.util.Locale; + +/** + * Utility class to validate certificate path. It supports OCSP and/or CRL + * validation. + */ +public class ValidatePathWithParams { + + private static final String FS = System.getProperty("file.separator"); + private static final String CACERTS_STORE = System.getProperty("test.jdk") + + FS + "lib" + FS + "security" + FS + "cacerts"; + + private final String[] trustedRootCerts; + + // use this for expired cert validation + private Date validationDate = null; + + // expected certificate status + private Status expectedStatus = Status.UNKNOWN; + private Date expectedRevDate = null; + + private final CertPathValidator certPathValidator; + private final PKIXRevocationChecker certPathChecker; + private final CertificateFactory cf; + + /** + * Possible status values supported for EE certificate + */ + public static enum Status { + UNKNOWN, GOOD, REVOKED, EXPIRED; + } + + /** + * Constructor + * + * @param additionalTrustRoots trusted root certificates + * @throws IOException + * @throws CertificateException + * @throws NoSuchAlgorithmException + */ + public ValidatePathWithParams(String[] additionalTrustRoots) + throws IOException, CertificateException, NoSuchAlgorithmException { + + cf = CertificateFactory.getInstance("X509"); + certPathValidator = CertPathValidator.getInstance("PKIX"); + certPathChecker + = (PKIXRevocationChecker) certPathValidator.getRevocationChecker(); + + if ((additionalTrustRoots == null) || (additionalTrustRoots[0] == null)) { + trustedRootCerts = null; + } else { + trustedRootCerts = additionalTrustRoots.clone(); + } + } + + /** + * Validate certificates + * + * @param certsToValidate Certificates to validate + * @param st expected certificate status + * @param revDate if revoked, expected revocation date + * @param out PrintStream to log messages + * @throws IOException + * @throws CertificateException + * @throws InvalidAlgorithmParameterException + * @throws ParseException + * @throws NoSuchAlgorithmException + * @throws KeyStoreException + */ + public void validate(String[] certsToValidate, + Status st, + String revDate, + PrintStream out) + throws IOException, CertificateException, + InvalidAlgorithmParameterException, ParseException, + NoSuchAlgorithmException, KeyStoreException { + + expectedStatus = st; + if (expectedStatus == Status.REVOKED) { + if (revDate != null) { + expectedRevDate = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", + Locale.US).parse(revDate); + } + } + + Status certStatus = null; + Date revocationDate = null; + + logSettings(out); + + try { + doCertPathValidate(certsToValidate, out); + certStatus = Status.GOOD; + } catch (IOException ioe) { + // Some machines don't have network setup correctly to be able to + // reach outside world, skip such failures + out.println("WARNING: Network setup issue, skip this test"); + ioe.printStackTrace(System.err); + return; + } catch (CertPathValidatorException cpve) { + out.println("Received exception: " + cpve); + + if (cpve.getCause() instanceof IOException) { + out.println("WARNING: CertPathValidatorException caused by IO" + + " error, skip this test"); + return; + } + + if (cpve.getReason() == CertPathValidatorException.BasicReason.ALGORITHM_CONSTRAINED) { + out.println("WARNING: CertPathValidatorException caused by" + + " restricted algorithm, skip this test"); + return; + } + + if (cpve.getReason() == CertPathValidatorException.BasicReason.REVOKED + || cpve.getCause() instanceof CertificateRevokedException) { + certStatus = Status.REVOKED; + if (cpve.getCause() instanceof CertificateRevokedException) { + CertificateRevokedException cre + = (CertificateRevokedException) cpve.getCause(); + revocationDate = cre.getRevocationDate(); + } + } else if (cpve.getReason() == CertPathValidatorException.BasicReason.EXPIRED + || cpve.getCause() instanceof CertificateExpiredException) { + certStatus = Status.EXPIRED; + } else { + throw new RuntimeException( + "TEST FAILED: couldn't determine EE certificate status"); + } + } + + out.println("Expected Certificate status: " + expectedStatus); + out.println("Certificate status after validation: " + certStatus.name()); + + // Don't want test to fail in case certificate is expired when not expected + // Simply skip the test. + if (expectedStatus != Status.EXPIRED && certStatus == Status.EXPIRED) { + out.println("WARNING: Certificate expired, skip the test"); + return; + } + + if (certStatus != expectedStatus) { + throw new RuntimeException( + "TEST FAILED: unexpected status of EE certificate"); + } + + if (certStatus == Status.REVOKED) { + // Check revocation date + if (revocationDate != null) { + out.println( + "Certificate revocation date:" + revocationDate.toString()); + if (expectedRevDate != null) { + out.println( + "Expected revocation date:" + expectedRevDate.toString()); + if (!expectedRevDate.equals(revocationDate)) { + throw new RuntimeException( + "TEST FAILED: unexpected revocation date"); + } + } + } else { + throw new RuntimeException("TEST FAILED: no revocation date"); + } + } + } + + private void logSettings(PrintStream out) { + out.println(); + out.println("====================================================="); + out.println("CONFIGURATION"); + out.println("====================================================="); + out.println("http.proxyHost :" + System.getProperty("http.proxyHost")); + out.println("http.proxyPort :" + System.getProperty("http.proxyPort")); + out.println("https.proxyHost :" + System.getProperty("https.proxyHost")); + out.println("https.proxyPort :" + System.getProperty("https.proxyPort")); + out.println("https.socksProxyHost :" + + System.getProperty("https.socksProxyHost")); + out.println("https.socksProxyPort :" + + System.getProperty("https.socksProxyPort")); + out.println("jdk.certpath.disabledAlgorithms :" + + Security.getProperty("jdk.certpath.disabledAlgorithms")); + out.println("Revocation options :" + certPathChecker.getOptions()); + out.println("OCSP responder set :" + certPathChecker.getOcspResponder()); + out.println("Trusted root set: " + (trustedRootCerts != null)); + + if (validationDate != null) { + out.println("Validation Date:" + validationDate.toString()); + } + out.println("Expected EE Status:" + expectedStatus.name()); + if (expectedStatus == Status.REVOKED && expectedRevDate != null) { + out.println( + "Expected EE Revocation Date:" + expectedRevDate.toString()); + } + out.println("====================================================="); + } + + private void doCertPathValidate(String[] certsToValidate, PrintStream out) + throws IOException, CertificateException, + InvalidAlgorithmParameterException, ParseException, + NoSuchAlgorithmException, CertPathValidatorException, KeyStoreException { + + if (certsToValidate == null) { + throw new RuntimeException("Require atleast one cert to validate"); + } + + // Generate CertPath with certsToValidate + ArrayList certs = new ArrayList(); + for (String cert : certsToValidate) { + if (cert != null) { + certs.add(getCertificate(cert)); + } + } + CertPath certPath = (CertPath) cf.generateCertPath(certs); + + // Set cacerts as anchor + KeyStore cacerts = KeyStore.getInstance("JKS"); + try (FileInputStream fis = new FileInputStream(CACERTS_STORE)) { + cacerts.load(fis, "changeit".toCharArray()); + } catch (IOException | NoSuchAlgorithmException | CertificateException ex) { + throw new RuntimeException(ex); + } + + // Set additional trust certificates + if (trustedRootCerts != null) { + for (int i = 0; i < trustedRootCerts.length; i++) { + X509Certificate rootCACert = getCertificate(trustedRootCerts[i]); + cacerts.setCertificateEntry("tempca" + i, rootCACert); + } + } + + PKIXParameters params; + params = new PKIXParameters(cacerts); + params.addCertPathChecker(certPathChecker); + + // Set backdated validation if requested, if null, current date is set + params.setDate(validationDate); + + // Validate + certPathValidator.validate(certPath, params); + out.println("Successful CertPath validation"); + } + + private X509Certificate getCertificate(String encodedCert) + throws IOException, CertificateException { + ByteArrayInputStream is + = new ByteArrayInputStream(encodedCert.getBytes()); + X509Certificate cert = (X509Certificate) cf.generateCertificate(is); + return cert; + } + + /** + * Set list of disabled algorithms + * + * @param algos algorithms to disable + */ + public static void setDisabledAlgorithms(String algos) { + Security.setProperty("jdk.certpath.disabledAlgorithms", algos); + } + + /** + * Enable OCSP only revocation checks, treat network error as success + */ + public void enableOCSPCheck() { + // OCSP is by default, disable fallback to CRL + certPathChecker.setOptions(EnumSet.of( + PKIXRevocationChecker.Option.NO_FALLBACK)); + } + + /** + * Enable CRL only revocation check, treat network error as success + */ + public void enableCRLCheck() { + certPathChecker.setOptions(EnumSet.of( + PKIXRevocationChecker.Option.PREFER_CRLS, + PKIXRevocationChecker.Option.NO_FALLBACK)); + } + + /** + * Overrides OCSP responder URL in AIA extension of certificate + * + * @param url OCSP responder + * @throws URISyntaxException + */ + public void setOCSPResponderURL(String url) throws URISyntaxException { + certPathChecker.setOcspResponder(new URI(url)); + } + + /** + * Set validation date for EE certificate + * + * @param vDate string formatted date + * @throws ParseException if vDate is incorrect + */ + public void setValidationDate(String vDate) throws ParseException { + validationDate = DateFormat.getDateInstance(DateFormat.MEDIUM, + Locale.US).parse(vDate); + } + + /** + * Reset validation date for EE certificate to current date + */ + public void resetValidationDate() { + validationDate = null; + } +} From 05d1149d5e5127dc0f93fd99876417e6aaf82fdd Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Tue, 12 Dec 2017 20:18:14 -0800 Subject: [PATCH 20/26] 8192850: method summary tables of inherited methods improperly list static interface methods Reviewed-by: jjg --- .../builders/MemberSummaryBuilder.java | 9 +- .../TestMemberInheritance.java} | 16 +- .../diamond/A.java | 0 .../diamond/B.java | 0 .../diamond/C.java | 0 .../diamond/X.java | 0 .../diamond/Z.java | 0 .../inheritDist/A.java | 0 .../inheritDist/B.java | 0 .../inheritDist/C.java | 0 .../pkg/BaseClass.java | 0 .../pkg/BaseInterface.java | 0 .../pkg/SubClass.java | 0 .../pkg1/Implementer.java | 0 .../pkg1/Interface.java | 0 .../TestBadOverride.java | 0 .../TestMultiInheritance.java} | 7 +- .../TestOverriddenMethodDocCopy.java} | 6 +- .../TestOverriddenPrivateMethods.java} | 8 +- ...rriddenPrivateMethodsWithPackageFlag.java} | 6 +- ...rriddenPrivateMethodsWithPrivateFlag.java} | 6 +- .../TestOverrideMethods.java | 255 ++++++++++++++++++ .../pkg1/BaseClass.java | 0 .../pkg1/SubClass.java | 0 .../pkg2/SubClass.java | 0 .../pkg3/I0.java | 0 .../pkg3/I1.java | 0 .../pkg3/I2.java | 0 .../pkg3/I3.java | 0 .../pkg3/I4.java | 0 .../pkg4/Foo.java | 0 .../pkg5/Classes.java | 0 .../pkg5/Interfaces.java | 8 + .../pkg5/TestEnum.java | 0 .../TestOverrideMethods.java | 254 ----------------- 35 files changed, 294 insertions(+), 281 deletions(-) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence/TestMemberInheritence.java => testMemberInheritance/TestMemberInheritance.java} (92%) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence => testMemberInheritance}/diamond/A.java (100%) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence => testMemberInheritance}/diamond/B.java (100%) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence => testMemberInheritance}/diamond/C.java (100%) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence => testMemberInheritance}/diamond/X.java (100%) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence => testMemberInheritance}/diamond/Z.java (100%) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence => testMemberInheritance}/inheritDist/A.java (100%) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence => testMemberInheritance}/inheritDist/B.java (100%) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence => testMemberInheritance}/inheritDist/C.java (100%) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence => testMemberInheritance}/pkg/BaseClass.java (100%) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence => testMemberInheritance}/pkg/BaseInterface.java (100%) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence => testMemberInheritance}/pkg/SubClass.java (100%) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence => testMemberInheritance}/pkg1/Implementer.java (100%) rename test/langtools/jdk/javadoc/doclet/{testMemberInheritence => testMemberInheritance}/pkg1/Interface.java (100%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods => testOverriddenMethods}/TestBadOverride.java (100%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods/TestMultiInheritence.java => testOverriddenMethods/TestMultiInheritance.java} (93%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods/TestOverridenMethodDocCopy.java => testOverriddenMethods/TestOverriddenMethodDocCopy.java} (91%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods/TestOverridenPrivateMethods.java => testOverriddenMethods/TestOverriddenPrivateMethods.java} (92%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods/TestOverridenPrivateMethodsWithPackageFlag.java => testOverriddenMethods/TestOverriddenPrivateMethodsWithPackageFlag.java} (94%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods/TestOverridenPrivateMethodsWithPrivateFlag.java => testOverriddenMethods/TestOverriddenPrivateMethodsWithPrivateFlag.java} (93%) create mode 100644 test/langtools/jdk/javadoc/doclet/testOverriddenMethods/TestOverrideMethods.java rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods => testOverriddenMethods}/pkg1/BaseClass.java (100%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods => testOverriddenMethods}/pkg1/SubClass.java (100%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods => testOverriddenMethods}/pkg2/SubClass.java (100%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods => testOverriddenMethods}/pkg3/I0.java (100%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods => testOverriddenMethods}/pkg3/I1.java (100%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods => testOverriddenMethods}/pkg3/I2.java (100%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods => testOverriddenMethods}/pkg3/I3.java (100%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods => testOverriddenMethods}/pkg3/I4.java (100%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods => testOverriddenMethods}/pkg4/Foo.java (100%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods => testOverriddenMethods}/pkg5/Classes.java (100%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods => testOverriddenMethods}/pkg5/Interfaces.java (92%) rename test/langtools/jdk/javadoc/doclet/{testOverridenMethods => testOverriddenMethods}/pkg5/TestEnum.java (100%) delete mode 100644 test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverrideMethods.java diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java index cdf7e933d42..d40607164d1 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java @@ -489,6 +489,10 @@ public abstract class MemberSummaryBuilder extends AbstractMemberBuilder { continue; } + // Skip static methods in interfaces they are not inherited + if (utils.isInterface(inheritedClass) && utils.isStatic(inheritedMember)) + continue; + // If applicable, filter those overridden methods that // should not be documented in the summary/detail sections, // and instead document them in the footnote. Care must be taken @@ -496,9 +500,8 @@ public abstract class MemberSummaryBuilder extends AbstractMemberBuilder { // but comments for these are synthesized on the output. ExecutableElement inheritedMethod = (ExecutableElement)inheritedMember; if (enclosedSuperMethods.stream() - .anyMatch(e -> utils.executableMembersEqual(inheritedMethod, e) - && (!utils.isSimpleOverride(e) - || visibleMemberMap.getPropertyElement(e) != null))) { + .anyMatch(e -> utils.executableMembersEqual(inheritedMethod, e) && + (!utils.isSimpleOverride(e) || visibleMemberMap.getPropertyElement(e) != null))) { inheritedMembers.add(inheritedMember); } } diff --git a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/TestMemberInheritence.java b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/TestMemberInheritance.java similarity index 92% rename from test/langtools/jdk/javadoc/doclet/testMemberInheritence/TestMemberInheritence.java rename to test/langtools/jdk/javadoc/doclet/testMemberInheritance/TestMemberInheritance.java index 62235eee870..a4a5baf4e5a 100644 --- a/test/langtools/jdk/javadoc/doclet/testMemberInheritence/TestMemberInheritence.java +++ b/test/langtools/jdk/javadoc/doclet/testMemberInheritance/TestMemberInheritance.java @@ -24,19 +24,20 @@ /* * @test * @bug 4638588 4635809 6256068 6270645 8025633 8026567 8162363 8175200 + * 8192850 * @summary Test to make sure that members are inherited properly in the Javadoc. - * Verify that inheritence labels are correct. + * Verify that inheritance labels are correct. * @author jamieh * @library ../lib * @modules jdk.javadoc/jdk.javadoc.internal.tool * @build JavadocTester - * @run main TestMemberInheritence + * @run main TestMemberInheritance */ -public class TestMemberInheritence extends JavadocTester { +public class TestMemberInheritance extends JavadocTester { public static void main(String... args) throws Exception { - TestMemberInheritence tester = new TestMemberInheritence(); + TestMemberInheritance tester = new TestMemberInheritance(); tester.runTests(); } @@ -77,7 +78,7 @@ public class TestMemberInheritence extends JavadocTester { + "
    "); checkOutput("diamond/Z.html", true, - // Test diamond inheritence member summary (6256068) + // Test diamond inheritance member summary (6256068) "aMethod"); checkOutput("inheritDist/C.html", true, @@ -93,8 +94,9 @@ public class TestMemberInheritence extends JavadocTester { + "" + "" + "between​(java.time.LocalDate startDateInclusive,\n" - + " java.time.LocalDate endDateExclusive)", - // check the inherited from interfaces + + " java.time.LocalDate endDateExclusive)"); + + checkOutput("pkg1/Implementer.html", false, "

    Methods inherited from interface pkg1.Interface

    \n" + "rate", + + // Check nested classes + "Nested classes/interfaces declared in class pkg5.", + "Classes.P", + "./pkg5/Classes.P.PN.html", + "Classes.P.PN.html", + "type parameter in Classes.P.PN\">K", + "type parameter in Classes.P.PN", + "V", + + // Check fields + "Fields declared in class pkg5.field0", + + // Check method summary + "Method Summary", + "void", + "../pkg5/Classes.C.html#m1--\">m1", + "A modified method", + + "void", + "../pkg5/Classes.C.html#m4-java.lang.String-java.lang.String-\">m4", + "java.lang.String k,", + "java.lang.String", + " v)", + + // Check footnotes + "Methods declared in class pkg5.m0", + + // Check method details for override + "overrideSpecifyLabel", + "Overrides:", + "../pkg5/Classes.GP.html#m7--\">m7", + "in class", + "../pkg5/Classes.GP.html", + "Classes.GP" + ); + + checkOrder("pkg5/Classes.C.html", + // Check footnotes 2 + "Methods declared in class pkg5.", + "../pkg5/Classes.P.html#getRate--\">getRate", + "../pkg5/Classes.P.html#m2--\">m2", + "../pkg5/Classes.P.html#m3--\">m3", + "../pkg5/Classes.P.html#m4-K-V-\">m4", + "../pkg5/Classes.P.html#rateProperty--\">rateProperty", + "../pkg5/Classes.P.html#setRate-double-\">setRate", + + // Check @link + "A test of links to the methods in this class.

    \n", + "../pkg5/Classes.GP.html#m0--", + "Classes.GP.m0()", + "../pkg5/Classes.C.html#m1--", + "m1()", + "../pkg5/Classes.P.html#m2--", + "Classes.P.m2()", + "../pkg5/Classes.P.html#m3--", + "Classes.P.m3()", + "m4(java.lang.String,java.lang.String)", + "../pkg5/Classes.P.html#m5--", + "Classes.P.m5()", + "../pkg5/Classes.C.html#m6--", + "m6()", + "../pkg5/Classes.C.html#m7--", + "m7()", + "End of links", + + // Check @see + "See Also:", + "../pkg5/Classes.GP.html#m0--", + "Classes.GP.m0()", + "../pkg5/Classes.C.html#m1--", + "m1()", + "../pkg5/Classes.P.html#m2--", + "Classes.P.m2()", + "../pkg5/Classes.P.html#m3--", + "Classes.P.m3()", + "../pkg5/Classes.C.html#m4-java.lang.String-java.lang.String-", + "m4(String k, String v)", + "../pkg5/Classes.P.html#m5--\">Classes.P.m5()", + "../pkg5/Classes.C.html#m6--\">m6()", + "../pkg5/Classes.C.html#m7--\">m7()" + ); + + // Tests for interfaces + + // Make sure the static methods in the super interface + // do not make it to this interface + checkOutput("pkg5/Interfaces.D.html", false, + "msd", "msn"); + + checkOrder("pkg5/Interfaces.D.html", + "Start of links

    ", + "../pkg5/Interfaces.A.html#m0--\">Interfaces.A.m0()", + "../pkg5/Interfaces.A.html#m1--\">Interfaces.A.m1()", + "../pkg5/Interfaces.A.html#m2--\">Interfaces.A.m2()", + "../pkg5/Interfaces.A.html#m3--\">Interfaces.A.m3()", + "../pkg5/Interfaces.D.html#m--\">m()", + "../pkg5/Interfaces.D.html#n--\">n()", + "../pkg5/Interfaces.C.html#o--\">Interfaces.C.o()", + "End of links", + + // Check @see links + "See Also:", + "../pkg5/Interfaces.A.html#m0--\">Interfaces.A.m0()", + "../pkg5/Interfaces.A.html#m1--\">Interfaces.A.m1()", + "../pkg5/Interfaces.A.html#m2--\">Interfaces.A.m2()", + "../pkg5/Interfaces.A.html#m3--\">Interfaces.A.m3()", + "../pkg5/Interfaces.D.html#m--\">m()", + "../pkg5/Interfaces.D.html#n--\">n()", + "../pkg5/Interfaces.C.html#o--\">Interfaces.C.o()", + + // Check properties + "Properties declared in interface pkg5.Interfaces.A", + + // Check nested classes + "Nested classes/interfaces declared in interface pkg5.", + "Interfaces.A", + "../pkg5/Interfaces.A.AA.html", + "Interfaces.A.AA", + + // Check Fields + "Fields declared in interface pkg5.QUOTE", + "../pkg5/Interfaces.A.html#rate\">rate", + + // Check Method Summary + "Method Summary", + "../pkg5/Interfaces.D.html#m--\">m", + "../pkg5/Interfaces.D.html#n--\">n", + + // Check footnotes + "Methods declared in interface pkg5.getRate", + "../pkg5/Interfaces.A.html#rateProperty--\">rateProperty", + "../pkg5/Interfaces.A.html#setRate-double-", + "Methods declared in interface pkg5.m1", + "../pkg5/Interfaces.B.html#m3--\">m3", + "Methods declared in interface pkg5.o" + ); + + // Test synthetic values and valuesof of an enum. + checkOrder("index-all.html", + "

    M

    ", + "m()", + "m()", + "m0()", + "m0()", + "m1()", + "m1()", + "m1()", + "m1()", + "m2()", + "m2()", + "m3()", + "m3()", + "m3()", + "m4(String, String)", + "m4(K, V)", + "m5()", + "m6()", + "m6()", + "m7()", + "m7()", + "Returns the enum constant of this type with the specified name.", + "Returns an array containing the constants of this enum type, in\n" + + "the order they are declared." + ); + } +} diff --git a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg1/BaseClass.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg1/BaseClass.java similarity index 100% rename from test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg1/BaseClass.java rename to test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg1/BaseClass.java diff --git a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg1/SubClass.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg1/SubClass.java similarity index 100% rename from test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg1/SubClass.java rename to test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg1/SubClass.java diff --git a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg2/SubClass.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg2/SubClass.java similarity index 100% rename from test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg2/SubClass.java rename to test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg2/SubClass.java diff --git a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I0.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I0.java similarity index 100% rename from test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I0.java rename to test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I0.java diff --git a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I1.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I1.java similarity index 100% rename from test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I1.java rename to test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I1.java diff --git a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I2.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I2.java similarity index 100% rename from test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I2.java rename to test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I2.java diff --git a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I3.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I3.java similarity index 100% rename from test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I3.java rename to test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I3.java diff --git a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I4.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I4.java similarity index 100% rename from test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg3/I4.java rename to test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg3/I4.java diff --git a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg4/Foo.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg4/Foo.java similarity index 100% rename from test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg4/Foo.java rename to test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg4/Foo.java diff --git a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/Classes.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg5/Classes.java similarity index 100% rename from test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/Classes.java rename to test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg5/Classes.java diff --git a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/Interfaces.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg5/Interfaces.java similarity index 92% rename from test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/Interfaces.java rename to test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg5/Interfaces.java index 13327a9f526..dfac98fe4c0 100644 --- a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/Interfaces.java +++ b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg5/Interfaces.java @@ -29,6 +29,14 @@ public class Interfaces { /** field f in A */ public int f = 0; + public static String QUOTE = "Winter is coming"; + + /** a documented static method */ + public static void msd() {} + + /* An undocumented static method */ + public static void msn() {} + /** A property in parent */ DoubleProperty rate = null; public void setRate(double l); diff --git a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/TestEnum.java b/test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg5/TestEnum.java similarity index 100% rename from test/langtools/jdk/javadoc/doclet/testOverridenMethods/pkg5/TestEnum.java rename to test/langtools/jdk/javadoc/doclet/testOverriddenMethods/pkg5/TestEnum.java diff --git a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverrideMethods.java b/test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverrideMethods.java deleted file mode 100644 index 92698a8ddc3..00000000000 --- a/test/langtools/jdk/javadoc/doclet/testOverridenMethods/TestOverrideMethods.java +++ /dev/null @@ -1,254 +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. - * - * 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 8157000 - * @summary test the behavior of --override-methods option - * @library ../lib - * @modules jdk.javadoc/jdk.javadoc.internal.tool - * @build JavadocTester - * @run main TestOverrideMethods - */ - -public class TestOverrideMethods extends JavadocTester { - public static void main(String... args) throws Exception { - TestOverrideMethods tester = new TestOverrideMethods(); - tester.runTests(); - } - - @Test - void testInvalidOption() { - // Make sure an invalid argument fails - javadoc("-d", "out-bad-option", - "-sourcepath", testSrc, - "-javafx", - "--override-methods=nonsense", - "pkg5"); - - checkExit(Exit.CMDERR); - } - - @Test - void testDetail() { - // Make sure the option works - javadoc("-d", "out-detail", - "-sourcepath", testSrc, - "-javafx", - "--override-methods=detail", - "pkg5"); - - checkExit(Exit.OK); - } - - @Test - void testSummary() { - javadoc("-d", "out-summary", - "-sourcepath", testSrc, - "-javafx", - "--override-methods=summary", - "pkg5"); - - checkExit(Exit.OK); - - checkOutput("pkg5/Classes.C.html", true, - // Check properties - "

    Properties declared in class pkg5.Classes.P

    \n" - + "rate", - - // Check nested classes - "

    Nested classes/interfaces declared in class pkg5." - + "Classes.P

    \n" - + "" - + "Classes.P.PN<K," - + "" - + "V>\n", - - // Check fields - "

    Fields declared in class pkg5.Classes.P

    \n" - + "field0\n", - - // Check method summary - "void\n" - + "" - + "m1()\n" - + "\n" - + "
    A modified method
    \n", - - "void\n" - + "" - + "m4" - + "​(java.lang.String k,\n" - + " java.lang.String v)\n", - - // Check footnotes - "

    Methods declared in class pkg5.Classes.GP

    \n" - + "m0", - - // Check method details for override - "
    Overrides:
    \n" - + "
    m7" - + " in class Classes.GP
    \n" - ); - - // Check footnotes 2 - checkOrder("pkg5/Classes.C.html", - "Methods declared in class pkg5.", - "getRate, ", - "m2, ", - "m3, ", - "m4, ", - "rateProperty, ", - "setRate" - ); - - // Check @link - checkOrder("pkg5/Classes.C.html", - "A test of links to the methods in this class.

    \n", - "Classes.GP.m0()", - "m1()", - "Classes.P.m2()", - "Classes.P.m3()", - "m4(java.lang.String,java.lang.String)", - "Classes.P.m5()", - "m6()", - "m7()", - "End of links" - ); - - // Check @see - checkOrder("pkg5/Classes.C.html", - "See Also:", - "Classes.GP.m0()", - "m1()", - "Classes.P.m2()", - "Classes.P.m3()", - "" - + "m4(String k, String v)", - "Classes.P.m5()", - "m6()", - "m7()" - ); - - checkOutput("pkg5/Interfaces.D.html", true, - // Check properties - "

    Properties declared in interface pkg5.Interfaces.A", - - // Check nested classes - "

    Nested classes/interfaces declared in interface pkg5." - + "" - + "Interfaces.A

    \n" - + "Interfaces.A.AA", - - // Check fields - "

    Fields declared in interface pkg5.Interfaces.A

    \n" - + "f", - - // Check method summary - "void\n" - + "" - + "m()\n" - + "\n" - + "
    m in D
    \n", - - "void\n" - + "" - + "n()\n" - + "\n" - + "
    n in D
    \n", - - // Check footnote - "

    Methods declared in interface pkg5.Interfaces.A

    \n" - + "getRate, " - + "rateProperty, " - + "setRate", - - "

    Methods declared in interface pkg5.Interfaces.B

    \n" - + "m1, " - + "m3", - - "

    Methods declared in interface pkg5.Interfaces.C

    \n" - + "o" - ); - - checkOrder("pkg5/Interfaces.D.html", - "Start of links

    ", - "Interfaces.A.m0()", - "Interfaces.A.m1()", - "Interfaces.A.m2()", - "Interfaces.A.m3()", - "m()", - "n()", - "Interfaces.C.o()", - "End of links"); - - checkOrder("pkg5/Interfaces.D.html", - "See Also:", - "Interfaces.A.m0()", - "Interfaces.A.m1()", - "Interfaces.A.m2()", - "Interfaces.A.m3()", - "m()", - "n()", - "Interfaces.C.o()"); - - // Test synthetic values and valuesof of an enum. - checkOrder("index-all.html", - "

    M

    ", - "m()", - "m()", - "m0()", - "m0()", - "m1()", - "m1()", - "m1()", - "m1()", - "m2()", - "m2()", - "m3()", - "m3()", - "m3()", - "m4(String, String)", - "m4(K, V)", - "m5()", - "m6()", - "m6()", - "m7()", - "m7()", - "Returns the enum constant of this type with the specified name.", - "Returns an array containing the constants of this enum type, in\n" + - "the order they are declared." - ); - } -} From 7362d582941b97b44f9bd9e8b0ed6950583e9874 Mon Sep 17 00:00:00 2001 From: Nishit Jain Date: Wed, 13 Dec 2017 12:43:38 +0530 Subject: [PATCH 21/26] 8190278: ClassCastException is thrown by java.util.Scanner when a NumberFormatProvider is used Reviewed-by: naoto, rriggs --- .../share/classes/java/util/Scanner.java | 25 ++++++- .../Scanner/spi/UseLocaleWithProvider.java | 69 +++++++++++++++++++ .../Scanner/spi/provider/module-info.java | 26 +++++++ .../spi/provider/test/NumberFormatImpl.java | 48 +++++++++++++ .../test/NumberFormatProviderImpl.java | 59 ++++++++++++++++ 5 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 test/jdk/java/util/Scanner/spi/UseLocaleWithProvider.java create mode 100644 test/jdk/java/util/Scanner/spi/provider/module-info.java create mode 100644 test/jdk/java/util/Scanner/spi/provider/test/NumberFormatImpl.java create mode 100644 test/jdk/java/util/Scanner/spi/provider/test/NumberFormatProviderImpl.java diff --git a/src/java.base/share/classes/java/util/Scanner.java b/src/java.base/share/classes/java/util/Scanner.java index 8ea0826faa7..7ac4fb3422b 100644 --- a/src/java.base/share/classes/java/util/Scanner.java +++ b/src/java.base/share/classes/java/util/Scanner.java @@ -33,10 +33,13 @@ import java.nio.charset.*; import java.nio.file.Path; import java.nio.file.Files; import java.text.*; +import java.text.spi.NumberFormatProvider; import java.util.function.Consumer; import java.util.regex.*; import java.util.stream.Stream; import java.util.stream.StreamSupport; +import sun.util.locale.provider.LocaleProviderAdapter; +import sun.util.locale.provider.ResourceBundleBasedAdapter; /** * A simple text scanner which can parse primitive types and strings using @@ -1262,9 +1265,27 @@ public final class Scanner implements Iterator, Closeable { modCount++; this.locale = locale; - DecimalFormat df = - (DecimalFormat)NumberFormat.getNumberInstance(locale); + + DecimalFormat df = null; + NumberFormat nf = NumberFormat.getNumberInstance(locale); DecimalFormatSymbols dfs = DecimalFormatSymbols.getInstance(locale); + if (nf instanceof DecimalFormat) { + df = (DecimalFormat) nf; + } else { + + // In case where NumberFormat.getNumberInstance() returns + // other instance (non DecimalFormat) based on the provider + // used and java.text.spi.NumberFormatProvider implementations, + // DecimalFormat constructor is used to obtain the instance + LocaleProviderAdapter adapter = LocaleProviderAdapter + .getAdapter(NumberFormatProvider.class, locale); + if (!(adapter instanceof ResourceBundleBasedAdapter)) { + adapter = LocaleProviderAdapter.getResourceBundleBased(); + } + String[] all = adapter.getLocaleResources(locale) + .getNumberPatterns(); + df = new DecimalFormat(all[0], dfs); + } // These must be literalized to avoid collision with regex // metacharacters such as dot or parenthesis diff --git a/test/jdk/java/util/Scanner/spi/UseLocaleWithProvider.java b/test/jdk/java/util/Scanner/spi/UseLocaleWithProvider.java new file mode 100644 index 00000000000..0cf12c9f289 --- /dev/null +++ b/test/jdk/java/util/Scanner/spi/UseLocaleWithProvider.java @@ -0,0 +1,69 @@ +/* + * 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 8190278 + * @summary checks the Scanner.useLocale() with java.locale.providers=SPI, + * COMPAT. It should not throw ClassCastException if any SPI is + * used and NumberFormat.getInstance() does not return a + * DecimalFormat object. Also, to test the behaviour of Scanner + * while scanning numbers in the format of Scanner's locale. + * @modules jdk.localedata + * @library provider + * @build provider/module-info provider/test.NumberFormatProviderImpl + * provider/test.NumberFormatImpl + * @run main/othervm -Djava.locale.providers=SPI,COMPAT UseLocaleWithProvider + */ + +import java.util.Locale; +import java.util.Scanner; + +public class UseLocaleWithProvider { + + public static void main(String[] args) { + + try { + testScannerUseLocale("-123.4", Locale.US, -123.4); + testScannerUseLocale("-123,45", new Locale("fi", "FI"), -123.45); + testScannerUseLocale("334,65", Locale.FRENCH, 334.65); + testScannerUseLocale("4.334,65", Locale.GERMAN, 4334.65); + } catch (ClassCastException ex) { + throw new RuntimeException("[FAILED: With" + + " java.locale.providers=SPI,COMPAT, Scanner.useLocale()" + + " shouldn't throw ClassCastException]"); + } + } + + private static void testScannerUseLocale(String number, Locale locale, + Number actual) { + Scanner sc = new Scanner(number).useLocale(locale); + if (!sc.hasNextFloat() || sc.nextFloat() != actual.floatValue()) { + throw new RuntimeException("[FAILED: With" + + " java.locale.providers=SPI,COMPAT, Scanner" + + ".hasNextFloat() or Scanner.nextFloat() is unable to" + + " scan the given number: " + number + ", in the given" + + " locale:" + locale + "]"); + } + } +} + diff --git a/test/jdk/java/util/Scanner/spi/provider/module-info.java b/test/jdk/java/util/Scanner/spi/provider/module-info.java new file mode 100644 index 00000000000..4db1047e305 --- /dev/null +++ b/test/jdk/java/util/Scanner/spi/provider/module-info.java @@ -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. + * + * 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. +*/ +module provider { + exports test; + provides java.text.spi.NumberFormatProvider with test.NumberFormatProviderImpl; +} diff --git a/test/jdk/java/util/Scanner/spi/provider/test/NumberFormatImpl.java b/test/jdk/java/util/Scanner/spi/provider/test/NumberFormatImpl.java new file mode 100644 index 00000000000..2c57b092908 --- /dev/null +++ b/test/jdk/java/util/Scanner/spi/provider/test/NumberFormatImpl.java @@ -0,0 +1,48 @@ +/* + * 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 test; + +import java.text.FieldPosition; +import java.text.NumberFormat; +import java.text.ParsePosition; + +public class NumberFormatImpl extends NumberFormat { + + @Override + public StringBuffer format(double number, StringBuffer toAppendTo, + FieldPosition pos) { + return null; + } + + @Override + public StringBuffer format(long number, StringBuffer toAppendTo, + FieldPosition pos) { + return null; + } + + @Override + public Number parse(String source, ParsePosition parsePosition) { + return null; + } +} + diff --git a/test/jdk/java/util/Scanner/spi/provider/test/NumberFormatProviderImpl.java b/test/jdk/java/util/Scanner/spi/provider/test/NumberFormatProviderImpl.java new file mode 100644 index 00000000000..c8e082b302c --- /dev/null +++ b/test/jdk/java/util/Scanner/spi/provider/test/NumberFormatProviderImpl.java @@ -0,0 +1,59 @@ +/* + * 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 test; + +import java.text.NumberFormat; +import java.text.spi.NumberFormatProvider; +import java.util.Locale; + +public class NumberFormatProviderImpl extends NumberFormatProvider { + + private static final Locale[] locales = {Locale.US, Locale.FRENCH, + Locale.GERMAN, new Locale("fi", "FI")}; + + @Override + public NumberFormat getCurrencyInstance(Locale locale) { + return null; + } + + @Override + public NumberFormat getIntegerInstance(Locale locale) { + return null; + } + + @Override + public NumberFormat getNumberInstance(Locale locale) { + return new NumberFormatImpl(); + } + + @Override + public NumberFormat getPercentInstance(Locale locale) { + return null; + } + + @Override + public Locale[] getAvailableLocales() { + return locales; + } +} + From 17b766fb1d641d6ffe2a056a161cb8c7da74c1d0 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Wed, 13 Dec 2017 11:27:28 +0100 Subject: [PATCH 22/26] 8191636: [Windows] jshell tool: Wrong character in /env class-path command crashes jshell Fixing handling of invalid paths. Reviewed-by: rfield --- .../jdk/internal/jshell/tool/JShellTool.java | 13 ++++++++++++- test/langtools/jdk/jshell/ToolSimpleTest.java | 4 +++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index cfd9477bb4b..b21f782ed33 100644 --- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -43,6 +43,7 @@ import java.lang.module.ModuleReference; import java.nio.charset.Charset; import java.nio.file.FileSystems; import java.nio.file.Files; +import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; import java.text.MessageFormat; @@ -381,7 +382,7 @@ public class JShellTool implements MessageHandler { private Collection validPaths(Collection vals, String context, boolean isModulePath) { Stream result = vals.stream() .map(s -> Arrays.stream(s.split(File.pathSeparator)) - .map(sp -> toPathResolvingUserHome(sp)) + .flatMap(sp -> toPathImpl(sp, context)) .filter(p -> checkValidPathEntry(p, context, isModulePath)) .map(p -> p.toString()) .collect(Collectors.joining(File.pathSeparator))); @@ -421,6 +422,16 @@ public class JShellTool implements MessageHandler { return false; } + private Stream toPathImpl(String path, String context) { + try { + return Stream.of(toPathResolvingUserHome(path)); + } catch (InvalidPathException ex) { + msg("jshell.err.file.not.found", context, path); + failed = true; + return Stream.empty(); + } + } + Options parse(OptionSet options) { addOptions(OptionKind.CLASS_PATH, validPaths(options.valuesOf(argClassPath), "--class-path", false)); diff --git a/test/langtools/jdk/jshell/ToolSimpleTest.java b/test/langtools/jdk/jshell/ToolSimpleTest.java index 73ccd49c9f6..43a018d6b1a 100644 --- a/test/langtools/jdk/jshell/ToolSimpleTest.java +++ b/test/langtools/jdk/jshell/ToolSimpleTest.java @@ -216,7 +216,9 @@ public class ToolSimpleTest extends ReplToolTesting { public void testInvalidClassPath() { test( a -> assertCommand(a, "/env --class-path snurgefusal", - "| File 'snurgefusal' for '--class-path' is not found.") + "| File 'snurgefusal' for '--class-path' is not found."), + a -> assertCommand(a, "/env --class-path ?", + "| File '?' for '--class-path' is not found.") ); } From 3f0f9ef30c8b93eb8be2a70349444688a0f4daea Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Wed, 6 Dec 2017 15:51:06 -0800 Subject: [PATCH 23/26] 8193034: Optimize URL.toExternalForm Reviewed-by: chegar, alanb, clanger --- .../classes/java/net/URLStreamHandler.java | 41 ++++--------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/src/java.base/share/classes/java/net/URLStreamHandler.java b/src/java.base/share/classes/java/net/URLStreamHandler.java index 5e32ab13210..9232b60c28c 100644 --- a/src/java.base/share/classes/java/net/URLStreamHandler.java +++ b/src/java.base/share/classes/java/net/URLStreamHandler.java @@ -480,39 +480,14 @@ public abstract class URLStreamHandler { * @return a string representation of the {@code URL} argument. */ protected String toExternalForm(URL u) { - - // pre-compute length of StringBuffer - int len = u.getProtocol().length() + 1; - if (u.getAuthority() != null && u.getAuthority().length() > 0) - len += 2 + u.getAuthority().length(); - if (u.getPath() != null) { - len += u.getPath().length(); - } - if (u.getQuery() != null) { - len += 1 + u.getQuery().length(); - } - if (u.getRef() != null) - len += 1 + u.getRef().length(); - - StringBuilder result = new StringBuilder(len); - result.append(u.getProtocol()); - result.append(":"); - if (u.getAuthority() != null && u.getAuthority().length() > 0) { - result.append("//"); - result.append(u.getAuthority()); - } - if (u.getPath() != null) { - result.append(u.getPath()); - } - if (u.getQuery() != null) { - result.append('?'); - result.append(u.getQuery()); - } - if (u.getRef() != null) { - result.append("#"); - result.append(u.getRef()); - } - return result.toString(); + String s; + return u.getProtocol() + + ':' + + (((s = u.getAuthority()) != null && s.length() > 0) + ? "//" + s : "") + + (((s = u.getPath()) != null) ? s : "") + + (((s = u.getQuery()) != null) ? '?' + s : "") + + (((s = u.getRef()) != null) ? '#' + s : ""); } /** From 1ae8f548354f7cd5a43663924a0321989abc0ee6 Mon Sep 17 00:00:00 2001 From: Andrej Golovnin Date: Wed, 13 Dec 2017 15:32:36 +0000 Subject: [PATCH 24/26] 8193454: ModuleDescriptor.{Requires,Exports,Open} toString should use toLowerCase(Local.ROOT) Reviewed-by: alanb --- .../share/classes/java/lang/module/ModuleDescriptor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java index e8cdbccfb94..7a4ace8dd6b 100644 --- a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java +++ b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java @@ -39,6 +39,7 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Optional; @@ -2603,7 +2604,8 @@ public class ModuleDescriptor * Returns a string containing the given set of modifiers and label. */ private static String toString(Set mods, String what) { - return (Stream.concat(mods.stream().map(e -> e.toString().toLowerCase()), + return (Stream.concat(mods.stream().map(e -> e.toString() + .toLowerCase(Locale.ROOT)), Stream.of(what))) .collect(Collectors.joining(" ")); } From 4f0ea9242f35ccb2a557a2f2099a4f6ffefb7a8a Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Wed, 13 Dec 2017 07:51:57 -0800 Subject: [PATCH 25/26] 8184947: ZipCoder performance improvements Reviewed-by: martin, redestad --- .../share/classes/java/lang/String.java | 4 + .../share/classes/java/lang/StringCoding.java | 775 ++++++++++++------ .../classes/java/lang/StringDecoderUTF8.java | 235 ------ .../share/classes/java/lang/System.java | 9 + .../share/classes/java/util/zip/ZipCoder.java | 153 ++-- .../jdk/internal/misc/JavaLangAccess.java | 19 + .../share/classes/sun/nio/cs/ISO_8859_1.java | 55 +- .../share/classes/sun/nio/cs/US_ASCII.java | 59 +- .../share/classes/sun/nio/cs/UTF_8.java | 192 +---- 9 files changed, 620 insertions(+), 881 deletions(-) delete mode 100644 src/java.base/share/classes/java/lang/StringDecoderUTF8.java diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index e3da498617c..4631e13eb64 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -3046,6 +3046,10 @@ public final class String return COMPACT_STRINGS ? coder : UTF16; } + byte[] value() { + return value; + } + private boolean isLatin1() { return COMPACT_STRINGS && coder == LATIN1; } diff --git a/src/java.base/share/classes/java/lang/StringCoding.java b/src/java.base/share/classes/java/lang/StringCoding.java index 44eed95f32a..11ba41d62b8 100644 --- a/src/java.base/share/classes/java/lang/StringCoding.java +++ b/src/java.base/share/classes/java/lang/StringCoding.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 @@ -47,6 +47,11 @@ import sun.nio.cs.StandardCharsets; import static java.lang.String.LATIN1; import static java.lang.String.UTF16; import static java.lang.String.COMPACT_STRINGS; +import static java.lang.Character.isSurrogate; +import static java.lang.Character.highSurrogate; +import static java.lang.Character.lowSurrogate; +import static java.lang.Character.isSupplementaryCodePoint; +import static java.lang.StringUTF16.putChar; /** * Utility class for string encoding and decoding. @@ -66,8 +71,6 @@ class StringCoding { private static final Charset US_ASCII = sun.nio.cs.US_ASCII.INSTANCE; private static final Charset UTF_8 = sun.nio.cs.UTF_8.INSTANCE; - private static boolean warnUnsupportedCharset = true; - private static T deref(ThreadLocal> tl) { SoftReference sr = tl.get(); if (sr == null) @@ -80,7 +83,6 @@ class StringCoding { } // Trim the given byte array to the given length - // private static byte[] safeTrim(byte[] ba, int len, boolean isTrusted) { if (len == ba.length && (isTrusted || System.getSecurityManager() == null)) return ba; @@ -105,17 +107,6 @@ class StringCoding { return null; } - private static void warnUnsupportedCharset(String csn) { - if (warnUnsupportedCharset) { - // Use err(String) rather than the Logging API or System.err - // since this method may be called during VM initialization - // before either is available. - err("WARNING: Default charset " + csn + - " not supported, using ISO-8859-1 instead\n"); - warnUnsupportedCharset = false; - } - } - static class Result { byte[] value; byte coder; @@ -224,19 +215,6 @@ class StringCoding { } } - private static class StringDecoder8859_1 extends StringDecoder { - StringDecoder8859_1(Charset cs, String rcn) { - super(cs, rcn); - } - Result decode(byte[] ba, int off, int len) { - if (COMPACT_STRINGS) { - return result.with(Arrays.copyOfRange(ba, off, off + len), LATIN1); - } else { - return result.with(StringLatin1.inflate(ba, off, len), UTF16); - } - } - } - static Result decode(String charsetName, byte[] ba, int off, int len) throws UnsupportedEncodingException { @@ -249,12 +227,15 @@ class StringCoding { Charset cs = lookupCharset(csn); if (cs != null) { if (cs == UTF_8) { - sd = new StringDecoderUTF8(cs, csn); - } else if (cs == ISO_8859_1) { - sd = new StringDecoder8859_1(cs, csn); - } else { - sd = new StringDecoder(cs, csn); + return decodeUTF8(ba, off, len, true); } + if (cs == ISO_8859_1) { + return decodeLatin1(ba, off, len); + } + if (cs == US_ASCII) { + return decodeASCII(ba, off, len); + } + sd = new StringDecoder(cs, csn); } } catch (IllegalCharsetNameException x) {} if (sd == null) @@ -265,6 +246,16 @@ class StringCoding { } static Result decode(Charset cs, byte[] ba, int off, int len) { + if (cs == UTF_8) { + return decodeUTF8(ba, off, len, true); + } + if (cs == ISO_8859_1) { + return decodeLatin1(ba, off, len); + } + if (cs == US_ASCII) { + return decodeASCII(ba, off, len); + } + // (1)We never cache the "external" cs, the only benefit of creating // an additional StringDe/Encoder object to wrap it is to share the // de/encode() method. These SD/E objects are short-lived, the young-gen @@ -280,39 +271,29 @@ class StringCoding { // check (... && (isTrusted || SM == null || getClassLoader0())) in trim // but it then can be argued that the SM is null when the operation // is started... - if (cs == UTF_8) { - return StringDecoderUTF8.decode(ba, off, len, new Result()); - } CharsetDecoder cd = cs.newDecoder(); // ascii fastpath - if (cs == ISO_8859_1 || ((cd instanceof ArrayDecoder) && - ((ArrayDecoder)cd).isASCIICompatible() && - !hasNegatives(ba, off, len))) { - if (COMPACT_STRINGS) { - return new Result().with(Arrays.copyOfRange(ba, off, off + len), - LATIN1); - } else { - return new Result().with(StringLatin1.inflate(ba, off, len), UTF16); - } + if ((cd instanceof ArrayDecoder) && + ((ArrayDecoder)cd).isASCIICompatible() && !hasNegatives(ba, off, len)) { + return decodeLatin1(ba, off, len); } int en = scale(len, cd.maxCharsPerByte()); if (len == 0) { return new Result().with(); } - if (cs.getClass().getClassLoader0() != null && - System.getSecurityManager() != null) { - ba = Arrays.copyOfRange(ba, off, off + len); - off = 0; - } cd.onMalformedInput(CodingErrorAction.REPLACE) .onUnmappableCharacter(CodingErrorAction.REPLACE) .reset(); - char[] ca = new char[en]; if (cd instanceof ArrayDecoder) { int clen = ((ArrayDecoder)cd).decode(ba, off, len, ca); return new Result().with(ca, 0, clen); } + if (cs.getClass().getClassLoader0() != null && + System.getSecurityManager() != null) { + ba = Arrays.copyOfRange(ba, off, off + len); + off = 0; + } ByteBuffer bb = ByteBuffer.wrap(ba, off, len); CharBuffer cb = CharBuffer.wrap(ca); try { @@ -331,24 +312,22 @@ class StringCoding { } static Result decode(byte[] ba, int off, int len) { - String csn = Charset.defaultCharset().name(); - try { - // use charset name decode() variant which provides caching. - return decode(csn, ba, off, len); - } catch (UnsupportedEncodingException x) { - warnUnsupportedCharset(csn); + Charset cs = Charset.defaultCharset(); + if (cs == UTF_8) { + return decodeUTF8(ba, off, len, true); } - try { - return decode("ISO-8859-1", ba, off, len); - } catch (UnsupportedEncodingException x) { - // If this code is hit during VM initialization, err(String) is - // the only way we will be able to get any kind of error message. - err("ISO-8859-1 charset not available: " + x.toString() + "\n"); - // If we can not find ISO-8859-1 (a required encoding) then things - // are seriously wrong with the installation. - System.exit(1); - return null; + if (cs == ISO_8859_1) { + return decodeLatin1(ba, off, len); } + if (cs == US_ASCII) { + return decodeASCII(ba, off, len); + } + StringDecoder sd = deref(decoder); + if (sd == null || !cs.name().equals(sd.cs.name())) { + sd = new StringDecoder(cs, cs.name()); + set(decoder, sd); + } + return sd.decode(ba, off, len); } // -- Encoding -- @@ -393,9 +372,6 @@ class StringCoding { return ba; } if (ce instanceof ArrayEncoder) { - if (!isTrusted) { - val = Arrays.copyOf(val, val.length); - } int blen = (coder == LATIN1 ) ? ((ArrayEncoder)ce).encodeFromLatin1(val, 0, len, ba) : ((ArrayEncoder)ce).encodeFromUTF16(val, 0, len, ba); if (blen != -1) { @@ -423,49 +399,140 @@ class StringCoding { } } - @HotSpotIntrinsicCandidate - private static int implEncodeISOArray(byte[] sa, int sp, - byte[] da, int dp, int len) { - int i = 0; - for (; i < len; i++) { - char c = StringUTF16.getChar(sa, sp++); - if (c > '\u00FF') - break; - da[dp++] = (byte)c; + static byte[] encode(String charsetName, byte coder, byte[] val) + throws UnsupportedEncodingException + { + StringEncoder se = deref(encoder); + String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; + if ((se == null) || !(csn.equals(se.requestedCharsetName()) + || csn.equals(se.charsetName()))) { + se = null; + try { + Charset cs = lookupCharset(csn); + if (cs != null) { + if (cs == UTF_8) { + return encodeUTF8(coder, val, true); + } + if (cs == ISO_8859_1) { + return encode8859_1(coder, val); + } + if (cs == US_ASCII) { + return encodeASCII(coder, val); + } + se = new StringEncoder(cs, csn); + } + } catch (IllegalCharsetNameException x) {} + if (se == null) { + throw new UnsupportedEncodingException (csn); + } + set(encoder, se); } - return i; + return se.encode(coder, val); } - static byte[] encode8859_1(byte coder, byte[] val) { - if (coder == LATIN1) { + static byte[] encode(Charset cs, byte coder, byte[] val) { + if (cs == UTF_8) { + return encodeUTF8(coder, val, true); + } + if (cs == ISO_8859_1) { + return encode8859_1(coder, val); + } + if (cs == US_ASCII) { + return encodeASCII(coder, val); + } + CharsetEncoder ce = cs.newEncoder(); + // fastpath for ascii compatible + if (coder == LATIN1 && (((ce instanceof ArrayEncoder) && + ((ArrayEncoder)ce).isASCIICompatible() && + !hasNegatives(val, 0, val.length)))) { return Arrays.copyOf(val, val.length); } - int len = val.length >> 1; - byte[] dst = new byte[len]; - int dp = 0; - int sp = 0; - int sl = len; - while (sp < sl) { - int ret = implEncodeISOArray(val, sp, dst, dp, len); - sp = sp + ret; - dp = dp + ret; - if (ret != len) { - char c = StringUTF16.getChar(val, sp++); - if (Character.isHighSurrogate(c) && sp < sl && - Character.isLowSurrogate(StringUTF16.getChar(val, sp))) { - sp++; - } - dst[dp++] = '?'; - len = sl - sp; + int len = val.length >> coder; // assume LATIN1=0/UTF16=1; + int en = scale(len, ce.maxBytesPerChar()); + byte[] ba = new byte[en]; + if (len == 0) { + return ba; + } + ce.onMalformedInput(CodingErrorAction.REPLACE) + .onUnmappableCharacter(CodingErrorAction.REPLACE) + .reset(); + if (ce instanceof ArrayEncoder) { + int blen = (coder == LATIN1 ) ? ((ArrayEncoder)ce).encodeFromLatin1(val, 0, len, ba) + : ((ArrayEncoder)ce).encodeFromUTF16(val, 0, len, ba); + if (blen != -1) { + return safeTrim(ba, blen, true); } } - if (dp == dst.length) { - return dst; + boolean isTrusted = cs.getClass().getClassLoader0() == null || + System.getSecurityManager() == null; + char[] ca = (coder == LATIN1 ) ? StringLatin1.toChars(val) + : StringUTF16.toChars(val); + ByteBuffer bb = ByteBuffer.wrap(ba); + CharBuffer cb = CharBuffer.wrap(ca, 0, len); + try { + CoderResult cr = ce.encode(cb, bb, true); + if (!cr.isUnderflow()) + cr.throwException(); + cr = ce.flush(bb); + if (!cr.isUnderflow()) + cr.throwException(); + } catch (CharacterCodingException x) { + throw new Error(x); } - return Arrays.copyOf(dst, dp); + return safeTrim(ba, bb.position(), isTrusted); } - static byte[] encodeASCII(byte coder, byte[] val) { + static byte[] encode(byte coder, byte[] val) { + Charset cs = Charset.defaultCharset(); + if (cs == UTF_8) { + return encodeUTF8(coder, val, true); + } + if (cs == ISO_8859_1) { + return encode8859_1(coder, val); + } + if (cs == US_ASCII) { + return encodeASCII(coder, val); + } + StringEncoder se = deref(encoder); + if (se == null || !cs.name().equals(se.cs.name())) { + se = new StringEncoder(cs, cs.name()); + set(encoder, se); + } + return se.encode(coder, val); + } + + /** + * Print a message directly to stderr, bypassing all character conversion + * methods. + * @param msg message to print + */ + private static native void err(String msg); + + /* The cached Result for each thread */ + private static final ThreadLocal + resultCached = new ThreadLocal<>() { + protected StringCoding.Result initialValue() { + return new StringCoding.Result(); + }}; + + ////////////////////////// ascii ////////////////////////////// + + private static Result decodeASCII(byte[] ba, int off, int len) { + Result result = resultCached.get(); + if (COMPACT_STRINGS && !hasNegatives(ba, off, len)) { + return result.with(Arrays.copyOfRange(ba, off, off + len), + LATIN1); + } + byte[] dst = new byte[len<<1]; + int dp = 0; + while (dp < len) { + int b = ba[off++]; + putChar(dst, dp++, (b >= 0) ? (char)b : repl); + } + return result.with(dst, UTF16); + } + + private static byte[] encodeASCII(byte coder, byte[] val) { if (coder == LATIN1) { byte[] dst = new byte[val.length]; for (int i = 0; i < val.length; i++) { @@ -498,59 +565,51 @@ class StringCoding { return Arrays.copyOf(dst, dp); } - static byte[] encodeUTF8(byte coder, byte[] val) { - int dp = 0; - byte[] dst; + ////////////////////////// latin1/8859_1 /////////////////////////// + + private static Result decodeLatin1(byte[] ba, int off, int len) { + Result result = resultCached.get(); + if (COMPACT_STRINGS) { + return result.with(Arrays.copyOfRange(ba, off, off + len), LATIN1); + } else { + return result.with(StringLatin1.inflate(ba, off, len), UTF16); + } + } + + @HotSpotIntrinsicCandidate + private static int implEncodeISOArray(byte[] sa, int sp, + byte[] da, int dp, int len) { + int i = 0; + for (; i < len; i++) { + char c = StringUTF16.getChar(sa, sp++); + if (c > '\u00FF') + break; + da[dp++] = (byte)c; + } + return i; + } + + private static byte[] encode8859_1(byte coder, byte[] val) { if (coder == LATIN1) { - dst = new byte[val.length << 1]; - for (int sp = 0; sp < val.length; sp++) { - byte c = val[sp]; - if (c < 0) { - dst[dp++] = (byte)(0xc0 | ((c & 0xff) >> 6)); - dst[dp++] = (byte)(0x80 | (c & 0x3f)); - } else { - dst[dp++] = c; - } - } - } else { - int sp = 0; - int sl = val.length >> 1; - dst = new byte[sl * 3]; - char c; - while (sp < sl && (c = StringUTF16.getChar(val, sp)) < '\u0080') { - // ascii fast loop; - dst[dp++] = (byte)c; - sp++; - } - while (sp < sl) { - c = StringUTF16.getChar(val, sp++); - if (c < 0x80) { - dst[dp++] = (byte)c; - } else if (c < 0x800) { - dst[dp++] = (byte)(0xc0 | (c >> 6)); - dst[dp++] = (byte)(0x80 | (c & 0x3f)); - } else if (Character.isSurrogate(c)) { - int uc = -1; - char c2; - if (Character.isHighSurrogate(c) && sp < sl && - Character.isLowSurrogate(c2 = StringUTF16.getChar(val, sp))) { - uc = Character.toCodePoint(c, c2); - } - if (uc < 0) { - dst[dp++] = '?'; - } else { - dst[dp++] = (byte)(0xf0 | ((uc >> 18))); - dst[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f)); - dst[dp++] = (byte)(0x80 | ((uc >> 6) & 0x3f)); - dst[dp++] = (byte)(0x80 | (uc & 0x3f)); - sp++; // 2 chars - } - } else { - // 3 bytes, 16 bits - dst[dp++] = (byte)(0xe0 | ((c >> 12))); - dst[dp++] = (byte)(0x80 | ((c >> 6) & 0x3f)); - dst[dp++] = (byte)(0x80 | (c & 0x3f)); + return Arrays.copyOf(val, val.length); + } + int len = val.length >> 1; + byte[] dst = new byte[len]; + int dp = 0; + int sp = 0; + int sl = len; + while (sp < sl) { + int ret = implEncodeISOArray(val, sp, dst, dp, len); + sp = sp + ret; + dp = dp + ret; + if (ret != len) { + char c = StringUTF16.getChar(val, sp++); + if (Character.isHighSurrogate(c) && sp < sl && + Character.isLowSurrogate(StringUTF16.getChar(val, sp))) { + sp++; } + dst[dp++] = '?'; + len = sl - sp; } } if (dp == dst.length) { @@ -559,113 +618,333 @@ class StringCoding { return Arrays.copyOf(dst, dp); } - static byte[] encode(String charsetName, byte coder, byte[] val) - throws UnsupportedEncodingException - { - StringEncoder se = deref(encoder); - String csn = (charsetName == null) ? "ISO-8859-1" : charsetName; - if ((se == null) || !(csn.equals(se.requestedCharsetName()) - || csn.equals(se.charsetName()))) { - se = null; - try { - Charset cs = lookupCharset(csn); - if (cs != null) { - if (cs == UTF_8) { - return encodeUTF8(coder, val); - } else if (cs == ISO_8859_1) { - return encode8859_1(coder, val); - } else if (cs == US_ASCII) { - return encodeASCII(coder, val); - } - se = new StringEncoder(cs, csn); + //////////////////////////////// utf8 //////////////////////////////////// + + private static boolean isNotContinuation(int b) { + return (b & 0xc0) != 0x80; + } + + private static boolean isMalformed3(int b1, int b2, int b3) { + return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) || + (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80; + } + + private static boolean isMalformed3_2(int b1, int b2) { + return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) || + (b2 & 0xc0) != 0x80; + } + + private static boolean isMalformed4(int b2, int b3, int b4) { + return (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 || + (b4 & 0xc0) != 0x80; + } + + private static boolean isMalformed4_2(int b1, int b2) { + return (b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) || + (b1 == 0xf4 && (b2 & 0xf0) != 0x80) || + (b2 & 0xc0) != 0x80; + } + + private static boolean isMalformed4_3(int b3) { + return (b3 & 0xc0) != 0x80; + } + + // for nb == 3/4 + private static int malformedN(byte[] src, int sp, int nb) { + if (nb == 3) { + int b1 = src[sp++]; + int b2 = src[sp++]; // no need to lookup b3 + return ((b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) || + isNotContinuation(b2)) ? 1 : 2; + } else if (nb == 4) { // we don't care the speed here + int b1 = src[sp++] & 0xff; + int b2 = src[sp++] & 0xff; + if (b1 > 0xf4 || + (b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) || + (b1 == 0xf4 && (b2 & 0xf0) != 0x80) || + isNotContinuation(b2)) + return 1; + if (isNotContinuation(src[sp++])) + return 2; + return 3; + } + assert false; + return -1; + } + + private static void throwMalformed(int off, int nb) { + throw new IllegalArgumentException("malformed input off : " + off + + ", length : " + nb); + } + + private static char repl = '\ufffd'; + + private static Result decodeUTF8(byte[] src, int sp, int len, boolean doReplace) { + // ascii-bais, which has a relative impact to the non-ascii-only bytes + if (COMPACT_STRINGS && !hasNegatives(src, sp, len)) + return resultCached.get().with(Arrays.copyOfRange(src, sp, sp + len), + LATIN1); + return decodeUTF8_0(src, sp, len, doReplace); + } + + private static Result decodeUTF8_0(byte[] src, int sp, int len, boolean doReplace) { + Result ret = resultCached.get(); + + int sl = sp + len; + int dp = 0; + byte[] dst = new byte[len]; + + if (COMPACT_STRINGS) { + while (sp < sl) { + int b1 = src[sp]; + if (b1 >= 0) { + dst[dp++] = (byte)b1; + sp++; + continue; } - } catch (IllegalCharsetNameException x) {} - if (se == null) { - throw new UnsupportedEncodingException (csn); + if ((b1 == (byte)0xc2 || b1 == (byte)0xc3) && + sp + 1 < sl) { + int b2 = src[sp + 1]; + if (!isNotContinuation(b2)) { + dst[dp++] = (byte)(((b1 << 6) ^ b2)^ + (((byte) 0xC0 << 6) ^ + ((byte) 0x80 << 0))); + sp += 2; + continue; + } + } + // anything not a latin1, including the repl + // we have to go with the utf16 + break; + } + if (sp == sl) { + if (dp != dst.length) { + dst = Arrays.copyOf(dst, dp); + } + return ret.with(dst, LATIN1); } - set(encoder, se); } - return se.encode(coder, val); + if (dp == 0) { + dst = new byte[len << 1]; + } else { + byte[] buf = new byte[len << 1]; + StringLatin1.inflate(dst, 0, buf, 0, dp); + dst = buf; + } + while (sp < sl) { + int b1 = src[sp++]; + if (b1 >= 0) { + putChar(dst, dp++, (char) b1); + } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) { + if (sp < sl) { + int b2 = src[sp++]; + if (isNotContinuation(b2)) { + if (!doReplace) { + throwMalformed(sp - 1, 1); + } + putChar(dst, dp++, repl); + sp--; + } else { + putChar(dst, dp++, (char)(((b1 << 6) ^ b2)^ + (((byte) 0xC0 << 6) ^ + ((byte) 0x80 << 0)))); + } + continue; + } + if (!doReplace) { + throwMalformed(sp, 1); // underflow() + } + putChar(dst, dp++, repl); + break; + } else if ((b1 >> 4) == -2) { + if (sp + 1 < sl) { + int b2 = src[sp++]; + int b3 = src[sp++]; + if (isMalformed3(b1, b2, b3)) { + if (!doReplace) { + throwMalformed(sp - 3, 3); + } + putChar(dst, dp++, repl); + sp -= 3; + sp += malformedN(src, sp, 3); + } else { + char c = (char)((b1 << 12) ^ + (b2 << 6) ^ + (b3 ^ + (((byte) 0xE0 << 12) ^ + ((byte) 0x80 << 6) ^ + ((byte) 0x80 << 0)))); + if (isSurrogate(c)) { + if (!doReplace) { + throwMalformed(sp - 3, 3); + } + putChar(dst, dp++, repl); + } else { + putChar(dst, dp++, c); + } + } + continue; + } + if (sp < sl && isMalformed3_2(b1, src[sp])) { + if (!doReplace) { + throwMalformed(sp - 1, 2); + } + putChar(dst, dp++, repl); + continue; + } + if (!doReplace){ + throwMalformed(sp, 1); + } + putChar(dst, dp++, repl); + break; + } else if ((b1 >> 3) == -2) { + if (sp + 2 < sl) { + int b2 = src[sp++]; + int b3 = src[sp++]; + int b4 = src[sp++]; + int uc = ((b1 << 18) ^ + (b2 << 12) ^ + (b3 << 6) ^ + (b4 ^ + (((byte) 0xF0 << 18) ^ + ((byte) 0x80 << 12) ^ + ((byte) 0x80 << 6) ^ + ((byte) 0x80 << 0)))); + if (isMalformed4(b2, b3, b4) || + !isSupplementaryCodePoint(uc)) { // shortest form check + if (!doReplace) { + throwMalformed(sp - 4, 4); + } + putChar(dst, dp++, repl); + sp -= 4; + sp += malformedN(src, sp, 4); + } else { + putChar(dst, dp++, highSurrogate(uc)); + putChar(dst, dp++, lowSurrogate(uc)); + } + continue; + } + b1 &= 0xff; + if (b1 > 0xf4 || + sp < sl && isMalformed4_2(b1, src[sp] & 0xff)) { + if (!doReplace) { + throwMalformed(sp - 1, 1); // or 2 + } + putChar(dst, dp++, repl); + continue; + } + if (!doReplace) { + throwMalformed(sp - 1, 1); + } + sp++; + putChar(dst, dp++, repl); + if (sp < sl && isMalformed4_3(src[sp])) { + continue; + } + break; + } else { + if (!doReplace) { + throwMalformed(sp - 1, 1); + } + putChar(dst, dp++, repl); + } + } + if (dp != len) { + dst = Arrays.copyOf(dst, dp << 1); + } + return ret.with(dst, UTF16); } - static byte[] encode(Charset cs, byte coder, byte[] val) { - if (cs == UTF_8) { - return encodeUTF8(coder, val); - } else if (cs == ISO_8859_1) { - return encode8859_1(coder, val); - } else if (cs == US_ASCII) { - return encodeASCII(coder, val); - } - CharsetEncoder ce = cs.newEncoder(); - // fastpath for ascii compatible - if (coder == LATIN1 && (((ce instanceof ArrayEncoder) && - ((ArrayEncoder)ce).isASCIICompatible() && - !hasNegatives(val, 0, val.length)))) { + private static byte[] encodeUTF8(byte coder, byte[] val, boolean doReplace) { + if (coder == UTF16) + return encodeUTF8_UTF16(val, doReplace); + + if (!hasNegatives(val, 0, val.length)) return Arrays.copyOf(val, val.length); - } - int len = val.length >> coder; // assume LATIN1=0/UTF16=1; - int en = scale(len, ce.maxBytesPerChar()); - byte[] ba = new byte[en]; - if (len == 0) { - return ba; - } - boolean isTrusted = cs.getClass().getClassLoader0() == null || - System.getSecurityManager() == null; - ce.onMalformedInput(CodingErrorAction.REPLACE) - .onUnmappableCharacter(CodingErrorAction.REPLACE) - .reset(); - if (ce instanceof ArrayEncoder) { - if (!isTrusted) { - val = Arrays.copyOf(val, val.length); - } - int blen = (coder == LATIN1 ) ? ((ArrayEncoder)ce).encodeFromLatin1(val, 0, len, ba) - : ((ArrayEncoder)ce).encodeFromUTF16(val, 0, len, ba); - if (blen != -1) { - return safeTrim(ba, blen, isTrusted); + + int dp = 0; + byte[] dst = new byte[val.length << 1]; + for (int sp = 0; sp < val.length; sp++) { + byte c = val[sp]; + if (c < 0) { + dst[dp++] = (byte)(0xc0 | ((c & 0xff) >> 6)); + dst[dp++] = (byte)(0x80 | (c & 0x3f)); + } else { + dst[dp++] = c; } } - char[] ca = (coder == LATIN1 ) ? StringLatin1.toChars(val) - : StringUTF16.toChars(val); - ByteBuffer bb = ByteBuffer.wrap(ba); - CharBuffer cb = CharBuffer.wrap(ca, 0, len); - try { - CoderResult cr = ce.encode(cb, bb, true); - if (!cr.isUnderflow()) - cr.throwException(); - cr = ce.flush(bb); - if (!cr.isUnderflow()) - cr.throwException(); - } catch (CharacterCodingException x) { - throw new Error(x); - } - return safeTrim(ba, bb.position(), isTrusted); + if (dp == dst.length) + return dst; + return Arrays.copyOf(dst, dp); } - static byte[] encode(byte coder, byte[] val) { - String csn = Charset.defaultCharset().name(); - try { - // use charset name encode() variant which provides caching. - return encode(csn, coder, val); - } catch (UnsupportedEncodingException x) { - warnUnsupportedCharset(csn); + private static byte[] encodeUTF8_UTF16(byte[] val, boolean doReplace) { + int dp = 0; + int sp = 0; + int sl = val.length >> 1; + byte[] dst = new byte[sl * 3]; + char c; + while (sp < sl && (c = StringUTF16.getChar(val, sp)) < '\u0080') { + // ascii fast loop; + dst[dp++] = (byte)c; + sp++; } - try { - return encode("ISO-8859-1", coder, val); - } catch (UnsupportedEncodingException x) { - // If this code is hit during VM initialization, err(String) is - // the only way we will be able to get any kind of error message. - err("ISO-8859-1 charset not available: " + x.toString() + "\n"); - // If we can not find ISO-8859-1 (a required encoding) then things - // are seriously wrong with the installation. - System.exit(1); - return null; + while (sp < sl) { + c = StringUTF16.getChar(val, sp++); + if (c < 0x80) { + dst[dp++] = (byte)c; + } else if (c < 0x800) { + dst[dp++] = (byte)(0xc0 | (c >> 6)); + dst[dp++] = (byte)(0x80 | (c & 0x3f)); + } else if (Character.isSurrogate(c)) { + int uc = -1; + char c2; + if (Character.isHighSurrogate(c) && sp < sl && + Character.isLowSurrogate(c2 = StringUTF16.getChar(val, sp))) { + uc = Character.toCodePoint(c, c2); + } + if (uc < 0) { + if (doReplace) { + dst[dp++] = '?'; + } else { + throwMalformed(sp - 1, 1); // or 2, does not matter here + } + } else { + dst[dp++] = (byte)(0xf0 | ((uc >> 18))); + dst[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f)); + dst[dp++] = (byte)(0x80 | ((uc >> 6) & 0x3f)); + dst[dp++] = (byte)(0x80 | (uc & 0x3f)); + sp++; // 2 chars + } + } else { + // 3 bytes, 16 bits + dst[dp++] = (byte)(0xe0 | ((c >> 12))); + dst[dp++] = (byte)(0x80 | ((c >> 6) & 0x3f)); + dst[dp++] = (byte)(0x80 | (c & 0x3f)); + } } + if (dp == dst.length) { + return dst; + } + return Arrays.copyOf(dst, dp); } - /** - * Print a message directly to stderr, bypassing all character conversion - * methods. - * @param msg message to print + ////////////////////// for j.u.z.ZipCoder ////////////////////////// + + /* + * Throws iae, instead of replacing, if malformed or unmappble. */ - private static native void err(String msg); + static String newStringUTF8NoRepl(byte[] src, int off, int len) { + if (COMPACT_STRINGS && !hasNegatives(src, off, len)) + return new String(Arrays.copyOfRange(src, off, off + len), LATIN1); + Result ret = decodeUTF8_0(src, off, len, false); + return new String(ret.value, ret.coder); + } + + /* + * Throws iae, instead of replacing, if unmappble. + */ + static byte[] getBytesUTF8NoRepl(String s) { + return encodeUTF8(s.coder(), s.value(), false); + } } diff --git a/src/java.base/share/classes/java/lang/StringDecoderUTF8.java b/src/java.base/share/classes/java/lang/StringDecoderUTF8.java deleted file mode 100644 index 1b504df2574..00000000000 --- a/src/java.base/share/classes/java/lang/StringDecoderUTF8.java +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * 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 java.lang; - -import java.nio.charset.Charset; -import java.util.Arrays; - -import static java.lang.String.LATIN1; -import static java.lang.String.UTF16; -import static java.lang.String.COMPACT_STRINGS; -import static java.lang.Character.isSurrogate; -import static java.lang.Character.highSurrogate; -import static java.lang.Character.lowSurrogate; -import static java.lang.Character.isSupplementaryCodePoint; -import static java.lang.StringUTF16.putChar; - -class StringDecoderUTF8 extends StringCoding.StringDecoder { - - StringDecoderUTF8(Charset cs, String rcn) { - super(cs, rcn); - } - - private static boolean isNotContinuation(int b) { - return (b & 0xc0) != 0x80; - } - - private static boolean isMalformed3(int b1, int b2, int b3) { - return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) || - (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80; - } - - private static boolean isMalformed3_2(int b1, int b2) { - return (b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) || - (b2 & 0xc0) != 0x80; - } - - private static boolean isMalformed4(int b2, int b3, int b4) { - return (b2 & 0xc0) != 0x80 || (b3 & 0xc0) != 0x80 || - (b4 & 0xc0) != 0x80; - } - - private static boolean isMalformed4_2(int b1, int b2) { - return (b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) || - (b1 == 0xf4 && (b2 & 0xf0) != 0x80) || - (b2 & 0xc0) != 0x80; - } - - private static boolean isMalformed4_3(int b3) { - return (b3 & 0xc0) != 0x80; - } - - // for nb == 3/4 - private static int malformedN(byte[] src, int sp, int nb) { - if (nb == 3) { - int b1 = src[sp++]; - int b2 = src[sp++]; // no need to lookup b3 - return ((b1 == (byte)0xe0 && (b2 & 0xe0) == 0x80) || - isNotContinuation(b2)) ? 1 : 2; - } else if (nb == 4) { // we don't care the speed here - int b1 = src[sp++] & 0xff; - int b2 = src[sp++] & 0xff; - if (b1 > 0xf4 || - (b1 == 0xf0 && (b2 < 0x90 || b2 > 0xbf)) || - (b1 == 0xf4 && (b2 & 0xf0) != 0x80) || - isNotContinuation(b2)) - return 1; - if (isNotContinuation(src[sp++])) - return 2; - return 3; - } - assert false; - return -1; - } - - private static char repl = '\ufffd'; - - StringCoding.Result decode(byte[] src, int sp, int len) { - return decode(src, sp, len, result); - } - - static StringCoding.Result decode(byte[] src, int sp, int len, - StringCoding.Result ret) { - int sl = sp + len; - byte[] dst = new byte[len]; - int dp = 0; - if (COMPACT_STRINGS) { // Latin1 only loop - while (sp < sl) { - int b1 = src[sp]; - if (b1 >= 0) { - dst[dp++] = (byte)b1; - sp++; - continue; - } - if ((b1 == (byte)0xc2 || b1 == (byte)0xc3) && - sp + 1 < sl) { - int b2 = src[sp + 1]; - if (!isNotContinuation(b2)) { - dst[dp++] = (byte)(((b1 << 6) ^ b2)^ - (((byte) 0xC0 << 6) ^ - ((byte) 0x80 << 0))); - sp += 2; - continue; - } - } - // anything not a latin1, including the repl - // we have to go with the utf16 - break; - } - if (sp == sl) { - if (dp != dst.length) { - dst = Arrays.copyOf(dst, dp); - } - return ret.with(dst, LATIN1); - } - } - if (dp == 0) { - dst = new byte[len << 1]; - } else { - byte[] buf = new byte[len << 1]; - StringLatin1.inflate(dst, 0, buf, 0, dp); - dst = buf; - } - while (sp < sl) { - int b1 = src[sp++]; - if (b1 >= 0) { - putChar(dst, dp++, (char) b1); - } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) { - if (sp < sl) { - int b2 = src[sp++]; - if (isNotContinuation(b2)) { - putChar(dst, dp++, repl); - sp--; - } else { - putChar(dst, dp++, (char)(((b1 << 6) ^ b2)^ - (((byte) 0xC0 << 6) ^ - ((byte) 0x80 << 0)))); - } - continue; - } - putChar(dst, dp++, repl); - break; - } else if ((b1 >> 4) == -2) { - if (sp + 1 < sl) { - int b2 = src[sp++]; - int b3 = src[sp++]; - if (isMalformed3(b1, b2, b3)) { - putChar(dst, dp++, repl); - sp -= 3; - sp += malformedN(src, sp, 3); - } else { - char c = (char)((b1 << 12) ^ - (b2 << 6) ^ - (b3 ^ - (((byte) 0xE0 << 12) ^ - ((byte) 0x80 << 6) ^ - ((byte) 0x80 << 0)))); - putChar(dst, dp++, isSurrogate(c) ? repl : c); - } - continue; - } - if (sp < sl && isMalformed3_2(b1, src[sp])) { - putChar(dst, dp++, repl); - continue; - } - putChar(dst, dp++, repl); - break; - } else if ((b1 >> 3) == -2) { - if (sp + 2 < sl) { - int b2 = src[sp++]; - int b3 = src[sp++]; - int b4 = src[sp++]; - int uc = ((b1 << 18) ^ - (b2 << 12) ^ - (b3 << 6) ^ - (b4 ^ - (((byte) 0xF0 << 18) ^ - ((byte) 0x80 << 12) ^ - ((byte) 0x80 << 6) ^ - ((byte) 0x80 << 0)))); - if (isMalformed4(b2, b3, b4) || - !isSupplementaryCodePoint(uc)) { // shortest form check - putChar(dst, dp++, repl); - sp -= 4; - sp += malformedN(src, sp, 4); - } else { - putChar(dst, dp++, highSurrogate(uc)); - putChar(dst, dp++, lowSurrogate(uc)); - } - continue; - } - b1 &= 0xff; - if (b1 > 0xf4 || - sp < sl && isMalformed4_2(b1, src[sp] & 0xff)) { - putChar(dst, dp++, repl); - continue; - } - sp++; - putChar(dst, dp++, repl); - if (sp < sl && isMalformed4_3(src[sp])) { - continue; - } - break; - } else { - putChar(dst, dp++, repl); - } - } - if (dp != len) { - dst = Arrays.copyOf(dst, dp << 1); - } - return ret.with(dst, UTF16); - } -} diff --git a/src/java.base/share/classes/java/lang/System.java b/src/java.base/share/classes/java/lang/System.java index 6271f87a6f0..b28b5793ab6 100644 --- a/src/java.base/share/classes/java/lang/System.java +++ b/src/java.base/share/classes/java/lang/System.java @@ -2184,6 +2184,15 @@ public final class System { public Stream layers(ClassLoader loader) { return ModuleLayer.layers(loader); } + + public String newStringUTF8NoRepl(byte[] bytes, int off, int len) { + return StringCoding.newStringUTF8NoRepl(bytes, off, len); + } + + public byte[] getBytesUTF8NoRepl(String s) { + return StringCoding.getBytesUTF8NoRepl(s); + } + }); } } diff --git a/src/java.base/share/classes/java/util/zip/ZipCoder.java b/src/java.base/share/classes/java/util/zip/ZipCoder.java index 44939906e12..23fd2af409a 100644 --- a/src/java.base/share/classes/java/util/zip/ZipCoder.java +++ b/src/java.base/share/classes/java/util/zip/ZipCoder.java @@ -28,72 +28,60 @@ package java.util.zip; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; import java.nio.charset.CharsetDecoder; import java.nio.charset.CharsetEncoder; -import java.nio.charset.CoderResult; +import java.nio.charset.CharacterCodingException; import java.nio.charset.CodingErrorAction; -import java.util.Arrays; -import sun.nio.cs.ArrayDecoder; -import sun.nio.cs.ArrayEncoder; + +import static java.nio.charset.StandardCharsets.UTF_8; /** * Utility class for zipfile name and comment decoding and encoding */ -final class ZipCoder { +class ZipCoder { - private static boolean isASCII(byte[] ba, int off, int len) { - for (int i = off; i < off + len; i++) { - if (ba[i] < 0) - return false; + private static final jdk.internal.misc.JavaLangAccess JLA = + jdk.internal.misc.SharedSecrets.getJavaLangAccess(); + + static final class UTF8 extends ZipCoder { + + UTF8(Charset utf8) { + super(utf8); + } + + @Override + boolean isUTF8() { + return true; + } + + @Override + String toString(byte[] ba, int off, int length) { + return JLA.newStringUTF8NoRepl(ba, off, length); + } + + @Override + byte[] getBytes(String s) { + return JLA.getBytesUTF8NoRepl(s); } - return true; } - private static boolean hasReplaceChar(byte[] ba) { - for (int i = 0; i < ba.length; i++) { - if (ba[i] == (byte)'?') - return true; - } - return false; + // UTF_8.ArrayEn/Decoder is stateless, so make it singleton. + private static ZipCoder utf8 = new UTF8(UTF_8); + + public static ZipCoder get(Charset charset) { + if (charset == UTF_8) + return utf8; + return new ZipCoder(charset); } String toString(byte[] ba, int off, int length) { + try { + return decoder().decode(ByteBuffer.wrap(ba, off, length)).toString(); - // fastpath for UTF-8 cs and ascii only name, leverage the - // compact string impl to avoid the unnecessary char[] copy/ - // paste. A temporary workaround before we have better approach, - // such as a String constructor that throws exception for - // malformed and/or unmappable characters, instead of silently - // replacing with repl char - if (isUTF8 && isASCII(ba, off, length)) { - return new String(ba, off, length, cs); + } catch (CharacterCodingException x) { + throw new IllegalArgumentException(x); } - - CharsetDecoder cd = decoder().reset(); - int len = (int)(length * cd.maxCharsPerByte()); - char[] ca = new char[len]; - if (len == 0) - return new String(ca); - // UTF-8 only for now. Other ArrayDeocder only handles - // CodingErrorAction.REPLACE mode. ZipCoder uses - // REPORT mode. - if (isUTF8 && cd instanceof ArrayDecoder) { - int clen = ((ArrayDecoder)cd).decode(ba, off, length, ca); - if (clen == -1) // malformed - throw new IllegalArgumentException("MALFORMED"); - return new String(ca, 0, clen); - } - ByteBuffer bb = ByteBuffer.wrap(ba, off, length); - CharBuffer cb = CharBuffer.wrap(ca); - CoderResult cr = cd.decode(bb, cb, true); - if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); - cr = cd.flush(cb); - if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); - return new String(ca, 0, cb.position()); } String toString(byte[] ba, int length) { @@ -105,84 +93,47 @@ final class ZipCoder { } byte[] getBytes(String s) { - if (isUTF8) { - // fastpath for UTF8. should only occur when the string - // has malformed surrogates. A postscan should still be - // faster and use less memory. - byte[] ba = s.getBytes(cs); - if (!hasReplaceChar(ba)) { - return ba; + try { + ByteBuffer bb = encoder().encode(CharBuffer.wrap(s)); + int pos = bb.position(); + int limit = bb.limit(); + if (bb.hasArray() && pos == 0 && limit == bb.capacity()) { + return bb.array(); } + byte[] bytes = new byte[bb.limit() - bb.position()]; + bb.get(bytes); + return bytes; + } catch (CharacterCodingException x) { + throw new IllegalArgumentException(x); } - CharsetEncoder ce = encoder().reset(); - char[] ca = s.toCharArray(); - int len = (int)(ca.length * ce.maxBytesPerChar()); - byte[] ba = new byte[len]; - if (len == 0) - return ba; - // UTF-8 only for now. Other ArrayDeocder only handles - // CodingErrorAction.REPLACE mode. - if (isUTF8 && ce instanceof ArrayEncoder) { - int blen = ((ArrayEncoder)ce).encode(ca, 0, ca.length, ba); - if (blen == -1) // malformed - throw new IllegalArgumentException("MALFORMED"); - return Arrays.copyOf(ba, blen); - } - ByteBuffer bb = ByteBuffer.wrap(ba); - CharBuffer cb = CharBuffer.wrap(ca); - CoderResult cr = ce.encode(cb, bb, true); - if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); - cr = ce.flush(bb); - if (!cr.isUnderflow()) - throw new IllegalArgumentException(cr.toString()); - if (bb.position() == ba.length) // defensive copy? - return ba; - else - return Arrays.copyOf(ba, bb.position()); } // assume invoked only if "this" is not utf8 byte[] getBytesUTF8(String s) { - if (isUTF8) - return getBytes(s); - if (utf8 == null) - utf8 = new ZipCoder(StandardCharsets.UTF_8); return utf8.getBytes(s); } String toStringUTF8(byte[] ba, int len) { - return toStringUTF8(ba, 0, len); + return utf8.toString(ba, 0, len); } String toStringUTF8(byte[] ba, int off, int len) { - if (isUTF8) - return toString(ba, off, len); - if (utf8 == null) - utf8 = new ZipCoder(StandardCharsets.UTF_8); return utf8.toString(ba, off, len); } boolean isUTF8() { - return isUTF8; + return false; } private Charset cs; private CharsetDecoder dec; private CharsetEncoder enc; - private boolean isUTF8; - private ZipCoder utf8; private ZipCoder(Charset cs) { this.cs = cs; - this.isUTF8 = cs.name().equals(StandardCharsets.UTF_8.name()); } - static ZipCoder get(Charset charset) { - return new ZipCoder(charset); - } - - private CharsetDecoder decoder() { + protected CharsetDecoder decoder() { if (dec == null) { dec = cs.newDecoder() .onMalformedInput(CodingErrorAction.REPORT) @@ -191,7 +142,7 @@ final class ZipCoder { return dec; } - private CharsetEncoder encoder() { + protected CharsetEncoder encoder() { if (enc == null) { enc = cs.newEncoder() .onMalformedInput(CodingErrorAction.REPORT) diff --git a/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java b/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java index 7561b2109ad..5a7f389fadd 100644 --- a/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java +++ b/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java @@ -254,4 +254,23 @@ public interface JavaLangAccess { * given class loader. */ Stream layers(ClassLoader loader); + + /** + * Returns a new string by decoding from the given utf8 bytes array. + * + * @param off the index of the first byte to decode + * @param len the number of bytes to decode + * @return the newly created string + * @throws IllegalArgumentException for malformed or unmappable bytes. + */ + String newStringUTF8NoRepl(byte[] bytes, int off, int len); + + /** + * Encode the given string into a sequence of bytes using utf8. + * + * @param s the string to encode + * @return the encoded bytes in utf8 + * @throws IllegalArgumentException for malformed surrogates + */ + byte[] getBytesUTF8NoRepl(String s); } diff --git a/src/java.base/share/classes/sun/nio/cs/ISO_8859_1.java b/src/java.base/share/classes/sun/nio/cs/ISO_8859_1.java index 2567c4abeb1..316cbb81284 100644 --- a/src/java.base/share/classes/sun/nio/cs/ISO_8859_1.java +++ b/src/java.base/share/classes/sun/nio/cs/ISO_8859_1.java @@ -63,8 +63,8 @@ public class ISO_8859_1 return new Encoder(this); } - private static class Decoder extends CharsetDecoder - implements ArrayDecoder { + private static class Decoder extends CharsetDecoder { + private Decoder(Charset cs) { super(cs, 1.0f, 1.0f); } @@ -124,23 +124,10 @@ public class ISO_8859_1 else return decodeBufferLoop(src, dst); } - - public int decode(byte[] src, int sp, int len, char[] dst) { - if (len > dst.length) - len = dst.length; - int dp = 0; - while (dp < len) - dst[dp++] = (char)(src[sp++] & 0xff); - return dp; - } - - public boolean isASCIICompatible() { - return true; - } } - private static class Encoder extends CharsetEncoder - implements ArrayEncoder { + private static class Encoder extends CharsetEncoder { + private Encoder(Charset cs) { super(cs, 1.0f, 1.0f); } @@ -271,39 +258,5 @@ public class ISO_8859_1 else return encodeBufferLoop(src, dst); } - - private byte repl = (byte)'?'; - protected void implReplaceWith(byte[] newReplacement) { - repl = newReplacement[0]; - } - - public int encode(char[] src, int sp, int len, byte[] dst) { - int dp = 0; - int slen = Math.min(len, dst.length); - int sl = sp + slen; - while (sp < sl) { - int ret = encodeISOArray(src, sp, dst, dp, slen); - sp = sp + ret; - dp = dp + ret; - if (ret != slen) { - char c = src[sp++]; - if (Character.isHighSurrogate(c) && sp < sl && - Character.isLowSurrogate(src[sp])) { - if (len > dst.length) { - sl++; - len--; - } - sp++; - } - dst[dp++] = repl; - slen = Math.min((sl - sp), (dst.length - dp)); - } - } - return dp; - } - - public boolean isASCIICompatible() { - return true; - } } } diff --git a/src/java.base/share/classes/sun/nio/cs/US_ASCII.java b/src/java.base/share/classes/sun/nio/cs/US_ASCII.java index abc045e6819..100748aa695 100644 --- a/src/java.base/share/classes/sun/nio/cs/US_ASCII.java +++ b/src/java.base/share/classes/sun/nio/cs/US_ASCII.java @@ -58,8 +58,7 @@ public class US_ASCII return new Encoder(this); } - private static class Decoder extends CharsetDecoder - implements ArrayDecoder { + private static class Decoder extends CharsetDecoder { private Decoder(Charset cs) { super(cs, 1.0f, 1.0f); @@ -128,32 +127,9 @@ public class US_ASCII else return decodeBufferLoop(src, dst); } - - private char repl = '\uFFFD'; - protected void implReplaceWith(String newReplacement) { - repl = newReplacement.charAt(0); - } - - public int decode(byte[] src, int sp, int len, char[] dst) { - int dp = 0; - len = Math.min(len, dst.length); - while (dp < len) { - byte b = src[sp++]; - if (b >= 0) - dst[dp++] = (char)b; - else - dst[dp++] = repl; - } - return dp; - } - - public boolean isASCIICompatible() { - return true; - } } - private static class Encoder extends CharsetEncoder - implements ArrayEncoder { + private static class Encoder extends CharsetEncoder { private Encoder(Charset cs) { super(cs, 1.0f, 1.0f); @@ -237,36 +213,5 @@ public class US_ASCII return encodeBufferLoop(src, dst); } - private byte repl = (byte)'?'; - protected void implReplaceWith(byte[] newReplacement) { - repl = newReplacement[0]; - } - - public int encode(char[] src, int sp, int len, byte[] dst) { - int dp = 0; - int sl = sp + Math.min(len, dst.length); - while (sp < sl) { - char c = src[sp++]; - if (c < 0x80) { - dst[dp++] = (byte)c; - continue; - } - if (Character.isHighSurrogate(c) && sp < sl && - Character.isLowSurrogate(src[sp])) { - if (len > dst.length) { - sl++; - len--; - } - sp++; - } - dst[dp++] = repl; - } - return dp; - } - - public boolean isASCIICompatible() { - return true; - } } - } diff --git a/src/java.base/share/classes/sun/nio/cs/UTF_8.java b/src/java.base/share/classes/sun/nio/cs/UTF_8.java index da733c806bb..5561fc30065 100644 --- a/src/java.base/share/classes/sun/nio/cs/UTF_8.java +++ b/src/java.base/share/classes/sun/nio/cs/UTF_8.java @@ -80,8 +80,8 @@ public final class UTF_8 extends Unicode { dst.position(dp - dst.arrayOffset()); } - private static class Decoder extends CharsetDecoder - implements ArrayDecoder { + private static class Decoder extends CharsetDecoder { + private Decoder(Charset cs) { super(cs, 1.0f, 1.0f); } @@ -423,142 +423,9 @@ public final class UTF_8 extends Unicode { bb.position(sp); return bb; } - - // returns -1 if there is/are malformed byte(s) and the - // "action" for malformed input is not REPLACE. - public int decode(byte[] sa, int sp, int len, char[] da) { - final int sl = sp + len; - int dp = 0; - int dlASCII = Math.min(len, da.length); - ByteBuffer bb = null; // only necessary if malformed - - // ASCII only optimized loop - while (dp < dlASCII && sa[sp] >= 0) - da[dp++] = (char) sa[sp++]; - - while (sp < sl) { - int b1 = sa[sp++]; - if (b1 >= 0) { - // 1 byte, 7 bits: 0xxxxxxx - da[dp++] = (char) b1; - } else if ((b1 >> 5) == -2 && (b1 & 0x1e) != 0) { - // 2 bytes, 11 bits: 110xxxxx 10xxxxxx - if (sp < sl) { - int b2 = sa[sp++]; - if (isNotContinuation(b2)) { - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = replacement().charAt(0); - sp--; // malformedN(bb, 2) always returns 1 - } else { - da[dp++] = (char) (((b1 << 6) ^ b2)^ - (((byte) 0xC0 << 6) ^ - ((byte) 0x80 << 0))); - } - continue; - } - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = replacement().charAt(0); - return dp; - } else if ((b1 >> 4) == -2) { - // 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx - if (sp + 1 < sl) { - int b2 = sa[sp++]; - int b3 = sa[sp++]; - if (isMalformed3(b1, b2, b3)) { - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = replacement().charAt(0); - sp -= 3; - bb = getByteBuffer(bb, sa, sp); - sp += malformedN(bb, 3).length(); - } else { - char c = (char)((b1 << 12) ^ - (b2 << 6) ^ - (b3 ^ - (((byte) 0xE0 << 12) ^ - ((byte) 0x80 << 6) ^ - ((byte) 0x80 << 0)))); - if (Character.isSurrogate(c)) { - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = replacement().charAt(0); - } else { - da[dp++] = c; - } - } - continue; - } - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - if (sp < sl && isMalformed3_2(b1, sa[sp])) { - da[dp++] = replacement().charAt(0); - continue; - - } - da[dp++] = replacement().charAt(0); - return dp; - } else if ((b1 >> 3) == -2) { - // 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx - if (sp + 2 < sl) { - int b2 = sa[sp++]; - int b3 = sa[sp++]; - int b4 = sa[sp++]; - int uc = ((b1 << 18) ^ - (b2 << 12) ^ - (b3 << 6) ^ - (b4 ^ - (((byte) 0xF0 << 18) ^ - ((byte) 0x80 << 12) ^ - ((byte) 0x80 << 6) ^ - ((byte) 0x80 << 0)))); - if (isMalformed4(b2, b3, b4) || - // shortest form check - !Character.isSupplementaryCodePoint(uc)) { - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = replacement().charAt(0); - sp -= 4; - bb = getByteBuffer(bb, sa, sp); - sp += malformedN(bb, 4).length(); - } else { - da[dp++] = Character.highSurrogate(uc); - da[dp++] = Character.lowSurrogate(uc); - } - continue; - } - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - b1 &= 0xff; - if (b1 > 0xf4 || - sp < sl && isMalformed4_2(b1, sa[sp] & 0xff)) { - da[dp++] = replacement().charAt(0); - continue; - } - sp++; - if (sp < sl && isMalformed4_3(sa[sp])) { - da[dp++] = replacement().charAt(0); - continue; - } - da[dp++] = replacement().charAt(0); - return dp; - } else { - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = replacement().charAt(0); - } - } - return dp; - } - - public boolean isASCIICompatible() { - return true; - } } - private static final class Encoder extends CharsetEncoder - implements ArrayEncoder { + private static final class Encoder extends CharsetEncoder { private Encoder(Charset cs) { super(cs, 1.1f, 3.0f); @@ -699,58 +566,5 @@ public final class UTF_8 extends Unicode { return encodeBufferLoop(src, dst); } - private byte repl = (byte)'?'; - protected void implReplaceWith(byte[] newReplacement) { - repl = newReplacement[0]; - } - - // returns -1 if there is malformed char(s) and the - // "action" for malformed input is not REPLACE. - public int encode(char[] sa, int sp, int len, byte[] da) { - int sl = sp + len; - int dp = 0; - int dlASCII = dp + Math.min(len, da.length); - - // ASCII only optimized loop - while (dp < dlASCII && sa[sp] < '\u0080') - da[dp++] = (byte) sa[sp++]; - - while (sp < sl) { - char c = sa[sp++]; - if (c < 0x80) { - // Have at most seven bits - da[dp++] = (byte)c; - } else if (c < 0x800) { - // 2 bytes, 11 bits - da[dp++] = (byte)(0xc0 | (c >> 6)); - da[dp++] = (byte)(0x80 | (c & 0x3f)); - } else if (Character.isSurrogate(c)) { - if (sgp == null) - sgp = new Surrogate.Parser(); - int uc = sgp.parse(c, sa, sp - 1, sl); - if (uc < 0) { - if (malformedInputAction() != CodingErrorAction.REPLACE) - return -1; - da[dp++] = repl; - } else { - da[dp++] = (byte)(0xf0 | ((uc >> 18))); - da[dp++] = (byte)(0x80 | ((uc >> 12) & 0x3f)); - da[dp++] = (byte)(0x80 | ((uc >> 6) & 0x3f)); - da[dp++] = (byte)(0x80 | (uc & 0x3f)); - sp++; // 2 chars - } - } else { - // 3 bytes, 16 bits - da[dp++] = (byte)(0xe0 | ((c >> 12))); - da[dp++] = (byte)(0x80 | ((c >> 6) & 0x3f)); - da[dp++] = (byte)(0x80 | (c & 0x3f)); - } - } - return dp; - } - - public boolean isASCIICompatible() { - return true; - } } } From c8868455fe9c94f0125c8e03d1350c2bb6e41531 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Wed, 13 Dec 2017 16:16:17 +0000 Subject: [PATCH 26/26] 8193370: Provide more user friendly defaults for HTTP/2 client settings Reviewed-by: chegar --- .../jdk/incubator/http/Http2ClientImpl.java | 72 +++++++++++++++---- .../jdk/incubator/http/Http2Connection.java | 19 +++-- .../jdk/incubator/http/HttpClientImpl.java | 2 +- .../incubator/http/PlainHttpConnection.java | 16 ++++- .../incubator/http/WindowUpdateSender.java | 2 + .../http/internal/frame/SettingsFrame.java | 5 ++ .../security/filePerms/httpclient.policy | 1 + .../websocket/security/httpclient.policy | 1 + 8 files changed, 96 insertions(+), 22 deletions(-) diff --git a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2ClientImpl.java b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2ClientImpl.java index 21a8a4a4fd2..500ad84e63b 100644 --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2ClientImpl.java +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2ClientImpl.java @@ -36,6 +36,8 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CompletableFuture; + +import jdk.incubator.http.internal.common.Log; import jdk.incubator.http.internal.common.MinimalFuture; import jdk.incubator.http.internal.common.Utils; import jdk.incubator.http.internal.frame.SettingsFrame; @@ -78,10 +80,6 @@ class Http2ClientImpl { } } -// boolean haveConnectionFor(URI uri, InetSocketAddress proxy) { -// return connections.containsKey(Http2Connection.keyFor(uri,proxy)); -// } - /** * If a https request then async waits until a connection is opened. * Returns null if the request is 'http' as a different (upgrade) @@ -188,18 +186,64 @@ class Http2ClientImpl { private static final int K = 1024; + private static int getParameter(String property, int min, int max, int defaultValue) { + int value = Utils.getIntegerNetProperty(property, defaultValue); + // use default value if misconfigured + if (value < min || value > max) { + Log.logError("Property value for {0}={1} not in [{2}..{3}]: " + + "using default={4}", property, value, min, max, defaultValue); + value = defaultValue; + } + return value; + } + + // used for the connection window, to have a connection window size + // bigger than the initial stream window size. + int getConnectionWindowSize(SettingsFrame clientSettings) { + // Maximum size is 2^31-1. Don't allow window size to be less + // than the stream window size. HTTP/2 specify a default of 64 * K -1, + // but we use 2^26 by default for better performance. + int streamWindow = clientSettings.getParameter(INITIAL_WINDOW_SIZE); + + // The default is the max between the stream window size + // and the connection window size. + int defaultValue = Math.min(Integer.MAX_VALUE, + Math.max(streamWindow, K*K*32)); + + return getParameter( + "jdk.httpclient.connectionWindowSize", + streamWindow, Integer.MAX_VALUE, defaultValue); + } + SettingsFrame getClientSettings() { SettingsFrame frame = new SettingsFrame(); - frame.setParameter(HEADER_TABLE_SIZE, Utils.getIntegerNetProperty( - "jdk.httpclient.hpack.maxheadertablesize", 16 * K)); - frame.setParameter(ENABLE_PUSH, Utils.getIntegerNetProperty( - "jdk.httpclient.enablepush", 1)); - frame.setParameter(MAX_CONCURRENT_STREAMS, Utils.getIntegerNetProperty( - "jdk.httpclient.maxstreams", 16)); - frame.setParameter(INITIAL_WINDOW_SIZE, Utils.getIntegerNetProperty( - "jdk.httpclient.windowsize", 64 * K - 1)); - frame.setParameter(MAX_FRAME_SIZE, Utils.getIntegerNetProperty( - "jdk.httpclient.maxframesize", 16 * K)); + // default defined for HTTP/2 is 4 K, we use 16 K. + frame.setParameter(HEADER_TABLE_SIZE, getParameter( + "jdk.httpclient.hpack.maxheadertablesize", + 0, Integer.MAX_VALUE, 16 * K)); + // O: does not accept push streams. 1: accepts push streams. + frame.setParameter(ENABLE_PUSH, getParameter( + "jdk.httpclient.enablepush", + 0, 1, 1)); + // HTTP/2 recommends to set the number of concurrent streams + // no lower than 100. We use 100. 0 means no stream would be + // accepted. That would render the client to be non functional, + // so we won't let 0 be configured for our Http2ClientImpl. + frame.setParameter(MAX_CONCURRENT_STREAMS, getParameter( + "jdk.httpclient.maxstreams", + 1, Integer.MAX_VALUE, 100)); + // Maximum size is 2^31-1. Don't allow window size to be less + // than the minimum frame size as this is likely to be a + // configuration error. HTTP/2 specify a default of 64 * K -1, + // but we use 16 M for better performance. + frame.setParameter(INITIAL_WINDOW_SIZE, getParameter( + "jdk.httpclient.windowsize", + 16 * K, Integer.MAX_VALUE, 16*K*K)); + // HTTP/2 specify a minimum size of 16 K, a maximum size of 2^24-1, + // and a default of 16 K. We use 16 K as default. + frame.setParameter(MAX_FRAME_SIZE, getParameter( + "jdk.httpclient.maxframesize", + 16 * K, 16 * K * K -1, 16 * K)); return frame; } } diff --git a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java index e1461d8b5ea..d4522b20979 100644 --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/Http2Connection.java @@ -228,7 +228,7 @@ class Http2Connection { private final WindowController windowController = new WindowController(); private final FramesController framesController = new FramesController(); private final Http2TubeSubscriber subscriber = new Http2TubeSubscriber(); - final WindowUpdateSender windowUpdater; + final ConnectionWindowUpdateSender windowUpdater; private volatile Throwable cause; private volatile Supplier initial; @@ -247,7 +247,8 @@ class Http2Connection { this.nextstreamid = nextstreamid; this.key = key; this.clientSettings = this.client2.getClientSettings(); - this.framesDecoder = new FramesDecoder(this::processFrame, clientSettings.getParameter(SettingsFrame.MAX_FRAME_SIZE)); + this.framesDecoder = new FramesDecoder(this::processFrame, + clientSettings.getParameter(SettingsFrame.MAX_FRAME_SIZE)); // serverSettings will be updated by server this.serverSettings = SettingsFrame.getDefaultSettings(); this.hpackOut = new Encoder(serverSettings.getParameter(HEADER_TABLE_SIZE)); @@ -255,7 +256,8 @@ class Http2Connection { debugHpack.log(Level.DEBUG, () -> "For the record:" + super.toString()); debugHpack.log(Level.DEBUG, "Decoder created: %s", hpackIn); debugHpack.log(Level.DEBUG, "Encoder created: %s", hpackOut); - this.windowUpdater = new ConnectionWindowUpdateSender(this, client().getReceiveBufferSize()); + this.windowUpdater = new ConnectionWindowUpdateSender(this, + client2.getConnectionWindowSize(clientSettings)); } /** @@ -774,7 +776,8 @@ class Http2Connection { Log.logTrace("{0}: start sending connection preface to {1}", connection.channel().getLocalAddress(), connection.address()); - SettingsFrame sf = client2.getClientSettings(); + SettingsFrame sf = new SettingsFrame(clientSettings); + int initialWindowSize = sf.getParameter(INITIAL_WINDOW_SIZE); ByteBuffer buf = framesEncoder.encodeConnectionPreface(PREFACE_BYTES, sf); Log.logFrames(sf, "OUT"); // send preface bytes and SettingsFrame together @@ -788,8 +791,10 @@ class Http2Connection { // send a Window update for the receive buffer we are using // minus the initial 64 K specified in protocol - final int len = client2.client().getReceiveBufferSize() - (64 * 1024 - 1); - windowUpdater.sendWindowUpdate(len); + final int len = windowUpdater.initialWindowSize - initialWindowSize; + if (len > 0) { + windowUpdater.sendWindowUpdate(len); + } // there will be an ACK to the windows update - which should // cause any pending data stored before the preface was sent to be // flushed (see PrefaceController). @@ -1202,9 +1207,11 @@ class Http2Connection { static final class ConnectionWindowUpdateSender extends WindowUpdateSender { + final int initialWindowSize; public ConnectionWindowUpdateSender(Http2Connection connection, int initialWindowSize) { super(connection, initialWindowSize); + this.initialWindowSize = initialWindowSize; } @Override diff --git a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java index d5753361686..f46e53e4e37 100644 --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpClientImpl.java @@ -1038,7 +1038,7 @@ class HttpClientImpl extends HttpClient { // used for the connection window int getReceiveBufferSize() { return Utils.getIntegerNetProperty( - "jdk.httpclient.connectionWindowSize", 256 * 1024 + "jdk.httpclient.receiveBufferSize", 2 * 1024 * 1024 ); } } diff --git a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainHttpConnection.java b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainHttpConnection.java index 38ecd4065d5..a8281835b8a 100644 --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainHttpConnection.java +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PlainHttpConnection.java @@ -143,7 +143,9 @@ class PlainHttpConnection extends HttpConnection { this.chan = SocketChannel.open(); chan.configureBlocking(false); int bufsize = client.getReceiveBufferSize(); - chan.setOption(StandardSocketOptions.SO_RCVBUF, bufsize); + if (!trySetReceiveBufferSize(bufsize)) { + trySetReceiveBufferSize(256*1024); + } chan.setOption(StandardSocketOptions.TCP_NODELAY, true); // wrap the connected channel in a Tube for async reading and writing tube = new SocketTube(client(), chan, Utils::getBuffer); @@ -152,6 +154,18 @@ class PlainHttpConnection extends HttpConnection { } } + private boolean trySetReceiveBufferSize(int bufsize) { + try { + chan.setOption(StandardSocketOptions.SO_RCVBUF, bufsize); + return true; + } catch(IOException x) { + debug.log(Level.DEBUG, + "Failed to set receive buffer size to %d on %s", + bufsize, chan); + } + return false; + } + @Override HttpPublisher publisher() { return writePublisher; } diff --git a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WindowUpdateSender.java b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WindowUpdateSender.java index 1e9975827be..ad60abf232d 100644 --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WindowUpdateSender.java +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WindowUpdateSender.java @@ -59,6 +59,8 @@ abstract class WindowUpdateSender { // or // - remaining window size reached max frame size. limit = Math.min(v0, v1); + debug.log(Level.DEBUG, "maxFrameSize=%d, initWindowSize=%d, limit=%d", + maxFrameSize, initWindowSize, limit); } abstract int getStreamId(); diff --git a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/SettingsFrame.java b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/SettingsFrame.java index 12b237d8ad8..3ccb125c457 100644 --- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/SettingsFrame.java +++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/internal/frame/SettingsFrame.java @@ -100,6 +100,11 @@ public class SettingsFrame extends Http2Frame { this(0); } + public SettingsFrame(SettingsFrame other) { + super(0, other.flags); + parameters = Arrays.copyOf(other.parameters, MAX_PARAM); + } + @Override public int type() { return TYPE; diff --git a/test/jdk/java/net/httpclient/security/filePerms/httpclient.policy b/test/jdk/java/net/httpclient/security/filePerms/httpclient.policy index 8a2c74df9b7..e63c2acd92a 100644 --- a/test/jdk/java/net/httpclient/security/filePerms/httpclient.policy +++ b/test/jdk/java/net/httpclient/security/filePerms/httpclient.policy @@ -49,6 +49,7 @@ grant codeBase "jrt:/jdk.incubator.httpclient" { permission java.util.PropertyPermission "jdk.httpclient.maxstreams","read"; permission java.util.PropertyPermission "jdk.httpclient.redirects.retrylimit","read"; permission java.util.PropertyPermission "jdk.httpclient.windowsize","read"; + permission java.util.PropertyPermission "jdk.httpclient.receiveBufferSize","read"; permission java.util.PropertyPermission "jdk.httpclient.bufsize","read"; permission java.util.PropertyPermission "jdk.httpclient.internal.selector.timeout","read"; permission java.util.PropertyPermission "jdk.internal.httpclient.debug","read"; diff --git a/test/jdk/java/net/httpclient/websocket/security/httpclient.policy b/test/jdk/java/net/httpclient/websocket/security/httpclient.policy index 8a2c74df9b7..e63c2acd92a 100644 --- a/test/jdk/java/net/httpclient/websocket/security/httpclient.policy +++ b/test/jdk/java/net/httpclient/websocket/security/httpclient.policy @@ -49,6 +49,7 @@ grant codeBase "jrt:/jdk.incubator.httpclient" { permission java.util.PropertyPermission "jdk.httpclient.maxstreams","read"; permission java.util.PropertyPermission "jdk.httpclient.redirects.retrylimit","read"; permission java.util.PropertyPermission "jdk.httpclient.windowsize","read"; + permission java.util.PropertyPermission "jdk.httpclient.receiveBufferSize","read"; permission java.util.PropertyPermission "jdk.httpclient.bufsize","read"; permission java.util.PropertyPermission "jdk.httpclient.internal.selector.timeout","read"; permission java.util.PropertyPermission "jdk.internal.httpclient.debug","read";