changeset 49667:9552f0648b53

Merge
author prr
date Tue, 13 Mar 2018 09:57:44 -0700
parents b09417148c93 b43edd41622d
children 6e6c3a755b89 8d8f74e84ff6
files
diffstat 19 files changed, 223 insertions(+), 107 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Mar 13 12:00:55 2018 +0000
+++ b/.hgtags	Tue Mar 13 09:57:44 2018 -0700
@@ -474,3 +474,4 @@
 663f20fc51091bd7f95d18448850ba091207b7bd jdk-10+44
 4f96cf952e71cb8a127334494faf28880c26181b jdk-10+45
 1fd4d6068f54561cfc67d54fc9ca84af7212c4f8 jdk-11+3
+e59941f7247d451fa7df9eaef3fce0f492f8420c jdk-11+4
--- a/make/InterimImage.gmk	Tue Mar 13 12:00:55 2018 +0000
+++ b/make/InterimImage.gmk	Tue Mar 13 09:57:44 2018 -0700
@@ -48,6 +48,7 @@
 	$(RM) -r $(INTERIM_IMAGE_DIR)
 	$(JLINK_TOOL) \
 	    --output $(INTERIM_IMAGE_DIR) \
+	    --disable-plugin generate-jli-classes \
 	    --add-modules $(INTERIM_MODULES_LIST)
 	$(TOUCH) $@
 
--- a/make/autoconf/toolchain_windows.m4	Tue Mar 13 12:00:55 2018 +0000
+++ b/make/autoconf/toolchain_windows.m4	Tue Mar 13 09:57:44 2018 -0700
@@ -77,7 +77,7 @@
 VS_MSVCP_2017=msvcp140.dll
 VS_ENVVAR_2017="VS150COMNTOOLS"
 VS_VS_INSTALLDIR_2017="Microsoft Visual Studio/2017"
-VS_EDITIONS_2017="Community Professional Enterprise"
+VS_EDITIONS_2017="BuildTools Community Professional Enterprise"
 VS_SDK_INSTALLDIR_2017=
 VS_VS_PLATFORM_NAME_2017="v141"
 VS_SDK_PLATFORM_NAME_2017=
--- a/src/demo/share/java2d/J2DBench/src/j2dbench/ResultSet.java	Tue Mar 13 12:00:55 2018 +0000
+++ b/src/demo/share/java2d/J2DBench/src/j2dbench/ResultSet.java	Tue Mar 13 09:57:44 2018 -0700
@@ -77,7 +77,6 @@
         "line.separator",
         "file.separator",
         "file.encoding",
-        "file.encoding.pkg",
         "java.class.path",
         "java.library.path",
         "java.io.tmpdir",
--- a/src/java.base/share/classes/java/lang/Character.java	Tue Mar 13 12:00:55 2018 +0000
+++ b/src/java.base/share/classes/java/lang/Character.java	Tue Mar 13 09:57:44 2018 -0700
@@ -3590,7 +3590,8 @@
          */
         public static UnicodeBlock of(int codePoint) {
             if (!isValidCodePoint(codePoint)) {
-                throw new IllegalArgumentException();
+                throw new IllegalArgumentException(
+                    String.format("Not a valid Unicode code point: 0x%X", codePoint));
             }
 
             int top, bottom, current;
@@ -3649,7 +3650,8 @@
         public static final UnicodeBlock forName(String blockName) {
             UnicodeBlock block = map.get(blockName.toUpperCase(Locale.US));
             if (block == null) {
-                throw new IllegalArgumentException();
+                throw new IllegalArgumentException("Not a valid block name: "
+                            + blockName);
             }
             return block;
         }
@@ -7394,7 +7396,8 @@
          */
         public static UnicodeScript of(int codePoint) {
             if (!isValidCodePoint(codePoint))
-                throw new IllegalArgumentException();
+                throw new IllegalArgumentException(
+                    String.format("Not a valid Unicode code point: 0x%X", codePoint));
             int type = getType(codePoint);
             // leave SURROGATE and PRIVATE_USE for table lookup
             if (type == UNASSIGNED)
@@ -8088,7 +8091,8 @@
             toSurrogates(codePoint, dst, dstIndex);
             return 2;
         } else {
-            throw new IllegalArgumentException();
+            throw new IllegalArgumentException(
+                String.format("Not a valid Unicode code point: 0x%X", codePoint));
         }
     }
 
