# HG changeset patch # User jwilhelm # Date 1515808582 -3600 # Node ID cc231bd80c8becfea10c8d70b16093720c14abc9 # Parent 4d1970962ee93b2599a7eb4456ebfef2cadf9850# Parent fb56735cb46aaf6349900705ded4c0e0b863442d Merge diff -r 4d1970962ee9 -r cc231bd80c8b .hgtags --- a/.hgtags Mon Jan 15 15:18:27 2018 +0100 +++ b/.hgtags Sat Jan 13 02:56:22 2018 +0100 @@ -463,3 +463,4 @@ 0ee20aad71c4f33c426372b4c8bcc1235ce2ec08 jdk-11+0 959f2f7cbaa6d2ee45d50029744efb219721576c jdk-10+36 4f830b447edf04fb4a52151a5ad44d9bb60723cd jdk-10+37 +e569e83139fdfbecfeb3cd9014d560917787f158 jdk-10+38 diff -r 4d1970962ee9 -r cc231bd80c8b src/hotspot/cpu/x86/vm_version_x86.cpp --- a/src/hotspot/cpu/x86/vm_version_x86.cpp Mon Jan 15 15:18:27 2018 +0100 +++ b/src/hotspot/cpu/x86/vm_version_x86.cpp Sat Jan 13 02:56:22 2018 +0100 @@ -887,7 +887,7 @@ FLAG_SET_DEFAULT(UseSHA256Intrinsics, false); } - if (UseSHA) { + if (UseSHA && supports_avx2() && supports_bmi2()) { if (FLAG_IS_DEFAULT(UseSHA512Intrinsics)) { FLAG_SET_DEFAULT(UseSHA512Intrinsics, true); } diff -r 4d1970962ee9 -r cc231bd80c8b src/hotspot/os/linux/osContainer_linux.cpp --- a/src/hotspot/os/linux/osContainer_linux.cpp Mon Jan 15 15:18:27 2018 +0100 +++ b/src/hotspot/os/linux/osContainer_linux.cpp Sat Jan 13 02:56:22 2018 +0100 @@ -31,16 +31,11 @@ #include "logging/log.hpp" #include "osContainer_linux.hpp" -/* - * Warning: Some linux distros use 0x7FFFFFFFFFFFF000 - * and others use 0x7FFFFFFFFFFFFFFF for unlimited. - */ -#define UNLIMITED_MEM CONST64(0x7FFFFFFFFFFFF000) - #define PER_CPU_SHARES 1024 bool OSContainer::_is_initialized = false; bool OSContainer::_is_containerized = false; +julong _unlimited_memory; class CgroupSubsystem: CHeapObj { friend class OSContainer; @@ -217,6 +212,8 @@ _is_initialized = true; _is_containerized = false; + _unlimited_memory = (LONG_MAX / os::vm_page_size()) * os::vm_page_size(); + log_trace(os, container)("OSContainer::init: Initializing Container Support"); if (!UseContainerSupport) { log_trace(os, container)("Container Support not enabled"); @@ -419,37 +416,37 @@ * OSCONTAINER_ERROR for not supported */ jlong OSContainer::memory_limit_in_bytes() { - GET_CONTAINER_INFO(jlong, memory, "/memory.limit_in_bytes", - "Memory Limit is: " JLONG_FORMAT, JLONG_FORMAT, memlimit); + GET_CONTAINER_INFO(julong, memory, "/memory.limit_in_bytes", + "Memory Limit is: " JULONG_FORMAT, JULONG_FORMAT, memlimit); - if (memlimit >= UNLIMITED_MEM) { + if (memlimit >= _unlimited_memory) { log_trace(os, container)("Memory Limit is: Unlimited"); return (jlong)-1; } else { - return memlimit; + return (jlong)memlimit; } } jlong OSContainer::memory_and_swap_limit_in_bytes() { - GET_CONTAINER_INFO(jlong, memory, "/memory.memsw.limit_in_bytes", - "Memory and Swap Limit is: " JLONG_FORMAT, JLONG_FORMAT, memswlimit); - if (memswlimit >= UNLIMITED_MEM) { + GET_CONTAINER_INFO(julong, memory, "/memory.memsw.limit_in_bytes", + "Memory and Swap Limit is: " JULONG_FORMAT, JULONG_FORMAT, memswlimit); + if (memswlimit >= _unlimited_memory) { log_trace(os, container)("Memory and Swap Limit is: Unlimited"); return (jlong)-1; } else { - return memswlimit; + return (jlong)memswlimit; } } jlong OSContainer::memory_soft_limit_in_bytes() { - GET_CONTAINER_INFO(jlong, memory, "/memory.soft_limit_in_bytes", - "Memory Soft Limit is: " JLONG_FORMAT, JLONG_FORMAT, memsoftlimit); - if (memsoftlimit >= UNLIMITED_MEM) { + GET_CONTAINER_INFO(julong, memory, "/memory.soft_limit_in_bytes", + "Memory Soft Limit is: " JULONG_FORMAT, JULONG_FORMAT, memsoftlimit); + if (memsoftlimit >= _unlimited_memory) { log_trace(os, container)("Memory Soft Limit is: Unlimited"); return (jlong)-1; } else { - return memsoftlimit; + return (jlong)memsoftlimit; } } diff -r 4d1970962ee9 -r cc231bd80c8b src/hotspot/share/jvmci/jvmciCodeInstaller.cpp --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp Mon Jan 15 15:18:27 2018 +0100 +++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp Sat Jan 13 02:56:22 2018 +0100 @@ -600,6 +600,9 @@ if (!compiled_code->is_a(HotSpotCompiledNmethod::klass())) { oop stubName = HotSpotCompiledCode::name(compiled_code_obj); + if (oopDesc::is_null(stubName)) { + JVMCI_ERROR_OK("stub should have a name"); + } char* name = strdup(java_lang_String::as_utf8_string(stubName)); cb = RuntimeStub::new_runtime_stub(name, &buffer, diff -r 4d1970962ee9 -r cc231bd80c8b src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java --- a/src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. * 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,6 +66,8 @@ } // step 2: find mount point + List procMountsEntries = + fs.getMountEntries("/proc/mounts"); UnixPath parent = path.getParent(); while (parent != null) { UnixFileAttributes attrs = null; @@ -74,16 +76,23 @@ } catch (UnixException x) { x.rethrowAsIOException(parent); } - if (attrs.dev() != dev()) - break; + if (attrs.dev() != dev()) { + // step 3: lookup mounted file systems (use /proc/mounts to + // ensure we find the file system even when not in /etc/mtab) + byte[] dir = path.asByteArray(); + for (UnixMountEntry entry : procMountsEntries) { + if (Arrays.equals(dir, entry.dir())) + return entry; + } + } path = parent; parent = parent.getParent(); } - // step 3: lookup mounted file systems (use /proc/mounts to ensure we - // find the file system even when not in /etc/mtab) + // step 3: lookup mounted file systems (use /proc/mounts to + // ensure we find the file system even when not in /etc/mtab) byte[] dir = path.asByteArray(); - for (UnixMountEntry entry: fs.getMountEntries("/proc/mounts")) { + for (UnixMountEntry entry : procMountsEntries) { if (Arrays.equals(dir, entry.dir())) return entry; } diff -r 4d1970962ee9 -r cc231bd80c8b src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java --- a/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,7 @@ /** * Returns object to iterate over the mount entries in the given fstab file. */ - Iterable getMountEntries(String fstab) { + List getMountEntries(String fstab) { ArrayList entries = new ArrayList<>(); try { long fp = setmntent(Util.toBytes(fstab), Util.toBytes("r")); @@ -101,7 +101,7 @@ * Returns object to iterate over the mount entries in /etc/mtab */ @Override - Iterable getMountEntries() { + List getMountEntries() { return getMountEntries("/etc/mtab"); } diff -r 4d1970962ee9 -r cc231bd80c8b src/java.base/share/classes/java/io/ByteArrayOutputStream.java --- a/src/java.base/share/classes/java/io/ByteArrayOutputStream.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/java.base/share/classes/java/io/ByteArrayOutputStream.java Sat Jan 13 02:56:22 2018 +0100 @@ -27,6 +27,7 @@ import java.nio.charset.Charset; import java.util.Arrays; +import java.util.Objects; /** * This class implements an output stream in which the data is @@ -147,10 +148,7 @@ * @param len the number of bytes to write. */ public synchronized void write(byte b[], int off, int len) { - if ((off < 0) || (off > b.length) || (len < 0) || - ((off + len) - b.length > 0)) { - throw new IndexOutOfBoundsException(); - } + Objects.checkFromIndexSize(off, len, b.length); ensureCapacity(count + len); System.arraycopy(b, off, buf, count, len); count += len; diff -r 4d1970962ee9 -r cc231bd80c8b src/java.base/share/classes/java/io/File.java --- a/src/java.base/share/classes/java/io/File.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/java.base/share/classes/java/io/File.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2256,7 +2256,7 @@ private transient volatile Path filePath; /** - * Returns a {@link Path java.nio.file.Path} object constructed from the + * Returns a {@link Path java.nio.file.Path} object constructed from * this abstract path. The resulting {@code Path} is associated with the * {@link java.nio.file.FileSystems#getDefault default-filesystem}. * diff -r 4d1970962ee9 -r cc231bd80c8b src/java.base/share/classes/java/io/InputStream.java --- a/src/java.base/share/classes/java/io/InputStream.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/java.base/share/classes/java/io/InputStream.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,6 +56,93 @@ private static final int DEFAULT_BUFFER_SIZE = 8192; /** + * Returns a new {@code InputStream} that reads no bytes. The returned + * stream is initially open. The stream is closed by calling the + * {@code close()} method. Subsequent calls to {@code close()} have no + * effect. + * + *