@@ -8116,7 +8120,8 @@
             toSurrogates(codePoint, result, 0);
             return result;
         } else {
-            throw new IllegalArgumentException();
+            throw new IllegalArgumentException(
+                String.format("Not a valid Unicode code point: 0x%X", codePoint));
         }
     }
 
@@ -10178,7 +10183,8 @@
      */
     public static String getName(int codePoint) {
         if (!isValidCodePoint(codePoint)) {
-            throw new IllegalArgumentException();
+            throw new IllegalArgumentException(
+                String.format("Not a valid Unicode code point: 0x%X", codePoint));
         }
         String name = CharacterName.getInstance().getName(codePoint);
         if (name != null)
--- a/src/java.base/share/classes/java/lang/String.java	Tue Mar 13 12:00:55 2018 +0000
+++ b/src/java.base/share/classes/java/lang/String.java	Tue Mar 13 09:57:44 2018 -0700
@@ -3178,6 +3178,7 @@
             return new String(StringUTF16.toBytesSupplementary(codePoint), UTF16);
         }
 
-        throw new IllegalArgumentException("Not a valid Unicode code point");
+        throw new IllegalArgumentException(
+            format("Not a valid Unicode code point: 0x%X", codePoint));
     }
 }
--- a/src/java.base/share/classes/java/lang/ref/Reference.java	Tue Mar 13 12:00:55 2018 +0000
+++ b/src/java.base/share/classes/java/lang/ref/Reference.java	Tue Mar 13 09:57:44 2018 -0700
@@ -25,7 +25,7 @@
 
 package java.lang.ref;
 
-import jdk.internal.vm.annotation.DontInline;
+import jdk.internal.vm.annotation.ForceInline;
 import jdk.internal.HotSpotIntrinsicCandidate;
 import jdk.internal.misc.JavaLangRefAccess;
 import jdk.internal.misc.SharedSecrets;
@@ -420,10 +420,12 @@
      * @param ref the reference. If {@code null}, this method has no effect.
      * @since 9
      */
-    @DontInline
+    @ForceInline
     public static void reachabilityFence(Object ref) {
-        // Does nothing, because this method is annotated with @DontInline
-        // HotSpot needs to retain the ref and not GC it before a call to this
-        // method
+        // Does nothing. This method is annotated with @ForceInline to eliminate
+        // most of the overhead that using @DontInline would cause with the
+        // HotSpot JVM, when this fence is used in a wide variety of situations.
+        // HotSpot JVM retains the ref and does not GC it before a call to
+        // this method, because the JIT-compilers do not have GC-only safepoints.
     }
 }