While the stream is open, the {@code available()}, {@code read()}, + * {@code read(byte[])}, {@code read(byte[], int, int)}, + * {@code readAllBytes()}, {@code readNBytes()}, {@code skip()}, and + * {@code transferTo()} methods all behave as if end of stream has been + * reached. After the stream has been closed, these methods all throw + * {@code IOException}. + * + *

The {@code markSupported()} method returns {@code false}. The + * {@code mark()} method does nothing, and the {@code reset()} method + * throws {@code IOException}. + * + * @return an {@code InputStream} which contains no bytes + * + * @since 11 + */ + public static InputStream nullInputStream() { + return new InputStream() { + private volatile boolean closed; + + private void ensureOpen() throws IOException { + if (closed) { + throw new IOException("Stream closed"); + } + } + + @Override + public int available () throws IOException { + ensureOpen(); + return 0; + } + + @Override + public int read() throws IOException { + ensureOpen(); + return -1; + } + + @Override + public int read(byte[] b, int off, int len) throws IOException { + Objects.checkFromIndexSize(off, len, b.length); + if (len == 0) { + return 0; + } + ensureOpen(); + return -1; + } + + @Override + public byte[] readAllBytes() throws IOException { + ensureOpen(); + return new byte[0]; + } + + @Override + public int readNBytes(byte[] b, int off, int len) + throws IOException { + Objects.checkFromIndexSize(off, len, b.length); + ensureOpen(); + return 0; + } + + @Override + public long skip(long n) throws IOException { + ensureOpen(); + return 0L; + } + + @Override + public long transferTo(OutputStream out) throws IOException { + Objects.requireNonNull(out); + ensureOpen(); + return 0L; + } + + @Override + public void close() throws IOException { + closed = true; + } + }; + } + + /** * Reads the next byte of data from the input stream. The value byte is * returned as an int in the range 0 to * 255. If no byte is available because the end of the stream @@ -166,7 +253,6 @@ * @see java.io.InputStream#read() */ public int read(byte b[], int off, int len) throws IOException { - Objects.requireNonNull(b); Objects.checkFromIndexSize(off, len, b.length); if (len == 0) { return 0; @@ -326,7 +412,6 @@ * @since 9 */ public int readNBytes(byte[] b, int off, int len) throws IOException { - Objects.requireNonNull(b); Objects.checkFromIndexSize(off, len, b.length); int n = 0; diff -r 4d1970962ee9 -r cc231bd80c8b src/java.base/share/classes/java/io/ObjectInputStream.java --- a/src/java.base/share/classes/java/io/ObjectInputStream.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/java.base/share/classes/java/io/ObjectInputStream.java Sat Jan 13 02:56:22 2018 +0100 @@ -1296,7 +1296,6 @@ * @throws InvalidClassException if the filter rejects creation */ private void checkArray(Class arrayType, int arrayLength) throws InvalidClassException { - Objects.requireNonNull(arrayType); if (! arrayType.isArray()) { throw new IllegalArgumentException("not an array type"); } diff -r 4d1970962ee9 -r cc231bd80c8b src/java.base/share/classes/java/io/OutputStream.java --- a/src/java.base/share/classes/java/io/OutputStream.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/java.base/share/classes/java/io/OutputStream.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved. * 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,51 @@ */ public abstract class OutputStream implements Closeable, Flushable { /** + * Returns a new {@code OutputStream} which discards all bytes. The + * returned stream is initially open. The stream is closed by calling + * the {@code close()} method. Subsequent calls to {@code close()} have + * no effect. + * + *

While the stream is open, the {@code write(int)}, {@code + * write(byte[])}, and {@code write(byte[], int, int)} methods do nothing. + * After the stream has been closed, these methods all throw {@code + * IOException}. + * + *

The {@code flush()} method does nothing. + * + * @return an {@code OutputStream} which discards all bytes + * + * @since 11 + */ + public static OutputStream nullOutputStream() { + return new OutputStream() { + private volatile boolean closed; + + private void ensureOpen() throws IOException { + if (closed) { + throw new IOException("Stream closed"); + } + } + + @Override + public void write(int b) throws IOException { + ensureOpen(); + } + + @Override + public void write(byte b[], int off, int len) throws IOException { + Objects.checkFromIndexSize(off, len, b.length); + ensureOpen(); + } + + @Override + public void close() { + closed = true; + } + }; + } + + /** * Writes the specified byte to this output stream. The general * contract for write is that one byte is written * to the output stream. The byte to be written is the eight @@ -106,7 +151,6 @@ * stream is closed. */ public void write(byte b[], int off, int len) throws IOException { - Objects.requireNonNull(b); Objects.checkFromIndexSize(off, len, b.length); // len == 0 condition implicitly handled by loop bounds for (int i = 0 ; i < len ; i++) { diff -r 4d1970962ee9 -r cc231bd80c8b src/java.base/share/classes/java/lang/invoke/MethodHandle.java --- a/src/java.base/share/classes/java/lang/invoke/MethodHandle.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandle.java Sat Jan 13 02:56:22 2018 +0100 @@ -1667,6 +1667,7 @@ /** Craft a LambdaForm customized for this particular MethodHandle */ /*non-public*/ void customize() { + final LambdaForm form = this.form; if (form.customized == null) { LambdaForm newForm = form.customize(this); updateForm(newForm); diff -r 4d1970962ee9 -r cc231bd80c8b src/java.base/share/classes/java/net/InetSocketAddress.java --- a/src/java.base/share/classes/java/net/InetSocketAddress.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/java.base/share/classes/java/net/InetSocketAddress.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -317,10 +317,9 @@ } /** - * * Gets the {@code InetAddress}. * - * @return the InetAdress or {@code null} if it is unresolved. + * @return the InetAddress or {@code null} if it is unresolved. */ public final InetAddress getAddress() { return holder.getAddress(); diff -r 4d1970962ee9 -r cc231bd80c8b src/java.base/share/classes/java/util/regex/Pattern.java --- a/src/java.base/share/classes/java/util/regex/Pattern.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/java.base/share/classes/java/util/regex/Pattern.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -954,6 +954,12 @@ private int flags; /** + * The temporary pattern flags used during compiling. The flags might be turn + * on and off by embedded flag. + */ + private transient int flags0; + + /** * Boolean indicating this Pattern is compiled; this is necessary in order * to lazily compile deserialized Patterns. */ @@ -1137,7 +1143,7 @@ * @return The match flags specified when this pattern was compiled */ public int flags() { - return flags; + return flags0; } /** @@ -1369,6 +1375,9 @@ // Read in all fields s.defaultReadObject(); + // reset the flags + flags0 = flags; + // Initialize counts capturingGroupCount = 1; localCount = 0; @@ -1400,6 +1409,9 @@ if ((flags & UNICODE_CHARACTER_CLASS) != 0) flags |= UNICODE_CASE; + // 'flags' for compiling + flags0 = flags; + // Reset group index count capturingGroupCount = 1; localCount = 0; @@ -1841,7 +1853,7 @@ * Indicates whether a particular flag is set or not. */ private boolean has(int f) { - return (flags & f) != 0; + return (flags0 & f) != 0; } /** @@ -2718,7 +2730,7 @@ ch == 0x53 || ch == 0x73 || //S and s ch == 0x4b || ch == 0x6b || //K and k ch == 0xc5 || ch == 0xe5))) { //A+ring - bits.add(ch, flags()); + bits.add(ch, flags0); return null; } return single(ch); @@ -2931,7 +2943,7 @@ boolean capturingGroup = false; Node head = null; Node tail = null; - int save = flags; + int save = flags0; int saveTCNCount = topClosureNodes.size(); root = null; int ch = next(); @@ -3032,7 +3044,7 @@ } accept(')', "Unclosed group"); - flags = save; + flags0 = save; // Check for quantifiers Node node = closure(head); @@ -3135,28 +3147,28 @@ for (;;) { switch (ch) { case 'i': - flags |= CASE_INSENSITIVE; + flags0 |= CASE_INSENSITIVE; break; case 'm': - flags |= MULTILINE; + flags0 |= MULTILINE; break; case 's': - flags |= DOTALL; + flags0 |= DOTALL; break; case 'd': - flags |= UNIX_LINES; + flags0 |= UNIX_LINES; break; case 'u': - flags |= UNICODE_CASE; + flags0 |= UNICODE_CASE; break; case 'c': - flags |= CANON_EQ; + flags0 |= CANON_EQ; break; case 'x': - flags |= COMMENTS; + flags0 |= COMMENTS; break; case 'U': - flags |= (UNICODE_CHARACTER_CLASS | UNICODE_CASE); + flags0 |= (UNICODE_CHARACTER_CLASS | UNICODE_CASE); break; case '-': // subFlag then fall through ch = next(); @@ -3178,28 +3190,28 @@ for (;;) { switch (ch) { case 'i': - flags &= ~CASE_INSENSITIVE; + flags0 &= ~CASE_INSENSITIVE; break; case 'm': - flags &= ~MULTILINE; + flags0 &= ~MULTILINE; break; case 's': - flags &= ~DOTALL; + flags0 &= ~DOTALL; break; case 'd': - flags &= ~UNIX_LINES; + flags0 &= ~UNIX_LINES; break; case 'u': - flags &= ~UNICODE_CASE; + flags0 &= ~UNICODE_CASE; break; case 'c': - flags &= ~CANON_EQ; + flags0 &= ~CANON_EQ; break; case 'x': - flags &= ~COMMENTS; + flags0 &= ~COMMENTS; break; case 'U': - flags &= ~(UNICODE_CHARACTER_CLASS | UNICODE_CASE); + flags0 &= ~(UNICODE_CHARACTER_CLASS | UNICODE_CASE); break; default: return; diff -r 4d1970962ee9 -r cc231bd80c8b src/java.compiler/share/classes/javax/tools/FileManagerUtils.java --- a/src/java.compiler/share/classes/javax/tools/FileManagerUtils.java Mon Jan 15 15:18:27 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2014, 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 javax.tools; - -import java.io.File; -import java.nio.file.Path; -import java.util.Iterator; - -/** - * Package-private utility methods to convert between files and paths. - * - * @since 9 - */ -class FileManagerUtils { - private FileManagerUtils() { } - - static Iterable asPaths(final Iterable files) { - return () -> new Iterator() { - Iterator iter = files.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public Path next() { - return iter.next().toPath(); - } - }; - } - - static Iterable asFiles(final Iterable paths) { - return () -> new Iterator() { - Iterator iter = paths.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public File next() { - Path p = iter.next(); - try { - return p.toFile(); - } catch (UnsupportedOperationException e) { - throw new IllegalArgumentException(p.toString(), e); - } - } - }; - } -} diff -r 4d1970962ee9 -r cc231bd80c8b src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java --- a/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,8 +30,7 @@ import java.nio.file.Path; import java.util.Arrays; import java.util.Collection; - -import static javax.tools.FileManagerUtils.*; +import java.util.Iterator; /** * File manager based on {@linkplain File java.io.File} and {@linkplain Path java.nio.file.Path}. @@ -447,4 +446,42 @@ * @since 9 */ default void setPathFactory(PathFactory f) { } + + + private static Iterable asPaths(final Iterable files) { + return () -> new Iterator() { + Iterator iter = files.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public Path next() { + return iter.next().toPath(); + } + }; + } + + private static Iterable asFiles(final Iterable paths) { + return () -> new Iterator() { + Iterator iter = paths.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public File next() { + Path p = iter.next(); + try { + return p.toFile(); + } catch (UnsupportedOperationException e) { + throw new IllegalArgumentException(p.toString(), e); + } + } + }; + } } diff -r 4d1970962ee9 -r cc231bd80c8b src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTBackend.java --- a/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTBackend.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/jdk.aot/share/classes/jdk.tools.jaotc/src/jdk/tools/jaotc/AOTBackend.java Sat Jan 13 02:56:22 2018 +0100 @@ -166,7 +166,7 @@ void printCompiledMethod(HotSpotResolvedJavaMethod resolvedMethod, CompilationResult compResult) { // This is really not installing the method. - InstalledCode installedCode = codeCache.addCode(resolvedMethod, HotSpotCompiledCodeBuilder.createCompiledCode(codeCache, null, null, compResult), null, null); + InstalledCode installedCode = codeCache.addCode(resolvedMethod, HotSpotCompiledCodeBuilder.createCompiledCode(codeCache, resolvedMethod, null, compResult), null, null); String disassembly = codeCache.disassemble(installedCode); if (disassembly != null) { main.printer.printlnDebug(disassembly); diff -r 4d1970962ee9 -r cc231bd80c8b src/jdk.compiler/share/classes/com/sun/tools/doclint/DocLint.java --- a/src/jdk.compiler/share/classes/com/sun/tools/doclint/DocLint.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/jdk.compiler/share/classes/com/sun/tools/doclint/DocLint.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,8 +37,10 @@ import javax.tools.StandardLocation; import com.sun.source.doctree.DocCommentTree; +import com.sun.source.tree.BlockTree; import com.sun.source.tree.ClassTree; import com.sun.source.tree.CompilationUnitTree; +import com.sun.source.tree.LambdaExpressionTree; import com.sun.source.tree.ModuleTree; import com.sun.source.tree.PackageTree; import com.sun.source.tree.MethodTree; @@ -398,6 +400,7 @@ visitDecl(tree, null); return super.visitPackage(tree, ignore); } + @Override @DefinedBy(Api.COMPILER_TREE) public Void visitClass(ClassTree tree, Void ignore) { visitDecl(tree, tree.getSimpleName()); @@ -407,7 +410,6 @@ @Override @DefinedBy(Api.COMPILER_TREE) public Void visitMethod(MethodTree tree, Void ignore) { visitDecl(tree, tree.getName()); - //return super.visitMethod(tree, ignore); return null; } @@ -431,6 +433,16 @@ return super.visitCompilationUnit(node, p); } + @Override @DefinedBy(Api.COMPILER_TREE) + public Void visitBlock(BlockTree tree, Void ignore) { + return null; + } + + @Override @DefinedBy(Api.COMPILER_TREE) + public Void visitLambdaExpression(LambdaExpressionTree tree, Void ignore) { + return null; + } + } // diff -r 4d1970962ee9 -r cc231bd80c8b src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -4743,9 +4743,8 @@ // Check for proper use of serialVersionUID if (env.info.lint.isEnabled(LintCategory.SERIAL) && isSerializable(c.type) - && (c.flags() & Flags.ENUM) == 0 - && !c.isAnonymous() - && checkForSerial(c)) { + && (c.flags() & (Flags.ENUM | Flags.INTERFACE)) == 0 + && !c.isAnonymous()) { checkSerialVersionUID(tree, c); } if (allowTypeAnnos) { @@ -4757,17 +4756,6 @@ } } // where - boolean checkForSerial(ClassSymbol c) { - if ((c.flags() & ABSTRACT) == 0) { - return true; - } else { - return c.members().anyMatch(anyNonAbstractOrDefaultMethod); - } - } - - public static final Filter anyNonAbstractOrDefaultMethod = s -> - s.kind == MTH && (s.flags() & (DEFAULT | ABSTRACT)) != ABSTRACT; - /** get a diagnostic position for an attribute of Type t, or null if attribute missing */ private DiagnosticPosition getDiagnosticPosition(JCClassDecl tree, Type t) { for(List al = tree.mods.annotations; !al.isEmpty(); al = al.tail) { diff -r 4d1970962ee9 -r cc231bd80c8b src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Sat Jan 13 02:56:22 2018 +0100 @@ -3464,6 +3464,7 @@ types.hasSameArgs(sym.type, byName.type) || types.hasSameArgs(types.erasure(sym.type), types.erasure(byName.type)))) { if ((sym.flags() & VARARGS) != (byName.flags() & VARARGS)) { + sym.flags_field |= CLASH; varargsDuplicateError(pos, sym, byName); return true; } else if (sym.kind == MTH && !types.hasSameArgs(sym.type, byName.type, false)) { diff -r 4d1970962ee9 -r cc231bd80c8b src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Sat Jan 13 02:56:22 2018 +0100 @@ -1618,19 +1618,30 @@ if ((m1.flags() & BRIDGE) != (m2.flags() & BRIDGE)) return ((m1.flags() & BRIDGE) != 0) ? m2 : m1; + if (m1.baseSymbol() == m2.baseSymbol()) { + // this is the same imported symbol which has been cloned twice. + // Return the first one (either will do). + return m1; + } + // if one overrides or hides the other, use it TypeSymbol m1Owner = (TypeSymbol)m1.owner; TypeSymbol m2Owner = (TypeSymbol)m2.owner; - if (types.asSuper(m1Owner.type, m2Owner) != null && - ((m1.owner.flags_field & INTERFACE) == 0 || - (m2.owner.flags_field & INTERFACE) != 0) && - m1.overrides(m2, m1Owner, types, false)) - return m1; - if (types.asSuper(m2Owner.type, m1Owner) != null && - ((m2.owner.flags_field & INTERFACE) == 0 || - (m1.owner.flags_field & INTERFACE) != 0) && - m2.overrides(m1, m2Owner, types, false)) - return m2; + // the two owners can never be the same if the target methods are compiled from source, + // but we need to protect against cases where the methods are defined in some classfile + // and make sure we issue an ambiguity error accordingly (by skipping the logic below). + if (m1Owner != m2Owner) { + if (types.asSuper(m1Owner.type, m2Owner) != null && + ((m1.owner.flags_field & INTERFACE) == 0 || + (m2.owner.flags_field & INTERFACE) != 0) && + m1.overrides(m2, m1Owner, types, false)) + return m1; + if (types.asSuper(m2Owner.type, m1Owner) != null && + ((m2.owner.flags_field & INTERFACE) == 0 || + (m1.owner.flags_field & INTERFACE) != 0) && + m2.overrides(m1, m2Owner, types, false)) + return m2; + } boolean m1Abstract = (m1.flags() & ABSTRACT) != 0; boolean m2Abstract = (m2.flags() & ABSTRACT) != 0; if (m1Abstract && !m2Abstract) return m2; diff -r 4d1970962ee9 -r cc231bd80c8b src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1678,7 +1678,7 @@ try { writeClassFile(out, c); if (verbose) - log.printVerbose("wrote.file", outFile); + log.printVerbose("wrote.file", outFile.getName()); out.close(); out = null; } finally { diff -r 4d1970962ee9 -r cc231bd80c8b src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java --- a/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java Sat Jan 13 02:56:22 2018 +0100 @@ -116,7 +116,7 @@ if(clazz.isArray()) { // Some languages won't have a notion of manipulating collections. Exposing "length" on arrays as an // explicit property is beneficial for them. - setPropertyGetter("length", MethodHandles.arrayLength(clazz), ValidationType.EXACT_CLASS); + setPropertyGetter("length", GET_ARRAY_LENGTH, ValidationType.IS_ARRAY); } else if(Collection.class.isAssignableFrom(clazz)) { setPropertyGetter("length", GET_COLLECTION_LENGTH, ValidationType.INSTANCE_OF); } else if(Map.class.isAssignableFrom(clazz)) { @@ -546,6 +546,9 @@ private static final MethodHandle GET_MAP_LENGTH = Lookup.PUBLIC.findVirtual(Map.class, "size", MethodType.methodType(int.class)); + private static final MethodHandle GET_ARRAY_LENGTH = Lookup.PUBLIC.findStatic(Array.class, "getLength", + MethodType.methodType(int.class, Object.class)); + private static void assertParameterCount(final CallSiteDescriptor descriptor, final int paramCount) { if(descriptor.getMethodType().parameterCount() != paramCount) { throw new BootstrapMethodError(descriptor.getOperation() + " must have exactly " + paramCount + " parameters."); diff -r 4d1970962ee9 -r cc231bd80c8b src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java --- a/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/main/ToolOption.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -159,6 +159,7 @@ public void process(Helper helper, String arg) { helper.encoding = arg; helper.setCompilerOpt(opt, arg); + helper.setFileManagerOpt(Option.ENCODING, arg); } }, diff -r 4d1970962ee9 -r cc231bd80c8b src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Mon Jan 15 15:18:27 2018 +0100 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Sat Jan 13 02:56:22 2018 +0100 @@ -820,11 +820,14 @@ Content summary = new ContentBuilder(); if (display(usesTrees)) { description = usesTrees.get(t); - if (description != null) { - summary.addContent(description); + if (description != null && !description.isEmpty()) { + summary.addContent(HtmlTree.DIV(HtmlStyle.block, description)); + } else { + addSummaryComment(t, summary); } + } else { + summary.addContent(Contents.SPACE); } - addSummaryComment(t, summary); table.addRow(typeLinkContent, summary); } } @@ -847,11 +850,12 @@ Content desc = new ContentBuilder(); if (display(providesTrees)) { description = providesTrees.get(srv); - if (description != null) { - desc.addContent(description); + desc.addContent((description != null && !description.isEmpty()) + ? HtmlTree.DIV(HtmlStyle.block, description) + : Contents.SPACE); + } else { + desc.addContent(Contents.SPACE); } - } - addSummaryComment(srv, desc); // Only display the implementation details in the "all" mode. if (moduleMode == ModuleMode.ALL && !implSet.isEmpty()) { desc.addContent(new HtmlTree(HtmlTag.BR)); diff -r 4d1970962ee9 -r cc231bd80c8b test/hotspot/jtreg/compiler/aot/cli/jaotc/CompileClassWithDebugTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/hotspot/jtreg/compiler/aot/cli/jaotc/CompileClassWithDebugTest.java Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @requires vm.aot + * @library / /test/lib /testlibrary + * @modules java.base/jdk.internal.misc + * @build compiler.aot.cli.jaotc.CompileClassWithDebugTest + * @run driver ClassFileInstaller compiler.aot.cli.jaotc.data.HelloWorldOne + * @run driver compiler.aot.cli.jaotc.CompileClassWithDebugTest + * @summary check that jaotc can compile a class with a --debug flag + */ + +package compiler.aot.cli.jaotc; + +import compiler.aot.cli.jaotc.data.HelloWorldOne; +import java.io.File; +import jdk.test.lib.Asserts; +import jdk.test.lib.process.OutputAnalyzer; + +public class CompileClassWithDebugTest { + public static void main(String[] args) { + OutputAnalyzer oa = JaotcTestHelper.compileLibrary("--debug", "--class-name", JaotcTestHelper + .getClassAotCompilationName(HelloWorldOne.class)); + oa.shouldHaveExitValue(0); + File compiledLibrary = new File(JaotcTestHelper.DEFAULT_LIB_PATH); + Asserts.assertTrue(compiledLibrary.exists(), "Compiled library file missing"); + Asserts.assertGT(compiledLibrary.length(), 0L, "Unexpected compiled library size"); + JaotcTestHelper.checkLibraryUsage(HelloWorldOne.class.getName()); + } +} diff -r 4d1970962ee9 -r cc231bd80c8b test/jdk/ProblemList.txt --- a/test/jdk/ProblemList.txt Mon Jan 15 15:18:27 2018 +0100 +++ b/test/jdk/ProblemList.txt Sat Jan 13 02:56:22 2018 +0100 @@ -218,6 +218,8 @@ java/net/DatagramSocket/SendDatagramToBadAddress.java 7143960 macosx-all +java/net/httpclient/SplitResponseSSL.java 8194151 windows-all + ############################################################################ # jdk_nio diff -r 4d1970962ee9 -r cc231bd80c8b test/jdk/java/io/InputStream/NullInputStream.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/io/InputStream/NullInputStream.java Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * 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.InputStream; +import java.io.IOException; +import org.testng.annotations.AfterGroups; +import org.testng.annotations.BeforeGroups; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/* + * @test + * @bug 4358774 + * @run testng NullInputStream + * @summary Check for expected behavior of InputStream.nullInputStream(). + */ +public class NullInputStream { + private static InputStream openStream; + private static InputStream closedStream; + + @BeforeGroups(groups="open") + public static void openStream() { + openStream = InputStream.nullInputStream(); + } + + @BeforeGroups(groups="closed") + public static void openAndCloseStream() { + closedStream = InputStream.nullInputStream(); + try { + closedStream.close(); + } catch (IOException e) { + fail("Unexpected IOException"); + } + } + + @AfterGroups(groups="open") + public static void closeStream() { + try { + openStream.close(); + } catch (IOException e) { + fail("Unexpected IOException"); + } + } + + @Test(groups = "open") + public static void testOpen() { + assertNotNull(openStream, "InputStream.nullInputStream() returned null"); + } + + @Test(groups = "open") + public static void testAvailable() { + try { + assertEquals(0, openStream.available(), "available() != 0"); + } catch (IOException ioe) { + fail("Unexpected IOException"); + } + } + + @Test(groups = "open") + public static void testRead() { + try { + assertEquals(-1, openStream.read(), "read() != -1"); + } catch (IOException ioe) { + fail("Unexpected IOException"); + } + } + + @Test(groups = "open") + public static void testReadBII() { + try { + assertEquals(-1, openStream.read(new byte[1], 0, 1), + "read(byte[],int,int) != -1"); + } catch (IOException ioe) { + fail("Unexpected IOException"); + } + } + + @Test(groups = "open") + public static void testReadAllBytes() { + try { + assertEquals(0, openStream.readAllBytes().length, + "readAllBytes().length != 0"); + } catch (IOException ioe) { + fail("Unexpected IOException"); + } + } + + @Test(groups = "open") + public static void testreadNBytes() { + try { + assertEquals(0, openStream.readNBytes(new byte[1], 0, 1), + "readNBytes(byte[],int,int) != 0"); + } catch (IOException ioe) { + fail("Unexpected IOException"); + } + } + + @Test(groups = "open") + public static void testSkip() { + try { + assertEquals(0, openStream.skip(1), "skip() != 0"); + } catch (IOException ioe) { + fail("Unexpected IOException"); + } + } + + @Test(groups = "open") + public static void testTransferTo() { + try { + assertEquals(0, openStream.transferTo(new ByteArrayOutputStream(7)), + "transferTo() != 0"); + } catch (IOException ioe) { + fail("Unexpected IOException"); + } + } + + @Test(groups = "closed") + public static void testAvailableClosed() { + try { + closedStream.available(); + fail("Expected IOException not thrown"); + } catch (IOException e) { + } + } + + @Test(groups = "closed") + public static void testReadClosed() { + try { + closedStream.read(); + fail("Expected IOException not thrown"); + } catch (IOException e) { + } + } + + @Test(groups = "closed") + public static void testReadBIIClosed() { + try { + closedStream.read(new byte[1], 0, 1); + fail("Expected IOException not thrown"); + } catch (IOException e) { + } + } + + @Test(groups = "closed") + public static void testReadAllBytesClosed() { + try { + closedStream.readAllBytes(); + fail("Expected IOException not thrown"); + } catch (IOException e) { + } + } + + @Test(groups = "closed") + public static void testReadNBytesClosed() { + try { + closedStream.readNBytes(new byte[1], 0, 1); + fail("Expected IOException not thrown"); + } catch (IOException e) { + } + } + + @Test(groups = "closed") + public static void testSkipClosed() { + try { + closedStream.skip(1); + fail("Expected IOException not thrown"); + } catch (IOException e) { + } + } + + @Test(groups = "closed") + public static void testTransferToClosed() { + try { + closedStream.transferTo(new ByteArrayOutputStream(7)); + fail("Expected IOException not thrown"); + } catch (IOException e) { + } + } +} diff -r 4d1970962ee9 -r cc231bd80c8b test/jdk/java/io/InputStream/ReadParams.java --- a/test/jdk/java/io/InputStream/ReadParams.java Mon Jan 15 15:18:27 2018 +0100 +++ b/test/jdk/java/io/InputStream/ReadParams.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. * 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 4008296 4008293 4190090 4193729 + * @bug 4008296 4008293 4190090 4193729 4358774 * @summary Check for correct handling of parameters to * XXXXInputStream.read(b, off, len). * @@ -197,6 +197,11 @@ doTest1(ifs); ifs.close(); + InputStream nis = InputStream.nullInputStream(); + doTest(nis); + doTest1(nis); + nis.close(); + /* cleanup */ fn.delete(); } diff -r 4d1970962ee9 -r cc231bd80c8b test/jdk/java/io/OutputStream/NullOutputStream.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/jdk/java/io/OutputStream/NullOutputStream.java Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * 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.IOException; +import java.io.OutputStream; +import org.testng.annotations.AfterGroups; +import org.testng.annotations.BeforeGroups; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +/* + * @test + * @bug 4358774 + * @run testng NullOutputStream + * @summary Check for expected behavior of OutputStream.nullOutputStream(). + */ +public class NullOutputStream { + private static OutputStream openStream; + private static OutputStream closedStream; + + @BeforeGroups(groups="open") + public static void openStream() { + openStream = OutputStream.nullOutputStream(); + } + + @BeforeGroups(groups="closed") + public static void openAndCloseStream() { + closedStream = OutputStream.nullOutputStream(); + try { + closedStream.close(); + } catch (IOException e) { + fail("Unexpected IOException"); + } + } + + @AfterGroups(groups="open") + public static void closeStream() { + try { + openStream.close(); + } catch (IOException e) { + fail("Unexpected IOException"); + } + } + + @Test(groups="open") + public static void testOpen() { + assertNotNull(openStream, + "OutputStream.nullOutputStream() returned null"); + } + + @Test(groups="open") + public static void testWrite() { + try { + openStream.write(62832); + } catch (IOException e) { + fail("Unexpected IOException"); + } + } + + @Test(groups="open") + public static void testWriteBII() { + try { + openStream.write(new byte[] {(byte)6}, 0, 1); + } catch (Exception e) { + fail("Unexpected IOException"); + } + } + + @Test(groups="closed") + public static void testWriteClosed() { + try { + closedStream.write(62832); + fail("Expected IOException not thrown"); + } catch (IOException e) { + } + } + + @Test(groups="closed") + public static void testWriteBIIClosed() { + try { + closedStream.write(new byte[] {(byte)6}, 0, 1); + fail("Expected IOException not thrown"); + } catch (IOException e) { + } + } +} diff -r 4d1970962ee9 -r cc231bd80c8b test/jdk/java/io/OutputStream/WriteParams.java --- a/test/jdk/java/io/OutputStream/WriteParams.java Mon Jan 15 15:18:27 2018 +0100 +++ b/test/jdk/java/io/OutputStream/WriteParams.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. * 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 1267039 1267043 4193729 + * @bug 1267039 1267043 4193729 4358774 * @summary Check for correct handling of parameters to * XXXXOutputStream.write(b, off, len). * @@ -152,6 +152,11 @@ doTest1(dfos); dfos.close(); + OutputStream nos = OutputStream.nullOutputStream(); + doTest(nos); + doTest1(nos); + nos.close(); + /* cleanup */ fn.delete(); diff -r 4d1970962ee9 -r cc231bd80c8b test/jdk/java/util/Locale/bcp47u/FormatTests.java --- a/test/jdk/java/util/Locale/bcp47u/FormatTests.java Mon Jan 15 15:18:27 2018 +0100 +++ b/test/jdk/java/util/Locale/bcp47u/FormatTests.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /* * * @test - * @bug 8176841 + * @bug 8176841 8194148 * @summary Tests *Format class deals with Unicode extensions * correctly. * @modules jdk.localedata @@ -73,6 +73,7 @@ private static final String NUM_SINH = "\u0de7\u0de8,\u0de9\u0dea\u0deb.\u0dec\u0ded\u0dee\u0def"; private static final Date testDate = new Calendar.Builder() + .setCalendarType("gregory") .setDate(2017, 7, 10) .setTimeOfDay(15, 15, 0) .setTimeZone(AMLA) diff -r 4d1970962ee9 -r cc231bd80c8b test/jdk/java/util/Locale/bcp47u/SymbolsTests.java --- a/test/jdk/java/util/Locale/bcp47u/SymbolsTests.java Mon Jan 15 15:18:27 2018 +0100 +++ b/test/jdk/java/util/Locale/bcp47u/SymbolsTests.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,11 +24,11 @@ /* * * @test - * @bug 8176841 + * @bug 8176841 8194148 * @summary Tests *FormatSymbols class deals with Unicode extensions * correctly. * @modules jdk.localedata - * @run testng/othervm -Djava.locale.providers=CLDR FormatTests + * @run testng/othervm -Djava.locale.providers=CLDR SymbolsTests */ import static org.testng.Assert.assertEquals; @@ -66,11 +66,11 @@ return new Object[][] { // Locale, expected decimal separator, expected grouping separator - {RG_AT, ",", "."}, - {Locale.US, ".", ","}, + {RG_AT, ',', '.'}, + {Locale.US, '.', ','}, // -nu & -rg mixed. -nu should win - {Locale.forLanguageTag("ar-EG-u-nu-latn-rg-mazzzz"), ".", ","}, + {Locale.forLanguageTag("ar-EG-u-nu-latn-rg-mazzzz"), '.', ','}, }; } diff -r 4d1970962ee9 -r cc231bd80c8b test/jdk/java/util/regex/RegExTest.java --- a/test/jdk/java/util/regex/RegExTest.java Mon Jan 15 15:18:27 2018 +0100 +++ b/test/jdk/java/util/regex/RegExTest.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ * 8027645 8035076 8039124 8035975 8074678 6854417 8143854 8147531 7071819 * 8151481 4867170 7080302 6728861 6995635 6736245 4916384 6328855 6192895 * 6345469 6988218 6693451 7006761 8140212 8143282 8158482 8176029 8184706 + * 8194667 * * @library /test/lib * @build jdk.test.lib.RandomFactory @@ -1367,24 +1368,35 @@ report("Reluctant Repetition"); } + private static Pattern serializedPattern(Pattern p) throws Exception { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(p); + oos.close(); + try (ObjectInputStream ois = new ObjectInputStream( + new ByteArrayInputStream(baos.toByteArray()))) { + return (Pattern)ois.readObject(); + } + } + private static void serializeTest() throws Exception { String patternStr = "(b)"; String matchStr = "b"; Pattern pattern = Pattern.compile(patternStr); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream oos = new ObjectOutputStream(baos); - oos.writeObject(pattern); - oos.close(); - ObjectInputStream ois = new ObjectInputStream( - new ByteArrayInputStream(baos.toByteArray())); - Pattern serializedPattern = (Pattern)ois.readObject(); - ois.close(); + Pattern serializedPattern = serializedPattern(pattern); Matcher matcher = serializedPattern.matcher(matchStr); if (!matcher.matches()) failCount++; if (matcher.groupCount() != 1) failCount++; + pattern = Pattern.compile("a(?-i)b", Pattern.CASE_INSENSITIVE); + serializedPattern = serializedPattern(pattern); + if (!serializedPattern.matcher("Ab").matches()) + failCount++; + if (serializedPattern.matcher("AB").matches()) + failCount++; + report("Serialization"); } diff -r 4d1970962ee9 -r cc231bd80c8b test/jdk/java/util/stream/test/org/openjdk/tests/java/util/stream/WhileOpTest.java --- a/test/jdk/java/util/stream/test/org/openjdk/tests/java/util/stream/WhileOpTest.java Mon Jan 15 15:18:27 2018 +0100 +++ b/test/jdk/java/util/stream/test/org/openjdk/tests/java/util/stream/WhileOpTest.java Sat Jan 13 02:56:22 2018 +0100 @@ -47,6 +47,7 @@ /* * @test * @bug 8071597 8193856 + * @run main/timeout=240 */ @Test public class WhileOpTest extends OpTestCase { diff -r 4d1970962ee9 -r cc231bd80c8b test/jdk/javax/net/ssl/compatibility/Parameter.java --- a/test/jdk/javax/net/ssl/compatibility/Parameter.java Mon Jan 15 15:18:27 2018 +0100 +++ b/test/jdk/javax/net/ssl/compatibility/Parameter.java Sat Jan 13 02:56:22 2018 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,15 +65,15 @@ TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384( Protocol.TLSV1_2, JdkRelease.JDK7), TLS_RSA_WITH_AES_256_CBC_SHA256( - Protocol.TLSV1_2, JdkRelease.JDK7), + Protocol.TLSV1_2, JdkRelease.JDK6), TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384( Protocol.TLSV1_2, JdkRelease.JDK7), TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384( Protocol.TLSV1_2, JdkRelease.JDK7), TLS_DHE_RSA_WITH_AES_256_CBC_SHA256( - Protocol.TLSV1_2, JdkRelease.JDK7), + Protocol.TLSV1_2, JdkRelease.JDK6), TLS_DHE_DSS_WITH_AES_256_CBC_SHA256( - Protocol.TLSV1_2, JdkRelease.JDK7), + Protocol.TLSV1_2, JdkRelease.JDK6), TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA(), TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA(), TLS_RSA_WITH_AES_256_CBC_SHA(), @@ -86,15 +86,15 @@ TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256( Protocol.TLSV1_2, JdkRelease.JDK7), TLS_RSA_WITH_AES_128_CBC_SHA256( - Protocol.TLSV1_2, JdkRelease.JDK7), + Protocol.TLSV1_2, JdkRelease.JDK6), TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256( Protocol.TLSV1_2, JdkRelease.JDK7), TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256( Protocol.TLSV1_2, JdkRelease.JDK7), TLS_DHE_RSA_WITH_AES_128_CBC_SHA256( - Protocol.TLSV1_2, JdkRelease.JDK7), + Protocol.TLSV1_2, JdkRelease.JDK6), TLS_DHE_DSS_WITH_AES_128_CBC_SHA256( - Protocol.TLSV1_2, JdkRelease.JDK7), + Protocol.TLSV1_2, JdkRelease.JDK6), TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA(), TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA(), TLS_RSA_WITH_AES_128_CBC_SHA(), diff -r 4d1970962ee9 -r cc231bd80c8b test/jdk/lib/testlibrary/bootlib/java.base/java/util/stream/LambdaTestHelpers.java --- a/test/jdk/lib/testlibrary/bootlib/java.base/java/util/stream/LambdaTestHelpers.java Mon Jan 15 15:18:27 2018 +0100 +++ b/test/jdk/lib/testlibrary/bootlib/java.base/java/util/stream/LambdaTestHelpers.java Sat Jan 13 02:56:22 2018 +0100 @@ -48,6 +48,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertFalse; +import static org.testng.Assert.fail; /** * LambdaTestHelpers -- assertion methods and useful objects for lambda test cases @@ -277,7 +278,7 @@ public static void assertContents(Iterable actual, Iterable expected) { if (actual instanceof Collection && expected instanceof Collection) { - assertEquals(actual, expected); + assertIterableEquals(actual, expected); } else { assertContents(actual.iterator(), expected.iterator()); } @@ -287,6 +288,42 @@ assertEquals(toBoxedList(actual), toBoxedList(expected)); } + // Workaround excessive String creation in inner loop in org.testng.Assert.assertEquals(Iterable, Iterable) + static public void assertIterableEquals(Iterable actual, Iterable expected) { + if(actual == expected) { + return; + } + + if(actual == null || expected == null) { + fail("Iterables not equal: expected: " + expected + " and actual: " + actual); + } + + assertIteratorsEquals(actual.iterator(), expected.iterator()); + } + + // Workaround excessive String creation in inner loop in org.testng.Assert.assertEquals(Iterator, Iterator) + static public void assertIteratorsEquals(Iterator actual, Iterator expected) { + if (actual == expected) { + return; + } + + if (actual == null || expected == null) { + fail("Iterators not equal: expected: " + expected + " and actual: " + actual); + } + + while (actual.hasNext() && expected.hasNext()) { + Object e = expected.next(); + Object a = actual.next(); + assertEquals(a, e, "Iterator contents differ"); + } + + if(actual.hasNext()) { + fail("Actual iterator returned more elements than the expected iterator."); + } else if(expected.hasNext()) { + fail("Expected iterator returned more elements than the actual iterator."); + } + } + @SafeVarargs @SuppressWarnings("varargs") public static void assertContents(Iterator actual, T... expected) { diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/ProblemList.txt --- a/test/langtools/ProblemList.txt Mon Jan 15 15:18:27 2018 +0100 +++ b/test/langtools/ProblemList.txt Sat Jan 13 02:56:22 2018 +0100 @@ -37,7 +37,7 @@ # jshell jdk/jshell/UserJdiUserRemoteTest.java 8173079 linux-all -jdk/jshell/UserInputTest.java 8169536 generic-all +jdk/jshell/UserInputTest.java 8169536 generic-all ########################################################################### # @@ -55,6 +55,7 @@ tools/javac/warnings/suppress/TypeAnnotations.java 8057683 generic-all improve ordering of errors with type annotations tools/javac/modules/SourceInSymlinkTest.java 8180263 windows-all fails when run on a subst drive tools/javac/options/release/ReleaseOptionUnsupported.java 8193784 generic-all temporary until support for --release 11 is worked out +tools/javac/jvm/VerboseOutTest.java 8194968 windows-all ########################################################################### # diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java --- a/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java Mon Jan 15 15:18:27 2018 +0100 +++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java Sat Jan 13 02:56:22 2018 +0100 @@ -23,7 +23,7 @@ /* * @test - * @bug 8178067 + * @bug 8178067 8192007 * @summary tests the module's services, such as provides and uses * @modules jdk.javadoc/jdk.javadoc.internal.api * jdk.javadoc/jdk.javadoc.internal.tool @@ -34,6 +34,7 @@ * @run main TestModuleServices */ +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -52,6 +53,106 @@ } @Test + public void checkModuleServicesDescription(Path base) throws Exception { + Path src = Files.createDirectories(base.resolve("src")); + ModuleBuilder mb = new ModuleBuilder(tb, "moduleService") + .comment("This module exports a package containing the declaration of a service type.") + .exports("pkgService") + .classes("/**A Package that has a service.*/ package pkgService;") + .classes("package pkgService; /**A service Interface for service providers.*/ " + + "public interface Service {\n" + + " /**\n" + + " * A test method for the service.\n" + + " */\n" + + " void testMethod1();\n" + + " /**\n" + + " * Another test method for the service.\n" + + " */\n" + + " void testMethod2();\n" + + "}"); + mb.write(src); + mb = new ModuleBuilder(tb, "moduleServiceProvider") + .comment("This module provides an implementation of a service.\n" + + "@provides pkgService.Service Provides a service whose name is ServiceProvider.") + .requires("moduleService") + .provides("pkgService.Service", "pkgServiceProvider.ServiceProvider") + .classes("/**A Package that has a service provider.*/ package pkgServiceProvider;") + .classes("package pkgServiceProvider;\n" + + "public class ServiceProvider implements pkgService.Service {\n" + + " /**\n" + + " * {@inheritDoc}\n" + + " */\n" + + " public void testMethod1() {}\n" + + " /**\n" + + " * This is an internal implementation so the documentation will not be seen.\n" + + " */\n" + + " public void testMethod2() {}\n" + + "}"); + mb.write(src); + mb = new ModuleBuilder(tb, "moduleServiceUser") + .comment("This module uses a service defined in another module.\n" + + "@uses pkgService.Service If no other provider is found, a default internal implementation will be used.") + .requires("moduleService") + .uses("pkgService.Service") + .classes("/**A Package that has a service user.*/ package pkgServiceUser;") + .classes("package pkgServiceUser;\n" + + "/**\n" + + " * A service user class.\n" + + " */\n" + + "public class ServiceUser {\n" + + "}"); + mb.write(src); + mb = new ModuleBuilder(tb, "moduleServiceUserNoDescription") + .comment("This is another module that uses a service defined in another module.\n" + + "@uses pkgService.Service") + .requires("moduleService") + .uses("pkgService.Service") + .classes("/**A Package that has a service user with no description.*/ package pkgServiceUserNoDescription;") + .classes("package pkgServiceUserNoDescription;\n" + + "/**\n" + + " * A service user class.\n" + + " */\n" + + "public class ServiceUserNoDescription {\n" + + "}"); + mb.write(src); + + javadoc("-d", base.resolve("out").toString(), + "-quiet", "-noindex", + "--module-source-path", src.toString(), + "--module", "moduleService,moduleServiceProvider,moduleServiceUser,moduleServiceUserNoDescription", + "pkgService", "moduleServiceProvider/pkgServiceProvider", "moduleServiceUser/pkgServiceUser", + "moduleServiceUserNoDescription/pkgServiceUserNoDescription"); + checkExit(Exit.OK); + + checkOutput("moduleServiceProvider-summary.html", true, + "\n" + + "Service\n" + + "\n" + + "

Provides a service whose name is ServiceProvider.
\n" + + "\n" + + ""); + checkOutput("moduleServiceUser-summary.html", true, + "\n" + + "Service\n" + + "\n" + + "
If no other provider is found, a default internal implementation will be used.
\n" + + "\n" + + ""); + checkOutput("moduleServiceUserNoDescription-summary.html", true, + "\n" + + "Service\n" + + "\n" + + "
A service Interface for service providers.
\n" + + "\n" + + ""); + checkOutput("moduleServiceProvider-summary.html", false, + "A service Interface for service providers."); + checkOutput("moduleServiceUser-summary.html", false, + "A service Interface for service providers."); + } + + @Test public void checkUsesNoApiTagModuleModeDefault(Path base) throws Exception { ModuleBuilder mb = new ModuleBuilder(tb, "m") .comment("module m.\n@provides p1.A abc") // bogus tag @@ -251,7 +352,8 @@ "\n" + "\n" + "A\n" + - "abc \n" + + "\n" + + "
abc
\n\n" + "\n" + "\n" + "\n"); @@ -292,7 +394,8 @@ "\n" + "\n" + "A\n" + - "abc \n" + + "\n" + + "
abc
\n\n" + "\n" + "\n" + "", @@ -305,7 +408,8 @@ "\n" + "\n" + "B\n" + - "def \n" + + "\n" + + "
def
\n\n" + "\n" + "\n" + "\n"); diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/jdk/javadoc/doclet/testModules/TestModules.java --- a/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java Mon Jan 15 15:18:27 2018 +0100 +++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModules.java Sat Jan 13 02:56:22 2018 +0100 @@ -26,7 +26,7 @@ * @bug 8154119 8154262 8156077 8157987 8154261 8154817 8135291 8155995 8162363 * 8168766 8168688 8162674 8160196 8175799 8174974 8176778 8177562 8175218 * 8175823 8166306 8178043 8181622 8183511 8169819 8074407 8183037 8191464 - 8164407 + 8164407 8192007 * @summary Test modules support in javadoc. * @author bpatel * @library ../lib @@ -764,7 +764,8 @@ + "", "\n" + "TestClassInModuleB\n" - + "With a test description for uses. \n" + + "\n" + + "
With a test description for uses.
\n\n" + "", "Opens \n" + "\n" @@ -931,7 +932,8 @@ + "testpkgmdlB\n"); checkOutput("moduleB-summary.html", true, "TestClassInModuleB\n" - + "With a test description for uses. "); + + "\n" + + "
With a test description for uses.
\n\n"); checkOutput("moduletags-summary.html", true, "
  • Description | Modules" + " | Packages | Services
  • ", diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/jdk/javadoc/tool/EncodingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/jdk/javadoc/tool/EncodingTest.java Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * 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 8188649 + * @summary ensure javadoc -encoding is not ignored + * @modules jdk.compiler/com.sun.tools.javac.api + * @modules jdk.compiler/com.sun.tools.javac.main + * @modules jdk.javadoc/jdk.javadoc.internal.api + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @library /tools/lib /tools/javadoc/lib + * @build toolbox.JavacTask toolbox.JavadocTask toolbox.TestRunner toolbox.ToolBox + * @run main EncodingTest + */ + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import toolbox.JavadocTask; +import toolbox.Task; +import toolbox.TestRunner; +import toolbox.ToolBox; + +public class EncodingTest extends TestRunner { + public static void main(String... args) throws Exception { + EncodingTest t = new EncodingTest(); + t.runTests(); + } + + private final ToolBox tb = new ToolBox(); + private final Path src = Paths.get("src"); + private final Path api = Paths.get("api"); + + EncodingTest() throws Exception { + super(System.err); + init(); + } + + void init() throws IOException { + Files.createDirectories(src); + Files.write(src.resolve("C.java"), + "/** \u03b1\u03b2\u03b3 */ public class C { }".getBytes(StandardCharsets.UTF_8)); + } + + @Test + public void testEncoding() { + Task.Result result = new JavadocTask(tb, Task.Mode.EXEC) + .outdir(api) + .options("-J-Dfile.encoding=ASCII", + "-encoding", "UTF-8", + "-docencoding", "UTF-8") + .files(src.resolve("C.java")) + .run(Task.Expect.SUCCESS) + .writeAll(); + } +} + diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/tools/doclint/LambdaTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/tools/doclint/LambdaTest.java Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * 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 8194069 + * @summary ignore declarations in lambda expressions + * @modules jdk.compiler/com.sun.tools.doclint + * @build DocLintTester + * @run main DocLintTester -Xmsgs:all SyntheticTest.java + */ + +package acme; + +import java.util.Arrays; +import java.util.Set; +import java.util.function.Function; + +/** + * The class has docs. + */ +public final class LambdaTest +{ + /** + * The field itself has docs. + */ + // Ensure no warning for lambda parameter, at 'string ->' + static final Function someFunction = string -> { + // Ensure no warning for 'localVariable' + int localVariable = 3; + return Integer.toString(localVariable); + }; +} + diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/tools/javac/8194932/Foo.jcod --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/tools/javac/8194932/Foo.jcod Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,115 @@ +class Foo { + 0xCAFEBABE; + 0; // minor version + 52; // version + [] { // Constant Pool + ; // first element is empty + Method #4 #14; // #1 + String #15; // #2 + class #16; // #3 + class #17; // #4 + Utf8 ""; // #5 + Utf8 "()V"; // #6 + Utf8 "Code"; // #7 + Utf8 "LineNumberTable"; // #8 + Utf8 "m"; // #9 + Utf8 "m2"; // #10 + Utf8 "()Ljava/lang/String;"; // #11 + Utf8 "SourceFile"; // #12 + Utf8 "Foo.java"; // #13 + NameAndType #5 #6; // #14 + Utf8 "Hello"; // #15 + Utf8 "Foo"; // #16 + Utf8 "java/lang/Object"; // #17 + } // Constant Pool + + 0x0020; // access + #3;// this_cpx + #4;// super_cpx + + [] { // Interfaces + } // Interfaces + + [] { // fields + } // fields + + [] { // methods + { // Member + 0x0000; // access + #5; // name_cpx + #6; // sig_cpx + [] { // Attributes + Attr(#7) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0x2AB70001B1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#8) { // LineNumberTable + [] { // LineNumberTable + 0 1; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0000; // access + #9; // name_cpx + #6; // sig_cpx + [] { // Attributes + Attr(#7) { // Code + 0; // max_stack + 1; // max_locals + Bytes[]{ + 0xB1; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#8) { // LineNumberTable + [] { // LineNumberTable + 0 2; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + ; + { // Member + 0x0000; // access + #9; // name_cpx + #11; // sig_cpx + [] { // Attributes + Attr(#7) { // Code + 1; // max_stack + 1; // max_locals + Bytes[]{ + 0x1202B0; + }; + [] { // Traps + } // end Traps + [] { // Attributes + Attr(#8) { // LineNumberTable + [] { // LineNumberTable + 0 3; + } + } // end LineNumberTable + } // Attributes + } // end Code + } // Attributes + } // Member + } // methods + + [] { // Attributes + Attr(#12) { // SourceFile + #13; + } // end SourceFile + } // Attributes +} // end class Foo diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/tools/javac/8194932/T8194932.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/tools/javac/8194932/T8194932.java Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,13 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8194932 + * @summary no ambuguity error is emitted if classfile contains two identical methods with different return types + * @build Foo + * @compile/fail/ref=T8194932.out -XDrawDiagnostics T8194932.java + */ + +class T8194932 { + void test(Foo foo) { + foo.m(); //should get an ambiguity here + } +} diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/tools/javac/8194932/T8194932.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/tools/javac/8194932/T8194932.out Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,2 @@ +T8194932.java:11:12: compiler.err.ref.ambiguous: m, kindname.method, m(), Foo, kindname.method, m(), Foo +1 error diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/tools/javac/T6356530/SerializableAbstractClassTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/tools/javac/T6356530/SerializableAbstractClassTest.java Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * 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 6356530 8191637 + * @summary -Xlint:serial does not flag abstract classes with persisent fields + * @compile/fail/ref=SerializableAbstractClassTest.out -XDrawDiagnostics -Werror -Xlint:serial SerializableAbstractClassTest.java + */ + +abstract class SerializableAbstractClassTest implements java.io.Serializable { + // no serialVersionUID; error + abstract void m2(); + + static abstract class AWithUID implements java.io.Serializable { + private static final long serialVersionUID = 0; + void m(){} + } + + interface I extends java.io.Serializable { + // no need for serialVersionUID + } + + interface IDefault extends java.io.Serializable { + // no need for serialVersionUID + default int m() { return 1; } + } + + interface IUID extends java.io.Serializable { + // no need for serialVersionUID, but not wrong + static final long serialVersionUID = 0; + } +} diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/tools/javac/T6356530/SerializableAbstractClassTest.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/tools/javac/T6356530/SerializableAbstractClassTest.out Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,4 @@ +SerializableAbstractClassTest.java:31:10: compiler.warn.missing.SVUID: SerializableAbstractClassTest +- compiler.err.warnings.and.werror +1 error +1 warning diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/tools/javac/T6356530/SerializableAbstractClassWithNonAbstractMethodsTest.java --- a/test/langtools/tools/javac/T6356530/SerializableAbstractClassWithNonAbstractMethodsTest.java Mon Jan 15 15:18:27 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @test - * @bug 6356530 - * @summary -Xlint:serial does not flag abstract classes with concrete methods/members - * @compile/fail/ref=SerializableAbstractClassWithNonAbstractMethodsTest.out -XDrawDiagnostics -Werror -Xlint:serial SerializableAbstractClassWithNonAbstractMethodsTest.java - */ - -abstract class SerializableAbstractClassWithNonAbstractMethodsTest implements java.io.Serializable { - void m1() {} - abstract void m2(); - - abstract class AWithUID implements java.io.Serializable { - private static final long serialVersionUID = 0; - void m(){} - } - - interface IDefault extends java.io.Serializable { - default int m() { return 1; } - } - - interface IDefaultAndUID extends java.io.Serializable { - static final long serialVersionUID = 0; - default int m() { return 1; } - } -} diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/tools/javac/T6356530/SerializableAbstractClassWithNonAbstractMethodsTest.out --- a/test/langtools/tools/javac/T6356530/SerializableAbstractClassWithNonAbstractMethodsTest.out Mon Jan 15 15:18:27 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -SerializableAbstractClassWithNonAbstractMethodsTest.java:40:5: compiler.warn.missing.SVUID: SerializableAbstractClassWithNonAbstractMethodsTest.IDefault -SerializableAbstractClassWithNonAbstractMethodsTest.java:31:10: compiler.warn.missing.SVUID: SerializableAbstractClassWithNonAbstractMethodsTest -- compiler.err.warnings.and.werror -1 error -2 warnings diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/tools/javac/jvm/VerboseOutTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/tools/javac/jvm/VerboseOutTest.java Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * 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 8194893 + * @summary javac -verbose prints wrong paths for output files + * @modules jdk.compiler + * @run main VerboseOutTest + */ + +import java.io.PrintWriter; +import java.io.StringWriter; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.spi.ToolProvider; + +public class VerboseOutTest { + public static void main(String... args) throws Exception { + new VerboseOutTest().run(); + } + + void run() throws Exception { + String className = getClass().getName(); + Path testSrc = Paths.get(System.getProperty("test.src")); + Path file = testSrc.resolve(className + ".java"); + ToolProvider javac = ToolProvider.findFirst("javac").orElseThrow(); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw, true); + int rc = javac.run(pw, pw, + "-d", ".", + "-verbose", + file.toString()); + String log = sw.toString(); + System.out.println(log); + if (rc != 0) { + throw new Exception("compilation failed: rc=" + rc); + } + String expected = "[wrote ./" + className + ".class]"; + if (!log.contains(expected)) { + throw new Exception("expected output not found: " + expected); + } + } +} + diff -r 4d1970962ee9 -r cc231bd80c8b test/langtools/tools/javadoc/EncodingTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/langtools/tools/javadoc/EncodingTest.java Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * 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 8188649 + * @summary javadoc -encoding doesn't work when using the old doclet API + * @modules jdk.compiler/com.sun.tools.javac.api + * @modules jdk.compiler/com.sun.tools.javac.main + * @modules jdk.javadoc/jdk.javadoc.internal.api + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @library /tools/lib /tools/javadoc/lib + * @build toolbox.JavacTask toolbox.JavadocTask toolbox.TestRunner toolbox.ToolBox ToyDoclet + * @run main EncodingTest + */ + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import toolbox.JavadocTask; +import toolbox.Task; +import toolbox.TestRunner; +import toolbox.ToolBox; + +public class EncodingTest extends TestRunner { + public static void main(String... args) throws Exception { + EncodingTest t = new EncodingTest(); + t.runTests(); + } + + private final ToolBox tb = new ToolBox(); + private final Path src = Paths.get("src"); + + EncodingTest() throws Exception { + super(System.err); + init(); + } + + void init() throws IOException { + Files.createDirectories(src); + Files.write(src.resolve("C.java"), + "/** \u03b1\u03b2\u03b3 */ public class C { }".getBytes(StandardCharsets.UTF_8)); + } + + @Test + public void testEncoding() { + Task.Result result = new JavadocTask(tb, Task.Mode.EXEC) + .options("-docletpath", System.getProperty("test.class.path"), + "-doclet", "ToyDoclet", + "-J-Dfile.encoding=ASCII", + "-encoding", "UTF-8") + .files(src.resolve("C.java")) + .run(Task.Expect.SUCCESS) + .writeAll(); + } +} + diff -r 4d1970962ee9 -r cc231bd80c8b test/nashorn/script/basic/JDK-8157251.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/nashorn/script/basic/JDK-8157251.js Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * 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-8157251: BeanLinker relinks array length operations for array types + * + * @test + * @run + */ + +var intArray = Java.type("int[]") +var doubleArray = Java.type("double[]") +var arrs = [new intArray(20), new doubleArray(0)] +for (var i in arrs) + print(arrs[i].length) diff -r 4d1970962ee9 -r cc231bd80c8b test/nashorn/script/basic/JDK-8157251.js.EXPECTED --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/nashorn/script/basic/JDK-8157251.js.EXPECTED Sat Jan 13 02:56:22 2018 +0100 @@ -0,0 +1,2 @@ +20 +0 \ No newline at end of file