--- a/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template	Tue Mar 13 12:00:55 2018 +0000
+++ b/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template	Tue Mar 13 09:57:44 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, 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
@@ -32,24 +32,40 @@
 #if[rw]
 
     private $type$ get$Type$(long a) {
-        $memtype$ x = UNSAFE.get$Memtype$Unaligned(null, a, bigEndian);
-        return $fromBits$(x);
+        try {
+            $memtype$ x = UNSAFE.get$Memtype$Unaligned(null, a, bigEndian);
+            return $fromBits$(x);
+        } finally {
+            Reference.reachabilityFence(this);
+        }
     }
 
     public $type$ get$Type$() {
-        return get$Type$(ix(nextGetIndex($BYTES_PER_VALUE$)));
+        try {
+            return get$Type$(ix(nextGetIndex($BYTES_PER_VALUE$)));
+        } finally {
+            Reference.reachabilityFence(this);
+        }
     }
 
     public $type$ get$Type$(int i) {
-        return get$Type$(ix(checkIndex(i, $BYTES_PER_VALUE$)));
+        try {
+            return get$Type$(ix(checkIndex(i, $BYTES_PER_VALUE$)));
+        } finally {
+            Reference.reachabilityFence(this);
+        }
     }
 
 #end[rw]
 
     private ByteBuffer put$Type$(long a, $type$ x) {
 #if[rw]
-        $memtype$ y = $toBits$(x);
-        UNSAFE.put$Memtype$Unaligned(null, a, y, bigEndian);
+        try {
+            $memtype$ y = $toBits$(x);
+            UNSAFE.put$Memtype$Unaligned(null, a, y, bigEndian);
+        } finally {
+            Reference.reachabilityFence(this);
+        }
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
--- a/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template	Tue Mar 13 12:00:55 2018 +0000
+++ b/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template	Tue Mar 13 09:57:44 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, 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
@@ -28,6 +28,7 @@
 package java.nio;
 
 import java.io.FileDescriptor;
+import java.lang.ref.Reference;
 import jdk.internal.misc.VM;
 import jdk.internal.ref.Cleaner;
 import sun.nio.ch.DirectBuffer;
@@ -257,16 +258,28 @@
     }
 
     public $type$ get() {
-        return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(nextGetIndex()))));
+        try {
+            return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(nextGetIndex()))));
+        } finally {
+            Reference.reachabilityFence(this);
+        }
     }
 
     public $type$ get(int i) {
-        return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(checkIndex(i)))));
+        try {
+            return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(checkIndex(i)))));
+        } finally {
+            Reference.reachabilityFence(this);
+        }
     }
 
 #if[streamableType]
     $type$ getUnchecked(int i) {
-        return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(i))));
+        try {
+            return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(i))));
+        } finally {
+            Reference.reachabilityFence(this);
+        }
     }
 #end[streamableType]
 
@@ -282,21 +295,25 @@
                 throw new BufferUnderflowException();
 
             long dstOffset = ARRAY_BASE_OFFSET + ((long)offset << $LG_BYTES_PER_VALUE$);
+            try {
 #if[!byte]
-            if (order() != ByteOrder.nativeOrder())
-                UNSAFE.copySwapMemory(null,
+                if (order() != ByteOrder.nativeOrder())
+                    UNSAFE.copySwapMemory(null,
+                                          ix(pos),
+                                          dst,
+                                          dstOffset,
+                                          (long)length << $LG_BYTES_PER_VALUE$,
+                                          (long)1 << $LG_BYTES_PER_VALUE$);
+                else
+#end[!byte]
+                    UNSAFE.copyMemory(null,
                                       ix(pos),
                                       dst,
                                       dstOffset,
-                                      (long)length << $LG_BYTES_PER_VALUE$,
-                                      (long)1 << $LG_BYTES_PER_VALUE$);
-            else
-#end[!byte]
-                UNSAFE.copyMemory(null,
-                                  ix(pos),
-                                  dst,
-                                  dstOffset,
-                                  (long)length << $LG_BYTES_PER_VALUE$);
+                                      (long)length << $LG_BYTES_PER_VALUE$);
+            } finally {
+                Reference.reachabilityFence(this);
+            }
             position(pos + length);
         } else {
             super.get(dst, offset, length);
@@ -311,7 +328,11 @@
 
     public $Type$Buffer put($type$ x) {
 #if[rw]
-        UNSAFE.put$Swaptype$(ix(nextPutIndex()), $swap$($toBits$(x)));
+        try {
+            UNSAFE.put$Swaptype$(ix(nextPutIndex()), $swap$($toBits$(x)));
+        } finally {
+            Reference.reachabilityFence(this);
+        }
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -320,7 +341,11 @@
 
     public $Type$Buffer put(int i, $type$ x) {
 #if[rw]
-        UNSAFE.put$Swaptype$(ix(checkIndex(i)), $swap$($toBits$(x)));
+        try {
+            UNSAFE.put$Swaptype$(ix(checkIndex(i)), $swap$($toBits$(x)));
+        } finally {
+            Reference.reachabilityFence(this);
+        }
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -346,7 +371,12 @@
 
             if (srem > rem)
                 throw new BufferOverflowException();
-            UNSAFE.copyMemory(sb.ix(spos), ix(pos), (long)srem << $LG_BYTES_PER_VALUE$);
+            try {
+                UNSAFE.copyMemory(sb.ix(spos), ix(pos), (long)srem << $LG_BYTES_PER_VALUE$);
+            } finally {
+                Reference.reachabilityFence(sb);
+                Reference.reachabilityFence(this);
+            }
             sb.position(spos + srem);
             position(pos + srem);
         } else if (src.hb != null) {
@@ -380,21 +410,25 @@
                 throw new BufferOverflowException();
 
             long srcOffset = ARRAY_BASE_OFFSET + ((long)offset << $LG_BYTES_PER_VALUE$);
+            try {
 #if[!byte]
-            if (order() != ByteOrder.nativeOrder())
-                UNSAFE.copySwapMemory(src,
+                if (order() != ByteOrder.nativeOrder())
+                    UNSAFE.copySwapMemory(src,
+                                          srcOffset,
+                                          null,
+                                          ix(pos),
+                                          (long)length << $LG_BYTES_PER_VALUE$,
+                                          (long)1 << $LG_BYTES_PER_VALUE$);
+                else
+#end[!byte]
+                    UNSAFE.copyMemory(src,
                                       srcOffset,
                                       null,
                                       ix(pos),
-                                      (long)length << $LG_BYTES_PER_VALUE$,
-                                      (long)1 << $LG_BYTES_PER_VALUE$);
-            else
-#end[!byte]
-                UNSAFE.copyMemory(src,
-                                  srcOffset,
-                                  null,
-                                  ix(pos),
-                                  (long)length << $LG_BYTES_PER_VALUE$);
+                                      (long)length << $LG_BYTES_PER_VALUE$);
+            } finally {
+                Reference.reachabilityFence(this);
+            }
             position(pos + length);
         } else {
             super.put(src, offset, length);
@@ -411,8 +445,11 @@
         int lim = limit();
         assert (pos <= lim);
         int rem = (pos <= lim ? lim - pos : 0);
-
-        UNSAFE.copyMemory(ix(pos), ix(0), (long)rem << $LG_BYTES_PER_VALUE$);
+        try {
+            UNSAFE.copyMemory(ix(pos), ix(0), (long)rem << $LG_BYTES_PER_VALUE$);
+        } finally {
+            Reference.reachabilityFence(this);
+        }
         position(rem);
         limit(capacity());
         discardMark();
@@ -497,19 +534,6 @@
 
 
 #if[byte]
-
-    byte _get(int i) {                          // package-private
-        return UNSAFE.getByte(address + i);
-    }
-
-    void _put(int i, byte b) {                  // package-private
-#if[rw]
-        UNSAFE.putByte(address + i, b);
-#else[rw]
-        throw new ReadOnlyBufferException();
-#end[rw]
-    }
-
     // #BIN
     //
     // Binary-data access methods  for short, char, int, long, float,
--- a/src/java.base/share/classes/java/nio/MappedByteBuffer.java	Tue Mar 13 12:00:55 2018 +0000
+++ b/src/java.base/share/classes/java/nio/MappedByteBuffer.java	Tue Mar 13 09:57:44 2018 -0700
@@ -26,6 +26,7 @@
 package java.nio;
 
 import java.io.FileDescriptor;
+import java.lang.ref.Reference;
 import jdk.internal.misc.Unsafe;
 
 
@@ -166,9 +167,15 @@
         int count = Bits.pageCount(length);
         long a = mappingAddress(offset);
         byte x = 0;
-        for (int i=0; i<count; i++) {
-            x ^= unsafe.getByte(a);
-            a += ps;
+        try {
+            for (int i=0; i<count; i++) {
+                // TODO consider changing to getByteOpaque thus avoiding
+                // dead code elimination and the need to calculate a checksum
+                x ^= unsafe.getByte(a);
+                a += ps;
+            }
+        } finally {
+            Reference.reachabilityFence(this);
         }
         if (unused != 0)
             unused = x;
--- a/src/java.base/share/classes/java/nio/X-Buffer.java.template	Tue Mar 13 12:00:55 2018 +0000
+++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template	Tue Mar 13 09:57:44 2018 -0700
@@ -1749,11 +1749,6 @@
 
     abstract ByteBuffer slice(int pos, int lim);
 
-    // Unchecked accessors, for use by ByteBufferAs-X-Buffer classes
-    //
-    abstract byte _get(int i);                          // package-private
-    abstract void _put(int i, byte b);                  // package-private
-
     // #BIN
     //
     // Binary-data access methods  for short, char, int, long, float,
--- a/src/java.base/share/native/libjava/System.c	Tue Mar 13 12:00:55 2018 +0000
+++ b/src/java.base/share/native/libjava/System.c	Tue Mar 13 09:57:44 2018 -0700
@@ -247,7 +247,6 @@
      *  user.language
      *  user.script, user.country, user.variant (if user's environment specifies them)
      *  file.encoding
-     *  file.encoding.pkg
      */
     PUTPROP(props, "user.language", sprops->language);
     if (sprops->script) {
@@ -266,7 +265,6 @@
     if (sprops->sun_stderr_encoding != NULL) {
         PUTPROP(props, "sun.stderr.encoding", sprops->sun_stderr_encoding);
     }
-    PUTPROP(props, "file.encoding.pkg", "sun.io");
 
     /* unicode_encoding specifies the default endianness */
     PUTPROP(props, "sun.io.unicode.encoding", sprops->unicode_encoding);
--- a/src/java.base/windows/native/libjava/java_props_md.c	Tue Mar 13 12:00:55 2018 +0000
+++ b/src/java.base/windows/native/libjava/java_props_md.c	Tue Mar 13 09:57:44 2018 -0700
@@ -629,7 +629,6 @@
      *  user.language
      *  user.script, user.country, user.variant (if user's environment specifies them)
      *  file.encoding
-     *  file.encoding.pkg
      */
     {
         /*
--- a/test/jdk/java/lang/ref/ReachabilityFenceTest.java	Tue Mar 13 12:00:55 2018 +0000
+++ b/test/jdk/java/lang/ref/ReachabilityFenceTest.java	Tue Mar 13 09:57:44 2018 -0700
@@ -122,9 +122,11 @@
             }
         }
 
-        Reference.reachabilityFence(o);
-
-        return finalized.get();
+        try {
+            return finalized.get();
+        } finally {
+            Reference.reachabilityFence(o);
+        }
     }
 
     private static class MyFinalizeable {
--- a/test/jdk/tools/jar/LeadingGarbage.java	Tue Mar 13 12:00:55 2018 +0000
+++ b/test/jdk/tools/jar/LeadingGarbage.java	Tue Mar 13 09:57:44 2018 -0700
@@ -30,23 +30,28 @@
 import java.io.OutputStream;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Stream;
 
-import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.Utils;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
 
 import org.testng.annotations.Test;
 
 /**
  * @test
- * @bug 8058520
+ * @bug 8058520 8196748
  * @summary jar tf and jar xf should work on zip files with leading garbage
- * @library /lib/testlibrary
+ * @library /test/lib
  * @run testng LeadingGarbage
  */
 @Test
 public class LeadingGarbage {
-    final String jar =
-        Paths.get(System.getProperty("java.home"), "bin", "jar").toString();
+
     final File[] files = { new File("a"), new File("b") };
     final File normalZip = new File("normal.zip");
     final File leadingGarbageZip = new File("leadingGarbage.zip");
@@ -74,12 +79,10 @@
 
     void createNormalZip() throws Throwable {
         createFiles();
-        String[] cmd = { jar, "c0Mf", "normal.zip", "a", "b" };
-        ProcessBuilder pb = new ProcessBuilder(cmd);
-        OutputAnalyzer a = ProcessTools.executeProcess(pb);
+        OutputAnalyzer a = jar("c0Mf", "normal.zip", "a", "b");
         a.shouldHaveExitValue(0);
         a.stdoutShouldMatch("\\A\\Z");
-        a.stderrShouldMatch("\\A\\Z");
+        a.stderrShouldMatchIgnoreVMWarnings("\\A\\Z");
         deleteFiles();
     }
 
@@ -104,15 +107,13 @@
     }
 
     void assertCanList(String zipFileName) throws Throwable {
-        String[] cmd = { jar, "tf", zipFileName };
-        ProcessBuilder pb = new ProcessBuilder(cmd);
-        OutputAnalyzer a = ProcessTools.executeProcess(pb);
+        OutputAnalyzer a = jar("tf", zipFileName);
         a.shouldHaveExitValue(0);
         StringBuilder expected = new StringBuilder();
         for (File file : files)
             expected.append(file.getName()).append(System.lineSeparator());
         a.stdoutShouldMatch(expected.toString());
-        a.stderrShouldMatch("\\A\\Z");
+        a.stderrShouldMatchIgnoreVMWarnings("\\A\\Z");
     }
 
     public void test_canExtract() throws Throwable {
@@ -126,13 +127,20 @@
     }
 
     void assertCanExtract(String zipFileName) throws Throwable {
-        String[] cmd = { jar, "xf", zipFileName };
-        ProcessBuilder pb = new ProcessBuilder(cmd);
-        OutputAnalyzer a = ProcessTools.executeProcess(pb);
+        OutputAnalyzer a = jar("xf", zipFileName);
         a.shouldHaveExitValue(0);
         a.stdoutShouldMatch("\\A\\Z");
-        a.stderrShouldMatch("\\A\\Z");
+        a.stderrShouldMatchIgnoreVMWarnings("\\A\\Z");
         assertFilesExist();
     }
 
+    OutputAnalyzer jar(String... args) throws Throwable {
+        String jar = JDKToolFinder.getJDKTool("jar");
+        List<String> cmds = new ArrayList<>();
+        cmds.add(jar);
+        cmds.addAll(Utils.getForwardVmOptions());
+        Stream.of(args).forEach(x -> cmds.add(x));
+        ProcessBuilder p = new ProcessBuilder(cmds);
+        return ProcessTools.executeCommand(p);
+    }
 }
--- a/test/jdk/tools/jar/modularJar/Basic.java	Tue Mar 13 12:00:55 2018 +0000
+++ b/test/jdk/tools/jar/modularJar/Basic.java	Tue Mar 13 09:57:44 2018 -0700
@@ -46,7 +46,7 @@
 
 /*
  * @test
- * @bug 8167328 8171830 8165640 8174248 8176772
+ * @bug 8167328 8171830 8165640 8174248 8176772 8196748
  * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
  *          jdk.jartool
@@ -155,6 +155,8 @@
                     } else if (line.startsWith("contains:")) {
                         line = line.substring("contains:".length());
                         conceals = stringToSet(line);
+                    } else if (line.contains("VM warning:")) {
+                        continue;  // ignore server vm warning see#8196748
                     } else {
                         throw new AssertionError("Unknown value " + line);
                     }
--- a/test/jdk/tools/jar/multiRelease/ApiValidatorTest.java	Tue Mar 13 12:00:55 2018 +0000
+++ b/test/jdk/tools/jar/multiRelease/ApiValidatorTest.java	Tue Mar 13 09:57:44 2018 -0700
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ # @bug 8196748
  * @summary Tests for API validator.
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
@@ -86,7 +87,7 @@
                 ".");
         if (isAcceptable) {
             result.shouldHaveExitValue(SUCCESS)
-                    .shouldBeEmpty();
+                  .shouldBeEmptyIgnoreVMWarnings();
         } else {
             result.shouldNotHaveExitValue(SUCCESS)
                     .shouldContain("contains a class with different api from earlier version");
@@ -417,4 +418,3 @@
         javac(classes, sourceFiles);
     }
 }
-
--- a/test/jdk/tools/jar/multiRelease/Basic.java	Tue Mar 13 12:00:55 2018 +0000
+++ b/test/jdk/tools/jar/multiRelease/Basic.java	Tue Mar 13 09:57:44 2018 -0700
@@ -23,7 +23,7 @@
 
 /*
  * @test
- # @bug 8186087
+ # @bug 8186087 8196748
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          jdk.compiler
@@ -127,7 +127,7 @@
             jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
                     "--release", release, "-C", classes.resolve("v10").toString(), ".")
                     .shouldHaveExitValue(SUCCESS)
-                    .shouldBeEmpty();
+                    .shouldBeEmptyIgnoreVMWarnings();
         }
         // invalid
         for (String release : List.of("9.0", "8", "v9",
@@ -335,7 +335,7 @@
         jar("cf", jarfile, "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".")
                 .shouldHaveExitValue(SUCCESS)
-                .shouldBeEmpty();
+                .shouldBeEmptyIgnoreVMWarnings();
         jar("uf", jarfile,
                 "--release", "10", "-C", classes.resolve("v9").toString(), ".")
                 .shouldHaveExitValue(SUCCESS)
@@ -417,7 +417,7 @@
                 "-C", classes.resolve("base").toString(), ".",
                 "--release", "9", "-C", classes.resolve("v9").toString(), ".")
                 .shouldNotHaveExitValue(SUCCESS)
-                .asLines();
+                .asLinesWithoutVMWarnings();
 
         /* "META-INF/versions/9/version/Nested$nested.class" is really NOT isolated
         assertTrue(output.size() == 4);
@@ -516,7 +516,7 @@
                 "-C", classes.resolve("base").toString(), ".",
                 "--release", "10", "-C", classes.resolve("v10").toString(), ".")
                 .shouldHaveExitValue(SUCCESS)
-                .shouldBeEmpty();
+                .shouldBeEmptyIgnoreVMWarnings();
 
         try (JarFile jf = new JarFile(new File(jarfile), true,
                 ZipFile.OPEN_READ, JarFile.runtimeVersion())) {
--- a/test/lib/jdk/test/lib/process/OutputAnalyzer.java	Tue Mar 13 12:00:55 2018 +0000
+++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.java	Tue Mar 13 09:57:44 2018 -0700
@@ -27,6 +27,7 @@
 import java.io.PrintStream;
 import java.util.Arrays;
 import java.util.List;
+import java.util.stream.Collectors;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -184,9 +185,9 @@
   }
 
   /**
-   * Verify that the stdout and stderr contents of output buffer does not contain the string
+   * Verify that the stdout and stderr contents of output buffer are empty
    *
-   * @throws RuntimeException If the string was found
+   * @throws RuntimeException If the stdout and stderr are not empty
    */
   public OutputAnalyzer shouldBeEmpty() {
     if (!stdout.isEmpty()) {
@@ -271,6 +272,7 @@
    * @throws RuntimeException If the pattern was not found
    */
   public OutputAnalyzer stderrShouldMatch(String pattern) {
+
       Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
       if (!matcher.find()) {
           reportDiagnosticSummary();
@@ -485,4 +487,57 @@
   private List<String> asLines(String buffer) {
     return Arrays.asList(buffer.split("(\\r\\n|\\n|\\r)"));
   }
+
+
+  private static final String jvmwarningmsg = ".* VM warning:.*";
+
+  /**
+   * Verifies that the stdout and stderr contents of output buffer are empty, after
+   * filtering out the HotSpot warning messages.
+   *
+   * @throws RuntimeException If the stdout and stderr are not empty
+   */
+  public OutputAnalyzer shouldBeEmptyIgnoreVMWarnings() {
+    if (!stdout.isEmpty()) {
+        reportDiagnosticSummary();
+        throw new RuntimeException("stdout was not empty");
+    }
+    if (!stderr.replaceAll(jvmwarningmsg + "\\R", "").isEmpty()) {
+        reportDiagnosticSummary();
+        throw new RuntimeException("stderr was not empty");
+    }
+    return this;
+  }
+
+  /**
+   * Verify that the stderr contents of output buffer matches the pattern,
+   * after filtering out the Hotespot warning messages
+   *
+   * @param pattern
+   * @throws RuntimeException If the pattern was not found
+   */
+  public OutputAnalyzer stderrShouldMatchIgnoreVMWarnings(String pattern) {
+      String stderr = this.stderr.replaceAll(jvmwarningmsg + "\\R", "");
+      Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(stderr);
+      if (!matcher.find()) {
+          reportDiagnosticSummary();
+          throw new RuntimeException("'" + pattern
+                + "' missing from stderr \n");
+      }
+      return this;
+  }
+
+  /**
+   * Returns the contents of the output buffer (stdout and stderr), without those
+   * JVM warning msgs, as list of strings. Output is split by newlines.
+   *
+   * @return Contents of the output buffer as list of strings
+   */
+  public List<String> asLinesWithoutVMWarnings() {
+      return Arrays.asList(getOutput().split("\\R"))
+              .stream()
+              .filter(Pattern.compile(jvmwarningmsg).asPredicate().negate())
+              .collect(Collectors.toList());
+  }
+
 }