Merge
authorduke
Wed, 05 Jul 2017 23:25:53 +0200
changeset 45075 d82c02cceb22
parent 45074 38f7f9fa0ac1 (current diff)
parent 45072 52bc4eace1aa (diff)
child 45078 8344afa5ea9e
Merge
jdk/src/java.base/share/classes/sun/security/ssl/EllipticCurvesExtension.java
jdk/test/java/util/stream/bootlib/java.base/java/util/SpliteratorOfIntDataBuilder.java
jdk/test/java/util/stream/bootlib/java.base/java/util/SpliteratorTestHelper.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/CollectorOps.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DefaultMethodStreams.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DoubleStreamTestDataProvider.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DoubleStreamTestScenario.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/FlagDeclaringOp.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntStreamTestDataProvider.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntStreamTestScenario.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntermediateTestOp.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LambdaTestHelpers.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LambdaTestMode.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LoggingTestCase.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LongStreamTestDataProvider.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LongStreamTestScenario.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/OpTestCase.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StatefulTestOp.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StatelessTestOp.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamOpFlagTestHelper.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamTestDataProvider.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamTestScenario.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/TestData.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/TestFlagExpectedOp.java
jdk/test/java/util/stream/bootlib/java.base/java/util/stream/ThrowableHelper.java
jdk/test/java/util/stream/test/org/openjdk/tests/java/util/NullArgsTestCase.java
jdk/test/sample/TEST.properties
jdk/test/sample/chatserver/ChatTest.java
jdk/test/sample/mergesort/MergeSortTest.java
jdk/test/tools/launcher/modules/listmods/src/java.transaction/javax/transaction/atomic/Atomic.java
--- a/.hgtags-top-repo	Thu May 11 20:23:41 2017 +0000
+++ b/.hgtags-top-repo	Wed Jul 05 23:25:53 2017 +0200
@@ -417,4 +417,6 @@
 06373236a30801f72e2a31ee5c691c2a1e500f57 jdk-10+3
 8ec175c61fc3f58328a3324f07d7ded00e060be3 jdk-10+4
 111e2e7d00f45c983cdbc9c59ae40552152fcc23 jdk-10+5
-03fe61bb7670644cf6e46b5cfafb6b27c0e0157e jdk-10+6
\ No newline at end of file
+03fe61bb7670644cf6e46b5cfafb6b27c0e0157e jdk-10+6
+b25838a28195f4b6dab34668411eedd2d366a16c jdk-9+169
+
--- a/common/autoconf/boot-jdk.m4	Thu May 11 20:23:41 2017 +0000
+++ b/common/autoconf/boot-jdk.m4	Wed Jul 05 23:25:53 2017 +0200
@@ -318,7 +318,7 @@
   AC_SUBST(JAVAC_FLAGS)
 
   # Check if the boot jdk is 32 or 64 bit
-  if "$JAVA" -d64 -version > /dev/null 2>&1; then
+  if "$JAVA" -version 2>&1 | $GREP -q "64-Bit"; then
     BOOT_JDK_BITS="64"
   else
     BOOT_JDK_BITS="32"
--- a/common/autoconf/build-aux/install.sh	Thu May 11 20:23:41 2017 +0000
+++ b/common/autoconf/build-aux/install.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,28 @@
-#!/bin/sh
-echo >&2 "No suitable 'install' command found.'"
-echo >&2 "If automake is installed, running 'automake -fa'"
-echo >&2 "(and ignoring the errors) might produce one."
-exit 1
+#!/bin/bash
+#
+# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# This file is empty on purpose. It's a placeholder which is required by
+# autoconf, but it serves no purpose for us.
--- a/common/autoconf/build-performance.m4	Thu May 11 20:23:41 2017 +0000
+++ b/common/autoconf/build-performance.m4	Wed Jul 05 23:25:53 2017 +0200
@@ -417,10 +417,8 @@
   AC_SUBST(SJAVAC_SERVER_JAVA)
 
   if test "$MEMORY_SIZE" -gt "3000"; then
-    ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA_FLAGS,[$SJAVAC_SERVER_JAVA])
-    if test "$JVM_ARG_OK" = true; then
+    if "$JAVA" -version 2>&1 | $GREP -q "64-Bit"; then
       JVM_64BIT=true
-      JVM_ARG_OK=false
     fi
   fi
 
--- a/common/autoconf/generated-configure.sh	Thu May 11 20:23:41 2017 +0000
+++ b/common/autoconf/generated-configure.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -996,8 +996,9 @@
 OPENJDK_TARGET_CPU_ISADIR
 OPENJDK_TARGET_CPU_LEGACY_LIB
 OPENJDK_TARGET_CPU_LEGACY
-OPENJDK_MODULE_TARGET_OS_ARCH
-OPENJDK_MODULE_TARGET_OS_NAME
+RELEASE_FILE_OS_ARCH
+RELEASE_FILE_OS_NAME
+OPENJDK_MODULE_TARGET_PLATFORM
 COMPILE_TYPE
 OPENJDK_TARGET_CPU_ENDIAN
 OPENJDK_TARGET_CPU_BITS
@@ -4900,6 +4901,8 @@
 
 
 
+
+
 #%%% Build and target systems %%%
 
 
@@ -5183,7 +5186,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1492975963
+DATE_WHEN_GENERATED=1494615666
 
 ###############################################################################
 #
@@ -16043,6 +16046,27 @@
     OPENJDK_MODULE_TARGET_OS_ARCH="$OPENJDK_TARGET_CPU"
   fi
 
+  OPENJDK_MODULE_TARGET_PLATFORM="${OPENJDK_MODULE_TARGET_OS_NAME}-${OPENJDK_MODULE_TARGET_OS_ARCH}"
+
+
+
+  if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
+    RELEASE_FILE_OS_NAME=SunOS
+  fi
+  if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
+    RELEASE_FILE_OS_NAME=Linux
+  fi
+  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+    RELEASE_FILE_OS_NAME=Windows
+  fi
+  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    RELEASE_FILE_OS_NAME="Darwin"
+  fi
+  if test "x$OPENJDK_TARGET_OS" = "xaix"; then
+    RELEASE_FILE_OS_NAME="AIX"
+  fi
+  RELEASE_FILE_OS_ARCH=${OPENJDK_TARGET_CPU}
+
 
 
 
@@ -31392,7 +31416,7 @@
 
 
   # Check if the boot jdk is 32 or 64 bit
-  if "$JAVA" -d64 -version > /dev/null 2>&1; then
+  if "$JAVA" -version 2>&1 | $GREP -q "64-Bit"; then
     BOOT_JDK_BITS="64"
   else
     BOOT_JDK_BITS="32"
@@ -65910,24 +65934,8 @@
 
 
   if test "$MEMORY_SIZE" -gt "3000"; then
-
-  $ECHO "Check if jvm arg is ok: -d64" >&5
-  $ECHO "Command: $SJAVAC_SERVER_JAVA -d64 -version" >&5
-  OUTPUT=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1`
-  FOUND_WARN=`$ECHO "$OUTPUT" | $GREP -i warn`
-  FOUND_VERSION=`$ECHO $OUTPUT | $GREP " version \""`
-  if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-    SJAVAC_SERVER_JAVA_FLAGS="$SJAVAC_SERVER_JAVA_FLAGS -d64"
-    JVM_ARG_OK=true
-  else
-    $ECHO "Arg failed:" >&5
-    $ECHO "$OUTPUT" >&5
-    JVM_ARG_OK=false
-  fi
-
-    if test "$JVM_ARG_OK" = true; then
+    if "$JAVA" -version 2>&1 | $GREP -q "64-Bit"; then
       JVM_64BIT=true
-      JVM_ARG_OK=false
     fi
   fi
 
--- a/common/autoconf/platform.m4	Thu May 11 20:23:41 2017 +0000
+++ b/common/autoconf/platform.m4	Wed Jul 05 23:25:53 2017 +0200
@@ -433,6 +433,29 @@
 
 ])
 
+AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
+[
+  if test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
+    RELEASE_FILE_OS_NAME=SunOS
+  fi
+  if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
+    RELEASE_FILE_OS_NAME=Linux
+  fi
+  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+    RELEASE_FILE_OS_NAME=Windows
+  fi
+  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    RELEASE_FILE_OS_NAME="Darwin"
+  fi
+  if test "x$OPENJDK_TARGET_OS" = "xaix"; then
+    RELEASE_FILE_OS_NAME="AIX"
+  fi
+  RELEASE_FILE_OS_ARCH=${OPENJDK_TARGET_CPU}
+
+  AC_SUBST(RELEASE_FILE_OS_NAME)
+  AC_SUBST(RELEASE_FILE_OS_ARCH)
+])
+
 AC_DEFUN([PLATFORM_SET_MODULE_TARGET_OS_VALUES],
 [
   if test "x$OPENJDK_TARGET_OS" = xmacosx; then
@@ -447,8 +470,8 @@
     OPENJDK_MODULE_TARGET_OS_ARCH="$OPENJDK_TARGET_CPU"
   fi
 
-  AC_SUBST(OPENJDK_MODULE_TARGET_OS_NAME)
-  AC_SUBST(OPENJDK_MODULE_TARGET_OS_ARCH)
+  OPENJDK_MODULE_TARGET_PLATFORM="${OPENJDK_MODULE_TARGET_OS_NAME}-${OPENJDK_MODULE_TARGET_OS_ARCH}"
+  AC_SUBST(OPENJDK_MODULE_TARGET_PLATFORM)
 ])
 
 #%%% Build and target systems %%%
@@ -466,6 +489,7 @@
   PLATFORM_EXTRACT_TARGET_AND_BUILD
   PLATFORM_SETUP_TARGET_CPU_BITS
   PLATFORM_SET_MODULE_TARGET_OS_VALUES
+  PLATFORM_SET_RELEASE_FILE_OS_VALUES
   PLATFORM_SETUP_LEGACY_VARS
 ])
 
--- a/common/autoconf/spec.gmk.in	Thu May 11 20:23:41 2017 +0000
+++ b/common/autoconf/spec.gmk.in	Wed Jul 05 23:25:53 2017 +0200
@@ -101,9 +101,12 @@
 OPENJDK_BUILD_CPU_BITS:=@OPENJDK_BUILD_CPU_BITS@
 OPENJDK_BUILD_CPU_ENDIAN:=@OPENJDK_BUILD_CPU_ENDIAN@
 
-# OS values for use in ModuleTarget class file attribute.
-OPENJDK_MODULE_TARGET_OS_NAME:=@OPENJDK_MODULE_TARGET_OS_NAME@
-OPENJDK_MODULE_TARGET_OS_ARCH:=@OPENJDK_MODULE_TARGET_OS_ARCH@
+# Target platform value in ModuleTarget class file attribute.
+OPENJDK_MODULE_TARGET_PLATFORM:=@OPENJDK_MODULE_TARGET_PLATFORM@
+
+# OS_* properties in release file
+RELEASE_FILE_OS_NAME:=@RELEASE_FILE_OS_NAME@
+RELEASE_FILE_OS_ARCH:=@RELEASE_FILE_OS_ARCH@
 
 LIBM:=@LIBM@
 LIBDL:=@LIBDL@
--- a/common/conf/jib-profiles.js	Thu May 11 20:23:41 2017 +0000
+++ b/common/conf/jib-profiles.js	Wed Jul 05 23:25:53 2017 +0200
@@ -239,11 +239,8 @@
     common.main_profile_base = {
         dependencies: ["boot_jdk", "gnumake", "jtreg"],
         default_make_targets: ["product-bundles", "test-bundles"],
-        configure_args: [
-            "--with-version-opt=" + common.build_id,
-            "--enable-jtreg-failure-handler",
-            "--with-version-build=" + common.build_number
-        ]
+        configure_args: concat(["--enable-jtreg-failure-handler"],
+                               versionArgs(input, common))
     };
     // Extra settings for debug profiles
     common.debug_suffix = "-debug";
@@ -269,10 +266,12 @@
 
     /**
      * Define common artifacts template for all main profiles
-     * @param pf - Name of platform in bundle names
-     * @param demo_ext - Type of extension for demo bundle
+     * @param o - Object containing data for artifacts
      */
-    common.main_profile_artifacts = function (pf, demo_ext) {
+    common.main_profile_artifacts = function (o) {
+        var jdk_subdir = (o.jdk_subdir != null ? o.jdk_subdir : "jdk-" + data.version);
+        var jre_subdir = (o.jre_subdir != null ? o.jre_subdir : "jre-" + data.version);
+        var pf = o.platform
         return {
             artifacts: {
                 jdk: {
@@ -281,7 +280,7 @@
                         "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin.tar.gz",
                         "bundles/" + pf + "/\\1"
                     ],
-                    subdir: "jdk-" + data.version,
+                    subdir: jdk_subdir,
                     exploded: "images/jdk"
                 },
                 jre: {
@@ -290,7 +289,7 @@
                         "bundles/" + pf + "/jre-" + data.version + "_" + pf + "_bin.tar.gz",
                         "bundles/" + pf + "/\\1"
                     ],
-                    subdir: "jre-" + data.version,
+                    subdir: jre_subdir,
                     exploded: "images/jre"
                 },
                 test: {
@@ -307,7 +306,7 @@
                         "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-symbols.tar.gz",
                         "bundles/" + pf + "/\\1"
                     ],
-                    subdir: "jdk-" + data.version,
+                    subdir: jdk_subdir,
                     exploded: "images/jdk"
                 },
                 jre_symbols: {
@@ -316,15 +315,8 @@
                         "bundles/" + pf + "/jre-" + data.version + "_" + pf + "_bin-symbols.tar.gz",
                         "bundles/" + pf + "/\\1"
                     ],
-                    subdir: "jre-" + data.version,
+                    subdir: jre_subdir,
                     exploded: "images/jre"
-                },
-                demo: {
-                    local: "bundles/\\(jdk.*demo." + demo_ext + "\\)",
-                    remote: [
-                        "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_demo." + demo_ext,
-                        "bundles/" + pf + "/\\1"
-                    ],
                 }
             }
         };
@@ -333,9 +325,12 @@
 
     /**
      * Define common artifacts template for all debug profiles
-     * @param pf - Name of platform in bundle names
+     * @param o - Object containing data for artifacts
      */
-    common.debug_profile_artifacts = function (pf) {
+    common.debug_profile_artifacts = function (o) {
+        var jdk_subdir = "jdk-" + data.version + "/fastdebug";
+        var jre_subdir = "jre-" + data.version + "/fastdebug";
+        var pf = o.platform
         return {
             artifacts: {
                 jdk: {
@@ -344,7 +339,7 @@
                         "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-debug.tar.gz",
                         "bundles/" + pf + "/\\1"
                     ],
-                    subdir: "jdk-" + data.version,
+                    subdir: jdk_subdir,
                     exploded: "images/jdk"
                 },
                 jre: {
@@ -353,7 +348,7 @@
                         "bundles/" + pf + "/jre-" + data.version + "_" + pf + "_bin-debug.tar.gz",
                         "bundles/" + pf + "/\\1"
                     ],
-                    subdir: "jre-" + data.version,
+                    subdir: jre_subdir,
                     exploded: "images/jre"
                 },
                 test: {
@@ -370,7 +365,7 @@
                         "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-debug-symbols.tar.gz",
                         "bundles/" + pf + "/\\1"
                     ],
-                    subdir: "jdk-" + data.version,
+                    subdir: jdk_subdir,
                     exploded: "images/jdk"
                 },
                 jre_symbols: {
@@ -379,7 +374,7 @@
                         "bundles/" + pf + "/jre-" + data.version + "_" + pf + "_bin-debug-symbols.tar.gz",
                         "bundles/" + pf + "/\\1"
                     ],
-                    subdir: "jre-" + data.version,
+                    subdir: jre_subdir,
                     exploded: "images/jre"
                 }
             }
@@ -665,61 +660,53 @@
     //
     // Define artifacts for profiles
     //
-    // Macosx bundles are named osx and Windows demo bundles use zip instead of
+    // Macosx bundles are named osx
     // tar.gz.
     var artifactData = {
         "linux-x64": {
             platform: "linux-x64",
-            demo_ext: "tar.gz"
         },
         "linux-x86": {
             platform: "linux-x86",
-            demo_ext: "tar.gz"
         },
         "macosx-x64": {
             platform: "osx-x64",
-            demo_ext: "tar.gz"
+            jdk_subdir: "jdk-" + data.version +  ".jdk/Contents/Home",
+            jre_subdir: "jre-" + data.version +  ".jre/Contents/Home"
         },
         "solaris-x64": {
             platform: "solaris-x64",
-            demo_ext: "tar.gz"
         },
         "solaris-sparcv9": {
             platform: "solaris-sparcv9",
-            demo_ext: "tar.gz"
         },
         "windows-x64": {
             platform: "windows-x64",
-            demo_ext: "zip"
         },
         "windows-x86": {
             platform: "windows-x86",
-            demo_ext: "zip"
         },
        "linux-arm64": {
             platform: "linux-arm64-vfp-hflt",
-            demo_ext: "tar.gz"
         },
         "linux-arm-vfp-hflt": {
             platform: "linux-arm32-vfp-hflt",
-            demo_ext: "tar.gz"
         },
         "linux-arm-vfp-hflt-dyn": {
             platform: "linux-arm32-vfp-hflt-dyn",
-            demo_ext: "tar.gz"
         }
     }
     // Generate common artifacts for all main profiles
     Object.keys(artifactData).forEach(function (name) {
         profiles[name] = concatObjects(profiles[name],
-            common.main_profile_artifacts(artifactData[name].platform, artifactData[name].demo_ext));
+            common.main_profile_artifacts(artifactData[name]));
     });
 
     // Generate common artifacts for all debug profiles
     Object.keys(artifactData).forEach(function (name) {
         var debugName = name + common.debug_suffix;
         profiles[debugName] = concatObjects(profiles[debugName],
-            common.debug_profile_artifacts(artifactData[name].platform));
+            common.debug_profile_artifacts(artifactData[name]));
     });
 
     // Extra profile specific artifacts
@@ -740,7 +727,12 @@
             artifacts: {
                 jdk: {
                     local: "bundles/\\(jdk.*bin.tar.gz\\)",
-                    remote: "bundles/openjdk/GPL/linux-x64/\\1",
+                    remote: [
+                        "bundles/openjdk/GPL/linux-x64/jdk-" + data.version
+                            + "_linux-x64_bin.tar.gz",
+                        "bundles/openjdk/GPL/linux-x64/\\1"
+                    ],
+                    subdir: "jdk-" + data.version
                 },
                 jre: {
                     local: "bundles/\\(jre.*bin.tar.gz\\)",
@@ -748,20 +740,25 @@
                 },
                 test: {
                     local: "bundles/\\(jdk.*bin-tests.tar.gz\\)",
-                    remote: "bundles/openjdk/GPL/linux-x64/\\1",
+                    remote: [
+                        "bundles/openjdk/GPL/linux-x64/jdk-" + data.version
+                            + "_linux-x64_bin-tests.tar.gz",
+                        "bundles/openjdk/GPL/linux-x64/\\1"
+                    ]
                 },
                 jdk_symbols: {
                     local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)",
-                    remote: "bundles/openjdk/GPL/linux-x64/\\1",
+                    remote: [
+                        "bundles/openjdk/GPL/linux-x64/jdk-" + data.version
+                            + "_linux-x64_bin-symbols.tar.gz",
+                        "bundles/openjdk/GPL/linux-x64/\\1"
+                    ],
+                    subdir: "jdk-" + data.version
                 },
                 jre_symbols: {
                     local: "bundles/\\(jre.*bin-symbols.tar.gz\\)",
                     remote: "bundles/openjdk/GPL/linux-x64/\\1",
                 },
-                demo: {
-                    local: "bundles/\\(jdk.*demo.tar.gz\\)",
-                    remote: "bundles/openjdk/GPL/linux-x64/\\1",
-                },
                 doc_api_spec: {
                     local: "bundles/\\(jdk.*doc-api-spec.tar.gz\\)",
                     remote: "bundles/openjdk/GPL/linux-x64/\\1",
@@ -773,11 +770,29 @@
             artifacts: {
                 jdk: {
                     local: "bundles/\\(jdk.*bin.tar.gz\\)",
-                    remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
+                    remote: [
+                        "bundles/openjdk/GPL/linux-x86/jdk-" + data.version
+                            + "_linux-x86_bin.tar.gz",
+                        "bundles/openjdk/GPL/linux-x86/\\1"
+                    ],
+                    subdir: "jdk-" + data.version
                 },
                 jdk_symbols: {
                     local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)",
-                    remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
+                    remote: [
+                        "bundles/openjdk/GPL/linux-x86/jdk-" + data.version
+                            + "_linux-x86_bin-symbols.tar.gz",
+                        "bundles/openjdk/GPL/linux-x86/\\1"
+                    ],
+                    subdir: "jdk-" + data.version
+                },
+                test: {
+                    local: "bundles/\\(jdk.*bin-tests.tar.gz\\)",
+                    remote: [
+                        "bundles/openjdk/GPL/linux-x86/jdk-" + data.version
+                            + "_linux-x86_bin-tests.tar.gz",
+                        "bundles/openjdk/GPL/linux-x86/\\1"
+                    ]
                 },
                 jre: {
                     // This regexp needs to not match the compact* files below
@@ -803,7 +818,12 @@
             artifacts: {
                 jdk: {
                     local: "bundles/\\(jdk.*bin.tar.gz\\)",
-                    remote: "bundles/openjdk/GPL/windows-x86/\\1",
+                    remote: [
+                        "bundles/openjdk/GPL/windows-x86/jdk-" + data.version
+                            + "_windows-x86_bin.tar.gz",
+                        "bundles/openjdk/GPL/windows-x86/\\1"
+                    ],
+                    subdir: "jdk-" + data.version
                 },
                 jre: {
                     local: "bundles/\\(jre.*bin.tar.gz\\)",
@@ -811,19 +831,24 @@
                 },
                 test: {
                     local: "bundles/\\(jdk.*bin-tests.tar.gz\\)",
-                    remote: "bundles/openjdk/GPL/windows-x86/\\1",
+                    remote: [
+                        "bundles/openjdk/GPL/windows-x86/jdk-" + data.version
+                            + "_windows-x86_bin-tests.tar.gz",
+                        "bundles/openjdk/GPL/windows-x86/\\1"
+                    ]
                 },
                 jdk_symbols: {
                     local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)",
-                    remote: "bundles/openjdk/GPL/windows-x86/\\1"
+                    remote: [
+                        "bundles/openjdk/GPL/windows-x86/jdk-" + data.version
+                            + "_windows-x86_bin-symbols.tar.gz",
+                        "bundles/openjdk/GPL/windows-x86/\\1"
+                    ],
+                    subdir: "jdk-" + data.version
                 },
                 jre_symbols: {
                     local: "bundles/\\(jre.*bin-symbols.tar.gz\\)",
                     remote: "bundles/openjdk/GPL/windows-x86/\\1",
-                },
-                demo: {
-                    local: "bundles/\\(jdk.*demo.zip\\)",
-                    remote: "bundles/openjdk/GPL/windows-x86/\\1",
                 }
             }
         },
@@ -1154,6 +1179,23 @@
     return version;
 };
 
+/**
+ * Constructs the common version configure args based on build type and
+ * other version inputs
+ */
+var versionArgs = function(input, common) {
+    var args = ["--with-version-build=" + common.build_number];
+    if (input.build_type == "promoted") {
+        args = concat(args,
+                      // This needs to be changed when we start building release candidates
+                      "--with-version-pre=ea",
+                      "--without-version-opt");
+    } else {
+        args = concat(args, "--with-version-opt=" + common.build_id);
+    }
+    return args;
+}
+
 // Properties representation of the common/autoconf/version-numbers file. Lazily
 // initiated by the function below.
 var version_numbers;
--- a/common/doc/testing.md	Thu May 11 20:23:41 2017 +0000
+++ b/common/doc/testing.md	Wed Jul 05 23:25:53 2017 +0200
@@ -199,9 +199,8 @@
 Use `GTEST="OPTIONS=--help"` to see all available Gtest options.
 
 ---
-# Override some definitions in http://openjdk.java.net/page.css that are
-# unsuitable for this document.
+# Override some definitions in the global css file that are not optimal for
+# this document.
 header-includes:
  - '<style type="text/css">pre, code, tt { color: #1d6ae5; }</style>'
- - '<style type="text/css">pre { font-size: 10pt; }</style>'
 ---
--- a/hotspot/.hgtags	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/.hgtags	Wed Jul 05 23:25:53 2017 +0200
@@ -578,3 +578,4 @@
 762465099d938fd96cd1efda193bc1fa23d070d3 jdk-10+6
 1ca7ed1b17b5776930d641d1379834f3140a74e4 jdk-9+167
 fbb9c802649585d19f6d7e81b4a519d44806225a jdk-9+168
+16d692be099c5c38eb48cc9aca78b0c900910d5b jdk-9+169
--- a/hotspot/src/cpu/aarch64/vm/aarch64.ad	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad	Wed Jul 05 23:25:53 2017 +0200
@@ -577,7 +577,7 @@
     R26
  /* R27, */                     // heapbase
  /* R28, */                     // thread
- /* R29, */                     // fp
+    R29,                        // fp
  /* R30, */                     // lr
  /* R31 */                      // sp
 );
@@ -646,7 +646,7 @@
     R26, R26_H,
  /* R27, R27_H, */              // heapbase
  /* R28, R28_H, */              // thread
- /* R29, R29_H, */              // fp
+    R29, R29_H,                 // fp
  /* R30, R30_H, */              // lr
  /* R31, R31_H */               // sp
 );
@@ -14021,10 +14021,12 @@
   ins_pipe(pipe_class_memory);
 %}
 
-instruct clearArray_imm_reg(immL cnt, iRegP_R10 base, iRegL_R11 tmp, Universe dummy, rFlagsReg cr)
-%{
+instruct clearArray_imm_reg(immL cnt, iRegP_R10 base, Universe dummy, rFlagsReg cr)
+%{
+  predicate((u_int64_t)n->in(2)->get_long()
+            < (u_int64_t)(BlockZeroingLowLimit >> LogBytesPerWord));
   match(Set dummy (ClearArray cnt base));
-  effect(USE_KILL base, TEMP tmp);
+  effect(USE_KILL base);
 
   ins_cost(4 * INSN_COST);
   format %{ "ClearArray $cnt, $base" %}
--- a/hotspot/src/cpu/aarch64/vm/assembler_aarch64.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/assembler_aarch64.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,8 +1,7 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
- * reserved.  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE
- * HEADER.
+ * 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
@@ -21,7 +20,6 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
- *
  */
 
 #include <stdio.h>
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -698,6 +698,7 @@
 // trampolines won't be emitted.
 
 address MacroAssembler::trampoline_call(Address entry, CodeBuffer *cbuf) {
+  assert(JavaThread::current()->is_Compiler_thread(), "just checking");
   assert(entry.rspec().type() == relocInfo::runtime_call_type
          || entry.rspec().type() == relocInfo::opt_virtual_call_type
          || entry.rspec().type() == relocInfo::static_call_type
@@ -4944,34 +4945,67 @@
 }
 
 
-// base:     Address of a buffer to be zeroed, 8 bytes aligned.
-// cnt:      Count in HeapWords.
-// is_large: True when 'cnt' is known to be >= BlockZeroingLowLimit.
-void MacroAssembler::zero_words(Register base, Register cnt)
+// The size of the blocks erased by the zero_blocks stub.  We must
+// handle anything smaller than this ourselves in zero_words().
+const int MacroAssembler::zero_words_block_size = 8;
+
+// zero_words() is used by C2 ClearArray patterns.  It is as small as
+// possible, handling small word counts locally and delegating
+// anything larger to the zero_blocks stub.  It is expanded many times
+// in compiled code, so it is important to keep it short.
+
+// ptr:   Address of a buffer to be zeroed.
+// cnt:   Count in HeapWords.
+//
+// ptr, cnt, rscratch1, and rscratch2 are clobbered.
+void MacroAssembler::zero_words(Register ptr, Register cnt)
 {
-  if (UseBlockZeroing) {
-    block_zero(base, cnt);
-  } else {
-    fill_words(base, cnt, zr);
+  assert(is_power_of_2(zero_words_block_size), "adjust this");
+  assert(ptr == r10 && cnt == r11, "mismatch in register usage");
+
+  BLOCK_COMMENT("zero_words {");
+  cmp(cnt, zero_words_block_size);
+  Label around, done, done16;
+  br(LO, around);
+  {
+    RuntimeAddress zero_blocks =  RuntimeAddress(StubRoutines::aarch64::zero_blocks());
+    assert(zero_blocks.target() != NULL, "zero_blocks stub has not been generated");
+    if (StubRoutines::aarch64::complete()) {
+      trampoline_call(zero_blocks);
+    } else {
+      bl(zero_blocks);
+    }
   }
+  bind(around);
+  for (int i = zero_words_block_size >> 1; i > 1; i >>= 1) {
+    Label l;
+    tbz(cnt, exact_log2(i), l);
+    for (int j = 0; j < i; j += 2) {
+      stp(zr, zr, post(ptr, 16));
+    }
+    bind(l);
+  }
+  {
+    Label l;
+    tbz(cnt, 0, l);
+    str(zr, Address(ptr));
+    bind(l);
+  }
+  BLOCK_COMMENT("} zero_words");
 }
 
-// r10 = base:   Address of a buffer to be zeroed, 8 bytes aligned.
+// base:         Address of a buffer to be zeroed, 8 bytes aligned.
 // cnt:          Immediate count in HeapWords.
-// r11 = tmp:    For use as cnt if we need to call out
-#define ShortArraySize (18 * BytesPerLong)
+#define SmallArraySize (18 * BytesPerLong)
 void MacroAssembler::zero_words(Register base, u_int64_t cnt)
 {
-  Register tmp = r11;
+  BLOCK_COMMENT("zero_words {");
   int i = cnt & 1;  // store any odd word to start
   if (i) str(zr, Address(base));
 
-  if (cnt <= ShortArraySize / BytesPerLong) {
+  if (cnt <= SmallArraySize / BytesPerLong) {
     for (; i < (int)cnt; i += 2)
       stp(zr, zr, Address(base, i * wordSize));
-  } else if (UseBlockZeroing && cnt >= (u_int64_t)(BlockZeroingLowLimit >> LogBytesPerWord)) {
-    mov(tmp, cnt);
-    block_zero(base, tmp, true);
   } else {
     const int unroll = 4; // Number of stp(zr, zr) instructions we'll unroll
     int remainder = cnt % (2 * unroll);
@@ -4992,6 +5026,51 @@
     stp(zr, zr, Address(pre(loop_base, 2 * unroll * wordSize)));
     cbnz(cnt_reg, loop);
   }
+  BLOCK_COMMENT("} zero_words");
+}
+
+// Zero blocks of memory by using DC ZVA.
+//
+// Aligns the base address first sufficently for DC ZVA, then uses
+// DC ZVA repeatedly for every full block.  cnt is the size to be
+// zeroed in HeapWords.  Returns the count of words left to be zeroed
+// in cnt.
+//
+// NOTE: This is intended to be used in the zero_blocks() stub.  If
+// you want to use it elsewhere, note that cnt must be >= 2*zva_length.
+void MacroAssembler::zero_dcache_blocks(Register base, Register cnt) {
+  Register tmp = rscratch1;
+  Register tmp2 = rscratch2;
+  int zva_length = VM_Version::zva_length();
+  Label initial_table_end, loop_zva;
+  Label fini;
+
+  // Base must be 16 byte aligned. If not just return and let caller handle it
+  tst(base, 0x0f);
+  br(Assembler::NE, fini);
+  // Align base with ZVA length.
+  neg(tmp, base);
+  andr(tmp, tmp, zva_length - 1);
+
+  // tmp: the number of bytes to be filled to align the base with ZVA length.
+  add(base, base, tmp);
+  sub(cnt, cnt, tmp, Assembler::ASR, 3);
+  adr(tmp2, initial_table_end);
+  sub(tmp2, tmp2, tmp, Assembler::LSR, 2);
+  br(tmp2);
+
+  for (int i = -zva_length + 16; i < 0; i += 16)
+    stp(zr, zr, Address(base, i));
+  bind(initial_table_end);
+
+  sub(cnt, cnt, zva_length >> 3);
+  bind(loop_zva);
+  dc(Assembler::ZVA, base);
+  subs(cnt, cnt, zva_length >> 3);
+  add(base, base, zva_length);
+  br(Assembler::GE, loop_zva);
+  add(cnt, cnt, zva_length >> 3); // count not zeroed by DC ZVA
+  bind(fini);
 }
 
 // base:   Address of a buffer to be filled, 8 bytes aligned.
@@ -5052,69 +5131,6 @@
   bind(fini);
 }
 
-// Use DC ZVA to do fast zeroing.
-// base:   Address of a buffer to be zeroed, 8 bytes aligned.
-// cnt:    Count in HeapWords.
-// is_large: True when 'cnt' is known to be >= BlockZeroingLowLimit.
-void MacroAssembler::block_zero(Register base, Register cnt, bool is_large)
-{
-  Label small;
-  Label store_pair, loop_store_pair, done;
-  Label base_aligned;
-
-  assert_different_registers(base, cnt, rscratch1);
-  guarantee(base == r10 && cnt == r11, "fix register usage");
-
-  Register tmp = rscratch1;
-  Register tmp2 = rscratch2;
-  int zva_length = VM_Version::zva_length();
-
-  // Ensure ZVA length can be divided by 16. This is required by
-  // the subsequent operations.
-  assert (zva_length % 16 == 0, "Unexpected ZVA Length");
-
-  if (!is_large) cbz(cnt, done);
-  tbz(base, 3, base_aligned);
-  str(zr, Address(post(base, 8)));
-  sub(cnt, cnt, 1);
-  bind(base_aligned);
-
-  // Ensure count >= zva_length * 2 so that it still deserves a zva after
-  // alignment.
-  if (!is_large || !(BlockZeroingLowLimit >= zva_length * 2)) {
-    int low_limit = MAX2(zva_length * 2, (int)BlockZeroingLowLimit);
-    subs(tmp, cnt, low_limit >> 3);
-    br(Assembler::LT, small);
-  }
-
-  far_call(StubRoutines::aarch64::get_zero_longs());
-
-  bind(small);
-
-  const int unroll = 8; // Number of stp instructions we'll unroll
-  Label small_loop, small_table_end;
-
-  andr(tmp, cnt, (unroll-1) * 2);
-  sub(cnt, cnt, tmp);
-  add(base, base, tmp, Assembler::LSL, 3);
-  adr(tmp2, small_table_end);
-  sub(tmp2, tmp2, tmp, Assembler::LSL, 1);
-  br(tmp2);
-
-  bind(small_loop);
-  add(base, base, unroll * 16);
-  for (int i = -unroll; i < 0; i++)
-    stp(zr, zr, Address(base, i * 16));
-  bind(small_table_end);
-  subs(cnt, cnt, unroll * 2);
-  br(Assembler::GE, small_loop);
-
-  tbz(cnt, 0, done);
-  str(zr, Address(post(base, 8)));
-
-  bind(done);
-}
-
 // Intrinsic for sun/nio/cs/ISO_8859_1$Encoder.implEncodeISOArray and
 // java/lang/StringUTF16.compress.
 void MacroAssembler::encode_iso_array(Register src, Register dst,
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1213,8 +1213,10 @@
 
   void fill_words(Register base, Register cnt, Register value);
   void zero_words(Register base, u_int64_t cnt);
-  void zero_words(Register base, Register cnt);
-  void block_zero(Register base, Register cnt, bool is_large = false);
+  void zero_words(Register ptr, Register cnt);
+  void zero_dcache_blocks(Register base, Register cnt);
+
+  static const int zero_words_block_size;
 
   void byte_array_inflate(Register src, Register dst, Register len,
                           FloatRegister vtmp1, FloatRegister vtmp2,
--- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -719,48 +719,74 @@
     }
   }
 
-  address generate_zero_longs(Register base, Register cnt) {
-    Register tmp = rscratch1;
-    Register tmp2 = rscratch2;
-    int zva_length = VM_Version::zva_length();
-    Label initial_table_end, loop_zva;
-    Label fini;
+  // The inner part of zero_words().  This is the bulk operation,
+  // zeroing words in blocks, possibly using DC ZVA to do it.  The
+  // caller is responsible for zeroing the last few words.
+  //
+  // Inputs:
+  // r10: the HeapWord-aligned base address of an array to zero.
+  // r11: the count in HeapWords, r11 > 0.
+  //
+  // Returns r10 and r11, adjusted for the caller to clear.
+  // r10: the base address of the tail of words left to clear.
+  // r11: the number of words in the tail.
+  //      r11 < MacroAssembler::zero_words_block_size.
+
+  address generate_zero_blocks() {
+    Label store_pair, loop_store_pair, done;
+    Label base_aligned;
+
+    Register base = r10, cnt = r11;
 
     __ align(CodeEntryAlignment);
-    StubCodeMark mark(this, "StubRoutines", "zero_longs");
+    StubCodeMark mark(this, "StubRoutines", "zero_blocks");
     address start = __ pc();
 
-    // Base must be 16 byte aligned. If not just return and let caller handle it
-    __ tst(base, 0x0f);
-    __ br(Assembler::NE, fini);
-    // Align base with ZVA length.
-    __ neg(tmp, base);
-    __ andr(tmp, tmp, zva_length - 1);
-
-    // tmp: the number of bytes to be filled to align the base with ZVA length.
-    __ add(base, base, tmp);
-    __ sub(cnt, cnt, tmp, Assembler::ASR, 3);
-    __ adr(tmp2, initial_table_end);
-    __ sub(tmp2, tmp2, tmp, Assembler::LSR, 2);
-    __ br(tmp2);
-
-    for (int i = -zva_length + 16; i < 0; i += 16)
-      __ stp(zr, zr, Address(base, i));
-    __ bind(initial_table_end);
-
-    __ sub(cnt, cnt, zva_length >> 3);
-    __ bind(loop_zva);
-    __ dc(Assembler::ZVA, base);
-    __ subs(cnt, cnt, zva_length >> 3);
-    __ add(base, base, zva_length);
-    __ br(Assembler::GE, loop_zva);
-    __ add(cnt, cnt, zva_length >> 3); // count not zeroed by DC ZVA
-    __ bind(fini);
+    if (UseBlockZeroing) {
+      int zva_length = VM_Version::zva_length();
+
+      // Ensure ZVA length can be divided by 16. This is required by
+      // the subsequent operations.
+      assert (zva_length % 16 == 0, "Unexpected ZVA Length");
+
+      __ tbz(base, 3, base_aligned);
+      __ str(zr, Address(__ post(base, 8)));
+      __ sub(cnt, cnt, 1);
+      __ bind(base_aligned);
+
+      // Ensure count >= zva_length * 2 so that it still deserves a zva after
+      // alignment.
+      Label small;
+      int low_limit = MAX2(zva_length * 2, (int)BlockZeroingLowLimit);
+      __ cmp(cnt, low_limit >> 3);
+      __ br(Assembler::LT, small);
+      __ zero_dcache_blocks(base, cnt);
+      __ bind(small);
+    }
+
+    {
+      // Number of stp instructions we'll unroll
+      const int unroll =
+        MacroAssembler::zero_words_block_size / 2;
+      // Clear the remaining blocks.
+      Label loop;
+      __ subs(cnt, cnt, unroll * 2);
+      __ br(Assembler::LT, done);
+      __ bind(loop);
+      for (int i = 0; i < unroll; i++)
+        __ stp(zr, zr, __ post(base, 16));
+      __ subs(cnt, cnt, unroll * 2);
+      __ br(Assembler::GE, loop);
+      __ bind(done);
+      __ add(cnt, cnt, unroll * 2);
+    }
+
     __ ret(lr);
 
     return start;
   }
 
+
   typedef enum {
     copy_forwards = 1,
     copy_backwards = -1
@@ -2346,20 +2372,16 @@
     __ subw(count, count, cnt_words, Assembler::LSL, 3 - shift);
     if (UseBlockZeroing) {
       Label non_block_zeroing, rest;
-      Register tmp = rscratch1;
-      // count >= BlockZeroingLowLimit && value == 0
-      __ subs(tmp, cnt_words, BlockZeroingLowLimit >> 3);
-      __ ccmp(value, 0 /* comparing value */, 0 /* NZCV */, Assembler::GE);
-      __ br(Assembler::NE, non_block_zeroing);
+      // If the fill value is zero we can use the fast zero_words().
+      __ cbnz(value, non_block_zeroing);
       __ mov(bz_base, to);
-      __ block_zero(bz_base, cnt_words, true);
-      __ mov(to, bz_base);
+      __ add(to, to, cnt_words, Assembler::LSL, LogBytesPerWord);
+      __ zero_words(bz_base, cnt_words);
       __ b(rest);
       __ bind(non_block_zeroing);
       __ fill_words(to, cnt_words, value);
       __ bind(rest);
-    }
-    else {
+    } else {
       __ fill_words(to, cnt_words, value);
     }
 
@@ -2420,7 +2442,7 @@
     generate_copy_longs(copy_f, r0, r1, rscratch2, copy_forwards);
     generate_copy_longs(copy_b, r0, r1, rscratch2, copy_backwards);
 
-    StubRoutines::aarch64::_zero_longs = generate_zero_longs(r10, r11);
+    StubRoutines::aarch64::_zero_blocks = generate_zero_blocks();
 
     //*** jbyte
     // Always need aligned and unaligned versions
@@ -4769,6 +4791,7 @@
                                                        &StubRoutines::_safefetchN_fault_pc,
                                                        &StubRoutines::_safefetchN_continuation_pc);
 #endif
+    StubRoutines::aarch64::set_completed();
   }
 
  public:
--- a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -43,7 +43,8 @@
 address StubRoutines::aarch64::_float_sign_flip = NULL;
 address StubRoutines::aarch64::_double_sign_mask = NULL;
 address StubRoutines::aarch64::_double_sign_flip = NULL;
-address StubRoutines::aarch64::_zero_longs = NULL;
+address StubRoutines::aarch64::_zero_blocks = NULL;
+bool StubRoutines::aarch64::_completed = false;
 
 /**
  *  crc_table[] from jdk/src/share/native/java/util/zip/zlib-1.2.5/crc32.h
--- a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp	Wed Jul 05 23:25:53 2017 +0200
@@ -61,7 +61,8 @@
   static address _double_sign_mask;
   static address _double_sign_flip;
 
-  static address _zero_longs;
+  static address _zero_blocks;
+  static bool _completed;
 
  public:
 
@@ -115,12 +116,19 @@
     return _double_sign_flip;
   }
 
-  static address get_zero_longs()
-  {
-    return _zero_longs;
+  static address zero_blocks() {
+    return _zero_blocks;
   }
 
- private:
+  static bool complete() {
+    return _completed;
+  }
+
+  static void set_completed() {
+    _completed = true;
+  }
+
+private:
   static juint    _crc_table[];
 
 };
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64RegisterMap.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64RegisterMap.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 20014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -246,21 +246,21 @@
                         "jdk/internal/misc/Unsafe.allocateUninitializedArray0(Ljava/lang/Class;I)Ljava/lang/Object;",
                         "jdk/internal/misc/Unsafe.compareAndExchangeByteAcquire(Ljava/lang/Object;JBB)B",
                         "jdk/internal/misc/Unsafe.compareAndExchangeByteRelease(Ljava/lang/Object;JBB)B",
-                        "jdk/internal/misc/Unsafe.compareAndExchangeByteVolatile(Ljava/lang/Object;JBB)B",
+                        "jdk/internal/misc/Unsafe.compareAndExchangeByte(Ljava/lang/Object;JBB)B",
                         "jdk/internal/misc/Unsafe.compareAndExchangeIntAcquire(Ljava/lang/Object;JII)I",
                         "jdk/internal/misc/Unsafe.compareAndExchangeIntRelease(Ljava/lang/Object;JII)I",
-                        "jdk/internal/misc/Unsafe.compareAndExchangeIntVolatile(Ljava/lang/Object;JII)I",
+                        "jdk/internal/misc/Unsafe.compareAndExchangeInt(Ljava/lang/Object;JII)I",
                         "jdk/internal/misc/Unsafe.compareAndExchangeLongAcquire(Ljava/lang/Object;JJJ)J",
                         "jdk/internal/misc/Unsafe.compareAndExchangeLongRelease(Ljava/lang/Object;JJJ)J",
-                        "jdk/internal/misc/Unsafe.compareAndExchangeLongVolatile(Ljava/lang/Object;JJJ)J",
+                        "jdk/internal/misc/Unsafe.compareAndExchangeLong(Ljava/lang/Object;JJJ)J",
                         "jdk/internal/misc/Unsafe.compareAndExchangeObjectAcquire(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
                         "jdk/internal/misc/Unsafe.compareAndExchangeObjectRelease(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
-                        "jdk/internal/misc/Unsafe.compareAndExchangeObjectVolatile(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
+                        "jdk/internal/misc/Unsafe.compareAndExchangeObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
                         "jdk/internal/misc/Unsafe.compareAndExchangeShortAcquire(Ljava/lang/Object;JSS)S",
                         "jdk/internal/misc/Unsafe.compareAndExchangeShortRelease(Ljava/lang/Object;JSS)S",
-                        "jdk/internal/misc/Unsafe.compareAndExchangeShortVolatile(Ljava/lang/Object;JSS)S",
-                        "jdk/internal/misc/Unsafe.compareAndSwapByte(Ljava/lang/Object;JBB)Z",
-                        "jdk/internal/misc/Unsafe.compareAndSwapShort(Ljava/lang/Object;JSS)Z",
+                        "jdk/internal/misc/Unsafe.compareAndExchangeShort(Ljava/lang/Object;JSS)S",
+                        "jdk/internal/misc/Unsafe.compareAndSetByte(Ljava/lang/Object;JBB)Z",
+                        "jdk/internal/misc/Unsafe.compareAndSetShort(Ljava/lang/Object;JSS)Z",
                         "jdk/internal/misc/Unsafe.copyMemory0(Ljava/lang/Object;JLjava/lang/Object;JJ)V",
                         "jdk/internal/misc/Unsafe.getAndAddByte(Ljava/lang/Object;JB)B",
                         "jdk/internal/misc/Unsafe.getAndAddShort(Ljava/lang/Object;JS)S",
@@ -295,26 +295,26 @@
                         "jdk/internal/misc/Unsafe.putObjectOpaque(Ljava/lang/Object;JLjava/lang/Object;)V",
                         "jdk/internal/misc/Unsafe.putShortOpaque(Ljava/lang/Object;JS)V",
                         "jdk/internal/misc/Unsafe.unpark(Ljava/lang/Object;)V",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapByte(Ljava/lang/Object;JBB)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapByteAcquire(Ljava/lang/Object;JBB)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapByteRelease(Ljava/lang/Object;JBB)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapByteVolatile(Ljava/lang/Object;JBB)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapInt(Ljava/lang/Object;JII)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapIntAcquire(Ljava/lang/Object;JII)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapIntRelease(Ljava/lang/Object;JII)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapIntVolatile(Ljava/lang/Object;JII)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapLong(Ljava/lang/Object;JJJ)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapLongAcquire(Ljava/lang/Object;JJJ)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapLongRelease(Ljava/lang/Object;JJJ)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapLongVolatile(Ljava/lang/Object;JJJ)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapObjectAcquire(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapObjectRelease(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapObjectVolatile(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapShort(Ljava/lang/Object;JSS)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapShortAcquire(Ljava/lang/Object;JSS)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapShortRelease(Ljava/lang/Object;JSS)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapShortVolatile(Ljava/lang/Object;JSS)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetBytePlain(Ljava/lang/Object;JBB)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetByteAcquire(Ljava/lang/Object;JBB)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetByteRelease(Ljava/lang/Object;JBB)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetByte(Ljava/lang/Object;JBB)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetIntPlain(Ljava/lang/Object;JII)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetIntAcquire(Ljava/lang/Object;JII)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetIntRelease(Ljava/lang/Object;JII)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetInt(Ljava/lang/Object;JII)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetLongPlain(Ljava/lang/Object;JJJ)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetLongAcquire(Ljava/lang/Object;JJJ)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetLongRelease(Ljava/lang/Object;JJJ)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetLong(Ljava/lang/Object;JJJ)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetObjectPlain(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetObjectAcquire(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetObjectRelease(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetShortPlain(Ljava/lang/Object;JSS)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetShortAcquire(Ljava/lang/Object;JSS)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetShortRelease(Ljava/lang/Object;JSS)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetShort(Ljava/lang/Object;JSS)Z",
                         "jdk/internal/util/Preconditions.checkIndex(IILjava/util/function/BiFunction;)I",
                         "jdk/jfr/internal/JVM.counterTime()J",
                         "jdk/jfr/internal/JVM.getBufferWriter()Ljava/lang/Object;",
--- a/hotspot/src/share/vm/c1/c1_Compiler.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -108,7 +108,7 @@
   }
 
   switch (id) {
-  case vmIntrinsics::_compareAndSwapLong:
+  case vmIntrinsics::_compareAndSetLong:
     if (!VM_Version::supports_cx8()) return false;
     break;
   case vmIntrinsics::_getAndAddInt:
@@ -217,8 +217,8 @@
   case vmIntrinsics::_updateDirectByteBufferCRC32C:
 #endif
   case vmIntrinsics::_vectorizedMismatch:
-  case vmIntrinsics::_compareAndSwapInt:
-  case vmIntrinsics::_compareAndSwapObject:
+  case vmIntrinsics::_compareAndSetInt:
+  case vmIntrinsics::_compareAndSetObject:
   case vmIntrinsics::_getCharStringU:
   case vmIntrinsics::_putCharStringU:
 #ifdef TRACE_HAVE_INTRINSICS
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3500,9 +3500,9 @@
   case vmIntrinsics::_putLongVolatile    : append_unsafe_put_obj(callee, T_LONG,    true); return;
   case vmIntrinsics::_putFloatVolatile   : append_unsafe_put_obj(callee, T_FLOAT,   true); return;
   case vmIntrinsics::_putDoubleVolatile  : append_unsafe_put_obj(callee, T_DOUBLE,  true); return;
-  case vmIntrinsics::_compareAndSwapLong:
-  case vmIntrinsics::_compareAndSwapInt:
-  case vmIntrinsics::_compareAndSwapObject: append_unsafe_CAS(callee); return;
+  case vmIntrinsics::_compareAndSetLong:
+  case vmIntrinsics::_compareAndSetInt:
+  case vmIntrinsics::_compareAndSetObject: append_unsafe_CAS(callee); return;
   case vmIntrinsics::_getAndAddInt:
   case vmIntrinsics::_getAndAddLong      : append_unsafe_get_and_set_obj(callee, true); return;
   case vmIntrinsics::_getAndSetInt       :
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3212,13 +3212,13 @@
   // java.nio.Buffer.checkIndex
   case vmIntrinsics::_checkIndex:     do_NIOCheckIndex(x); break;
 
-  case vmIntrinsics::_compareAndSwapObject:
+  case vmIntrinsics::_compareAndSetObject:
     do_CompareAndSwap(x, objectType);
     break;
-  case vmIntrinsics::_compareAndSwapInt:
+  case vmIntrinsics::_compareAndSetInt:
     do_CompareAndSwap(x, intType);
     break;
-  case vmIntrinsics::_compareAndSwapLong:
+  case vmIntrinsics::_compareAndSetLong:
     do_CompareAndSwap(x, longType);
     break;
 
--- a/hotspot/src/share/vm/classfile/moduleEntry.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -158,10 +158,10 @@
       loader_data() != m_loader_data &&
       !m_loader_data->is_builtin_class_loader_data()) {
     _must_walk_reads = true;
-    if (log_is_enabled(Trace, modules)) {
+    if (log_is_enabled(Trace, module)) {
       ResourceMark rm;
-      log_trace(modules)("ModuleEntry::set_read_walk_required(): module %s reads list must be walked",
-                         (name() != NULL) ? name()->as_C_string() : UNNAMED_MODULE);
+      log_trace(module)("ModuleEntry::set_read_walk_required(): module %s reads list must be walked",
+                        (name() != NULL) ? name()->as_C_string() : UNNAMED_MODULE);
     }
   }
 }
@@ -180,10 +180,10 @@
     // on the remaining live modules on the reads list.
     _must_walk_reads = false;
 
-    if (log_is_enabled(Trace, modules)) {
+    if (log_is_enabled(Trace, module)) {
       ResourceMark rm;
-      log_trace(modules)("ModuleEntry::purge_reads(): module %s reads list being walked",
-                         (name() != NULL) ? name()->as_C_string() : UNNAMED_MODULE);
+      log_trace(module)("ModuleEntry::purge_reads(): module %s reads list being walked",
+                        (name() != NULL) ? name()->as_C_string() : UNNAMED_MODULE);
     }
 
     // Go backwards because this removes entries that are dead.
@@ -236,8 +236,11 @@
       m = m->next();
 
       ResourceMark rm;
-      log_debug(modules)("ModuleEntryTable: deleting module: %s", to_remove->name() != NULL ?
-                         to_remove->name()->as_C_string() : UNNAMED_MODULE);
+      if (to_remove->name() != NULL) {
+        log_info(module, unload)("unloading module %s", to_remove->name()->as_C_string());
+      }
+      log_debug(module)("ModuleEntryTable: deleting module: %s", to_remove->name() != NULL ?
+                        to_remove->name()->as_C_string() : UNNAMED_MODULE);
 
       // Clean out the C heap allocated reads list first before freeing the entry
       to_remove->delete_reads();
@@ -315,9 +318,9 @@
 
   if (ClassLoader::is_in_patch_mod_entries(name)) {
     entry->set_is_patched();
-    if (log_is_enabled(Trace, modules, patch)) {
+    if (log_is_enabled(Trace, module, patch)) {
       ResourceMark rm;
-      log_trace(modules, patch)("Marked module %s as patched from --patch-module", name->as_C_string());
+      log_trace(module, patch)("Marked module %s as patched from --patch-module", name->as_C_string());
     }
   }
 
--- a/hotspot/src/share/vm/classfile/modules.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/classfile/modules.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -237,16 +237,18 @@
   // Patch any previously loaded class's module field with java.base's java.lang.Module.
   ModuleEntryTable::patch_javabase_entries(module_handle);
 
-  log_debug(modules)("define_javabase_module(): Definition of module: "
-                     JAVA_BASE_NAME ", version: %s, location: %s, package #: %d",
-                     module_version != NULL ? module_version : "NULL",
-                     module_location != NULL ? module_location : "NULL",
-                     pkg_list->length());
+  log_info(module, load)(JAVA_BASE_NAME " location: %s",
+                         module_location != NULL ? module_location : "NULL");
+  log_debug(module)("define_javabase_module(): Definition of module: "
+                    JAVA_BASE_NAME ", version: %s, location: %s, package #: %d",
+                    module_version != NULL ? module_version : "NULL",
+                    module_location != NULL ? module_location : "NULL",
+                    pkg_list->length());
 
   // packages defined to java.base
   for (int x = 0; x < pkg_list->length(); x++) {
-    log_trace(modules)("define_javabase_module(): creation of package %s for module " JAVA_BASE_NAME,
-                       (pkg_list->at(x))->as_C_string());
+    log_trace(module)("define_javabase_module(): creation of package %s for module " JAVA_BASE_NAME,
+                      (pkg_list->at(x))->as_C_string());
   }
 }
 
@@ -438,23 +440,24 @@
       throw_dup_pkg_exception(module_name, existing_pkg, CHECK);
   }
 
-  if (log_is_enabled(Debug, modules)) {
-    outputStream* logst = Log(modules)::debug_stream();
+  log_info(module, load)("%s location: %s", module_name,
+                         module_location != NULL ? module_location : "NULL");
+  if (log_is_enabled(Debug, module)) {
+    outputStream* logst = Log(module)::debug_stream();
     logst->print("define_module(): creation of module: %s, version: %s, location: %s, ",
                  module_name, module_version != NULL ? module_version : "NULL",
                  module_location != NULL ? module_location : "NULL");
     loader_data->print_value_on(logst);
     logst->print_cr(", package #: %d", pkg_list->length());
     for (int y = 0; y < pkg_list->length(); y++) {
-      log_trace(modules)("define_module(): creation of package %s for module %s",
-                         (pkg_list->at(y))->as_C_string(), module_name);
+      log_trace(module)("define_module(): creation of package %s for module %s",
+                        (pkg_list->at(y))->as_C_string(), module_name);
     }
   }
 
   // If the module is defined to the boot loader and an exploded build is being
   // used, prepend <java.home>/modules/modules_name, if it exists, to the system boot class path.
   if (loader == NULL &&
-      !Universe::is_module_initialized() &&
       !ClassLoader::has_jrt_entry()) {
     ClassLoader::add_to_exploded_build_list(module_symbol, CHECK);
   }
@@ -487,7 +490,7 @@
   }
   Handle h_loader = Handle(THREAD, loader);
 
-  log_debug(modules)("set_bootloader_unnamed_module(): recording unnamed module for boot loader");
+  log_debug(module)("set_bootloader_unnamed_module(): recording unnamed module for boot loader");
 
   // Ensure the boot loader's PackageEntryTable has been created
   ModuleEntryTable* module_table = get_module_entry_table(h_loader, CHECK);
@@ -545,10 +548,10 @@
                       from_module_entry->name()->as_C_string()));
   }
 
-  log_debug(modules)("add_module_exports(): package %s in module %s is exported to module %s",
-                     package_entry->name()->as_C_string(),
-                     from_module_entry->name()->as_C_string(),
-                     to_module_entry == NULL ? "NULL" :
+  log_debug(module)("add_module_exports(): package %s in module %s is exported to module %s",
+                    package_entry->name()->as_C_string(),
+                    from_module_entry->name()->as_C_string(),
+                    to_module_entry == NULL ? "NULL" :
                       to_module_entry->is_named() ?
                         to_module_entry->name()->as_C_string() : UNNAMED_MODULE);
 
@@ -592,12 +595,12 @@
   }
 
   ResourceMark rm(THREAD);
-  log_debug(modules)("add_reads_module(): Adding read from module %s to module %s",
-                     from_module_entry->is_named() ?
-                     from_module_entry->name()->as_C_string() : UNNAMED_MODULE,
-                     to_module_entry == NULL ? "all unnamed" :
-                       (to_module_entry->is_named() ?
-                        to_module_entry->name()->as_C_string() : UNNAMED_MODULE));
+  log_debug(module)("add_reads_module(): Adding read from module %s to module %s",
+                    from_module_entry->is_named() ?
+                    from_module_entry->name()->as_C_string() : UNNAMED_MODULE,
+                    to_module_entry == NULL ? "all unnamed" :
+                      (to_module_entry->is_named() ?
+                       to_module_entry->name()->as_C_string() : UNNAMED_MODULE));
 
   // if modules are the same or if from_module is unnamed then no need to add the read.
   if (from_module_entry != to_module_entry && from_module_entry->is_named()) {
@@ -616,7 +619,7 @@
   }
   oop mirror = JNIHandles::resolve_non_null(clazz);
   if (mirror == NULL) {
-    log_debug(modules)("get_module(): no mirror, returning NULL");
+    log_debug(module)("get_module(): no mirror, returning NULL");
     return NULL;
   }
   if (!java_lang_Class::is_instance(mirror)) {
@@ -629,9 +632,9 @@
   assert(module != NULL, "java.lang.Class module field not set");
   assert(java_lang_Module::is_instance(module), "module is not an instance of type java.lang.Module");
 
-  if (log_is_enabled(Debug, modules)) {
+  if (log_is_enabled(Debug, module)) {
     ResourceMark rm(THREAD);
-    outputStream* logst = Log(modules)::debug_stream();
+    outputStream* logst = Log(module)::debug_stream();
     Klass* klass = java_lang_Class::as_Klass(mirror);
     oop module_name = java_lang_Module::name(module);
     if (module_name != NULL) {
@@ -764,8 +767,8 @@
     THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), message);
   }
 
-  log_debug(modules)("add_module_package(): Adding package %s to module %s",
-                     package_name, module_entry->name()->as_C_string());
+  log_debug(module)("add_module_package(): Adding package %s to module %s",
+                    package_name, module_entry->name()->as_C_string());
 
   TempNewSymbol pkg_symbol = SymbolTable::new_symbol(package_name, CHECK);
   PackageEntryTable* package_table = loader_data->packages();
@@ -820,8 +823,8 @@
                         module_entry->name()->as_C_string()));
     }
 
-    log_debug(modules)("add_module_exports_to_all_unnamed(): package %s in module"
-                       " %s is exported to all unnamed modules",
+    log_debug(module)("add_module_exports_to_all_unnamed(): package %s in module"
+                      " %s is exported to all unnamed modules",
                        package_entry->name()->as_C_string(),
                        module_entry->name()->as_C_string());
 
--- a/hotspot/src/share/vm/classfile/packageEntry.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/classfile/packageEntry.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -77,13 +77,13 @@
       (this_pkg_mod == NULL || this_pkg_mod->loader_data() != m_loader_data) &&
       !m_loader_data->is_builtin_class_loader_data()) {
     _must_walk_exports = true;
-    if (log_is_enabled(Trace, modules)) {
+    if (log_is_enabled(Trace, module)) {
       ResourceMark rm;
       assert(name() != NULL, "PackageEntry without a valid name");
-      log_trace(modules)("PackageEntry::set_export_walk_required(): package %s defined in module %s, exports list must be walked",
-                         name()->as_C_string(),
-                         (this_pkg_mod == NULL || this_pkg_mod->name() == NULL) ?
-                           UNNAMED_MODULE : this_pkg_mod->name()->as_C_string());
+      log_trace(module)("PackageEntry::set_export_walk_required(): package %s defined in module %s, exports list must be walked",
+                        name()->as_C_string(),
+                        (this_pkg_mod == NULL || this_pkg_mod->name() == NULL) ?
+                          UNNAMED_MODULE : this_pkg_mod->name()->as_C_string());
     }
   }
 }
@@ -132,13 +132,13 @@
     // on the remaining live modules on the exports list.
     _must_walk_exports = false;
 
-    if (log_is_enabled(Trace, modules)) {
+    if (log_is_enabled(Trace, module)) {
       ResourceMark rm;
       assert(name() != NULL, "PackageEntry without a valid name");
       ModuleEntry* pkg_mod = module();
-      log_trace(modules)("PackageEntry::purge_qualified_exports(): package %s defined in module %s, exports list being walked",
-                         name()->as_C_string(),
-                         (pkg_mod == NULL || pkg_mod->name() == NULL) ? UNNAMED_MODULE : pkg_mod->name()->as_C_string());
+      log_trace(module)("PackageEntry::purge_qualified_exports(): package %s defined in module %s, exports list being walked",
+                        name()->as_C_string(),
+                        (pkg_mod == NULL || pkg_mod->name() == NULL) ? UNNAMED_MODULE : pkg_mod->name()->as_C_string());
     }
 
     // Go backwards because this removes entries that are dead.
--- a/hotspot/src/share/vm/classfile/vmSymbols.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -632,25 +632,28 @@
   case vmIntrinsics::_loadFence:
   case vmIntrinsics::_storeFence:
   case vmIntrinsics::_fullFence:
-  case vmIntrinsics::_compareAndSwapLong:
-  case vmIntrinsics::_weakCompareAndSwapLong:
-  case vmIntrinsics::_weakCompareAndSwapLongAcquire:
-  case vmIntrinsics::_weakCompareAndSwapLongRelease:
-  case vmIntrinsics::_compareAndSwapInt:
-  case vmIntrinsics::_weakCompareAndSwapInt:
-  case vmIntrinsics::_weakCompareAndSwapIntAcquire:
-  case vmIntrinsics::_weakCompareAndSwapIntRelease:
-  case vmIntrinsics::_compareAndSwapObject:
-  case vmIntrinsics::_weakCompareAndSwapObject:
-  case vmIntrinsics::_weakCompareAndSwapObjectAcquire:
-  case vmIntrinsics::_weakCompareAndSwapObjectRelease:
-  case vmIntrinsics::_compareAndExchangeIntVolatile:
+  case vmIntrinsics::_compareAndSetLong:
+  case vmIntrinsics::_weakCompareAndSetLong:
+  case vmIntrinsics::_weakCompareAndSetLongPlain:
+  case vmIntrinsics::_weakCompareAndSetLongAcquire:
+  case vmIntrinsics::_weakCompareAndSetLongRelease:
+  case vmIntrinsics::_compareAndSetInt:
+  case vmIntrinsics::_weakCompareAndSetInt:
+  case vmIntrinsics::_weakCompareAndSetIntPlain:
+  case vmIntrinsics::_weakCompareAndSetIntAcquire:
+  case vmIntrinsics::_weakCompareAndSetIntRelease:
+  case vmIntrinsics::_compareAndSetObject:
+  case vmIntrinsics::_weakCompareAndSetObject:
+  case vmIntrinsics::_weakCompareAndSetObjectPlain:
+  case vmIntrinsics::_weakCompareAndSetObjectAcquire:
+  case vmIntrinsics::_weakCompareAndSetObjectRelease:
+  case vmIntrinsics::_compareAndExchangeInt:
   case vmIntrinsics::_compareAndExchangeIntAcquire:
   case vmIntrinsics::_compareAndExchangeIntRelease:
-  case vmIntrinsics::_compareAndExchangeLongVolatile:
+  case vmIntrinsics::_compareAndExchangeLong:
   case vmIntrinsics::_compareAndExchangeLongAcquire:
   case vmIntrinsics::_compareAndExchangeLongRelease:
-  case vmIntrinsics::_compareAndExchangeObjectVolatile:
+  case vmIntrinsics::_compareAndExchangeObject:
   case vmIntrinsics::_compareAndExchangeObjectAcquire:
   case vmIntrinsics::_compareAndExchangeObjectRelease:
     if (!InlineUnsafeOps) return true;
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Jul 05 23:25:53 2017 +0200
@@ -650,6 +650,8 @@
   template(addUses_signature,                          "(Ljava/lang/Module;Ljava/lang/Class;)V")                  \
   template(addProvides_name,                           "addProvides")                                             \
   template(addProvides_signature,                      "(Ljava/lang/Module;Ljava/lang/Class;Ljava/lang/Class;)V") \
+  template(loadModule_name,                            "loadModule")                                              \
+  template(loadModule_signature,                       "(Ljava/lang/String;)Ljava/lang/Module;")                  \
   template(transformedByAgent_name,                    "transformedByAgent")                                      \
   template(transformedByAgent_signature,               "(Ljava/lang/Module;)V")                                   \
   template(appendToClassPathForInstrumentation_name,   "appendToClassPathForInstrumentation")                     \
@@ -1242,100 +1244,100 @@
   do_intrinsic(_putIntUnaligned,           jdk_internal_misc_Unsafe,    putIntUnaligned_name, putInt_signature,         F_R)  \
   do_intrinsic(_putLongUnaligned,          jdk_internal_misc_Unsafe,    putLongUnaligned_name, putLong_signature,       F_R)  \
                                                                                                                         \
-  do_signature(compareAndSwapObject_signature,     "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z")        \
+  do_signature(compareAndSetObject_signature,      "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z")        \
   do_signature(compareAndExchangeObject_signature, "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;") \
-  do_signature(compareAndSwapLong_signature,       "(Ljava/lang/Object;JJJ)Z")                                          \
+  do_signature(compareAndSetLong_signature,        "(Ljava/lang/Object;JJJ)Z")                                          \
   do_signature(compareAndExchangeLong_signature,   "(Ljava/lang/Object;JJJ)J")                                          \
-  do_signature(compareAndSwapInt_signature,        "(Ljava/lang/Object;JII)Z")                                          \
+  do_signature(compareAndSetInt_signature,         "(Ljava/lang/Object;JII)Z")                                          \
   do_signature(compareAndExchangeInt_signature,    "(Ljava/lang/Object;JII)I")                                          \
-  do_signature(compareAndSwapByte_signature,       "(Ljava/lang/Object;JBB)Z")                                          \
+  do_signature(compareAndSetByte_signature,        "(Ljava/lang/Object;JBB)Z")                                          \
   do_signature(compareAndExchangeByte_signature,   "(Ljava/lang/Object;JBB)B")                                          \
-  do_signature(compareAndSwapShort_signature,      "(Ljava/lang/Object;JSS)Z")                                          \
+  do_signature(compareAndSetShort_signature,       "(Ljava/lang/Object;JSS)Z")                                          \
   do_signature(compareAndExchangeShort_signature,  "(Ljava/lang/Object;JSS)S")                                          \
                                                                                                                         \
-  do_name(compareAndSwapObject_name,             "compareAndSwapObject")                                                \
-  do_name(compareAndExchangeObjectVolatile_name, "compareAndExchangeObjectVolatile")                                    \
+  do_name(compareAndSetObject_name,              "compareAndSetObject")                                                 \
+  do_name(compareAndExchangeObject_name,         "compareAndExchangeObject")                                            \
   do_name(compareAndExchangeObjectAcquire_name,  "compareAndExchangeObjectAcquire")                                     \
   do_name(compareAndExchangeObjectRelease_name,  "compareAndExchangeObjectRelease")                                     \
-  do_name(compareAndSwapLong_name,               "compareAndSwapLong")                                                  \
-  do_name(compareAndExchangeLongVolatile_name,   "compareAndExchangeLongVolatile")                                      \
+  do_name(compareAndSetLong_name,                "compareAndSetLong")                                                   \
+  do_name(compareAndExchangeLong_name,           "compareAndExchangeLong")                                              \
   do_name(compareAndExchangeLongAcquire_name,    "compareAndExchangeLongAcquire")                                       \
   do_name(compareAndExchangeLongRelease_name,    "compareAndExchangeLongRelease")                                       \
-  do_name(compareAndSwapInt_name,                "compareAndSwapInt")                                                   \
-  do_name(compareAndExchangeIntVolatile_name,    "compareAndExchangeIntVolatile")                                       \
+  do_name(compareAndSetInt_name,                 "compareAndSetInt")                                                    \
+  do_name(compareAndExchangeInt_name,            "compareAndExchangeInt")                                               \
   do_name(compareAndExchangeIntAcquire_name,     "compareAndExchangeIntAcquire")                                        \
   do_name(compareAndExchangeIntRelease_name,     "compareAndExchangeIntRelease")                                        \
-  do_name(compareAndSwapByte_name,               "compareAndSwapByte")                                                  \
-  do_name(compareAndExchangeByteVolatile_name,   "compareAndExchangeByteVolatile")                                      \
+  do_name(compareAndSetByte_name,                "compareAndSetByte")                                                   \
+  do_name(compareAndExchangeByte_name,           "compareAndExchangeByte")                                              \
   do_name(compareAndExchangeByteAcquire_name,    "compareAndExchangeByteAcquire")                                       \
   do_name(compareAndExchangeByteRelease_name,    "compareAndExchangeByteRelease")                                       \
-  do_name(compareAndSwapShort_name,              "compareAndSwapShort")                                                 \
-  do_name(compareAndExchangeShortVolatile_name,  "compareAndExchangeShortVolatile")                                     \
+  do_name(compareAndSetShort_name,               "compareAndSetShort")                                                  \
+  do_name(compareAndExchangeShort_name,          "compareAndExchangeShort")                                             \
   do_name(compareAndExchangeShortAcquire_name,   "compareAndExchangeShortAcquire")                                      \
   do_name(compareAndExchangeShortRelease_name,   "compareAndExchangeShortRelease")                                      \
                                                                                                                         \
-  do_name(weakCompareAndSwapObject_name,         "weakCompareAndSwapObject")                                            \
-  do_name(weakCompareAndSwapObjectAcquire_name,  "weakCompareAndSwapObjectAcquire")                                     \
-  do_name(weakCompareAndSwapObjectRelease_name,  "weakCompareAndSwapObjectRelease")                                     \
-  do_name(weakCompareAndSwapObjectVolatile_name, "weakCompareAndSwapObjectVolatile")                                    \
-  do_name(weakCompareAndSwapLong_name,           "weakCompareAndSwapLong")                                              \
-  do_name(weakCompareAndSwapLongAcquire_name,    "weakCompareAndSwapLongAcquire")                                       \
-  do_name(weakCompareAndSwapLongRelease_name,    "weakCompareAndSwapLongRelease")                                       \
-  do_name(weakCompareAndSwapLongVolatile_name,   "weakCompareAndSwapLongVolatile")                                      \
-  do_name(weakCompareAndSwapInt_name,            "weakCompareAndSwapInt")                                               \
-  do_name(weakCompareAndSwapIntAcquire_name,     "weakCompareAndSwapIntAcquire")                                        \
-  do_name(weakCompareAndSwapIntRelease_name,     "weakCompareAndSwapIntRelease")                                        \
-  do_name(weakCompareAndSwapIntVolatile_name,    "weakCompareAndSwapIntVolatile")                                       \
-  do_name(weakCompareAndSwapByte_name,           "weakCompareAndSwapByte")                                              \
-  do_name(weakCompareAndSwapByteAcquire_name,    "weakCompareAndSwapByteAcquire")                                       \
-  do_name(weakCompareAndSwapByteRelease_name,    "weakCompareAndSwapByteRelease")                                       \
-  do_name(weakCompareAndSwapByteVolatile_name,   "weakCompareAndSwapByteVolatile")                                      \
-  do_name(weakCompareAndSwapShort_name,          "weakCompareAndSwapShort")                                             \
-  do_name(weakCompareAndSwapShortAcquire_name,   "weakCompareAndSwapShortAcquire")                                      \
-  do_name(weakCompareAndSwapShortRelease_name,   "weakCompareAndSwapShortRelease")                                      \
-  do_name(weakCompareAndSwapShortVolatile_name,  "weakCompareAndSwapShortVolatile")                                     \
+  do_name(weakCompareAndSetObjectPlain_name,     "weakCompareAndSetObjectPlain")                                        \
+  do_name(weakCompareAndSetObjectAcquire_name,   "weakCompareAndSetObjectAcquire")                                      \
+  do_name(weakCompareAndSetObjectRelease_name,   "weakCompareAndSetObjectRelease")                                      \
+  do_name(weakCompareAndSetObject_name,          "weakCompareAndSetObject")                                             \
+  do_name(weakCompareAndSetLongPlain_name,       "weakCompareAndSetLongPlain")                                          \
+  do_name(weakCompareAndSetLongAcquire_name,     "weakCompareAndSetLongAcquire")                                        \
+  do_name(weakCompareAndSetLongRelease_name,     "weakCompareAndSetLongRelease")                                        \
+  do_name(weakCompareAndSetLong_name,            "weakCompareAndSetLong")                                               \
+  do_name(weakCompareAndSetIntPlain_name,        "weakCompareAndSetIntPlain")                                           \
+  do_name(weakCompareAndSetIntAcquire_name,      "weakCompareAndSetIntAcquire")                                         \
+  do_name(weakCompareAndSetIntRelease_name,      "weakCompareAndSetIntRelease")                                         \
+  do_name(weakCompareAndSetInt_name,             "weakCompareAndSetInt")                                                \
+  do_name(weakCompareAndSetBytePlain_name,       "weakCompareAndSetBytePlain")                                          \
+  do_name(weakCompareAndSetByteAcquire_name,     "weakCompareAndSetByteAcquire")                                        \
+  do_name(weakCompareAndSetByteRelease_name,     "weakCompareAndSetByteRelease")                                        \
+  do_name(weakCompareAndSetByte_name,            "weakCompareAndSetByte")                                               \
+  do_name(weakCompareAndSetShortPlain_name,      "weakCompareAndSetShortPlain")                                         \
+  do_name(weakCompareAndSetShortAcquire_name,    "weakCompareAndSetShortAcquire")                                       \
+  do_name(weakCompareAndSetShortRelease_name,    "weakCompareAndSetShortRelease")                                       \
+  do_name(weakCompareAndSetShort_name,           "weakCompareAndSetShort")                                              \
                                                                                                                         \
-  do_intrinsic(_compareAndSwapObject,             jdk_internal_misc_Unsafe,  compareAndSwapObject_name,             compareAndSwapObject_signature,     F_RN) \
-  do_intrinsic(_compareAndExchangeObjectVolatile, jdk_internal_misc_Unsafe,  compareAndExchangeObjectVolatile_name, compareAndExchangeObject_signature, F_RN) \
+  do_intrinsic(_compareAndSetObject,              jdk_internal_misc_Unsafe,  compareAndSetObject_name,              compareAndSetObject_signature,      F_RN) \
+  do_intrinsic(_compareAndExchangeObject,         jdk_internal_misc_Unsafe,  compareAndExchangeObject_name,         compareAndExchangeObject_signature, F_RN) \
   do_intrinsic(_compareAndExchangeObjectAcquire,  jdk_internal_misc_Unsafe,  compareAndExchangeObjectAcquire_name,  compareAndExchangeObject_signature, F_R)  \
   do_intrinsic(_compareAndExchangeObjectRelease,  jdk_internal_misc_Unsafe,  compareAndExchangeObjectRelease_name,  compareAndExchangeObject_signature, F_R)  \
-  do_intrinsic(_compareAndSwapLong,               jdk_internal_misc_Unsafe,  compareAndSwapLong_name,               compareAndSwapLong_signature,       F_RN) \
-  do_intrinsic(_compareAndExchangeLongVolatile,   jdk_internal_misc_Unsafe,  compareAndExchangeLongVolatile_name,   compareAndExchangeLong_signature,   F_RN) \
+  do_intrinsic(_compareAndSetLong,                jdk_internal_misc_Unsafe,  compareAndSetLong_name,                compareAndSetLong_signature,        F_RN) \
+  do_intrinsic(_compareAndExchangeLong,           jdk_internal_misc_Unsafe,  compareAndExchangeLong_name,           compareAndExchangeLong_signature,   F_RN) \
   do_intrinsic(_compareAndExchangeLongAcquire,    jdk_internal_misc_Unsafe,  compareAndExchangeLongAcquire_name,    compareAndExchangeLong_signature,   F_R)  \
   do_intrinsic(_compareAndExchangeLongRelease,    jdk_internal_misc_Unsafe,  compareAndExchangeLongRelease_name,    compareAndExchangeLong_signature,   F_R)  \
-  do_intrinsic(_compareAndSwapInt,                jdk_internal_misc_Unsafe,  compareAndSwapInt_name,                compareAndSwapInt_signature,        F_RN) \
-  do_intrinsic(_compareAndExchangeIntVolatile,    jdk_internal_misc_Unsafe,  compareAndExchangeIntVolatile_name,    compareAndExchangeInt_signature,    F_RN) \
+  do_intrinsic(_compareAndSetInt,                 jdk_internal_misc_Unsafe,  compareAndSetInt_name,                 compareAndSetInt_signature,         F_RN) \
+  do_intrinsic(_compareAndExchangeInt,            jdk_internal_misc_Unsafe,  compareAndExchangeInt_name,            compareAndExchangeInt_signature,    F_RN) \
   do_intrinsic(_compareAndExchangeIntAcquire,     jdk_internal_misc_Unsafe,  compareAndExchangeIntAcquire_name,     compareAndExchangeInt_signature,    F_R)  \
   do_intrinsic(_compareAndExchangeIntRelease,     jdk_internal_misc_Unsafe,  compareAndExchangeIntRelease_name,     compareAndExchangeInt_signature,    F_R)  \
-  do_intrinsic(_compareAndSwapByte,               jdk_internal_misc_Unsafe,  compareAndSwapByte_name,               compareAndSwapByte_signature,       F_R)  \
-  do_intrinsic(_compareAndExchangeByteVolatile,   jdk_internal_misc_Unsafe,  compareAndExchangeByteVolatile_name,   compareAndExchangeByte_signature,   F_R)  \
+  do_intrinsic(_compareAndSetByte,                jdk_internal_misc_Unsafe,  compareAndSetByte_name,                compareAndSetByte_signature,        F_R)  \
+  do_intrinsic(_compareAndExchangeByte,           jdk_internal_misc_Unsafe,  compareAndExchangeByte_name,           compareAndExchangeByte_signature,   F_R)  \
   do_intrinsic(_compareAndExchangeByteAcquire,    jdk_internal_misc_Unsafe,  compareAndExchangeByteAcquire_name,    compareAndExchangeByte_signature,   F_R)  \
   do_intrinsic(_compareAndExchangeByteRelease,    jdk_internal_misc_Unsafe,  compareAndExchangeByteRelease_name,    compareAndExchangeByte_signature,   F_R)  \
-  do_intrinsic(_compareAndSwapShort,              jdk_internal_misc_Unsafe,  compareAndSwapShort_name,              compareAndSwapShort_signature,      F_R)  \
-  do_intrinsic(_compareAndExchangeShortVolatile,  jdk_internal_misc_Unsafe,  compareAndExchangeShortVolatile_name,  compareAndExchangeShort_signature,  F_R)  \
+  do_intrinsic(_compareAndSetShort,               jdk_internal_misc_Unsafe,  compareAndSetShort_name,               compareAndSetShort_signature,       F_R)  \
+  do_intrinsic(_compareAndExchangeShort,          jdk_internal_misc_Unsafe,  compareAndExchangeShort_name,          compareAndExchangeShort_signature,  F_R)  \
   do_intrinsic(_compareAndExchangeShortAcquire,   jdk_internal_misc_Unsafe,  compareAndExchangeShortAcquire_name,   compareAndExchangeShort_signature,  F_R)  \
   do_intrinsic(_compareAndExchangeShortRelease,   jdk_internal_misc_Unsafe,  compareAndExchangeShortRelease_name,   compareAndExchangeShort_signature,  F_R)  \
                                                                                                                                                              \
-  do_intrinsic(_weakCompareAndSwapObject,         jdk_internal_misc_Unsafe,  weakCompareAndSwapObject_name,         compareAndSwapObject_signature,     F_R) \
-  do_intrinsic(_weakCompareAndSwapObjectAcquire,  jdk_internal_misc_Unsafe,  weakCompareAndSwapObjectAcquire_name,  compareAndSwapObject_signature,     F_R) \
-  do_intrinsic(_weakCompareAndSwapObjectRelease,  jdk_internal_misc_Unsafe,  weakCompareAndSwapObjectRelease_name,  compareAndSwapObject_signature,     F_R) \
-  do_intrinsic(_weakCompareAndSwapObjectVolatile, jdk_internal_misc_Unsafe,  weakCompareAndSwapObjectVolatile_name, compareAndSwapObject_signature,     F_R) \
-  do_intrinsic(_weakCompareAndSwapLong,           jdk_internal_misc_Unsafe,  weakCompareAndSwapLong_name,           compareAndSwapLong_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapLongAcquire,    jdk_internal_misc_Unsafe,  weakCompareAndSwapLongAcquire_name,    compareAndSwapLong_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapLongRelease,    jdk_internal_misc_Unsafe,  weakCompareAndSwapLongRelease_name,    compareAndSwapLong_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapLongVolatile,   jdk_internal_misc_Unsafe,  weakCompareAndSwapLongVolatile_name,   compareAndSwapLong_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapInt,            jdk_internal_misc_Unsafe,  weakCompareAndSwapInt_name,            compareAndSwapInt_signature,        F_R) \
-  do_intrinsic(_weakCompareAndSwapIntAcquire,     jdk_internal_misc_Unsafe,  weakCompareAndSwapIntAcquire_name,     compareAndSwapInt_signature,        F_R) \
-  do_intrinsic(_weakCompareAndSwapIntRelease,     jdk_internal_misc_Unsafe,  weakCompareAndSwapIntRelease_name,     compareAndSwapInt_signature,        F_R) \
-  do_intrinsic(_weakCompareAndSwapIntVolatile,    jdk_internal_misc_Unsafe,  weakCompareAndSwapIntVolatile_name,    compareAndSwapInt_signature,        F_R) \
-  do_intrinsic(_weakCompareAndSwapByte,           jdk_internal_misc_Unsafe,  weakCompareAndSwapByte_name,           compareAndSwapByte_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapByteAcquire,    jdk_internal_misc_Unsafe,  weakCompareAndSwapByteAcquire_name,    compareAndSwapByte_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapByteRelease,    jdk_internal_misc_Unsafe,  weakCompareAndSwapByteRelease_name,    compareAndSwapByte_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapByteVolatile,   jdk_internal_misc_Unsafe,  weakCompareAndSwapByteVolatile_name,   compareAndSwapByte_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapShort,          jdk_internal_misc_Unsafe,  weakCompareAndSwapShort_name,          compareAndSwapShort_signature,      F_R) \
-  do_intrinsic(_weakCompareAndSwapShortAcquire,   jdk_internal_misc_Unsafe,  weakCompareAndSwapShortAcquire_name,   compareAndSwapShort_signature,      F_R) \
-  do_intrinsic(_weakCompareAndSwapShortRelease,   jdk_internal_misc_Unsafe,  weakCompareAndSwapShortRelease_name,   compareAndSwapShort_signature,      F_R) \
-  do_intrinsic(_weakCompareAndSwapShortVolatile,  jdk_internal_misc_Unsafe,  weakCompareAndSwapShortVolatile_name,  compareAndSwapShort_signature,      F_R) \
+  do_intrinsic(_weakCompareAndSetObjectPlain,     jdk_internal_misc_Unsafe,  weakCompareAndSetObjectPlain_name,     compareAndSetObject_signature,      F_R) \
+  do_intrinsic(_weakCompareAndSetObjectAcquire,   jdk_internal_misc_Unsafe,  weakCompareAndSetObjectAcquire_name,   compareAndSetObject_signature,      F_R) \
+  do_intrinsic(_weakCompareAndSetObjectRelease,   jdk_internal_misc_Unsafe,  weakCompareAndSetObjectRelease_name,   compareAndSetObject_signature,      F_R) \
+  do_intrinsic(_weakCompareAndSetObject,          jdk_internal_misc_Unsafe,  weakCompareAndSetObject_name,          compareAndSetObject_signature,      F_R) \
+  do_intrinsic(_weakCompareAndSetLongPlain,       jdk_internal_misc_Unsafe,  weakCompareAndSetLongPlain_name,       compareAndSetLong_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetLongAcquire,     jdk_internal_misc_Unsafe,  weakCompareAndSetLongAcquire_name,     compareAndSetLong_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetLongRelease,     jdk_internal_misc_Unsafe,  weakCompareAndSetLongRelease_name,     compareAndSetLong_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetLong,            jdk_internal_misc_Unsafe,  weakCompareAndSetLong_name,            compareAndSetLong_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetIntPlain,        jdk_internal_misc_Unsafe,  weakCompareAndSetIntPlain_name,        compareAndSetInt_signature,         F_R) \
+  do_intrinsic(_weakCompareAndSetIntAcquire,      jdk_internal_misc_Unsafe,  weakCompareAndSetIntAcquire_name,      compareAndSetInt_signature,         F_R) \
+  do_intrinsic(_weakCompareAndSetIntRelease,      jdk_internal_misc_Unsafe,  weakCompareAndSetIntRelease_name,      compareAndSetInt_signature,         F_R) \
+  do_intrinsic(_weakCompareAndSetInt,             jdk_internal_misc_Unsafe,  weakCompareAndSetInt_name,             compareAndSetInt_signature,         F_R) \
+  do_intrinsic(_weakCompareAndSetBytePlain,       jdk_internal_misc_Unsafe,  weakCompareAndSetBytePlain_name,       compareAndSetByte_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetByteAcquire,     jdk_internal_misc_Unsafe,  weakCompareAndSetByteAcquire_name,     compareAndSetByte_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetByteRelease,     jdk_internal_misc_Unsafe,  weakCompareAndSetByteRelease_name,     compareAndSetByte_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetByte,            jdk_internal_misc_Unsafe,  weakCompareAndSetByte_name,            compareAndSetByte_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetShortPlain,      jdk_internal_misc_Unsafe,  weakCompareAndSetShortPlain_name,      compareAndSetShort_signature,       F_R) \
+  do_intrinsic(_weakCompareAndSetShortAcquire,    jdk_internal_misc_Unsafe,  weakCompareAndSetShortAcquire_name,    compareAndSetShort_signature,       F_R) \
+  do_intrinsic(_weakCompareAndSetShortRelease,    jdk_internal_misc_Unsafe,  weakCompareAndSetShortRelease_name,    compareAndSetShort_signature,       F_R) \
+  do_intrinsic(_weakCompareAndSetShort,           jdk_internal_misc_Unsafe,  weakCompareAndSetShort_name,           compareAndSetShort_signature,       F_R) \
                            \
   do_intrinsic(_getAndAddInt,             jdk_internal_misc_Unsafe,     getAndAddInt_name, getAndAddInt_signature, F_R)       \
    do_name(     getAndAddInt_name,                                      "getAndAddInt")                                       \
--- a/hotspot/src/share/vm/logging/logTag.hpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/logging/logTag.hpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -82,7 +82,7 @@
   LOG_TAG(metadata) \
   LOG_TAG(metaspace) \
   LOG_TAG(mmu) \
-  LOG_TAG(modules) \
+  LOG_TAG(module) \
   LOG_TAG(monitorinflation) \
   LOG_TAG(monitormismatch) \
   LOG_TAG(nmethod) \
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -2331,21 +2331,21 @@
              name()->as_C_string(), loader_data->loader_name());
     }
 
-    if (log_is_enabled(Debug, modules)) {
+    if (log_is_enabled(Debug, module)) {
       ResourceMark rm;
       ModuleEntry* m = _package_entry->module();
-      log_trace(modules)("Setting package: class: %s, package: %s, loader: %s, module: %s",
-                         external_name(),
-                         pkg_name->as_C_string(),
-                         loader_data->loader_name(),
-                         (m->is_named() ? m->name()->as_C_string() : UNNAMED_MODULE));
+      log_trace(module)("Setting package: class: %s, package: %s, loader: %s, module: %s",
+                        external_name(),
+                        pkg_name->as_C_string(),
+                        loader_data->loader_name(),
+                        (m->is_named() ? m->name()->as_C_string() : UNNAMED_MODULE));
     }
   } else {
     ResourceMark rm;
-    log_trace(modules)("Setting package: class: %s, package: unnamed, loader: %s, module: %s",
-                       external_name(),
-                       (loader_data != NULL) ? loader_data->loader_name() : "NULL",
-                       UNNAMED_MODULE);
+    log_trace(module)("Setting package: class: %s, package: unnamed, loader: %s, module: %s",
+                      external_name(),
+                      (loader_data != NULL) ? loader_data->loader_name() : "NULL",
+                      UNNAMED_MODULE);
   }
 }
 
--- a/hotspot/src/share/vm/opto/c2compiler.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -244,8 +244,8 @@
     if (!Matcher::match_rule_supported(Op_ReverseBytesL)) return false;
     break;
 
-  /* CompareAndSwap, Object: */
-  case vmIntrinsics::_compareAndSwapObject:
+  /* CompareAndSet, Object: */
+  case vmIntrinsics::_compareAndSetObject:
 #ifdef _LP64
     if ( UseCompressedOops && !Matcher::match_rule_supported(Op_CompareAndSwapN)) return false;
     if (!UseCompressedOops && !Matcher::match_rule_supported(Op_CompareAndSwapP)) return false;
@@ -253,10 +253,10 @@
     if (!Matcher::match_rule_supported(Op_CompareAndSwapP)) return false;
 #endif
     break;
-  case vmIntrinsics::_weakCompareAndSwapObject:
-  case vmIntrinsics::_weakCompareAndSwapObjectAcquire:
-  case vmIntrinsics::_weakCompareAndSwapObjectRelease:
-  case vmIntrinsics::_weakCompareAndSwapObjectVolatile:
+  case vmIntrinsics::_weakCompareAndSetObjectPlain:
+  case vmIntrinsics::_weakCompareAndSetObjectAcquire:
+  case vmIntrinsics::_weakCompareAndSetObjectRelease:
+  case vmIntrinsics::_weakCompareAndSetObject:
 #ifdef _LP64
     if ( UseCompressedOops && !Matcher::match_rule_supported(Op_WeakCompareAndSwapN)) return false;
     if (!UseCompressedOops && !Matcher::match_rule_supported(Op_WeakCompareAndSwapP)) return false;
@@ -264,52 +264,52 @@
     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapP)) return false;
 #endif
     break;
-  /* CompareAndSwap, Long: */
-  case vmIntrinsics::_compareAndSwapLong:
+  /* CompareAndSet, Long: */
+  case vmIntrinsics::_compareAndSetLong:
     if (!Matcher::match_rule_supported(Op_CompareAndSwapL)) return false;
     break;
-  case vmIntrinsics::_weakCompareAndSwapLong:
-  case vmIntrinsics::_weakCompareAndSwapLongAcquire:
-  case vmIntrinsics::_weakCompareAndSwapLongRelease:
-  case vmIntrinsics::_weakCompareAndSwapLongVolatile:
+  case vmIntrinsics::_weakCompareAndSetLongPlain:
+  case vmIntrinsics::_weakCompareAndSetLongAcquire:
+  case vmIntrinsics::_weakCompareAndSetLongRelease:
+  case vmIntrinsics::_weakCompareAndSetLong:
     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapL)) return false;
     break;
 
-  /* CompareAndSwap, Int: */
-  case vmIntrinsics::_compareAndSwapInt:
+  /* CompareAndSet, Int: */
+  case vmIntrinsics::_compareAndSetInt:
     if (!Matcher::match_rule_supported(Op_CompareAndSwapI)) return false;
     break;
-  case vmIntrinsics::_weakCompareAndSwapInt:
-  case vmIntrinsics::_weakCompareAndSwapIntAcquire:
-  case vmIntrinsics::_weakCompareAndSwapIntRelease:
-  case vmIntrinsics::_weakCompareAndSwapIntVolatile:
+  case vmIntrinsics::_weakCompareAndSetIntPlain:
+  case vmIntrinsics::_weakCompareAndSetIntAcquire:
+  case vmIntrinsics::_weakCompareAndSetIntRelease:
+  case vmIntrinsics::_weakCompareAndSetInt:
     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapL)) return false;
     break;
 
-  /* CompareAndSwap, Byte: */
-  case vmIntrinsics::_compareAndSwapByte:
+  /* CompareAndSet, Byte: */
+  case vmIntrinsics::_compareAndSetByte:
     if (!Matcher::match_rule_supported(Op_CompareAndSwapB)) return false;
     break;
-  case vmIntrinsics::_weakCompareAndSwapByte:
-  case vmIntrinsics::_weakCompareAndSwapByteAcquire:
-  case vmIntrinsics::_weakCompareAndSwapByteRelease:
-  case vmIntrinsics::_weakCompareAndSwapByteVolatile:
+  case vmIntrinsics::_weakCompareAndSetBytePlain:
+  case vmIntrinsics::_weakCompareAndSetByteAcquire:
+  case vmIntrinsics::_weakCompareAndSetByteRelease:
+  case vmIntrinsics::_weakCompareAndSetByte:
     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapB)) return false;
     break;
 
-  /* CompareAndSwap, Short: */
-  case vmIntrinsics::_compareAndSwapShort:
+  /* CompareAndSet, Short: */
+  case vmIntrinsics::_compareAndSetShort:
     if (!Matcher::match_rule_supported(Op_CompareAndSwapS)) return false;
     break;
-  case vmIntrinsics::_weakCompareAndSwapShort:
-  case vmIntrinsics::_weakCompareAndSwapShortAcquire:
-  case vmIntrinsics::_weakCompareAndSwapShortRelease:
-  case vmIntrinsics::_weakCompareAndSwapShortVolatile:
+  case vmIntrinsics::_weakCompareAndSetShortPlain:
+  case vmIntrinsics::_weakCompareAndSetShortAcquire:
+  case vmIntrinsics::_weakCompareAndSetShortRelease:
+  case vmIntrinsics::_weakCompareAndSetShort:
     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapS)) return false;
     break;
 
   /* CompareAndExchange, Object: */
-  case vmIntrinsics::_compareAndExchangeObjectVolatile:
+  case vmIntrinsics::_compareAndExchangeObject:
   case vmIntrinsics::_compareAndExchangeObjectAcquire:
   case vmIntrinsics::_compareAndExchangeObjectRelease:
 #ifdef _LP64
@@ -321,28 +321,28 @@
     break;
 
   /* CompareAndExchange, Long: */
-  case vmIntrinsics::_compareAndExchangeLongVolatile:
+  case vmIntrinsics::_compareAndExchangeLong:
   case vmIntrinsics::_compareAndExchangeLongAcquire:
   case vmIntrinsics::_compareAndExchangeLongRelease:
     if (!Matcher::match_rule_supported(Op_CompareAndExchangeL)) return false;
     break;
 
   /* CompareAndExchange, Int: */
-  case vmIntrinsics::_compareAndExchangeIntVolatile:
+  case vmIntrinsics::_compareAndExchangeInt:
   case vmIntrinsics::_compareAndExchangeIntAcquire:
   case vmIntrinsics::_compareAndExchangeIntRelease:
     if (!Matcher::match_rule_supported(Op_CompareAndExchangeI)) return false;
     break;
 
   /* CompareAndExchange, Byte: */
-  case vmIntrinsics::_compareAndExchangeByteVolatile:
+  case vmIntrinsics::_compareAndExchangeByte:
   case vmIntrinsics::_compareAndExchangeByteAcquire:
   case vmIntrinsics::_compareAndExchangeByteRelease:
     if (!Matcher::match_rule_supported(Op_CompareAndExchangeB)) return false;
     break;
 
   /* CompareAndExchange, Short: */
-  case vmIntrinsics::_compareAndExchangeShortVolatile:
+  case vmIntrinsics::_compareAndExchangeShort:
   case vmIntrinsics::_compareAndExchangeShortAcquire:
   case vmIntrinsics::_compareAndExchangeShortRelease:
     if (!Matcher::match_rule_supported(Op_CompareAndExchangeS)) return false;
--- a/hotspot/src/share/vm/opto/library_call.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -649,46 +649,46 @@
   case vmIntrinsics::_putFloatOpaque:           return inline_unsafe_access( is_store, T_FLOAT,    Opaque, false);
   case vmIntrinsics::_putDoubleOpaque:          return inline_unsafe_access( is_store, T_DOUBLE,   Opaque, false);
 
-  case vmIntrinsics::_compareAndSwapObject:             return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap,      Volatile);
-  case vmIntrinsics::_compareAndSwapByte:               return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap,      Volatile);
-  case vmIntrinsics::_compareAndSwapShort:              return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap,      Volatile);
-  case vmIntrinsics::_compareAndSwapInt:                return inline_unsafe_load_store(T_INT,    LS_cmp_swap,      Volatile);
-  case vmIntrinsics::_compareAndSwapLong:               return inline_unsafe_load_store(T_LONG,   LS_cmp_swap,      Volatile);
-
-  case vmIntrinsics::_weakCompareAndSwapObject:         return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Relaxed);
-  case vmIntrinsics::_weakCompareAndSwapObjectAcquire:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Acquire);
-  case vmIntrinsics::_weakCompareAndSwapObjectRelease:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Release);
-  case vmIntrinsics::_weakCompareAndSwapObjectVolatile: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Volatile);
-  case vmIntrinsics::_weakCompareAndSwapByte:           return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Relaxed);
-  case vmIntrinsics::_weakCompareAndSwapByteAcquire:    return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Acquire);
-  case vmIntrinsics::_weakCompareAndSwapByteRelease:    return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Release);
-  case vmIntrinsics::_weakCompareAndSwapByteVolatile:   return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Volatile);
-  case vmIntrinsics::_weakCompareAndSwapShort:          return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Relaxed);
-  case vmIntrinsics::_weakCompareAndSwapShortAcquire:   return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Acquire);
-  case vmIntrinsics::_weakCompareAndSwapShortRelease:   return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Release);
-  case vmIntrinsics::_weakCompareAndSwapShortVolatile:  return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Volatile);
-  case vmIntrinsics::_weakCompareAndSwapInt:            return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Relaxed);
-  case vmIntrinsics::_weakCompareAndSwapIntAcquire:     return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Acquire);
-  case vmIntrinsics::_weakCompareAndSwapIntRelease:     return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Release);
-  case vmIntrinsics::_weakCompareAndSwapIntVolatile:    return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Volatile);
-  case vmIntrinsics::_weakCompareAndSwapLong:           return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Relaxed);
-  case vmIntrinsics::_weakCompareAndSwapLongAcquire:    return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Acquire);
-  case vmIntrinsics::_weakCompareAndSwapLongRelease:    return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Release);
-  case vmIntrinsics::_weakCompareAndSwapLongVolatile:   return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Volatile);
-
-  case vmIntrinsics::_compareAndExchangeObjectVolatile: return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  Volatile);
+  case vmIntrinsics::_compareAndSetObject:              return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap,      Volatile);
+  case vmIntrinsics::_compareAndSetByte:                return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap,      Volatile);
+  case vmIntrinsics::_compareAndSetShort:               return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap,      Volatile);
+  case vmIntrinsics::_compareAndSetInt:                 return inline_unsafe_load_store(T_INT,    LS_cmp_swap,      Volatile);
+  case vmIntrinsics::_compareAndSetLong:                return inline_unsafe_load_store(T_LONG,   LS_cmp_swap,      Volatile);
+
+  case vmIntrinsics::_weakCompareAndSetObjectPlain:     return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Relaxed);
+  case vmIntrinsics::_weakCompareAndSetObjectAcquire:   return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Acquire);
+  case vmIntrinsics::_weakCompareAndSetObjectRelease:   return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSetObject:          return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Volatile);
+  case vmIntrinsics::_weakCompareAndSetBytePlain:       return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Relaxed);
+  case vmIntrinsics::_weakCompareAndSetByteAcquire:     return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Acquire);
+  case vmIntrinsics::_weakCompareAndSetByteRelease:     return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSetByte:            return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Volatile);
+  case vmIntrinsics::_weakCompareAndSetShortPlain:      return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Relaxed);
+  case vmIntrinsics::_weakCompareAndSetShortAcquire:    return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Acquire);
+  case vmIntrinsics::_weakCompareAndSetShortRelease:    return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSetShort:           return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Volatile);
+  case vmIntrinsics::_weakCompareAndSetIntPlain:        return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Relaxed);
+  case vmIntrinsics::_weakCompareAndSetIntAcquire:      return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Acquire);
+  case vmIntrinsics::_weakCompareAndSetIntRelease:      return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSetInt:             return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Volatile);
+  case vmIntrinsics::_weakCompareAndSetLongPlain:       return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Relaxed);
+  case vmIntrinsics::_weakCompareAndSetLongAcquire:     return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Acquire);
+  case vmIntrinsics::_weakCompareAndSetLongRelease:     return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSetLong:            return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Volatile);
+
+  case vmIntrinsics::_compareAndExchangeObject:         return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  Volatile);
   case vmIntrinsics::_compareAndExchangeObjectAcquire:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  Acquire);
   case vmIntrinsics::_compareAndExchangeObjectRelease:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  Release);
-  case vmIntrinsics::_compareAndExchangeByteVolatile:   return inline_unsafe_load_store(T_BYTE,   LS_cmp_exchange,  Volatile);
+  case vmIntrinsics::_compareAndExchangeByte:           return inline_unsafe_load_store(T_BYTE,   LS_cmp_exchange,  Volatile);
   case vmIntrinsics::_compareAndExchangeByteAcquire:    return inline_unsafe_load_store(T_BYTE,   LS_cmp_exchange,  Acquire);
   case vmIntrinsics::_compareAndExchangeByteRelease:    return inline_unsafe_load_store(T_BYTE,   LS_cmp_exchange,  Release);
-  case vmIntrinsics::_compareAndExchangeShortVolatile:  return inline_unsafe_load_store(T_SHORT,  LS_cmp_exchange,  Volatile);
+  case vmIntrinsics::_compareAndExchangeShort:          return inline_unsafe_load_store(T_SHORT,  LS_cmp_exchange,  Volatile);
   case vmIntrinsics::_compareAndExchangeShortAcquire:   return inline_unsafe_load_store(T_SHORT,  LS_cmp_exchange,  Acquire);
   case vmIntrinsics::_compareAndExchangeShortRelease:   return inline_unsafe_load_store(T_SHORT,  LS_cmp_exchange,  Release);
-  case vmIntrinsics::_compareAndExchangeIntVolatile:    return inline_unsafe_load_store(T_INT,    LS_cmp_exchange,  Volatile);
+  case vmIntrinsics::_compareAndExchangeInt:            return inline_unsafe_load_store(T_INT,    LS_cmp_exchange,  Volatile);
   case vmIntrinsics::_compareAndExchangeIntAcquire:     return inline_unsafe_load_store(T_INT,    LS_cmp_exchange,  Acquire);
   case vmIntrinsics::_compareAndExchangeIntRelease:     return inline_unsafe_load_store(T_INT,    LS_cmp_exchange,  Release);
-  case vmIntrinsics::_compareAndExchangeLongVolatile:   return inline_unsafe_load_store(T_LONG,   LS_cmp_exchange,  Volatile);
+  case vmIntrinsics::_compareAndExchangeLong:           return inline_unsafe_load_store(T_LONG,   LS_cmp_exchange,  Volatile);
   case vmIntrinsics::_compareAndExchangeLongAcquire:    return inline_unsafe_load_store(T_LONG,   LS_cmp_exchange,  Acquire);
   case vmIntrinsics::_compareAndExchangeLongRelease:    return inline_unsafe_load_store(T_LONG,   LS_cmp_exchange,  Release);
 
@@ -2587,23 +2587,26 @@
 //
 // LS_cmp_swap:
 //
-//   boolean compareAndSwapObject(Object o, long offset, Object expected, Object x);
-//   boolean compareAndSwapInt(   Object o, long offset, int    expected, int    x);
-//   boolean compareAndSwapLong(  Object o, long offset, long   expected, long   x);
+//   boolean compareAndSetObject(Object o, long offset, Object expected, Object x);
+//   boolean compareAndSetInt(   Object o, long offset, int    expected, int    x);
+//   boolean compareAndSetLong(  Object o, long offset, long   expected, long   x);
 //
 // LS_cmp_swap_weak:
 //
-//   boolean weakCompareAndSwapObject(       Object o, long offset, Object expected, Object x);
-//   boolean weakCompareAndSwapObjectAcquire(Object o, long offset, Object expected, Object x);
-//   boolean weakCompareAndSwapObjectRelease(Object o, long offset, Object expected, Object x);
+//   boolean weakCompareAndSetObject(       Object o, long offset, Object expected, Object x);
+//   boolean weakCompareAndSetObjectPlain(  Object o, long offset, Object expected, Object x);
+//   boolean weakCompareAndSetObjectAcquire(Object o, long offset, Object expected, Object x);
+//   boolean weakCompareAndSetObjectRelease(Object o, long offset, Object expected, Object x);
 //
-//   boolean weakCompareAndSwapInt(          Object o, long offset, int    expected, int    x);
-//   boolean weakCompareAndSwapIntAcquire(   Object o, long offset, int    expected, int    x);
-//   boolean weakCompareAndSwapIntRelease(   Object o, long offset, int    expected, int    x);
+//   boolean weakCompareAndSetInt(          Object o, long offset, int    expected, int    x);
+//   boolean weakCompareAndSetIntPlain(     Object o, long offset, int    expected, int    x);
+//   boolean weakCompareAndSetIntAcquire(   Object o, long offset, int    expected, int    x);
+//   boolean weakCompareAndSetIntRelease(   Object o, long offset, int    expected, int    x);
 //
-//   boolean weakCompareAndSwapLong(         Object o, long offset, long   expected, long   x);
-//   boolean weakCompareAndSwapLongAcquire(  Object o, long offset, long   expected, long   x);
-//   boolean weakCompareAndSwapLongRelease(  Object o, long offset, long   expected, long   x);
+//   boolean weakCompareAndSetLong(         Object o, long offset, long   expected, long   x);
+//   boolean weakCompareAndSetLongPlain(    Object o, long offset, long   expected, long   x);
+//   boolean weakCompareAndSetLongAcquire(  Object o, long offset, long   expected, long   x);
+//   boolean weakCompareAndSetLongRelease(  Object o, long offset, long   expected, long   x);
 //
 // LS_cmp_exchange:
 //
@@ -4965,7 +4968,7 @@
   // See arraycopy_restore_alloc_state() comment
   // if alloc == NULL we don't have to worry about a tightly coupled allocation so we can emit all needed guards
   // if saved_jvms != NULL (then alloc != NULL) then we can handle guards and a tightly coupled allocation
-  // if saved_jvms == NULL and alloc != NULL, we can’t emit any guards
+  // if saved_jvms == NULL and alloc != NULL, we can't emit any guards
   bool can_emit_guards = (alloc == NULL || saved_jvms != NULL);
 
   // The following tests must be performed
--- a/hotspot/src/share/vm/opto/parse3.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/opto/parse3.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -146,8 +146,16 @@
 
 
 void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) {
+  BasicType bt = field->layout_type();
+
   // Does this field have a constant value?  If so, just push the value.
-  if (field->is_constant()) {
+  if (field->is_constant() &&
+      // Keep consistent with types found by ciTypeFlow: for an
+      // unloaded field type, ciTypeFlow::StateVector::do_getstatic()
+      // speculates the field is null. The code in the rest of this
+      // method does the same. We must not bypass it and use a non
+      // null constant here.
+      (bt != T_OBJECT || field->type()->is_loaded())) {
     // final or stable field
     Node* con = make_constant_from_field(field, obj);
     if (con != NULL) {
@@ -163,7 +171,6 @@
   int offset = field->offset_in_bytes();
   const TypePtr* adr_type = C->alias_type(field)->adr_type();
   Node *adr = basic_plus_adr(obj, obj, offset);
-  BasicType bt = field->layout_type();
 
   // Build the resultant type of the load
   const Type *type;
--- a/hotspot/src/share/vm/prims/jvmti.xml	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/prims/jvmti.xml	Wed Jul 05 23:25:53 2017 +0200
@@ -6814,7 +6814,9 @@
         <functionlink id="AddModuleReads"/>, <functionlink id="AddModuleExports"/>,
         <functionlink id="AddModuleOpens"/>, <functionlink id="AddModuleUses"/>,
         and <functionlink id="AddModuleProvides"/>. If a module is not modifiable
-        then the module can not be updated with these functions.
+        then the module can not be updated with these functions. The result of
+        this function is always <code>JNI_TRUE</code> when called to determine
+        if an unnamed module is modifiable.
       </description>
       <origin>new</origin>
       <capabilities>
--- a/hotspot/src/share/vm/prims/jvmtiExport.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -54,7 +54,6 @@
 #include "runtime/os.inline.hpp"
 #include "runtime/thread.inline.hpp"
 #include "runtime/vframe.hpp"
-#include "services/attachListener.hpp"
 #include "services/serviceUtil.hpp"
 #include "utilities/macros.hpp"
 #if INCLUDE_ALL_GCS
@@ -2479,15 +2478,6 @@
   typedef jint (JNICALL *OnAttachEntry_t)(JavaVM*, char *, void *);
 }
 
-jint JvmtiExport::load_agent_library(AttachOperation* op, outputStream* st) {
-  // get agent name and options
-  const char* agent = op->arg(0);
-  const char* absParam = op->arg(1);
-  const char* options = op->arg(2);
-
-  return load_agent_library(agent, absParam, options, st);
-}
-
 jint JvmtiExport::load_agent_library(const char *agent, const char *absParam,
                                      const char *options, outputStream* st) {
   char ebuf[1024];
--- a/hotspot/src/share/vm/prims/jvmtiExport.hpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/prims/jvmtiExport.hpp	Wed Jul 05 23:25:53 2017 +0200
@@ -45,7 +45,6 @@
 class JvmtiManageCapabilities;
 class JvmtiEnv;
 class JvmtiThreadState;
-class AttachOperation;
 
 #define JVMTI_SUPPORT_FLAG(key)                                           \
   private:                                                                \
@@ -396,7 +395,6 @@
 #if INCLUDE_SERVICES
   // attach support
   static jint load_agent_library(const char *agent, const char *absParam, const char *options, outputStream* out) NOT_JVMTI_RETURN_(JNI_ERR);
-  static jint load_agent_library(AttachOperation* op, outputStream* out) NOT_JVMTI_RETURN_(JNI_ERR);
 #endif
 
   // SetNativeMethodPrefix support
--- a/hotspot/src/share/vm/prims/unsafe.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/prims/unsafe.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -378,7 +378,7 @@
 // On platforms which do not support atomic compare-and-swap of jlong (8 byte)
 // values we have to use a lock-based scheme to enforce atomicity. This has to be
 // applied to all Unsafe operations that set the value of a jlong field. Even so
-// the compareAndSwapLong operation will not be atomic with respect to direct stores
+// the compareAndSetLong operation will not be atomic with respect to direct stores
 // to the field from Java code. It is important therefore that any Java code that
 // utilizes these Unsafe jlong operations does not perform direct stores. To permit
 // direct loads of the field from Java code we must also use Atomic::store within the
@@ -1013,7 +1013,7 @@
 #endif
 } UNSAFE_END
 
-UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject e_h, jobject x_h)) {
+UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject e_h, jobject x_h)) {
   oop x = JNIHandles::resolve(x_h);
   oop e = JNIHandles::resolve(e_h);
   oop p = JNIHandles::resolve(obj);
@@ -1028,14 +1028,14 @@
   return true;
 } UNSAFE_END
 
-UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint e, jint x)) {
+UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSetInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint e, jint x)) {
   oop p = JNIHandles::resolve(obj);
   jint* addr = (jint *)index_oop_from_field_offset_long(p, offset);
 
   return (jint)(Atomic::cmpxchg(x, addr, e)) == e;
 } UNSAFE_END
 
-UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong e, jlong x)) {
+UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSetLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong e, jlong x)) {
   Handle p(THREAD, JNIHandles::resolve(obj));
   jlong* addr = (jlong*)index_oop_from_field_offset_long(p(), offset);
 
@@ -1194,12 +1194,12 @@
     {CC "defineClass0",       CC "(" DC_Args ")" CLS,    FN_PTR(Unsafe_DefineClass0)},
     {CC "allocateInstance",   CC "(" CLS ")" OBJ,        FN_PTR(Unsafe_AllocateInstance)},
     {CC "throwException",     CC "(" THR ")V",           FN_PTR(Unsafe_ThrowException)},
-    {CC "compareAndSwapObject", CC "(" OBJ "J" OBJ "" OBJ ")Z", FN_PTR(Unsafe_CompareAndSwapObject)},
-    {CC "compareAndSwapInt",  CC "(" OBJ "J""I""I"")Z",  FN_PTR(Unsafe_CompareAndSwapInt)},
-    {CC "compareAndSwapLong", CC "(" OBJ "J""J""J"")Z",  FN_PTR(Unsafe_CompareAndSwapLong)},
-    {CC "compareAndExchangeObjectVolatile", CC "(" OBJ "J" OBJ "" OBJ ")" OBJ, FN_PTR(Unsafe_CompareAndExchangeObject)},
-    {CC "compareAndExchangeIntVolatile",  CC "(" OBJ "J""I""I"")I", FN_PTR(Unsafe_CompareAndExchangeInt)},
-    {CC "compareAndExchangeLongVolatile", CC "(" OBJ "J""J""J"")J", FN_PTR(Unsafe_CompareAndExchangeLong)},
+    {CC "compareAndSetObject",CC "(" OBJ "J" OBJ "" OBJ ")Z", FN_PTR(Unsafe_CompareAndSetObject)},
+    {CC "compareAndSetInt",   CC "(" OBJ "J""I""I"")Z",  FN_PTR(Unsafe_CompareAndSetInt)},
+    {CC "compareAndSetLong",  CC "(" OBJ "J""J""J"")Z",  FN_PTR(Unsafe_CompareAndSetLong)},
+    {CC "compareAndExchangeObject", CC "(" OBJ "J" OBJ "" OBJ ")" OBJ, FN_PTR(Unsafe_CompareAndExchangeObject)},
+    {CC "compareAndExchangeInt",  CC "(" OBJ "J""I""I"")I", FN_PTR(Unsafe_CompareAndExchangeInt)},
+    {CC "compareAndExchangeLong", CC "(" OBJ "J""J""J"")J", FN_PTR(Unsafe_CompareAndExchangeLong)},
 
     {CC "park",               CC "(ZJ)V",                FN_PTR(Unsafe_Park)},
     {CC "unpark",             CC "(" OBJ ")V",           FN_PTR(Unsafe_Unpark)},
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -2762,11 +2762,14 @@
         build_jvm_args(option->optionString);
     }
 
-    // -verbose:[class/gc/jni]
+    // -verbose:[class/module/gc/jni]
     if (match_option(option, "-verbose", &tail)) {
       if (!strcmp(tail, ":class") || !strcmp(tail, "")) {
         LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, load));
         LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, unload));
+      } else if (!strcmp(tail, ":module")) {
+        LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(module, load));
+        LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(module, unload));
       } else if (!strcmp(tail, ":gc")) {
         LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc));
       } else if (!strcmp(tail, ":jni")) {
--- a/hotspot/src/share/vm/runtime/globals.hpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Wed Jul 05 23:25:53 2017 +0200
@@ -3848,6 +3848,9 @@
   product(bool, StartAttachListener, false,                                 \
           "Always start Attach Listener at VM startup")                     \
                                                                             \
+  product(bool, EnableDynamicAgentLoading, true,                            \
+          "Allow tools to load agents with the attach mechanism")           \
+                                                                            \
   manageable(bool, PrintConcurrentLocks, false,                             \
           "Print java.util.concurrent locks in thread dump")                \
                                                                             \
--- a/hotspot/src/share/vm/runtime/thread.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/runtime/thread.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -3404,7 +3404,7 @@
 //
 //     After phase 2, The VM will begin search classes from -Xbootclasspath/a.
 static void call_initPhase2(TRAPS) {
-  TraceTime timer("Phase2 initialization", TRACETIME_LOG(Info, modules, startuptime));
+  TraceTime timer("Phase2 initialization", TRACETIME_LOG(Info, module, startuptime));
 
   Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::java_lang_System(), true, CHECK);
   instanceKlassHandle klass (THREAD, k);
--- a/hotspot/src/share/vm/services/attachListener.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/services/attachListener.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -100,6 +100,36 @@
   return JNI_OK;
 }
 
+// Implementation of "load" command.
+static jint load_agent(AttachOperation* op, outputStream* out) {
+  // get agent name and options
+  const char* agent = op->arg(0);
+  const char* absParam = op->arg(1);
+  const char* options = op->arg(2);
+
+  // If loading a java agent then need to ensure that the java.instrument module is loaded
+  if (strcmp(agent, "instrument") == 0) {
+    Thread* THREAD = Thread::current();
+    ResourceMark rm(THREAD);
+    HandleMark hm(THREAD);
+    JavaValue result(T_OBJECT);
+    Handle h_module_name = java_lang_String::create_from_str("java.instrument", THREAD);
+    JavaCalls::call_static(&result,
+                           SystemDictionary::module_Modules_klass(),
+                           vmSymbols::loadModule_name(),
+                           vmSymbols::loadModule_signature(),
+                           h_module_name,
+                           THREAD);
+    if (HAS_PENDING_EXCEPTION) {
+      java_lang_Throwable::print(PENDING_EXCEPTION, out);
+      CLEAR_PENDING_EXCEPTION;
+      return JNI_ERR;
+    }
+  }
+
+  return JvmtiExport::load_agent_library(agent, absParam, options, out);
+}
+
 // Implementation of "properties" command.
 // See also: PrintSystemPropertiesDCmd class
 static jint get_system_properties(AttachOperation* op, outputStream* out) {
@@ -282,7 +312,7 @@
   { "agentProperties",  get_agent_properties },
   { "datadump",         data_dump },
   { "dumpheap",         dump_heap },
-  { "load",             JvmtiExport::load_agent_library },
+  { "load",             load_agent },
   { "properties",       get_system_properties },
   { "threaddump",       thread_dump },
   { "inspectheap",      heap_inspection },
@@ -321,6 +351,10 @@
     // handle special detachall operation
     if (strcmp(op->name(), AttachOperation::detachall_operation_name()) == 0) {
       AttachListener::detachall();
+    } else if (!EnableDynamicAgentLoading && strcmp(op->name(), "load") == 0) {
+      st.print("Dynamic agent loading is not enabled. "
+               "Use -XX:+EnableDynamicAgentLoading to launch target VM.");
+      res = JNI_ERR;
     } else {
       // find the function to dispatch too
       AttachOperationFunctionInfo* info = NULL;
--- a/hotspot/src/share/vm/services/diagnosticCommand.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/services/diagnosticCommand.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -42,6 +42,21 @@
 #include "utilities/macros.hpp"
 #include "oops/objArrayOop.inline.hpp"
 
+
+static void loadAgentModule(TRAPS) {
+  ResourceMark rm(THREAD);
+  HandleMark hm(THREAD);
+
+  JavaValue result(T_OBJECT);
+  Handle h_module_name = java_lang_String::create_from_str("jdk.management.agent", CHECK);
+  JavaCalls::call_static(&result,
+                         SystemDictionary::module_Modules_klass(),
+                         vmSymbols::loadModule_name(),
+                         vmSymbols::loadModule_signature(),
+                         h_module_name,
+                         THREAD);
+}
+
 void DCmdRegistrant::register_dcmds(){
   // Registration of the diagnostic commands
   // First argument specifies which interfaces will export the command
@@ -753,6 +768,7 @@
     // the remote management server.
     // throw java.lang.NoSuchMethodError if the method doesn't exist
 
+    loadAgentModule(CHECK);
     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
     instanceKlassHandle ik (THREAD, k);
@@ -826,6 +842,7 @@
     // the local management server
     // throw java.lang.NoSuchMethodError if method doesn't exist
 
+    loadAgentModule(CHECK);
     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
     instanceKlassHandle ik (THREAD, k);
@@ -843,6 +860,7 @@
     // management server
     // throw java.lang.NoSuchMethodError if method doesn't exist
 
+    loadAgentModule(CHECK);
     Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
     Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
     instanceKlassHandle ik (THREAD, k);
@@ -864,6 +882,7 @@
   // invoke getManagementAgentStatus() method to generate the status info
   // throw java.lang.NoSuchMethodError if method doesn't exist
 
+  loadAgentModule(CHECK);
   Handle loader = Handle(THREAD, SystemDictionary::java_system_loader());
   Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_agent_Agent(), loader, Handle(), true, CHECK);
   instanceKlassHandle ik (THREAD, k);
--- a/hotspot/src/share/vm/shark/sharkIntrinsics.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/shark/sharkIntrinsics.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2009 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -66,7 +66,7 @@
     return true;
 
     // Unsafe
-  case vmIntrinsics::_compareAndSwapInt:
+  case vmIntrinsics::_compareAndSetInt:
     return true;
 
   default:
@@ -140,8 +140,8 @@
     break;
 
     // Unsafe
-  case vmIntrinsics::_compareAndSwapInt:
-    do_Unsafe_compareAndSwapInt();
+  case vmIntrinsics::_compareAndSetInt:
+    do_Unsafe_compareAndSetInt();
     break;
 
   default:
@@ -241,7 +241,7 @@
       true));
 }
 
-void SharkIntrinsics::do_Unsafe_compareAndSwapInt() {
+void SharkIntrinsics::do_Unsafe_compareAndSetInt() {
   // Pop the arguments
   Value *x      = state()->pop()->jint_value();
   Value *e      = state()->pop()->jint_value();
--- a/hotspot/src/share/vm/shark/sharkIntrinsics.hpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/src/share/vm/shark/sharkIntrinsics.hpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2009 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -58,7 +58,7 @@
   void do_Object_getClass();
   void do_System_currentTimeMillis();
   void do_Thread_currentThread();
-  void do_Unsafe_compareAndSwapInt();
+  void do_Unsafe_compareAndSetInt();
 };
 
 #endif // SHARE_VM_SHARK_SHARKINTRINSICS_HPP
--- a/hotspot/test/compiler/intrinsics/unsafe/TestCAEAntiDep.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/intrinsics/unsafe/TestCAEAntiDep.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2016, Red Hat, Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -53,7 +54,7 @@
     }
 
     static int m(TestCAEAntiDep test, Object expected, Object x) {
-        C old = (C)UNSAFE.compareAndExchangeObjectVolatile(test, O_OFFSET, expected, x);
+        C old = (C)UNSAFE.compareAndExchangeObject(test, O_OFFSET, expected, x);
         int res = old.f1;
         old.f1 = 0x42;
         return res;
--- a/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,9 +72,8 @@
     }
 
     static void testAccess(Object base, long offset) {
-        UNSAFE.compareAndSwapLong(base, offset, 1L, 2L);
-        UNSAFE.compareAndSwapLong(base, offset, 2L, 1L);
+        UNSAFE.compareAndSetLong(base, offset, 1L, 2L);
+        UNSAFE.compareAndSetLong(base, offset, 2L, 1L);
     }
 
 }
-
--- a/hotspot/test/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/jsr292/RedefineMethodUsedByMultipleMethodHandles.java	Wed Jul 05 23:25:53 2017 +0200
@@ -32,7 +32,7 @@
  *          java.management
  *          jdk.attach
  *
- * @run main/othervm compiler.jsr292.RedefineMethodUsedByMultipleMethodHandles
+ * @run main/othervm -Djdk.attach.allowAttachSelf compiler.jsr292.RedefineMethodUsedByMultipleMethodHandles
  */
 
 package compiler.jsr292;
--- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -29,7 +29,7 @@
  *          jdk.internal.vm.ci/jdk.vm.ci.runtime
  *          jdk.attach
  *          java.base/jdk.internal.misc
- * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Djvmci.Compiler=null jdk.vm.ci.runtime.test.RedefineClassTest
+ * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Djvmci.Compiler=null -Djdk.attach.allowAttachSelf jdk.vm.ci.runtime.test.RedefineClassTest
  */
 
 package jdk.vm.ci.runtime.test;
--- a/hotspot/test/compiler/profiling/spectrapredefineclass/Launcher.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/profiling/spectrapredefineclass/Launcher.java	Wed Jul 05 23:25:53 2017 +0200
@@ -33,7 +33,7 @@
  * @run driver compiler.profiling.spectrapredefineclass.Launcher
  * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation
  *                   -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222
- *                   -XX:ReservedCodeCacheSize=3M
+ *                   -XX:ReservedCodeCacheSize=3M -Djdk.attach.allowAttachSelf
  *                   compiler.profiling.spectrapredefineclass.Agent
  */
 
--- a/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Launcher.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/profiling/spectrapredefineclass_classloaders/Launcher.java	Wed Jul 05 23:25:53 2017 +0200
@@ -36,7 +36,7 @@
  * @run driver compiler.profiling.spectrapredefineclass_classloaders.Launcher
  * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation
  *                   -XX:-UseOnStackReplacement -XX:TypeProfileLevel=222
- *                   -XX:ReservedCodeCacheSize=3M
+ *                   -XX:ReservedCodeCacheSize=3M -Djdk.attach.allowAttachSelf
  *                   compiler.profiling.spectrapredefineclass_classloaders.Agent
  */
 
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -151,32 +151,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapBoolean(base, offset, true, false);
-            assertEquals(r, true, "success compareAndSwap boolean");
+            boolean r = UNSAFE.compareAndSetBoolean(base, offset, true, false);
+            assertEquals(r, true, "success compareAndSet boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, false, "success compareAndSwap boolean value");
+            assertEquals(x, false, "success compareAndSet boolean value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapBoolean(base, offset, true, false);
-            assertEquals(r, false, "failing compareAndSwap boolean");
+            boolean r = UNSAFE.compareAndSetBoolean(base, offset, true, false);
+            assertEquals(r, false, "failing compareAndSet boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, false, "failing compareAndSwap boolean value");
+            assertEquals(x, false, "failing compareAndSet boolean value");
         }
 
         // Advanced compare
         {
-            boolean r = UNSAFE.compareAndExchangeBooleanVolatile(base, offset, false, true);
-            assertEquals(r, false, "success compareAndExchangeVolatile boolean");
+            boolean r = UNSAFE.compareAndExchangeBoolean(base, offset, false, true);
+            assertEquals(r, false, "success compareAndExchange boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, true, "success compareAndExchangeVolatile boolean value");
+            assertEquals(x, true, "success compareAndExchange boolean value");
         }
 
         {
-            boolean r = UNSAFE.compareAndExchangeBooleanVolatile(base, offset, false, false);
-            assertEquals(r, true, "failing compareAndExchangeVolatile boolean");
+            boolean r = UNSAFE.compareAndExchangeBoolean(base, offset, false, false);
+            assertEquals(r, true, "failing compareAndExchange boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, true, "failing compareAndExchangeVolatile boolean value");
+            assertEquals(x, true, "failing compareAndExchange boolean value");
         }
 
         {
@@ -210,41 +210,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapBoolean(base, offset, true, false);
+                success = UNSAFE.weakCompareAndSetBooleanPlain(base, offset, true, false);
             }
-            assertEquals(success, true, "weakCompareAndSwap boolean");
+            assertEquals(success, true, "weakCompareAndSetPlain boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, false, "weakCompareAndSwap boolean value");
+            assertEquals(x, false, "weakCompareAndSetPlain boolean value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapBooleanAcquire(base, offset, false, true);
+                success = UNSAFE.weakCompareAndSetBooleanAcquire(base, offset, false, true);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire boolean");
+            assertEquals(success, true, "weakCompareAndSetAcquire boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, true, "weakCompareAndSwapAcquire boolean");
+            assertEquals(x, true, "weakCompareAndSetAcquire boolean");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapBooleanRelease(base, offset, true, false);
+                success = UNSAFE.weakCompareAndSetBooleanRelease(base, offset, true, false);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease boolean");
+            assertEquals(success, true, "weakCompareAndSetRelease boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, false, "weakCompareAndSwapRelease boolean");
+            assertEquals(x, false, "weakCompareAndSetRelease boolean");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapBooleanVolatile(base, offset, false, true);
+                success = UNSAFE.weakCompareAndSetBoolean(base, offset, false, true);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile boolean");
+            assertEquals(success, true, "weakCompareAndSet boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, true, "weakCompareAndSwapVolatile boolean");
+            assertEquals(x, true, "weakCompareAndSet boolean");
         }
 
         UNSAFE.putBoolean(base, offset, false);
@@ -260,4 +260,3 @@
     }
 
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -180,32 +180,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapByte(base, offset, (byte)0x01, (byte)0x23);
-            assertEquals(r, true, "success compareAndSwap byte");
+            boolean r = UNSAFE.compareAndSetByte(base, offset, (byte)0x01, (byte)0x23);
+            assertEquals(r, true, "success compareAndSet byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x23, "success compareAndSwap byte value");
+            assertEquals(x, (byte)0x23, "success compareAndSet byte value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapByte(base, offset, (byte)0x01, (byte)0x45);
-            assertEquals(r, false, "failing compareAndSwap byte");
+            boolean r = UNSAFE.compareAndSetByte(base, offset, (byte)0x01, (byte)0x45);
+            assertEquals(r, false, "failing compareAndSet byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x23, "failing compareAndSwap byte value");
+            assertEquals(x, (byte)0x23, "failing compareAndSet byte value");
         }
 
         // Advanced compare
         {
-            byte r = UNSAFE.compareAndExchangeByteVolatile(base, offset, (byte)0x23, (byte)0x01);
-            assertEquals(r, (byte)0x23, "success compareAndExchangeVolatile byte");
+            byte r = UNSAFE.compareAndExchangeByte(base, offset, (byte)0x23, (byte)0x01);
+            assertEquals(r, (byte)0x23, "success compareAndExchange byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x01, "success compareAndExchangeVolatile byte value");
+            assertEquals(x, (byte)0x01, "success compareAndExchange byte value");
         }
 
         {
-            byte r = UNSAFE.compareAndExchangeByteVolatile(base, offset, (byte)0x23, (byte)0x45);
-            assertEquals(r, (byte)0x01, "failing compareAndExchangeVolatile byte");
+            byte r = UNSAFE.compareAndExchangeByte(base, offset, (byte)0x23, (byte)0x45);
+            assertEquals(r, (byte)0x01, "failing compareAndExchange byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x01, "failing compareAndExchangeVolatile byte value");
+            assertEquals(x, (byte)0x01, "failing compareAndExchange byte value");
         }
 
         {
@@ -239,41 +239,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapByte(base, offset, (byte)0x01, (byte)0x23);
+                success = UNSAFE.weakCompareAndSetBytePlain(base, offset, (byte)0x01, (byte)0x23);
             }
-            assertEquals(success, true, "weakCompareAndSwap byte");
+            assertEquals(success, true, "weakCompareAndSetPlain byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x23, "weakCompareAndSwap byte value");
+            assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapByteAcquire(base, offset, (byte)0x23, (byte)0x01);
+                success = UNSAFE.weakCompareAndSetByteAcquire(base, offset, (byte)0x23, (byte)0x01);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire byte");
+            assertEquals(success, true, "weakCompareAndSetAcquire byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x01, "weakCompareAndSwapAcquire byte");
+            assertEquals(x, (byte)0x01, "weakCompareAndSetAcquire byte");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapByteRelease(base, offset, (byte)0x01, (byte)0x23);
+                success = UNSAFE.weakCompareAndSetByteRelease(base, offset, (byte)0x01, (byte)0x23);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease byte");
+            assertEquals(success, true, "weakCompareAndSetRelease byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x23, "weakCompareAndSwapRelease byte");
+            assertEquals(x, (byte)0x23, "weakCompareAndSetRelease byte");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapByteVolatile(base, offset, (byte)0x23, (byte)0x01);
+                success = UNSAFE.weakCompareAndSetByte(base, offset, (byte)0x23, (byte)0x01);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile byte");
+            assertEquals(success, true, "weakCompareAndSet byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x01, "weakCompareAndSwapVolatile byte");
+            assertEquals(x, (byte)0x01, "weakCompareAndSet byte");
         }
 
         UNSAFE.putByte(base, offset, (byte)0x23);
@@ -306,4 +306,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -198,32 +198,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapChar(base, offset, '\u0123', '\u4567');
-            assertEquals(r, true, "success compareAndSwap char");
+            boolean r = UNSAFE.compareAndSetChar(base, offset, '\u0123', '\u4567');
+            assertEquals(r, true, "success compareAndSet char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u4567', "success compareAndSwap char value");
+            assertEquals(x, '\u4567', "success compareAndSet char value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapChar(base, offset, '\u0123', '\u89AB');
-            assertEquals(r, false, "failing compareAndSwap char");
+            boolean r = UNSAFE.compareAndSetChar(base, offset, '\u0123', '\u89AB');
+            assertEquals(r, false, "failing compareAndSet char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u4567', "failing compareAndSwap char value");
+            assertEquals(x, '\u4567', "failing compareAndSet char value");
         }
 
         // Advanced compare
         {
-            char r = UNSAFE.compareAndExchangeCharVolatile(base, offset, '\u4567', '\u0123');
-            assertEquals(r, '\u4567', "success compareAndExchangeVolatile char");
+            char r = UNSAFE.compareAndExchangeChar(base, offset, '\u4567', '\u0123');
+            assertEquals(r, '\u4567', "success compareAndExchange char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u0123', "success compareAndExchangeVolatile char value");
+            assertEquals(x, '\u0123', "success compareAndExchange char value");
         }
 
         {
-            char r = UNSAFE.compareAndExchangeCharVolatile(base, offset, '\u4567', '\u89AB');
-            assertEquals(r, '\u0123', "failing compareAndExchangeVolatile char");
+            char r = UNSAFE.compareAndExchangeChar(base, offset, '\u4567', '\u89AB');
+            assertEquals(r, '\u0123', "failing compareAndExchange char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u0123', "failing compareAndExchangeVolatile char value");
+            assertEquals(x, '\u0123', "failing compareAndExchange char value");
         }
 
         {
@@ -257,41 +257,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapChar(base, offset, '\u0123', '\u4567');
+                success = UNSAFE.weakCompareAndSetCharPlain(base, offset, '\u0123', '\u4567');
             }
-            assertEquals(success, true, "weakCompareAndSwap char");
+            assertEquals(success, true, "weakCompareAndSetPlain char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u4567', "weakCompareAndSwap char value");
+            assertEquals(x, '\u4567', "weakCompareAndSetPlain char value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapCharAcquire(base, offset, '\u4567', '\u0123');
+                success = UNSAFE.weakCompareAndSetCharAcquire(base, offset, '\u4567', '\u0123');
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire char");
+            assertEquals(success, true, "weakCompareAndSetAcquire char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u0123', "weakCompareAndSwapAcquire char");
+            assertEquals(x, '\u0123', "weakCompareAndSetAcquire char");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapCharRelease(base, offset, '\u0123', '\u4567');
+                success = UNSAFE.weakCompareAndSetCharRelease(base, offset, '\u0123', '\u4567');
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease char");
+            assertEquals(success, true, "weakCompareAndSetRelease char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u4567', "weakCompareAndSwapRelease char");
+            assertEquals(x, '\u4567', "weakCompareAndSetRelease char");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapCharVolatile(base, offset, '\u4567', '\u0123');
+                success = UNSAFE.weakCompareAndSetChar(base, offset, '\u4567', '\u0123');
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile char");
+            assertEquals(success, true, "weakCompareAndSet char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u0123', "weakCompareAndSwapVolatile char");
+            assertEquals(x, '\u0123', "weakCompareAndSet char");
         }
 
         UNSAFE.putChar(base, offset, '\u4567');
@@ -324,4 +324,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -180,32 +180,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapDouble(base, offset, 1.0d, 2.0d);
-            assertEquals(r, true, "success compareAndSwap double");
+            boolean r = UNSAFE.compareAndSetDouble(base, offset, 1.0d, 2.0d);
+            assertEquals(r, true, "success compareAndSet double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 2.0d, "success compareAndSwap double value");
+            assertEquals(x, 2.0d, "success compareAndSet double value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapDouble(base, offset, 1.0d, 3.0d);
-            assertEquals(r, false, "failing compareAndSwap double");
+            boolean r = UNSAFE.compareAndSetDouble(base, offset, 1.0d, 3.0d);
+            assertEquals(r, false, "failing compareAndSet double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 2.0d, "failing compareAndSwap double value");
+            assertEquals(x, 2.0d, "failing compareAndSet double value");
         }
 
         // Advanced compare
         {
-            double r = UNSAFE.compareAndExchangeDoubleVolatile(base, offset, 2.0d, 1.0d);
-            assertEquals(r, 2.0d, "success compareAndExchangeVolatile double");
+            double r = UNSAFE.compareAndExchangeDouble(base, offset, 2.0d, 1.0d);
+            assertEquals(r, 2.0d, "success compareAndExchange double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 1.0d, "success compareAndExchangeVolatile double value");
+            assertEquals(x, 1.0d, "success compareAndExchange double value");
         }
 
         {
-            double r = UNSAFE.compareAndExchangeDoubleVolatile(base, offset, 2.0d, 3.0d);
-            assertEquals(r, 1.0d, "failing compareAndExchangeVolatile double");
+            double r = UNSAFE.compareAndExchangeDouble(base, offset, 2.0d, 3.0d);
+            assertEquals(r, 1.0d, "failing compareAndExchange double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 1.0d, "failing compareAndExchangeVolatile double value");
+            assertEquals(x, 1.0d, "failing compareAndExchange double value");
         }
 
         {
@@ -239,41 +239,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapDouble(base, offset, 1.0d, 2.0d);
+                success = UNSAFE.weakCompareAndSetDoublePlain(base, offset, 1.0d, 2.0d);
             }
-            assertEquals(success, true, "weakCompareAndSwap double");
+            assertEquals(success, true, "weakCompareAndSetPlain double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 2.0d, "weakCompareAndSwap double value");
+            assertEquals(x, 2.0d, "weakCompareAndSetPlain double value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapDoubleAcquire(base, offset, 2.0d, 1.0d);
+                success = UNSAFE.weakCompareAndSetDoubleAcquire(base, offset, 2.0d, 1.0d);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire double");
+            assertEquals(success, true, "weakCompareAndSetAcquire double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 1.0d, "weakCompareAndSwapAcquire double");
+            assertEquals(x, 1.0d, "weakCompareAndSetAcquire double");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapDoubleRelease(base, offset, 1.0d, 2.0d);
+                success = UNSAFE.weakCompareAndSetDoubleRelease(base, offset, 1.0d, 2.0d);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease double");
+            assertEquals(success, true, "weakCompareAndSetRelease double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 2.0d, "weakCompareAndSwapRelease double");
+            assertEquals(x, 2.0d, "weakCompareAndSetRelease double");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapDoubleVolatile(base, offset, 2.0d, 1.0d);
+                success = UNSAFE.weakCompareAndSetDouble(base, offset, 2.0d, 1.0d);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile double");
+            assertEquals(success, true, "weakCompareAndSet double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 1.0d, "weakCompareAndSwapVolatile double");
+            assertEquals(x, 1.0d, "weakCompareAndSet double");
         }
 
         UNSAFE.putDouble(base, offset, 2.0d);
@@ -306,4 +306,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -180,32 +180,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapFloat(base, offset, 1.0f, 2.0f);
-            assertEquals(r, true, "success compareAndSwap float");
+            boolean r = UNSAFE.compareAndSetFloat(base, offset, 1.0f, 2.0f);
+            assertEquals(r, true, "success compareAndSet float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 2.0f, "success compareAndSwap float value");
+            assertEquals(x, 2.0f, "success compareAndSet float value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapFloat(base, offset, 1.0f, 3.0f);
-            assertEquals(r, false, "failing compareAndSwap float");
+            boolean r = UNSAFE.compareAndSetFloat(base, offset, 1.0f, 3.0f);
+            assertEquals(r, false, "failing compareAndSet float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 2.0f, "failing compareAndSwap float value");
+            assertEquals(x, 2.0f, "failing compareAndSet float value");
         }
 
         // Advanced compare
         {
-            float r = UNSAFE.compareAndExchangeFloatVolatile(base, offset, 2.0f, 1.0f);
-            assertEquals(r, 2.0f, "success compareAndExchangeVolatile float");
+            float r = UNSAFE.compareAndExchangeFloat(base, offset, 2.0f, 1.0f);
+            assertEquals(r, 2.0f, "success compareAndExchange float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 1.0f, "success compareAndExchangeVolatile float value");
+            assertEquals(x, 1.0f, "success compareAndExchange float value");
         }
 
         {
-            float r = UNSAFE.compareAndExchangeFloatVolatile(base, offset, 2.0f, 3.0f);
-            assertEquals(r, 1.0f, "failing compareAndExchangeVolatile float");
+            float r = UNSAFE.compareAndExchangeFloat(base, offset, 2.0f, 3.0f);
+            assertEquals(r, 1.0f, "failing compareAndExchange float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 1.0f, "failing compareAndExchangeVolatile float value");
+            assertEquals(x, 1.0f, "failing compareAndExchange float value");
         }
 
         {
@@ -239,41 +239,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapFloat(base, offset, 1.0f, 2.0f);
+                success = UNSAFE.weakCompareAndSetFloatPlain(base, offset, 1.0f, 2.0f);
             }
-            assertEquals(success, true, "weakCompareAndSwap float");
+            assertEquals(success, true, "weakCompareAndSetPlain float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 2.0f, "weakCompareAndSwap float value");
+            assertEquals(x, 2.0f, "weakCompareAndSetPlain float value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapFloatAcquire(base, offset, 2.0f, 1.0f);
+                success = UNSAFE.weakCompareAndSetFloatAcquire(base, offset, 2.0f, 1.0f);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire float");
+            assertEquals(success, true, "weakCompareAndSetAcquire float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 1.0f, "weakCompareAndSwapAcquire float");
+            assertEquals(x, 1.0f, "weakCompareAndSetAcquire float");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapFloatRelease(base, offset, 1.0f, 2.0f);
+                success = UNSAFE.weakCompareAndSetFloatRelease(base, offset, 1.0f, 2.0f);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease float");
+            assertEquals(success, true, "weakCompareAndSetRelease float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 2.0f, "weakCompareAndSwapRelease float");
+            assertEquals(x, 2.0f, "weakCompareAndSetRelease float");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapFloatVolatile(base, offset, 2.0f, 1.0f);
+                success = UNSAFE.weakCompareAndSetFloat(base, offset, 2.0f, 1.0f);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile float");
+            assertEquals(success, true, "weakCompareAndSet float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 1.0f, "weakCompareAndSwapVolatile float");
+            assertEquals(x, 1.0f, "weakCompareAndSet float");
         }
 
         UNSAFE.putFloat(base, offset, 2.0f);
@@ -306,4 +306,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -198,32 +198,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapInt(base, offset, 0x01234567, 0x89ABCDEF);
-            assertEquals(r, true, "success compareAndSwap int");
+            boolean r = UNSAFE.compareAndSetInt(base, offset, 0x01234567, 0x89ABCDEF);
+            assertEquals(r, true, "success compareAndSet int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x89ABCDEF, "success compareAndSwap int value");
+            assertEquals(x, 0x89ABCDEF, "success compareAndSet int value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapInt(base, offset, 0x01234567, 0xCAFEBABE);
-            assertEquals(r, false, "failing compareAndSwap int");
+            boolean r = UNSAFE.compareAndSetInt(base, offset, 0x01234567, 0xCAFEBABE);
+            assertEquals(r, false, "failing compareAndSet int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x89ABCDEF, "failing compareAndSwap int value");
+            assertEquals(x, 0x89ABCDEF, "failing compareAndSet int value");
         }
 
         // Advanced compare
         {
-            int r = UNSAFE.compareAndExchangeIntVolatile(base, offset, 0x89ABCDEF, 0x01234567);
-            assertEquals(r, 0x89ABCDEF, "success compareAndExchangeVolatile int");
+            int r = UNSAFE.compareAndExchangeInt(base, offset, 0x89ABCDEF, 0x01234567);
+            assertEquals(r, 0x89ABCDEF, "success compareAndExchange int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x01234567, "success compareAndExchangeVolatile int value");
+            assertEquals(x, 0x01234567, "success compareAndExchange int value");
         }
 
         {
-            int r = UNSAFE.compareAndExchangeIntVolatile(base, offset, 0x89ABCDEF, 0xCAFEBABE);
-            assertEquals(r, 0x01234567, "failing compareAndExchangeVolatile int");
+            int r = UNSAFE.compareAndExchangeInt(base, offset, 0x89ABCDEF, 0xCAFEBABE);
+            assertEquals(r, 0x01234567, "failing compareAndExchange int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x01234567, "failing compareAndExchangeVolatile int value");
+            assertEquals(x, 0x01234567, "failing compareAndExchange int value");
         }
 
         {
@@ -257,41 +257,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapInt(base, offset, 0x01234567, 0x89ABCDEF);
+                success = UNSAFE.weakCompareAndSetIntPlain(base, offset, 0x01234567, 0x89ABCDEF);
             }
-            assertEquals(success, true, "weakCompareAndSwap int");
+            assertEquals(success, true, "weakCompareAndSetPlain int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x89ABCDEF, "weakCompareAndSwap int value");
+            assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapIntAcquire(base, offset, 0x89ABCDEF, 0x01234567);
+                success = UNSAFE.weakCompareAndSetIntAcquire(base, offset, 0x89ABCDEF, 0x01234567);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire int");
+            assertEquals(success, true, "weakCompareAndSetAcquire int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x01234567, "weakCompareAndSwapAcquire int");
+            assertEquals(x, 0x01234567, "weakCompareAndSetAcquire int");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapIntRelease(base, offset, 0x01234567, 0x89ABCDEF);
+                success = UNSAFE.weakCompareAndSetIntRelease(base, offset, 0x01234567, 0x89ABCDEF);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease int");
+            assertEquals(success, true, "weakCompareAndSetRelease int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x89ABCDEF, "weakCompareAndSwapRelease int");
+            assertEquals(x, 0x89ABCDEF, "weakCompareAndSetRelease int");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapIntVolatile(base, offset, 0x89ABCDEF, 0x01234567);
+                success = UNSAFE.weakCompareAndSetInt(base, offset, 0x89ABCDEF, 0x01234567);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile int");
+            assertEquals(success, true, "weakCompareAndSet int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x01234567, "weakCompareAndSwapVolatile int");
+            assertEquals(x, 0x01234567, "weakCompareAndSet int");
         }
 
         UNSAFE.putInt(base, offset, 0x89ABCDEF);
@@ -324,4 +324,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -198,32 +198,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
-            assertEquals(r, true, "success compareAndSwap long");
+            boolean r = UNSAFE.compareAndSetLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
+            assertEquals(r, true, "success compareAndSet long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSwap long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSet long value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
-            assertEquals(r, false, "failing compareAndSwap long");
+            boolean r = UNSAFE.compareAndSetLong(base, offset, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
+            assertEquals(r, false, "failing compareAndSet long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSwap long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSet long value");
         }
 
         // Advanced compare
         {
-            long r = UNSAFE.compareAndExchangeLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
-            assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeVolatile long");
+            long r = UNSAFE.compareAndExchangeLong(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+            assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchange long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeVolatile long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchange long value");
         }
 
         {
-            long r = UNSAFE.compareAndExchangeLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
-            assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long");
+            long r = UNSAFE.compareAndExchangeLong(base, offset, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+            assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchange long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchange long value");
         }
 
         {
@@ -257,41 +257,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
+                success = UNSAFE.weakCompareAndSetLongPlain(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
             }
-            assertEquals(success, true, "weakCompareAndSwap long");
+            assertEquals(success, true, "weakCompareAndSetPlain long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSwap long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapLongAcquire(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+                success = UNSAFE.weakCompareAndSetLongAcquire(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire long");
+            assertEquals(success, true, "weakCompareAndSetAcquire long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSwapAcquire long");
+            assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetAcquire long");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapLongRelease(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
+                success = UNSAFE.weakCompareAndSetLongRelease(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease long");
+            assertEquals(success, true, "weakCompareAndSetRelease long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSwapRelease long");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetRelease long");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+                success = UNSAFE.weakCompareAndSetLong(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile long");
+            assertEquals(success, true, "weakCompareAndSet long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSwapVolatile long");
+            assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long");
         }
 
         UNSAFE.putLong(base, offset, 0xCAFEBABECAFEBABEL);
@@ -324,4 +324,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -151,32 +151,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapObject(base, offset, "foo", "bar");
-            assertEquals(r, true, "success compareAndSwap Object");
+            boolean r = UNSAFE.compareAndSetObject(base, offset, "foo", "bar");
+            assertEquals(r, true, "success compareAndSet Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "bar", "success compareAndSwap Object value");
+            assertEquals(x, "bar", "success compareAndSet Object value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapObject(base, offset, "foo", "baz");
-            assertEquals(r, false, "failing compareAndSwap Object");
+            boolean r = UNSAFE.compareAndSetObject(base, offset, "foo", "baz");
+            assertEquals(r, false, "failing compareAndSet Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "bar", "failing compareAndSwap Object value");
+            assertEquals(x, "bar", "failing compareAndSet Object value");
         }
 
         // Advanced compare
         {
-            Object r = UNSAFE.compareAndExchangeObjectVolatile(base, offset, "bar", "foo");
-            assertEquals(r, "bar", "success compareAndExchangeVolatile Object");
+            Object r = UNSAFE.compareAndExchangeObject(base, offset, "bar", "foo");
+            assertEquals(r, "bar", "success compareAndExchange Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "foo", "success compareAndExchangeVolatile Object value");
+            assertEquals(x, "foo", "success compareAndExchange Object value");
         }
 
         {
-            Object r = UNSAFE.compareAndExchangeObjectVolatile(base, offset, "bar", "baz");
-            assertEquals(r, "foo", "failing compareAndExchangeVolatile Object");
+            Object r = UNSAFE.compareAndExchangeObject(base, offset, "bar", "baz");
+            assertEquals(r, "foo", "failing compareAndExchange Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "foo", "failing compareAndExchangeVolatile Object value");
+            assertEquals(x, "foo", "failing compareAndExchange Object value");
         }
 
         {
@@ -210,41 +210,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapObject(base, offset, "foo", "bar");
+                success = UNSAFE.weakCompareAndSetObjectPlain(base, offset, "foo", "bar");
             }
-            assertEquals(success, true, "weakCompareAndSwap Object");
+            assertEquals(success, true, "weakCompareAndSetPlain Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "bar", "weakCompareAndSwap Object value");
+            assertEquals(x, "bar", "weakCompareAndSetPlain Object value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapObjectAcquire(base, offset, "bar", "foo");
+                success = UNSAFE.weakCompareAndSetObjectAcquire(base, offset, "bar", "foo");
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire Object");
+            assertEquals(success, true, "weakCompareAndSetAcquire Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "foo", "weakCompareAndSwapAcquire Object");
+            assertEquals(x, "foo", "weakCompareAndSetAcquire Object");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapObjectRelease(base, offset, "foo", "bar");
+                success = UNSAFE.weakCompareAndSetObjectRelease(base, offset, "foo", "bar");
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease Object");
+            assertEquals(success, true, "weakCompareAndSetRelease Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "bar", "weakCompareAndSwapRelease Object");
+            assertEquals(x, "bar", "weakCompareAndSetRelease Object");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapObjectVolatile(base, offset, "bar", "foo");
+                success = UNSAFE.weakCompareAndSetObject(base, offset, "bar", "foo");
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile Object");
+            assertEquals(success, true, "weakCompareAndSet Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "foo", "weakCompareAndSwapVolatile Object");
+            assertEquals(x, "foo", "weakCompareAndSet Object");
         }
 
         UNSAFE.putObject(base, offset, "bar");
@@ -260,4 +260,3 @@
     }
 
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -198,32 +198,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapShort(base, offset, (short)0x0123, (short)0x4567);
-            assertEquals(r, true, "success compareAndSwap short");
+            boolean r = UNSAFE.compareAndSetShort(base, offset, (short)0x0123, (short)0x4567);
+            assertEquals(r, true, "success compareAndSet short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x4567, "success compareAndSwap short value");
+            assertEquals(x, (short)0x4567, "success compareAndSet short value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapShort(base, offset, (short)0x0123, (short)0x89AB);
-            assertEquals(r, false, "failing compareAndSwap short");
+            boolean r = UNSAFE.compareAndSetShort(base, offset, (short)0x0123, (short)0x89AB);
+            assertEquals(r, false, "failing compareAndSet short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x4567, "failing compareAndSwap short value");
+            assertEquals(x, (short)0x4567, "failing compareAndSet short value");
         }
 
         // Advanced compare
         {
-            short r = UNSAFE.compareAndExchangeShortVolatile(base, offset, (short)0x4567, (short)0x0123);
-            assertEquals(r, (short)0x4567, "success compareAndExchangeVolatile short");
+            short r = UNSAFE.compareAndExchangeShort(base, offset, (short)0x4567, (short)0x0123);
+            assertEquals(r, (short)0x4567, "success compareAndExchange short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x0123, "success compareAndExchangeVolatile short value");
+            assertEquals(x, (short)0x0123, "success compareAndExchange short value");
         }
 
         {
-            short r = UNSAFE.compareAndExchangeShortVolatile(base, offset, (short)0x4567, (short)0x89AB);
-            assertEquals(r, (short)0x0123, "failing compareAndExchangeVolatile short");
+            short r = UNSAFE.compareAndExchangeShort(base, offset, (short)0x4567, (short)0x89AB);
+            assertEquals(r, (short)0x0123, "failing compareAndExchange short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x0123, "failing compareAndExchangeVolatile short value");
+            assertEquals(x, (short)0x0123, "failing compareAndExchange short value");
         }
 
         {
@@ -257,41 +257,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapShort(base, offset, (short)0x0123, (short)0x4567);
+                success = UNSAFE.weakCompareAndSetShortPlain(base, offset, (short)0x0123, (short)0x4567);
             }
-            assertEquals(success, true, "weakCompareAndSwap short");
+            assertEquals(success, true, "weakCompareAndSetPlain short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x4567, "weakCompareAndSwap short value");
+            assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapShortAcquire(base, offset, (short)0x4567, (short)0x0123);
+                success = UNSAFE.weakCompareAndSetShortAcquire(base, offset, (short)0x4567, (short)0x0123);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire short");
+            assertEquals(success, true, "weakCompareAndSetAcquire short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x0123, "weakCompareAndSwapAcquire short");
+            assertEquals(x, (short)0x0123, "weakCompareAndSetAcquire short");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapShortRelease(base, offset, (short)0x0123, (short)0x4567);
+                success = UNSAFE.weakCompareAndSetShortRelease(base, offset, (short)0x0123, (short)0x4567);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease short");
+            assertEquals(success, true, "weakCompareAndSetRelease short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x4567, "weakCompareAndSwapRelease short");
+            assertEquals(x, (short)0x4567, "weakCompareAndSetRelease short");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapShortVolatile(base, offset, (short)0x4567, (short)0x0123);
+                success = UNSAFE.weakCompareAndSetShort(base, offset, (short)0x4567, (short)0x0123);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile short");
+            assertEquals(success, true, "weakCompareAndSet short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x0123, "weakCompareAndSwapVolatile short");
+            assertEquals(x, (short)0x0123, "weakCompareAndSet short");
         }
 
         UNSAFE.putShort(base, offset, (short)0x4567);
@@ -324,4 +324,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -138,4 +138,3 @@
     }
 
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -216,4 +216,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -216,4 +216,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -170,4 +170,3 @@
     }
 
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,11 @@
  * @bug 8143628
  * @summary Test unsafe access for $type$
  *
+#if[JdkInternalMisc]
+ * @modules $module$/$package$:+open
+#else[JdkInternalMisc]
  * @modules $module$/$package$
+#end[JdkInternalMisc]
  * @run testng/othervm -Diters=100   -Xint                   compiler.unsafe.$Qualifier$UnsafeAccessTest$Type$
  * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 compiler.unsafe.$Qualifier$UnsafeAccessTest$Type$
  * @run testng/othervm -Diters=20000 -XX:-TieredCompilation  compiler.unsafe.$Qualifier$UnsafeAccessTest$Type$
@@ -219,33 +223,51 @@
 
         // Compare
         {
+#if[JdkInternalMisc]
+            boolean r = UNSAFE.compareAndSet$Type$(base, offset, $value1$, $value2$);
+            assertEquals(r, true, "success compareAndSet $type$");
+#else[JdkInternalMisc]
             boolean r = UNSAFE.compareAndSwap$Type$(base, offset, $value1$, $value2$);
             assertEquals(r, true, "success compareAndSwap $type$");
+#end[JdkInternalMisc]
             $type$ x = UNSAFE.get$Type$(base, offset);
+#if[JdkInternalMisc]
+            assertEquals(x, $value2$, "success compareAndSet $type$ value");
+#else[JdkInternalMisc]
             assertEquals(x, $value2$, "success compareAndSwap $type$ value");
+#end[JdkInternalMisc]
         }
 
         {
+#if[JdkInternalMisc]
+            boolean r = UNSAFE.compareAndSet$Type$(base, offset, $value1$, $value3$);
+            assertEquals(r, false, "failing compareAndSet $type$");
+#else[JdkInternalMisc]
             boolean r = UNSAFE.compareAndSwap$Type$(base, offset, $value1$, $value3$);
             assertEquals(r, false, "failing compareAndSwap $type$");
+#end[JdkInternalMisc]
             $type$ x = UNSAFE.get$Type$(base, offset);
+#if[JdkInternalMisc]
+            assertEquals(x, $value2$, "failing compareAndSet $type$ value");
+#else[JdkInternalMisc]
             assertEquals(x, $value2$, "failing compareAndSwap $type$ value");
+#end[JdkInternalMisc]
         }
 
 #if[JdkInternalMisc]
         // Advanced compare
         {
-            $type$ r = UNSAFE.compareAndExchange$Type$Volatile(base, offset, $value2$, $value1$);
-            assertEquals(r, $value2$, "success compareAndExchangeVolatile $type$");
+            $type$ r = UNSAFE.compareAndExchange$Type$(base, offset, $value2$, $value1$);
+            assertEquals(r, $value2$, "success compareAndExchange $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value1$, "success compareAndExchangeVolatile $type$ value");
+            assertEquals(x, $value1$, "success compareAndExchange $type$ value");
         }
 
         {
-            $type$ r = UNSAFE.compareAndExchange$Type$Volatile(base, offset, $value2$, $value3$);
-            assertEquals(r, $value1$, "failing compareAndExchangeVolatile $type$");
+            $type$ r = UNSAFE.compareAndExchange$Type$(base, offset, $value2$, $value3$);
+            assertEquals(r, $value1$, "failing compareAndExchange $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value1$, "failing compareAndExchangeVolatile $type$ value");
+            assertEquals(x, $value1$, "failing compareAndExchange $type$ value");
         }
 
         {
@@ -279,41 +301,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwap$Type$(base, offset, $value1$, $value2$);
+                success = UNSAFE.weakCompareAndSet$Type$Plain(base, offset, $value1$, $value2$);
             }
-            assertEquals(success, true, "weakCompareAndSwap $type$");
+            assertEquals(success, true, "weakCompareAndSetPlain $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value2$, "weakCompareAndSwap $type$ value");
+            assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwap$Type$Acquire(base, offset, $value2$, $value1$);
+                success = UNSAFE.weakCompareAndSet$Type$Acquire(base, offset, $value2$, $value1$);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire $type$");
+            assertEquals(success, true, "weakCompareAndSetAcquire $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value1$, "weakCompareAndSwapAcquire $type$");
+            assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwap$Type$Release(base, offset, $value1$, $value2$);
+                success = UNSAFE.weakCompareAndSet$Type$Release(base, offset, $value1$, $value2$);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease $type$");
+            assertEquals(success, true, "weakCompareAndSetRelease $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value2$, "weakCompareAndSwapRelease $type$");
+            assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwap$Type$Volatile(base, offset, $value2$, $value1$);
+                success = UNSAFE.weakCompareAndSet$Type$(base, offset, $value2$, $value1$);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile $type$");
+            assertEquals(success, true, "weakCompareAndSet $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value1$, "weakCompareAndSwapVolatile $type$");
+            assertEquals(x, $value1$, "weakCompareAndSet $type$");
         }
 
 #end[JdkInternalMisc]
@@ -354,4 +376,3 @@
 #end[!boolean]
 #end[!Object]
 }
-
--- a/hotspot/test/gc/class_unloading/TestClassUnloadingDisabled.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/gc/class_unloading/TestClassUnloadingDisabled.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reqserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/hotspot/test/native/logging/test_logTagSetDescriptions.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/native/logging/test_logTagSetDescriptions.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -10,7 +10,7 @@
  * 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
- * ac_heapanied this code).
+ * 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,
--- a/hotspot/test/native/memory/test_metachunk.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/native/memory/test_metachunk.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRangesDynamic.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRangesDynamic.java	Wed Jul 05 23:25:53 2017 +0200
@@ -28,7 +28,7 @@
  * @modules java.base/jdk.internal.misc
  *          jdk.attach/sun.tools.attach
  *          java.management
- * @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 TestOptionsWithRangesDynamic
+ * @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 -Djdk.attach.allowAttachSelf TestOptionsWithRangesDynamic
  */
 
 import java.util.List;
--- a/hotspot/test/runtime/CommandLine/PermGenFlagsTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/runtime/CommandLine/PermGenFlagsTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -8,7 +8,7 @@
  *
  * 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
+ * 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).
  *
--- a/hotspot/test/runtime/Metaspace/DefineClass.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/runtime/Metaspace/DefineClass.java	Wed Jul 05 23:25:53 2017 +0200
@@ -41,8 +41,8 @@
  * @run main/othervm -XX:+UnlockDiagnosticVMOptions
                      -XX:-UnsyncloadClass -XX:-AllowParallelDefineClass
                      test.DefineClass defineClassParallel
- * @run main/othervm test.DefineClass redefineClass
- * @run main/othervm test.DefineClass redefineClassWithError
+ * @run main/othervm -Djdk.attach.allowAttachSelf test.DefineClass redefineClass
+ * @run main/othervm -Djdk.attach.allowAttachSelf test.DefineClass redefineClassWithError
  * @author volker.simonis@gmail.com
  */
 
--- a/hotspot/test/runtime/logging/ModulesTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/runtime/logging/ModulesTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @summary modules=debug should have logging from statements in the code
+ * @summary -Xlog:module should emit logging output
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          java.management
@@ -35,9 +35,16 @@
 
 public class ModulesTest {
     public static void main(String[] args) throws Exception {
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-            "-Xlog:modules=trace", "-version");
-        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+        testModuleTrace("-Xlog:module=trace", "-version");
+        testModuleLoad("-Xlog:module+load", "-version");
+        testModuleUnload("-Xlog:module+unload", "-version");
+
+        // same as -Xlog:module+load -Xlog:module+unload
+        testModuleLoad("-verbose:module", "-version");
+    }
+
+    static void testModuleTrace(String... args) throws Exception {
+        OutputAnalyzer output = run(args);
         output.shouldContain("define_javabase_module(): Definition of module:");
         output.shouldContain("define_javabase_module(): creation of package");
         output.shouldContain("define_module(): creation of module");
@@ -48,5 +55,22 @@
         output.shouldContain("Setting package: class:");
         output.shouldHaveExitValue(0);
     }
+
+    static void testModuleLoad(String... args) throws Exception {
+        OutputAnalyzer output = run(args);
+        output.shouldContain("java.base location:");
+        output.shouldContain("java.management location:");
+        output.shouldHaveExitValue(0);
+    }
+
+    static void testModuleUnload(String... args) throws Exception {
+        OutputAnalyzer output = run(args);
+        output.shouldHaveExitValue(0);
+    }
+
+    static OutputAnalyzer run(String... args) throws Exception {
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
+        return new OutputAnalyzer(pb.start());
+    }
 }
 
--- a/hotspot/test/runtime/logging/StartupTimeTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/runtime/logging/StartupTimeTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -57,7 +57,7 @@
 
     static void analyzeModulesOutputOff(ProcessBuilder pb) throws Exception {
         OutputAnalyzer output = new OutputAnalyzer(pb.start());
-        output.shouldNotContain("[modules,startuptime]");
+        output.shouldNotContain("[module,startuptime]");
         output.shouldHaveExitValue(0);
     }
 
@@ -70,11 +70,11 @@
                                                    InnerClass.class.getName());
         analyzeOutputOff(pb);
 
-        pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime+modules",
+        pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime+module",
                                                    InnerClass.class.getName());
         analyzeModulesOutputOn(pb);
 
-        pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime+modules=off",
+        pb = ProcessTools.createJavaProcessBuilder("-Xlog:startuptime+module=off",
                                                    InnerClass.class.getName());
         analyzeModulesOutputOff(pb);
     }
--- a/hotspot/test/runtime/logging/ThreadLoggingTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/runtime/logging/ThreadLoggingTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -9,7 +9,7 @@
  *
  * 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
+ * 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).
  *
--- a/hotspot/test/runtime/logging/p2/B.jcod	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/runtime/logging/p2/B.jcod	Wed Jul 05 23:25:53 2017 +0200
@@ -8,7 +8,7 @@
  *
  * 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
+ * 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).
  *
--- a/hotspot/test/runtime/modules/JVMAddModuleExports.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/runtime/modules/JVMAddModuleExports.java	Wed Jul 05 23:25:53 2017 +0200
@@ -41,12 +41,12 @@
         MyClassLoader to_cl = new MyClassLoader();
         Module from_module, to_module;
 
-        from_module = ModuleHelper.ModuleObject("from_module", from_cl, new String[] { "mypackage", "this/package" });
+        from_module = ModuleHelper.ModuleObject("from_module", from_cl, new String[] { "mypackage", "x/apackage" });
         assertNotNull(from_module, "Module should not be null");
-        ModuleHelper.DefineModule(from_module, "9.0", "from_module/here", new String[] { "mypackage", "this/package" });
-        to_module = ModuleHelper.ModuleObject("to_module", to_cl, new String[] { "yourpackage", "that/package" });
+        ModuleHelper.DefineModule(from_module, "9.0", "from_module/here", new String[] { "mypackage", "x/apackage" });
+        to_module = ModuleHelper.ModuleObject("to_module", to_cl, new String[] { "yourpackage", "that/apackage" });
         assertNotNull(to_module, "Module should not be null");
-        ModuleHelper.DefineModule(to_module, "9.0", "to_module/here", new String[] { "yourpackage", "that/package" });
+        ModuleHelper.DefineModule(to_module, "9.0", "to_module/here", new String[] { "yourpackage", "that/apackage" });
 
         // Null from_module argument, expect an NPE
         try {
@@ -117,19 +117,19 @@
 
         // Export a package, that is not in from_module, to from_module
         try {
-            ModuleHelper.AddModuleExports(from_module, "that/package", from_module);
+            ModuleHelper.AddModuleExports(from_module, "that/apackage", from_module);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
         }
 
         // Export the same package twice to the same module
-        ModuleHelper.AddModuleExports(from_module, "this/package", to_module);
-        ModuleHelper.AddModuleExports(from_module, "this/package", to_module);
+        ModuleHelper.AddModuleExports(from_module, "x/apackage", to_module);
+        ModuleHelper.AddModuleExports(from_module, "x/apackage", to_module);
 
         // Export a package, using '.' instead of '/'
         try {
-            ModuleHelper.AddModuleExports(from_module, "this.package", to_module);
+            ModuleHelper.AddModuleExports(from_module, "x.apackage", to_module);
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -137,8 +137,8 @@
 
         // Export a package to the unnamed module and then to a specific module.
         // The qualified export should be ignored.
-        ModuleHelper.AddModuleExportsToAll(to_module, "that/package");
-        ModuleHelper.AddModuleExports(to_module, "that/package", from_module);
+        ModuleHelper.AddModuleExportsToAll(to_module, "that/apackage");
+        ModuleHelper.AddModuleExports(to_module, "that/apackage", from_module);
     }
 
     static class MyClassLoader extends ClassLoader { }
--- a/hotspot/test/runtime/modules/JVMAddModulePackage.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/runtime/modules/JVMAddModulePackage.java	Wed Jul 05 23:25:53 2017 +0200
@@ -49,16 +49,16 @@
         module_two = ModuleHelper.ModuleObject("module_two", cl1, new String[] { "yourpackage" });
         assertNotNull(module_two, "Module should not be null");
         ModuleHelper.DefineModule(module_two, "9.0", "module_two/here", new String[] { "yourpackage" });
-        module_three = ModuleHelper.ModuleObject("module_three", cl3, new String[] { "package/num3" });
+        module_three = ModuleHelper.ModuleObject("module_three", cl3, new String[] { "apackage/num3" });
         assertNotNull(module_three, "Module should not be null");
-        ModuleHelper.DefineModule(module_three, "9.0", "module_three/here", new String[] { "package/num3" });
+        ModuleHelper.DefineModule(module_three, "9.0", "module_three/here", new String[] { "apackage/num3" });
 
         // Simple call
         ModuleHelper.AddModulePackage(module_one, "new_package");
 
         // Add a package and export it
-        ModuleHelper.AddModulePackage(module_one, "package/num3");
-        ModuleHelper.AddModuleExportsToAll(module_one, "package/num3");
+        ModuleHelper.AddModulePackage(module_one, "apackage/num3");
+        ModuleHelper.AddModuleExportsToAll(module_one, "apackage/num3");
 
         // Null module argument, expect an NPE
         try {
@@ -94,7 +94,7 @@
 
         // Invalid package name, expect an IAE
         try {
-            ModuleHelper.AddModulePackage(module_one, "your.package");
+            ModuleHelper.AddModulePackage(module_one, "your.apackage");
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
@@ -102,7 +102,7 @@
 
         // Invalid package name, expect an IAE
         try {
-            ModuleHelper.AddModulePackage(module_one, ";your/package");
+            ModuleHelper.AddModulePackage(module_one, ";your/apackage");
             throw new RuntimeException("Failed to get the expected IAE");
         } catch(IllegalArgumentException e) {
             // Expected
--- a/hotspot/test/runtime/modules/JVMDefineModule.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/runtime/modules/JVMDefineModule.java	Wed Jul 05 23:25:53 2017 +0200
@@ -207,10 +207,10 @@
         ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { });
 
         // Invalid package name, expect an IAE
-        m = ModuleHelper.ModuleObject("moduleFive", cl, new String[] { "your.package" });
+        m = ModuleHelper.ModuleObject("moduleFive", cl, new String[] { "your.apackage" });
         try {
-            ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "your.package" });
-            throw new RuntimeException("Failed to get expected IAE for your.package");
+            ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { "your.apackage" });
+            throw new RuntimeException("Failed to get expected IAE for your.apackage");
         } catch(IllegalArgumentException e) {
             if (!e.getMessage().contains("Invalid package name")) {
               throw new RuntimeException("Failed to get expected IAE message for bad package name: " + e.getMessage());
@@ -220,8 +220,8 @@
         // Invalid package name, expect an IAE
         m = ModuleHelper.ModuleObject("moduleSix", cl, new String[] { "foo" }); // Name irrelevant
         try {
-            ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { ";your/package" });
-            throw new RuntimeException("Failed to get expected IAE for ;your.package");
+            ModuleHelper.DefineModule(m, "9.0", "module.name/here", new String[] { ";your/apackage" });
+            throw new RuntimeException("Failed to get expected IAE for ;your.apackage");
         } catch(IllegalArgumentException e) {
             if (!e.getMessage().contains("Invalid package name")) {
               throw new RuntimeException("Failed to get expected IAE message for bad package name: " + e.getMessage());
--- a/hotspot/test/runtime/modules/ModuleStress/ModuleStress.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/runtime/modules/ModuleStress/ModuleStress.java	Wed Jul 05 23:25:53 2017 +0200
@@ -53,7 +53,7 @@
         //   those loaders never die.
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
              "-Xbootclasspath/a:.",
-             "-Xlog:modules=trace",
+             "-Xlog:module=trace",
              "-version");
 
         OutputAnalyzer oa = new OutputAnalyzer(pb.start());
@@ -88,7 +88,7 @@
         //   the same loader and thus have the exact same life cycle.
         pb = ProcessTools.createJavaProcessBuilder(
              "-Xbootclasspath/a:.",
-             "-Xlog:modules=trace",
+             "-Xlog:module=trace",
              "ModuleSameCLMain");
 
         oa = new OutputAnalyzer(pb.start());
@@ -102,7 +102,7 @@
         //   class loaders which could die and thus be unloaded.
         pb = ProcessTools.createJavaProcessBuilder(
              "-Xbootclasspath/a:.",
-             "-Xlog:modules=trace",
+             "-Xlog:module=trace",
              "ModuleNonBuiltinCLMain");
 
         oa = new OutputAnalyzer(pb.start());
@@ -120,7 +120,7 @@
         pb = ProcessTools.createJavaProcessBuilder(
              "-Djava.system.class.loader=CustomSystemClassLoader",
              "-Xbootclasspath/a:.",
-             "-Xlog:modules=trace",
+             "-Xlog:module=trace",
              "ModuleNonBuiltinCLMain");
 
         oa = new OutputAnalyzer(pb.start());
--- a/hotspot/test/runtime/modules/ModuleStress/ModuleStressGC.java	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/runtime/modules/ModuleStress/ModuleStressGC.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -73,7 +73,7 @@
         // test's, defined to module jdk.translet, export list at
         // GC safepoints.
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-            "-Xlog:modules=trace",
+            "-Xlog:module=trace",
             "-p", MODS_DIR.toString(),
             "-m", "jdk.test/test.MainGC");
         OutputAnalyzer oa = new OutputAnalyzer(pb.start());
--- a/hotspot/test/testlibrary/ctw/Makefile	Thu May 11 20:23:41 2017 +0000
+++ b/hotspot/test/testlibrary/ctw/Makefile	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2013, 2016. Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
--- a/jdk/.hgtags	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/.hgtags	Wed Jul 05 23:25:53 2017 +0200
@@ -418,3 +418,4 @@
 329609d00aef2443cf1e44ded94637c5ed55a143 jdk-10+6
 7828aedcb525df40b7c8122bcc3f997c75ebaf7f jdk-9+167
 e78da9db6299b3fcba49300d52e2359e82fdd218 jdk-9+168
+177436a54ca13730ffc725a6e5dbfcd9486f3da3 jdk-9+169
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/make/data/docs-resources/specs/resources/jdk-default.css	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+body {
+  margin: 2em 2em;
+  font-family: DejaVu Sans, Bitstream Vera Sans, Luxi Sans, Verdana, Arial, Helvetica;
+  font-size: 10pt;
+  line-height: 1.4;
+}
+
+pre, code, tt {
+  font-family: DejaVu Sans Mono, Bitstream Vera Sans Mono, Luxi Mono,
+    Courier New, monospace;
+}
+
+blockquote {
+  margin: 1.5ex 0em 1.5ex 2em;
+}
+
+p {
+  padding: 0pt;
+  margin: 1ex 0em;
+}
+
+p:first-child, pre:first-child { margin-top: 0pt; }
+
+h1 {
+  font-weight: bold;
+  padding: 0pt;
+  margin: 2ex .5ex 1ex 0pt;
+}
+
+h1:first-child, h2:first-child {
+  margin-top: 0ex;
+}
+
+h2 {
+  font-weight: bold;
+  padding: 0pt;
+  margin: 2ex 0pt 1ex 0pt;
+}
+
+h3 {
+  font-weight: bold;
+  padding: 0pt;
+  margin: 1.5ex 0pt 1ex 0pt;
+}
+
+h4 {
+  font-weight: bold;
+  padding: 0pt;
+  margin: 1.5ex 0pt 1ex 0pt;
+}
+
+a:link {
+  color: #437291;
+}
+
+a:visited {
+  color: #666666;
+}
+
+a[href]:hover {
+  color: #e76f00;
+}
+
+a img {
+  border-width: 0px;
+}
+
+img {
+  background: white;
+}
+
+table {
+  border-collapse: collapse;
+  margin-left: 15px;
+  margin-right: 15px;
+}
+
+th, td {
+  padding: 3px;
+  vertical-align: top;
+}
+
+table, th, td {
+  border: 1px solid black;
+}
+
+caption  {
+  text-align: left;
+  font-style: italic;
+  text-indent: 15px;
+  margin-bottom:10px;
+}
+
+tr:nth-child(even) {
+  background: #DDD;
+}
+
+tr:nth-child(odd) {
+  background: #FFF;
+}
+
+th {
+  background: #DDF;
+}
--- a/jdk/make/mapfiles/libinstrument/mapfile-vers	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/make/mapfiles/libinstrument/mapfile-vers	Wed Jul 05 23:25:53 2017 +0200
@@ -39,6 +39,7 @@
             Java_sun_instrument_InstrumentationImpl_getObjectSize0;
 	    Java_sun_instrument_InstrumentationImpl_appendToClassLoaderSearch0;
 	    Java_sun_instrument_InstrumentationImpl_setNativeMethodPrefixes;
+            Java_sun_instrument_InstrumentationImpl_loadAgent0;
 	local:
 		*;
 };
--- a/jdk/src/java.base/aix/native/libnet/aix_close.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/aix/native/libnet/aix_close.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2016, SAP SE and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, SAP SE and/or its affiliates. All rights reserved.
  * 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,6 +65,8 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/poll.h>
+#include "jvm.h"
+#include "net_util.h"
 
 /*
  * Stack allocated by thread when doing blocking operation
@@ -507,9 +509,9 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout0(int s, long timeout, long currentTime) {
-    long prevtime = currentTime, newtime;
-    struct timeval t;
+int NET_Timeout(JNIEnv *env, int s, long timeout, jlong nanoTimeStamp) {
+    jlong prevNanoTime = nanoTimeStamp;
+    jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
     fdEntry_t *fdEntry = getFdEntry(s);
 
     /*
@@ -533,7 +535,7 @@
         pfd.events = POLLIN | POLLERR;
 
         startOp(fdEntry, &self);
-        rv = poll(&pfd, 1, timeout);
+        rv = poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
         endOp(fdEntry, &self);
 
         /*
@@ -541,18 +543,14 @@
          * has expired return 0 (indicating timeout expired).
          */
         if (rv < 0 && errno == EINTR) {
-            if (timeout > 0) {
-                gettimeofday(&t, NULL);
-                newtime = t.tv_sec * 1000  +  t.tv_usec / 1000;
-                timeout -= newtime - prevtime;
-                if (timeout <= 0) {
-                    return 0;
-                }
-                prevtime = newtime;
+            jlong newNanoTime = JVM_NanoTime(env, 0);
+            nanoTimeout -= newNanoTime - prevNanoTime;
+            if (nanoTimeout < NET_NSEC_PER_MSEC) {
+                return 0;
             }
+            prevNanoTime = newNanoTime;
         } else {
             return rv;
         }
-
     }
 }
--- a/jdk/src/java.base/linux/native/libnet/linux_close.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/linux/native/libnet/linux_close.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,8 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/poll.h>
+#include "jvm.h"
+#include "net_util.h"
 
 /*
  * Stack allocated by thread when doing blocking operation
@@ -410,9 +412,9 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout0(int s, long timeout, long currentTime) {
-    long prevtime = currentTime, newtime;
-    struct timeval t;
+int NET_Timeout(JNIEnv *env, int s, long timeout, jlong nanoTimeStamp) {
+    jlong prevNanoTime = nanoTimeStamp;
+    jlong nanoTimeout = (jlong)timeout * NET_NSEC_PER_MSEC;
     fdEntry_t *fdEntry = getFdEntry(s);
 
     /*
@@ -436,26 +438,21 @@
         pfd.events = POLLIN | POLLERR;
 
         startOp(fdEntry, &self);
-        rv = poll(&pfd, 1, timeout);
+        rv = poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
         endOp(fdEntry, &self);
-
         /*
          * If interrupted then adjust timeout. If timeout
          * has expired return 0 (indicating timeout expired).
          */
         if (rv < 0 && errno == EINTR) {
-            if (timeout > 0) {
-                gettimeofday(&t, NULL);
-                newtime = t.tv_sec * 1000  +  t.tv_usec / 1000;
-                timeout -= newtime - prevtime;
-                if (timeout <= 0) {
-                    return 0;
-                }
-                prevtime = newtime;
+            jlong newNanoTime = JVM_NanoTime(env, 0);
+            nanoTimeout -= newNanoTime - prevNanoTime;
+            if (nanoTimeout < NET_NSEC_PER_MSEC) {
+                return 0;
             }
+            prevNanoTime = newNanoTime;
         } else {
             return rv;
         }
-
     }
 }
--- a/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -136,8 +136,7 @@
  *  |
  * \|/
  * ParseArguments
- * (removes -d32 and -d64 if any,
- *  processes version options,
+ * (processes version options,
  *  creates argument list for vm,
  *  etc.)
  *   |
@@ -147,20 +146,20 @@
  *   |
  *   |
  *  \|/
- * Path is desired JRE ? YES --> Have Desired Model ? NO --> Re-exec --> Main
- *  NO                               YES --> Continue
+ * Path is desired JRE ? YES --> Continue
+ *  NO
  *   |
  *   |
  *  \|/
  * Paths have well known
- * jvm paths ?       --> NO --> Have Desired Model ? NO --> Re-exec --> Main
- *  YES                              YES --> Continue
+ * jvm paths ?       --> NO --> Continue
+ *  YES
  *   |
  *   |
  *  \|/
  *  Does libjvm.so exist
- *  in any of them ? --> NO --> Have Desired Model ? NO --> Re-exec --> Main
- *   YES                             YES --> Continue
+ *  in any of them ? --> NO --> Continue
+ *   YES
  *   |
  *   |
  *  \|/
@@ -217,7 +216,7 @@
     }
 
     char jvmPath[PATH_MAX];
-    jboolean gotJVMPath = GetJVMPath(jrePath, preferredJVM, jvmPath, sizeof(jvmPath), CURRENT_DATA_MODEL);
+    jboolean gotJVMPath = GetJVMPath(jrePath, preferredJVM, jvmPath, sizeof(jvmPath));
     if (!gotJVMPath) {
         JLI_ReportErrorMessage("Failed to GetJVMPath()");
         return NULL;
@@ -362,203 +361,51 @@
                            char jrepath[], jint so_jrepath,
                            char jvmpath[], jint so_jvmpath,
                            char jvmcfg[],  jint so_jvmcfg) {
-  /*
-   * First, determine if we are running the desired data model.  If we
-   * are running the desired data model, all the error messages
-   * associated with calling GetJREPath, ReadKnownVMs, etc. should be
-   * output.  However, if we are not running the desired data model,
-   * some of the errors should be suppressed since it is more
-   * informative to issue an error message based on whether or not the
-   * os/processor combination has dual mode capabilities.
-   */
     jboolean jvmpathExists;
 
     /* Compute/set the name of the executable */
     SetExecname(*pargv);
 
-    /* Check data model flags, and exec process, if needed */
-    {
-      char * jvmtype    = NULL;
-      int  argc         = *pargc;
-      char **argv       = *pargv;
-      int running       = CURRENT_DATA_MODEL;
-
-      int wanted        = running;      /* What data mode is being
-                                           asked for? Current model is
-                                           fine unless another model
-                                           is asked for */
-
-      char** newargv    = NULL;
-      int    newargc    = 0;
-
-      /*
-       * Starting in 1.5, all unix platforms accept the -d32 and -d64
-       * options.  On platforms where only one data-model is supported
-       * (e.g. ia-64 Linux), using the flag for the other data model is
-       * an error and will terminate the program.
-       */
-
-      { /* open new scope to declare local variables */
-        int i;
-
-        newargv = (char **)JLI_MemAlloc((argc+1) * sizeof(char*));
-        newargv[newargc++] = argv[0];
-
-        /* scan for data model arguments and remove from argument list;
-           last occurrence determines desired data model */
-        for (i=1; i < argc; i++) {
-
-          if (JLI_StrCmp(argv[i], "-J-d64") == 0 || JLI_StrCmp(argv[i], "-d64") == 0) {
-            wanted = 64;
-            continue;
-          }
-          if (JLI_StrCmp(argv[i], "-J-d32") == 0 || JLI_StrCmp(argv[i], "-d32") == 0) {
-            wanted = 32;
-            continue;
-          }
-          newargv[newargc++] = argv[i];
-
-          if (IsJavaArgs()) {
-            if (argv[i][0] != '-') continue;
-          } else {
-            if (JLI_StrCmp(argv[i], "-classpath") == 0 || JLI_StrCmp(argv[i], "-cp") == 0) {
-              i++;
-              if (i >= argc) break;
-              newargv[newargc++] = argv[i];
-              continue;
-            }
-            if (argv[i][0] != '-') { i++; break; }
-          }
-        }
-
-        /* copy rest of args [i .. argc) */
-        while (i < argc) {
-          newargv[newargc++] = argv[i++];
-        }
-        newargv[newargc] = NULL;
-
-        /*
-         * newargv has all proper arguments here
-         */
-
-        argc = newargc;
-        argv = newargv;
-      }
-
-      /* If the data model is not changing, it is an error if the
-         jvmpath does not exist */
-      if (wanted == running) {
-        /* Find out where the JRE is that we will be using. */
-        if (!GetJREPath(jrepath, so_jrepath, JNI_FALSE) ) {
-          JLI_ReportErrorMessage(JRE_ERROR1);
-          exit(2);
-        }
-        JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%s%s%sjvm.cfg",
-          jrepath, FILESEP, FILESEP,  "", "");
-        /* Find the specified JVM type */
-        if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) {
-          JLI_ReportErrorMessage(CFG_ERROR7);
-          exit(1);
-        }
+    char * jvmtype    = NULL;
+    int  argc         = *pargc;
+    char **argv       = *pargv;
 
-        jvmpath[0] = '\0';
-        jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE);
-        if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
-            JLI_ReportErrorMessage(CFG_ERROR9);
-            exit(4);
-        }
-
-        if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, wanted)) {
-          JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
-          exit(4);
-        }
-
-        /*
-         * Mac OS X requires the Cocoa event loop to be run on the "main"
-         * thread. Spawn off a new thread to run main() and pass
-         * this thread off to the Cocoa event loop.
-         */
-        MacOSXStartup(argc, argv);
-
-        /*
-         * we seem to have everything we need, so without further ado
-         * we return back, otherwise proceed to set the environment.
-         */
-        return;
-      } else {  /* do the same speculatively or exit */
-#if defined(DUAL_MODE)
-        if (running != wanted) {
-          /* Find out where the JRE is that we will be using. */
-          if (!GetJREPath(jrepath, so_jrepath, JNI_TRUE)) {
-            /* give up and let other code report error message */
-            JLI_ReportErrorMessage(JRE_ERROR2, wanted);
-            exit(1);
-          }
-          JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%s%s%sjvm.cfg",
-            jrepath, FILESEP, FILESEP,  "", "");
-          /*
-           * Read in jvm.cfg for target data model and process vm
-           * selection options.
-           */
-          if (ReadKnownVMs(jvmcfg, JNI_TRUE) < 1) {
-            /* give up and let other code report error message */
-            JLI_ReportErrorMessage(JRE_ERROR2, wanted);
-            exit(1);
-          }
-          jvmpath[0] = '\0';
-          jvmtype = CheckJvmType(pargc, pargv, JNI_TRUE);
-          if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
-            JLI_ReportErrorMessage(CFG_ERROR9);
-            exit(4);
-          }
-
-          /* exec child can do error checking on the existence of the path */
-          jvmpathExists = GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, wanted);
-        }
-#else /* ! DUAL_MODE */
-        JLI_ReportErrorMessage(JRE_ERROR2, wanted);
-        exit(1);
-#endif /* DUAL_MODE */
-        }
-        {
-            char *newexec = execname;
-            JLI_TraceLauncher("TRACER_MARKER:About to EXEC\n");
-            (void) fflush(stdout);
-            (void) fflush(stderr);
-            /*
-            * Use posix_spawn() instead of execv() on Mac OS X.
-            * This allows us to choose which architecture the child process
-            * should run as.
-            */
-            {
-                posix_spawnattr_t attr;
-                size_t unused_size;
-                pid_t  unused_pid;
-
-#if defined(__i386__) || defined(__x86_64__)
-                cpu_type_t cpu_type[] = { (wanted == 64) ? CPU_TYPE_X86_64 : CPU_TYPE_X86,
-                                    (running== 64) ? CPU_TYPE_X86_64 : CPU_TYPE_X86 };
-#else
-                cpu_type_t cpu_type[] = { CPU_TYPE_ANY };
-#endif /* __i386 .. */
-
-                posix_spawnattr_init(&attr);
-                posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETEXEC);
-                posix_spawnattr_setbinpref_np(&attr, sizeof(cpu_type) / sizeof(cpu_type_t),
-                                            cpu_type, &unused_size);
-
-                posix_spawn(&unused_pid, newexec, NULL, &attr, argv, environ);
-            }
-            JLI_ReportErrorMessageSys(JRE_ERROR4, newexec);
-
-#if defined(DUAL_MODE)
-            if (running != wanted) {
-                JLI_ReportErrorMessage(JRE_ERROR5, wanted, running);
-            }
-#endif /* DUAL_MODE */
-        }
+    /* Find out where the JRE is that we will be using. */
+    if (!GetJREPath(jrepath, so_jrepath, JNI_FALSE) ) {
+        JLI_ReportErrorMessage(JRE_ERROR1);
+        exit(2);
+    }
+    JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%sjvm.cfg",
+                 jrepath, FILESEP, FILESEP);
+    /* Find the specified JVM type */
+    if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) {
+        JLI_ReportErrorMessage(CFG_ERROR7);
         exit(1);
     }
+
+    jvmpath[0] = '\0';
+    jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE);
+    if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
+        JLI_ReportErrorMessage(CFG_ERROR9);
+        exit(4);
+    }
+
+    if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) {
+        JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
+        exit(4);
+    }
+
+    /*
+     * Mac OS X requires the Cocoa event loop to be run on the "main"
+     * thread. Spawn off a new thread to run main() and pass
+     * this thread off to the Cocoa event loop.
+     */
+    MacOSXStartup(argc, argv);
+
+    /*
+     * we seem to have everything we need
+     */
+    return;
 }
 
 /*
@@ -566,7 +413,7 @@
  */
 static jboolean
 GetJVMPath(const char *jrepath, const char *jvmtype,
-           char *jvmpath, jint jvmpathsize, int bitsWanted)
+           char *jvmpath, jint jvmpathsize)
 {
     struct stat s;
 
@@ -577,8 +424,7 @@
          * macosx client library is built thin, i386 only.
          * 64 bit client requests must load server library
          */
-        const char *jvmtypeUsed = ((bitsWanted == 64) && (strcmp(jvmtype, "client") == 0)) ? "server" : jvmtype;
-        JLI_Snprintf(jvmpath, jvmpathsize, "%s/lib/%s/" JVM_DLL, jrepath, jvmtypeUsed);
+        JLI_Snprintf(jvmpath, jvmpathsize, "%s/lib/%s/" JVM_DLL, jrepath, jvmtype);
     }
 
     JLI_TraceLauncher("Does `%s' exist ... ", jvmpath);
--- a/jdk/src/java.base/macosx/native/libnet/DefaultProxySelector.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/macosx/native/libnet/DefaultProxySelector.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2017 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
--- a/jdk/src/java.base/macosx/native/libnet/bsd_close.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/macosx/native/libnet/bsd_close.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,6 +39,8 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/poll.h>
+#include "jvm.h"
+#include "net_util.h"
 
 /*
  * Stack allocated by thread when doing blocking operation
@@ -414,8 +416,7 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout0(int s, long timeout, long currentTime) {
-    long prevtime = currentTime, newtime;
+int NET_Timeout(JNIEnv *env, int s, long timeout, jlong nanoTimeStamp) {
     struct timeval t, *tp = &t;
     fd_set fds;
     fd_set* fdsp = NULL;
@@ -460,6 +461,8 @@
     }
     FD_SET(s, fdsp);
 
+    jlong prevNanoTime = nanoTimeStamp;
+    jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
     for(;;) {
         int rv;
 
@@ -477,25 +480,21 @@
          * has expired return 0 (indicating timeout expired).
          */
         if (rv < 0 && errno == EINTR) {
-            if (timeout > 0) {
-                struct timeval now;
-                gettimeofday(&now, NULL);
-                newtime = now.tv_sec * 1000  +  now.tv_usec / 1000;
-                timeout -= newtime - prevtime;
-                if (timeout <= 0) {
-                    if (allocated != 0)
-                        free(fdsp);
-                    return 0;
-                }
-                prevtime = newtime;
-                t.tv_sec = timeout / 1000;
-                t.tv_usec = (timeout % 1000) * 1000;
+            jlong newNanoTime = JVM_NanoTime(env, 0);
+            nanoTimeout -= newNanoTime - prevNanoTime;
+            if (nanoTimeout < NET_NSEC_PER_MSEC) {
+                if (allocated != 0)
+                    free(fdsp);
+                return 0;
             }
+            prevNanoTime = newNanoTime;
+            t.tv_sec = nanoTimeout / NET_NSEC_PER_SEC;
+            t.tv_usec = (nanoTimeout % NET_NSEC_PER_SEC) / NET_NSEC_PER_USEC;
+
         } else {
             if (allocated != 0)
                 free(fdsp);
             return rv;
         }
-
     }
 }
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/GCTR.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/GCTR.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/PropMap.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/PropMap.java	Wed Jul 05 23:25:53 2017 +0200
@@ -29,6 +29,8 @@
 import java.io.InputStream;
 import java.io.PrintStream;
 import java.io.PrintWriter;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Comparator;
@@ -62,12 +64,17 @@
         Properties props = new Properties();
 
         // Allow implementation selected via -Dpack.disable.native=true
+        String propValue = getPropertyValue(Utils.DEBUG_DISABLE_NATIVE, "false");
         props.put(Utils.DEBUG_DISABLE_NATIVE,
-                  String.valueOf(Boolean.getBoolean(Utils.DEBUG_DISABLE_NATIVE)));
+                  String.valueOf(Boolean.parseBoolean(propValue)));
 
         // Set the DEBUG_VERBOSE from system
-        props.put(Utils.DEBUG_VERBOSE,
-                  String.valueOf(Integer.getInteger(Utils.DEBUG_VERBOSE,0)));
+        int verbose = 0;
+        try {
+            verbose = Integer.decode(getPropertyValue(Utils.DEBUG_VERBOSE, "0"));
+        } catch (NumberFormatException e) {
+        }
+        props.put(Utils.DEBUG_VERBOSE, String.valueOf(verbose));
 
         // The segment size is unlimited
         props.put(Pack200.Packer.SEGMENT_LIMIT, "-1");
@@ -87,7 +94,7 @@
         // Pass through files with unrecognized format by default, also
         // allow system property to be set
         props.put(Utils.CLASS_FORMAT_ERROR,
-                System.getProperty(Utils.CLASS_FORMAT_ERROR, Pack200.Packer.PASS));
+                  getPropertyValue(Utils.CLASS_FORMAT_ERROR, Pack200.Packer.PASS));
 
         // Default effort is 5, midway between 1 and 9.
         props.put(Pack200.Packer.EFFORT, "5");
@@ -97,7 +104,9 @@
         // to allow override if necessary.
         String propFile = "intrinsic.properties";
 
-        try (InputStream propStr = PackerImpl.class.getResourceAsStream(propFile)) {
+        PrivilegedAction<InputStream> pa =
+            () -> PackerImpl.class.getResourceAsStream(propFile);
+        try (InputStream propStr = AccessController.doPrivileged(pa)) {
             if (propStr == null) {
                 throw new RuntimeException(propFile + " cannot be loaded");
             }
@@ -119,6 +128,12 @@
         defaultProps = temp;
     }
 
+    private static String getPropertyValue(String key, String defaultValue) {
+        PrivilegedAction<String> pa = () -> System.getProperty(key);
+        String s = AccessController.doPrivileged(pa);
+        return s != null ? s : defaultValue;
+    }
+
     PropMap() {
         theMap.putAll(defaultProps);
     }
--- a/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java	Wed Jul 05 23:25:53 2017 +0200
@@ -40,10 +40,8 @@
  *
  * <p> Each invocation of a write() method causes the encoding converter to be
  * invoked on the given character(s).  The resulting bytes are accumulated in a
- * buffer before being written to the underlying output stream.  The size of
- * this buffer may be specified, but by default it is large enough for most
- * purposes.  Note that the characters passed to the write() methods are not
- * buffered.
+ * buffer before being written to the underlying output stream.  Note that the
+ * characters passed to the write() methods are not buffered.
  *
  * <p> For top efficiency, consider wrapping an OutputStreamWriter within a
  * BufferedWriter so as to avoid frequent converter invocations.  For example:
--- a/jdk/src/java.base/share/classes/java/lang/Class.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java	Wed Jul 05 23:25:53 2017 +0200
@@ -2875,19 +2875,19 @@
         static <T> boolean casReflectionData(Class<?> clazz,
                                              SoftReference<ReflectionData<T>> oldData,
                                              SoftReference<ReflectionData<T>> newData) {
-            return unsafe.compareAndSwapObject(clazz, reflectionDataOffset, oldData, newData);
+            return unsafe.compareAndSetObject(clazz, reflectionDataOffset, oldData, newData);
         }
 
         static <T> boolean casAnnotationType(Class<?> clazz,
                                              AnnotationType oldType,
                                              AnnotationType newType) {
-            return unsafe.compareAndSwapObject(clazz, annotationTypeOffset, oldType, newType);
+            return unsafe.compareAndSetObject(clazz, annotationTypeOffset, oldType, newType);
         }
 
         static <T> boolean casAnnotationData(Class<?> clazz,
                                              AnnotationData oldData,
                                              AnnotationData newData) {
-            return unsafe.compareAndSwapObject(clazz, annotationDataOffset, oldData, newData);
+            return unsafe.compareAndSetObject(clazz, annotationDataOffset, oldData, newData);
         }
     }
 
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Wed Jul 05 23:25:53 2017 +0200
@@ -119,18 +119,24 @@
  * The Java run-time has the following built-in class loaders:
  *
  * <ul>
- * <li>Bootstrap class loader.
+ * <li><p>Bootstrap class loader.
  *     It is the virtual machine's built-in class loader, typically represented
  *     as {@code null}, and does not have a parent.</li>
- * <li>{@linkplain #getPlatformClassLoader() Platform class loader}.
+ * <li><p>{@linkplain #getPlatformClassLoader() Platform class loader}.
  *     All <em>platform classes</em> are visible to the platform class loader
  *     that can be used as the parent of a {@code ClassLoader} instance.
  *     Platform classes include Java SE platform APIs, their implementation
  *     classes and JDK-specific run-time classes that are defined by the
- *     platform class loader or its ancestors.</li>
- * <li>{@linkplain #getSystemClassLoader() System class loader}.
- *     It is also known as <em>application class
- *     loader</em> and is distinct from the platform class loader.
+ *     platform class loader or its ancestors.
+ *     <p> To allow for upgrading/overriding of modules defined to the platform
+ *     class loader, and where classes in the upgraded version link to
+ *     classes in modules defined to the application class loader, the
+ *     platform class loader may delegate to the application class loader.
+ *     In other words, classes in named modules defined to the application
+ *     class loader may be visible to the platform class loader. </li>
+ * <li><p>{@linkplain #getSystemClassLoader() System class loader}.
+ *     It is also known as <em>application class loader</em> and is distinct
+ *     from the platform class loader.
  *     The system class loader is typically used to define classes on the
  *     application class path, module path, and JDK-specific tools.
  *     The platform class loader is a parent or an ancestor of the system class
@@ -368,6 +374,10 @@
      * Creates a new class loader of the specified name and using the
      * specified parent class loader for delegation.
      *
+     * @apiNote If the parent is specified as {@code null} (for the
+     * bootstrap class loader) then there is no guarantee that all platform
+     * classes are visible.
+     *
      * @param  name   class loader name; or {@code null} if not named
      * @param  parent the parent class loader
      *
@@ -390,9 +400,12 @@
      * delegation.
      *
      * <p> If there is a security manager, its {@link
-     * SecurityManager#checkCreateClassLoader()
-     * checkCreateClassLoader} method is invoked.  This may result in
-     * a security exception.  </p>
+     * SecurityManager#checkCreateClassLoader() checkCreateClassLoader} method
+     * is invoked.  This may result in a security exception.  </p>
+     *
+     * @apiNote If the parent is specified as {@code null} (for the
+     * bootstrap class loader) then there is no guarantee that all platform
+     * classes are visible.
      *
      * @param  parent
      *         The parent class loader
@@ -2206,6 +2219,12 @@
      * this class loader are searched recursively (parent by parent)
      * for a {@code Package} of the given name.
      *
+     * @apiNote The {@link #getPlatformClassLoader() platform class loader}
+     * may delegate to the application class loader but the application class
+     * loader is not its ancestor.  When invoked on the platform class loader,
+     * this method  will not find packages defined to the application
+     * class loader.
+     *
      * @param  name
      *         The <a href="#name">package name</a>
      *
@@ -2251,6 +2270,14 @@
      * {@code Package} object of the same package name, each defined by
      * a different class loader in the class loader hierarchy.
      *
+     * @apiNote The {@link #getPlatformClassLoader() platform class loader}
+     * may delegate to the application class loader. In other words,
+     * packages in modules defined to the application class loader may be
+     * visible to the platform class loader.  On the other hand,
+     * the application class loader is not its ancestor and hence
+     * when invoked on the platform class loader, this method will not
+     * return any packages defined to the application class loader.
+     *
      * @return  The array of {@code Package} objects defined by this
      *          class loader and its ancestors
      *
@@ -2857,7 +2884,7 @@
         } catch (NoSuchFieldException e) {
             throw new InternalError(e);
         }
-        return unsafe.compareAndSwapObject(this, offset, null, obj);
+        return unsafe.compareAndSetObject(this, offset, null, obj);
     }
 }
 
--- a/jdk/src/java.base/share/classes/java/lang/Module.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/Module.java	Wed Jul 05 23:25:53 2017 +0200
@@ -57,6 +57,7 @@
 import jdk.internal.loader.BootLoader;
 import jdk.internal.misc.JavaLangAccess;
 import jdk.internal.misc.SharedSecrets;
+import jdk.internal.module.ModuleLoaderMap;
 import jdk.internal.module.ServicesCatalog;
 import jdk.internal.module.Resources;
 import jdk.internal.org.objectweb.asm.AnnotationVisitor;
@@ -215,8 +216,8 @@
     }
 
     /**
-     * Returns the layer that contains this module or {@code null} if this
-     * module is not in a layer.
+     * Returns the module layer that contains this module or {@code null} if
+     * this module is not in a module layer.
      *
      * A module layer contains named modules and therefore this method always
      * returns {@code null} when invoked on an unnamed module.
@@ -691,6 +692,13 @@
      * <p> This method has no effect if the package is already <em>open</em>
      * to the given module. </p>
      *
+     * @apiNote This method can be used for cases where a <em>consumer
+     * module</em> uses a qualified opens to open a package to an <em>API
+     * module</em> but where the reflective access to the members of classes in
+     * the consumer module is delegated to code in another module. Code in the
+     * API module can use this method to open the package in the consumer module
+     * to the other module.
+     *
      * @param  pn
      *         The package name
      * @param  other
@@ -1077,7 +1085,7 @@
             if (loader != null) {
                 moduleToLoader.put(name, loader);
                 loaders.add(loader);
-            } else if (!isBootLayer) {
+            } else if (!(clf instanceof ModuleLoaderMap.Mapper)) {
                 throw new IllegalArgumentException("loader can't be 'null'");
             }
         }
@@ -1458,11 +1466,11 @@
      *     encapsulated. </li>
      *
      *     <li> A <em>package name</em> is derived from the resource name. If
-     *     the package name is a {@link #getPackages() package} in the module
-     *     then the resource can only be located by the caller of this method
-     *     when the package is {@link #isOpen(String,Module) open} to at least
-     *     the caller's module. If the resource is not in a package in the module
-     *     then the resource is not encapsulated. </li>
+     *     the package name is a {@linkplain #getPackages() package} in the
+     *     module then the resource can only be located by the caller of this
+     *     method when the package is {@linkplain #isOpen(String,Module) open}
+     *     to at least the caller's module. If the resource is not in a
+     *     package in the module then the resource is not encapsulated. </li>
      * </ul>
      *
      * <p> In the above, the <em>package name</em> for a resource is derived
@@ -1521,8 +1529,7 @@
         }
 
         // locate resource in module
-        JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
-        URL url = jla.findResource(loader, mn, name);
+        URL url = loader.findResource(mn, name);
         if (url != null) {
             try {
                 return url.openStream();
--- a/jdk/src/java.base/share/classes/java/lang/SecurityManager.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/SecurityManager.java	Wed Jul 05 23:25:53 2017 +0200
@@ -25,10 +25,10 @@
 
 package java.lang;
 
-import java.lang.RuntimePermission;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleDescriptor.Exports;
 import java.lang.module.ModuleDescriptor.Opens;
+import java.lang.module.ModuleReference;
 import java.lang.reflect.Member;
 import java.io.FileDescriptor;
 import java.io.File;
@@ -42,12 +42,15 @@
 import java.security.Security;
 import java.security.SecurityPermission;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Objects;
 import java.util.PropertyPermission;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
+import jdk.internal.module.ModuleBootstrap;
+import jdk.internal.module.ModuleLoaderMap;
 import jdk.internal.reflect.CallerSensitive;
 import sun.security.util.SecurityConstants;
 
@@ -1431,29 +1434,29 @@
         return packages;
     }
 
-    // The non-exported packages of the modules in the boot layer that are
-    // loaded by the platform class loader or its ancestors. A non-exported
-    // package is a package that either is not exported at all by its containing
-    // module or is exported in a qualified fashion by its containing module.
-    private static final Set<String> nonExportedPkgs;
-
+    // The non-exported packages in modules defined to the boot or platform
+    // class loaders. A non-exported package is a package that is not exported
+    // or is only exported to specific modules.
+    private static final Map<String, Boolean> nonExportedPkgs = new ConcurrentHashMap<>();
     static {
-        // Get the modules in the boot layer
-        Stream<Module> bootLayerModules = ModuleLayer.boot().modules().stream();
+        addNonExportedPackages(ModuleLayer.boot());
+    }
 
-        // Filter out the modules loaded by the boot or platform loader
-        PrivilegedAction<Set<Module>> pa = () ->
-            bootLayerModules.filter(SecurityManager::isBootOrPlatformModule)
-                            .collect(Collectors.toSet());
-        Set<Module> modules = AccessController.doPrivileged(pa);
+    /**
+     * Record the non-exported packages of the modules in the given layer
+     */
+    static void addNonExportedPackages(ModuleLayer layer) {
+        Set<String> bootModules = ModuleLoaderMap.bootModules();
+        Set<String> platformModules = ModuleLoaderMap.platformModules();
+        layer.modules().stream()
+                .map(Module::getDescriptor)
+                .filter(md -> bootModules.contains(md.name())
+                        || platformModules.contains(md.name()))
+                .map(SecurityManager::nonExportedPkgs)
+                .flatMap(Set::stream)
+                .forEach(pn -> nonExportedPkgs.put(pn, Boolean.TRUE));
+    }
 
-        // Filter out the non-exported packages
-        nonExportedPkgs = modules.stream()
-                                 .map(Module::getDescriptor)
-                                 .map(SecurityManager::nonExportedPkgs)
-                                 .flatMap(Set::stream)
-                                 .collect(Collectors.toSet());
-    }
 
     /**
      * Called by java.security.Security
@@ -1468,14 +1471,6 @@
     }
 
     /**
-     * Returns true if the module's loader is the boot or platform loader.
-     */
-    private static boolean isBootOrPlatformModule(Module m) {
-        return m.getClassLoader() == null ||
-               m.getClassLoader() == ClassLoader.getPlatformClassLoader();
-    }
-
-    /**
      * Returns the non-exported packages of the specified module.
      */
     private static Set<String> nonExportedPkgs(ModuleDescriptor md) {
@@ -1535,7 +1530,7 @@
         Objects.requireNonNull(pkg, "package name can't be null");
 
         // check if pkg is not exported to all modules
-        if (nonExportedPkgs.contains(pkg)) {
+        if (nonExportedPkgs.containsKey(pkg)) {
             checkPermission(
                 new RuntimePermission("accessClassInPackage." + pkg));
             return;
@@ -1634,7 +1629,7 @@
         Objects.requireNonNull(pkg, "package name can't be null");
 
         // check if pkg is not exported to all modules
-        if (nonExportedPkgs.contains(pkg)) {
+        if (nonExportedPkgs.containsKey(pkg)) {
             checkPermission(
                 new RuntimePermission("defineClassInPackage." + pkg));
             return;
--- a/jdk/src/java.base/share/classes/java/lang/System.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/System.java	Wed Jul 05 23:25:53 2017 +0200
@@ -41,7 +41,6 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.net.URI;
-import java.net.URL;
 import java.security.AccessControlContext;
 import java.security.ProtectionDomain;
 import java.security.AccessController;
@@ -2113,9 +2112,6 @@
             public Class<?> findBootstrapClassOrNull(ClassLoader cl, String name) {
                 return cl.findBootstrapClassOrNull(name);
             }
-            public URL findResource(ClassLoader cl, String mn, String name) throws IOException {
-                return cl.findResource(mn, name);
-            }
             public Stream<Package> packages(ClassLoader cl) {
                 return cl.packages();
             }
@@ -2125,6 +2121,9 @@
             public String fastUUID(long lsb, long msb) {
                 return Long.fastUUID(lsb, msb);
             }
+            public void addNonExportedPackages(ModuleLayer layer) {
+                SecurityManager.addNonExportedPackages(layer);
+            }
             public void invalidatePackageAccessCache() {
                 SecurityManager.invalidatePackageAccessCache();
             }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Wed Jul 05 23:25:53 2017 +0200
@@ -113,6 +113,19 @@
     }
 
     /**
+     * This reflected$lookup method is the alternate implementation of
+     * the lookup method when being invoked by reflection.
+     */
+    @CallerSensitive
+    private static Lookup reflected$lookup() {
+        Class<?> caller = Reflection.getCallerClass();
+        if (caller.getClassLoader() == null) {
+            throw newIllegalArgumentException("illegal lookupClass: "+caller);
+        }
+        return new Lookup(caller);
+    }
+
+    /**
      * Returns a {@link Lookup lookup object} which is trusted minimally.
      * The lookup has the {@code PUBLIC} and {@code UNCONDITIONAL} modes.
      * It can only be used to create method handles to public members of
@@ -747,7 +760,7 @@
         Lookup(Class<?> lookupClass) {
             this(lookupClass, FULL_POWER_MODES);
             // make sure we haven't accidentally picked up a privileged class:
-            checkUnprivilegedlookupClass(lookupClass, FULL_POWER_MODES);
+            checkUnprivilegedlookupClass(lookupClass);
         }
 
         private Lookup(Class<?> lookupClass, int allowedModes) {
@@ -827,7 +840,7 @@
                 newModes = 0;
             }
 
-            checkUnprivilegedlookupClass(requestedLookupClass, newModes);
+            checkUnprivilegedlookupClass(requestedLookupClass);
             return new Lookup(requestedLookupClass, newModes);
         }
 
@@ -876,9 +889,7 @@
          * accessible to the class. The {@code PACKAGE} lookup mode serves to authenticate
          * that the lookup object was created by a caller in the runtime package (or derived
          * from a lookup originally created by suitably privileged code to a target class in
-         * the runtime package). The lookup modes cannot include {@link #PRIVATE PRIVATE}
-         * access. A lookup with {@code PRIVATE} access can be downgraded to drop this lookup
-         * mode with the {@linkplain #dropLookupMode(int) dropLookupMode} method. </p>
+         * the runtime package). </p>
          *
          * <p> The {@code bytes} parameter is the class bytes of a valid class file (as defined
          * by the <em>The Java Virtual Machine Specification</em>) with a class name in the
@@ -896,7 +907,6 @@
          * @throws IllegalArgumentException the bytes are for a class in a different package
          * to the lookup class
          * @throws IllegalAccessException if this lookup does not have {@code PACKAGE} access
-         * @throws UnsupportedOperationException if the lookup class has {@code PRIVATE} access
          * @throws LinkageError if the class is malformed ({@code ClassFormatError}), cannot be
          * verified ({@code VerifyError}), is already defined, or another linkage error occurs
          * @throws SecurityException if denied by the security manager
@@ -911,8 +921,6 @@
             SecurityManager sm = System.getSecurityManager();
             if (sm != null)
                 sm.checkPermission(new RuntimePermission("defineClass"));
-            if (hasPrivateAccess())
-                throw new UnsupportedOperationException("PRIVATE access not supported");
             if ((lookupModes() & PACKAGE) == 0)
                 throw new IllegalAccessException("Lookup does not have PACKAGE access");
             assert (lookupModes() & (MODULE|PUBLIC)) != 0;
@@ -984,25 +992,10 @@
          */
         static final Lookup PUBLIC_LOOKUP = new Lookup(Object.class, (PUBLIC|UNCONDITIONAL));
 
-        private static void checkUnprivilegedlookupClass(Class<?> lookupClass, int allowedModes) {
+        private static void checkUnprivilegedlookupClass(Class<?> lookupClass) {
             String name = lookupClass.getName();
             if (name.startsWith("java.lang.invoke."))
                 throw newIllegalArgumentException("illegal lookupClass: "+lookupClass);
-
-            // For caller-sensitive MethodHandles.lookup() disallow lookup from
-            // restricted packages.  This a fragile and blunt approach.
-            // TODO replace with a more formal and less fragile mechanism
-            // that does not bluntly restrict classes under packages within
-            // java.base from looking up MethodHandles or VarHandles.
-            if (allowedModes == FULL_POWER_MODES && lookupClass.getClassLoader() == null) {
-                if ((name.startsWith("java.") &&
-                     !name.equals("java.lang.Thread") &&
-                     !name.startsWith("java.util.concurrent.")) ||
-                    (name.startsWith("sun.") &&
-                     !name.startsWith("sun.invoke."))) {
-                    throw newIllegalArgumentException("illegal lookupClass: " + lookupClass);
-                }
-            }
         }
 
         /**
@@ -1662,7 +1655,7 @@
          * (If the trailing array argument is the only argument,
          * the given receiver value will be bound to it.)
          * <p>
-         * This is equivalent to the following code:
+         * This is almost equivalent to the following code, with some differences noted below:
          * <blockquote><pre>{@code
 import static java.lang.invoke.MethodHandles.*;
 import static java.lang.invoke.MethodType.*;
@@ -1675,7 +1668,10 @@
          * where {@code defc} is either {@code receiver.getClass()} or a super
          * type of that class, in which the requested method is accessible
          * to the lookup class.
-         * (Note that {@code bindTo} does not preserve variable arity.)
+         * (Unlike {@code bind}, {@code bindTo} does not preserve variable arity.
+         * Also, {@code bindTo} may throw a {@code ClassCastException} in instances where {@code bind} would
+         * throw a {@code IllegalAccessException}, as in the case where the member is {@code protected} and
+         * the receiver is restricted by {@code findVirtual} to the lookup class)
          * @param receiver the object from which the method is accessed
          * @param name the name of the method
          * @param type the type of the method, with the receiver argument omitted
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -125,7 +125,7 @@
 
         @ForceInline
         static boolean compareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            return UNSAFE.compareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.compareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -133,7 +133,7 @@
 
         @ForceInline
         static $type$ compareAndExchange(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            return UNSAFE.compareAndExchange$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.compareAndExchange$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -157,7 +157,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetPlain(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.weakCompareAndSet$Type$Plain(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -165,7 +165,7 @@
 
         @ForceInline
         static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.weakCompareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -173,7 +173,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.weakCompareAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -181,7 +181,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.weakCompareAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -275,7 +275,7 @@
                                        handle.fieldOffset,
                                        value);
         }
-        
+
         @ForceInline
         static $type$ getAndBitwiseXor(FieldInstanceReadWrite handle, Object holder, $type$ value) {
             return UNSAFE.getAndBitwiseXor$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
@@ -392,7 +392,7 @@
 
         @ForceInline
         static boolean compareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            return UNSAFE.compareAndSwap$Type$(handle.base,
+            return UNSAFE.compareAndSet$Type$(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -401,7 +401,7 @@
 
         @ForceInline
         static $type$ compareAndExchange(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            return UNSAFE.compareAndExchange$Type$Volatile(handle.base,
+            return UNSAFE.compareAndExchange$Type$(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -425,7 +425,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetPlain(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$(handle.base,
+            return UNSAFE.weakCompareAndSet$Type$Plain(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -433,7 +433,7 @@
 
         @ForceInline
         static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$Volatile(handle.base,
+            return UNSAFE.weakCompareAndSet$Type$(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -441,7 +441,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$Acquire(handle.base,
+            return UNSAFE.weakCompareAndSet$Type$Acquire(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -449,7 +449,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$Release(handle.base,
+            return UNSAFE.weakCompareAndSet$Type$Release(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -689,7 +689,7 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            return UNSAFE.compareAndSwap$Type$(array,
+            return UNSAFE.compareAndSet$Type$(array,
                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
@@ -702,7 +702,7 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            return UNSAFE.compareAndExchange$Type$Volatile(array,
+            return UNSAFE.compareAndExchange$Type$(array,
                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
@@ -741,7 +741,7 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            return UNSAFE.weakCompareAndSwap$Type$(array,
+            return UNSAFE.weakCompareAndSet$Type$Plain(array,
                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
@@ -754,7 +754,7 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            return UNSAFE.weakCompareAndSwap$Type$Volatile(array,
+            return UNSAFE.weakCompareAndSet$Type$(array,
                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
@@ -767,7 +767,7 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            return UNSAFE.weakCompareAndSwap$Type$Acquire(array,
+            return UNSAFE.weakCompareAndSet$Type$Acquire(array,
                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
@@ -780,7 +780,7 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            return UNSAFE.weakCompareAndSwap$Type$Release(array,
+            return UNSAFE.weakCompareAndSet$Type$Release(array,
                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
@@ -897,7 +897,7 @@
                                        (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                                        value);
         }
-        
+
         @ForceInline
         static $type$ getAndBitwiseXor(Array handle, Object oarray, int index, $type$ value) {
             $type$[] array = ($type$[]) oarray;
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -186,7 +186,7 @@
         @ForceInline
         static boolean compareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
-            return UNSAFE.compareAndSwap$RawType$(
+            return UNSAFE.compareAndSet$RawType$(
                     ba,
                     address(ba, index(ba, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -196,7 +196,7 @@
         static $type$ compareAndExchange(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
             return convEndian(handle.be,
-                              UNSAFE.compareAndExchange$RawType$Volatile(
+                              UNSAFE.compareAndExchange$RawType$(
                                       ba,
                                       address(ba, index(ba, index)),
                                       convEndian(handle.be, expected), convEndian(handle.be, value)));
@@ -225,7 +225,7 @@
         @ForceInline
         static boolean weakCompareAndSetPlain(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
-            return UNSAFE.weakCompareAndSwap$RawType$(
+            return UNSAFE.weakCompareAndSet$RawType$Plain(
                     ba,
                     address(ba, index(ba, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -234,7 +234,7 @@
         @ForceInline
         static boolean weakCompareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
-            return UNSAFE.weakCompareAndSwap$RawType$Volatile(
+            return UNSAFE.weakCompareAndSet$RawType$(
                     ba,
                     address(ba, index(ba, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -243,7 +243,7 @@
         @ForceInline
         static boolean weakCompareAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
-            return UNSAFE.weakCompareAndSwap$RawType$Acquire(
+            return UNSAFE.weakCompareAndSet$RawType$Acquire(
                     ba,
                     address(ba, index(ba, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -252,7 +252,7 @@
         @ForceInline
         static boolean weakCompareAndSetRelease(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
-            return UNSAFE.weakCompareAndSwap$RawType$Release(
+            return UNSAFE.weakCompareAndSet$RawType$Release(
                     ba,
                     address(ba, index(ba, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -336,7 +336,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(ba, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta)));
             return expectedValue;
         }
@@ -389,7 +389,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(ba, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value)));
             return expectedValue;
         }
@@ -440,7 +440,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(ba, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value)));
             return expectedValue;
         }
@@ -491,7 +491,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(ba, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value)));
             return expectedValue;
         }
@@ -625,7 +625,7 @@
         @ForceInline
         static boolean compareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
-            return UNSAFE.compareAndSwap$RawType$(
+            return UNSAFE.compareAndSet$RawType$(
                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -635,7 +635,7 @@
         static $type$ compareAndExchange(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
             return convEndian(handle.be,
-                              UNSAFE.compareAndExchange$RawType$Volatile(
+                              UNSAFE.compareAndExchange$RawType$(
                                       UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                                       address(bb, indexRO(bb, index)),
                                       convEndian(handle.be, expected), convEndian(handle.be, value)));
@@ -664,7 +664,7 @@
         @ForceInline
         static boolean weakCompareAndSetPlain(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
-            return UNSAFE.weakCompareAndSwap$RawType$(
+            return UNSAFE.weakCompareAndSet$RawType$Plain(
                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -673,7 +673,7 @@
         @ForceInline
         static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
-            return UNSAFE.weakCompareAndSwap$RawType$Volatile(
+            return UNSAFE.weakCompareAndSet$RawType$(
                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -682,7 +682,7 @@
         @ForceInline
         static boolean weakCompareAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
-            return UNSAFE.weakCompareAndSwap$RawType$Acquire(
+            return UNSAFE.weakCompareAndSet$RawType$Acquire(
                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -691,7 +691,7 @@
         @ForceInline
         static boolean weakCompareAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
-            return UNSAFE.weakCompareAndSwap$RawType$Release(
+            return UNSAFE.weakCompareAndSet$RawType$Release(
                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -776,7 +776,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta)));
             return expectedValue;
         }
@@ -830,7 +830,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value)));
             return expectedValue;
         }
@@ -882,12 +882,12 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value)));
             return expectedValue;
         }
-        
-        
+
+
         @ForceInline
         static $type$ getAndBitwiseXor(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
@@ -935,7 +935,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value)));
             return expectedValue;
         }
--- a/jdk/src/java.base/share/classes/java/lang/module/Configuration.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/Configuration.java	Wed Jul 05 23:25:53 2017 +0200
@@ -109,20 +109,17 @@
     private final Set<ResolvedModule> modules;
     private final Map<String, ResolvedModule> nameToModule;
 
-    // module constraints on target
-    private final String osName;
-    private final String osArch;
+    // constraint on target platform
+    private final String targetPlatform;
 
-    String osName() { return osName; }
-    String osArch() { return osArch; }
+    String targetPlatform() { return targetPlatform; }
 
     private Configuration() {
         this.parents = Collections.emptyList();
         this.graph = Collections.emptyMap();
         this.modules = Collections.emptySet();
         this.nameToModule = Collections.emptyMap();
-        this.osName = null;
-        this.osArch = null;
+        this.targetPlatform = null;
     }
 
     private Configuration(List<Configuration> parents,
@@ -147,8 +144,7 @@
         this.modules = Set.of(moduleArray);
         this.nameToModule = Map.ofEntries(nameEntries);
 
-        this.osName = resolver.osName();
-        this.osArch = resolver.osArch();
+        this.targetPlatform = resolver.targetPlatform();
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java	Wed Jul 05 23:25:53 2017 +0200
@@ -99,6 +99,7 @@
      *
      * @see ModuleDescriptor#modifiers()
      * @since 9
+     * @spec JPMS
      */
     public static enum Modifier {
         /**
--- a/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleFinder.java	Wed Jul 05 23:25:53 2017 +0200
@@ -286,8 +286,9 @@
      *     class names of provider classes. </p></li>
      *
      *     <li><p> If the JAR file has a {@code Main-Class} attribute in its
-     *     main manifest then its value is the module {@link
-     *     ModuleDescriptor#mainClass() main class}. </p></li>
+     *     main manifest, its value is a legal class name, and its package is
+     *     in the set of packages derived for the module, then the value is the
+     *     module {@linkplain ModuleDescriptor#mainClass() main class}. </p></li>
      *
      * </ul>
      *
@@ -298,8 +299,7 @@
      * file, where the JAR file contains a {@code .class} in the top-level
      * directory of the JAR file, where an entry in a service configuration
      * file is not a legal class name or its package name is not in the set of
-     * packages derived for the module, or where the module main class is not
-     * a legal class name or its package is not in the module. </p>
+     * packages derived for the module. </p>
      *
      * <p> In addition to JAR files, an implementation may also support modules
      * that are packaged in other implementation specific module formats. If
--- a/jdk/src/java.base/share/classes/java/lang/module/Resolver.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/lang/module/Resolver.java	Wed Jul 05 23:25:53 2017 +0200
@@ -28,6 +28,7 @@
 import java.io.PrintStream;
 import java.lang.module.ModuleDescriptor.Provides;
 import java.lang.module.ModuleDescriptor.Requires.Modifier;
+import java.net.URI;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -38,10 +39,8 @@
 import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
-import java.util.StringJoiner;
 import java.util.stream.Collectors;
 
 import jdk.internal.module.ModuleHashes;
@@ -69,12 +68,10 @@
     // true if all automatic modules have been found
     private boolean haveAllAutomaticModules;
 
-    // module constraints on target platform
-    private String osName;
-    private String osArch;
+    // constraint on target platform
+    private String targetPlatform;
 
-    String osName() { return osName; }
-    String osArch() { return osArch; }
+    String targetPlatform() { return targetPlatform; }
 
     /**
      * @throws IllegalArgumentException if there are more than one parent and
@@ -89,37 +86,23 @@
         this.afterFinder = afterFinder;
         this.traceOutput = traceOutput;
 
-        // record constraints on target platform, checking that they don't conflict
+        // record constraint on target platform, checking for conflicts
         for (Configuration parent : parents) {
-            String value = parent.osName();
+            String value = parent.targetPlatform();
             if (value != null) {
-                if (osName == null) {
-                    osName = value;
+                if (targetPlatform == null) {
+                    targetPlatform = value;
                 } else {
-                    if (!value.equals(osName)) {
-                        failParentConflict("Operating System", osName, value);
-                    }
-                }
-            }
-            value = parent.osArch();
-            if (value != null) {
-                if (osArch == null) {
-                    osArch = value;
-                } else {
-                    if (!value.equals(osArch)) {
-                        failParentConflict("OS architecture", osArch, value);
+                    if (!value.equals(targetPlatform)) {
+                        String msg = "Parents have conflicting constraints on target" +
+                                     "  platform: " + targetPlatform + ", " + value;
+                        throw new IllegalArgumentException(msg);
                     }
                 }
             }
         }
     }
 
-    private void failParentConflict(String constraint, String s1, String s2) {
-        String msg = "Parents have conflicting constraints on target "
-                     + constraint + ": " + s1 + ", " + s2;
-        throw new IllegalArgumentException(msg);
-    }
-
     /**
      * Resolves the given named modules.
      *
@@ -147,8 +130,7 @@
             }
 
             if (isTracing()) {
-                trace("Root module %s located", root);
-                mref.location().ifPresent(uri -> trace("  (%s)", uri));
+                trace("root %s", nameAndInfo(mref));
             }
 
             addFoundModule(mref);
@@ -180,9 +162,7 @@
                     ModuleDescriptor other = mref.descriptor();
                     q.offer(other);
                     if (isTracing()) {
-                        trace("Automatic module %s located, required by %s",
-                              other.name(), descriptor.name());
-                        mref.location().ifPresent(uri -> trace("  (%s)", uri));
+                        trace("%s requires %s", descriptor.name(), nameAndInfo(mref));
                     }
                 });
                 haveAllAutomaticModules = true;
@@ -213,21 +193,13 @@
                     }
                 }
 
+                if (isTracing() && !dn.equals("java.base")) {
+                    trace("%s requires %s", descriptor.name(), nameAndInfo(mref));
+                }
+
                 if (!nameToReference.containsKey(dn)) {
                     addFoundModule(mref);
                     q.offer(mref.descriptor());
-
-                    if (isTracing()) {
-                        String prefix;
-                        if (mref.descriptor().isAutomatic()) {
-                            prefix = "Automatic module";
-                        } else {
-                            prefix = "Module";
-                        }
-                        trace(prefix + " %s located, required by %s",
-                              dn, descriptor.name());
-                        mref.location().ifPresent(uri -> trace("  (%s)", uri));
-                    }
                 }
 
             }
@@ -291,6 +263,13 @@
         do {
             for (ModuleDescriptor descriptor : candidateConsumers) {
                 if (!descriptor.uses().isEmpty()) {
+
+                    // the modules that provide at least one service
+                    Set<ModuleDescriptor> modulesToBind = null;
+                    if (isTracing()) {
+                        modulesToBind = new HashSet<>();
+                    }
+
                     for (String service : descriptor.uses()) {
                         Set<ModuleReference> mrefs = availableProviders.get(service);
                         if (mrefs != null) {
@@ -298,15 +277,13 @@
                                 ModuleDescriptor provider = mref.descriptor();
                                 if (!provider.equals(descriptor)) {
 
-                                    trace("Module %s provides %s, used by %s",
-                                            provider.name(), service, descriptor.name());
+                                    if (isTracing() && modulesToBind.add(provider)) {
+                                        trace("%s binds %s", descriptor.name(),
+                                                nameAndInfo(mref));
+                                    }
 
                                     String pn = provider.name();
                                     if (!nameToReference.containsKey(pn)) {
-                                        if (isTracing()) {
-                                            mref.location()
-                                                .ifPresent(uri -> trace("  (%s)", uri));
-                                        }
                                         addFoundModule(mref);
                                         q.push(provider);
                                     }
@@ -349,59 +326,31 @@
         if (mref instanceof ModuleReferenceImpl) {
             ModuleTarget target = ((ModuleReferenceImpl)mref).moduleTarget();
             if (target != null)
-                checkTargetConstraints(mn, target);
+                checkTargetPlatform(mn, target);
         }
 
         nameToReference.put(mn, mref);
     }
 
     /**
-     * Check that the module's constraints on the target platform do not
-     * conflict with the constraints of other modules resolved so far or
-     * modules in parent configurations.
+     * Check that the module's constraints on the target platform does
+     * conflict with the constraint of other modules resolved so far.
      */
-    private void checkTargetConstraints(String mn, ModuleTarget target) {
-        String value = target.osName();
+    private void checkTargetPlatform(String mn, ModuleTarget target) {
+        String value = target.targetPlatform();
         if (value != null) {
-            if (osName == null) {
-                osName = value;
+            if (targetPlatform == null) {
+                targetPlatform = value;
             } else {
-                if (!value.equals(osName)) {
-                    failTargetConstraint(mn, target);
-                }
-            }
-        }
-        value = target.osArch();
-        if (value != null) {
-            if (osArch == null) {
-                osArch = value;
-            } else {
-                if (!value.equals(osArch)) {
-                    failTargetConstraint(mn, target);
+                if (!value.equals(targetPlatform)) {
+                    findFail("Module %s has constraints on target platform (%s)"
+                             + " that conflict with other modules: %s", mn,
+                             value, targetPlatform);
                 }
             }
         }
     }
 
-    private void failTargetConstraint(String mn, ModuleTarget target) {
-        String s1 = targetAsString(osName, osArch);
-        String s2 = targetAsString(target.osName(), target.osArch());
-        findFail("Module %s has constraints on target platform (%s) that"
-                 + " conflict with other modules: %s", mn, s1, s2);
-    }
-
-    private String targetAsString(ModuleTarget target) {
-        return targetAsString(target.osName(), target.osArch());
-    }
-
-    private String targetAsString(String osName, String osArch) {
-        return new StringJoiner("-")
-                .add(Objects.toString(osName, "*"))
-                .add(Objects.toString(osArch, "*"))
-                .toString();
-    }
-
-
     /**
      * Execute post-resolution checks and returns the module graph of resolved
      * modules as {@code Map}. The resolved modules will be in the given
@@ -412,12 +361,6 @@
     Map<ResolvedModule, Set<ResolvedModule>> finish(Configuration cf,
                                                     boolean check)
     {
-        if (isTracing()) {
-            trace("Result:");
-            Set<String> names = nameToReference.keySet();
-            names.stream().sorted().forEach(name -> trace("  %s", name));
-        }
-
         if (check) {
             detectCycles();
             checkHashes();
@@ -520,9 +463,8 @@
                     findFail("Unable to compute the hash of module %s", dn);
                 }
 
-                // skip checking the hash if the module has been patched
                 ModuleReferenceImpl other = (ModuleReferenceImpl)mref2;
-                if (other != null && !other.isPatched()) {
+                if (other != null) {
                     byte[] recordedHash = hashes.hashFor(dn);
                     byte[] actualHash = other.computeHash(algorithm);
                     if (actualHash == null)
@@ -965,9 +907,17 @@
 
     private void trace(String fmt, Object ... args) {
         if (traceOutput != null) {
-            traceOutput.format("[Resolver] " + fmt, args);
+            traceOutput.format(fmt, args);
             traceOutput.println();
         }
     }
 
+    private String nameAndInfo(ModuleReference mref) {
+        ModuleDescriptor descriptor = mref.descriptor();
+        StringBuilder sb = new StringBuilder(descriptor.name());
+        mref.location().ifPresent(uri -> sb.append(" " + uri));
+        if (descriptor.isAutomatic())
+            sb.append(" automatic");
+        return sb.toString();
+    }
 }
--- a/jdk/src/java.base/share/classes/java/nio/file/FileSystems.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/nio/file/FileSystems.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,6 +36,8 @@
 import java.util.ServiceConfigurationError;
 import java.util.ServiceLoader;
 
+import jdk.internal.misc.VM;
+
 /**
  * Factory methods for file systems. This class defines the {@link #getDefault
  * getDefault} method to get the default file system and factory methods to
@@ -120,8 +122,8 @@
 
             // if the property java.nio.file.spi.DefaultFileSystemProvider is
             // set then its value is the name of the default provider (or a list)
-            String propValue = System
-                .getProperty("java.nio.file.spi.DefaultFileSystemProvider");
+            String prop = "java.nio.file.spi.DefaultFileSystemProvider";
+            String propValue = System.getProperty(prop);
             if (propValue != null) {
                 for (String cn: propValue.split(",")) {
                     try {
@@ -184,7 +186,7 @@
      * @return  the default file system
      */
     public static FileSystem getDefault() {
-        if (jdk.internal.misc.VM.isBooted()) {
+        if (VM.isModuleSystemInited()) {
             return DefaultFileSystemHolder.defaultFileSystem;
         } else {
             return BuiltinFileSystemHolder.builtinFileSystem;
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Wed Jul 05 23:25:53 2017 +0200
@@ -768,7 +768,7 @@
 
     static final <K,V> boolean casTabAt(Node<K,V>[] tab, int i,
                                         Node<K,V> c, Node<K,V> v) {
-        return U.compareAndSwapObject(tab, ((long)i << ASHIFT) + ABASE, c, v);
+        return U.compareAndSetObject(tab, ((long)i << ASHIFT) + ABASE, c, v);
     }
 
     static final <K,V> void setTabAt(Node<K,V>[] tab, int i, Node<K,V> v) {
@@ -2300,7 +2300,7 @@
         while ((tab = table) == null || tab.length == 0) {
             if ((sc = sizeCtl) < 0)
                 Thread.yield(); // lost initialization race; just spin
-            else if (U.compareAndSwapInt(this, SIZECTL, sc, -1)) {
+            else if (U.compareAndSetInt(this, SIZECTL, sc, -1)) {
                 try {
                     if ((tab = table) == null || tab.length == 0) {
                         int n = (sc > 0) ? sc : DEFAULT_CAPACITY;
@@ -2331,13 +2331,13 @@
     private final void addCount(long x, int check) {
         CounterCell[] as; long b, s;
         if ((as = counterCells) != null ||
-            !U.compareAndSwapLong(this, BASECOUNT, b = baseCount, s = b + x)) {
+            !U.compareAndSetLong(this, BASECOUNT, b = baseCount, s = b + x)) {
             CounterCell a; long v; int m;
             boolean uncontended = true;
             if (as == null || (m = as.length - 1) < 0 ||
                 (a = as[ThreadLocalRandom.getProbe() & m]) == null ||
                 !(uncontended =
-                  U.compareAndSwapLong(a, CELLVALUE, v = a.value, v + x))) {
+                  U.compareAndSetLong(a, CELLVALUE, v = a.value, v + x))) {
                 fullAddCount(x, uncontended);
                 return;
             }
@@ -2355,10 +2355,10 @@
                         sc == rs + MAX_RESIZERS || (nt = nextTable) == null ||
                         transferIndex <= 0)
                         break;
-                    if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1))
+                    if (U.compareAndSetInt(this, SIZECTL, sc, sc + 1))
                         transfer(tab, nt);
                 }
-                else if (U.compareAndSwapInt(this, SIZECTL, sc,
+                else if (U.compareAndSetInt(this, SIZECTL, sc,
                                              (rs << RESIZE_STAMP_SHIFT) + 2))
                     transfer(tab, null);
                 s = sumCount();
@@ -2379,7 +2379,7 @@
                 if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||
                     sc == rs + MAX_RESIZERS || transferIndex <= 0)
                     break;
-                if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1)) {
+                if (U.compareAndSetInt(this, SIZECTL, sc, sc + 1)) {
                     transfer(tab, nextTab);
                     break;
                 }
@@ -2402,7 +2402,7 @@
             Node<K,V>[] tab = table; int n;
             if (tab == null || (n = tab.length) == 0) {
                 n = (sc > c) ? sc : c;
-                if (U.compareAndSwapInt(this, SIZECTL, sc, -1)) {
+                if (U.compareAndSetInt(this, SIZECTL, sc, -1)) {
                     try {
                         if (table == tab) {
                             @SuppressWarnings("unchecked")
@@ -2419,7 +2419,7 @@
                 break;
             else if (tab == table) {
                 int rs = resizeStamp(n);
-                if (U.compareAndSwapInt(this, SIZECTL, sc,
+                if (U.compareAndSetInt(this, SIZECTL, sc,
                                         (rs << RESIZE_STAMP_SHIFT) + 2))
                     transfer(tab, null);
             }
@@ -2460,7 +2460,7 @@
                     i = -1;
                     advance = false;
                 }
-                else if (U.compareAndSwapInt
+                else if (U.compareAndSetInt
                          (this, TRANSFERINDEX, nextIndex,
                           nextBound = (nextIndex > stride ?
                                        nextIndex - stride : 0))) {
@@ -2477,7 +2477,7 @@
                     sizeCtl = (n << 1) - (n >>> 1);
                     return;
                 }
-                if (U.compareAndSwapInt(this, SIZECTL, sc = sizeCtl, sc - 1)) {
+                if (U.compareAndSetInt(this, SIZECTL, sc = sizeCtl, sc - 1)) {
                     if ((sc - 2) != resizeStamp(n) << RESIZE_STAMP_SHIFT)
                         return;
                     finishing = advance = true;
@@ -2602,7 +2602,7 @@
                     if (cellsBusy == 0) {            // Try to attach new Cell
                         CounterCell r = new CounterCell(x); // Optimistic create
                         if (cellsBusy == 0 &&
-                            U.compareAndSwapInt(this, CELLSBUSY, 0, 1)) {
+                            U.compareAndSetInt(this, CELLSBUSY, 0, 1)) {
                             boolean created = false;
                             try {               // Recheck under lock
                                 CounterCell[] rs; int m, j;
@@ -2624,14 +2624,14 @@
                 }
                 else if (!wasUncontended)       // CAS already known to fail
                     wasUncontended = true;      // Continue after rehash
-                else if (U.compareAndSwapLong(a, CELLVALUE, v = a.value, v + x))
+                else if (U.compareAndSetLong(a, CELLVALUE, v = a.value, v + x))
                     break;
                 else if (counterCells != as || n >= NCPU)
                     collide = false;            // At max size or stale
                 else if (!collide)
                     collide = true;
                 else if (cellsBusy == 0 &&
-                         U.compareAndSwapInt(this, CELLSBUSY, 0, 1)) {
+                         U.compareAndSetInt(this, CELLSBUSY, 0, 1)) {
                     try {
                         if (counterCells == as) {// Expand table unless stale
                             CounterCell[] rs = new CounterCell[n << 1];
@@ -2648,7 +2648,7 @@
                 h = ThreadLocalRandom.advanceProbe(h);
             }
             else if (cellsBusy == 0 && counterCells == as &&
-                     U.compareAndSwapInt(this, CELLSBUSY, 0, 1)) {
+                     U.compareAndSetInt(this, CELLSBUSY, 0, 1)) {
                 boolean init = false;
                 try {                           // Initialize table
                     if (counterCells == as) {
@@ -2663,7 +2663,7 @@
                 if (init)
                     break;
             }
-            else if (U.compareAndSwapLong(this, BASECOUNT, v = baseCount, v + x))
+            else if (U.compareAndSetLong(this, BASECOUNT, v = baseCount, v + x))
                 break;                          // Fall back on using base
         }
     }
@@ -2859,7 +2859,7 @@
          * Acquires write lock for tree restructuring.
          */
         private final void lockRoot() {
-            if (!U.compareAndSwapInt(this, LOCKSTATE, 0, WRITER))
+            if (!U.compareAndSetInt(this, LOCKSTATE, 0, WRITER))
                 contendedLock(); // offload to separate method
         }
 
@@ -2877,14 +2877,14 @@
             boolean waiting = false;
             for (int s;;) {
                 if (((s = lockState) & ~WAITER) == 0) {
-                    if (U.compareAndSwapInt(this, LOCKSTATE, s, WRITER)) {
+                    if (U.compareAndSetInt(this, LOCKSTATE, s, WRITER)) {
                         if (waiting)
                             waiter = null;
                         return;
                     }
                 }
                 else if ((s & WAITER) == 0) {
-                    if (U.compareAndSwapInt(this, LOCKSTATE, s, s | WAITER)) {
+                    if (U.compareAndSetInt(this, LOCKSTATE, s, s | WAITER)) {
                         waiting = true;
                         waiter = Thread.currentThread();
                     }
@@ -2909,7 +2909,7 @@
                             return e;
                         e = e.next;
                     }
-                    else if (U.compareAndSwapInt(this, LOCKSTATE, s,
+                    else if (U.compareAndSetInt(this, LOCKSTATE, s,
                                                  s + READER)) {
                         TreeNode<K,V> r, p;
                         try {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java	Wed Jul 05 23:25:53 2017 +0200
@@ -140,7 +140,7 @@
      * the actual value was not equal to the expected value.
      */
     public final boolean compareAndSet(int expectedValue, int newValue) {
-        return U.compareAndSwapInt(this, VALUE, expectedValue, newValue);
+        return U.compareAndSetInt(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -161,7 +161,7 @@
      */
     @Deprecated(since="9")
     public final boolean weakCompareAndSet(int expectedValue, int newValue) {
-        return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetIntPlain(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -175,7 +175,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetPlain(int expectedValue, int newValue) {
-        return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetIntPlain(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -473,7 +473,7 @@
      * @since 9
      */
     public final int compareAndExchange(int expectedValue, int newValue) {
-        return U.compareAndExchangeIntVolatile(this, VALUE, expectedValue, newValue);
+        return U.compareAndExchangeInt(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -520,7 +520,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetVolatile(int expectedValue, int newValue) {
-        return U.weakCompareAndSwapIntVolatile(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetInt(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -535,7 +535,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetAcquire(int expectedValue, int newValue) {
-        return U.weakCompareAndSwapIntAcquire(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetIntAcquire(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -550,7 +550,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetRelease(int expectedValue, int newValue) {
-        return U.weakCompareAndSwapIntRelease(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetIntRelease(this, VALUE, expectedValue, newValue);
     }
 
 }
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java	Wed Jul 05 23:25:53 2017 +0200
@@ -481,12 +481,12 @@
 
         public final boolean compareAndSet(T obj, int expect, int update) {
             accessCheck(obj);
-            return U.compareAndSwapInt(obj, offset, expect, update);
+            return U.compareAndSetInt(obj, offset, expect, update);
         }
 
         public final boolean weakCompareAndSet(T obj, int expect, int update) {
             accessCheck(obj);
-            return U.compareAndSwapInt(obj, offset, expect, update);
+            return U.compareAndSetInt(obj, offset, expect, update);
         }
 
         public final void set(T obj, int newValue) {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java	Wed Jul 05 23:25:53 2017 +0200
@@ -56,7 +56,7 @@
 
     /**
      * Records whether the underlying JVM supports lockless
-     * compareAndSwap for longs. While the intrinsic compareAndSwapLong
+     * compareAndSet for longs. While the intrinsic compareAndSetLong
      * method works in either case, some constructions should be
      * handled at Java level to avoid locking user-visible locks.
      */
@@ -119,7 +119,7 @@
      */
     public final void set(long newValue) {
         // Use putLongVolatile instead of ordinary volatile store when
-        // using compareAndSwapLong, for sake of some 32bit systems.
+        // using compareAndSetLong, for sake of some 32bit systems.
         U.putLongVolatile(this, VALUE, newValue);
     }
 
@@ -156,7 +156,7 @@
      * the actual value was not equal to the expected value.
      */
     public final boolean compareAndSet(long expectedValue, long newValue) {
-        return U.compareAndSwapLong(this, VALUE, expectedValue, newValue);
+        return U.compareAndSetLong(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -177,7 +177,7 @@
      */
     @Deprecated(since="9")
     public final boolean weakCompareAndSet(long expectedValue, long newValue) {
-        return U.weakCompareAndSwapLong(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetLongPlain(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -191,7 +191,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetPlain(long expectedValue, long newValue) {
-        return U.weakCompareAndSwapLong(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetLongPlain(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -487,7 +487,7 @@
      * @since 9
      */
     public final long compareAndExchange(long expectedValue, long newValue) {
-        return U.compareAndExchangeLongVolatile(this, VALUE, expectedValue, newValue);
+        return U.compareAndExchangeLong(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -534,7 +534,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetVolatile(long expectedValue, long newValue) {
-        return U.weakCompareAndSwapLongVolatile(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetLong(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -549,7 +549,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetAcquire(long expectedValue, long newValue) {
-        return U.weakCompareAndSwapLongAcquire(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetLongAcquire(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -564,7 +564,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetRelease(long expectedValue, long newValue) {
-        return U.weakCompareAndSwapLongRelease(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetLongRelease(this, VALUE, expectedValue, newValue);
     }
 
 }
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java	Wed Jul 05 23:25:53 2017 +0200
@@ -454,12 +454,12 @@
 
         public final boolean compareAndSet(T obj, long expect, long update) {
             accessCheck(obj);
-            return U.compareAndSwapLong(obj, offset, expect, update);
+            return U.compareAndSetLong(obj, offset, expect, update);
         }
 
         public final boolean weakCompareAndSet(T obj, long expect, long update) {
             accessCheck(obj);
-            return U.compareAndSwapLong(obj, offset, expect, update);
+            return U.compareAndSetLong(obj, offset, expect, update);
         }
 
         public final void set(T obj, long newValue) {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java	Wed Jul 05 23:25:53 2017 +0200
@@ -432,14 +432,14 @@
         public final boolean compareAndSet(T obj, V expect, V update) {
             accessCheck(obj);
             valueCheck(update);
-            return U.compareAndSwapObject(obj, offset, expect, update);
+            return U.compareAndSetObject(obj, offset, expect, update);
         }
 
         public final boolean weakCompareAndSet(T obj, V expect, V update) {
             // same implementation as strong form for now
             accessCheck(obj);
             valueCheck(update);
-            return U.compareAndSwapObject(obj, offset, expect, update);
+            return U.compareAndSetObject(obj, offset, expect, update);
         }
 
         public final void set(T obj, V newValue) {
--- a/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/javax/crypto/CipherInputStream.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -93,7 +93,7 @@
     // stream status
     private boolean closed = false;
 
-    /**
+    /*
      * private convenience function.
      *
      * Entry condition: ostart = ofinish
--- a/jdk/src/java.base/share/classes/javax/crypto/CryptoPermission.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/javax/crypto/CryptoPermission.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -196,19 +196,19 @@
      * Checks if the specified permission is "implied" by
      * this object.
      * <p>
-     * More specifically, this method returns true if:<p>
+     * More specifically, this method returns true if:
      * <ul>
-     * <li> <i>p</i> is an instance of CryptoPermission, and<p>
+     * <li> <i>p</i> is an instance of CryptoPermission, and</li>
      * <li> <i>p</i>'s algorithm name equals or (in the case of wildcards)
-     *       is implied by this permission's algorithm name, and<p>
+     *       is implied by this permission's algorithm name, and</li>
      * <li> <i>p</i>'s maximum allowable key size is less or
-     *       equal to this permission's maximum allowable key size, and<p>
+     *       equal to this permission's maximum allowable key size, and</li>
      * <li> <i>p</i>'s algorithm parameter spec equals or is
-     *        implied by this permission's algorithm parameter spec, and<p>
+     *        implied by this permission's algorithm parameter spec, and</li>
      * <li> <i>p</i>'s exemptionMechanism equals or
      *        is implied by this permission's
      *        exemptionMechanism (a <code>null</code> exemption mechanism
-     *        implies any other exemption mechanism).
+     *        implies any other exemption mechanism).</li>
      * </ul>
      *
      * @param p the permission to check against.
--- a/jdk/src/java.base/share/classes/javax/crypto/CryptoPolicyParser.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/javax/crypto/CryptoPolicyParser.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,10 +46,12 @@
  *
  * The format of a permission entry in the jurisdiction policy file is:
  *
+ * <pre>{@code
  *   permission <crypto permission class name>[, <algorithm name>
  *              [[, <exemption mechanism name>][, <maxKeySize>
  *              [, <AlgrithomParameterSpec class name>, <parameters
  *              for constructing an AlgrithomParameterSpec object>]]]];
+ * }</pre>
  *
  * @author Sharon Liu
  *
@@ -526,8 +528,7 @@
 
     /**
      * Each grant entry in the policy configuration file is  represented by a
-     * GrantEntry object.  <p>
-     *
+     * GrantEntry object.
      * <p>
      * For example, the entry
      * <pre>
@@ -587,8 +588,7 @@
 
     /**
      * Each crypto permission entry in the policy configuration file is
-     * represented by a CryptoPermissionEntry object.  <p>
-     *
+     * represented by a CryptoPermissionEntry object.
      * <p>
      * For example, the entry
      * <pre>
--- a/jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/loader/BuiltinClassLoader.java	Wed Jul 05 23:25:53 2017 +0200
@@ -172,12 +172,10 @@
     }
 
     /**
-     * Register a module this this class loader. This has the effect of making
-     * the types in the module visible.
+     * Register a module this class loader. This has the effect of making the
+     * types in the module visible.
      */
     public void loadModule(ModuleReference mref) {
-        assert !VM.isModuleSystemInited();
-
         String mn = mref.descriptor().name();
         if (nameToModule.putIfAbsent(mn, mref) != null) {
             throw new InternalError(mn + " already defined to this loader");
@@ -191,6 +189,11 @@
                                         + other.mref().descriptor().name());
             }
         }
+
+        // clear resources cache if VM is already initialized
+        if (VM.isModuleSystemInited() && resourceCache != null) {
+            resourceCache = null;
+        }
     }
 
     /**
@@ -355,7 +358,10 @@
     private List<URL> findMiscResource(String name) throws IOException {
         SoftReference<Map<String, List<URL>>> ref = this.resourceCache;
         Map<String, List<URL>> map = (ref != null) ? ref.get() : null;
-        if (map != null) {
+        if (map == null) {
+            map = new ConcurrentHashMap<>();
+            this.resourceCache = new SoftReference<>(map);
+        } else {
             List<URL> urls = map.get(name);
             if (urls != null)
                 return urls;
@@ -381,23 +387,18 @@
                                 }
                             }
                         }
-                        return result;
+                        return (result != null) ? result : Collections.emptyList();
                     }
                 });
         } catch (PrivilegedActionException pae) {
             throw (IOException) pae.getCause();
         }
 
-        // only cache resources after all modules have been defined
+        // only cache resources after VM is fully initialized
         if (VM.isModuleSystemInited()) {
-            if (map == null) {
-                map = new ConcurrentHashMap<>();
-                this.resourceCache = new SoftReference<>(map);
-            }
-            if (urls == null)
-                urls = Collections.emptyList();
             map.putIfAbsent(name, urls);
         }
+
         return urls;
     }
 
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java	Wed Jul 05 23:25:53 2017 +0200
@@ -25,13 +25,11 @@
 
 package jdk.internal.misc;
 
-import java.io.IOException;
 import java.lang.annotation.Annotation;
 import java.lang.module.ModuleDescriptor;
 import java.lang.reflect.Executable;
 import java.lang.reflect.Method;
 import java.net.URI;
-import java.net.URL;
 import java.security.AccessControlContext;
 import java.security.ProtectionDomain;
 import java.util.Map;
@@ -157,12 +155,6 @@
     Class<?> findBootstrapClassOrNull(ClassLoader cl, String name);
 
     /**
-     * Returns a URL to a resource with the given name in a module that is
-     * defined to the given class loader.
-     */
-    URL findResource(ClassLoader cl, String moduleName, String name) throws IOException;
-
-    /**
      * Returns the Packages for the given class loader.
      */
     Stream<Package> packages(ClassLoader cl);
@@ -178,6 +170,11 @@
     String fastUUID(long lsb, long msb);
 
     /**
+     * Record the non-exported packages of the modules in the given layer
+     */
+    void addNonExportedPackages(ModuleLayer layer);
+
+    /**
      * Invalidate package access cache
      */
     void invalidatePackageAccessCache();
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1278,55 +1278,55 @@
      * @return {@code true} if successful
      */
     @HotSpotIntrinsicCandidate
-    public final native boolean compareAndSwapObject(Object o, long offset,
-                                                     Object expected,
-                                                     Object x);
+    public final native boolean compareAndSetObject(Object o, long offset,
+                                                    Object expected,
+                                                    Object x);
 
     @HotSpotIntrinsicCandidate
-    public final native Object compareAndExchangeObjectVolatile(Object o, long offset,
-                                                                Object expected,
-                                                                Object x);
+    public final native Object compareAndExchangeObject(Object o, long offset,
+                                                        Object expected,
+                                                        Object x);
 
     @HotSpotIntrinsicCandidate
     public final Object compareAndExchangeObjectAcquire(Object o, long offset,
                                                                Object expected,
                                                                Object x) {
-        return compareAndExchangeObjectVolatile(o, offset, expected, x);
+        return compareAndExchangeObject(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
     public final Object compareAndExchangeObjectRelease(Object o, long offset,
                                                                Object expected,
                                                                Object x) {
-        return compareAndExchangeObjectVolatile(o, offset, expected, x);
+        return compareAndExchangeObject(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapObject(Object o, long offset,
-                                                         Object expected,
-                                                         Object x) {
-        return compareAndSwapObject(o, offset, expected, x);
+    public final boolean weakCompareAndSetObjectPlain(Object o, long offset,
+                                                      Object expected,
+                                                      Object x) {
+        return compareAndSetObject(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapObjectAcquire(Object o, long offset,
-                                                                Object expected,
-                                                                Object x) {
-        return compareAndSwapObject(o, offset, expected, x);
+    public final boolean weakCompareAndSetObjectAcquire(Object o, long offset,
+                                                        Object expected,
+                                                        Object x) {
+        return compareAndSetObject(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapObjectRelease(Object o, long offset,
-                                                                Object expected,
-                                                                Object x) {
-        return compareAndSwapObject(o, offset, expected, x);
+    public final boolean weakCompareAndSetObjectRelease(Object o, long offset,
+                                                        Object expected,
+                                                        Object x) {
+        return compareAndSetObject(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapObjectVolatile(Object o, long offset,
-                                                                Object expected,
-                                                                Object x) {
-        return compareAndSwapObject(o, offset, expected, x);
+    public final boolean weakCompareAndSetObject(Object o, long offset,
+                                                 Object expected,
+                                                 Object x) {
+        return compareAndSetObject(o, offset, expected, x);
     }
 
     /**
@@ -1339,61 +1339,61 @@
      * @return {@code true} if successful
      */
     @HotSpotIntrinsicCandidate
-    public final native boolean compareAndSwapInt(Object o, long offset,
+    public final native boolean compareAndSetInt(Object o, long offset,
+                                                 int expected,
+                                                 int x);
+
+    @HotSpotIntrinsicCandidate
+    public final native int compareAndExchangeInt(Object o, long offset,
                                                   int expected,
                                                   int x);
 
     @HotSpotIntrinsicCandidate
-    public final native int compareAndExchangeIntVolatile(Object o, long offset,
-                                                          int expected,
-                                                          int x);
-
-    @HotSpotIntrinsicCandidate
     public final int compareAndExchangeIntAcquire(Object o, long offset,
                                                          int expected,
                                                          int x) {
-        return compareAndExchangeIntVolatile(o, offset, expected, x);
+        return compareAndExchangeInt(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
     public final int compareAndExchangeIntRelease(Object o, long offset,
                                                          int expected,
                                                          int x) {
-        return compareAndExchangeIntVolatile(o, offset, expected, x);
+        return compareAndExchangeInt(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapInt(Object o, long offset,
-                                                      int expected,
-                                                      int x) {
-        return compareAndSwapInt(o, offset, expected, x);
+    public final boolean weakCompareAndSetIntPlain(Object o, long offset,
+                                                   int expected,
+                                                   int x) {
+        return compareAndSetInt(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapIntAcquire(Object o, long offset,
-                                                             int expected,
-                                                             int x) {
-        return compareAndSwapInt(o, offset, expected, x);
+    public final boolean weakCompareAndSetIntAcquire(Object o, long offset,
+                                                     int expected,
+                                                     int x) {
+        return compareAndSetInt(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapIntRelease(Object o, long offset,
-                                                             int expected,
-                                                             int x) {
-        return compareAndSwapInt(o, offset, expected, x);
+    public final boolean weakCompareAndSetIntRelease(Object o, long offset,
+                                                     int expected,
+                                                     int x) {
+        return compareAndSetInt(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapIntVolatile(Object o, long offset,
-                                                             int expected,
-                                                             int x) {
-        return compareAndSwapInt(o, offset, expected, x);
+    public final boolean weakCompareAndSetInt(Object o, long offset,
+                                              int expected,
+                                              int x) {
+        return compareAndSetInt(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final byte compareAndExchangeByteVolatile(Object o, long offset,
-                                                     byte expected,
-                                                     byte x) {
+    public final byte compareAndExchangeByte(Object o, long offset,
+                                             byte expected,
+                                             byte x) {
         long wordOffset = offset & ~3;
         int shift = (int) (offset & 3) << 3;
         if (BE) {
@@ -1407,64 +1407,64 @@
             fullWord = getIntVolatile(o, wordOffset);
             if ((fullWord & mask) != maskedExpected)
                 return (byte) ((fullWord & mask) >> shift);
-        } while (!weakCompareAndSwapIntVolatile(o, wordOffset,
+        } while (!weakCompareAndSetInt(o, wordOffset,
                                                 fullWord, (fullWord & ~mask) | maskedX));
         return expected;
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean compareAndSwapByte(Object o, long offset,
-                                            byte expected,
-                                            byte x) {
-        return compareAndExchangeByteVolatile(o, offset, expected, x) == expected;
+    public final boolean compareAndSetByte(Object o, long offset,
+                                           byte expected,
+                                           byte x) {
+        return compareAndExchangeByte(o, offset, expected, x) == expected;
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapByteVolatile(Object o, long offset,
-                                                        byte expected,
-                                                        byte x) {
-        return compareAndSwapByte(o, offset, expected, x);
+    public final boolean weakCompareAndSetByte(Object o, long offset,
+                                               byte expected,
+                                               byte x) {
+        return compareAndSetByte(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapByteAcquire(Object o, long offset,
-                                                       byte expected,
-                                                       byte x) {
-        return weakCompareAndSwapByteVolatile(o, offset, expected, x);
+    public final boolean weakCompareAndSetByteAcquire(Object o, long offset,
+                                                      byte expected,
+                                                      byte x) {
+        return weakCompareAndSetByte(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapByteRelease(Object o, long offset,
-                                                       byte expected,
-                                                       byte x) {
-        return weakCompareAndSwapByteVolatile(o, offset, expected, x);
+    public final boolean weakCompareAndSetByteRelease(Object o, long offset,
+                                                      byte expected,
+                                                      byte x) {
+        return weakCompareAndSetByte(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapByte(Object o, long offset,
-                                                        byte expected,
-                                                        byte x) {
-        return weakCompareAndSwapByteVolatile(o, offset, expected, x);
+    public final boolean weakCompareAndSetBytePlain(Object o, long offset,
+                                                    byte expected,
+                                                    byte x) {
+        return weakCompareAndSetByte(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
     public final byte compareAndExchangeByteAcquire(Object o, long offset,
                                                     byte expected,
                                                     byte x) {
-        return compareAndExchangeByteVolatile(o, offset, expected, x);
+        return compareAndExchangeByte(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
     public final byte compareAndExchangeByteRelease(Object o, long offset,
                                                     byte expected,
                                                     byte x) {
-        return compareAndExchangeByteVolatile(o, offset, expected, x);
+        return compareAndExchangeByte(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final short compareAndExchangeShortVolatile(Object o, long offset,
-                                             short expected,
-                                             short x) {
+    public final short compareAndExchangeShort(Object o, long offset,
+                                               short expected,
+                                               short x) {
         if ((offset & 3) == 3) {
             throw new IllegalArgumentException("Update spans the word, not supported");
         }
@@ -1482,44 +1482,44 @@
             if ((fullWord & mask) != maskedExpected) {
                 return (short) ((fullWord & mask) >> shift);
             }
-        } while (!weakCompareAndSwapIntVolatile(o, wordOffset,
+        } while (!weakCompareAndSetInt(o, wordOffset,
                                                 fullWord, (fullWord & ~mask) | maskedX));
         return expected;
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean compareAndSwapShort(Object o, long offset,
-                                             short expected,
-                                             short x) {
-        return compareAndExchangeShortVolatile(o, offset, expected, x) == expected;
+    public final boolean compareAndSetShort(Object o, long offset,
+                                            short expected,
+                                            short x) {
+        return compareAndExchangeShort(o, offset, expected, x) == expected;
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapShortVolatile(Object o, long offset,
-                                                         short expected,
-                                                         short x) {
-        return compareAndSwapShort(o, offset, expected, x);
+    public final boolean weakCompareAndSetShort(Object o, long offset,
+                                                short expected,
+                                                short x) {
+        return compareAndSetShort(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapShortAcquire(Object o, long offset,
-                                                        short expected,
-                                                        short x) {
-        return weakCompareAndSwapShortVolatile(o, offset, expected, x);
+    public final boolean weakCompareAndSetShortAcquire(Object o, long offset,
+                                                       short expected,
+                                                       short x) {
+        return weakCompareAndSetShort(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapShortRelease(Object o, long offset,
-                                                        short expected,
-                                                        short x) {
-        return weakCompareAndSwapShortVolatile(o, offset, expected, x);
+    public final boolean weakCompareAndSetShortRelease(Object o, long offset,
+                                                       short expected,
+                                                       short x) {
+        return weakCompareAndSetShort(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapShort(Object o, long offset,
-                                                 short expected,
-                                                 short x) {
-        return weakCompareAndSwapShortVolatile(o, offset, expected, x);
+    public final boolean weakCompareAndSetShortPlain(Object o, long offset,
+                                                     short expected,
+                                                     short x) {
+        return weakCompareAndSetShort(o, offset, expected, x);
     }
 
 
@@ -1527,14 +1527,14 @@
     public final short compareAndExchangeShortAcquire(Object o, long offset,
                                                      short expected,
                                                      short x) {
-        return compareAndExchangeShortVolatile(o, offset, expected, x);
+        return compareAndExchangeShort(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
     public final short compareAndExchangeShortRelease(Object o, long offset,
                                                     short expected,
                                                     short x) {
-        return compareAndExchangeShortVolatile(o, offset, expected, x);
+        return compareAndExchangeShort(o, offset, expected, x);
     }
 
     @ForceInline
@@ -1548,17 +1548,17 @@
     }
 
     @ForceInline
-    public final boolean compareAndSwapChar(Object o, long offset,
-                                            char expected,
-                                            char x) {
-        return compareAndSwapShort(o, offset, c2s(expected), c2s(x));
+    public final boolean compareAndSetChar(Object o, long offset,
+                                           char expected,
+                                           char x) {
+        return compareAndSetShort(o, offset, c2s(expected), c2s(x));
     }
 
     @ForceInline
-    public final char compareAndExchangeCharVolatile(Object o, long offset,
-                                            char expected,
-                                            char x) {
-        return s2c(compareAndExchangeShortVolatile(o, offset, c2s(expected), c2s(x)));
+    public final char compareAndExchangeChar(Object o, long offset,
+                                             char expected,
+                                             char x) {
+        return s2c(compareAndExchangeShort(o, offset, c2s(expected), c2s(x)));
     }
 
     @ForceInline
@@ -1576,31 +1576,31 @@
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapCharVolatile(Object o, long offset,
-                                            char expected,
-                                            char x) {
-        return weakCompareAndSwapShortVolatile(o, offset, c2s(expected), c2s(x));
+    public final boolean weakCompareAndSetChar(Object o, long offset,
+                                               char expected,
+                                               char x) {
+        return weakCompareAndSetShort(o, offset, c2s(expected), c2s(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapCharAcquire(Object o, long offset,
-                                            char expected,
-                                            char x) {
-        return weakCompareAndSwapShortAcquire(o, offset, c2s(expected), c2s(x));
+    public final boolean weakCompareAndSetCharAcquire(Object o, long offset,
+                                                      char expected,
+                                                      char x) {
+        return weakCompareAndSetShortAcquire(o, offset, c2s(expected), c2s(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapCharRelease(Object o, long offset,
-                                            char expected,
-                                            char x) {
-        return weakCompareAndSwapShortRelease(o, offset, c2s(expected), c2s(x));
+    public final boolean weakCompareAndSetCharRelease(Object o, long offset,
+                                                      char expected,
+                                                      char x) {
+        return weakCompareAndSetShortRelease(o, offset, c2s(expected), c2s(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapChar(Object o, long offset,
-                                            char expected,
-                                            char x) {
-        return weakCompareAndSwapShort(o, offset, c2s(expected), c2s(x));
+    public final boolean weakCompareAndSetCharPlain(Object o, long offset,
+                                                    char expected,
+                                                    char x) {
+        return weakCompareAndSetShortPlain(o, offset, c2s(expected), c2s(x));
     }
 
     /**
@@ -1653,17 +1653,17 @@
     }
 
     @ForceInline
-    public final boolean compareAndSwapBoolean(Object o, long offset,
-                                               boolean expected,
-                                               boolean x) {
-        return compareAndSwapByte(o, offset, bool2byte(expected), bool2byte(x));
+    public final boolean compareAndSetBoolean(Object o, long offset,
+                                              boolean expected,
+                                              boolean x) {
+        return compareAndSetByte(o, offset, bool2byte(expected), bool2byte(x));
     }
 
     @ForceInline
-    public final boolean compareAndExchangeBooleanVolatile(Object o, long offset,
-                                                        boolean expected,
-                                                        boolean x) {
-        return byte2bool(compareAndExchangeByteVolatile(o, offset, bool2byte(expected), bool2byte(x)));
+    public final boolean compareAndExchangeBoolean(Object o, long offset,
+                                                   boolean expected,
+                                                   boolean x) {
+        return byte2bool(compareAndExchangeByte(o, offset, bool2byte(expected), bool2byte(x)));
     }
 
     @ForceInline
@@ -1681,31 +1681,31 @@
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapBooleanVolatile(Object o, long offset,
-                                                           boolean expected,
-                                                           boolean x) {
-        return weakCompareAndSwapByteVolatile(o, offset, bool2byte(expected), bool2byte(x));
+    public final boolean weakCompareAndSetBoolean(Object o, long offset,
+                                                  boolean expected,
+                                                  boolean x) {
+        return weakCompareAndSetByte(o, offset, bool2byte(expected), bool2byte(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapBooleanAcquire(Object o, long offset,
-                                                          boolean expected,
-                                                          boolean x) {
-        return weakCompareAndSwapByteAcquire(o, offset, bool2byte(expected), bool2byte(x));
+    public final boolean weakCompareAndSetBooleanAcquire(Object o, long offset,
+                                                         boolean expected,
+                                                         boolean x) {
+        return weakCompareAndSetByteAcquire(o, offset, bool2byte(expected), bool2byte(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapBooleanRelease(Object o, long offset,
-                                                          boolean expected,
-                                                          boolean x) {
-        return weakCompareAndSwapByteRelease(o, offset, bool2byte(expected), bool2byte(x));
+    public final boolean weakCompareAndSetBooleanRelease(Object o, long offset,
+                                                         boolean expected,
+                                                         boolean x) {
+        return weakCompareAndSetByteRelease(o, offset, bool2byte(expected), bool2byte(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapBoolean(Object o, long offset,
-                                                   boolean expected,
-                                                   boolean x) {
-        return weakCompareAndSwapByte(o, offset, bool2byte(expected), bool2byte(x));
+    public final boolean weakCompareAndSetBooleanPlain(Object o, long offset,
+                                                       boolean expected,
+                                                       boolean x) {
+        return weakCompareAndSetBytePlain(o, offset, bool2byte(expected), bool2byte(x));
     }
 
     /**
@@ -1718,21 +1718,21 @@
      * @return {@code true} if successful
      */
     @ForceInline
-    public final boolean compareAndSwapFloat(Object o, long offset,
-                                             float expected,
-                                             float x) {
-        return compareAndSwapInt(o, offset,
+    public final boolean compareAndSetFloat(Object o, long offset,
+                                            float expected,
+                                            float x) {
+        return compareAndSetInt(o, offset,
                                  Float.floatToRawIntBits(expected),
                                  Float.floatToRawIntBits(x));
     }
 
     @ForceInline
-    public final float compareAndExchangeFloatVolatile(Object o, long offset,
-                                                       float expected,
-                                                       float x) {
-        int w = compareAndExchangeIntVolatile(o, offset,
-                                              Float.floatToRawIntBits(expected),
-                                              Float.floatToRawIntBits(x));
+    public final float compareAndExchangeFloat(Object o, long offset,
+                                               float expected,
+                                               float x) {
+        int w = compareAndExchangeInt(o, offset,
+                                      Float.floatToRawIntBits(expected),
+                                      Float.floatToRawIntBits(x));
         return Float.intBitsToFloat(w);
     }
 
@@ -1757,37 +1757,37 @@
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapFloat(Object o, long offset,
-                                               float expected,
-                                               float x) {
-        return weakCompareAndSwapInt(o, offset,
+    public final boolean weakCompareAndSetFloatPlain(Object o, long offset,
+                                                     float expected,
+                                                     float x) {
+        return weakCompareAndSetIntPlain(o, offset,
                                      Float.floatToRawIntBits(expected),
                                      Float.floatToRawIntBits(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapFloatAcquire(Object o, long offset,
-                                                      float expected,
-                                                      float x) {
-        return weakCompareAndSwapIntAcquire(o, offset,
+    public final boolean weakCompareAndSetFloatAcquire(Object o, long offset,
+                                                       float expected,
+                                                       float x) {
+        return weakCompareAndSetIntAcquire(o, offset,
                                             Float.floatToRawIntBits(expected),
                                             Float.floatToRawIntBits(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapFloatRelease(Object o, long offset,
-                                                      float expected,
-                                                      float x) {
-        return weakCompareAndSwapIntRelease(o, offset,
+    public final boolean weakCompareAndSetFloatRelease(Object o, long offset,
+                                                       float expected,
+                                                       float x) {
+        return weakCompareAndSetIntRelease(o, offset,
                                             Float.floatToRawIntBits(expected),
                                             Float.floatToRawIntBits(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapFloatVolatile(Object o, long offset,
-                                                       float expected,
-                                                       float x) {
-        return weakCompareAndSwapIntVolatile(o, offset,
+    public final boolean weakCompareAndSetFloat(Object o, long offset,
+                                                float expected,
+                                                float x) {
+        return weakCompareAndSetInt(o, offset,
                                              Float.floatToRawIntBits(expected),
                                              Float.floatToRawIntBits(x));
     }
@@ -1802,21 +1802,21 @@
      * @return {@code true} if successful
      */
     @ForceInline
-    public final boolean compareAndSwapDouble(Object o, long offset,
-                                              double expected,
-                                              double x) {
-        return compareAndSwapLong(o, offset,
-                                  Double.doubleToRawLongBits(expected),
-                                  Double.doubleToRawLongBits(x));
+    public final boolean compareAndSetDouble(Object o, long offset,
+                                             double expected,
+                                             double x) {
+        return compareAndSetLong(o, offset,
+                                 Double.doubleToRawLongBits(expected),
+                                 Double.doubleToRawLongBits(x));
     }
 
     @ForceInline
-    public final double compareAndExchangeDoubleVolatile(Object o, long offset,
-                                                         double expected,
-                                                         double x) {
-        long w = compareAndExchangeLongVolatile(o, offset,
-                                                Double.doubleToRawLongBits(expected),
-                                                Double.doubleToRawLongBits(x));
+    public final double compareAndExchangeDouble(Object o, long offset,
+                                                 double expected,
+                                                 double x) {
+        long w = compareAndExchangeLong(o, offset,
+                                        Double.doubleToRawLongBits(expected),
+                                        Double.doubleToRawLongBits(x));
         return Double.longBitsToDouble(w);
     }
 
@@ -1841,37 +1841,37 @@
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapDouble(Object o, long offset,
-                                                  double expected,
-                                                  double x) {
-        return weakCompareAndSwapLong(o, offset,
+    public final boolean weakCompareAndSetDoublePlain(Object o, long offset,
+                                                      double expected,
+                                                      double x) {
+        return weakCompareAndSetLongPlain(o, offset,
                                      Double.doubleToRawLongBits(expected),
                                      Double.doubleToRawLongBits(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapDoubleAcquire(Object o, long offset,
-                                                         double expected,
-                                                         double x) {
-        return weakCompareAndSwapLongAcquire(o, offset,
+    public final boolean weakCompareAndSetDoubleAcquire(Object o, long offset,
+                                                        double expected,
+                                                        double x) {
+        return weakCompareAndSetLongAcquire(o, offset,
                                              Double.doubleToRawLongBits(expected),
                                              Double.doubleToRawLongBits(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapDoubleRelease(Object o, long offset,
-                                                         double expected,
-                                                         double x) {
-        return weakCompareAndSwapLongRelease(o, offset,
+    public final boolean weakCompareAndSetDoubleRelease(Object o, long offset,
+                                                        double expected,
+                                                        double x) {
+        return weakCompareAndSetLongRelease(o, offset,
                                              Double.doubleToRawLongBits(expected),
                                              Double.doubleToRawLongBits(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapDoubleVolatile(Object o, long offset,
-                                                          double expected,
-                                                          double x) {
-        return weakCompareAndSwapLongVolatile(o, offset,
+    public final boolean weakCompareAndSetDouble(Object o, long offset,
+                                                 double expected,
+                                                 double x) {
+        return weakCompareAndSetLong(o, offset,
                                               Double.doubleToRawLongBits(expected),
                                               Double.doubleToRawLongBits(x));
     }
@@ -1886,55 +1886,55 @@
      * @return {@code true} if successful
      */
     @HotSpotIntrinsicCandidate
-    public final native boolean compareAndSwapLong(Object o, long offset,
-                                                   long expected,
-                                                   long x);
+    public final native boolean compareAndSetLong(Object o, long offset,
+                                                  long expected,
+                                                  long x);
 
     @HotSpotIntrinsicCandidate
-    public final native long compareAndExchangeLongVolatile(Object o, long offset,
-                                                            long expected,
-                                                            long x);
+    public final native long compareAndExchangeLong(Object o, long offset,
+                                                    long expected,
+                                                    long x);
 
     @HotSpotIntrinsicCandidate
     public final long compareAndExchangeLongAcquire(Object o, long offset,
                                                            long expected,
                                                            long x) {
-        return compareAndExchangeLongVolatile(o, offset, expected, x);
+        return compareAndExchangeLong(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
     public final long compareAndExchangeLongRelease(Object o, long offset,
                                                            long expected,
                                                            long x) {
-        return compareAndExchangeLongVolatile(o, offset, expected, x);
+        return compareAndExchangeLong(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapLong(Object o, long offset,
-                                                       long expected,
-                                                       long x) {
-        return compareAndSwapLong(o, offset, expected, x);
+    public final boolean weakCompareAndSetLongPlain(Object o, long offset,
+                                                    long expected,
+                                                    long x) {
+        return compareAndSetLong(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapLongAcquire(Object o, long offset,
-                                                              long expected,
-                                                              long x) {
-        return compareAndSwapLong(o, offset, expected, x);
+    public final boolean weakCompareAndSetLongAcquire(Object o, long offset,
+                                                      long expected,
+                                                      long x) {
+        return compareAndSetLong(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapLongRelease(Object o, long offset,
-                                                              long expected,
-                                                              long x) {
-        return compareAndSwapLong(o, offset, expected, x);
+    public final boolean weakCompareAndSetLongRelease(Object o, long offset,
+                                                      long expected,
+                                                      long x) {
+        return compareAndSetLong(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapLongVolatile(Object o, long offset,
-                                                              long expected,
-                                                              long x) {
-        return compareAndSwapLong(o, offset, expected, x);
+    public final boolean weakCompareAndSetLong(Object o, long offset,
+                                               long expected,
+                                               long x) {
+        return compareAndSetLong(o, offset, expected, x);
     }
 
     /**
@@ -2316,7 +2316,7 @@
         int v;
         do {
             v = getIntVolatile(o, offset);
-        } while (!weakCompareAndSwapIntVolatile(o, offset, v, v + delta));
+        } while (!weakCompareAndSetInt(o, offset, v, v + delta));
         return v;
     }
 
@@ -2325,7 +2325,7 @@
         int v;
         do {
             v = getInt(o, offset);
-        } while (!weakCompareAndSwapIntRelease(o, offset, v, v + delta));
+        } while (!weakCompareAndSetIntRelease(o, offset, v, v + delta));
         return v;
     }
 
@@ -2334,7 +2334,7 @@
         int v;
         do {
             v = getIntAcquire(o, offset);
-        } while (!weakCompareAndSwapIntAcquire(o, offset, v, v + delta));
+        } while (!weakCompareAndSetIntAcquire(o, offset, v, v + delta));
         return v;
     }
 
@@ -2354,7 +2354,7 @@
         long v;
         do {
             v = getLongVolatile(o, offset);
-        } while (!weakCompareAndSwapLongVolatile(o, offset, v, v + delta));
+        } while (!weakCompareAndSetLong(o, offset, v, v + delta));
         return v;
     }
 
@@ -2363,7 +2363,7 @@
         long v;
         do {
             v = getLong(o, offset);
-        } while (!weakCompareAndSwapLongRelease(o, offset, v, v + delta));
+        } while (!weakCompareAndSetLongRelease(o, offset, v, v + delta));
         return v;
     }
 
@@ -2372,7 +2372,7 @@
         long v;
         do {
             v = getLongAcquire(o, offset);
-        } while (!weakCompareAndSwapLongAcquire(o, offset, v, v + delta));
+        } while (!weakCompareAndSetLongAcquire(o, offset, v, v + delta));
         return v;
     }
 
@@ -2381,7 +2381,7 @@
         byte v;
         do {
             v = getByteVolatile(o, offset);
-        } while (!weakCompareAndSwapByteVolatile(o, offset, v, (byte) (v + delta)));
+        } while (!weakCompareAndSetByte(o, offset, v, (byte) (v + delta)));
         return v;
     }
 
@@ -2390,7 +2390,7 @@
         byte v;
         do {
             v = getByte(o, offset);
-        } while (!weakCompareAndSwapByteRelease(o, offset, v, (byte) (v + delta)));
+        } while (!weakCompareAndSetByteRelease(o, offset, v, (byte) (v + delta)));
         return v;
     }
 
@@ -2399,7 +2399,7 @@
         byte v;
         do {
             v = getByteAcquire(o, offset);
-        } while (!weakCompareAndSwapByteAcquire(o, offset, v, (byte) (v + delta)));
+        } while (!weakCompareAndSetByteAcquire(o, offset, v, (byte) (v + delta)));
         return v;
     }
 
@@ -2408,7 +2408,7 @@
         short v;
         do {
             v = getShortVolatile(o, offset);
-        } while (!weakCompareAndSwapShortVolatile(o, offset, v, (short) (v + delta)));
+        } while (!weakCompareAndSetShort(o, offset, v, (short) (v + delta)));
         return v;
     }
 
@@ -2417,7 +2417,7 @@
         short v;
         do {
             v = getShort(o, offset);
-        } while (!weakCompareAndSwapShortRelease(o, offset, v, (short) (v + delta)));
+        } while (!weakCompareAndSetShortRelease(o, offset, v, (short) (v + delta)));
         return v;
     }
 
@@ -2426,7 +2426,7 @@
         short v;
         do {
             v = getShortAcquire(o, offset);
-        } while (!weakCompareAndSwapShortAcquire(o, offset, v, (short) (v + delta)));
+        } while (!weakCompareAndSetShortAcquire(o, offset, v, (short) (v + delta)));
         return v;
     }
 
@@ -2455,7 +2455,7 @@
             // may result in the loop not terminating.
             expectedBits = getIntVolatile(o, offset);
             v = Float.intBitsToFloat(expectedBits);
-        } while (!weakCompareAndSwapIntVolatile(o, offset,
+        } while (!weakCompareAndSetInt(o, offset,
                                                 expectedBits, Float.floatToRawIntBits(v + delta)));
         return v;
     }
@@ -2470,7 +2470,7 @@
             // may result in the loop not terminating.
             expectedBits = getInt(o, offset);
             v = Float.intBitsToFloat(expectedBits);
-        } while (!weakCompareAndSwapIntRelease(o, offset,
+        } while (!weakCompareAndSetIntRelease(o, offset,
                                                expectedBits, Float.floatToRawIntBits(v + delta)));
         return v;
     }
@@ -2485,7 +2485,7 @@
             // may result in the loop not terminating.
             expectedBits = getIntAcquire(o, offset);
             v = Float.intBitsToFloat(expectedBits);
-        } while (!weakCompareAndSwapIntAcquire(o, offset,
+        } while (!weakCompareAndSetIntAcquire(o, offset,
                                                expectedBits, Float.floatToRawIntBits(v + delta)));
         return v;
     }
@@ -2500,7 +2500,7 @@
             // may result in the loop not terminating.
             expectedBits = getLongVolatile(o, offset);
             v = Double.longBitsToDouble(expectedBits);
-        } while (!weakCompareAndSwapLongVolatile(o, offset,
+        } while (!weakCompareAndSetLong(o, offset,
                                                  expectedBits, Double.doubleToRawLongBits(v + delta)));
         return v;
     }
@@ -2515,7 +2515,7 @@
             // may result in the loop not terminating.
             expectedBits = getLong(o, offset);
             v = Double.longBitsToDouble(expectedBits);
-        } while (!weakCompareAndSwapLongRelease(o, offset,
+        } while (!weakCompareAndSetLongRelease(o, offset,
                                                 expectedBits, Double.doubleToRawLongBits(v + delta)));
         return v;
     }
@@ -2530,7 +2530,7 @@
             // may result in the loop not terminating.
             expectedBits = getLongAcquire(o, offset);
             v = Double.longBitsToDouble(expectedBits);
-        } while (!weakCompareAndSwapLongAcquire(o, offset,
+        } while (!weakCompareAndSetLongAcquire(o, offset,
                                                 expectedBits, Double.doubleToRawLongBits(v + delta)));
         return v;
     }
@@ -2551,7 +2551,7 @@
         int v;
         do {
             v = getIntVolatile(o, offset);
-        } while (!weakCompareAndSwapIntVolatile(o, offset, v, newValue));
+        } while (!weakCompareAndSetInt(o, offset, v, newValue));
         return v;
     }
 
@@ -2560,7 +2560,7 @@
         int v;
         do {
             v = getInt(o, offset);
-        } while (!weakCompareAndSwapIntRelease(o, offset, v, newValue));
+        } while (!weakCompareAndSetIntRelease(o, offset, v, newValue));
         return v;
     }
 
@@ -2569,7 +2569,7 @@
         int v;
         do {
             v = getIntAcquire(o, offset);
-        } while (!weakCompareAndSwapIntAcquire(o, offset, v, newValue));
+        } while (!weakCompareAndSetIntAcquire(o, offset, v, newValue));
         return v;
     }
 
@@ -2589,7 +2589,7 @@
         long v;
         do {
             v = getLongVolatile(o, offset);
-        } while (!weakCompareAndSwapLongVolatile(o, offset, v, newValue));
+        } while (!weakCompareAndSetLong(o, offset, v, newValue));
         return v;
     }
 
@@ -2598,7 +2598,7 @@
         long v;
         do {
             v = getLong(o, offset);
-        } while (!weakCompareAndSwapLongRelease(o, offset, v, newValue));
+        } while (!weakCompareAndSetLongRelease(o, offset, v, newValue));
         return v;
     }
 
@@ -2607,7 +2607,7 @@
         long v;
         do {
             v = getLongAcquire(o, offset);
-        } while (!weakCompareAndSwapLongAcquire(o, offset, v, newValue));
+        } while (!weakCompareAndSetLongAcquire(o, offset, v, newValue));
         return v;
     }
 
@@ -2627,7 +2627,7 @@
         Object v;
         do {
             v = getObjectVolatile(o, offset);
-        } while (!weakCompareAndSwapObjectVolatile(o, offset, v, newValue));
+        } while (!weakCompareAndSetObject(o, offset, v, newValue));
         return v;
     }
 
@@ -2636,7 +2636,7 @@
         Object v;
         do {
             v = getObject(o, offset);
-        } while (!weakCompareAndSwapObjectRelease(o, offset, v, newValue));
+        } while (!weakCompareAndSetObjectRelease(o, offset, v, newValue));
         return v;
     }
 
@@ -2645,7 +2645,7 @@
         Object v;
         do {
             v = getObjectAcquire(o, offset);
-        } while (!weakCompareAndSwapObjectAcquire(o, offset, v, newValue));
+        } while (!weakCompareAndSetObjectAcquire(o, offset, v, newValue));
         return v;
     }
 
@@ -2654,7 +2654,7 @@
         byte v;
         do {
             v = getByteVolatile(o, offset);
-        } while (!weakCompareAndSwapByteVolatile(o, offset, v, newValue));
+        } while (!weakCompareAndSetByte(o, offset, v, newValue));
         return v;
     }
 
@@ -2663,7 +2663,7 @@
         byte v;
         do {
             v = getByte(o, offset);
-        } while (!weakCompareAndSwapByteRelease(o, offset, v, newValue));
+        } while (!weakCompareAndSetByteRelease(o, offset, v, newValue));
         return v;
     }
 
@@ -2672,7 +2672,7 @@
         byte v;
         do {
             v = getByteAcquire(o, offset);
-        } while (!weakCompareAndSwapByteAcquire(o, offset, v, newValue));
+        } while (!weakCompareAndSetByteAcquire(o, offset, v, newValue));
         return v;
     }
 
@@ -2696,7 +2696,7 @@
         short v;
         do {
             v = getShortVolatile(o, offset);
-        } while (!weakCompareAndSwapShortVolatile(o, offset, v, newValue));
+        } while (!weakCompareAndSetShort(o, offset, v, newValue));
         return v;
     }
 
@@ -2705,7 +2705,7 @@
         short v;
         do {
             v = getShort(o, offset);
-        } while (!weakCompareAndSwapShortRelease(o, offset, v, newValue));
+        } while (!weakCompareAndSetShortRelease(o, offset, v, newValue));
         return v;
     }
 
@@ -2714,7 +2714,7 @@
         short v;
         do {
             v = getShortAcquire(o, offset);
-        } while (!weakCompareAndSwapShortAcquire(o, offset, v, newValue));
+        } while (!weakCompareAndSetShortAcquire(o, offset, v, newValue));
         return v;
     }
 
@@ -2824,7 +2824,7 @@
         byte current;
         do {
             current = getByteVolatile(o, offset);
-        } while (!weakCompareAndSwapByteVolatile(o, offset,
+        } while (!weakCompareAndSetByte(o, offset,
                                                   current, (byte) (current | mask)));
         return current;
     }
@@ -2834,7 +2834,7 @@
         byte current;
         do {
             current = getByte(o, offset);
-        } while (!weakCompareAndSwapByteRelease(o, offset,
+        } while (!weakCompareAndSetByteRelease(o, offset,
                                                  current, (byte) (current | mask)));
         return current;
     }
@@ -2845,7 +2845,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getByte(o, offset);
-        } while (!weakCompareAndSwapByteAcquire(o, offset,
+        } while (!weakCompareAndSetByteAcquire(o, offset,
                                                  current, (byte) (current | mask)));
         return current;
     }
@@ -2855,7 +2855,7 @@
         byte current;
         do {
             current = getByteVolatile(o, offset);
-        } while (!weakCompareAndSwapByteVolatile(o, offset,
+        } while (!weakCompareAndSetByte(o, offset,
                                                   current, (byte) (current & mask)));
         return current;
     }
@@ -2865,7 +2865,7 @@
         byte current;
         do {
             current = getByte(o, offset);
-        } while (!weakCompareAndSwapByteRelease(o, offset,
+        } while (!weakCompareAndSetByteRelease(o, offset,
                                                  current, (byte) (current & mask)));
         return current;
     }
@@ -2876,7 +2876,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getByte(o, offset);
-        } while (!weakCompareAndSwapByteAcquire(o, offset,
+        } while (!weakCompareAndSetByteAcquire(o, offset,
                                                  current, (byte) (current & mask)));
         return current;
     }
@@ -2886,7 +2886,7 @@
         byte current;
         do {
             current = getByteVolatile(o, offset);
-        } while (!weakCompareAndSwapByteVolatile(o, offset,
+        } while (!weakCompareAndSetByte(o, offset,
                                                   current, (byte) (current ^ mask)));
         return current;
     }
@@ -2896,7 +2896,7 @@
         byte current;
         do {
             current = getByte(o, offset);
-        } while (!weakCompareAndSwapByteRelease(o, offset,
+        } while (!weakCompareAndSetByteRelease(o, offset,
                                                  current, (byte) (current ^ mask)));
         return current;
     }
@@ -2907,7 +2907,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getByte(o, offset);
-        } while (!weakCompareAndSwapByteAcquire(o, offset,
+        } while (!weakCompareAndSetByteAcquire(o, offset,
                                                  current, (byte) (current ^ mask)));
         return current;
     }
@@ -2964,7 +2964,7 @@
         short current;
         do {
             current = getShortVolatile(o, offset);
-        } while (!weakCompareAndSwapShortVolatile(o, offset,
+        } while (!weakCompareAndSetShort(o, offset,
                                                 current, (short) (current | mask)));
         return current;
     }
@@ -2974,7 +2974,7 @@
         short current;
         do {
             current = getShort(o, offset);
-        } while (!weakCompareAndSwapShortRelease(o, offset,
+        } while (!weakCompareAndSetShortRelease(o, offset,
                                                current, (short) (current | mask)));
         return current;
     }
@@ -2985,7 +2985,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getShort(o, offset);
-        } while (!weakCompareAndSwapShortAcquire(o, offset,
+        } while (!weakCompareAndSetShortAcquire(o, offset,
                                                current, (short) (current | mask)));
         return current;
     }
@@ -2995,7 +2995,7 @@
         short current;
         do {
             current = getShortVolatile(o, offset);
-        } while (!weakCompareAndSwapShortVolatile(o, offset,
+        } while (!weakCompareAndSetShort(o, offset,
                                                 current, (short) (current & mask)));
         return current;
     }
@@ -3005,7 +3005,7 @@
         short current;
         do {
             current = getShort(o, offset);
-        } while (!weakCompareAndSwapShortRelease(o, offset,
+        } while (!weakCompareAndSetShortRelease(o, offset,
                                                current, (short) (current & mask)));
         return current;
     }
@@ -3016,7 +3016,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getShort(o, offset);
-        } while (!weakCompareAndSwapShortAcquire(o, offset,
+        } while (!weakCompareAndSetShortAcquire(o, offset,
                                                current, (short) (current & mask)));
         return current;
     }
@@ -3026,7 +3026,7 @@
         short current;
         do {
             current = getShortVolatile(o, offset);
-        } while (!weakCompareAndSwapShortVolatile(o, offset,
+        } while (!weakCompareAndSetShort(o, offset,
                                                 current, (short) (current ^ mask)));
         return current;
     }
@@ -3036,7 +3036,7 @@
         short current;
         do {
             current = getShort(o, offset);
-        } while (!weakCompareAndSwapShortRelease(o, offset,
+        } while (!weakCompareAndSetShortRelease(o, offset,
                                                current, (short) (current ^ mask)));
         return current;
     }
@@ -3047,7 +3047,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getShort(o, offset);
-        } while (!weakCompareAndSwapShortAcquire(o, offset,
+        } while (!weakCompareAndSetShortAcquire(o, offset,
                                                current, (short) (current ^ mask)));
         return current;
     }
@@ -3058,7 +3058,7 @@
         int current;
         do {
             current = getIntVolatile(o, offset);
-        } while (!weakCompareAndSwapIntVolatile(o, offset,
+        } while (!weakCompareAndSetInt(o, offset,
                                                 current, current | mask));
         return current;
     }
@@ -3068,7 +3068,7 @@
         int current;
         do {
             current = getInt(o, offset);
-        } while (!weakCompareAndSwapIntRelease(o, offset,
+        } while (!weakCompareAndSetIntRelease(o, offset,
                                                current, current | mask));
         return current;
     }
@@ -3079,7 +3079,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getInt(o, offset);
-        } while (!weakCompareAndSwapIntAcquire(o, offset,
+        } while (!weakCompareAndSetIntAcquire(o, offset,
                                                current, current | mask));
         return current;
     }
@@ -3100,7 +3100,7 @@
         int current;
         do {
             current = getIntVolatile(o, offset);
-        } while (!weakCompareAndSwapIntVolatile(o, offset,
+        } while (!weakCompareAndSetInt(o, offset,
                                                 current, current & mask));
         return current;
     }
@@ -3110,7 +3110,7 @@
         int current;
         do {
             current = getInt(o, offset);
-        } while (!weakCompareAndSwapIntRelease(o, offset,
+        } while (!weakCompareAndSetIntRelease(o, offset,
                                                current, current & mask));
         return current;
     }
@@ -3121,7 +3121,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getInt(o, offset);
-        } while (!weakCompareAndSwapIntAcquire(o, offset,
+        } while (!weakCompareAndSetIntAcquire(o, offset,
                                                current, current & mask));
         return current;
     }
@@ -3131,7 +3131,7 @@
         int current;
         do {
             current = getIntVolatile(o, offset);
-        } while (!weakCompareAndSwapIntVolatile(o, offset,
+        } while (!weakCompareAndSetInt(o, offset,
                                                 current, current ^ mask));
         return current;
     }
@@ -3141,7 +3141,7 @@
         int current;
         do {
             current = getInt(o, offset);
-        } while (!weakCompareAndSwapIntRelease(o, offset,
+        } while (!weakCompareAndSetIntRelease(o, offset,
                                                current, current ^ mask));
         return current;
     }
@@ -3152,7 +3152,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getInt(o, offset);
-        } while (!weakCompareAndSwapIntAcquire(o, offset,
+        } while (!weakCompareAndSetIntAcquire(o, offset,
                                                current, current ^ mask));
         return current;
     }
@@ -3163,7 +3163,7 @@
         long current;
         do {
             current = getLongVolatile(o, offset);
-        } while (!weakCompareAndSwapLongVolatile(o, offset,
+        } while (!weakCompareAndSetLong(o, offset,
                                                 current, current | mask));
         return current;
     }
@@ -3173,7 +3173,7 @@
         long current;
         do {
             current = getLong(o, offset);
-        } while (!weakCompareAndSwapLongRelease(o, offset,
+        } while (!weakCompareAndSetLongRelease(o, offset,
                                                current, current | mask));
         return current;
     }
@@ -3184,7 +3184,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getLong(o, offset);
-        } while (!weakCompareAndSwapLongAcquire(o, offset,
+        } while (!weakCompareAndSetLongAcquire(o, offset,
                                                current, current | mask));
         return current;
     }
@@ -3194,7 +3194,7 @@
         long current;
         do {
             current = getLongVolatile(o, offset);
-        } while (!weakCompareAndSwapLongVolatile(o, offset,
+        } while (!weakCompareAndSetLong(o, offset,
                                                 current, current & mask));
         return current;
     }
@@ -3204,7 +3204,7 @@
         long current;
         do {
             current = getLong(o, offset);
-        } while (!weakCompareAndSwapLongRelease(o, offset,
+        } while (!weakCompareAndSetLongRelease(o, offset,
                                                current, current & mask));
         return current;
     }
@@ -3215,7 +3215,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getLong(o, offset);
-        } while (!weakCompareAndSwapLongAcquire(o, offset,
+        } while (!weakCompareAndSetLongAcquire(o, offset,
                                                current, current & mask));
         return current;
     }
@@ -3225,7 +3225,7 @@
         long current;
         do {
             current = getLongVolatile(o, offset);
-        } while (!weakCompareAndSwapLongVolatile(o, offset,
+        } while (!weakCompareAndSetLong(o, offset,
                                                 current, current ^ mask));
         return current;
     }
@@ -3235,7 +3235,7 @@
         long current;
         do {
             current = getLong(o, offset);
-        } while (!weakCompareAndSwapLongRelease(o, offset,
+        } while (!weakCompareAndSetLongRelease(o, offset,
                                                current, current ^ mask));
         return current;
     }
@@ -3246,7 +3246,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getLong(o, offset);
-        } while (!weakCompareAndSwapLongAcquire(o, offset,
+        } while (!weakCompareAndSetLongAcquire(o, offset,
                                                current, current ^ mask));
         return current;
     }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/Checks.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/Checks.java	Wed Jul 05 23:25:53 2017 +0200
@@ -25,6 +25,8 @@
 
 package jdk.internal.module;
 
+import java.util.Set;
+
 /**
  * Utility class for checking module, package, and class names.
  */
@@ -45,18 +47,17 @@
         int next;
         int off = 0;
         while ((next = name.indexOf('.', off)) != -1) {
-            if (isJavaIdentifier(name, off, (next - off)) == -1) {
-                String id = name.substring(off, next);
+            String id = name.substring(off, next);
+            if (!isJavaIdentifier(id)) {
                 throw new IllegalArgumentException(name + ": Invalid module name"
                         + ": '" + id + "' is not a Java identifier");
             }
             off = next+1;
         }
-        int last = isJavaIdentifier(name, off, name.length() - off);
-        if (last == -1) {
-            String id = name.substring(off);
+        String last = name.substring(off);
+        if (!isJavaIdentifier(last)) {
             throw new IllegalArgumentException(name + ": Invalid module name"
-                    + ": '" + id + "' is not a Java identifier");
+                    + ": '" + last + "' is not a Java identifier");
         }
         return name;
     }
@@ -68,14 +69,13 @@
         int next;
         int off = 0;
         while ((next = name.indexOf('.', off)) != -1) {
-            if (isJavaIdentifier(name, off, (next - off)) == -1)
+            String id = name.substring(off, next);
+            if (!isJavaIdentifier(id))
                 return false;
             off = next+1;
         }
-        int last = isJavaIdentifier(name, off, name.length() - off);
-        if (last == -1)
-            return false;
-        return true;
+        String last = name.substring(off);
+        return isJavaIdentifier(last);
     }
 
     /**
@@ -144,12 +144,13 @@
         int next;
         int off = 0;
         while ((next = name.indexOf('.', off)) != -1) {
-            if (isJavaIdentifier(name, off, (next - off)) == -1)
+            String id = name.substring(off, next);
+            if (!isJavaIdentifier(id))
                 return false;
             off = next+1;
         }
-        int count = name.length() - off;
-        return (isJavaIdentifier(name, off, count) != -1);
+        String last = name.substring(off);
+        return isJavaIdentifier(last);
     }
 
     /**
@@ -164,76 +165,99 @@
         int next;
         int off = 0;
         while ((next = name.indexOf('.', off)) != -1) {
-            if (isJavaIdentifier(name, off, (next - off)) == -1) {
-                String id = name.substring(off, next);
+            String id = name.substring(off, next);
+            if (!isJavaIdentifier(id)) {
                 throw new IllegalArgumentException(name + ": Invalid " + what
                         + ": '" + id + "' is not a Java identifier");
             }
             off = next + 1;
         }
-        if (isJavaIdentifier(name, off, name.length() - off) == -1) {
-            String id = name.substring(off, name.length());
+        String last = name.substring(off);
+        if (!isJavaIdentifier(last)) {
             throw new IllegalArgumentException(name + ": Invalid " + what
-                    + ": '" + id + "' is not a Java identifier");
+                    + ": '" + last + "' is not a Java identifier");
         }
         return name;
     }
 
     /**
-     * Returns {@code true} if a given legal module name contains an identifier
-     * that doesn't end with a Java letter.
+     * Returns true if the given char sequence is a legal Java identifier,
+     * otherwise false.
      */
-    public static boolean hasJavaIdentifierWithTrailingDigit(String name) {
-        // quick scan to allow names that are just ASCII without digits
-        boolean needToParse = false;
-        int i = 0;
-        while (i < name.length()) {
-            int c = name.charAt(i);
-            if (c > 0x7F || (c >= '0' && c <= '9')) {
-                needToParse = true;
-                break;
-            }
-            i++;
-        }
-        if (!needToParse)
+    private static boolean isJavaIdentifier(CharSequence cs) {
+        if (cs.length() == 0 || RESERVED.contains(cs))
             return false;
 
-        // slow path
-        int next;
-        int off = 0;
-        while ((next = name.indexOf('.', off)) != -1) {
-            int last = isJavaIdentifier(name, off, (next - off));
-            if (!Character.isJavaIdentifierStart(last))
-                return true;
-            off = next+1;
-        }
-        int last = isJavaIdentifier(name, off, name.length() - off);
-        if (!Character.isJavaIdentifierStart(last))
-            return true;
-        return false;
-
-    }
+        int first = Character.codePointAt(cs, 0);
+        if (!Character.isJavaIdentifierStart(first))
+            return false;
 
-    /**
-     * Checks if a char sequence is a legal Java identifier, returning the code
-     * point of the last character if legal or {@code -1} if not legal.
-     */
-    private static int isJavaIdentifier(CharSequence cs, int offset, int count) {
-        if (count == 0)
-            return -1;
-        int first = Character.codePointAt(cs, offset);
-        if (!Character.isJavaIdentifierStart(first))
-            return -1;
-
-        int cp = first;
         int i = Character.charCount(first);
-        while (i < count) {
-            cp = Character.codePointAt(cs, offset+i);
+        while (i < cs.length()) {
+            int cp = Character.codePointAt(cs, i);
             if (!Character.isJavaIdentifierPart(cp))
-                return -1;
+                return false;
             i += Character.charCount(cp);
         }
 
-        return cp;
+        return true;
     }
+
+    // keywords, boolean and null literals, not allowed in identifiers
+    private static final Set<String> RESERVED = Set.of(
+            "abstract",
+            "assert",
+            "boolean",
+            "break",
+            "byte",
+            "case",
+            "catch",
+            "char",
+            "class",
+            "const",
+            "continue",
+            "default",
+            "do",
+            "double",
+            "else",
+            "enum",
+            "extends",
+            "final",
+            "finally",
+            "float",
+            "for",
+            "goto",
+            "if",
+            "implements",
+            "import",
+            "instanceof",
+            "int",
+            "interface",
+            "long",
+            "native",
+            "new",
+            "package",
+            "private",
+            "protected",
+            "public",
+            "return",
+            "short",
+            "static",
+            "strictfp",
+            "super",
+            "switch",
+            "synchronized",
+            "this",
+            "throw",
+            "throws",
+            "transient",
+            "try",
+            "void",
+            "volatile",
+            "while",
+            "true",
+            "false",
+            "null",
+            "_"
+    );
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ClassFileAttributes.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ClassFileAttributes.java	Wed Jul 05 23:25:53 2017 +0200
@@ -549,34 +549,26 @@
      *   u2 attribute_name_index;
      *   u4 attribute_length;
      *
-     *   // index to CONSTANT_utf8_info structure with the OS name
-     *   u2 os_name_index;
-     *   // index to CONSTANT_utf8_info structure with the OS arch
-     *   u2 os_arch_index
+     *   // index to CONSTANT_utf8_info structure with the target platform
+     *   u2 target_platform_index;
      * }
      *
      * } </pre>
      */
     public static class ModuleTargetAttribute extends Attribute {
-        private final String osName;
-        private final String osArch;
+        private final String targetPlatform;
 
-        public ModuleTargetAttribute(String osName, String osArch) {
+        public ModuleTargetAttribute(String targetPlatform) {
             super(MODULE_TARGET);
-            this.osName = osName;
-            this.osArch = osArch;
+            this.targetPlatform = targetPlatform;
         }
 
         public ModuleTargetAttribute() {
-            this(null, null);
+            this(null);
         }
 
-        public String osName() {
-            return osName;
-        }
-
-        public String osArch() {
-            return osArch;
+        public String targetPlatform() {
+            return targetPlatform;
         }
 
         @Override
@@ -588,20 +580,14 @@
                                  Label[] labels)
         {
 
-            String osName = null;
-            String osArch = null;
+            String targetPlatform = null;
 
-            int name_index = cr.readUnsignedShort(off);
-            if (name_index != 0)
-                osName = cr.readUTF8(off, buf);
+            int target_platform_index = cr.readUnsignedShort(off);
+            if (target_platform_index != 0)
+                targetPlatform = cr.readUTF8(off, buf);
             off += 2;
 
-            int arch_index = cr.readUnsignedShort(off);
-            if (arch_index != 0)
-                osArch = cr.readUTF8(off, buf);
-            off += 2;
-
-            return new ModuleTargetAttribute(osName, osArch);
+            return new ModuleTargetAttribute(targetPlatform);
         }
 
         @Override
@@ -613,15 +599,10 @@
         {
             ByteVector attr = new ByteVector();
 
-            int name_index = 0;
-            if (osName != null && osName.length() > 0)
-                name_index = cw.newUTF8(osName);
-            attr.putShort(name_index);
-
-            int arch_index = 0;
-            if (osArch != null && osArch.length() > 0)
-                arch_index = cw.newUTF8(osArch);
-            attr.putShort(arch_index);
+            int target_platform_index = 0;
+            if (targetPlatform != null && targetPlatform.length() > 0)
+                target_platform_index = cw.newUTF8(targetPlatform);
+            attr.putShort(target_platform_index);
 
             return attr;
         }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java	Wed Jul 05 23:25:53 2017 +0200
@@ -84,8 +84,9 @@
     // The ModulePatcher for the initial configuration
     private static final ModulePatcher patcher = initModulePatcher();
 
-    // ModuleFinder for the initial configuration
-    private static ModuleFinder initialFinder;
+    // ModuleFinders for the initial configuration
+    private static ModuleFinder unlimitedFinder;
+    private static ModuleFinder limitedFinder;
 
     /**
      * Returns the ModulePatcher for the initial configuration.
@@ -95,11 +96,20 @@
     }
 
     /**
-     * Returns the ModuleFinder for the initial configuration
+     * Returns the ModuleFinder for the initial configuration before observability
+     * is limited by the --limit-modules command line option.
      */
-    public static ModuleFinder finder() {
-        assert initialFinder != null;
-        return initialFinder;
+    public static ModuleFinder unlimitedFinder() {
+        assert unlimitedFinder != null;
+        return unlimitedFinder;
+    }
+
+    /**
+     * Returns the ModuleFinder for the initial configuration.
+     */
+    public static ModuleFinder limitedFinder() {
+        assert limitedFinder != null;
+        return limitedFinder;
     }
 
     /**
@@ -134,6 +144,11 @@
 
         PerfCounters.defineBaseTime.addElapsedTimeFrom(t1);
 
+        // special mode to boot with only java.base, ignores other options
+        String propValue = getAndRemoveProperty("jdk.module.minimumBoot");
+        if (propValue != null) {
+            return createMinimalBootLayer();
+        }
 
         long t2 = System.nanoTime();
 
@@ -180,7 +195,8 @@
         }
 
         // --limit-modules
-        String propValue = getAndRemoveProperty("jdk.module.limitmods");
+        unlimitedFinder = finder;
+        propValue = getAndRemoveProperty("jdk.module.limitmods");
         if (propValue != null) {
             Set<String> mods = new HashSet<>();
             for (String mod: propValue.split(",")) {
@@ -188,6 +204,7 @@
             }
             finder = limitFinder(finder, mods, roots);
         }
+        limitedFinder = finder;
 
         // If there is no initial module specified then assume that the initial
         // module is the unnamed module of the application class loader. This
@@ -267,7 +284,8 @@
         }
 
         PrintStream traceOutput = null;
-        if (Boolean.getBoolean("jdk.launcher.traceResolver"))
+        propValue = getAndRemoveProperty("jdk.module.showModuleResolution");
+        if (propValue != null && Boolean.parseBoolean(propValue))
             traceOutput = System.out;
 
         // run the resolver to create the configuration
@@ -362,10 +380,21 @@
         // total time to initialize
         PerfCounters.bootstrapTime.addElapsedTimeFrom(t0);
 
-        // remember the ModuleFinder
-        initialFinder = finder;
+        return bootLayer;
+    }
 
-        return bootLayer;
+    /**
+     * Create a "minimal" boot module layer that only contains java.base.
+     */
+    private static ModuleLayer createMinimalBootLayer() {
+        Configuration cf = SharedSecrets.getJavaLangModuleAccess()
+            .resolveAndBind(ModuleFinder.ofSystem(),
+                            Set.of(JAVA_BASE),
+                            false,
+                            null);
+
+        Function<String, ClassLoader> clf = ModuleLoaderMap.mappingFunction(cf);
+        return ModuleLayer.empty().defineModules(cf, clf);
     }
 
     /**
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleHashesBuilder.java	Wed Jul 05 23:25:53 2017 +0200
@@ -138,7 +138,7 @@
     }
 
     /*
-     * Utilty class
+     * Utility class
      */
     static class Graph<T> {
         private final Set<T> nodes;
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java	Wed Jul 05 23:25:53 2017 +0200
@@ -546,21 +546,15 @@
     private ModuleTarget readModuleTargetAttribute(DataInput in, ConstantPool cpool)
         throws IOException
     {
-        String osName = null;
-        String osArch = null;
-
-        int name_index = in.readUnsignedShort();
-        if (name_index != 0)
-            osName = cpool.getUtf8(name_index);
+        String targetPlatform = null;
 
-        int arch_index = in.readUnsignedShort();
-        if (arch_index != 0)
-            osArch = cpool.getUtf8(arch_index);
+        int index = in.readUnsignedShort();
+        if (index != 0)
+            targetPlatform = cpool.getUtf8(index);
 
-        return new ModuleTarget(osName, osArch);
+        return new ModuleTarget(targetPlatform);
     }
 
-
     /**
      * Reads the ModuleHashes attribute
      */
@@ -612,7 +606,6 @@
         return new ModuleResolution(flags);
     }
 
-
     /**
      * Returns true if the given attribute can be present at most once
      * in the class file. Returns false otherwise.
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoExtender.java	Wed Jul 05 23:25:53 2017 +0200
@@ -62,9 +62,8 @@
     // the value of the ModuleMainClass attribute
     private String mainClass;
 
-    // the values for the ModuleTarget attribute
-    private String osName;
-    private String osArch;
+    // the value for the ModuleTarget attribute
+    private String targetPlatform;
 
     // the hashes for the ModuleHashes attribute
     private ModuleHashes hashes;
@@ -108,11 +107,10 @@
     }
 
     /**
-     * Sets the values for the ModuleTarget attribute.
+     * Sets the value for the ModuleTarget attribute.
      */
-    public ModuleInfoExtender targetPlatform(String osName, String osArch) {
-        this.osName = osName;
-        this.osArch = osArch;
+    public ModuleInfoExtender targetPlatform(String targetPlatform) {
+        this.targetPlatform = targetPlatform;
         return this;
     }
 
@@ -199,8 +197,8 @@
             cv.addAttribute(new ModulePackagesAttribute(packages));
         if (mainClass != null)
             cv.addAttribute(new ModuleMainClassAttribute(mainClass));
-        if (osName != null || osArch != null)
-            cv.addAttribute(new ModuleTargetAttribute(osName, osArch));
+        if (targetPlatform != null)
+            cv.addAttribute(new ModuleTargetAttribute(targetPlatform));
         if (hashes != null)
             cv.addAttribute(new ModuleHashesAttribute(hashes));
         if (moduleResolution != null)
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java	Wed Jul 05 23:25:53 2017 +0200
@@ -66,10 +66,9 @@
         // write ModuleMainClass if the module has a main class
         md.mainClass().ifPresent(mc -> cw.visitAttribute(new ModuleMainClassAttribute(mc)));
 
-        // write ModuleTarget if there is a platform OS/arch
+        // write ModuleTarget if there is a target platform
         if (target != null) {
-            cw.visitAttribute(new ModuleTargetAttribute(target.osName(),
-                                                        target.osArch()));
+            cw.visitAttribute(new ModuleTargetAttribute(target.targetPlatform()));
         }
 
         cw.visitEnd();
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java	Wed Jul 05 23:25:53 2017 +0200
@@ -37,36 +37,66 @@
 
 
 /**
- * The module to class loader map.  The list of boot modules and platform modules
- * are generated at build time.
+ * Supports the mapping of modules to class loaders. The set of modules mapped
+ * to the boot and platform class loaders is generated at build time from
+ * this source file.
  */
-final class ModuleLoaderMap {
+public final class ModuleLoaderMap {
+
+    /**
+     * Maps the system modules to the built-in class loaders.
+     */
+    public static final class Mapper implements Function<String, ClassLoader> {
+        private final Map<String, ClassLoader> map;
+
+        Mapper(Map<String, ClassLoader> map) {
+            this.map = map; // defensive copy not needed
+        }
+
+        @Override
+        public ClassLoader apply(String name) {
+            return map.get(name);
+        }
+    }
+
+    /**
+     * Returns the names of the modules defined to the boot loader.
+     */
+    public static Set<String> bootModules() {
+        // The list of boot modules generated at build time.
+        String[] BOOT_MODULES = new String[] { "@@BOOT_MODULE_NAMES@@" };
+        Set<String> bootModules = new HashSet<>(BOOT_MODULES.length);
+        for (String mn : BOOT_MODULES) {
+            bootModules.add(mn);
+        }
+        return bootModules;
+    }
+
+    /**
+     * Returns the names of the modules defined to the platform loader.
+     */
+    public static Set<String> platformModules() {
+        // The list of platform modules generated at build time.
+        String[] PLATFORM_MODULES = new String[] { "@@PLATFORM_MODULE_NAMES@@" };
+        Set<String> platformModules = new HashSet<>(PLATFORM_MODULES.length);
+        for (String mn : PLATFORM_MODULES) {
+            platformModules.add(mn);
+        }
+        return platformModules;
+    }
 
     /**
      * Returns the function to map modules in the given configuration to the
      * built-in class loaders.
      */
     static Function<String, ClassLoader> mappingFunction(Configuration cf) {
-
-        // The list of boot modules and platform modules are generated at build time.
-        final String[] BOOT_MODULES = new String[] { "@@BOOT_MODULE_NAMES@@" };
-        final String[] PLATFORM_MODULES = new String[] { "@@PLATFORM_MODULE_NAMES@@" };
-
-        Set<String> bootModules = new HashSet<>(BOOT_MODULES.length);
-        for (String mn : BOOT_MODULES) {
-            bootModules.add(mn);
-        }
-
-        Set<String> platformModules = new HashSet<>(PLATFORM_MODULES.length);
-        for (String mn : PLATFORM_MODULES) {
-            platformModules.add(mn);
-        }
+        Set<String> bootModules = bootModules();
+        Set<String> platformModules = platformModules();
 
         ClassLoader platformClassLoader = ClassLoaders.platformClassLoader();
         ClassLoader appClassLoader = ClassLoaders.appClassLoader();
 
         Map<String, ClassLoader> map = new HashMap<>();
-
         for (ResolvedModule resolvedModule : cf.modules()) {
             String mn = resolvedModule.name();
             if (!bootModules.contains(mn)) {
@@ -77,12 +107,6 @@
                 }
             }
         }
-
-        return new Function<String, ClassLoader> () {
-            @Override
-            public ClassLoader apply(String mn) {
-                return map.get(mn);
-            }
-        };
+        return new Mapper(map);
     }
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java	Wed Jul 05 23:25:53 2017 +0200
@@ -120,7 +120,7 @@
 
                     // JAR file - do not open as a multi-release JAR as this
                     // is not supported by the boot class loader
-                    try (JarFile jf = new JarFile(file.toFile())) {
+                    try (JarFile jf = new JarFile(file.toString())) {
                         jf.stream()
                           .filter(e -> !e.isDirectory()
                                   && (!isAutomatic || e.getName().endsWith(".class")))
@@ -431,7 +431,7 @@
         private final URL csURL;
 
         JarResourceFinder(Path path) throws IOException {
-            this.jf = new JarFile(path.toFile());
+            this.jf = new JarFile(path.toString());
             this.csURL = path.toUri().toURL();
         }
 
@@ -505,7 +505,7 @@
         public Resource find(String name) throws IOException {
             Path file = Resources.toFilePath(dir, name);
             if (file != null) {
-                return  newResource(name, dir, file);
+                return newResource(name, dir, file);
             } else {
                 return null;
             }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModulePath.java	Wed Jul 05 23:25:53 2017 +0200
@@ -59,6 +59,7 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
+import java.util.zip.ZipException;
 import java.util.zip.ZipFile;
 
 import jdk.internal.jmod.JmodFile;
@@ -315,26 +316,42 @@
     {
         try {
 
+            // exploded module
             if (attrs.isDirectory()) {
                 return readExplodedModule(entry); // may return null
-            } else {
+            }
+
+            // JAR or JMOD file
+            if (attrs.isRegularFile()) {
                 String fn = entry.getFileName().toString();
-                if (attrs.isRegularFile()) {
-                    if (fn.endsWith(".jar")) {
+                boolean isDefaultFileSystem = isDefaultFileSystem(entry);
+
+                // JAR file
+                if (fn.endsWith(".jar")) {
+                    if (isDefaultFileSystem) {
                         return readJar(entry);
-                    } else if (isLinkPhase && fn.endsWith(".jmod")) {
-                        return readJMod(entry);
+                    } else {
+                        // the JAR file is in a custom file system so
+                        // need to copy it to the local file system
+                        Path tmpdir = Files.createTempDirectory("mlib");
+                        Path target = Files.copy(entry, tmpdir.resolve(fn));
+                        return readJar(target);
                     }
                 }
-                return null;
+
+                // JMOD file
+                if (isDefaultFileSystem && isLinkPhase && fn.endsWith(".jmod")) {
+                    return readJMod(entry);
+                }
             }
 
+            return null;
+
         } catch (InvalidModuleDescriptorException e) {
             throw new FindException("Error reading module: " + entry, e);
         }
     }
 
-
     /**
      * Returns a string with the file name of the module if possible.
      * If the module location is not a file URI then return the URI
@@ -434,7 +451,7 @@
      * 3. The contents of any META-INF/services configuration files are mapped
      *    to "provides" declarations
      * 4. The Main-Class attribute in the main attributes of the JAR manifest
-     *    is mapped to the module descriptor mainClass
+     *    is mapped to the module descriptor mainClass if possible
      */
     private ModuleDescriptor deriveModuleDescriptor(JarFile jf)
         throws IOException
@@ -530,12 +547,12 @@
             String mainClass = attrs.getValue(Attributes.Name.MAIN_CLASS);
             if (mainClass != null) {
                 mainClass = mainClass.replace("/", ".");
-                String pn = packageName(mainClass);
-                if (!packages.contains(pn)) {
-                    String msg = "Main-Class " + mainClass + " not in module";
-                    throw new InvalidModuleDescriptorException(msg);
+                if (Checks.isClassName(mainClass)) {
+                    String pn = packageName(mainClass);
+                    if (packages.contains(pn)) {
+                        builder.mainClass(mainClass);
+                    }
                 }
-                builder.mainClass(mainClass);
             }
         }
 
@@ -617,6 +634,8 @@
             }
 
             return ModuleReferences.newJarModule(attrs, patcher, file);
+        } catch (ZipException e) {
+            throw new FindException("Error reading " + file, e);
         }
     }
 
@@ -733,6 +752,16 @@
         }
     }
 
+
+    /**
+     * Return true if a path locates a path in the default file system
+     */
+    private boolean isDefaultFileSystem(Path path) {
+        return path.getFileSystem().provider()
+                .getScheme().equalsIgnoreCase("file");
+    }
+
+
     private static final PerfCounter scanTime
         = PerfCounter.newPerfCounter("jdk.module.finder.modulepath.scanTime");
     private static final PerfCounter moduleCount
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferences.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleReferences.java	Wed Jul 05 23:25:53 2017 +0200
@@ -25,6 +25,7 @@
 
 package jdk.internal.module;
 
+import java.io.File;
 import java.io.IOError;
 import java.io.IOException;
 import java.io.InputStream;
@@ -226,8 +227,8 @@
 
         static JarFile newJarFile(Path path) {
             try {
-                return new JarFile(path.toFile(),
-                                   true,               // verify
+                return new JarFile(new File(path.toString()),
+                                   true,                       // verify
                                    ZipFile.OPEN_READ,
                                    JarFile.runtimeVersion());
             } catch (IOException ioe) {
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleResolution.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleResolution.java	Wed Jul 05 23:25:53 2017 +0200
@@ -39,6 +39,10 @@
         this.value = value;
     }
 
+    public int value() {
+        return value;
+    }
+
     public static ModuleResolution empty() {
         return new ModuleResolution(0);
     }
@@ -74,35 +78,30 @@
             throw new InternalError("cannot add deprecated for removal to " + value);
         return new ModuleResolution(value | WARN_DEPRECATED_FOR_REMOVAL);
     }
+
     public ModuleResolution withIncubating() {
         if ((value & (WARN_DEPRECATED | WARN_DEPRECATED_FOR_REMOVAL)) != 0)
             throw new InternalError("cannot add incubating to " + value);
         return new ModuleResolution(value | WARN_INCUBATING);
     }
 
-    public int value() {
-        return value;
-    }
-
     public static boolean doNotResolveByDefault(ModuleReference mref) {
         // get the DO_NOT_RESOLVE_BY_DEFAULT flag, if any
-        if (!(mref instanceof ModuleReferenceImpl))
-            return false;
-
-        ModuleResolution mres = ((ModuleReferenceImpl)mref).moduleResolution();
-        if (mres != null)
-            return mres.doNotResolveByDefault();
+        if (mref instanceof ModuleReferenceImpl) {
+            ModuleResolution mres = ((ModuleReferenceImpl) mref).moduleResolution();
+            if (mres != null)
+                return mres.doNotResolveByDefault();
+        }
 
         return false;
     }
 
     public static boolean hasIncubatingWarning(ModuleReference mref) {
-        if (!(mref instanceof ModuleReferenceImpl))
-            return false;
-
-        ModuleResolution mres = ((ModuleReferenceImpl)mref).moduleResolution();
-        if (mres != null)
-            return mres.hasIncubatingWarning();
+        if (mref instanceof ModuleReferenceImpl) {
+            ModuleResolution mres = ((ModuleReferenceImpl) mref).moduleResolution();
+            if (mres != null)
+                return mres.hasIncubatingWarning();
+        }
 
         return false;
     }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleTarget.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleTarget.java	Wed Jul 05 23:25:53 2017 +0200
@@ -25,22 +25,21 @@
 
 package jdk.internal.module;
 
+/**
+ * Represents the module target.
+ *
+ * For now, this is a single value for the target platform, e.g. "linux-x64".
+ */
 public final class ModuleTarget {
 
-    private final String osName;
-    private final String osArch;
+    private final String targetPlatform;
 
-    public ModuleTarget(String osName, String osArch) {
-        this.osName = osName;
-        this.osArch = osArch;
+    public ModuleTarget(String targetPlatform) {
+        this.targetPlatform = targetPlatform;
     }
 
-    public String osName() {
-        return osName;
-    }
-
-    public String osArch() {
-        return osArch;
+    public String targetPlatform() {
+        return targetPlatform;
     }
 
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/Modules.java	Wed Jul 05 23:25:53 2017 +0200
@@ -25,12 +25,22 @@
 
 package jdk.internal.module;
 
+import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReference;
+import java.lang.module.ResolvedModule;
 import java.net.URI;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 import jdk.internal.loader.BootLoader;
+import jdk.internal.loader.BuiltinClassLoader;
 import jdk.internal.loader.ClassLoaders;
 import jdk.internal.misc.JavaLangAccess;
 import jdk.internal.misc.SharedSecrets;
@@ -38,8 +48,8 @@
 /**
  * A helper class for creating and updating modules. This class is intended to
  * support command-line options, tests, and the instrumentation API. It is also
- * used by the VM to add read edges when agents are instrumenting code that
- * need to link to supporting classes.
+ * used by the VM to load modules or add read edges when agents are instrumenting
+ * code that need to link to supporting classes.
  *
  * The parameters that are package names in this API are the fully-qualified
  * names of the packages as defined in section 6.5.3 of <cite>The Java&trade;
@@ -154,4 +164,90 @@
         addReads(m, BootLoader.getUnnamedModule());
         addReads(m, ClassLoaders.appClassLoader().getUnnamedModule());
     }
+
+    /**
+     * Called by the VM to load a system module, typically "java.instrument" or
+     * "jdk.management.agent". If the module is not loaded then it is resolved
+     * and loaded (along with any dependences that weren't previously loaded)
+     * into a child layer.
+     */
+    public static synchronized Module loadModule(String name) {
+        ModuleLayer top = topLayer;
+        if (top == null)
+            top = ModuleLayer.boot();
+
+        Module module = top.findModule(name).orElse(null);
+        if (module != null) {
+            // module already loaded
+            return module;
+        }
+
+        // resolve the module with the top-most layer as the parent
+        ModuleFinder empty = ModuleFinder.of();
+        ModuleFinder finder = ModuleBootstrap.unlimitedFinder();
+        Set<String> roots = Set.of(name);
+        Configuration cf = top.configuration().resolveAndBind(empty, finder, roots);
+
+        // create the child layer
+        Function<String, ClassLoader> clf = ModuleLoaderMap.mappingFunction(cf);
+        ModuleLayer newLayer = top.defineModules(cf, clf);
+
+        // add qualified exports/opens to give access to modules in child layer
+        Map<String, Module> map = newLayer.modules().stream()
+                                          .collect(Collectors.toMap(Module::getName,
+                                                  Function.identity()));
+        ModuleLayer layer = top;
+        while (layer != null) {
+            for (Module m : layer.modules()) {
+                // qualified exports
+                m.getDescriptor().exports().stream()
+                    .filter(ModuleDescriptor.Exports::isQualified)
+                    .forEach(e -> e.targets().forEach(target -> {
+                        Module other = map.get(target);
+                        if (other != null) {
+                            addExports(m, e.source(), other);
+                        }}));
+
+                // qualified opens
+                m.getDescriptor().opens().stream()
+                    .filter(ModuleDescriptor.Opens::isQualified)
+                    .forEach(o -> o.targets().forEach(target -> {
+                        Module other = map.get(target);
+                        if (other != null) {
+                            addOpens(m, o.source(), other);
+                        }}));
+            }
+
+            List<ModuleLayer> parents = layer.parents();
+            assert parents.size() <= 1;
+            layer = parents.isEmpty() ? null : parents.get(0);
+        }
+
+        // update security manager before making types visible
+        JLA.addNonExportedPackages(newLayer);
+
+        // update the built-in class loaders to make the types visible
+        for (ResolvedModule resolvedModule : cf.modules()) {
+            ModuleReference mref = resolvedModule.reference();
+            String mn = mref.descriptor().name();
+            ClassLoader cl = clf.apply(mn);
+            if (cl == null) {
+                BootLoader.loadModule(mref);
+            } else {
+                ((BuiltinClassLoader) cl).loadModule(mref);
+            }
+        }
+
+        // new top layer
+        topLayer = newLayer;
+
+        // return module
+        return newLayer.findModule(name)
+                       .orElseThrow(() -> new InternalError("module not loaded"));
+
+    }
+
+    // the top-most system layer
+    private static ModuleLayer topLayer;
+
 }
--- a/jdk/src/java.base/share/classes/jdk/internal/module/Resources.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/module/Resources.java	Wed Jul 05 23:25:53 2017 +0200
@@ -26,10 +26,10 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.file.FileSystem;
 import java.nio.file.Files;
 import java.nio.file.NoSuchFileException;
 import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.nio.file.attribute.BasicFileAttributes;
 
 /**
@@ -94,7 +94,7 @@
         if (expectDirectory) {
             name = name.substring(0, name.length() - 1);  // drop trailing "/"
         }
-        Path path = toSafeFilePath(name);
+        Path path = toSafeFilePath(dir.getFileSystem(), name);
         if (path != null) {
             Path file = dir.resolve(path);
             try {
@@ -116,7 +116,7 @@
      * are rejected, as are resource names that translates to a file path
      * with a root component.
      */
-    private static Path toSafeFilePath(String name) {
+    private static Path toSafeFilePath(FileSystem fs, String name) {
         // scan elements of resource name
         int next;
         int off = 0;
@@ -135,12 +135,12 @@
         // convert to file path
         Path path;
         if (File.separatorChar == '/') {
-            path = Paths.get(name);
+            path = fs.getPath(name);
         } else {
             // not allowed to embed file separators
             if (name.contains(File.separator))
                 return null;
-            path = Paths.get(name.replace('/', File.separatorChar));
+            path = fs.getPath(name.replace('/', File.separatorChar));
         }
 
         // file path not allowed to have root component
--- a/jdk/src/java.base/share/classes/jdk/internal/reflect/Reflection.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/Reflection.java	Wed Jul 05 23:25:53 2017 +0200
@@ -31,6 +31,7 @@
 import java.util.Map;
 import java.util.Objects;
 import jdk.internal.HotSpotIntrinsicCandidate;
+import jdk.internal.loader.ClassLoaders;
 import jdk.internal.misc.VM;
 
 /** Common utility routines used by both java.lang and
@@ -315,23 +316,13 @@
      */
     public static boolean isCallerSensitive(Method m) {
         final ClassLoader loader = m.getDeclaringClass().getClassLoader();
-        if (VM.isSystemDomainLoader(loader) || isExtClassLoader(loader))  {
+        if (VM.isSystemDomainLoader(loader) ||
+                loader == ClassLoaders.platformClassLoader()) {
             return m.isAnnotationPresent(CallerSensitive.class);
         }
         return false;
     }
 
-    private static boolean isExtClassLoader(ClassLoader loader) {
-        ClassLoader cl = ClassLoader.getSystemClassLoader();
-        while (cl != null) {
-            if (cl.getParent() == null && cl == loader) {
-                return true;
-            }
-            cl = cl.getParent();
-        }
-        return false;
-    }
-
     /**
      * Returns an IllegalAccessException with an exception message based on
      * the access that is denied.
--- a/jdk/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java	Wed Jul 05 23:25:53 2017 +0200
@@ -135,6 +135,24 @@
         return soleInstance;
     }
 
+    /**
+     * Returns an alternate reflective Method instance for the given method
+     * intended for reflection to invoke, if present.
+     *
+     * A trusted method can define an alternate implementation for a method `foo`
+     * by defining a method named "reflected$foo" that will be invoked
+     * reflectively.
+     */
+    private static Method findMethodForReflection(Method method) {
+        String altName = "reflected$" + method.getName();
+        try {
+           return method.getDeclaringClass()
+                        .getDeclaredMethod(altName, method.getParameterTypes());
+        } catch (NoSuchMethodException ex) {
+            return null;
+        }
+    }
+
     //--------------------------------------------------------------------------
     //
     // Routines used by java.lang.reflect
@@ -161,6 +179,13 @@
     public MethodAccessor newMethodAccessor(Method method) {
         checkInitted();
 
+        if (Reflection.isCallerSensitive(method)) {
+            Method altMethod = findMethodForReflection(method);
+            if (altMethod != null) {
+                method = altMethod;
+            }
+        }
+
         if (noInflation && !ReflectUtil.isVMAnonymousClass(method.getDeclaringClass())) {
             return new MethodAccessorGenerator().
                 generateMethod(method.getDeclaringClass(),
--- a/jdk/src/java.base/share/classes/module-info.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/module-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -161,6 +161,7 @@
         java.security.jgss,
         java.sql,
         java.xml,
+        jdk.attach,
         jdk.charsets,
         jdk.compiler,   // reflective dependency
         jdk.incubator.httpclient,
--- a/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Wed Jul 05 23:25:53 2017 +0200
@@ -43,13 +43,17 @@
 import java.io.IOException;
 import java.io.PrintStream;
 import java.io.UnsupportedEncodingException;
-import java.lang.module.ModuleFinder;
-import java.lang.module.ModuleReference;
+import java.lang.module.Configuration;
+import java.lang.module.FindException;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleDescriptor.Requires;
 import java.lang.module.ModuleDescriptor.Exports;
 import java.lang.module.ModuleDescriptor.Opens;
 import java.lang.module.ModuleDescriptor.Provides;
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReference;
+import java.lang.module.ResolvedModule;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.math.BigDecimal;
@@ -58,14 +62,16 @@
 import java.nio.charset.Charset;
 import java.nio.file.DirectoryStream;
 import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
 import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributes;
 import java.text.Normalizer;
 import java.text.MessageFormat;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.HashSet;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
@@ -83,6 +89,7 @@
 import java.util.stream.Stream;
 
 import jdk.internal.misc.VM;
+import jdk.internal.module.ModuleBootstrap;
 import jdk.internal.module.Modules;
 
 
@@ -98,6 +105,7 @@
             "javafx.application.Application";
     private static final String JAVAFX_FXHELPER_CLASS_NAME_SUFFIX =
             "sun.launcher.LauncherHelper$FXHelper";
+    private static final String LAUNCHER_AGENT_CLASS = "Launcher-Agent-Class";
     private static final String MAIN_CLASS = "Main-Class";
     private static final String ADD_EXPORTS = "Add-Exports";
     private static final String ADD_OPENS = "Add-Opens";
@@ -408,8 +416,12 @@
         ostream =  (printToStderr) ? System.err : System.out;
     }
 
+    static void initOutput(PrintStream ps) {
+        ostream = ps;
+    }
+
     static String getMainClassFromJar(String jarname) {
-        String mainValue = null;
+        String mainValue;
         try (JarFile jarFile = new JarFile(jarname)) {
             Manifest manifest = jarFile.getManifest();
             if (manifest == null) {
@@ -426,6 +438,22 @@
                 abort(null, "java.launcher.jar.error3", jarname);
             }
 
+            // Launcher-Agent-Class (only check for this when Main-Class present)
+            String agentClass = mainAttrs.getValue(LAUNCHER_AGENT_CLASS);
+            if (agentClass != null) {
+                ModuleLayer.boot().findModule("java.instrument").ifPresent(m -> {
+                    try {
+                        String cn = "sun.instrument.InstrumentationImpl";
+                        Class<?> clazz = Class.forName(cn, false, null);
+                        Method loadAgent = clazz.getMethod("loadAgent", String.class);
+                        loadAgent.invoke(null, jarname);
+                    } catch (Throwable e) {
+                        if (e instanceof InvocationTargetException) e = e.getCause();
+                        abort(e, "java.launcher.jar.error4", jarname);
+                    }
+                });
+            }
+
             // Add-Exports and Add-Opens
             String exports = mainAttrs.getValue(ADD_EXPORTS);
             if (exports != null) {
@@ -913,141 +941,350 @@
         }
     }
 
-    private static void formatCommaList(PrintStream out,
-                                        String prefix,
-                                        Collection<?> list)
-    {
-        if (list.isEmpty())
-            return;
-        out.format("%s", prefix);
-        boolean first = true;
-        for (Object ob : list) {
-            if (first) {
-                out.format(" %s", ob);
-                first = false;
-            } else {
-                out.format(", %s", ob);
-            }
-        }
-        out.format("%n");
+    /**
+     * Called by the launcher to list the observable modules.
+     */
+    static void listModules() {
+        initOutput(System.out);
+
+        ModuleBootstrap.limitedFinder().findAll().stream()
+            .sorted(new JrtFirstComparator())
+            .forEach(LauncherHelper::showModule);
+    }
+
+    /**
+     * Called by the launcher to show the resolved modules
+     */
+    static void showResolvedModules() {
+        initOutput(System.out);
+
+        ModuleLayer bootLayer = ModuleLayer.boot();
+        Configuration cf = bootLayer.configuration();
+
+        cf.modules().stream()
+            .map(ResolvedModule::reference)
+            .sorted(new JrtFirstComparator())
+            .forEach(LauncherHelper::showModule);
     }
 
     /**
-     * Called by the launcher to list the observable modules.
-     * If called without any sub-options then the output is a simple list of
-     * the modules. If called with sub-options then the sub-options are the
-     * names of the modules to list (e.g. --list-modules java.base,java.desktop)
+     * Called by the launcher to describe a module
      */
-    static void listModules(boolean printToStderr, String optionFlag)
-        throws IOException, ClassNotFoundException
-    {
-        initOutput(printToStderr);
+    static void describeModule(String moduleName) {
+        initOutput(System.out);
 
-        ModuleFinder finder = jdk.internal.module.ModuleBootstrap.finder();
-        int colon = optionFlag.indexOf('=');
-        if (colon == -1) {
-            finder.findAll().stream()
-                  .sorted(Comparator.comparing(ModuleReference::descriptor))
-                  .forEach(mref -> describeModule(finder, mref, false));
-        } else {
-            String[] names = optionFlag.substring(colon+1).split(",");
-            for (String name: names) {
-                ModuleReference mref = finder.find(name).orElse(null);
-                if (mref == null) {
-                    System.err.format("%s not found%n", name);
-                    continue;
-                }
-                describeModule(finder, mref, true);
-            }
+        ModuleFinder finder = ModuleBootstrap.limitedFinder();
+        ModuleReference mref = finder.find(moduleName).orElse(null);
+        if (mref == null) {
+            abort(null, "java.launcher.module.error4", moduleName);
         }
-    }
+        ModuleDescriptor md = mref.descriptor();
 
-    /**
-     * Describes the given module.
-     */
-    static void describeModule(ModuleFinder finder,
-                               ModuleReference mref,
-                               boolean verbose)
-    {
-        ModuleDescriptor md = mref.descriptor();
-        ostream.print("module " + midAndLocation(md, mref.location()));
-        if (md.isAutomatic())
-            ostream.print(" automatic");
-        ostream.println();
-
-        if (!verbose)
-            return;
+        // one-line summary
+        showModule(mref);
 
         // unqualified exports (sorted by package)
-        Set<Exports> exports = new TreeSet<>(Comparator.comparing(Exports::source));
-        md.exports().stream().filter(e -> !e.isQualified()).forEach(exports::add);
-        for (Exports e : exports) {
-            String modsAndSource = Stream.concat(toStringStream(e.modifiers()),
-                    Stream.of(e.source()))
+        md.exports().stream()
+            .filter(e -> !e.isQualified())
+            .sorted(Comparator.comparing(Exports::source))
+            .map(e -> Stream.concat(Stream.of(e.source()),
+                                    toStringStream(e.modifiers()))
+                    .collect(Collectors.joining(" ")))
+            .forEach(sourceAndMods -> ostream.format("exports %s%n", sourceAndMods));
+
+        // dependences
+        for (Requires r : md.requires()) {
+            String nameAndMods = Stream.concat(Stream.of(r.name()),
+                                               toStringStream(r.modifiers()))
                     .collect(Collectors.joining(" "));
-            ostream.format("  exports %s%n", modsAndSource);
+            ostream.format("requires %s", nameAndMods);
+            finder.find(r.name())
+                .map(ModuleReference::descriptor)
+                .filter(ModuleDescriptor::isAutomatic)
+                .ifPresent(any -> ostream.print(" automatic"));
+            ostream.println();
         }
 
-        for (Requires d : md.requires()) {
-            ostream.format("  requires %s", d);
-            String suffix = finder.find(d.name())
-                    .map(ModuleReference::descriptor)
-                    .map(any -> any.isAutomatic() ? " automatic" : "")
-                    .orElse(" not found");
-            ostream.println(suffix);
+        // service use and provides
+        for (String s : md.uses()) {
+            ostream.format("uses %s%n", s);
         }
-        for (String s : md.uses()) {
-            ostream.format("  uses %s%n", s);
-        }
+        for (Provides ps : md.provides()) {
+            String names = ps.providers().stream().collect(Collectors.joining(" "));
+            ostream.format("provides %s with %s%n", ps.service(), names);
 
-        for (Provides ps : md.provides()) {
-            ostream.format("  provides %s with %s%n", ps.service(),
-                    ps.providers().stream().collect(Collectors.joining(", ")));
         }
 
         // qualified exports
         for (Exports e : md.exports()) {
             if (e.isQualified()) {
-                String modsAndSource = Stream.concat(toStringStream(e.modifiers()),
-                        Stream.of(e.source()))
-                        .collect(Collectors.joining(" "));
-                ostream.format("  exports %s", modsAndSource);
-                formatCommaList(ostream, " to", e.targets());
+                String who = e.targets().stream().collect(Collectors.joining(" "));
+                ostream.format("qualified exports %s to %s%n", e.source(), who);
             }
         }
 
         // open packages
-        for (Opens obj: md.opens()) {
-            String modsAndSource = Stream.concat(toStringStream(obj.modifiers()),
-                    Stream.of(obj.source()))
+        for (Opens opens: md.opens()) {
+            if (opens.isQualified())
+                ostream.print("qualified ");
+            String sourceAndMods = Stream.concat(Stream.of(opens.source()),
+                                                 toStringStream(opens.modifiers()))
                     .collect(Collectors.joining(" "));
-            ostream.format("  opens %s", modsAndSource);
-            if (obj.isQualified())
-                formatCommaList(ostream, " to", obj.targets());
-            else
-                ostream.println();
+            ostream.format("opens %s", sourceAndMods);
+            if (opens.isQualified()) {
+                String who = opens.targets().stream().collect(Collectors.joining(" "));
+                ostream.format(" to %s", who);
+            }
+            ostream.println();
         }
 
         // non-exported/non-open packages
         Set<String> concealed = new TreeSet<>(md.packages());
         md.exports().stream().map(Exports::source).forEach(concealed::remove);
         md.opens().stream().map(Opens::source).forEach(concealed::remove);
-        concealed.forEach(p -> ostream.format("  contains %s%n", p));
+        concealed.forEach(p -> ostream.format("contains %s%n", p));
+    }
+
+    /**
+     * Prints a single line with the module name, version and modifiers
+     */
+    private static void showModule(ModuleReference mref) {
+        ModuleDescriptor md = mref.descriptor();
+        ostream.print(md.toNameAndVersion());
+        mref.location()
+                .filter(uri -> !isJrt(uri))
+                .ifPresent(uri -> ostream.format(" %s", uri));
+        if (md.isOpen())
+            ostream.print(" open");
+        if (md.isAutomatic())
+            ostream.print(" automatic");
+        ostream.println();
     }
 
-    static <T> String toString(Set<T> s) {
-        return toStringStream(s).collect(Collectors.joining(" "));
+    /**
+     * A ModuleReference comparator that considers modules in the run-time
+     * image to be less than modules than not in the run-time image.
+     */
+    private static class JrtFirstComparator implements Comparator<ModuleReference> {
+        private final Comparator<ModuleReference> real;
+
+        JrtFirstComparator() {
+            this.real = Comparator.comparing(ModuleReference::descriptor);
+        }
+
+        @Override
+        public int compare(ModuleReference a, ModuleReference b) {
+            if (isJrt(a)) {
+                return isJrt(b) ? real.compare(a, b) : -1;
+            } else {
+                return isJrt(b) ? 1 : real.compare(a, b);
+            }
+        }
     }
 
-    static <T> Stream<String> toStringStream(Set<T> s) {
+    private static <T> Stream<String> toStringStream(Set<T> s) {
         return s.stream().map(e -> e.toString().toLowerCase());
     }
 
-    static String midAndLocation(ModuleDescriptor md, Optional<URI> location ) {
-        URI loc = location.orElse(null);
-        if (loc == null || loc.getScheme().equalsIgnoreCase("jrt"))
-            return md.toNameAndVersion();
-        else
-            return md.toNameAndVersion() + " (" + loc + ")";
+    private static boolean isJrt(ModuleReference mref) {
+        return isJrt(mref.location().orElse(null));
+    }
+
+    private static boolean isJrt(URI uri) {
+        return (uri != null && uri.getScheme().equalsIgnoreCase("jrt"));
+    }
+
+    /**
+     * Called by the launcher to validate the modules on the upgrade and
+     * application module paths.
+     *
+     * @return {@code true} if no errors are found
+     */
+    private static boolean validateModules() {
+        initOutput(System.out);
+
+        ModuleValidator validator = new ModuleValidator();
+
+        // upgrade module path
+        String value = System.getProperty("jdk.module.upgrade.path");
+        if (value != null) {
+            Stream.of(value.split(File.pathSeparator))
+                    .map(Paths::get)
+                    .forEach(validator::scan);
+        }
+
+        // system modules
+        ModuleFinder.ofSystem().findAll().stream()
+                .sorted(Comparator.comparing(ModuleReference::descriptor))
+                .forEach(validator::process);
+
+        // application module path
+        value = System.getProperty("jdk.module.path");
+        if (value != null) {
+            Stream.of(value.split(File.pathSeparator))
+                    .map(Paths::get)
+                    .forEach(validator::scan);
+        }
+
+        return !validator.foundErrors();
+    }
+
+    /**
+     * A simple validator to check for errors and conflicts between modules.
+     */
+    static class ModuleValidator {
+        private static final String MODULE_INFO = "module-info.class";
+
+        private Map<String, ModuleReference> nameToModule = new HashMap<>();
+        private Map<String, ModuleReference> packageToModule = new HashMap<>();
+        private boolean errorFound;
+
+        /**
+         * Returns true if at least one error was found
+         */
+        boolean foundErrors() {
+            return errorFound;
+        }
+
+        /**
+         * Prints the module location and name.
+         */
+        private void printModule(ModuleReference mref) {
+            mref.location()
+                .filter(uri -> !isJrt(uri))
+                .ifPresent(uri -> ostream.print(uri + " "));
+            ModuleDescriptor descriptor = mref.descriptor();
+            ostream.print(descriptor.name());
+            if (descriptor.isAutomatic())
+                ostream.print(" automatic");
+            ostream.println();
+        }
+
+        /**
+         * Prints the module location and name, checks if the module is
+         * shadowed by a previously seen module, and finally checks for
+         * package conflicts with previously seen modules.
+         */
+        void process(ModuleReference mref) {
+            printModule(mref);
+
+            String name = mref.descriptor().name();
+            ModuleReference previous = nameToModule.putIfAbsent(name, mref);
+            if (previous != null) {
+                ostream.print(INDENT + "shadowed by ");
+                printModule(previous);
+            } else {
+                // check for package conflicts when not shadowed
+                for (String pkg :  mref.descriptor().packages()) {
+                    previous = packageToModule.putIfAbsent(pkg, mref);
+                    if (previous != null) {
+                        String mn = previous.descriptor().name();
+                        ostream.println(INDENT + "contains " + pkg
+                                        + " conflicts with module " + mn);
+                        errorFound = true;
+                    }
+                }
+            }
+        }
+
+        /**
+         * Scan an element on a module path. The element is a directory
+         * of modules, an exploded module, or a JAR file.
+         */
+        void scan(Path entry) {
+            BasicFileAttributes attrs;
+            try {
+                attrs = Files.readAttributes(entry, BasicFileAttributes.class);
+            } catch (NoSuchFileException ignore) {
+                return;
+            } catch (IOException ioe) {
+                ostream.println(entry + " " + ioe);
+                errorFound = true;
+                return;
+            }
+
+            String fn = entry.getFileName().toString();
+            if (attrs.isRegularFile() && fn.endsWith(".jar")) {
+                // JAR file, explicit or automatic module
+                scanModule(entry).ifPresent(this::process);
+            } else if (attrs.isDirectory()) {
+                Path mi = entry.resolve(MODULE_INFO);
+                if (Files.exists(mi)) {
+                    // exploded module
+                    scanModule(entry).ifPresent(this::process);
+                } else {
+                    // directory of modules
+                    scanDirectory(entry);
+                }
+            }
+        }
+
+        /**
+         * Scan the JAR files and exploded modules in a directory.
+         */
+        private void scanDirectory(Path dir) {
+            try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir)) {
+                Map<String, Path> moduleToEntry = new HashMap<>();
+
+                for (Path entry : stream) {
+                    BasicFileAttributes attrs;
+                    try {
+                        attrs = Files.readAttributes(entry, BasicFileAttributes.class);
+                    } catch (IOException ioe) {
+                        ostream.println(entry + " " + ioe);
+                        errorFound = true;
+                        continue;
+                    }
+
+                    ModuleReference mref = null;
+
+                    String fn = entry.getFileName().toString();
+                    if (attrs.isRegularFile() && fn.endsWith(".jar")) {
+                        mref = scanModule(entry).orElse(null);
+                    } else if (attrs.isDirectory()) {
+                        Path mi = entry.resolve(MODULE_INFO);
+                        if (Files.exists(mi)) {
+                            mref = scanModule(entry).orElse(null);
+                        }
+                    }
+
+                    if (mref != null) {
+                        String name = mref.descriptor().name();
+                        Path previous = moduleToEntry.putIfAbsent(name, entry);
+                        if (previous != null) {
+                            // same name as other module in the directory
+                            printModule(mref);
+                            ostream.println(INDENT + "contains same module as "
+                                            + previous.getFileName());
+                            errorFound = true;
+                        } else {
+                            process(mref);
+                        }
+                    }
+                }
+            } catch (IOException ioe) {
+                ostream.println(dir + " " + ioe);
+                errorFound = true;
+            }
+        }
+
+        /**
+         * Scan a JAR file or exploded module.
+         */
+        private Optional<ModuleReference> scanModule(Path entry) {
+            ModuleFinder finder = ModuleFinder.of(entry);
+            try {
+                return finder.findAll().stream().findFirst();
+            } catch (FindException e) {
+                ostream.println(entry);
+                ostream.println(INDENT + e.getMessage());
+                Throwable cause = e.getCause();
+                if (cause != null) {
+                    ostream.println(INDENT + cause);
+                }
+                errorFound = true;
+                return Optional.empty();
+            }
+        }
     }
 }
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Wed Jul 05 23:25:53 2017 +0200
@@ -53,26 +53,33 @@
 \                  A {0} separated list of directories, each directory\n\
 \                  is a directory of modules that replace upgradeable\n\
 \                  modules in the runtime image\n\
-\    --add-modules <modulename>[,<modulename>...]\n\
+\    --add-modules <module name>[,<module name>...]\n\
 \                  root modules to resolve in addition to the initial module.\n\
-\                  <modulename> can also be ALL-DEFAULT, ALL-SYSTEM,\n\
+\                  <module name> can also be ALL-DEFAULT, ALL-SYSTEM,\n\
 \                  ALL-MODULE-PATH.\n\
-\    --limit-modules <modulename>[,<modulename>...]\n\
-\                  limit the universe of observable modules\n\
-\    --list-modules [<modulename>[,<modulename>...]]\n\
-\                  list the observable modules and exit\n\
-\    --dry-run     create VM but do not execute main method.\n\
-\                  This --dry-run option may be useful for validating the\n\
+\    --list-modules\n\
+\                  list observable modules and exit\n\
+\    --d <module name>\n\
+\    --describe-module <module name>\n\
+\                  describe a module and exit\n\
+\    --dry-run     create VM and load main class but do not execute main method.\n\
+\                  The --dry-run option may be useful for validating the\n\
 \                  command-line options such as the module system configuration.\n\
+\    --validate-modules\n\
+\                  validate all modules and exit\n\
+\                  The --validate-modules option may be useful for finding\n\
+\                  conflicts and other errors with modules on the module path.\n\
 \    -D<name>=<value>\n\
 \                  set a system property\n\
-\    -verbose:[class|gc|jni]\n\
+\    -verbose:[class|module|gc|jni]\n\
 \                  enable verbose output\n\
 \    -version      print product version to the error stream and exit\n\
 \    --version     print product version to the output stream and exit\n\
 \    -showversion  print product version to the error stream and continue\n\
 \    --show-version\n\
 \                  print product version to the output stream and continue\n\
+\    --show-module-resolution\n\
+\                  show module resolution output during startup\n\
 \    -? -h -help\n\
 \                  print this help message to the error stream\n\
 \    --help        print this help message to the output stream\n\
@@ -119,7 +126,6 @@
 \    -Xcomp            forces compilation of methods on first invocation\n\
 \    -Xdebug           provided for backward compatibility\n\
 \    -Xdiag            show additional diagnostic messages\n\
-\    -Xdiag:resolver   show resolver diagnostic messages\n\
 \    -Xfuture          enable strictest checks, anticipating future default\n\
 \    -Xint             interpreted mode execution only\n\
 \    -Xinternalversion\n\
@@ -164,10 +170,12 @@
 \                      permit illegal access to members of types in named modules\n\
 \                      by code in unnamed modules. This compatibility option will\n\
 \                      be removed in the next release.\n\
-\    --disable-@files  disable further argument file expansion\n\
+\    --limit-modules <module name>[,<module name>...]\n\
+\                      limit the universe of observable modules\n\
 \    --patch-module <module>=<file>({0}<file>)*\n\
-\                      Override or augment a module with classes and resources\n\
-\                      in JAR files or directories.\n\n\
+\                      override or augment a module with classes and resources\n\
+\                      in JAR files or directories.\n\
+\    --disable-@files  disable further argument file expansion\n\n\
 These extra options are subject to change without notice.\n
 
 # Translators please note do not translate the options themselves
@@ -204,6 +212,7 @@
     Error: An unexpected error occurred while trying to open file {0}
 java.launcher.jar.error2=manifest not found in {0}
 java.launcher.jar.error3=no main manifest attribute, in {0}
+java.launcher.jar.error4=error loading java agent in {0}
 java.launcher.init.error=initialization error
 java.launcher.javafx.error1=\
     Error: The JavaFX launchApplication method has the wrong signature, it\n\
@@ -215,4 +224,5 @@
 java.launcher.module.error3=\
     Error: Unable to load main class {0} from module {1}\n\
     \t{2}
-
+java.launcher.module.error4=\
+    {0} not found
--- a/jdk/src/java.base/share/classes/sun/security/provider/X509Factory.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/provider/X509Factory.java	Wed Jul 05 23:25:53 2017 +0200
@@ -553,8 +553,7 @@
             return bout.toByteArray();
         } else {
             // Read BASE64 encoded data, might skip info at the beginning
-            char[] data = new char[2048];
-            int pos = 0;
+            ByteArrayOutputStream data = new ByteArrayOutputStream();
 
             // Step 1: Read until header is found
             int hyphen = (c=='-') ? 1: 0;   // count of consequent hyphens
@@ -598,7 +597,10 @@
                         end = '\n';
                     } else {
                         end = '\r';
-                        data[pos++] = (char)next;
+                        // Skip all white space chars
+                        if (next != 9 && next != 10 && next != 13 && next != 32) {
+                            data.write(next);
+                        }
                     }
                     break;
                 }
@@ -612,9 +614,9 @@
                     throw new IOException("Incomplete data");
                 }
                 if (next != '-') {
-                    data[pos++] = (char)next;
-                    if (pos >= data.length) {
-                        data = Arrays.copyOf(data, data.length+1024);
+                    // Skip all white space chars
+                    if (next != 9 && next != 10 && next != 13 && next != 32) {
+                        data.write(next);
                     }
                 } else {
                     break;
@@ -635,7 +637,11 @@
 
             checkHeaderFooter(header.toString(), footer.toString());
 
-            return Pem.decode(new String(data, 0, pos));
+            try {
+                return Base64.getDecoder().decode(data.toByteArray());
+            } catch (IllegalArgumentException e) {
+                throw new IOException(e);
+            }
         }
     }
 
--- a/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuite.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuite.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,6 +44,7 @@
 import static sun.security.ssl.CipherSuite.MacAlg.*;
 import static sun.security.ssl.CipherSuite.BulkCipher.*;
 import static sun.security.ssl.JsseJce.*;
+import static sun.security.ssl.NamedGroupType.*;
 
 /**
  * An SSL/TLS CipherSuite. Constants for the standard key exchange, cipher,
@@ -376,38 +377,38 @@
     static enum KeyExchange {
 
         // key exchange algorithms
-        K_NULL       ("NULL",       false,      false),
-        K_RSA        ("RSA",        true,       false),
-        K_RSA_EXPORT ("RSA_EXPORT", true,       false),
-        K_DH_RSA     ("DH_RSA",     false,      false),
-        K_DH_DSS     ("DH_DSS",     false,      false),
-        K_DHE_DSS    ("DHE_DSS",    true,       false),
-        K_DHE_RSA    ("DHE_RSA",    true,       false),
-        K_DH_ANON    ("DH_anon",    true,       false),
+        K_NULL       ("NULL",       false,      NAMED_GROUP_NONE),
+        K_RSA        ("RSA",        true,       NAMED_GROUP_NONE),
+        K_RSA_EXPORT ("RSA_EXPORT", true,       NAMED_GROUP_NONE),
+        K_DH_RSA     ("DH_RSA",     false,      NAMED_GROUP_NONE),
+        K_DH_DSS     ("DH_DSS",     false,      NAMED_GROUP_NONE),
+        K_DHE_DSS    ("DHE_DSS",    true,       NAMED_GROUP_FFDHE),
+        K_DHE_RSA    ("DHE_RSA",    true,       NAMED_GROUP_FFDHE),
+        K_DH_ANON    ("DH_anon",    true,       NAMED_GROUP_FFDHE),
 
-        K_ECDH_ECDSA ("ECDH_ECDSA",  ALLOW_ECC, true),
-        K_ECDH_RSA   ("ECDH_RSA",    ALLOW_ECC, true),
-        K_ECDHE_ECDSA("ECDHE_ECDSA", ALLOW_ECC, true),
-        K_ECDHE_RSA  ("ECDHE_RSA",   ALLOW_ECC, true),
-        K_ECDH_ANON  ("ECDH_anon",   ALLOW_ECC, true),
+        K_ECDH_ECDSA ("ECDH_ECDSA",  ALLOW_ECC, NAMED_GROUP_ECDHE),
+        K_ECDH_RSA   ("ECDH_RSA",    ALLOW_ECC, NAMED_GROUP_ECDHE),
+        K_ECDHE_ECDSA("ECDHE_ECDSA", ALLOW_ECC, NAMED_GROUP_ECDHE),
+        K_ECDHE_RSA  ("ECDHE_RSA",   ALLOW_ECC, NAMED_GROUP_ECDHE),
+        K_ECDH_ANON  ("ECDH_anon",   ALLOW_ECC, NAMED_GROUP_ECDHE),
 
         // Kerberos cipher suites
-        K_KRB5       ("KRB5", true,             false),
-        K_KRB5_EXPORT("KRB5_EXPORT", true,      false),
+        K_KRB5       ("KRB5", true,             NAMED_GROUP_NONE),
+        K_KRB5_EXPORT("KRB5_EXPORT", true,      NAMED_GROUP_NONE),
 
         // renegotiation protection request signaling cipher suite
-        K_SCSV       ("SCSV",        true,      false);
+        K_SCSV       ("SCSV",        true,      NAMED_GROUP_NONE);
 
         // name of the key exchange algorithm, e.g. DHE_DSS
         final String name;
         final boolean allowed;
-        final boolean isEC;
+        final NamedGroupType groupType;
         private final boolean alwaysAvailable;
 
-        KeyExchange(String name, boolean allowed, boolean isEC) {
+        KeyExchange(String name, boolean allowed, NamedGroupType groupType) {
             this.name = name;
             this.allowed = allowed;
-            this.isEC = isEC;
+            this.groupType = groupType;
             this.alwaysAvailable = allowed &&
                 (!name.startsWith("EC")) && (!name.startsWith("KRB"));
         }
@@ -417,7 +418,7 @@
                 return true;
             }
 
-            if (isEC) {
+            if (groupType == NAMED_GROUP_ECDHE) {
                 return (allowed && JsseJce.isEcAvailable());
             } else if (name.startsWith("KRB")) {
                 return (allowed && JsseJce.isKerberosAvailable());
--- a/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuiteList.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuiteList.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 import java.util.*;
 
 import javax.net.ssl.SSLException;
+import static sun.security.ssl.NamedGroupType.*;
 
 /**
  * A list of CipherSuites. Also maintains the lists of supported and
@@ -42,15 +43,16 @@
 
     private final Collection<CipherSuite> cipherSuites;
     private String[] suiteNames;
-
-    // flag indicating whether this list contains any ECC ciphersuites.
-    // null if not yet checked.
-    private volatile Boolean containsEC;
+    private final EnumSet<NamedGroupType> groupsTypes =
+            EnumSet.noneOf(NamedGroupType.class);
 
     // for use by buildAvailableCache() and
     // Handshaker.getKickstartMessage() only
     CipherSuiteList(Collection<CipherSuite> cipherSuites) {
         this.cipherSuites = cipherSuites;
+        for (CipherSuite suite : cipherSuites) {
+            updateGroupTypes(suite);
+        }
     }
 
     /**
@@ -59,6 +61,7 @@
     CipherSuiteList(CipherSuite suite) {
         cipherSuites = new ArrayList<CipherSuite>(1);
         cipherSuites.add(suite);
+        updateGroupTypes(suite);
     }
 
     /**
@@ -82,6 +85,7 @@
                     + suiteName + " with currently installed providers");
             }
             cipherSuites.add(suite);
+            updateGroupTypes(suite);
         }
     }
 
@@ -97,7 +101,20 @@
         }
         cipherSuites = new ArrayList<CipherSuite>(bytes.length >> 1);
         for (int i = 0; i < bytes.length; i += 2) {
-            cipherSuites.add(CipherSuite.valueOf(bytes[i], bytes[i+1]));
+            CipherSuite suite = CipherSuite.valueOf(bytes[i], bytes[i+1]);
+            cipherSuites.add(suite);
+            updateGroupTypes(suite);
+        }
+    }
+
+    // Please don't use this method except constructors.
+    private void updateGroupTypes(CipherSuite cipherSuite) {
+        if (cipherSuite.keyExchange != null && (!cipherSuite.exportable)) {
+            NamedGroupType groupType = cipherSuite.keyExchange.groupType;
+            if ((groupType != NAMED_GROUP_NONE) &&
+                    (!groupsTypes.contains(groupType))) {
+                groupsTypes.add(groupType);
+            }
         }
     }
 
@@ -108,20 +125,9 @@
         return cipherSuites.contains(suite);
     }
 
-    // Return whether this list contains any ECC ciphersuites
-    boolean containsEC() {
-        if (containsEC == null) {
-            for (CipherSuite c : cipherSuites) {
-                if (c.keyExchange.isEC) {
-                    containsEC = true;
-                    return true;
-                }
-            }
-
-            containsEC = false;
-        }
-
-        return containsEC;
+    // Return whether this list contains cipher suites of a named group type.
+    boolean contains(NamedGroupType groupType) {
+        return groupsTypes.contains(groupType);
     }
 
     /**
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -148,6 +148,10 @@
     private static final boolean enableMFLExtension =
             Debug.getBooleanProperty("jsse.enableMFLExtension", false);
 
+    // To switch off the supported_groups extension for DHE cipher suite.
+    private static final boolean enableFFDHE =
+            Debug.getBooleanProperty("jsse.enableFFDHE", true);
+
     // Whether an ALPN extension was sent in the ClientHello
     private boolean alpnActive = false;
 
@@ -767,13 +771,15 @@
                     fatalSE(Alerts.alert_unexpected_message, "Server set " +
                             type + " extension when not requested by client");
                 }
-            } else if ((type != ExtensionType.EXT_ELLIPTIC_CURVES)
+            } else if ((type != ExtensionType.EXT_SUPPORTED_GROUPS)
                     && (type != ExtensionType.EXT_EC_POINT_FORMATS)
                     && (type != ExtensionType.EXT_SERVER_NAME)
                     && (type != ExtensionType.EXT_ALPN)
                     && (type != ExtensionType.EXT_RENEGOTIATION_INFO)
                     && (type != ExtensionType.EXT_STATUS_REQUEST)
                     && (type != ExtensionType.EXT_STATUS_REQUEST_V2)) {
+                // Note: Better to check client requested extensions rather
+                // than all supported extensions.
                 fatalSE(Alerts.alert_unsupported_extension,
                     "Server sent an unsupported extension: " + type);
             }
@@ -823,6 +829,17 @@
      * our own D-H algorithm object so we can defer key calculations
      * until after we've sent the client key exchange message (which
      * gives client and server some useful parallelism).
+     *
+     * Note per section 3 of RFC 7919, if the server is not compatible with
+     * FFDHE specification, the client MAY decide to continue the connection
+     * if the selected DHE group is acceptable under local policy, or it MAY
+     * decide to terminate the connection with a fatal insufficient_security
+     * (71) alert.  The algorithm constraints mechanism is JDK local policy
+     * used for additional DHE parameters checking.  So this implementation
+     * does not check the server compatibility and just pass to the local
+     * algorithm constraints checking.  The client will continue the
+     * connection if the server selected DHE group is acceptable by the
+     * specified algorithm constraints.
      */
     private void serverKeyExchange(DH_ServerKeyExchange mesg)
             throws IOException {
@@ -1495,14 +1512,17 @@
                 sslContext.getSecureRandom(), maxProtocolVersion,
                 sessionId, cipherSuites, isDTLS);
 
-        // add elliptic curves and point format extensions
-        if (cipherSuites.containsEC()) {
-            EllipticCurvesExtension ece =
-                EllipticCurvesExtension.createExtension(algorithmConstraints);
-            if (ece != null) {
-                clientHelloMessage.extensions.add(ece);
+        // Add named groups extension for ECDHE and FFDHE if necessary.
+        SupportedGroupsExtension sge =
+                SupportedGroupsExtension.createExtension(
+                        algorithmConstraints,
+                        cipherSuites, enableFFDHE);
+        if (sge != null) {
+            clientHelloMessage.extensions.add(sge);
+            // Add elliptic point format extensions
+            if (cipherSuites.contains(NamedGroupType.NAMED_GROUP_ECDHE)) {
                 clientHelloMessage.extensions.add(
-                        EllipticPointFormatsExtension.DEFAULT);
+                    EllipticPointFormatsExtension.DEFAULT);
             }
         }
 
--- a/jdk/src/java.base/share/classes/sun/security/ssl/DHCrypt.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/DHCrypt.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,14 +26,8 @@
 
 package sun.security.ssl;
 
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
 import java.math.BigInteger;
 import java.security.*;
-import java.io.IOException;
 import javax.net.ssl.SSLHandshakeException;
 import javax.crypto.SecretKey;
 import javax.crypto.KeyAgreement;
@@ -101,7 +95,7 @@
      */
     DHCrypt(int keyLength, SecureRandom random) {
         this(keyLength,
-                ParametersHolder.definedParams.get(keyLength), random);
+            PredefinedDHParameterSpecs.definedParams.get(keyLength), random);
     }
 
     /**
@@ -116,6 +110,14 @@
     }
 
     /**
+     * Generate a Diffie-Hellman keypair using the named group.
+     */
+    DHCrypt(NamedGroup namedGroup, SecureRandom random) {
+        this(-1,        // The length (-1) is not used in the implementation.
+            SupportedGroupsExtension.getDHParameterSpec(namedGroup), random);
+    }
+
+    /**
      * Generate a Diffie-Hellman keypair using the specified size and
      * parameters.
      */
@@ -272,266 +274,5 @@
 
         return null;
     }
-
-    // lazy initialization holder class idiom for static default parameters
-    //
-    // See Effective Java Second Edition: Item 71.
-    private static class ParametersHolder {
-        private final static boolean debugIsOn =
-                (Debug.getInstance("ssl") != null) && Debug.isOn("sslctx");
-
-        //
-        // Default DH ephemeral parameters
-        //
-        private static final BigInteger p512 = new BigInteger(   // generated
-                "D87780E15FF50B4ABBE89870188B049406B5BEA98AB23A02" +
-                "41D88EA75B7755E669C08093D3F0CA7FC3A5A25CF067DCB9" +
-                "A43DD89D1D90921C6328884461E0B6D3", 16);
-        private static final BigInteger p768 = new BigInteger(   // RFC 2409
-                "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
-                "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
-                "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
-                "E485B576625E7EC6F44C42E9A63A3620FFFFFFFFFFFFFFFF", 16);
+}
 
-        private static final BigInteger p1024 = new BigInteger(  // RFC 2409
-                "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
-                "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
-                "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
-                "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
-                "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381" +
-                "FFFFFFFFFFFFFFFF", 16);
-        private static final BigInteger p1536 = new BigInteger(  // RFC 3526
-                "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
-                "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
-                "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
-                "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
-                "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" +
-                "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" +
-                "83655D23DCA3AD961C62F356208552BB9ED529077096966D" +
-                "670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF", 16);
-        private static final BigInteger p2048 = new BigInteger(  // TLS FFDHE
-                "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
-                "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
-                "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
-                "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
-                "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
-                "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
-                "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
-                "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
-                "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
-                "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
-                "886B423861285C97FFFFFFFFFFFFFFFF", 16);
-        private static final BigInteger p3072 = new BigInteger(  // TLS FFDHE
-                "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
-                "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
-                "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
-                "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
-                "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
-                "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
-                "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
-                "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
-                "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
-                "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
-                "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
-                "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
-                "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
-                "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
-                "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
-                "3C1B20EE3FD59D7C25E41D2B66C62E37FFFFFFFFFFFFFFFF", 16);
-        private static final BigInteger p4096 = new BigInteger(  // TLS FFDHE
-                "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
-                "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
-                "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
-                "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
-                "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
-                "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
-                "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
-                "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
-                "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
-                "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
-                "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
-                "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
-                "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
-                "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
-                "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
-                "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
-                "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
-                "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
-                "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
-                "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
-                "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E655F6A" +
-                "FFFFFFFFFFFFFFFF", 16);
-        private static final BigInteger p6144 = new BigInteger(  // TLS FFDHE
-                "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
-                "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
-                "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
-                "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
-                "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
-                "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
-                "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
-                "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
-                "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
-                "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
-                "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
-                "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
-                "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
-                "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
-                "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
-                "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
-                "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
-                "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
-                "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
-                "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
-                "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD902" +
-                "0BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA6" +
-                "3BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3A" +
-                "CDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477" +
-                "A52471F7A9A96910B855322EDB6340D8A00EF092350511E3" +
-                "0ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4" +
-                "763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6" +
-                "B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538C" +
-                "D72B03746AE77F5E62292C311562A846505DC82DB854338A" +
-                "E49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B04" +
-                "5B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1" +
-                "A41D570D7938DAD4A40E329CD0E40E65FFFFFFFFFFFFFFFF", 16);
-        private static final BigInteger p8192 = new BigInteger(  // TLS FFDHE
-                "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
-                "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
-                "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
-                "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
-                "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
-                "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
-                "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
-                "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
-                "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
-                "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
-                "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
-                "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
-                "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
-                "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
-                "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
-                "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
-                "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
-                "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
-                "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
-                "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
-                "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD902" +
-                "0BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA6" +
-                "3BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3A" +
-                "CDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477" +
-                "A52471F7A9A96910B855322EDB6340D8A00EF092350511E3" +
-                "0ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4" +
-                "763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6" +
-                "B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538C" +
-                "D72B03746AE77F5E62292C311562A846505DC82DB854338A" +
-                "E49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B04" +
-                "5B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1" +
-                "A41D570D7938DAD4A40E329CCFF46AAA36AD004CF600C838" +
-                "1E425A31D951AE64FDB23FCEC9509D43687FEB69EDD1CC5E" +
-                "0B8CC3BDF64B10EF86B63142A3AB8829555B2F747C932665" +
-                "CB2C0F1CC01BD70229388839D2AF05E454504AC78B758282" +
-                "2846C0BA35C35F5C59160CC046FD8251541FC68C9C86B022" +
-                "BB7099876A460E7451A8A93109703FEE1C217E6C3826E52C" +
-                "51AA691E0E423CFC99E9E31650C1217B624816CDAD9A95F9" +
-                "D5B8019488D9C0A0A1FE3075A577E23183F81D4A3F2FA457" +
-                "1EFC8CE0BA8A4FE8B6855DFE72B0A66EDED2FBABFBE58A30" +
-                "FAFABE1C5D71A87E2F741EF8C1FE86FEA6BBFDE530677F0D" +
-                "97D11D49F7A8443D0822E506A9F4614E011E2A94838FF88C" +
-                "D68C8BB7C5C6424CFFFFFFFFFFFFFFFF", 16);
-
-        private static final BigInteger[] supportedPrimes = {
-                p512, p768, p1024, p1536, p2048, p3072, p4096, p6144, p8192};
-
-        // a measure of the uncertainty that prime modulus p is not a prime
-        //
-        // see BigInteger.isProbablePrime(int certainty)
-        private final static int PRIME_CERTAINTY = 120;
-
-        // the known security property, jdk.tls.server.defaultDHEParameters
-        private final static String PROPERTY_NAME =
-                "jdk.tls.server.defaultDHEParameters";
-
-        private static final Pattern spacesPattern = Pattern.compile("\\s+");
-
-        private final static Pattern syntaxPattern = Pattern.compile(
-                "(\\{[0-9A-Fa-f]+,[0-9A-Fa-f]+\\})" +
-                "(,\\{[0-9A-Fa-f]+,[0-9A-Fa-f]+\\})*");
-
-        private static final Pattern paramsPattern = Pattern.compile(
-                "\\{([0-9A-Fa-f]+),([0-9A-Fa-f]+)\\}");
-
-        // cache of predefined default DH ephemeral parameters
-        private final static Map<Integer,DHParameterSpec> definedParams;
-
-        static {
-            String property = AccessController.doPrivileged(
-                new PrivilegedAction<String>() {
-                    public String run() {
-                        return Security.getProperty(PROPERTY_NAME);
-                    }
-                });
-
-            if (property != null && !property.isEmpty()) {
-                // remove double quote marks from beginning/end of the property
-                if (property.length() >= 2 && property.charAt(0) == '"' &&
-                        property.charAt(property.length() - 1) == '"') {
-                    property = property.substring(1, property.length() - 1);
-                }
-
-                property = property.trim();
-            }
-
-            if (property != null && !property.isEmpty()) {
-                Matcher spacesMatcher = spacesPattern.matcher(property);
-                property = spacesMatcher.replaceAll("");
-
-                if (debugIsOn) {
-                    System.out.println("The Security Property " +
-                            PROPERTY_NAME + ": " + property);
-                }
-            }
-
-            Map<Integer,DHParameterSpec> defaultParams = new HashMap<>();
-            if (property != null && !property.isEmpty()) {
-                Matcher syntaxMatcher = syntaxPattern.matcher(property);
-                if (syntaxMatcher.matches()) {
-                    Matcher paramsFinder = paramsPattern.matcher(property);
-                    while(paramsFinder.find()) {
-                        String primeModulus = paramsFinder.group(1);
-                        BigInteger p = new BigInteger(primeModulus, 16);
-                        if (!p.isProbablePrime(PRIME_CERTAINTY)) {
-                            if (debugIsOn) {
-                                System.out.println(
-                                    "Prime modulus p in Security Property, " +
-                                    PROPERTY_NAME + ", is not a prime: " +
-                                    primeModulus);
-                            }
-
-                            continue;
-                        }
-
-                        String baseGenerator = paramsFinder.group(2);
-                        BigInteger g = new BigInteger(baseGenerator, 16);
-
-                        DHParameterSpec spec = new DHParameterSpec(p, g);
-                        int primeLen = p.bitLength();
-                        defaultParams.put(primeLen, spec);
-                    }
-                } else if (debugIsOn) {
-                    System.out.println("Invalid Security Property, " +
-                            PROPERTY_NAME + ", definition");
-                }
-            }
-
-            for (BigInteger p : supportedPrimes) {
-                int primeLen = p.bitLength();
-                defaultParams.putIfAbsent(primeLen,
-                        new DHParameterSpec(p, BigInteger.TWO));
-            }
-
-            definedParams =
-                    Collections.<Integer,DHParameterSpec>unmodifiableMap(
-                                                                defaultParams);
-        }
-    }
-}
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ECDHCrypt.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ECDHCrypt.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,17 +56,17 @@
     }
 
     // Called by ServerHandshaker for ephemeral ECDH
-    ECDHCrypt(int curveId, SecureRandom random) {
+    ECDHCrypt(NamedGroup namedGroup, SecureRandom random) {
         try {
             KeyPairGenerator kpg = JsseJce.getKeyPairGenerator("EC");
             ECGenParameterSpec params =
-                    EllipticCurvesExtension.getECGenParamSpec(curveId);
+                    SupportedGroupsExtension.getECGenParamSpec(namedGroup);
             kpg.initialize(params, random);
             KeyPair kp = kpg.generateKeyPair();
             privateKey = kp.getPrivate();
             publicKey = (ECPublicKey)kp.getPublic();
         } catch (GeneralSecurityException e) {
-            throw new RuntimeException("Could not generate DH keypair", e);
+            throw new RuntimeException("Could not generate ECDH keypair", e);
         }
     }
 
@@ -79,7 +79,7 @@
             privateKey = kp.getPrivate();
             publicKey = (ECPublicKey)kp.getPublic();
         } catch (GeneralSecurityException e) {
-            throw new RuntimeException("Could not generate DH keypair", e);
+            throw new RuntimeException("Could not generate ECDH keypair", e);
         }
     }
 
--- a/jdk/src/java.base/share/classes/sun/security/ssl/EllipticCurvesExtension.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,400 +0,0 @@
-/*
- * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.ssl;
-
-import java.io.IOException;
-import java.security.spec.ECParameterSpec;
-import java.security.spec.ECGenParameterSpec;
-import java.security.spec.InvalidParameterSpecException;
-import java.security.AlgorithmParameters;
-import java.security.AlgorithmConstraints;
-import java.security.CryptoPrimitive;
-import java.security.AccessController;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ArrayList;
-import javax.net.ssl.SSLProtocolException;
-
-import sun.security.action.GetPropertyAction;
-
-final class EllipticCurvesExtension extends HelloExtension {
-
-    /* Class and subclass dynamic debugging support */
-    private static final Debug debug = Debug.getInstance("ssl");
-
-    private static final int ARBITRARY_PRIME = 0xff01;
-    private static final int ARBITRARY_CHAR2 = 0xff02;
-
-    // speed up the searching
-    private static final Map<String, Integer> oidToIdMap = new HashMap<>();
-    private static final Map<Integer, String> idToOidMap = new HashMap<>();
-
-    // speed up the parameters construction
-    private static final Map<Integer,
-                AlgorithmParameters> idToParams = new HashMap<>();
-
-    // the supported elliptic curves
-    private static final int[] supportedCurveIds;
-
-    // the curves of the extension
-    private final int[] curveIds;
-
-    // See sun.security.util.CurveDB for the OIDs
-    private static enum NamedEllipticCurve {
-        T163_K1(1,  "sect163k1",    "1.3.132.0.1",      true),  // NIST K-163
-        T163_R1(2,  "sect163r1",    "1.3.132.0.2",      false),
-        T163_R2(3,  "sect163r2",    "1.3.132.0.15",     true),  // NIST B-163
-        T193_R1(4,  "sect193r1",    "1.3.132.0.24",     false),
-        T193_R2(5,  "sect193r2",    "1.3.132.0.25",     false),
-        T233_K1(6,  "sect233k1",    "1.3.132.0.26",     true),  // NIST K-233
-        T233_R1(7,  "sect233r1",    "1.3.132.0.27",     true),  // NIST B-233
-        T239_K1(8,  "sect239k1",    "1.3.132.0.3",      false),
-        T283_K1(9,  "sect283k1",    "1.3.132.0.16",     true),  // NIST K-283
-        T283_R1(10, "sect283r1",    "1.3.132.0.17",     true),  // NIST B-283
-        T409_K1(11, "sect409k1",    "1.3.132.0.36",     true),  // NIST K-409
-        T409_R1(12, "sect409r1",    "1.3.132.0.37",     true),  // NIST B-409
-        T571_K1(13, "sect571k1",    "1.3.132.0.38",     true),  // NIST K-571
-        T571_R1(14, "sect571r1",    "1.3.132.0.39",     true),  // NIST B-571
-
-        P160_K1(15, "secp160k1",    "1.3.132.0.9",      false),
-        P160_R1(16, "secp160r1",    "1.3.132.0.8",      false),
-        P160_R2(17, "secp160r2",    "1.3.132.0.30",     false),
-        P192_K1(18, "secp192k1",    "1.3.132.0.31",     false),
-        P192_R1(19, "secp192r1",    "1.2.840.10045.3.1.1", true), // NIST P-192
-        P224_K1(20, "secp224k1",    "1.3.132.0.32",     false),
-        P224_R1(21, "secp224r1",    "1.3.132.0.33",     true),  // NIST P-224
-        P256_K1(22, "secp256k1",    "1.3.132.0.10",     false),
-        P256_R1(23, "secp256r1",    "1.2.840.10045.3.1.7", true), // NIST P-256
-        P384_R1(24, "secp384r1",    "1.3.132.0.34",     true),  // NIST P-384
-        P521_R1(25, "secp521r1",    "1.3.132.0.35",     true);  // NIST P-521
-
-        int          id;
-        String       name;
-        String       oid;
-        boolean      isFips;
-
-        NamedEllipticCurve(int id, String name, String oid, boolean isFips) {
-            this.id = id;
-            this.name = name;
-            this.oid = oid;
-            this.isFips = isFips;
-
-            if (oidToIdMap.put(oid, id) != null ||
-                idToOidMap.put(id, oid) != null) {
-
-                throw new RuntimeException(
-                        "Duplicate named elliptic curve definition: " + name);
-            }
-        }
-
-        static NamedEllipticCurve getCurve(String name, boolean requireFips) {
-            for (NamedEllipticCurve curve : NamedEllipticCurve.values()) {
-                if (curve.name.equals(name) && (!requireFips || curve.isFips)) {
-                    return curve;
-                }
-            }
-
-            return null;
-        }
-    }
-
-    static {
-        boolean requireFips = SunJSSE.isFIPS();
-
-        // hack code to initialize NamedEllipticCurve
-        NamedEllipticCurve nec =
-                NamedEllipticCurve.getCurve("secp256r1", false);
-
-        // The value of the System Property defines a list of enabled named
-        // curves in preference order, separated with comma.  For example:
-        //
-        //      jdk.tls.namedGroups="secp521r1, secp256r1, secp384r1"
-        //
-        // If the System Property is not defined or the value is empty, the
-        // default curves and preferences will be used.
-        String property = AccessController.doPrivileged(
-                    new GetPropertyAction("jdk.tls.namedGroups"));
-        if (property != null && property.length() != 0) {
-            // remove double quote marks from beginning/end of the property
-            if (property.length() > 1 && property.charAt(0) == '"' &&
-                    property.charAt(property.length() - 1) == '"') {
-                property = property.substring(1, property.length() - 1);
-            }
-        }
-
-        ArrayList<Integer> idList;
-        if (property != null && property.length() != 0) {   // customized curves
-            String[] curves = property.split(",");
-            idList = new ArrayList<>(curves.length);
-            for (String curve : curves) {
-                curve = curve.trim();
-                if (!curve.isEmpty()) {
-                    NamedEllipticCurve namedCurve =
-                            NamedEllipticCurve.getCurve(curve, requireFips);
-                    if (namedCurve != null) {
-                        if (isAvailableCurve(namedCurve.id)) {
-                            idList.add(namedCurve.id);
-                        }
-                    }   // ignore unknown curves
-                }
-            }
-            if (idList.isEmpty() && JsseJce.isEcAvailable()) {
-                throw new IllegalArgumentException(
-                    "System property jdk.tls.namedGroups(" + property + ") " +
-                    "contains no supported elliptic curves");
-            }
-        } else {        // default curves
-            int[] ids;
-            if (requireFips) {
-                ids = new int[] {
-                    // only NIST curves in FIPS mode
-                    23, 24, 25, 9, 10, 11, 12, 13, 14,
-                };
-            } else {
-                ids = new int[] {
-                    // NIST curves first
-                    23, 24, 25, 9, 10, 11, 12, 13, 14,
-                    // non-NIST curves
-                    22,
-                };
-            }
-
-            idList = new ArrayList<>(ids.length);
-            for (int curveId : ids) {
-                if (isAvailableCurve(curveId)) {
-                    idList.add(curveId);
-                }
-            }
-        }
-
-        if (debug != null && idList.isEmpty()) {
-            Debug.log(
-                "Initialized [jdk.tls.namedGroups|default] list contains " +
-                "no available elliptic curves. " +
-                (property != null ? "(" + property + ")" : "[Default]"));
-        }
-
-        supportedCurveIds = new int[idList.size()];
-        int i = 0;
-        for (Integer id : idList) {
-            supportedCurveIds[i++] = id;
-        }
-    }
-
-    // check whether the curve is supported by the underlying providers
-    private static boolean isAvailableCurve(int curveId) {
-        String oid = idToOidMap.get(curveId);
-        if (oid != null) {
-            AlgorithmParameters params = null;
-            try {
-                params = JsseJce.getAlgorithmParameters("EC");
-                params.init(new ECGenParameterSpec(oid));
-            } catch (Exception e) {
-                return false;
-            }
-
-            // cache the parameters
-            idToParams.put(curveId, params);
-
-            return true;
-        }
-
-        return false;
-    }
-
-    private EllipticCurvesExtension(int[] curveIds) {
-        super(ExtensionType.EXT_ELLIPTIC_CURVES);
-
-        this.curveIds = curveIds;
-    }
-
-    EllipticCurvesExtension(HandshakeInStream s, int len)
-            throws IOException {
-        super(ExtensionType.EXT_ELLIPTIC_CURVES);
-
-        int k = s.getInt16();
-        if (((len & 1) != 0) || (k + 2 != len)) {
-            throw new SSLProtocolException("Invalid " + type + " extension");
-        }
-
-        // Note: unknown curves will be ignored later.
-        curveIds = new int[k >> 1];
-        for (int i = 0; i < curveIds.length; i++) {
-            curveIds[i] = s.getInt16();
-        }
-    }
-
-    // get the preferred active curve
-    static int getActiveCurves(AlgorithmConstraints constraints) {
-        return getPreferredCurve(supportedCurveIds, constraints);
-    }
-
-    static boolean hasActiveCurves(AlgorithmConstraints constraints) {
-        return getActiveCurves(constraints) >= 0;
-    }
-
-    static EllipticCurvesExtension createExtension(
-                AlgorithmConstraints constraints) {
-
-        ArrayList<Integer> idList = new ArrayList<>(supportedCurveIds.length);
-        for (int curveId : supportedCurveIds) {
-            if (constraints.permits(
-                    EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
-                                "EC", idToParams.get(curveId))) {
-                idList.add(curveId);
-            }
-        }
-
-        if (!idList.isEmpty()) {
-            int[] ids = new int[idList.size()];
-            int i = 0;
-            for (Integer id : idList) {
-                ids[i++] = id;
-            }
-
-            return new EllipticCurvesExtension(ids);
-        }
-
-        return null;
-    }
-
-    // get the preferred activated curve
-    int getPreferredCurve(AlgorithmConstraints constraints) {
-        return getPreferredCurve(curveIds, constraints);
-    }
-
-    // get a preferred activated curve
-    private static int getPreferredCurve(int[] curves,
-                AlgorithmConstraints constraints) {
-        for (int curveId : curves) {
-            if (isSupported(curveId) && constraints.permits(
-                    EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
-                                "EC", idToParams.get(curveId))) {
-                return curveId;
-            }
-        }
-
-        return -1;
-    }
-
-    boolean contains(int index) {
-        for (int curveId : curveIds) {
-            if (index == curveId) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    @Override
-    int length() {
-        return 6 + (curveIds.length << 1);
-    }
-
-    @Override
-    void send(HandshakeOutStream s) throws IOException {
-        s.putInt16(type.id);
-        int k = curveIds.length << 1;
-        s.putInt16(k + 2);
-        s.putInt16(k);
-        for (int curveId : curveIds) {
-            s.putInt16(curveId);
-        }
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append("Extension " + type + ", curve names: {");
-        boolean first = true;
-        for (int curveId : curveIds) {
-            if (first) {
-                first = false;
-            } else {
-                sb.append(", ");
-            }
-            // first check if it is a known named curve, then try other cases.
-            String curveName = getCurveName(curveId);
-            if (curveName != null) {
-                sb.append(curveName);
-            } else if (curveId == ARBITRARY_PRIME) {
-                sb.append("arbitrary_explicit_prime_curves");
-            } else if (curveId == ARBITRARY_CHAR2) {
-                sb.append("arbitrary_explicit_char2_curves");
-            } else {
-                sb.append("unknown curve " + curveId);
-            }
-        }
-        sb.append("}");
-        return sb.toString();
-    }
-
-    // Test whether the given curve is supported.
-    static boolean isSupported(int index) {
-        for (int curveId : supportedCurveIds) {
-            if (index == curveId) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    static int getCurveIndex(ECParameterSpec params) {
-        String oid = JsseJce.getNamedCurveOid(params);
-        if (oid == null) {
-            return -1;
-        }
-        Integer n = oidToIdMap.get(oid);
-        return (n == null) ? -1 : n;
-    }
-
-    static String getCurveOid(int index) {
-        return idToOidMap.get(index);
-    }
-
-    static ECGenParameterSpec getECGenParamSpec(int index) {
-        AlgorithmParameters params = idToParams.get(index);
-        try {
-            return params.getParameterSpec(ECGenParameterSpec.class);
-        } catch (InvalidParameterSpecException ipse) {
-            // should be unlikely
-            String curveOid = getCurveOid(index);
-            return new ECGenParameterSpec(curveOid);
-        }
-    }
-
-    private static String getCurveName(int index) {
-        for (NamedEllipticCurve namedCurve : NamedEllipticCurve.values()) {
-            if (namedCurve.id == index) {
-                return namedCurve.name;
-            }
-        }
-
-        return null;
-    }
-}
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ExtensionType.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ExtensionType.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -82,9 +82,9 @@
     static final ExtensionType EXT_CERT_TYPE =
             e(0x0009, "cert_type");              // IANA registry value: 9
 
-    // extensions defined in RFC 4492 (ECC)
-    static final ExtensionType EXT_ELLIPTIC_CURVES =
-            e(0x000A, "elliptic_curves");        // IANA registry value: 10
+    // extensions defined in RFC 4492 (ECC) and RFC 7919 (FFDHE)
+    static final ExtensionType EXT_SUPPORTED_GROUPS =
+            e(0x000A, "supported_groups");       // IANA registry value: 10
     static final ExtensionType EXT_EC_POINT_FORMATS =
             e(0x000B, "ec_point_formats");       // IANA registry value: 11
 
--- a/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1369,8 +1369,9 @@
     private static final int CURVE_EXPLICIT_CHAR2 = 2;
     private static final int CURVE_NAMED_CURVE    = 3;
 
-    // id of the curve we are using
-    private int curveId;
+    // id of the named group we are using
+    private int groupId;
+
     // encoded public point
     private byte[] pointBytes;
 
@@ -1389,7 +1390,8 @@
     ECDH_ServerKeyExchange(ECDHCrypt obj, PrivateKey privateKey,
             byte[] clntNonce, byte[] svrNonce, SecureRandom sr,
             SignatureAndHashAlgorithm signAlgorithm,
-            ProtocolVersion protocolVersion) throws GeneralSecurityException {
+            ProtocolVersion protocolVersion)
+            throws SSLHandshakeException, GeneralSecurityException {
 
         this.protocolVersion = protocolVersion;
 
@@ -1397,7 +1399,14 @@
         ECParameterSpec params = publicKey.getParams();
         ECPoint point = publicKey.getW();
         pointBytes = JsseJce.encodePoint(point, params.getCurve());
-        curveId = EllipticCurvesExtension.getCurveIndex(params);
+
+        NamedGroup namedGroup = NamedGroup.valueOf(params);
+        if ((namedGroup == null) || (namedGroup.oid == null) ){
+            // unlikely
+            throw new SSLHandshakeException(
+                "Unnamed EC parameter spec: " + params);
+        }
+        groupId = namedGroup.id;
 
         if (privateKey == null) {
             // ECDH_anon
@@ -1434,20 +1443,27 @@
         // These parsing errors should never occur as we negotiated
         // the supported curves during the exchange of the Hello messages.
         if (curveType == CURVE_NAMED_CURVE) {
-            curveId = input.getInt16();
-            if (!EllipticCurvesExtension.isSupported(curveId)) {
+            groupId = input.getInt16();
+            NamedGroup namedGroup = NamedGroup.valueOf(groupId);
+            if (namedGroup == null) {
                 throw new SSLHandshakeException(
-                    "Unsupported curveId: " + curveId);
+                    "Unknown named group ID: " + groupId);
             }
-            String curveOid = EllipticCurvesExtension.getCurveOid(curveId);
-            if (curveOid == null) {
+
+            if (!SupportedGroupsExtension.supports(namedGroup)) {
                 throw new SSLHandshakeException(
-                    "Unknown named curve: " + curveId);
+                    "Unsupported named group: " + namedGroup);
             }
-            parameters = JsseJce.getECParameterSpec(curveOid);
+
+            if (namedGroup.oid == null) {
+                throw new SSLHandshakeException(
+                    "Unknown named EC curve: " + namedGroup);
+            }
+
+            parameters = JsseJce.getECParameterSpec(namedGroup.oid);
             if (parameters == null) {
                 throw new SSLHandshakeException(
-                    "Unsupported curve: " + curveOid);
+                    "No supported EC parameter for named group: " + namedGroup);
             }
         } else {
             throw new SSLHandshakeException(
@@ -1530,8 +1546,8 @@
         sig.update(svrNonce);
 
         sig.update((byte)CURVE_NAMED_CURVE);
-        sig.update((byte)(curveId >> 8));
-        sig.update((byte)curveId);
+        sig.update((byte)(groupId >> 8));
+        sig.update((byte)groupId);
         sig.update((byte)pointBytes.length);
         sig.update(pointBytes);
     }
@@ -1552,7 +1568,7 @@
     @Override
     void send(HandshakeOutStream s) throws IOException {
         s.putInt8(CURVE_NAMED_CURVE);
-        s.putInt16(curveId);
+        s.putInt16(groupId);
         s.putBytes8(pointBytes);
 
         if (signatureBytes != null) {
--- a/jdk/src/java.base/share/classes/sun/security/ssl/Handshaker.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/Handshaker.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,6 +52,7 @@
 
 import static sun.security.ssl.CipherSuite.PRF.*;
 import static sun.security.ssl.CipherSuite.CipherType.*;
+import static sun.security.ssl.NamedGroupType.*;
 
 /**
  * Handshaker ... processes handshake records from an SSL V3.0
@@ -685,42 +686,14 @@
             ArrayList<CipherSuite> suites = new ArrayList<>();
             if (!(activeProtocols.collection().isEmpty()) &&
                     activeProtocols.min.v != ProtocolVersion.NONE.v) {
-                boolean checkedCurves = false;
-                boolean hasCurves = false;
+                Map<NamedGroupType, Boolean> cachedStatus =
+                        new EnumMap<>(NamedGroupType.class);
                 for (CipherSuite suite : enabledCipherSuites.collection()) {
-                    if (!activeProtocols.min.obsoletes(suite) &&
+                    if (suite.isAvailable() &&
+                            (!activeProtocols.min.obsoletes(suite)) &&
                             activeProtocols.max.supports(suite)) {
-                        if (algorithmConstraints.permits(
-                                EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
-                                suite.name, null)) {
-
-                            boolean available = true;
-                            if (suite.keyExchange.isEC) {
-                                if (!checkedCurves) {
-                                    hasCurves = EllipticCurvesExtension
-                                        .hasActiveCurves(algorithmConstraints);
-                                    checkedCurves = true;
-
-                                    if (!hasCurves && debug != null &&
-                                                Debug.isOn("verbose")) {
-                                        System.out.println(
-                                            "No available elliptic curves");
-                                    }
-                                }
-
-                                available = hasCurves;
-
-                                if (!available && debug != null &&
-                                        Debug.isOn("verbose")) {
-                                    System.out.println(
-                                        "No active elliptic curves, ignore " +
-                                        suite);
-                                }
-                            }
-
-                            if (available) {
-                                suites.add(suite);
-                            }
+                        if (isActivatable(suite, cachedStatus)) {
+                            suites.add(suite);
                         }
                     } else if (debug != null && Debug.isOn("verbose")) {
                         if (activeProtocols.min.obsoletes(suite)) {
@@ -779,46 +752,15 @@
                 }
 
                 boolean found = false;
+                Map<NamedGroupType, Boolean> cachedStatus =
+                        new EnumMap<>(NamedGroupType.class);
                 for (CipherSuite suite : enabledCipherSuites.collection()) {
                     if (suite.isAvailable() && (!protocol.obsoletes(suite)) &&
                                                protocol.supports(suite)) {
-                        if (algorithmConstraints.permits(
-                                EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
-                                suite.name, null)) {
-
-                            boolean available = true;
-                            if (suite.keyExchange.isEC) {
-                                if (!checkedCurves) {
-                                    hasCurves = EllipticCurvesExtension
-                                        .hasActiveCurves(algorithmConstraints);
-                                    checkedCurves = true;
-
-                                    if (!hasCurves && debug != null &&
-                                                Debug.isOn("verbose")) {
-                                        System.out.println(
-                                            "No activated elliptic curves");
-                                    }
-                                }
-
-                                available = hasCurves;
-
-                                if (!available && debug != null &&
-                                        Debug.isOn("verbose")) {
-                                    System.out.println(
-                                        "No active elliptic curves, ignore " +
-                                        suite + " for " + protocol);
-                                }
-                            }
-
-                            if (available) {
-                                protocols.add(protocol);
-                                found = true;
-                                break;
-                            }
-                        } else if (debug != null && Debug.isOn("verbose")) {
-                            System.out.println(
-                                "Ignoring disabled cipher suite: " + suite +
-                                 " for " + protocol);
+                        if (isActivatable(suite, cachedStatus)) {
+                            protocols.add(protocol);
+                            found = true;
+                            break;
                         }
                     } else if (debug != null && Debug.isOn("verbose")) {
                         System.out.println(
@@ -826,6 +768,7 @@
                                  " for " + protocol);
                     }
                 }
+
                 if (!found && (debug != null) && Debug.isOn("handshake")) {
                     System.out.println(
                         "No available cipher suite for " + protocol);
@@ -842,6 +785,43 @@
         return activeProtocols;
     }
 
+    private boolean isActivatable(CipherSuite suite,
+            Map<NamedGroupType, Boolean> cachedStatus) {
+
+        if (algorithmConstraints.permits(
+                EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), suite.name, null)) {
+            boolean available = true;
+            NamedGroupType groupType = suite.keyExchange.groupType;
+            if (groupType != NAMED_GROUP_NONE) {
+                Boolean checkedStatus = cachedStatus.get(groupType);
+                if (checkedStatus == null) {
+                    available = SupportedGroupsExtension.isActivatable(
+                            algorithmConstraints, groupType);
+                    cachedStatus.put(groupType, available);
+
+                    if (!available && debug != null && Debug.isOn("verbose")) {
+                        System.out.println("No activated named group");
+                    }
+                } else {
+                    available = checkedStatus.booleanValue();
+                }
+
+                if (!available && debug != null && Debug.isOn("verbose")) {
+                    System.out.println(
+                        "No active named group, ignore " + suite);
+                }
+
+                return available;
+            } else {
+                return true;
+            }
+        } else if (debug != null && Debug.isOn("verbose")) {
+            System.out.println("Ignoring disabled cipher suite: " + suite);
+        }
+
+        return false;
+    }
+
     /**
      * As long as handshaking has not activated, we can
      * change whether session creations are allowed.
--- a/jdk/src/java.base/share/classes/sun/security/ssl/HelloExtensions.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/HelloExtensions.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,7 +49,7 @@
  *      explicitly support.
  *  . ServerNameExtension: the server_name extension.
  *  . SignatureAlgorithmsExtension: the signature_algorithms extension.
- *  . EllipticCurvesExtension: the ECC supported curves extension.
+ *  . SupportedGroupsExtension: the supported groups extension.
  *  . EllipticPointFormatsExtension: the ECC supported point formats
  *      (compressed/uncompressed) extension.
  *  . ALPNExtension: the application_layer_protocol_negotiation extension.
@@ -79,8 +79,8 @@
                 extension = new ServerNameExtension(s, extlen);
             } else if (extType == ExtensionType.EXT_SIGNATURE_ALGORITHMS) {
                 extension = new SignatureAlgorithmsExtension(s, extlen);
-            } else if (extType == ExtensionType.EXT_ELLIPTIC_CURVES) {
-                extension = new EllipticCurvesExtension(s, extlen);
+            } else if (extType == ExtensionType.EXT_SUPPORTED_GROUPS) {
+                extension = new SupportedGroupsExtension(s, extlen);
             } else if (extType == ExtensionType.EXT_EC_POINT_FORMATS) {
                 extension = new EllipticPointFormatsExtension(s, extlen);
             } else if (extType == ExtensionType.EXT_RENEGOTIATION_INFO) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/NamedGroup.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.ssl;
+
+import java.security.spec.ECParameterSpec;
+import java.security.spec.ECGenParameterSpec;
+import static sun.security.ssl.NamedGroupType.*;
+
+enum NamedGroup {
+    // Elliptic Curves (RFC 4492)
+    //
+    // See sun.security.util.CurveDB for the OIDs
+
+    // NIST K-163
+    SECT163_K1(1, NAMED_GROUP_ECDHE, "sect163k1", "1.3.132.0.1", true),
+
+    SECT163_R1(2, NAMED_GROUP_ECDHE, "sect163r1", "1.3.132.0.2", false),
+
+    // NIST B-163
+    SECT163_R2(3, NAMED_GROUP_ECDHE, "sect163r2", "1.3.132.0.15", true),
+
+    SECT193_R1(4, NAMED_GROUP_ECDHE, "sect193r1", "1.3.132.0.24", false),
+    SECT193_R2(5, NAMED_GROUP_ECDHE, "sect193r2", "1.3.132.0.25", false),
+
+    // NIST K-233
+    SECT233_K1(6, NAMED_GROUP_ECDHE, "sect233k1", "1.3.132.0.26", true),
+
+    // NIST B-233
+    SECT233_R1(7, NAMED_GROUP_ECDHE, "sect233r1", "1.3.132.0.27", true),
+
+    SECT239_K1(8, NAMED_GROUP_ECDHE, "sect239k1", "1.3.132.0.3", false),
+
+    // NIST K-283
+    SECT283_K1(9, NAMED_GROUP_ECDHE, "sect283k1", "1.3.132.0.16", true),
+
+    // NIST B-283
+    SECT283_R1(10, NAMED_GROUP_ECDHE, "sect283r1", "1.3.132.0.17", true),
+
+    // NIST K-409
+    SECT409_K1(11, NAMED_GROUP_ECDHE, "sect409k1", "1.3.132.0.36", true),
+
+    // NIST B-409
+    SECT409_R1(12, NAMED_GROUP_ECDHE, "sect409r1", "1.3.132.0.37", true),
+
+    // NIST K-571
+    SECT571_K1(13, NAMED_GROUP_ECDHE, "sect571k1", "1.3.132.0.38", true),
+
+    // NIST B-571
+    SECT571_R1(14, NAMED_GROUP_ECDHE, "sect571r1", "1.3.132.0.39", true),
+
+    SECP160_K1(15, NAMED_GROUP_ECDHE, "secp160k1", "1.3.132.0.9", false),
+    SECP160_R1(16, NAMED_GROUP_ECDHE, "secp160r1", "1.3.132.0.8", false),
+    SECP160_R2(17, NAMED_GROUP_ECDHE, "secp160r2", "1.3.132.0.30", false),
+    SECP192_K1(18, NAMED_GROUP_ECDHE, "secp192k1", "1.3.132.0.31", false),
+
+    // NIST P-192
+    SECP192_R1(19, NAMED_GROUP_ECDHE, "secp192r1", "1.2.840.10045.3.1.1", true),
+
+    SECP224_K1(20, NAMED_GROUP_ECDHE, "secp224k1", "1.3.132.0.32", false),
+    // NIST P-224
+    SECP224_R1(21, NAMED_GROUP_ECDHE, "secp224r1", "1.3.132.0.33", true),
+
+    SECP256_K1(22, NAMED_GROUP_ECDHE, "secp256k1", "1.3.132.0.10", false),
+
+    // NIST P-256
+    SECP256_R1(23, NAMED_GROUP_ECDHE, "secp256r1", "1.2.840.10045.3.1.7", true),
+
+    // NIST P-384
+    SECP384_R1(24, NAMED_GROUP_ECDHE, "secp384r1", "1.3.132.0.34", true),
+
+    // NIST P-521
+    SECP521_R1(25, NAMED_GROUP_ECDHE, "secp521r1", "1.3.132.0.35", true),
+
+    // Finite Field Diffie-Hellman Ephemeral Parameters (RFC 7919)
+    FFDHE_2048(256, NAMED_GROUP_FFDHE, "ffdhe2048",  true),
+    FFDHE_3072(257, NAMED_GROUP_FFDHE, "ffdhe3072",  true),
+    FFDHE_4096(258, NAMED_GROUP_FFDHE, "ffdhe4096",  true),
+    FFDHE_6144(259, NAMED_GROUP_FFDHE, "ffdhe6144",  true),
+    FFDHE_8192(260, NAMED_GROUP_FFDHE, "ffdhe8192",  true);
+
+    int             id;
+    NamedGroupType  type;
+    String          name;
+    String          oid;
+    String          algorithm;
+    boolean         isFips;
+
+    // Constructor used for Elliptic Curve Groups (ECDHE)
+    NamedGroup(int id, NamedGroupType type,
+                String name, String oid, boolean isFips) {
+        this.id = id;
+        this.type = type;
+        this.name = name;
+        this.oid = oid;
+        this.algorithm = "EC";
+        this.isFips = isFips;
+    }
+
+    // Constructor used for Finite Field Diffie-Hellman Groups (FFDHE)
+    NamedGroup(int id, NamedGroupType type, String name, boolean isFips) {
+        this.id = id;
+        this.type = type;
+        this.name = name;
+        this.oid = null;
+        this.algorithm = "DiffieHellman";
+        this.isFips = isFips;
+    }
+
+    static NamedGroup valueOf(int id) {
+        for (NamedGroup group : NamedGroup.values()) {
+            if (group.id == id) {
+                return group;
+            }
+        }
+
+        return null;
+    }
+
+    static NamedGroup nameOf(String name) {
+        for (NamedGroup group : NamedGroup.values()) {
+            if (group.name.equals(name)) {
+                return group;
+            }
+        }
+
+        return null;
+    }
+
+    static NamedGroup valueOf(ECParameterSpec params) {
+        String oid = JsseJce.getNamedCurveOid(params);
+        if ((oid != null) && (!oid.isEmpty())) {
+            for (NamedGroup group : NamedGroup.values()) {
+                if (oid.equals(group.oid)) {
+                    return group;
+                }
+            }
+        }
+
+        return null;
+    }
+
+    @Override
+    public String toString() {
+        return this.name;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/NamedGroupType.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.ssl;
+
+enum NamedGroupType {
+    NAMED_GROUP_ECDHE,          // Elliptic Curve Groups (ECDHE)
+    NAMED_GROUP_FFDHE,          // Finite Field Groups (DHE)
+    NAMED_GROUP_NONE            // No predefined named group
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/PredefinedDHParameterSpecs.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,314 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.ssl;
+
+import java.security.*;
+import java.math.BigInteger;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+import javax.crypto.spec.DHParameterSpec;
+
+/**
+ * Predefined default DH ephemeral parameters.
+ */
+final class PredefinedDHParameterSpecs {
+    private final static boolean debugIsOn =
+            (Debug.getInstance("ssl") != null) && Debug.isOn("sslctx");
+
+    //
+    // Default DH ephemeral parameters
+    //
+    private static final BigInteger p512 = new BigInteger(       // generated
+            "D87780E15FF50B4ABBE89870188B049406B5BEA98AB23A02" +
+            "41D88EA75B7755E669C08093D3F0CA7FC3A5A25CF067DCB9" +
+            "A43DD89D1D90921C6328884461E0B6D3", 16);
+    private static final BigInteger p768 = new BigInteger(       // RFC 2409
+            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+            "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+            "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+            "E485B576625E7EC6F44C42E9A63A3620FFFFFFFFFFFFFFFF", 16);
+
+    private static final BigInteger p1024 = new BigInteger(      // RFC 2409
+            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+            "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+            "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+            "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
+            "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381" +
+            "FFFFFFFFFFFFFFFF", 16);
+    private static final BigInteger p1536 = new BigInteger(      // RFC 3526
+            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+            "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+            "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+            "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
+            "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" +
+            "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" +
+            "83655D23DCA3AD961C62F356208552BB9ED529077096966D" +
+            "670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF", 16);
+    private static final BigInteger p2048 = new BigInteger(      // TLS FFDHE
+            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+            "886B423861285C97FFFFFFFFFFFFFFFF", 16);
+    private static final BigInteger p3072 = new BigInteger(      // TLS FFDHE
+            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+            "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
+            "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
+            "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
+            "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
+            "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
+            "3C1B20EE3FD59D7C25E41D2B66C62E37FFFFFFFFFFFFFFFF", 16);
+    private static final BigInteger p4096 = new BigInteger(      // TLS FFDHE
+            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+            "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
+            "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
+            "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
+            "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
+            "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
+            "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
+            "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
+            "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
+            "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
+            "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
+            "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E655F6A" +
+            "FFFFFFFFFFFFFFFF", 16);
+    private static final BigInteger p6144 = new BigInteger(      // TLS FFDHE
+            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+            "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
+            "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
+            "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
+            "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
+            "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
+            "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
+            "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
+            "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
+            "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
+            "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
+            "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD902" +
+            "0BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA6" +
+            "3BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3A" +
+            "CDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477" +
+            "A52471F7A9A96910B855322EDB6340D8A00EF092350511E3" +
+            "0ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4" +
+            "763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6" +
+            "B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538C" +
+            "D72B03746AE77F5E62292C311562A846505DC82DB854338A" +
+            "E49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B04" +
+            "5B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1" +
+            "A41D570D7938DAD4A40E329CD0E40E65FFFFFFFFFFFFFFFF", 16);
+    private static final BigInteger p8192 = new BigInteger(      // TLS FFDHE
+            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+            "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
+            "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
+            "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
+            "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
+            "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
+            "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
+            "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
+            "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
+            "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
+            "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
+            "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD902" +
+            "0BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA6" +
+            "3BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3A" +
+            "CDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477" +
+            "A52471F7A9A96910B855322EDB6340D8A00EF092350511E3" +
+            "0ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4" +
+            "763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6" +
+            "B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538C" +
+            "D72B03746AE77F5E62292C311562A846505DC82DB854338A" +
+            "E49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B04" +
+            "5B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1" +
+            "A41D570D7938DAD4A40E329CCFF46AAA36AD004CF600C838" +
+            "1E425A31D951AE64FDB23FCEC9509D43687FEB69EDD1CC5E" +
+            "0B8CC3BDF64B10EF86B63142A3AB8829555B2F747C932665" +
+            "CB2C0F1CC01BD70229388839D2AF05E454504AC78B758282" +
+            "2846C0BA35C35F5C59160CC046FD8251541FC68C9C86B022" +
+            "BB7099876A460E7451A8A93109703FEE1C217E6C3826E52C" +
+            "51AA691E0E423CFC99E9E31650C1217B624816CDAD9A95F9" +
+            "D5B8019488D9C0A0A1FE3075A577E23183F81D4A3F2FA457" +
+            "1EFC8CE0BA8A4FE8B6855DFE72B0A66EDED2FBABFBE58A30" +
+            "FAFABE1C5D71A87E2F741EF8C1FE86FEA6BBFDE530677F0D" +
+            "97D11D49F7A8443D0822E506A9F4614E011E2A94838FF88C" +
+            "D68C8BB7C5C6424CFFFFFFFFFFFFFFFF", 16);
+
+    private static final BigInteger[] supportedPrimes = {
+            p512, p768, p1024, p1536, p2048, p3072, p4096, p6144, p8192};
+
+    private static final BigInteger[] ffdhePrimes = {
+            p2048, p3072, p4096, p6144, p8192};
+
+    // a measure of the uncertainty that prime modulus p is not a prime
+    //
+    // see BigInteger.isProbablePrime(int certainty)
+    private final static int PRIME_CERTAINTY = 120;
+
+    // the known security property, jdk.tls.server.defaultDHEParameters
+    private final static String PROPERTY_NAME =
+            "jdk.tls.server.defaultDHEParameters";
+
+    private static final Pattern spacesPattern = Pattern.compile("\\s+");
+
+    private final static Pattern syntaxPattern = Pattern.compile(
+            "(\\{[0-9A-Fa-f]+,[0-9A-Fa-f]+\\})" +
+            "(,\\{[0-9A-Fa-f]+,[0-9A-Fa-f]+\\})*");
+
+    private static final Pattern paramsPattern = Pattern.compile(
+            "\\{([0-9A-Fa-f]+),([0-9A-Fa-f]+)\\}");
+
+    // cache of predefined default DH ephemeral parameters
+    final static Map<Integer, DHParameterSpec> definedParams;
+
+    // cache of Finite Field DH Ephemeral parameters (RFC 7919/FFDHE)
+    final static Map<Integer, DHParameterSpec> ffdheParams;
+
+    static {
+        String property = AccessController.doPrivileged(
+            new PrivilegedAction<String>() {
+                public String run() {
+                    return Security.getProperty(PROPERTY_NAME);
+                }
+            });
+
+        if (property != null && !property.isEmpty()) {
+            // remove double quote marks from beginning/end of the property
+            if (property.length() >= 2 && property.charAt(0) == '"' &&
+                    property.charAt(property.length() - 1) == '"') {
+                property = property.substring(1, property.length() - 1);
+            }
+
+            property = property.trim();
+        }
+
+        if (property != null && !property.isEmpty()) {
+            Matcher spacesMatcher = spacesPattern.matcher(property);
+            property = spacesMatcher.replaceAll("");
+
+            if (debugIsOn) {
+                System.out.println("The Security Property " +
+                        PROPERTY_NAME + ": " + property);
+            }
+        }
+
+        Map<Integer,DHParameterSpec> defaultParams = new HashMap<>();
+        if (property != null && !property.isEmpty()) {
+            Matcher syntaxMatcher = syntaxPattern.matcher(property);
+            if (syntaxMatcher.matches()) {
+                Matcher paramsFinder = paramsPattern.matcher(property);
+                while(paramsFinder.find()) {
+                    String primeModulus = paramsFinder.group(1);
+                    BigInteger p = new BigInteger(primeModulus, 16);
+                    if (!p.isProbablePrime(PRIME_CERTAINTY)) {
+                        if (debugIsOn) {
+                            System.out.println(
+                                "Prime modulus p in Security Property, " +
+                                PROPERTY_NAME + ", is not a prime: " +
+                                primeModulus);
+                        }
+
+                        continue;
+                    }
+
+                    String baseGenerator = paramsFinder.group(2);
+                    BigInteger g = new BigInteger(baseGenerator, 16);
+
+                    DHParameterSpec spec = new DHParameterSpec(p, g);
+                    int primeLen = p.bitLength();
+                    defaultParams.put(primeLen, spec);
+                }
+            } else if (debugIsOn) {
+                System.out.println("Invalid Security Property, " +
+                        PROPERTY_NAME + ", definition");
+            }
+        }
+
+        Map<Integer,DHParameterSpec> tempFFDHEs = new HashMap<>();
+        for (BigInteger p : ffdhePrimes) {
+            int primeLen = p.bitLength();
+            DHParameterSpec dhps = new DHParameterSpec(p, BigInteger.TWO);
+            tempFFDHEs.put(primeLen, dhps);
+            defaultParams.putIfAbsent(primeLen, dhps);
+        }
+
+        for (BigInteger p : supportedPrimes) {
+            int primeLen = p.bitLength();
+            if (defaultParams.get(primeLen) == null) {
+                defaultParams.put(primeLen,
+                    new DHParameterSpec(p, BigInteger.TWO));
+            }
+        }
+
+        ffdheParams =
+            Collections.<Integer,DHParameterSpec>unmodifiableMap(tempFFDHEs);
+        definedParams =
+            Collections.<Integer,DHParameterSpec>unmodifiableMap(defaultParams);
+    }
+}
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -96,7 +96,7 @@
     private ProtocolVersion clientRequestedVersion;
 
     // client supported elliptic curves
-    private EllipticCurvesExtension requestedCurves;
+    private SupportedGroupsExtension requestedGroups;
 
     // the preferable signature algorithm used by ServerKeyExchange message
     SignatureAndHashAlgorithm preferableSignatureAlgorithm;
@@ -751,8 +751,8 @@
                 throw new SSLException("Client did not resume a session");
             }
 
-            requestedCurves = (EllipticCurvesExtension)
-                        mesg.extensions.get(ExtensionType.EXT_ELLIPTIC_CURVES);
+            requestedGroups = (SupportedGroupsExtension)
+                    mesg.extensions.get(ExtensionType.EXT_SUPPORTED_GROUPS);
 
             // We only need to handle the "signature_algorithm" extension
             // for full handshakes and TLS 1.2 or later.
@@ -1341,6 +1341,8 @@
             }
         }
 
+        // The named group used for ECDHE and FFDHE.
+        NamedGroup namedGroup = null;
         switch (keyExchange) {
         case K_RSA:
             // need RSA certs for authentication
@@ -1366,6 +1368,37 @@
             }
             break;
         case K_DHE_RSA:
+            // Is ephemeral DH cipher suite usable for the connection?
+            //
+            // [RFC 7919] If a compatible TLS server receives a Supported
+            // Groups extension from a client that includes any FFDHE group
+            // (i.e., any codepoint between 256 and 511, inclusive, even if
+            // unknown to the server), and if none of the client-proposed
+            // FFDHE groups are known and acceptable to the server, then
+            // the server MUST NOT select an FFDHE cipher suite.  In this
+            // case, the server SHOULD select an acceptable non-FFDHE cipher
+            // suite from the client's offered list.  If the extension is
+            // present with FFDHE groups, none of the client's offered
+            // groups are acceptable by the server, and none of the client's
+            // proposed non-FFDHE cipher suites are acceptable to the server,
+            // the server MUST end the connection with a fatal TLS alert
+            // of type insufficient_security(71).
+            //
+            // Note: For compatibility, if an application is customized to
+            // use legacy sizes (512 bits for exportable cipher suites and
+            // 768 bits for others), or the cipher suite is exportable, the
+            // FFDHE extension will not be used.
+            if ((!useLegacyEphemeralDHKeys) && (!suite.exportable) &&
+                (requestedGroups != null) && requestedGroups.hasFFDHEGroup()) {
+
+                namedGroup = requestedGroups.getPreferredGroup(
+                    algorithmConstraints, NamedGroupType.NAMED_GROUP_FFDHE);
+                if (namedGroup == null) {
+                    // no match found, cannot use this cipher suite.
+                    return false;
+                }
+            }
+
             // need RSA certs for authentication
             if (setupPrivateKeyAndChain("RSA") == false) {
                 return false;
@@ -1386,9 +1419,20 @@
                 }
             }
 
-            setupEphemeralDHKeys(suite.exportable, privateKey);
+            setupEphemeralDHKeys(namedGroup, suite.exportable, privateKey);
             break;
         case K_ECDHE_RSA:
+            // Is ECDHE cipher suite usable for the connection?
+            namedGroup = (requestedGroups != null) ?
+                requestedGroups.getPreferredGroup(
+                    algorithmConstraints, NamedGroupType.NAMED_GROUP_ECDHE) :
+                SupportedGroupsExtension.getPreferredECGroup(
+                    algorithmConstraints);
+            if (namedGroup == null) {
+                // no match found, cannot use this ciphersuite
+                return false;
+            }
+
             // need RSA certs for authentication
             if (setupPrivateKeyAndChain("RSA") == false) {
                 return false;
@@ -1409,11 +1453,23 @@
                 }
             }
 
-            if (setupEphemeralECDHKeys() == false) {
-                return false;
-            }
+            setupEphemeralECDHKeys(namedGroup);
             break;
         case K_DHE_DSS:
+            // Is ephemeral DH cipher suite usable for the connection?
+            //
+            // See comment in K_DHE_RSA case.
+            if ((!useLegacyEphemeralDHKeys) && (!suite.exportable) &&
+                (requestedGroups != null) && requestedGroups.hasFFDHEGroup()) {
+
+                namedGroup = requestedGroups.getPreferredGroup(
+                    algorithmConstraints, NamedGroupType.NAMED_GROUP_FFDHE);
+                if (namedGroup == null) {
+                    // no match found, cannot use this cipher suite.
+                    return false;
+                }
+            }
+
             // get preferable peer signature algorithm for server key exchange
             if (protocolVersion.useTLS12PlusSpec()) {
                 preferableSignatureAlgorithm =
@@ -1434,9 +1490,20 @@
                 return false;
             }
 
-            setupEphemeralDHKeys(suite.exportable, privateKey);
+            setupEphemeralDHKeys(namedGroup, suite.exportable, privateKey);
             break;
         case K_ECDHE_ECDSA:
+            // Is ECDHE cipher suite usable for the connection?
+            namedGroup = (requestedGroups != null) ?
+                requestedGroups.getPreferredGroup(
+                    algorithmConstraints, NamedGroupType.NAMED_GROUP_ECDHE) :
+                SupportedGroupsExtension.getPreferredECGroup(
+                    algorithmConstraints);
+            if (namedGroup == null) {
+                // no match found, cannot use this ciphersuite
+                return false;
+            }
+
             // get preferable peer signature algorithm for server key exchange
             if (protocolVersion.useTLS12PlusSpec()) {
                 preferableSignatureAlgorithm =
@@ -1456,9 +1523,8 @@
             if (setupPrivateKeyAndChain("EC") == false) {
                 return false;
             }
-            if (setupEphemeralECDHKeys() == false) {
-                return false;
-            }
+
+            setupEphemeralECDHKeys(namedGroup);
             break;
         case K_ECDH_RSA:
             // need EC cert
@@ -1475,14 +1541,36 @@
             setupStaticECDHKeys();
             break;
         case K_DH_ANON:
+            // Is ephemeral DH cipher suite usable for the connection?
+            //
+            // See comment in K_DHE_RSA case.
+            if ((!useLegacyEphemeralDHKeys) && (!suite.exportable) &&
+                (requestedGroups != null) && requestedGroups.hasFFDHEGroup()) {
+                namedGroup = requestedGroups.getPreferredGroup(
+                    algorithmConstraints, NamedGroupType.NAMED_GROUP_FFDHE);
+                if (namedGroup == null) {
+                    // no match found, cannot use this cipher suite.
+                    return false;
+                }
+            }
+
             // no certs needed for anonymous
-            setupEphemeralDHKeys(suite.exportable, null);
+            setupEphemeralDHKeys(namedGroup, suite.exportable, null);
             break;
         case K_ECDH_ANON:
-            // no certs needed for anonymous
-            if (setupEphemeralECDHKeys() == false) {
+            // Is ECDHE cipher suite usable for the connection?
+            namedGroup = (requestedGroups != null) ?
+                requestedGroups.getPreferredGroup(
+                    algorithmConstraints, NamedGroupType.NAMED_GROUP_ECDHE) :
+                SupportedGroupsExtension.getPreferredECGroup(
+                    algorithmConstraints);
+            if (namedGroup == null) {
+                // no match found, cannot use this ciphersuite
                 return false;
             }
+
+            // no certs needed for anonymous
+            setupEphemeralECDHKeys(namedGroup);
             break;
         default:
             ClientKeyExchangeService p =
@@ -1544,7 +1632,15 @@
      * Acquire some "ephemeral" Diffie-Hellman  keys for this handshake.
      * We don't reuse these, for improved forward secrecy.
      */
-    private void setupEphemeralDHKeys(boolean export, Key key) {
+    private void setupEphemeralDHKeys(
+            NamedGroup namedGroup, boolean export, Key key) {
+        // Are the client and server willing to negotiate FFDHE groups?
+        if ((!useLegacyEphemeralDHKeys) && (!export) && (namedGroup != null)) {
+            dh = new DHCrypt(namedGroup, sslContext.getSecureRandom());
+
+            return;
+        }   // Otherwise, the client is not compatible with FFDHE extension.
+
         /*
          * 768 bits ephemeral DH private keys were used to be used in
          * ServerKeyExchange except that exportable ciphers max out at 512
@@ -1613,20 +1709,11 @@
         dh = new DHCrypt(keySize, sslContext.getSecureRandom());
     }
 
-    // Setup the ephemeral ECDH parameters.
-    // If we cannot continue because we do not support any of the curves that
-    // the client requested, return false. Otherwise (all is well), return true.
-    private boolean setupEphemeralECDHKeys() {
-        int index = (requestedCurves != null) ?
-                requestedCurves.getPreferredCurve(algorithmConstraints) :
-                EllipticCurvesExtension.getActiveCurves(algorithmConstraints);
-        if (index < 0) {
-            // no match found, cannot use this ciphersuite
-            return false;
-        }
-
-        ecdh = new ECDHCrypt(index, sslContext.getSecureRandom());
-        return true;
+    /**
+     * Setup the ephemeral ECDH parameters.
+     */
+    private void setupEphemeralECDHKeys(NamedGroup namedGroup) {
+        ecdh = new ECDHCrypt(namedGroup, sslContext.getSecureRandom());
     }
 
     private void setupStaticECDHKeys() {
@@ -1674,9 +1761,11 @@
                 return false;
             }
             ECParameterSpec params = ((ECPublicKey)publicKey).getParams();
-            int id = EllipticCurvesExtension.getCurveIndex(params);
-            if ((id <= 0) || !EllipticCurvesExtension.isSupported(id) ||
-                ((requestedCurves != null) && !requestedCurves.contains(id))) {
+            NamedGroup namedGroup = NamedGroup.valueOf(params);
+            if ((namedGroup == null) ||
+                (!SupportedGroupsExtension.supports(namedGroup)) ||
+                ((requestedGroups != null) &&
+                        !requestedGroups.contains(namedGroup.id))) {
                 return false;
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,491 @@
+/*
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.ssl;
+
+import java.io.IOException;
+import java.security.spec.ECGenParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
+import java.security.AlgorithmParameters;
+import java.security.AlgorithmConstraints;
+import java.security.CryptoPrimitive;
+import java.security.AccessController;
+import java.security.spec.AlgorithmParameterSpec;
+import javax.crypto.spec.DHParameterSpec;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ArrayList;
+import javax.net.ssl.SSLProtocolException;
+
+import sun.security.action.GetPropertyAction;
+
+//
+// Note: Since RFC 7919, the extension's semantics are expanded from
+// "Supported Elliptic Curves" to "Supported Groups".  The enum datatype
+// used in the extension has been renamed from NamedCurve to NamedGroup.
+// Its semantics are likewise expanded from "named curve" to "named group".
+//
+final class SupportedGroupsExtension extends HelloExtension {
+
+    /* Class and subclass dynamic debugging support */
+    private static final Debug debug = Debug.getInstance("ssl");
+
+    private static final int ARBITRARY_PRIME = 0xff01;
+    private static final int ARBITRARY_CHAR2 = 0xff02;
+
+    // cache to speed up the parameters construction
+    private static final Map<NamedGroup,
+                AlgorithmParameters> namedGroupParams = new HashMap<>();
+
+    // the supported named groups
+    private static final NamedGroup[] supportedNamedGroups;
+
+    // the named group presented in the extension
+    private final int[] requestedNamedGroupIds;
+
+    static {
+        boolean requireFips = SunJSSE.isFIPS();
+
+        // The value of the System Property defines a list of enabled named
+        // groups in preference order, separated with comma.  For example:
+        //
+        //      jdk.tls.namedGroups="secp521r1, secp256r1, ffdhe2048"
+        //
+        // If the System Property is not defined or the value is empty, the
+        // default groups and preferences will be used.
+        String property = AccessController.doPrivileged(
+                    new GetPropertyAction("jdk.tls.namedGroups"));
+        if (property != null && property.length() != 0) {
+            // remove double quote marks from beginning/end of the property
+            if (property.length() > 1 && property.charAt(0) == '"' &&
+                    property.charAt(property.length() - 1) == '"') {
+                property = property.substring(1, property.length() - 1);
+            }
+        }
+
+        ArrayList<NamedGroup> groupList;
+        if (property != null && property.length() != 0) {   // customized groups
+            String[] groups = property.split(",");
+            groupList = new ArrayList<>(groups.length);
+            for (String group : groups) {
+                group = group.trim();
+                if (!group.isEmpty()) {
+                    NamedGroup namedGroup = NamedGroup.nameOf(group);
+                    if (namedGroup != null &&
+                            (!requireFips || namedGroup.isFips)) {
+                        if (isAvailableGroup(namedGroup)) {
+                            groupList.add(namedGroup);
+                        }
+                    }   // ignore unknown groups
+                }
+            }
+
+            if (groupList.isEmpty() && JsseJce.isEcAvailable()) {
+                throw new IllegalArgumentException(
+                    "System property jdk.tls.namedGroups(" + property + ") " +
+                    "contains no supported elliptic curves");
+            }
+        } else {        // default groups
+            NamedGroup[] groups;
+            if (requireFips) {
+                groups = new NamedGroup[] {
+                    // only NIST curves in FIPS mode
+                    NamedGroup.SECP256_R1,
+                    NamedGroup.SECP384_R1,
+                    NamedGroup.SECP521_R1,
+                    NamedGroup.SECT283_K1,
+                    NamedGroup.SECT283_R1,
+                    NamedGroup.SECT409_K1,
+                    NamedGroup.SECT409_R1,
+                    NamedGroup.SECT571_K1,
+                    NamedGroup.SECT571_R1,
+
+                    // FFDHE 2048
+                    NamedGroup.FFDHE_2048,
+                    NamedGroup.FFDHE_3072,
+                    NamedGroup.FFDHE_4096,
+                    NamedGroup.FFDHE_6144,
+                    NamedGroup.FFDHE_8192,
+                };
+            } else {
+                groups = new NamedGroup[] {
+                    // NIST curves first
+                    NamedGroup.SECP256_R1,
+                    NamedGroup.SECP384_R1,
+                    NamedGroup.SECP521_R1,
+                    NamedGroup.SECT283_K1,
+                    NamedGroup.SECT283_R1,
+                    NamedGroup.SECT409_K1,
+                    NamedGroup.SECT409_R1,
+                    NamedGroup.SECT571_K1,
+                    NamedGroup.SECT571_R1,
+
+                    // non-NIST curves
+                    NamedGroup.SECP256_K1,
+
+                    // FFDHE 2048
+                    NamedGroup.FFDHE_2048,
+                    NamedGroup.FFDHE_3072,
+                    NamedGroup.FFDHE_4096,
+                    NamedGroup.FFDHE_6144,
+                    NamedGroup.FFDHE_8192,
+                };
+            }
+
+            groupList = new ArrayList<>(groups.length);
+            for (NamedGroup group : groups) {
+                if (isAvailableGroup(group)) {
+                    groupList.add(group);
+                }
+            }
+        }
+
+        if (debug != null && groupList.isEmpty()) {
+            Debug.log(
+                "Initialized [jdk.tls.namedGroups|default] list contains " +
+                "no available elliptic curves. " +
+                (property != null ? "(" + property + ")" : "[Default]"));
+        }
+
+        supportedNamedGroups = new NamedGroup[groupList.size()];
+        int i = 0;
+        for (NamedGroup namedGroup : groupList) {
+            supportedNamedGroups[i++] = namedGroup;
+        }
+    }
+
+    // check whether the group is supported by the underlying providers
+    private static boolean isAvailableGroup(NamedGroup namedGroup) {
+        AlgorithmParameters params = null;
+        AlgorithmParameterSpec spec = null;
+        if ("EC".equals(namedGroup.algorithm)) {
+            if (namedGroup.oid != null) {
+                try {
+                    params = JsseJce.getAlgorithmParameters("EC");
+                    spec = new ECGenParameterSpec(namedGroup.oid);
+                } catch (Exception e) {
+                    return false;
+                }
+            }
+        } else if ("DiffieHellman".equals(namedGroup.algorithm)) {
+            try {
+                params = JsseJce.getAlgorithmParameters("DiffieHellman");
+                spec = getFFDHEDHParameterSpec(namedGroup);
+            } catch (Exception e) {
+                return false;
+            }
+        }
+
+        if ((params != null) && (spec != null)) {
+            try {
+                params.init(spec);
+            } catch (Exception e) {
+                return false;
+            }
+
+            // cache the parameters
+            namedGroupParams.put(namedGroup, params);
+
+            return true;
+        }
+
+        return false;
+    }
+
+    private static DHParameterSpec getFFDHEDHParameterSpec(
+            NamedGroup namedGroup) {
+        DHParameterSpec spec = null;
+        switch (namedGroup) {
+            case FFDHE_2048:
+                spec = PredefinedDHParameterSpecs.ffdheParams.get(2048);
+                break;
+            case FFDHE_3072:
+                spec = PredefinedDHParameterSpecs.ffdheParams.get(3072);
+                break;
+            case FFDHE_4096:
+                spec = PredefinedDHParameterSpecs.ffdheParams.get(4096);
+                break;
+            case FFDHE_6144:
+                spec = PredefinedDHParameterSpecs.ffdheParams.get(6144);
+                break;
+            case FFDHE_8192:
+                spec = PredefinedDHParameterSpecs.ffdheParams.get(8192);
+        }
+
+        return spec;
+    }
+
+    private static DHParameterSpec getPredefinedDHParameterSpec(
+            NamedGroup namedGroup) {
+        DHParameterSpec spec = null;
+        switch (namedGroup) {
+            case FFDHE_2048:
+                spec = PredefinedDHParameterSpecs.definedParams.get(2048);
+                break;
+            case FFDHE_3072:
+                spec = PredefinedDHParameterSpecs.definedParams.get(3072);
+                break;
+            case FFDHE_4096:
+                spec = PredefinedDHParameterSpecs.definedParams.get(4096);
+                break;
+            case FFDHE_6144:
+                spec = PredefinedDHParameterSpecs.definedParams.get(6144);
+                break;
+            case FFDHE_8192:
+                spec = PredefinedDHParameterSpecs.definedParams.get(8192);
+        }
+
+        return spec;
+    }
+
+    private SupportedGroupsExtension(int[] requestedNamedGroupIds) {
+        super(ExtensionType.EXT_SUPPORTED_GROUPS);
+
+        this.requestedNamedGroupIds = requestedNamedGroupIds;
+    }
+
+    SupportedGroupsExtension(HandshakeInStream s, int len) throws IOException {
+        super(ExtensionType.EXT_SUPPORTED_GROUPS);
+
+        int k = s.getInt16();
+        if (((len & 1) != 0) || (k == 0) || (k + 2 != len)) {
+            throw new SSLProtocolException("Invalid " + type + " extension");
+        }
+
+        // Note: unknown named group will be ignored later.
+        requestedNamedGroupIds = new int[k >> 1];
+        for (int i = 0; i < requestedNamedGroupIds.length; i++) {
+            requestedNamedGroupIds[i] = s.getInt16();
+        }
+    }
+
+    // Get a local preferred supported ECDHE group permitted by the constraints.
+    static NamedGroup getPreferredECGroup(AlgorithmConstraints constraints) {
+        for (NamedGroup namedGroup : supportedNamedGroups) {
+            if ((namedGroup.type == NamedGroupType.NAMED_GROUP_ECDHE) &&
+                constraints.permits(EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
+                    namedGroup.algorithm, namedGroupParams.get(namedGroup))) {
+
+                return namedGroup;
+            }
+        }
+
+        return null;
+    }
+
+    // Is there any supported group permitted by the constraints?
+    static boolean isActivatable(
+            AlgorithmConstraints constraints, NamedGroupType type) {
+
+        boolean hasFFDHEGroups = false;
+        for (NamedGroup namedGroup : supportedNamedGroups) {
+            if (namedGroup.type == type) {
+                if (constraints.permits(
+                        EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
+                        namedGroup.algorithm,
+                        namedGroupParams.get(namedGroup))) {
+
+                    return true;
+                }
+
+                if (!hasFFDHEGroups &&
+                        (type == NamedGroupType.NAMED_GROUP_FFDHE)) {
+
+                    hasFFDHEGroups = true;
+                }
+            }
+        }
+
+        // For compatibility, if no FFDHE groups are defined, the non-FFDHE
+        // compatible mode (using DHE cipher suite without FFDHE extension)
+        // is allowed.
+        //
+        // Note that the constraints checking on DHE parameters will be
+        // performed during key exchanging in a handshake.
+        if (!hasFFDHEGroups && (type == NamedGroupType.NAMED_GROUP_FFDHE)) {
+            return true;
+        }
+
+        return false;
+    }
+
+    // Create the default supported groups extension.
+    static SupportedGroupsExtension createExtension(
+            AlgorithmConstraints constraints,
+            CipherSuiteList cipherSuites, boolean enableFFDHE) {
+
+        ArrayList<Integer> groupList =
+                new ArrayList<>(supportedNamedGroups.length);
+        for (NamedGroup namedGroup : supportedNamedGroups) {
+            if ((!enableFFDHE) &&
+                (namedGroup.type == NamedGroupType.NAMED_GROUP_FFDHE)) {
+                continue;
+            }
+
+            if (cipherSuites.contains(namedGroup.type) &&
+                constraints.permits(EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
+                    namedGroup.algorithm, namedGroupParams.get(namedGroup))) {
+
+                groupList.add(namedGroup.id);
+            }
+        }
+
+        if (!groupList.isEmpty()) {
+            int[] ids = new int[groupList.size()];
+            int i = 0;
+            for (Integer id : groupList) {
+                ids[i++] = id;
+            }
+
+            return new SupportedGroupsExtension(ids);
+        }
+
+        return null;
+    }
+
+    // get the preferred activated named group
+    NamedGroup getPreferredGroup(
+            AlgorithmConstraints constraints, NamedGroupType type) {
+
+        for (int groupId : requestedNamedGroupIds) {
+            NamedGroup namedGroup = NamedGroup.valueOf(groupId);
+            if ((namedGroup != null) && (namedGroup.type == type) &&
+                SupportedGroupsExtension.supports(namedGroup) &&
+                constraints.permits(EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
+                    namedGroup.algorithm, namedGroupParams.get(namedGroup))) {
+
+                return namedGroup;
+            }
+        }
+
+        return null;
+    }
+
+    boolean hasFFDHEGroup() {
+        for (int groupId : requestedNamedGroupIds) {
+            /*
+             * [RFC 7919] Codepoints in the "Supported Groups Registry"
+             * with a high byte of 0x01 (that is, between 256 and 511,
+             * inclusive) are set aside for FFDHE groups.
+             */
+            if ((groupId >= 256) && (groupId <= 511)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    boolean contains(int index) {
+        for (int groupId : requestedNamedGroupIds) {
+            if (index == groupId) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    int length() {
+        return 6 + (requestedNamedGroupIds.length << 1);
+    }
+
+    @Override
+    void send(HandshakeOutStream s) throws IOException {
+        s.putInt16(type.id);
+        int k = requestedNamedGroupIds.length << 1;
+        s.putInt16(k + 2);
+        s.putInt16(k);
+        for (int groupId : requestedNamedGroupIds) {
+            s.putInt16(groupId);
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("Extension " + type + ", group names: {");
+        boolean first = true;
+        for (int groupId : requestedNamedGroupIds) {
+            if (first) {
+                first = false;
+            } else {
+                sb.append(", ");
+            }
+            // first check if it is a known named group, then try other cases.
+            NamedGroup namedGroup = NamedGroup.valueOf(groupId);
+            if (namedGroup != null) {
+                sb.append(namedGroup.name);
+            } else if (groupId == ARBITRARY_PRIME) {
+                sb.append("arbitrary_explicit_prime_curves");
+            } else if (groupId == ARBITRARY_CHAR2) {
+                sb.append("arbitrary_explicit_char2_curves");
+            } else {
+                sb.append("unknown named group " + groupId);
+            }
+        }
+        sb.append("}");
+        return sb.toString();
+    }
+
+    static boolean supports(NamedGroup namedGroup) {
+        for (NamedGroup group : supportedNamedGroups) {
+            if (namedGroup.id == group.id) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    static ECGenParameterSpec getECGenParamSpec(NamedGroup namedGroup) {
+        if (namedGroup.type != NamedGroupType.NAMED_GROUP_ECDHE) {
+            throw new RuntimeException("Not a named EC group: " + namedGroup);
+        }
+
+        AlgorithmParameters params = namedGroupParams.get(namedGroup);
+        try {
+            return params.getParameterSpec(ECGenParameterSpec.class);
+        } catch (InvalidParameterSpecException ipse) {
+            // should be unlikely
+            return new ECGenParameterSpec(namedGroup.oid);
+        }
+    }
+
+    static DHParameterSpec getDHParameterSpec(NamedGroup namedGroup) {
+        if (namedGroup.type != NamedGroupType.NAMED_GROUP_FFDHE) {
+            throw new RuntimeException("Not a named DH group: " + namedGroup);
+        }
+
+        AlgorithmParameters params = namedGroupParams.get(namedGroup);
+        try {
+            return params.getParameterSpec(DHParameterSpec.class);
+        } catch (InvalidParameterSpecException ipse) {
+            // should be unlikely
+            return getPredefinedDHParameterSpec(namedGroup);
+        }
+    }
+}
--- a/jdk/src/java.base/share/classes/sun/security/util/ConstraintsParameters.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/util/ConstraintsParameters.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/java.base/share/native/libjimage/endian.hpp	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/native/libjimage/endian.hpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
--- a/jdk/src/java.base/share/native/libjimage/imageDecompressor.cpp	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/native/libjimage/imageDecompressor.cpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
--- a/jdk/src/java.base/share/native/libjimage/imageDecompressor.hpp	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/native/libjimage/imageDecompressor.hpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
--- a/jdk/src/java.base/share/native/libjimage/imageFile.hpp	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/native/libjimage/imageFile.hpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
--- a/jdk/src/java.base/share/native/libjimage/inttypes.hpp	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/native/libjimage/inttypes.hpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -47,4 +47,3 @@
 #endif
 
 #endif // LIBJIMAGE_INTTYPES_HPP
-
--- a/jdk/src/java.base/share/native/libjimage/jimage.hpp	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/native/libjimage/jimage.hpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -202,4 +202,3 @@
 
 typedef bool (*JImage_ResourcePath_t)(JImageFile* jimage, JImageLocationRef location,
         char* buffer, jlong size);
-
--- a/jdk/src/java.base/share/native/libjimage/osSupport.hpp	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/native/libjimage/osSupport.hpp	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
--- a/jdk/src/java.base/share/native/libjli/emessages.h	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/native/libjli/emessages.h	Wed Jul 05 23:25:53 2017 +0200
@@ -43,13 +43,14 @@
 #define ARG_ERROR2      "Error: %s requires jar file specification"
 #define ARG_ERROR3      "Error: The -J option should not be followed by a space."
 #define ARG_ERROR4      "Error: %s requires module path specification"
-#define ARG_ERROR5      "Error: %s requires module id"
+#define ARG_ERROR5      "Error: %s requires module name"
 #define ARG_ERROR6      "Error: %s requires modules to be specified"
 #define ARG_ERROR7      "Error: %s can only be specified once"
 #define ARG_ERROR8      "Error: Unmatched quote in environment variable %s"
 #define ARG_ERROR9      "Error: Option %s is not allowed in environment variable %s"
 #define ARG_ERROR10     "Error: Option %s in %s is not allowed in environment variable %s"
 #define ARG_ERROR11     "Error: Cannot specify main class in environment variable %s"
+#define ARG_ERROR12     "Error: %s requires module name"
 
 #define JVM_ERROR1      "Error: Could not create the Java Virtual Machine.\n" GEN_ERROR
 #define JVM_ERROR2      "Error: Could not detach main thread.\n" JNI_ERROR
--- a/jdk/src/java.base/share/native/libjli/java.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/share/native/libjli/java.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -71,7 +71,10 @@
 static jboolean printXUsage = JNI_FALSE;  /* print and exit*/
 static jboolean dryRun = JNI_FALSE;       /* initialize VM and exit */
 static char     *showSettings = NULL;     /* print but continue */
-static char     *listModules = NULL;
+static jboolean showResolvedModules = JNI_FALSE;
+static jboolean listModules = JNI_FALSE;
+static char     *describeModule = NULL;
+static jboolean validateModules = JNI_FALSE;
 
 static const char *_program_name;
 static const char *_launcher_name;
@@ -118,12 +121,14 @@
 static void PrintJavaVersion(JNIEnv *env, jboolean extraLF);
 static void PrintUsage(JNIEnv* env, jboolean doXUsage);
 static void ShowSettings(JNIEnv* env, char *optString);
-static void ListModules(JNIEnv* env, char *optString);
+static void ShowResolvedModules(JNIEnv* env);
+static void ListModules(JNIEnv* env);
+static void DescribeModule(JNIEnv* env, char* optString);
+static jboolean ValidateModules(JNIEnv* env);
 
 static void SetPaths(int argc, char **argv);
 
 static void DumpState();
-static jboolean RemovableOption(char *option);
 
 enum OptionKind {
     LAUNCHER_OPTION = 0,
@@ -409,12 +414,34 @@
         CHECK_EXCEPTION_LEAVE(1);
     }
 
-    if (listModules != NULL) {
-        ListModules(env, listModules);
+    // show resolved modules and continue
+    if (showResolvedModules) {
+        ShowResolvedModules(env);
+        CHECK_EXCEPTION_LEAVE(1);
+    }
+
+    // list observable modules, then exit
+    if (listModules) {
+        ListModules(env);
         CHECK_EXCEPTION_LEAVE(1);
         LEAVE();
     }
 
+    // describe a module, then exit
+    if (describeModule != NULL) {
+        DescribeModule(env, describeModule);
+        CHECK_EXCEPTION_LEAVE(1);
+        LEAVE();
+    }
+
+    // validate modules on the module path, then exit
+    if (validateModules) {
+        jboolean okay = ValidateModules(env);
+        CHECK_EXCEPTION_LEAVE(1);
+        if (!okay) ret = 1;
+        LEAVE();
+    }
+
     if (printVersion || showVersion) {
         PrintJavaVersion(env, showVersion);
         CHECK_EXCEPTION_LEAVE(0);
@@ -552,7 +579,8 @@
 IsLauncherOption(const char* name) {
     return IsClassPathOption(name) ||
            IsLauncherMainOption(name) ||
-           JLI_StrCmp(name, "--list-modules") == 0;
+           JLI_StrCmp(name, "--describe-module") == 0 ||
+           JLI_StrCmp(name, "-d") == 0;
 }
 
 /*
@@ -742,17 +770,16 @@
 }
 
 /*
- * static void SetJvmEnvironment(int argc, char **argv);
- *   Is called just before the JVM is loaded.  We can set env variables
- *   that are consumed by the JVM.  This function is non-destructive,
- *   leaving the arg list intact.  The first use is for the JVM flag
- *   -XX:NativeMemoryTracking=value.
+ * This method must be called before the VM is loaded, primarily
+ * used to parse and set any VM related options or env variables.
+ * This function is non-destructive leaving the argument list intact.
  */
 static void
 SetJvmEnvironment(int argc, char **argv) {
 
     static const char*  NMT_Env_Name    = "NMT_LEVEL_";
     int i;
+    /* process only the launcher arguments */
     for (i = 0; i < argc; i++) {
         char *arg = argv[i];
         /*
@@ -811,11 +838,8 @@
                     printf("TRACER_MARKER: NativeMemoryTracking: got value %s\n",envBuf);
                     free(envName);
                 }
-
             }
-
         }
-
     }
 }
 
@@ -1199,7 +1223,7 @@
 
     } else if (JLI_StrCCmp(arg, "--") == 0 && (equals = JLI_StrChr(arg, '=')) != NULL) {
         value = equals+1;
-        if (JLI_StrCCmp(arg, "--list-modules=") == 0 ||
+        if (JLI_StrCCmp(arg, "--describe-module=") == 0 ||
             JLI_StrCCmp(arg, "--module=") == 0 ||
             JLI_StrCCmp(arg, "--class-path=") == 0) {
             kind = LAUNCHER_OPTION_WITH_ARGUMENT;
@@ -1263,18 +1287,18 @@
             REPORT_ERROR (has_arg_any_len, ARG_ERROR1, arg);
             SetClassPath(value);
             mode = LM_CLASS;
-        } else if (JLI_StrCmp(arg, "--list-modules") == 0 ||
-                   JLI_StrCCmp(arg, "--list-modules=") == 0) {
-            listModules = arg;
-
-            // set listModules to --list-modules=<module-names> if argument is specified
-            if (JLI_StrCmp(arg, "--list-modules") == 0 && has_arg) {
-                static const char format[] = "%s=%s";
-                size_t buflen = JLI_StrLen(option) + 2 + JLI_StrLen(value);
-                listModules = JLI_MemAlloc(buflen);
-                JLI_Snprintf(listModules, buflen, format, option, value);
-            }
-            return JNI_TRUE;
+        } else if (JLI_StrCmp(arg, "--list-modules") == 0) {
+            listModules = JNI_TRUE;
+        } else if (JLI_StrCmp(arg, "--show-resolved-modules") == 0) {
+            showResolvedModules = JNI_TRUE;
+        } else if (JLI_StrCmp(arg, "--validate-modules") == 0) {
+            AddOption("-Djdk.module.minimumBoot=true", NULL);
+            validateModules = JNI_TRUE;
+        } else if (JLI_StrCmp(arg, "--describe-module") == 0 ||
+                   JLI_StrCCmp(arg, "--describe-module=") == 0 ||
+                   JLI_StrCmp(arg, "-d") == 0) {
+            REPORT_ERROR (has_arg_any_len, ARG_ERROR12, arg);
+            describeModule = value;
 /*
  * Parse white-space options
  */
@@ -1336,9 +1360,8 @@
             showSettings = arg;
         } else if (JLI_StrCmp(arg, "-Xdiag") == 0) {
             AddOption("-Dsun.java.launcher.diag=true", NULL);
-            AddOption("-Djdk.launcher.traceResolver=true", NULL);
-        } else if (JLI_StrCmp(arg, "-Xdiag:resolver") == 0) {
-            AddOption("-Djdk.launcher.traceResolver=true", NULL);
+        } else if (JLI_StrCmp(arg, "--show-module-resolution") == 0) {
+            AddOption("-Djdk.module.showModuleResolution=true", NULL);
 /*
  * The following case provide backward compatibility with old-style
  * command line options.
@@ -1383,8 +1406,6 @@
             ; /* Ignore machine independent options already handled */
         } else if (ProcessPlatformOption(arg)) {
             ; /* Processing of platform dependent options */
-        } else if (RemovableOption(arg)) {
-            ; /* Do not pass option to vm. */
         } else {
             /* java.class.path set on the command line */
             if (JLI_StrCCmp(arg, "-Djava.class.path=") == 0) {
@@ -1399,7 +1420,10 @@
     }
 
     if (*pwhat == NULL) {
-        *pret = 1;
+        /* LM_UNKNOWN okay for options that exit */
+        if (!listModules && !describeModule && !validateModules) {
+            *pret = 1;
+        }
     } else if (mode == LM_UNKNOWN) {
         /* default to LM_CLASS if -m, -jar and -cp options are
          * not specified */
@@ -1828,21 +1852,61 @@
 }
 
 /**
- * List modules supported by the runtime
+ * Show resolved modules
+ */
+static void
+ShowResolvedModules(JNIEnv *env)
+{
+    jmethodID showResolvedModulesID;
+    jclass cls = GetLauncherHelperClass(env);
+    NULL_CHECK(cls);
+    NULL_CHECK(showResolvedModulesID = (*env)->GetStaticMethodID(env, cls,
+            "showResolvedModules", "()V"));
+    (*env)->CallStaticVoidMethod(env, cls, showResolvedModulesID);
+}
+
+/**
+ * List observable modules
  */
 static void
-ListModules(JNIEnv *env, char *optString)
+ListModules(JNIEnv *env)
 {
     jmethodID listModulesID;
+    jclass cls = GetLauncherHelperClass(env);
+    NULL_CHECK(cls);
+    NULL_CHECK(listModulesID = (*env)->GetStaticMethodID(env, cls,
+            "listModules", "()V"));
+    (*env)->CallStaticVoidMethod(env, cls, listModulesID);
+}
+
+/**
+ * Describe a module
+ */
+static void
+DescribeModule(JNIEnv *env, char *optString)
+{
+    jmethodID describeModuleID;
     jstring joptString = NULL;
     jclass cls = GetLauncherHelperClass(env);
     NULL_CHECK(cls);
-    NULL_CHECK(listModulesID = (*env)->GetStaticMethodID(env, cls,
-            "listModules", "(ZLjava/lang/String;)V"));
+    NULL_CHECK(describeModuleID = (*env)->GetStaticMethodID(env, cls,
+            "describeModule", "(Ljava/lang/String;)V"));
     NULL_CHECK(joptString = (*env)->NewStringUTF(env, optString));
-    (*env)->CallStaticVoidMethod(env, cls, listModulesID,
-                                 USE_STDOUT,
-                                 joptString);
+    (*env)->CallStaticVoidMethod(env, cls, describeModuleID, joptString);
+}
+
+/**
+ * Validate modules
+ */
+static jboolean
+ValidateModules(JNIEnv *env)
+{
+    jmethodID validateModulesID;
+    jclass cls = GetLauncherHelperClass(env);
+    NULL_CHECK_RETURN_VALUE(cls, JNI_FALSE);
+    validateModulesID = (*env)->GetStaticMethodID(env, cls, "validateModules", "()Z");
+    NULL_CHECK_RETURN_VALUE(cls, JNI_FALSE);
+    return (*env)->CallStaticBooleanMethod(env, cls, validateModulesID);
 }
 
 /*
@@ -2263,34 +2327,6 @@
 }
 
 /*
- * Return JNI_TRUE for an option string that has no effect but should
- * _not_ be passed on to the vm; return JNI_FALSE otherwise.  On
- * Solaris SPARC, this screening needs to be done if:
- *    -d32 or -d64 is passed to a binary with an unmatched data model
- *    (the exec in CreateExecutionEnvironment removes -d<n> options and points the
- *    exec to the proper binary).  In the case of when the data model and the
- *    requested version is matched, an exec would not occur, and these options
- *    were erroneously passed to the vm.
- */
-jboolean
-RemovableOption(char * option)
-{
-  /*
-   * Unconditionally remove both -d32 and -d64 options since only
-   * the last such options has an effect; e.g.
-   * java -d32 -d64 -d32 -version
-   * is equivalent to
-   * java -d32 -version
-   */
-
-  if( (JLI_StrCCmp(option, "-d32")  == 0 ) ||
-      (JLI_StrCCmp(option, "-d64")  == 0 ) )
-    return JNI_TRUE;
-  else
-    return JNI_FALSE;
-}
-
-/*
  * A utility procedure to always print to stderr
  */
 void
--- a/jdk/src/java.base/solaris/native/libnet/solaris_close.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/solaris/native/libnet/solaris_close.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
 #include <sys/socket.h>
 #include <stropts.h>
 #include <unistd.h>
+#include "jvm.h"
+#include "net_util.h"
 
 /* Support for restartable system calls on Solaris. */
 
@@ -90,25 +92,22 @@
     RESTARTABLE_RETURN_INT(poll(ufds, nfds, timeout));
 }
 
-int NET_Timeout0(int s, long timeout, long currentTime) {
+int NET_Timeout(JNIEnv *env, int s, long timeout, jlong nanoTimeStamp) {
     int result;
-    struct timeval t;
-    long prevtime = currentTime, newtime;
+    jlong prevNanoTime = nanoTimeStamp;
+    jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
     struct pollfd pfd;
     pfd.fd = s;
     pfd.events = POLLIN;
 
     for(;;) {
-        result = poll(&pfd, 1, timeout);
+        result = poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
         if (result < 0 && errno == EINTR) {
-            if (timeout > 0) {
-                gettimeofday(&t, NULL);
-                newtime = (t.tv_sec * 1000)  +  t.tv_usec /1000;
-                timeout -= newtime - prevtime;
-                if (timeout <= 0)
-                    return 0;
-                prevtime = newtime;
-            }
+            jlong newNanoTime = JVM_NanoTime(env, 0);
+            nanoTimeout -= newNanoTime - prevNanoTime;
+            if (nanoTimeout < NET_NSEC_PER_MSEC)
+                return 0;
+            prevNanoTime = newNanoTime;
         } else {
             return result;
         }
--- a/jdk/src/java.base/unix/native/libjli/java_md.h	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/unix/native/libjli/java_md.h	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,7 @@
 const char *SetExecname(char **argv);
 const char *GetExecName();
 static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
-                           char *jvmpath, jint jvmpathsize, int bitsWanted);
+                           char *jvmpath, jint jvmpathsize);
 static jboolean GetJREPath(char *path, jint pathsize, jboolean speculative);
 
 #if defined(_AIX)
--- a/jdk/src/java.base/unix/native/libjli/java_md_solinux.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/unix/native/libjli/java_md_solinux.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,9 +62,7 @@
  *
  * The selection of the proper vm shared library to open depends on
  * several classes of command line options, including vm "flavor"
- * options (-client, -server) and the data model options, -d32  and
- * -d64, as well as a version specification which may have come from
- * the command line or from the manifest of an executable jar file.
+ * options (-client, -server).
  * The vm selection options are not passed to the running
  * virtual machine; they must be screened out by the launcher.
  *
@@ -120,34 +118,30 @@
  *  |
  * \|/
  * ParseArguments
- * (removes -d32 and -d64 if any,
- *  processes version options,
- *  creates argument list for vm,
- *  etc.)
  *   |
  *   |
  *  \|/
  * RequiresSetenv
  * Is LD_LIBRARY_PATH
- * and friends set ? --> NO --> Have Desired Model ? NO --> Error/Exit
- *  YES                              YES --> Continue
+ * and friends set ? --> NO --> Continue
+ *  YES
  *   |
  *   |
  *  \|/
- * Path is desired JRE ? YES --> Have Desired Model ? NO --> Error/Exit
- *  NO                               YES --> Continue
+ * Path is desired JRE ? YES --> Continue
+ *  NO
  *   |
  *   |
  *  \|/
  * Paths have well known
- * jvm paths ?       --> NO --> Have Desired Model ? NO --> Error/Exit
- *  YES                              YES --> Continue
+ * jvm paths ?       --> NO --> Error/Exit
+ *  YES
  *   |
  *   |
  *  \|/
- *  Does libjvm.so exit
- *  in any of them ? --> NO --> Have Desired Model ? NO --> Error/Exit
- *   YES                             YES --> Continue
+ *  Does libjvm.so exist
+ *  in any of them ? --> NO  --> Continue
+ *   YES
  *   |
  *   |
  *  \|/
@@ -302,229 +296,97 @@
                            char jrepath[], jint so_jrepath,
                            char jvmpath[], jint so_jvmpath,
                            char jvmcfg[],  jint so_jvmcfg) {
-  /*
-   * First, determine if we are running the desired data model.  If we
-   * are running the desired data model, all the error messages
-   * associated with calling GetJREPath, ReadKnownVMs, etc. should be
-   * output, otherwise we simply exit with an error, as we no longer
-   * support dual data models.
-   */
-    jboolean jvmpathExists;
+
+    char * jvmtype = NULL;
+    int argc = *pargc;
+    char **argv = *pargv;
+
+#ifdef SETENV_REQUIRED
+    jboolean mustsetenv = JNI_FALSE;
+    char *runpath = NULL; /* existing effective LD_LIBRARY_PATH setting */
+    char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */
+    char* newpath = NULL; /* path on new LD_LIBRARY_PATH */
+    char* lastslash = NULL;
+    char** newenvp = NULL; /* current environment */
+    size_t new_runpath_size;
+#endif  /* SETENV_REQUIRED */
 
     /* Compute/set the name of the executable */
     SetExecname(*pargv);
 
-    /* Check data model flags, and exec process, if needed */
-    {
-      char * jvmtype    = NULL;
-      int  argc         = *pargc;
-      char **argv       = *pargv;
-      int running       = CURRENT_DATA_MODEL;
-      /*
-       * As of jdk9, there is no support for dual mode operations, however
-       * for legacy error reporting purposes and until -d options are supported
-       * we need this.
-       */
-      int wanted        = running;
-#ifdef SETENV_REQUIRED
-      jboolean mustsetenv = JNI_FALSE;
-      char *runpath     = NULL; /* existing effective LD_LIBRARY_PATH setting */
-      char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */
-      char* newpath     = NULL; /* path on new LD_LIBRARY_PATH */
-      char* lastslash   = NULL;
-      char** newenvp    = NULL; /* current environment */
-      size_t new_runpath_size;
-#ifdef __solaris__
-      char*  dmpath     = NULL;  /* data model specific LD_LIBRARY_PATH,
-                                    Solaris only */
-#endif /* __solaris__ */
-#endif  /* SETENV_REQUIRED */
+    /* Check to see if the jvmpath exists */
+    /* Find out where the JRE is that we will be using. */
+    if (!GetJREPath(jrepath, so_jrepath, JNI_FALSE)) {
+        JLI_ReportErrorMessage(JRE_ERROR1);
+        exit(2);
+    }
+    JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%sjvm.cfg",
+            jrepath, FILESEP, FILESEP);
+    /* Find the specified JVM type */
+    if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) {
+        JLI_ReportErrorMessage(CFG_ERROR7);
+        exit(1);
+    }
 
-      char** newargv    = NULL;
-      int    newargc    = 0;
-
-      /*
-       * Starting in 1.5, all unix platforms accept the -d32 and -d64
-       * options.  On platforms where only one data-model is supported
-       * (e.g. ia-64 Linux), using the flag for the other data model is
-       * an error and will terminate the program.
-       */
-
-      { /* open new scope to declare local variables */
-        int i;
+    jvmpath[0] = '\0';
+    jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE);
+    if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
+        JLI_ReportErrorMessage(CFG_ERROR9);
+        exit(4);
+    }
 
-        newargv = (char **)JLI_MemAlloc((argc+1) * sizeof(char*));
-        newargv[newargc++] = argv[0];
-
-        /* scan for data model arguments and remove from argument list;
-           last occurrence determines desired data model */
-        for (i=1; i < argc; i++) {
-
-          if (JLI_StrCmp(argv[i], "-J-d64") == 0 || JLI_StrCmp(argv[i], "-d64") == 0) {
-            wanted = 64;
-            continue;
-          }
-          if (JLI_StrCmp(argv[i], "-J-d32") == 0 || JLI_StrCmp(argv[i], "-d32") == 0) {
-            wanted = 32;
-            continue;
-          }
-          newargv[newargc++] = argv[i];
+    if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) {
+        JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
+        exit(4);
+    }
+    /*
+     * we seem to have everything we need, so without further ado
+     * we return back, otherwise proceed to set the environment.
+     */
+#ifdef SETENV_REQUIRED
+    mustsetenv = RequiresSetenv(jvmpath);
+    JLI_TraceLauncher("mustsetenv: %s\n", mustsetenv ? "TRUE" : "FALSE");
 
-          if (IsJavaArgs()) {
-            if (argv[i][0] != '-') continue;
-          } else {
-            if (JLI_StrCmp(argv[i], "-classpath") == 0 || JLI_StrCmp(argv[i], "-cp") == 0) {
-              i++;
-              if (i >= argc) break;
-              newargv[newargc++] = argv[i];
-              continue;
-            }
-            if (argv[i][0] != '-') { i++; break; }
-          }
-        }
+    if (mustsetenv == JNI_FALSE) {
+        return;
+    }
+#else
+    return;
+#endif /* SETENV_REQUIRED */
 
-        /* copy rest of args [i .. argc) */
-        while (i < argc) {
-          newargv[newargc++] = argv[i++];
-        }
-        newargv[newargc] = NULL;
-
+#ifdef SETENV_REQUIRED
+    if (mustsetenv) {
         /*
-         * newargv has all proper arguments here
+         * We will set the LD_LIBRARY_PATH as follows:
+         *
+         *     o          $JVMPATH (directory portion only)
+         *     o          $JRE/lib
+         *     o          $JRE/../lib
+         *
+         * followed by the user's previous effective LD_LIBRARY_PATH, if
+         * any.
          */
 
-        argc = newargc;
-        argv = newargv;
-      }
-
-      /* If the data model is not changing, it is an error if the
-         jvmpath does not exist */
-      if (wanted == running) {
-        /* Find out where the JRE is that we will be using. */
-        if (!GetJREPath(jrepath, so_jrepath, JNI_FALSE) ) {
-          JLI_ReportErrorMessage(JRE_ERROR1);
-          exit(2);
-        }
-        JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%s%sjvm.cfg",
-                     jrepath, FILESEP, FILESEP, FILESEP);
-        /* Find the specified JVM type */
-        if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) {
-          JLI_ReportErrorMessage(CFG_ERROR7);
-          exit(1);
-        }
-
-        jvmpath[0] = '\0';
-        jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE);
-        if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
-            JLI_ReportErrorMessage(CFG_ERROR9);
-            exit(4);
-        }
-
-        if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, 0 )) {
-          JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
-          exit(4);
-        }
-        /*
-         * we seem to have everything we need, so without further ado
-         * we return back, otherwise proceed to set the environment.
-         */
-#ifdef SETENV_REQUIRED
-        mustsetenv = RequiresSetenv(jvmpath);
-        JLI_TraceLauncher("mustsetenv: %s\n", mustsetenv ? "TRUE" : "FALSE");
+        runpath = getenv(LD_LIBRARY_PATH);
 
-        if (mustsetenv == JNI_FALSE) {
-            JLI_MemFree(newargv);
-            return;
-        }
-#else
-        JLI_MemFree(newargv);
-        return;
-#endif /* SETENV_REQUIRED */
-      } else {  /* do the same speculatively or exit */
-        JLI_ReportErrorMessage(JRE_ERROR2, wanted);
-        exit(1);
-      }
-#ifdef SETENV_REQUIRED
-        if (mustsetenv) {
-            /*
-             * We will set the LD_LIBRARY_PATH as follows:
-             *
-             *     o          $JVMPATH (directory portion only)
-             *     o          $JRE/lib
-             *     o          $JRE/../lib
-             *
-             * followed by the user's previous effective LD_LIBRARY_PATH, if
-             * any.
-             */
+        /* runpath contains current effective LD_LIBRARY_PATH setting */
+        { /* New scope to declare local variable */
+            char *new_jvmpath = JLI_StringDup(jvmpath);
+            new_runpath_size = ((runpath != NULL) ? JLI_StrLen(runpath) : 0) +
+                    2 * JLI_StrLen(jrepath) +
+#ifdef AIX
+                    /* On AIX we additionally need 'jli' in the path because ld doesn't support $ORIGIN. */
+                    JLI_StrLen(jrepath) + JLI_StrLen("/lib//jli:") +
+#endif
+                    JLI_StrLen(new_jvmpath) + 52;
+            new_runpath = JLI_MemAlloc(new_runpath_size);
+            newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "=");
 
-#ifdef __solaris__
-            /*
-             * Starting in Solaris 7, ld.so.1 supports three LD_LIBRARY_PATH
-             * variables:
-             *
-             * 1. LD_LIBRARY_PATH -- used for 32 and 64 bit searches if
-             * data-model specific variables are not set.
-             *
-             * 2. LD_LIBRARY_PATH_64 -- overrides and replaces LD_LIBRARY_PATH
-             * for 64-bit binaries.
-             * The vm uses LD_LIBRARY_PATH to set the java.library.path system
-             * property.  To shield the vm from the complication of multiple
-             * LD_LIBRARY_PATH variables, if the appropriate data model
-             * specific variable is set, we will act as if LD_LIBRARY_PATH had
-             * the value of the data model specific variant and the data model
-             * specific variant will be unset.  Note that the variable for the
-             * *wanted* data model must be used (if it is set), not simply the
-             * current running data model.
-             */
-
-            switch (wanted) {
-                case 0:
-                case 64:
-                    dmpath = getenv("LD_LIBRARY_PATH_64");
-                    wanted = 64;
-                    break;
-
-                default:
-                    JLI_ReportErrorMessage(JRE_ERROR3, __LINE__);
-                    exit(1); /* unknown value in wanted */
-                    break;
-            }
 
             /*
-             * If dmpath is NULL, the relevant data model specific variable is
-             * not set and normal LD_LIBRARY_PATH should be used.
-             */
-            if (dmpath == NULL) {
-                runpath = getenv("LD_LIBRARY_PATH");
-            } else {
-                runpath = dmpath;
-            }
-#else /* ! __solaris__ */
-            /*
-             * If not on Solaris, assume only a single LD_LIBRARY_PATH
-             * variable.
+             * Create desired LD_LIBRARY_PATH value for target data model.
              */
-            runpath = getenv(LD_LIBRARY_PATH);
-#endif /* __solaris__ */
-
-            /* runpath contains current effective LD_LIBRARY_PATH setting */
-            { /* New scope to declare local variable */
-              char *new_jvmpath = JLI_StringDup(jvmpath);
-              new_runpath_size = ((runpath != NULL) ? JLI_StrLen(runpath) : 0) +
-                      2 * JLI_StrLen(jrepath) +
-#ifdef AIX
-                      /* On AIX we additionally need 'jli' in the path because ld doesn't support $ORIGIN. */
-                      JLI_StrLen(jrepath) + JLI_StrLen("/lib//jli:") +
-#endif
-                      JLI_StrLen(new_jvmpath) + 52;
-              new_runpath = JLI_MemAlloc(new_runpath_size);
-              newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "=");
-
-
-              /*
-               * Create desired LD_LIBRARY_PATH value for target data model.
-               */
-              {
+            {
                 /* remove the name of the .so from the JVM path */
                 lastslash = JLI_StrRChr(new_jvmpath, '/');
                 if (lastslash)
@@ -555,85 +417,66 @@
                  */
                 if (runpath != NULL &&
                         JLI_StrNCmp(newpath, runpath, JLI_StrLen(newpath)) == 0 &&
-                        (runpath[JLI_StrLen(newpath)] == 0 || runpath[JLI_StrLen(newpath)] == ':') &&
-                        (running == wanted) /* data model does not have to be changed */
-#ifdef __solaris__
-                        && (dmpath == NULL) /* data model specific variables not set  */
-#endif /* __solaris__ */
-                        ) {
-                    JLI_MemFree(newargv);
+                        (runpath[JLI_StrLen(newpath)] == 0 ||
+                        runpath[JLI_StrLen(newpath)] == ':')) {
                     JLI_MemFree(new_runpath);
                     return;
                 }
-              }
             }
+        }
 
-            /*
-             * Place the desired environment setting onto the prefix of
-             * LD_LIBRARY_PATH.  Note that this prevents any possible infinite
-             * loop of execv() because we test for the prefix, above.
-             */
-            if (runpath != 0) {
-                /* ensure storage for runpath + colon + NULL */
-                if ((JLI_StrLen(runpath) + 1 + 1) > new_runpath_size) {
-                    JLI_ReportErrorMessageSys(JRE_ERROR11);
-                    exit(1);
-                }
-                JLI_StrCat(new_runpath, ":");
-                JLI_StrCat(new_runpath, runpath);
+        /*
+         * Place the desired environment setting onto the prefix of
+         * LD_LIBRARY_PATH.  Note that this prevents any possible infinite
+         * loop of execv() because we test for the prefix, above.
+         */
+        if (runpath != 0) {
+            /* ensure storage for runpath + colon + NULL */
+            if ((JLI_StrLen(runpath) + 1 + 1) > new_runpath_size) {
+                JLI_ReportErrorMessageSys(JRE_ERROR11);
+                exit(1);
             }
-
-            if (putenv(new_runpath) != 0) {
-                exit(1); /* problem allocating memory; LD_LIBRARY_PATH not set
-                    properly */
-            }
+            JLI_StrCat(new_runpath, ":");
+            JLI_StrCat(new_runpath, runpath);
+        }
 
-            /*
-             * Unix systems document that they look at LD_LIBRARY_PATH only
-             * once at startup, so we have to re-exec the current executable
-             * to get the changed environment variable to have an effect.
-             */
+        if (putenv(new_runpath) != 0) {
+            /* problem allocating memory; LD_LIBRARY_PATH not set properly */
+            exit(1);
+        }
 
-#ifdef __solaris__
-            /*
-             * If dmpath is not NULL, remove the data model specific string
-             * in the environment for the exec'ed child.
-             */
-            if (dmpath != NULL)
-                (void)UnsetEnv("LD_LIBRARY_PATH_64");
-#endif /* __solaris */
+        /*
+         * Unix systems document that they look at LD_LIBRARY_PATH only
+         * once at startup, so we have to re-exec the current executable
+         * to get the changed environment variable to have an effect.
+         */
 
-            newenvp = environ;
-        }
+        newenvp = environ;
+    }
 #endif /* SETENV_REQUIRED */
-        {
-            char *newexec = execname;
-            JLI_TraceLauncher("TRACER_MARKER:About to EXEC\n");
-            (void) fflush(stdout);
-            (void) fflush(stderr);
+    {
+        char *newexec = execname;
+        JLI_TraceLauncher("TRACER_MARKER:About to EXEC\n");
+        (void) fflush(stdout);
+        (void) fflush(stderr);
 #ifdef SETENV_REQUIRED
-            if (mustsetenv) {
-                execve(newexec, argv, newenvp);
-            } else {
-                execv(newexec, argv);
-            }
+        if (mustsetenv) {
+            execve(newexec, argv, newenvp);
+        } else {
+            execv(newexec, argv);
+        }
 #else /* !SETENV_REQUIRED */
-            execv(newexec, argv);
+        execv(newexec, argv);
 #endif /* SETENV_REQUIRED */
-            JLI_ReportErrorMessageSys(JRE_ERROR4, newexec);
-        }
-        exit(1);
+        JLI_ReportErrorMessageSys(JRE_ERROR4, newexec);
     }
+    exit(1);
 }
 
-/*
- * On Solaris VM choosing is done by the launcher (java.c),
- * bitsWanted is used by MacOSX,  on Solaris and Linux this.
- * parameter is unused.
- */
+
 static jboolean
 GetJVMPath(const char *jrepath, const char *jvmtype,
-           char *jvmpath, jint jvmpathsize, int bitsWanted)
+           char *jvmpath, jint jvmpathsize)
 {
     struct stat s;
 
--- a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -485,7 +485,7 @@
         return -1;
     }
     if (timeout) {
-        int ret = NET_Timeout(fd, timeout);
+        int ret = NET_Timeout(env, fd, timeout, JVM_NanoTime(env, 0));
         if (ret == 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Peek timed out");
@@ -576,7 +576,7 @@
     packetBufferOffset = (*env)->GetIntField(env, packet, dp_offsetID);
     packetBufferLen = (*env)->GetIntField(env, packet, dp_bufLengthID);
     if (timeout) {
-        int ret = NET_Timeout(fd, timeout);
+        int ret = NET_Timeout(env, fd, timeout, JVM_NanoTime(env, 0));
         if (ret == 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Receive timed out");
@@ -789,7 +789,7 @@
         retry = JNI_FALSE;
 
         if (timeout) {
-            int ret = NET_Timeout(fd, timeout);
+            int ret = NET_Timeout(env, fd, timeout, JVM_NanoTime(env, 0));
             if (ret <= 0) {
                 if (ret == 0) {
                     JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
--- a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
  */
 #include <errno.h>
 
+#include "jvm.h"
 #include "net_util.h"
 
 #include "java_net_SocketOptions.h"
@@ -231,7 +232,6 @@
 {
     jint localport = (*env)->GetIntField(env, this, psi_localportID);
     int len = 0;
-
     /* fdObj is the FileDescriptor field on this */
     jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
 
@@ -325,7 +325,8 @@
         /* connection not established immediately */
         if (connect_rv != 0) {
             socklen_t optlen;
-            jlong prevTime = JVM_CurrentTimeMillis(env, 0);
+            jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
+            jlong prevNanoTime = JVM_NanoTime(env, 0);
 
             if (errno != EINPROGRESS) {
                 NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
@@ -341,13 +342,13 @@
              * this thread.
              */
             while (1) {
-                jlong newTime;
+                jlong newNanoTime;
                 struct pollfd pfd;
                 pfd.fd = fd;
                 pfd.events = POLLOUT;
 
                 errno = 0;
-                connect_rv = NET_Poll(&pfd, 1, timeout);
+                connect_rv = NET_Poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
 
                 if (connect_rv >= 0) {
                     break;
@@ -360,13 +361,13 @@
                  * The poll was interrupted so adjust timeout and
                  * restart
                  */
-                newTime = JVM_CurrentTimeMillis(env, 0);
-                timeout -= (newTime - prevTime);
-                if (timeout <= 0) {
+                newNanoTime = JVM_NanoTime(env, 0);
+                nanoTimeout -= (newNanoTime - prevNanoTime);
+                if (nanoTimeout < NET_NSEC_PER_MSEC) {
                     connect_rv = 0;
                     break;
                 }
-                prevTime = newTime;
+                prevNanoTime = newNanoTime;
 
             } /* while */
 
@@ -593,7 +594,8 @@
     /* fields on this */
     int port;
     jint timeout = (*env)->GetIntField(env, this, psi_timeoutID);
-    jlong prevTime = 0;
+    jlong prevNanoTime = 0;
+    jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
     jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
 
     /* the FileDescriptor field on socket */
@@ -633,18 +635,19 @@
      */
     for (;;) {
         int ret;
+        jlong currNanoTime;
 
         /* first usage pick up current time */
-        if (prevTime == 0 && timeout > 0) {
-            prevTime = JVM_CurrentTimeMillis(env, 0);
+        if (prevNanoTime == 0 && nanoTimeout > 0) {
+            prevNanoTime = JVM_NanoTime(env, 0);
         }
 
         /* passing a timeout of 0 to poll will return immediately,
            but in the case of ServerSocket 0 means infinite. */
         if (timeout <= 0) {
-            ret = NET_Timeout(fd, -1);
+            ret = NET_Timeout(env, fd, -1, 0);
         } else {
-            ret = NET_Timeout(fd, timeout);
+            ret = NET_Timeout(env, fd, nanoTimeout / NET_NSEC_PER_MSEC, prevNanoTime);
         }
         if (ret == 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
@@ -676,17 +679,14 @@
         }
 
         /* ECONNABORTED or EWOULDBLOCK error so adjust timeout if there is one. */
-        if (timeout) {
-            jlong currTime = JVM_CurrentTimeMillis(env, 0);
-            timeout -= (currTime - prevTime);
-
-            if (timeout <= 0) {
-                JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
-                                "Accept timed out");
-                return;
-            }
-            prevTime = currTime;
+        currNanoTime = JVM_NanoTime(env, 0);
+        nanoTimeout -= (currNanoTime - prevNanoTime);
+        if (nanoTimeout < NET_NSEC_PER_MSEC) {
+            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
+                    "Accept timed out");
+            return;
         }
+        prevNanoTime = currNanoTime;
     }
 
     if (newfd < 0) {
--- a/jdk/src/java.base/unix/native/libnet/SocketInputStream.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "jvm.h"
 #include "net_util.h"
 
 #include "java_net_SocketInputStream.h"
@@ -48,9 +49,10 @@
 
 static int NET_ReadWithTimeout(JNIEnv *env, int fd, char *bufP, int len, long timeout) {
     int result = 0;
-    long prevtime = NET_GetCurrentTime(), newtime;
-    while (timeout > 0) {
-        result = NET_TimeoutWithCurrentTime(fd, timeout, prevtime);
+    jlong prevNanoTime = JVM_NanoTime(env, 0);
+    jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
+    while (nanoTimeout >= NET_NSEC_PER_MSEC) {
+        result = NET_Timeout(env, fd, nanoTimeout / NET_NSEC_PER_MSEC, prevNanoTime);
         if (result <= 0) {
             if (result == 0) {
                 JNU_ThrowByName(env, "java/net/SocketTimeoutException", "Read timed out");
@@ -68,10 +70,10 @@
         }
         result = NET_NonBlockingRead(fd, bufP, len);
         if (result == -1 && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) {
-            newtime = NET_GetCurrentTime();
-            timeout -= newtime - prevtime;
-            if (timeout > 0) {
-                prevtime = newtime;
+            jlong newtNanoTime = JVM_NanoTime(env, 0);
+            nanoTimeout -= newtNanoTime - prevNanoTime;
+            if (nanoTimeout >= NET_NSEC_PER_MSEC) {
+                prevNanoTime = newtNanoTime;
             }
         } else {
             break;
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,6 +49,7 @@
 #include <sys/sysctl.h>
 #endif
 
+#include "jvm.h"
 #include "net_util.h"
 
 #include "java_net_SocketOptions.h"
@@ -1543,11 +1544,12 @@
 jint
 NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
 {
-    jlong prevTime = JVM_CurrentTimeMillis(env, 0);
+    jlong prevNanoTime = JVM_NanoTime(env, 0);
+    jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
     jint read_rv;
 
     while (1) {
-        jlong newTime;
+        jlong newNanoTime;
         struct pollfd pfd;
         pfd.fd = fd;
         pfd.events = 0;
@@ -1559,36 +1561,18 @@
           pfd.events |= POLLOUT;
 
         errno = 0;
-        read_rv = NET_Poll(&pfd, 1, timeout);
+        read_rv = NET_Poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
 
-        newTime = JVM_CurrentTimeMillis(env, 0);
-        timeout -= (newTime - prevTime);
-        if (timeout <= 0) {
+        newNanoTime = JVM_NanoTime(env, 0);
+        nanoTimeout -= (newNanoTime - prevNanoTime);
+        if (nanoTimeout < NET_NSEC_PER_MSEC) {
           return read_rv > 0 ? 0 : -1;
         }
-        prevTime = newTime;
+        prevNanoTime = newNanoTime;
 
         if (read_rv > 0) {
           break;
         }
-
-
       } /* while */
-
-    return timeout;
+    return (nanoTimeout / NET_NSEC_PER_MSEC);
 }
-
-long NET_GetCurrentTime() {
-    struct timeval time;
-    gettimeofday(&time, NULL);
-    return (time.tv_sec * 1000 + time.tv_usec / 1000);
-}
-
-int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime) {
-    return NET_Timeout0(s, timeout, currentTime);
-}
-
-int NET_Timeout(int s, long timeout) {
-    long currentTime = (timeout > 0) ? NET_GetCurrentTime() : 0;
-    return NET_Timeout0(s, timeout, currentTime);
-}
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.h	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,10 @@
  * Macros and constants
  */
 
+#define NET_NSEC_PER_MSEC 1000000
+#define NET_NSEC_PER_SEC  1000000000
+#define NET_NSEC_PER_USEC 1000
+
 /* Defines SO_REUSEPORT */
 #ifndef SO_REUSEPORT
 #ifdef __linux__
@@ -68,12 +72,9 @@
  * Functions
  */
 
-int NET_Timeout(int s, long timeout);
-int NET_Timeout0(int s, long timeout, long currentTime);
+int NET_Timeout(JNIEnv *env, int s, long timeout, jlong  nanoTimeStamp);
 int NET_Read(int s, void* buf, size_t len);
 int NET_NonBlockingRead(int s, void* buf, size_t len);
-int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime);
-long NET_GetCurrentTime();
 int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
                  struct sockaddr *from, socklen_t *fromlen);
 int NET_ReadV(int s, const struct iovec * vector, int count);
--- a/jdk/src/java.base/windows/native/libjli/java_md.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.base/windows/native/libjli/java_md.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -158,32 +158,10 @@
                            char *jrepath, jint so_jrepath,
                            char *jvmpath, jint so_jvmpath,
                            char *jvmcfg,  jint so_jvmcfg) {
-    char * jvmtype;
+
+    char *jvmtype;
     int i = 0;
-    int running = CURRENT_DATA_MODEL;
-
-    int wanted = running;
-
     char** argv = *pargv;
-    for (i = 1; i < *pargc ; i++) {
-        if (JLI_StrCmp(argv[i], "-J-d64") == 0 || JLI_StrCmp(argv[i], "-d64") == 0) {
-            wanted = 64;
-            continue;
-        }
-        if (JLI_StrCmp(argv[i], "-J-d32") == 0 || JLI_StrCmp(argv[i], "-d32") == 0) {
-            wanted = 32;
-            continue;
-        }
-
-        if (IsJavaArgs() && argv[i][0] != '-')
-            continue;
-        if (argv[i][0] != '-')
-            break;
-    }
-    if (running != wanted) {
-        JLI_ReportErrorMessage(JRE_ERROR2, wanted);
-        exit(1);
-    }
 
     /* Find out where the JRE is that we will be using. */
     if (!GetJREPath(jrepath, so_jrepath)) {
--- a/jdk/src/java.desktop/macosx/native/include/jawt_md.h	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/macosx/native/include/jawt_md.h	Wed Jul 05 23:25:53 2017 +0200
@@ -37,7 +37,7 @@
 #endif
 
 /*
- * Mac OS X specific declarations for AWT native interface.
+ * MacOS specific declarations for AWT native interface.
  * See notes in jawt.h for an example of use.
  */
 
--- a/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java	Wed Jul 05 23:25:53 2017 +0200
@@ -339,11 +339,16 @@
     public Dimension getMinimumSize( JComponent c ) {
         Dimension d = super.getMinimumSize(c);
         if (XPStyle.getXP() != null) {
-            d.width += 5;
+            d.width += 7;
+            boolean isEditable = false;
+            if (c instanceof JComboBox) {
+                isEditable = ((JComboBox) c).isEditable();
+            }
+            d.height += isEditable ? 4 : 6;
         } else {
             d.width += 4;
+            d.height += 2;
         }
-        d.height += 2;
         return d;
     }
 
--- a/jdk/src/java.desktop/share/classes/java/awt/AlphaComposite.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/AlphaComposite.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,7 +74,7 @@
  *
  * <blockquote>
  * <table summary="layout">
- * <tr><th align=left>Factor&nbsp;&nbsp;<th align=left>Definition
+ * <tr><th style="text-align:left">Factor&nbsp;&nbsp;<th style="text-align:left">Definition
  * <tr><td><em>A<sub>s</sub></em><td>the alpha component of the source pixel
  * <tr><td><em>C<sub>s</sub></em><td>a color component of the source pixel in premultiplied form
  * <tr><td><em>A<sub>d</sub></em><td>the alpha component of the destination pixel
@@ -114,7 +114,7 @@
  *
  * <blockquote>
  * <table summary="layout">
- * <tr><th align=left>Factor&nbsp;&nbsp;<th align=left>Definition
+ * <tr><th style="text-align:left">Factor&nbsp;&nbsp;<th style="text-align:left">Definition
  * <tr><td><em>C<sub>sr</sub></em> <td>one of the raw color components of the source pixel
  * <tr><td><em>C<sub>dr</sub></em> <td>one of the raw color components of the destination pixel
  * <tr><td><em>A<sub>ac</sub></em>  <td>the "extra" alpha component from the AlphaComposite instance
@@ -205,7 +205,7 @@
  * appropriate conversions are performed before and after the compositing
  * operation.
  *
- * <h3><a name="caveats">Implementation Caveats</a></h3>
+ * <h3><a id="caveats">Implementation Caveats</a></h3>
  *
  * <ul>
  * <li>
--- a/jdk/src/java.desktop/share/classes/java/awt/Graphics2D.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/Graphics2D.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -78,7 +78,7 @@
  * <p>
  * When creating a {@code Graphics2D} object,  the
  * {@code GraphicsConfiguration}
- * specifies the <a name="deftransform">default transform</a> for
+ * specifies the <a id="deftransform">default transform</a> for
  * the target of the {@code Graphics2D} (a
  * {@link Component} or {@link Image}).  This default transform maps the
  * user space coordinate system to screen and printer device coordinates
@@ -129,7 +129,7 @@
  * of their particular rendering processes are:
  * <ol>
  * <li>
- * <b><a name="rendershape">{@code Shape} operations</a></b>
+ * <b><a id="rendershape">{@code Shape} operations</a></b>
  * <ol>
  * <li>
  * If the operation is a {@code draw(Shape)} operation, then
@@ -160,7 +160,7 @@
  * colors to render in device space.
  * </ol>
  * <li>
- * <b><a name=rendertext>Text operations</a></b>
+ * <b><a id=rendertext>Text operations</a></b>
  * <ol>
  * <li>
  * The following steps are used to determine the set of glyphs required
@@ -201,7 +201,7 @@
  * the colors to render in device space.
  * </ol>
  * <li>
- * <b><a name= renderingimage>{@code Image} Operations</a></b>
+ * <b><a id= renderingimage>{@code Image} Operations</a></b>
  * <ol>
  * <li>
  * The region of interest is defined by the bounding box of the source
--- a/jdk/src/java.desktop/share/classes/java/awt/GridBagLayout.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/GridBagLayout.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -122,7 +122,7 @@
  * are not.  Baseline relative values are calculated relative to the
  * baseline.  Valid values are:
  *
- * <center><table BORDER=0 WIDTH=800
+ * <center><table BORDER=0 style="width:800"
  *        SUMMARY="absolute, relative and baseline values as described above">
  * <tr>
  * <th><P style="text-align:left">Absolute Values</th>
@@ -198,7 +198,7 @@
  * The following figure shows a baseline layout and includes a
  * component that spans rows:
  * <center><table summary="Baseline Layout">
- * <tr ALIGN=CENTER>
+ * <tr style="text-align:center">
  * <td>
  * <img src="doc-files/GridBagLayout-baseline.png"
  *  alt="The following text describes this graphic (Figure 1)." style="float:center">
@@ -252,15 +252,15 @@
  * left-to-right container and Figure 3 shows the layout for a horizontal,
  * right-to-left container.
  *
- * <center><table WIDTH=600 summary="layout">
- * <tr ALIGN=CENTER>
+ * <center><table style="width:600" summary="layout">
+ * <tr style="text-align:center">
  * <td>
  * <img src="doc-files/GridBagLayout-1.gif" alt="The preceding text describes this graphic (Figure 1)." style="float:center; margin: 7px 10px;">
  * </td>
  * <td>
  * <img src="doc-files/GridBagLayout-2.gif" alt="The preceding text describes this graphic (Figure 2)." style="float:center; margin: 7px 10px;">
  * </td>
- * <tr ALIGN=CENTER>
+ * <tr style="text-align:center">
  * <td>Figure 2: Horizontal, Left-to-Right</td>
  * <td>Figure 3: Horizontal, Right-to-Left</td>
  * </tr>
--- a/jdk/src/java.desktop/share/classes/java/awt/GridLayout.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/GridLayout.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -55,20 +55,20 @@
  * If the container's {@code ComponentOrientation} property is horizontal
  * and right-to-left, the example produces the output shown in Figure 2.
  *
- * <table style="float:center" WIDTH=600 summary="layout">
- * <tr ALIGN=CENTER>
+ * <table style="float:center;width:600" summary="layout">
+ * <tr style="text-align:center">
  * <td><img SRC="doc-files/GridLayout-1.gif"
  *      alt="Shows 6 buttons in rows of 2. Row 1 shows buttons 1 then 2.
  * Row 2 shows buttons 3 then 4. Row 3 shows buttons 5 then 6.">
  * </td>
  *
- * <td ALIGN=CENTER><img SRC="doc-files/GridLayout-2.gif"
- *                   alt="Shows 6 buttons in rows of 2. Row 1 shows buttons 2 then 1.
+ * <td style="text-align:center"><img SRC="doc-files/GridLayout-2.gif"
+ *              alt="Shows 6 buttons in rows of 2. Row 1 shows buttons 2 then 1.
  * Row 2 shows buttons 4 then 3. Row 3 shows buttons 6 then 5.">
  * </td>
  * </tr>
  *
- * <tr ALIGN=CENTER>
+ * <tr style="text-align:center">
  * <td>Figure 1: Horizontal, Left-to-Right</td>
  *
  * <td>Figure 2: Horizontal, Right-to-Left</td>
--- a/jdk/src/java.desktop/share/classes/java/awt/LinearGradientPaint.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/LinearGradientPaint.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -91,10 +91,9 @@
  * <p>
  * This image demonstrates the example code above for each
  * of the three cycle methods:
- * <center>
+ * <p style="text-align:center">
  * <img src = "doc-files/LinearGradientPaint.png"
  * alt="image showing the output of the example code">
- * </center>
  *
  * @see java.awt.Paint
  * @see java.awt.Graphics2D#setPaint
--- a/jdk/src/java.desktop/share/classes/java/awt/MenuBar.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/MenuBar.java	Wed Jul 05 23:25:53 2017 +0200
@@ -46,7 +46,7 @@
  * the menu bar with a {@code Frame} object, call the
  * frame's {@code setMenuBar} method.
  * <p>
- * <A NAME="mbexample"></A><!-- target for cross references -->
+ * <a id="mbexample"></a><!-- target for cross references -->
  * This is what a menu bar might look like:
  * <p>
  * <img src="doc-files/MenuBar-1.gif"
--- a/jdk/src/java.desktop/share/classes/java/awt/RadialGradientPaint.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/RadialGradientPaint.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -79,18 +79,18 @@
  * The gradient color proportions are equal for any particular line drawn
  * from the focus point. The following figure shows that the distance AB
  * is equal to the distance BC, and the distance AD is equal to the distance DE.
- * <center>
+ * <p style="text-align:center">
  * <img src = "doc-files/RadialGradientPaint-3.png" alt="image showing the
  * distance AB=BC, and AD=DE">
- * </center>
+ * <p>
  * If the gradient and graphics rendering transforms are uniformly scaled and
  * the user sets the focus so that it coincides with the center of the circle,
  * the gradient color proportions are equal for any line drawn from the center.
  * The following figure shows the distances AB, BC, AD, and DE. They are all equal.
- * <center>
+ * <p style="text-align:center">
  * <img src = "doc-files/RadialGradientPaint-4.png" alt="image showing the
  * distance of AB, BC, AD, and DE are all equal">
- * </center>
+ * <p>
  * Note that some minor variations in distances may occur due to sampling at
  * the granularity of a pixel.
  * If no cycle method is specified, {@code NO_CYCLE} will be chosen by
@@ -116,11 +116,9 @@
  * <p>
  * This image demonstrates the example code above, with default
  * (centered) focus for each of the three cycle methods:
- * <center>
+ * <p style="text-align:center">
  * <img src = "doc-files/RadialGradientPaint-1.png" alt="image showing the
  * output of the sameple code">
- * </center>
- *
  * <p>
  * It is also possible to specify a non-centered focus point, as
  * in the following code:
@@ -139,10 +137,9 @@
  * <p>
  * This image demonstrates the previous example code, with non-centered
  * focus for each of the three cycle methods:
- * <center>
+ * <p style="text-align:center">
  * <img src = "doc-files/RadialGradientPaint-2.png" alt="image showing the
  * output of the sample code">
- * </center>
  *
  * @see java.awt.Paint
  * @see java.awt.Graphics2D#setPaint
--- a/jdk/src/java.desktop/share/classes/java/awt/Rectangle.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/Rectangle.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
  * that create a {@code Rectangle}, and the methods that can modify
  * one, do not prevent setting a negative value for width or height.
  * <p>
- * <a name="Empty">
+ * <a id="Empty">
  * A {@code Rectangle} whose width or height is exactly zero has location
  * along those axes with zero dimension, but is otherwise considered empty.</a>
  * The {@link #isEmpty} method will return true for such a {@code Rectangle}.
@@ -49,7 +49,7 @@
  * will include the location of the {@code Rectangle} on that axis in the
  * result as if the {@link #add(Point)} method were being called.
  * <p>
- * <a name="NonExistent">
+ * <a id="NonExistent">
  * A {@code Rectangle} whose width or height is negative has neither
  * location nor dimension along those axes with negative dimensions.
  * Such a {@code Rectangle} is treated as non-existent along those axes.
--- a/jdk/src/java.desktop/share/classes/java/awt/Shape.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/Shape.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
  * object that describes the trajectory path of the {@code Shape}
  * outline.
  * <p>
- * <a name="def_insideness"><b>Definition of insideness:</b></a>
+ * <a id="def_insideness"><b>Definition of insideness:</b></a>
  * A point is considered to lie inside a
  * {@code Shape} if and only if:
  * <ul>
--- a/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/dnd/DragSourceContext.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,7 +65,7 @@
  * itself between the platform and the
  * listeners provided by the initiator of the drag operation.
  * <p>
- * <a name="defaultCursor"></a>
+ * <a id="defaultCursor"></a>
  * By default, {@code DragSourceContext} sets the cursor as appropriate
  * for the current state of the drag and drop operation. For example, if
  * the user has chosen {@linkplain DnDConstants#ACTION_MOVE the move action},
--- a/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/font/TextAttribute.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -96,14 +96,14 @@
  * </UL>
  *
  * <h4>Summary of attributes</h4>
- * <table style="float:center" border="0" cellspacing="0" cellpadding="2" width="95%"
+ * <table style="float:center;width:95%" border="0" cellspacing="0" cellpadding="2"
  *     summary="Key, value type, principal constants, and default value
  *     behavior of all TextAttributes">
  * <tr style="background-color:#ccccff">
- * <th valign="TOP" align="CENTER">Key</th>
- * <th valign="TOP" align="CENTER">Value Type</th>
- * <th valign="TOP" align="CENTER">Principal Constants</th>
- * <th valign="TOP" align="CENTER">Default Value</th>
+ * <th valign="TOP" style="text-align:center">Key</th>
+ * <th valign="TOP" style="text-align:center">Value Type</th>
+ * <th valign="TOP" style="text-align:center">Principal Constants</th>
+ * <th valign="TOP" style="text-align:center">Default Value</th>
  * </tr>
  * <tr>
  * <td valign="TOP">{@link #FAMILY}</td>
--- a/jdk/src/java.desktop/share/classes/java/awt/geom/AffineTransform.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/geom/AffineTransform.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
  *      [ y'] = [  m10  m11  m12  ] [ y ] = [ m10x + m11y + m12 ]
  *      [ 1 ]   [   0    0    1   ] [ 1 ]   [         1         ]
  * </pre>
- * <h3><a name="quadrantapproximation">Handling 90-Degree Rotations</a></h3>
+ * <h3><a id="quadrantapproximation">Handling 90-Degree Rotations</a></h3>
  * <p>
  * In some variations of the {@code rotate} methods in the
  * {@code AffineTransform} class, a double-precision argument
--- a/jdk/src/java.desktop/share/classes/java/awt/geom/Arc2D.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/geom/Arc2D.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,11 +33,11 @@
  * start angle, angular extent (length of the arc), and a closure type
  * ({@code OPEN}, {@code CHORD}, or {@code PIE}).
  * <p>
- * <a name="inscribes">
+ * <a id="inscribes">
  * The arc is a partial section of a full ellipse which
  * inscribes the framing rectangle of its parent</a> {@link RectangularShape}.
  *
- * <a name="angles">
+ * <a id="angles">
  * The angles are specified relative to the non-square
  * framing rectangle such that 45 degrees always falls on the line from
  * the center of the ellipse to the upper right corner of the framing
--- a/jdk/src/java.desktop/share/classes/java/awt/geom/Line2D.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/geom/Line2D.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -618,7 +618,7 @@
      *           specified line segment
      * @param y2 the Y coordinate of the end point of the
      *           specified line segment
-     * @return {@code <true>} if this line segment and the specified line segment
+     * @return {@code true} if this line segment and the specified line segment
      *                  intersect each other; {@code false} otherwise.
      * @since 1.2
      */
--- a/jdk/src/java.desktop/share/classes/java/awt/geom/Path2D.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/geom/Path2D.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -846,7 +846,7 @@
          * path.
          *
          * @serialData
-         * <a name="Path2DSerialData"><!-- --></a>
+         * <a id="Path2DSerialData"><!-- --></a>
          * <ol>
          * <li>The default serializable fields.
          * There are no default serializable fields as of 1.6.
@@ -1605,7 +1605,7 @@
          * path.
          *
          * @serialData
-         * <a name="Path2DSerialData"><!-- --></a>
+         * <a id="Path2DSerialData"><!-- --></a>
          * <ol>
          * <li>The default serializable fields.
          * There are no default serializable fields as of 1.6.
--- a/jdk/src/java.desktop/share/classes/java/awt/im/spi/package-info.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/im/spi/package-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -33,7 +33,7 @@
  * languages and the use of entirely different input mechanisms, such as
  * handwriting recognition.
  *
- * <h2><a name="Packaging"></a>Packaging Input Methods</h2>
+ * <h2><a id="Packaging"></a>Packaging Input Methods</h2>
  * Input methods can be made available by adding them to the application's class
  * path. The main JAR file of an input method must contain the file:
  * <pre>
@@ -61,14 +61,14 @@
  * that loading of the class implementing {@code InputMethod} can be deferred
  * until actually needed.
  *
- * <h2><a name="Loading"></a>Loading Input Methods</h2>
+ * <h2><a id="Loading"></a>Loading Input Methods</h2>
  * The input method framework will usually defer loading of input  method
  * classes until they are absolutely needed. It loads only the
  * {@code InputMethodDescriptor} implementations during AWT initialization. It
  * loads an {@code InputMethod} implementation when the input method has been
  * selected.
  *
- * <h2><a name="PeeredComponents"></a>Java Input Methods and Peered Text
+ * <h2><a id="PeeredComponents"></a>Java Input Methods and Peered Text
  * Components</h2>
  * The Java input method framework intends to support all combinations of input
  * methods (host input methods and Java input methods) and components (peered
--- a/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/AbstractMultiResolutionImage.java	Wed Jul 05 23:25:53 2017 +0200
@@ -29,7 +29,8 @@
 
 /**
  * This class provides default implementations of several {@code Image} methods
- * for classes that want to implement the {@MultiResolutionImage} interface.
+ * for classes that want to implement the {@code MultiResolutionImage}
+ * interface.
  *
  * For example,
  * <pre> {@code
--- a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferByte.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferByte.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
  * Values stored in the byte array(s) of this {@code DataBuffer} are treated as
  * unsigned values.
  * <p>
- * <a name="optimizations">
+ * <a id="optimizations">
  * Note that some implementations may function more efficiently
  * if they can maintain control over how the data for an image is
  * stored.
--- a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferDouble.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferDouble.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@
  * This class extends {@code DataBuffer} and stores data internally
  * in {@code double} form.
  * <p>
- * <a name="optimizations">
+ * <a id="optimizations">
  * Note that some implementations may function more efficiently
  * if they can maintain control over how the data for an image is
  * stored.
--- a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferFloat.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferFloat.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@
  * This class extends {@code DataBuffer} and stores data internally
  * in {@code float} form.
  * <p>
- * <a name="optimizations">
+ * <a id="optimizations">
  * Note that some implementations may function more efficiently
  * if they can maintain control over how the data for an image is
  * stored.
--- a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferInt.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferInt.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
  * This class extends {@code DataBuffer} and stores data internally
  * as integers.
  * <p>
- * <a name="optimizations">
+ * <a id="optimizations">
  * Note that some implementations may function more efficiently
  * if they can maintain control over how the data for an image is
  * stored.
--- a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferShort.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferShort.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@
 /**
  * This class extends {@code DataBuffer} and stores data internally as shorts.
  * <p>
- * <a name="optimizations">
+ * <a id="optimizations">
  * Note that some implementations may function more efficiently
  * if they can maintain control over how the data for an image is
  * stored.
--- a/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferUShort.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/DataBufferUShort.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
  * shorts.  Values stored in the short array(s) of this {@code DataBuffer}
  * are treated as unsigned values.
  * <p>
- * <a name="optimizations">
+ * <a id="optimizations">
  * Note that some implementations may function more efficiently
  * if they can maintain control over how the data for an image is
  * stored.
--- a/jdk/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/image/IndexColorModel.java	Wed Jul 05 23:25:53 2017 +0200
@@ -55,7 +55,7 @@
  * {@code IndexColorModel} objects are never pre-multiplied with
  * the alpha components.
  * <p>
- * <a name="transparency">
+ * <a id="transparency">
  * The transparency of an {@code IndexColorModel} object is
  * determined by examining the alpha components of the colors in the
  * colormap and choosing the most specific value after considering
@@ -86,7 +86,7 @@
  * and {@code getNumComponents} returns 4.
  *
  * <p>
- * <a name="index_values">
+ * <a id="index_values">
  * The values used to index into the colormap are taken from the least
  * significant <em>n</em> bits of pixel representations where
  * <em>n</em> is based on the pixel size specified in the constructor.
--- a/jdk/src/java.desktop/share/classes/java/awt/package-info.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/java/awt/package-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -35,10 +35,10 @@
  * components can fire. See AWTEvent for a description of the AWT event model.
  * <p>
  * A container is a component that can contain components and other containers.
- * A con tainer can also have a layout manager that controls the visual
- * placement of components in the container. The AWT package contains several
- * layout manager classes and an interface for building your own layout manager.
- * See Container and LayoutManager for more information.
+ * A container can also have a layout manager that controls the visual placement
+ * of components in the container. The AWT package contains several layout
+ * manager classes and an interface for building your own layout manager. See
+ * Container and LayoutManager for more information.
  * <p>
  * Each {@code Component} object is limited in its maximum size and its location
  * because the values are stored as an integer. Also, a platform may further
@@ -54,6 +54,8 @@
  * <ul>
  *     <li><a href="doc-files/FocusSpec.html">The AWT Focus Subsystem</a>
  *     <li><a href="doc-files/Modality.html">The AWT Modality</a>
+ *     <li><a href="{@docRoot}/../specs/AWT_Native_Interface.html">
+ *                  The Java AWT Native Interface (JAWT)</a>
  * </ul>
  *
  * @since 1.0
--- a/jdk/src/java.desktop/share/classes/javax/accessibility/package-info.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/accessibility/package-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -37,7 +37,7 @@
  * interfaces, and 6 Java programming language classes. These are described
  * below.
  *
- * <h3><a name="Accessible"></a><a href="Accessible.html">Interface
+ * <h3><a id="Accessible"></a><a href="Accessible.html">Interface
  * Accessible</a></h3>
  * <a href="Accessible.html">Interface Accessible</a> is the main interface of
  * the Java Accessibility API. All components that support the Java
@@ -48,7 +48,7 @@
  * object that is part of the user interface of a Java application, if that
  * program is to be compatible with assistive technologies.
  *
- * <h3><a name="AccessibleContext"></a><a href="AccessibleContext.html">Class
+ * <h3><a id="AccessibleContext"></a><a href="AccessibleContext.html">Class
  * AccessibleContext</a></h3>
  * <a href="AccessibleContext.html">AccessibleContext</a> represents the minimum
  * information all accessible objects return and is obtained by calling the
@@ -108,7 +108,7 @@
  *     called on an AccessibleContext.</li>
  * </ul>
  *
- * <h3><a name="AccessibleRole"></a><a href="AccessibleRole.html">Class
+ * <h3><a id="AccessibleRole"></a><a href="AccessibleRole.html">Class
  * AccessibleRole</a></h3>
  * This class encapsulates the Accessible object's role in the user interface
  * and is obtained by calling the {@code getAccessibleRole} method on an
@@ -123,7 +123,7 @@
  * programmer-defined roles can be added in the future without needing to modify
  * the base class.
  *
- * <h3><a name="AccessibleState"></a><a href="AccessibleState.html">Class
+ * <h3><a id="AccessibleState"></a><a href="AccessibleState.html">Class
  * AccessibleState</a></h3>
  * This class encapsulates a particular state of the Accessible object.
  * Accessible states include things like "Armed", "Busy", "Checked", "Focused",
@@ -142,7 +142,7 @@
  * additional, programmer-defined roles can be added in the future without
  * needing to modify the base class.
  *
- * <h3><a name="AccessibleStateSet"></a><a href="AccessibleStateSet.html">Class
+ * <h3><a id="AccessibleStateSet"></a><a href="AccessibleStateSet.html">Class
  * AccessibleStateSet</a></h3>
  * This class encapsulates a collection of states of the Accessible object and
  * is obtained by calling the {@code getAccessibleStateSet} method on an
@@ -152,7 +152,7 @@
  * class provide for retrieving the individual
  * <a href="#AccessibleState">AccessibleStates</a> on the state set.
  *
- * <h3><a name="AccessibleBundle"></a><a href="AccessibleBundle.html">Class
+ * <h3><a id="AccessibleBundle"></a><a href="AccessibleBundle.html">Class
  * AccessibleBundle</a></h3>
  * This class is used to maintain a strongly typed enumeration. It is the super
  * class of both the <a href="#AccessibleRole">AccessibleRole</a> and
@@ -161,7 +161,7 @@
  * <a href="#AccessibleRole">AccessibleRole</a> and
  * <a href="#AccessibleState">AccessibleState</a> classes.
  *
- * <h3><a name="AccessibleAction"></a><a href="AccessibleAction.html">Interface
+ * <h3><a id="AccessibleAction"></a><a href="AccessibleAction.html">Interface
  * AccessibleAction</a></h3>
  * The <a href="AccessibleAction.html">AccessibleAction</a> interface should be
  * supported by any object that can perform one or more actions. This interface
@@ -177,7 +177,7 @@
  * <a href="#AccessibleContext">AccessibleContext</a>. If the return value is
  * not null, the object supports this interface.
  *
- * <h3> <a name="AccessibleComponent"></a><a href="AccessibleComponent.html">
+ * <h3> <a id="AccessibleComponent"></a><a href="AccessibleComponent.html">
  * Interface AccessibleComponent</a></h3>
  * The <a href="AccessibleComponent.html">AccessibleComponent</a> interface
  * should be supported by any object that is rendered on the screen. This
@@ -190,7 +190,7 @@
  * <a href="#AccessibleContext">AccessibleContext</a>. If the return value is
  * not null, the object supports this interface.
  *
- * <h3><a name="AccessibleSelection"></a><a href="AccessibleSelection.html">
+ * <h3><a id="AccessibleSelection"></a><a href="AccessibleSelection.html">
  * Interface AccessibleSelection</a></h3>
  * The <a href="AccessibleSelection.html">AccessibleSelection</a> interface
  * provides the standard mechanism for an assistive technology to determine what
@@ -206,7 +206,7 @@
  * <a href="#AccessibleContext">AccessibleContext</a>. If the return value is
  * not null, the object supports this interface.
  *
- * <h3><a name="AccessibleText"></a><a href="AccessibleText.html">Interface
+ * <h3><a id="AccessibleText"></a><a href="AccessibleText.html">Interface
  * AccessibleText</a></h3>
  * Interface <a href="AccessibleText.html">AccessibleText</a> is the contract
  * for making rich, editable text Accessible. Not all text displayed on the
@@ -230,7 +230,7 @@
  * <a href="#AccessibleContext">AccessibleContext</a>. If the return value is
  * not null, the object supports this interface.
  *
- * <h3><a name="AccessibleHypertext"></a> <a href="AccessibleHypertext.html">
+ * <h3><a id="AccessibleHypertext"></a> <a href="AccessibleHypertext.html">
  * Interface AccessibleHypertext</a></h3>
  * The <a href="AccessibleHypertext.html">AccessibleHypertext</a> interface
  * should be supported by any object that presents hypertext information on the
@@ -246,7 +246,7 @@
  * class which extends AccessibleHypertext, then that object supports
  * AccessibleHypertext.
  *
- * <h3><a name="AccessibleHyperlink"></a><a href="AccessibleHyperlink.html">
+ * <h3><a id="AccessibleHyperlink"></a><a href="AccessibleHyperlink.html">
  * Interface AccessibleHyperlink</a></h3>
  * An object that is a hyperlink should support the
  * <a href="AccessibleHyperlink.html">AccessibleHyperlink</a> interface.&nbsp;
@@ -254,7 +254,7 @@
  * getLink method on an <a href="#AccessibleHypertext">AccessibleHypertext</a>
  * object.
  *
- * <h3><a name="AccessibleValue"></a><a href="AccessibleValue.html">Interface
+ * <h3><a id="AccessibleValue"></a><a href="AccessibleValue.html">Interface
  * AccessibleValue</a></h3>
  * The <a href="AccessibleValue.html">AccessibleValue</a> interface should be
  * supported by any object that supports a numerical value (e.g., a scroll bar).
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFDirectory.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,8 +63,8 @@
  * <p>A {@code TIFFDirectory} is aware of the tag numbers in the
  * group of {@link TIFFTagSet}s associated with it. When
  * a {@code TIFFDirectory} is created from a native image metadata
- * object, these tag sets are derived from the <tt>tagSets</tt> attribute
- * of the <tt>TIFFIFD</tt> node.</p>
+ * object, these tag sets are derived from the {@code tagSets} attribute
+ * of the {@code TIFFIFD} node.</p>
  *
  * <p>A {@code TIFFDirectory} might also have a parent {@link TIFFTag}.
  * This will occur if the directory represents an IFD other than the root
@@ -73,8 +73,8 @@
  * {@link TIFFTag#isIFDPointer} method of this parent {@code TIFFTag}
  * must return {@code true}.  When a {@code TIFFDirectory} is
  * created from a native image metadata object, the parent tag set is set
- * from the <tt>parentTagName</tt> attribute of the corresponding
- * <tt>TIFFIFD</tt> node. Note that a {@code TIFFDirectory} instance
+ * from the {@code parentTagName} attribute of the corresponding
+ * {@code TIFFIFD} node. Note that a {@code TIFFDirectory} instance
  * which has a non-{@code null} parent tag will be contained in the
  * data field of a {@code TIFFField} instance which has a tag field
  * equal to the contained directory's parent tag.</p>
@@ -133,8 +133,8 @@
      * an image metadata object. The supplied object must support an image
      * metadata format supported by the TIFF {@link javax.imageio.ImageWriter}
      * plug-in. This will usually be either the TIFF native image metadata
-     * format <tt>javax_imageio_tiff_image_1.0</tt> or the Java
-     * Image I/O standard metadata format <tt>javax_imageio_1.0</tt>.
+     * format {@code javax_imageio_tiff_image_1.0} or the Java
+     * Image I/O standard metadata format {@code javax_imageio_1.0}.
      *
      * @param tiffImageMetadata A metadata object which supports a compatible
      * image metadata format.
--- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java	Wed Jul 05 23:25:53 2017 +0200
@@ -62,7 +62,7 @@
  *
  * <tr>
  * <td>
- * <tt>BYTE</tt>
+ * {@code BYTE}
  * </td>
  * <td>
  * {@link TIFFTag#TIFF_BYTE}
@@ -77,7 +77,7 @@
  *
  * <tr>
  * <td>
- * <tt>ASCII</tt>
+ * {@code ASCII}
  * </td>
  * <td>
  * {@link TIFFTag#TIFF_ASCII}
@@ -92,7 +92,7 @@
  *
  * <tr>
  * <td>
- * <tt>SHORT</tt>
+ * {@code SHORT}
  * </td>
  * <td>
  * {@link TIFFTag#TIFF_SHORT}
@@ -107,7 +107,7 @@
  *
  * <tr>
  * <td>
- * <tt>LONG</tt>
+ * {@code LONG}
  * </td>
  * <td>
  * {@link TIFFTag#TIFF_LONG}
@@ -122,7 +122,7 @@
  *
  * <tr>
  * <td>
- * <tt>RATIONAL</tt>
+ * {@code RATIONAL}
  * </td>
  * <td>
  * {@link TIFFTag#TIFF_RATIONAL}
@@ -137,7 +137,7 @@
  *
  * <tr>
  * <td>
- * <tt>SBYTE</tt>
+ * {@code SBYTE}
  * </td>
  * <td>
  * {@link TIFFTag#TIFF_SBYTE}
@@ -152,7 +152,7 @@
  *
  * <tr>
  * <td>
- * <tt>UNDEFINED</tt>
+ * {@code UNDEFINED}
  * </td>
  * <td>
  * {@link TIFFTag#TIFF_UNDEFINED}
@@ -167,7 +167,7 @@
  *
  * <tr>
  * <td>
- * <tt>SSHORT</tt>
+ * {@code SSHORT}
  * </td>
  * <td>
  * {@link TIFFTag#TIFF_SSHORT}
@@ -182,7 +182,7 @@
  *
  * <tr>
  * <td>
- * <tt>SLONG</tt>
+ * {@code SLONG}
  * </td>
  * <td>
  * {@link TIFFTag#TIFF_SLONG}
@@ -197,7 +197,7 @@
  *
  * <tr>
  * <td>
- * <tt>SRATIONAL</tt>
+ * {@code SRATIONAL}
  * </td>
  * <td>
  * {@link TIFFTag#TIFF_SRATIONAL}
@@ -212,7 +212,7 @@
  *
  * <tr>
  * <td>
- * <tt>FLOAT</tt>
+ * {@code FLOAT}
  * </td>
  * <td>
  * {@link TIFFTag#TIFF_FLOAT}
@@ -227,7 +227,7 @@
  *
  * <tr>
  * <td>
- * <tt>DOUBLE</tt>
+ * {@code DOUBLE}
  * </td>
  * <td>
  * {@link TIFFTag#TIFF_DOUBLE}
@@ -242,7 +242,7 @@
  *
  * <tr>
  * <td>
- * <tt>IFD</tt>
+ * {@code IFD}
  * </td>
  * <td>
  * {@link TIFFTag#TIFF_IFD_POINTER}
@@ -941,14 +941,14 @@
 
     /**
      * Returns the {@code TIFFField} as a node named either
-     * <tt>"TIFFField"</tt> or <tt>"TIFFIFD"</tt> as described in the
+     * {@code "TIFFField"} or {@code "TIFFIFD"} as described in the
      * TIFF native image metadata specification. The node will be named
-     * <tt>"TIFFIFD"</tt> if and only if {@link #hasDirectory()} returns
+     * {@code "TIFFIFD"} if and only if {@link #hasDirectory()} returns
      * {@code true} and the field's type is either {@link TIFFTag#TIFF_LONG}
      * or {@link TIFFTag#TIFF_IFD_POINTER}.
      *
-     * @return a {@code Node} named <tt>"TIFFField"</tt> or
-     * <tt>"TIFFIFD"</tt>.
+     * @return a {@code Node} named {@code "TIFFField"} or
+     * {@code "TIFFIFD"}.
      */
     public Node getAsNativeNode() {
         return new TIFFFieldNode(this);
--- a/jdk/src/java.desktop/share/classes/javax/print/MimeType.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/print/MimeType.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,6 @@
  * <LI>
  * Since not all Java profiles include the AWT, the Jini Print Service should
  * not depend on an AWT class.
- * <P>
  * <LI>
  * The implementation of class java.awt.datatransfer.MimeType does not
  * guarantee
@@ -76,7 +75,6 @@
  * <LI> Quoting backslash characters inside parameter values are removed.
  * <LI> The parameters are arranged in ascending order of parameter name.
  * </UL>
- * <P>
  *
  * @author  Alan Kaminsky
  */
--- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/Finishings.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@
  * for purposes of finishing.
  * <P>
  * Standard Finishings values are:
- * <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100% SUMMARY="layout">
+ * <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 style="width:100%" SUMMARY="layout">
  * <TR>
  * <TD STYLE="WIDTH:10%">
  * &nbsp;
@@ -76,7 +76,7 @@
  * <P>
  * The following Finishings values are more specific; they indicate a
  * corner or an edge as if the document were a portrait document:
- * <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100% SUMMARY="layout">
+ * <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 style="width:100%" SUMMARY="layout">
  * <TR>
  * <TD STYLE="WIDTH:10%">
  * &nbsp;
--- a/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/print/attribute/standard/MultipleDocumentHandling.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,7 +70,7 @@
  * The standard MultipleDocumentHandling values are:
  * <UL>
  * <LI>
- * <a NAME="sdfi"></a>{@link #SINGLE_DOCUMENT
+ * <a id="sdfi"></a>{@link #SINGLE_DOCUMENT
  * <B>SINGLE_DOCUMENT</B>}. If a print job has multiple
  * documents -- say, the document data is called {@code a} and
  * {@code b} -- then the result of processing all the document data
@@ -85,7 +85,7 @@
  * each copy ({@code a(*),b(*)}) to start on a new media sheet.
  *
  * <LI>
- * <a NAME="sducfi"></a>{@link #SEPARATE_DOCUMENTS_UNCOLLATED_COPIES
+ * <a id="sducfi"></a>{@link #SEPARATE_DOCUMENTS_UNCOLLATED_COPIES
  * <B>SEPARATE_DOCUMENTS_UNCOLLATED_COPIES</B>}. If a print job
  * has multiple documents -- say, the document data is called {@code a} and
  * {@code b} -- then the result of processing the data in each document
@@ -98,7 +98,7 @@
  * {@code a(*),a(*),...,b(*),b(*)...}.
  *
  * <LI>
- * <a NAME="sdccfi"></a>{@link #SEPARATE_DOCUMENTS_COLLATED_COPIES
+ * <a id="sdccfi"></a>{@link #SEPARATE_DOCUMENTS_COLLATED_COPIES
  * <B>SEPARATE_DOCUMENTS_COLLATED_COPIES</B>}. If a print job
  * has multiple documents -- say, the document data is called {@code a} and
  * {@code b} -- then the result of processing the data in each document
@@ -111,7 +111,7 @@
  * {@code a(*),b(*),a(*),b(*),...}.
  *
  * <LI>
- * <a NAME="sdnsfi"></a>{@link #SINGLE_DOCUMENT_NEW_SHEET
+ * <a id="sdnsfi"></a>{@link #SINGLE_DOCUMENT_NEW_SHEET
  * <B>SINGLE_DOCUMENT_NEW_SHEET</B>}. Same as SINGLE_DOCUMENT,
  * except that the printer must ensure that the first impression of each
  * document instance in the job is placed on a new media sheet. This value
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaMessage.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MetaMessage.java	Wed Jul 05 23:25:53 2017 +0200
@@ -59,7 +59,7 @@
      *
      * @see MidiMessage#getStatus
      */
-    public static final int META                                                = 0xFF; // 255
+    public static final int META = 0xFF; // 255
 
     /**
      * The length of the actual message in the data array. This is used to
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiMessage.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/MidiMessage.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,15 +47,15 @@
  * {@code MidiMessage} includes methods to get, but not set, these values.
  * Setting them is a subclass responsibility.
  * <p>
- * <a name="integersVsBytes"></a> The MIDI standard expresses MIDI data in
+ * <a id="integersVsBytes"></a> The MIDI standard expresses MIDI data in
  * bytes. However, because Java<sup>TM</sup> uses signed bytes, the Java Sound
  * API uses integers instead of bytes when expressing MIDI data. For example,
  * the {@link #getStatus()} method of {@code MidiMessage} returns MIDI status
  * bytes as integers. If you are processing MIDI data that originated outside
  * Java Sound and now is encoded as signed bytes, the bytes can be
  * converted to integers using this conversion:
- *
- * <center>{@code int i = (int)(byte & 0xFF)}</center>
+ * <p style="text-align:center">
+ * {@code int i = (int)(byte & 0xFF)}
  * <p>
  * If you simply need to pass a known MIDI byte value as a method parameter, it
  * can be expressed directly as an integer, using (for example) decimal or
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequence.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequence.java	Wed Jul 05 23:25:53 2017 +0200
@@ -58,7 +58,7 @@
      *
      * @see #Sequence(float, int)
      */
-    public static final float PPQ                                                       = 0.0f;
+    public static final float PPQ = 0.0f;
 
     /**
      * The SMPTE-based timing type with 24 frames per second (resolution is
@@ -66,7 +66,7 @@
      *
      * @see #Sequence(float, int)
      */
-    public static final float SMPTE_24                                          = 24.0f;
+    public static final float SMPTE_24 = 24.0f;
 
     /**
      * The SMPTE-based timing type with 25 frames per second (resolution is
@@ -74,7 +74,7 @@
      *
      * @see #Sequence(float, int)
      */
-    public static final float SMPTE_25                                          = 25.0f;
+    public static final float SMPTE_25 = 25.0f;
 
     /**
      * The SMPTE-based timing type with 29.97 frames per second (resolution is
@@ -82,7 +82,7 @@
      *
      * @see #Sequence(float, int)
      */
-    public static final float SMPTE_30DROP                                      = 29.97f;
+    public static final float SMPTE_30DROP = 29.97f;
 
     /**
      * The SMPTE-based timing type with 30 frames per second (resolution is
@@ -90,7 +90,7 @@
      *
      * @see #Sequence(float, int)
      */
-    public static final float SMPTE_30                                          = 30.0f;
+    public static final float SMPTE_30 = 30.0f;
 
     // Variables
 
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequencer.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/Sequencer.java	Wed Jul 05 23:25:53 2017 +0200
@@ -733,7 +733,7 @@
          * information from its internal clock. This is not a legal slave sync
          * mode.
          */
-        public static final SyncMode INTERNAL_CLOCK             = new SyncMode("Internal Clock");
+        public static final SyncMode INTERNAL_CLOCK = new SyncMode("Internal Clock");
 
         /**
          * A master or slave synchronization mode that specifies the use of MIDI
@@ -745,7 +745,7 @@
          * receiver. MIDI clock messages are sent at a rate of 24 per quarter
          * note.
          */
-        public static final SyncMode MIDI_SYNC                  = new SyncMode("MIDI Sync");
+        public static final SyncMode MIDI_SYNC = new SyncMode("MIDI Sync");
 
         /**
          * A master or slave synchronization mode that specifies the use of MIDI
@@ -756,13 +756,13 @@
          * sequencer sends MIDI Time Code messages to its receiver. (See the
          * MIDI 1.0 Detailed Specification for a description of MIDI Time Code.)
          */
-        public static final SyncMode MIDI_TIME_CODE             = new SyncMode("MIDI Time Code");
+        public static final SyncMode MIDI_TIME_CODE = new SyncMode("MIDI Time Code");
 
         /**
          * A slave synchronization mode indicating that no timing information
          * should be sent to the receiver. This is not a legal master sync mode.
          */
-        public static final SyncMode NO_SYNC                            = new SyncMode("No Timing");
+        public static final SyncMode NO_SYNC = new SyncMode("No Timing");
 
     }
 }
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/ShortMessage.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/ShortMessage.java	Wed Jul 05 23:25:53 2017 +0200
@@ -61,35 +61,35 @@
      *
      * @see MidiMessage#getStatus
      */
-    public static final int MIDI_TIME_CODE                              = 0xF1; // 241
+    public static final int MIDI_TIME_CODE = 0xF1; // 241
 
     /**
      * Status byte for Song Position Pointer message (0xF2, or 242).
      *
      * @see MidiMessage#getStatus
      */
-    public static final int SONG_POSITION_POINTER               = 0xF2; // 242
+    public static final int SONG_POSITION_POINTER = 0xF2; // 242
 
     /**
      * Status byte for MIDI Song Select message (0xF3, or 243).
      *
      * @see MidiMessage#getStatus
      */
-    public static final int SONG_SELECT                                 = 0xF3; // 243
+    public static final int SONG_SELECT = 0xF3; // 243
 
     /**
      * Status byte for Tune Request message (0xF6, or 246).
      *
      * @see MidiMessage#getStatus
      */
-    public static final int TUNE_REQUEST                                = 0xF6; // 246
+    public static final int TUNE_REQUEST = 0xF6; // 246
 
     /**
      * Status byte for End of System Exclusive message (0xF7, or 247).
      *
      * @see MidiMessage#getStatus
      */
-    public static final int END_OF_EXCLUSIVE                    = 0xF7; // 247
+    public static final int END_OF_EXCLUSIVE = 0xF7; // 247
 
     // System real-time messages
 
@@ -98,80 +98,80 @@
      *
      * @see MidiMessage#getStatus
      */
-    public static final int TIMING_CLOCK                                = 0xF8; // 248
+    public static final int TIMING_CLOCK = 0xF8; // 248
 
     /**
      * Status byte for Start message (0xFA, or 250).
      *
      * @see MidiMessage#getStatus
      */
-    public static final int START                                               = 0xFA; // 250
+    public static final int START = 0xFA; // 250
 
     /**
      * Status byte for Continue message (0xFB, or 251).
      *
      * @see MidiMessage#getStatus
      */
-    public static final int CONTINUE                                    = 0xFB; // 251
+    public static final int CONTINUE = 0xFB; // 251
 
     /**
      * Status byte for Stop message (0xFC, or 252).
      *
      * @see MidiMessage#getStatus
      */
-    public static final int STOP                                                = 0xFC; //252
+    public static final int STOP = 0xFC; //252
 
     /**
      * Status byte for Active Sensing message (0xFE, or 254).
      *
      * @see MidiMessage#getStatus
      */
-    public static final int ACTIVE_SENSING                              = 0xFE; // 254
+    public static final int ACTIVE_SENSING = 0xFE; // 254
 
     /**
      * Status byte for System Reset message (0xFF, or 255).
      *
      * @see MidiMessage#getStatus
      */
-    public static final int SYSTEM_RESET                                = 0xFF; // 255
+    public static final int SYSTEM_RESET = 0xFF; // 255
 
     // Channel voice message upper nibble defines
 
     /**
      * Command value for Note Off message (0x80, or 128).
      */
-    public static final int NOTE_OFF                                    = 0x80;  // 128
+    public static final int NOTE_OFF = 0x80;  // 128
 
     /**
      * Command value for Note On message (0x90, or 144).
      */
-    public static final int NOTE_ON                                             = 0x90;  // 144
+    public static final int NOTE_ON = 0x90;  // 144
 
     /**
      * Command value for Polyphonic Key Pressure (Aftertouch) message (0xA0, or
      * 160).
      */
-    public static final int POLY_PRESSURE                               = 0xA0;  // 160
+    public static final int POLY_PRESSURE = 0xA0;  // 160
 
     /**
      * Command value for Control Change message (0xB0, or 176).
      */
-    public static final int CONTROL_CHANGE                              = 0xB0;  // 176
+    public static final int CONTROL_CHANGE = 0xB0;  // 176
 
     /**
      * Command value for Program Change message (0xC0, or 192).
      */
-    public static final int PROGRAM_CHANGE                              = 0xC0;  // 192
+    public static final int PROGRAM_CHANGE = 0xC0;  // 192
 
     /**
      * Command value for Channel Pressure (Aftertouch) message (0xD0, or 208).
      */
-    public static final int CHANNEL_PRESSURE                    = 0xD0;  // 208
+    public static final int CHANNEL_PRESSURE = 0xD0;  // 208
 
     /**
      * Command value for Pitch Bend message (0xE0, or 224).
      */
-    public static final int PITCH_BEND                                  = 0xE0;  // 224
+    public static final int PITCH_BEND = 0xE0;  // 224
 
     /**
      * Constructs a new {@code ShortMessage}. The contents of the new message
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/SysexMessage.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/SysexMessage.java	Wed Jul 05 23:25:53 2017 +0200
@@ -81,7 +81,7 @@
      *
      * @see MidiMessage#getStatus
      */
-    public static final int SYSTEM_EXCLUSIVE                    = 0xF0; // 240
+    public static final int SYSTEM_EXCLUSIVE = 0xF0; // 240
 
     /**
      * Status byte for Special System Exclusive message (0xF7, or 247), which is
@@ -90,7 +90,7 @@
      *
      * @see MidiMessage#getStatus
      */
-    public static final int SPECIAL_SYSTEM_EXCLUSIVE    = 0xF7; // 247
+    public static final int SPECIAL_SYSTEM_EXCLUSIVE = 0xF7; // 247
 
     /**
      * The data bytes for this system exclusive message. These are initialized
--- a/jdk/src/java.desktop/share/classes/javax/sound/midi/VoiceStatus.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/midi/VoiceStatus.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,7 +51,7 @@
  * given type of {@code Synthesizer} always has a fixed number of voices, equal
  * to the maximum number of simultaneous notes it is capable of sounding.
  * <p>
- * <a NAME="description_of_active"></a> If the voice is not currently processing
+ * <a id="description_of_active"></a> If the voice is not currently processing
  * a MIDI note, it is considered inactive. A voice is inactive when it has been
  * given no note-on commands, or when every note-on command received has been
  * terminated by a corresponding note-off (or by an "all notes off" message).
--- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/BooleanControl.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/BooleanControl.java	Wed Jul 05 23:25:53 2017 +0200
@@ -141,14 +141,14 @@
          * Represents a control for the mute status of a line. Note that mute
          * status does not affect gain.
          */
-        public static final Type MUTE                           = new Type("Mute");
+        public static final Type MUTE = new Type("Mute");
 
         /**
          * Represents a control for whether reverberation is applied to a line.
          * Note that the status of this control not affect the reverberation
          * settings for a line, but does affect whether these settings are used.
          */
-        public static final Type APPLY_REVERB           = new Type("Apply Reverb");
+        public static final Type APPLY_REVERB = new Type("Apply Reverb");
 
         /**
          * Constructs a new boolean control type.
--- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/FloatControl.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/FloatControl.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -361,8 +361,8 @@
          * loudness is unaffected. Note that gain measures dB, not amplitude.
          * The relationship between a gain in decibels and the corresponding
          * linear amplitude multiplier is:
-         *
-         * <CENTER>{@code linearScalar = pow(10.0, gainDB/20.0)}</CENTER>
+         * <p style="text-align:center">
+         * {@code linearScalar = pow(10.0, gainDB/20.0)}
          * <p>
          * The {@code FloatControl} class has methods to impose a maximum and
          * minimum allowable value for gain. However, because an audio signal
@@ -386,7 +386,7 @@
          * @see #REVERB_RETURN
          * @see #VOLUME
          */
-        public static final Type MASTER_GAIN            = new Type("Master Gain");
+        public static final Type MASTER_GAIN = new Type("Master Gain");
 
         /**
          * Represents a control for the auxiliary send gain on a line.
@@ -394,7 +394,7 @@
          * @see #MASTER_GAIN
          * @see #AUX_RETURN
          */
-        public static final Type AUX_SEND                       = new Type("AUX Send");
+        public static final Type AUX_SEND = new Type("AUX Send");
 
         /**
          * Represents a control for the auxiliary return gain on a line.
@@ -402,7 +402,7 @@
          * @see #MASTER_GAIN
          * @see #AUX_SEND
          */
-        public static final Type AUX_RETURN                     = new Type("AUX Return");
+        public static final Type AUX_RETURN = new Type("AUX Return");
 
         /**
          * Represents a control for the pre-reverb gain on a line. This control
@@ -413,7 +413,7 @@
          * @see #REVERB_RETURN
          * @see EnumControl.Type#REVERB
          */
-        public static final Type REVERB_SEND            = new Type("Reverb Send");
+        public static final Type REVERB_SEND = new Type("Reverb Send");
 
         /**
          * Represents a control for the post-reverb gain on a line. This control
@@ -423,7 +423,7 @@
          * @see #MASTER_GAIN
          * @see #REVERB_SEND
          */
-        public static final Type REVERB_RETURN          = new Type("Reverb Return");
+        public static final Type REVERB_RETURN = new Type("Reverb Return");
 
         /**
          * Represents a control for the volume on a line.
@@ -431,7 +431,7 @@
         /*
          * $$kk: 08.30.99: ISSUE: what units?  linear or dB?
          */
-        public static final Type VOLUME                         = new Type("Volume");
+        public static final Type VOLUME = new Type("Volume");
 
         /**
          * Represents a control for the relative pan (left-right positioning) of
@@ -442,7 +442,7 @@
          *
          * @see #BALANCE
          */
-        public static final Type PAN                            = new Type("Pan");
+        public static final Type PAN = new Type("Pan");
 
         /**
          * Represents a control for the relative balance of a stereo signal
@@ -452,7 +452,7 @@
          *
          * @see #PAN
          */
-        public static final Type BALANCE                        = new Type("Balance");
+        public static final Type BALANCE = new Type("Balance");
 
         /**
          * Represents a control that changes the sample rate of audio playback.
@@ -470,7 +470,7 @@
          * doubling the sample rate has the effect of doubling the frequencies
          * in the sound's spectrum, which raises the pitch by an octave.
          */
-        public static final Type SAMPLE_RATE            = new Type("Sample Rate");
+        public static final Type SAMPLE_RATE = new Type("Sample Rate");
 
         /**
          * Constructs a new float control type.
--- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/LineEvent.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/LineEvent.java	Wed Jul 05 23:25:53 2017 +0200
@@ -220,7 +220,7 @@
          * @see #CLOSE
          * @see Line#open
          */
-        public static final Type OPEN   = new Type("Open");
+        public static final Type OPEN = new Type("Open");
 
         /**
          * A type of event that is sent when a line closes, freeing the system
@@ -229,7 +229,7 @@
          * @see #OPEN
          * @see Line#close
          */
-        public static final Type CLOSE  = new Type("Close");
+        public static final Type CLOSE = new Type("Close");
 
         /**
          * A type of event that is sent when a line begins to engage in active
@@ -239,7 +239,7 @@
          * @see #STOP
          * @see DataLine#start
          */
-        public static final Type START  = new Type("Start");
+        public static final Type START = new Type("Start");
 
         /**
          * A type of event that is sent when a line ceases active input or
@@ -249,7 +249,7 @@
          * @see #START
          * @see DataLine#stop
          */
-        public static final Type STOP   = new Type("Stop");
+        public static final Type STOP = new Type("Stop");
 
         /**
          * A type of event that is sent when a line ceases to engage in active
--- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/SourceDataLine.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/SourceDataLine.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -159,9 +159,9 @@
      * <p>
      * The number of bytes to write must represent an integral number of sample
      * frames, such that:
-     * <br>
-     * <center>{@code [ bytes written ] % [frame size in bytes ] == 0}</center>
-     * <br>
+     * <p style="text-align:center">
+     * {@code [ bytes written ] % [frame size in bytes ] == 0}
+     * <p>
      * The return value will always meet this requirement. A request to write a
      * number of bytes representing a non-integral number of sample frames
      * cannot be fulfilled and may result in an
--- a/jdk/src/java.desktop/share/classes/javax/sound/sampled/TargetDataLine.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/sound/sampled/TargetDataLine.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -149,9 +149,9 @@
      * <p>
      * The number of bytes to be read must represent an integral number of
      * sample frames, such that:
-     * <br>
-     * <center>{@code [ bytes read ] % [frame size in bytes ] == 0}</center>
-     * <br>
+     * <p style="text-align:center">
+     * {@code [ bytes read ] % [frame size in bytes ] == 0}
+     * <p>
      * The return value will always meet this requirement. A request to read a
      * number of bytes representing a non-integral number of sample frames
      * cannot be fulfilled and may result in an IllegalArgumentException.
--- a/jdk/src/java.desktop/share/classes/javax/swing/Action.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/Action.java	Wed Jul 05 23:25:53 2017 +0200
@@ -69,7 +69,7 @@
  * are desired, and use simple <code>ActionListener</code>s elsewhere.
  * <br>
  *
- * <h3><a name="buttonActions"></a>Swing Components Supporting <code>Action</code></h3>
+ * <h3><a id="buttonActions"></a>Swing Components Supporting <code>Action</code></h3>
  * <p>
  * Many of Swing's components have an <code>Action</code> property.  When
  * an <code>Action</code> is set on a component, the following things
@@ -96,34 +96,34 @@
  *
  * <table border="1" cellpadding="1" cellspacing="0"
  *         summary="Supported Action properties">
- *  <tr valign="top"  align="left">
- *    <th style="background-color:#CCCCFF" align="left">Component Property
- *    <th style="background-color:#CCCCFF" align="left">Components
- *    <th style="background-color:#CCCCFF" align="left">Action Key
- *    <th style="background-color:#CCCCFF" align="left">Notes
- *  <tr valign="top"  align="left">
+ *  <tr valign="top" style="text-align:left">
+ *    <th style="background-color:#CCCCFF;text-align:left">Component Property
+ *    <th style="background-color:#CCCCFF;text-align:left">Components
+ *    <th style="background-color:#CCCCFF;text-align:left">Action Key
+ *    <th style="background-color:#CCCCFF;text-align:left">Notes
+ *  <tr valign="top" style="text-align:left">
  *      <td><b><code>enabled</code></b>
  *      <td>All
  *      <td>The <code>isEnabled</code> method
  *      <td>&nbsp;
- *  <tr valign="top"  align="left">
+ *  <tr valign="top" style="text-align:left">
  *      <td><b><code>toolTipText</code></b>
  *      <td>All
  *      <td><code>SHORT_DESCRIPTION</code>
  *      <td>&nbsp;
- *  <tr valign="top"  align="left">
+ *  <tr valign="top" style="text-align:left">
  *      <td><b><code>actionCommand</code></b>
  *      <td>All
  *      <td><code>ACTION_COMMAND_KEY</code>
  *      <td>&nbsp;
- *  <tr valign="top"  align="left">
+ *  <tr valign="top" style="text-align:left">
  *      <td><b><code>mnemonic</code></b>
  *      <td>All buttons
  *      <td><code>MNEMONIC_KEY</code>
  *      <td>A <code>null</code> value or <code>Action</code> results in the
  *          button's <code>mnemonic</code> property being set to
  *          <code>'\0'</code>.
- *  <tr valign="top"  align="left">
+ *  <tr valign="top" style="text-align:left">
  *      <td><b><code>text</code></b>
  *      <td>All buttons
  *      <td><code>NAME</code>
@@ -139,7 +139,7 @@
  *          <code>true</code> if the <code>Action</code> has a
  *          non-<code>null</code> value for <code>LARGE_ICON_KEY</code> or
  *          <code>SMALL_ICON</code>.
- *  <tr valign="top"  align="left">
+ *  <tr valign="top" style="text-align:left">
  *      <td><b><code>displayedMnemonicIndex</code></b>
  *      <td>All buttons
  *      <td><code>DISPLAYED_MNEMONIC_INDEX_KEY</code>
@@ -150,7 +150,7 @@
  *          mnemonic index is not updated.  In any subsequent changes to
  *          <code>DISPLAYED_MNEMONIC_INDEX_KEY</code>, <code>null</code>
  *          is treated as -1.
- *  <tr valign="top"  align="left">
+ *  <tr valign="top" style="text-align:left">
  *      <td><b><code>icon</code></b>
  *      <td>All buttons except of <code>JCheckBox</code>,
  *      <code>JToggleButton</code> and <code>JRadioButton</code>.
@@ -160,13 +160,13 @@
  *         <code>SMALL_ICON</code>.  All other buttons will use
  *         <code>LARGE_ICON_KEY</code>; if the value is <code>null</code> they
  *         use <code>SMALL_ICON</code>.
- *  <tr valign="top"  align="left">
+ *  <tr valign="top" style="text-align:left">
  *      <td><b><code>accelerator</code></b>
  *      <td>All <code>JMenuItem</code> subclasses, with the exception of
  *          <code>JMenu</code>.
  *      <td><code>ACCELERATOR_KEY</code>
  *      <td>&nbsp;
- *  <tr valign="top"  align="left">
+ *  <tr valign="top" style="text-align:left">
  *      <td><b><code>selected</code></b>
  *      <td><code>JToggleButton</code>, <code>JCheckBox</code>,
  *          <code>JRadioButton</code>, <code>JCheckBoxMenuItem</code> and
--- a/jdk/src/java.desktop/share/classes/javax/swing/BoxLayout.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/BoxLayout.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,7 @@
  * arranged when the frame is resized.
  * <TABLE STYLE="FLOAT:RIGHT" BORDER="0" SUMMARY="layout">
  *    <TR>
- *      <TD ALIGN="CENTER">
+ *      <TD style="text-align:center">
  *         <P STYLE="TEXT-ALIGN:CENTER"><IMG SRC="doc-files/BoxLayout-1.gif"
  *          alt="The following text describes this graphic."
  *          WIDTH="191" HEIGHT="201" STYLE="FLOAT:BOTTOM; BORDER:0">
--- a/jdk/src/java.desktop/share/classes/javax/swing/DefaultListCellRenderer.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/DefaultListCellRenderer.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@
 /**
  * Renders an item in a list.
  * <p>
- * <strong><a name="override">Implementation Note:</a></strong>
+ * <strong><a id="override">Implementation Note:</a></strong>
  * This class overrides
  * <code>invalidate</code>,
  * <code>validate</code>,
--- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java	Wed Jul 05 23:25:53 2017 +0200
@@ -3735,7 +3735,7 @@
          * @since 1.3
          * @deprecated This class is no longer used or needed.
          * {@code java.awt.Component.AccessibleAWTComponent} provides
-         * the same functionality and it is handled in {@Component}.
+         * the same functionality and it is handled in {@code Component}.
          */
         @Deprecated
         protected class AccessibleFocusHandler implements FocusListener {
--- a/jdk/src/java.desktop/share/classes/javax/swing/JLayeredPane.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JLayeredPane.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,7 +49,7 @@
  *
  * <TABLE STYLE="FLOAT:RIGHT" BORDER="0" SUMMARY="layout">
  * <TR>
- *   <TD ALIGN="CENTER">
+ *   <TD style="text-align:center">
  *     <P STYLE="TEXT-ALIGN:CENTER"><IMG SRC="doc-files/JLayeredPane-1.gif"
  *     alt="The following text describes this image."
  *     WIDTH="269" HEIGHT="264" STYLE="FLOAT:BOTTOM; BORDER=0">
--- a/jdk/src/java.desktop/share/classes/javax/swing/JList.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JList.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -145,7 +145,7 @@
  * Responsibility for listening to selection changes in order to keep the list's
  * visual representation up to date lies with the list's {@code ListUI}.
  * <p>
- * <a name="renderer"></a>
+ * <a id="renderer"></a>
  * Painting of cells in a {@code JList} is handled by a delegate called a
  * cell renderer, installed on the list as the {@code cellRenderer} property.
  * The renderer provides a {@code java.awt.Component} that is used
@@ -201,7 +201,7 @@
  * To avoid these calculations, you can set a {@code fixedCellWidth} and
  * {@code fixedCellHeight} on the list, or have these values calculated
  * automatically based on a single prototype value:
- * <a name="prototype_example"></a>
+ * <a id="prototype_example"></a>
  * <pre>
  * {@code
  * JList<String> bigDataList = new JList<String>(bigData);
--- a/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JOptionPane.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -143,7 +143,7 @@
  * in which case a default <code>Frame</code> is used as the parent,
  * and the dialog will be
  * centered on the screen (depending on the {@literal L&F}).
- * <dt><a name=message>message</a><dd>
+ * <dt><a id=message>message</a><dd>
  * A descriptive message to be placed in the dialog box.
  * In the most common usage, message is just a <code>String</code> or
  * <code>String</code> constant.
--- a/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java	Wed Jul 05 23:25:53 2017 +0200
@@ -72,7 +72,7 @@
  * </blockquote>
  * <table style="float:right" border="0" summary="layout">
  * <tr>
- * <td align="center">
+ * <td style="text-align:center">
  * <img src="doc-files/JRootPane-2.gif"
  * alt="The following text describes this graphic." HEIGHT=386 WIDTH=349>
  * </td>
--- a/jdk/src/java.desktop/share/classes/javax/swing/JScrollPane.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JScrollPane.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -57,7 +57,7 @@
  *
  * <TABLE STYLE="FLOAT:RIGHT" BORDER="0" SUMMARY="layout">
  *    <TR>
- *    <TD ALIGN="CENTER">
+ *    <TD style="text-align:center">
  *      <P STYLE="TEXT-ALIGN:CENTER"><IMG SRC="doc-files/JScrollPane-1.gif"
  *      alt="The following text describes this image."
  *      WIDTH="256" HEIGHT="248" STYLE="FLOAT:BOTTOM; BORDER:0px">
--- a/jdk/src/java.desktop/share/classes/javax/swing/JTree.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/JTree.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,7 @@
 import static sun.swing.SwingUtilities2.Section.*;
 
 /**
- * <a name="jtree_description"></a>
+ * <a id="jtree_description"></a>
  * A control that displays a set of hierarchical data as an outline.
  * You can find task-oriented documentation and examples of using trees in
  * <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/tree.html">How to Use Trees</a>,
--- a/jdk/src/java.desktop/share/classes/javax/swing/LookAndFeel.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/LookAndFeel.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -91,7 +91,7 @@
  * to provide a specific set of defaults. These are documented in the
  * classes that require the specific default.
  *
- * <h3><a name="defaultRecommendation">ComponentUIs and defaults</a></h3>
+ * <h3><a id="defaultRecommendation">ComponentUIs and defaults</a></h3>
  *
  * All {@code ComponentUIs} typically need to set various properties
  * on the {@code JComponent} the {@code ComponentUI} is providing the
@@ -121,7 +121,7 @@
  * provided by this class as they handle the necessary checking and install
  * the property using the recommended guidelines.
  *
- * <h3><a name="exceptions"></a>Exceptions</h3>
+ * <h3><a id="exceptions"></a>Exceptions</h3>
  *
  * All of the install methods provided by {@code LookAndFeel} need to
  * access the defaults if the value of the property being changed is
--- a/jdk/src/java.desktop/share/classes/javax/swing/SizeSequence.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/SizeSequence.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,11 +53,10 @@
  * The following figure shows the relationship between size and position data
  * for a multi-column component.
  *
- * <center>
+ * <p style="text-align:center">
  * <img src="doc-files/SizeSequence-1.gif" width=384 height = 100
  * alt="The first item begins at position 0, the second at the position equal
  to the size of the previous item, and so on.">
- * </center>
  * <p>
  * In the figure, the first index (0) corresponds to the first column,
  * the second index (1) to the second column, and so on.
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1283,14 +1283,13 @@
      * text component (i.e. the root of the hierarchy) that
      * can be traversed to determine how the model is being
      * represented spatially.
-     * <p>
-     * <font style="color: red;"><b>NOTE:</b>The View hierarchy can
+     * <p style="color:red;">
+     * <b>NOTE:</b>The View hierarchy can
      * be traversed from the root view, and other things
      * can be done as well.  Things done in this way cannot
      * be protected like simple method calls through the TextUI.
      * Therefore, proper operation in the presence of concurrency
      * must be arranged by any logic that calls this method!
-     * </font>
      *
      * @param tc the text component for which this UI is installed
      * @return the view
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/DefaultMetalTheme.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/DefaultMetalTheme.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
  * All colors returned by {@code DefaultMetalTheme} are completely
  * opaque.
  *
- * <h3><a name="fontStyle"></a>Font Style</h3>
+ * <h3><a id="fontStyle"></a>Font Style</h3>
  *
  * {@code DefaultMetalTheme} uses bold fonts for many controls.  To make all
  * controls (with the exception of the internal frame title bars and
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java	Wed Jul 05 23:25:53 2017 +0200
@@ -292,85 +292,85 @@
      * added to {@code table}:
      * <table border="1" cellpadding="1" cellspacing="0"
      *         summary="Metal's system color mapping">
-     *  <tr valign="top"  align="left">
-     *    <th style="background-color:#CCCCFF" align="left">Key
-     *    <th style="background-color:#CCCCFF" align="left">Value
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
+     *    <th style="background-color:#CCCCFF;text-align:left">Key
+     *    <th style="background-color:#CCCCFF;text-align:left">Value
+     *  <tr valign="top" style="text-align:left">
      *    <td>"desktop"
      *    <td>{@code theme.getDesktopColor()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"activeCaption"
      *    <td>{@code theme.getWindowTitleBackground()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"activeCaptionText"
      *    <td>{@code theme.getWindowTitleForeground()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"activeCaptionBorder"
      *    <td>{@code theme.getPrimaryControlShadow()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"inactiveCaption"
      *    <td>{@code theme.getWindowTitleInactiveBackground()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"inactiveCaptionText"
      *    <td>{@code theme.getWindowTitleInactiveForeground()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"inactiveCaptionBorder"
      *    <td>{@code theme.getControlShadow()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"window"
      *    <td>{@code theme.getWindowBackground()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"windowBorder"
      *    <td>{@code theme.getControl()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"windowText"
      *    <td>{@code theme.getUserTextColor()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"menu"
      *    <td>{@code theme.getMenuBackground()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"menuText"
      *    <td>{@code theme.getMenuForeground()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"text"
      *    <td>{@code theme.getWindowBackground()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"textText"
      *    <td>{@code theme.getUserTextColor()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"textHighlight"
      *    <td>{@code theme.getTextHighlightColor()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"textHighlightText"
      *    <td>{@code theme.getHighlightedTextColor()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"textInactiveText"
      *    <td>{@code theme.getInactiveSystemTextColor()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"control"
      *    <td>{@code theme.getControl()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"controlText"
      *    <td>{@code theme.getControlTextColor()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"controlHighlight"
      *    <td>{@code theme.getControlHighlight()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"controlLtHighlight"
      *    <td>{@code theme.getControlHighlight()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"controlShadow"
      *    <td>{@code theme.getControlShadow()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"controlDkShadow"
      *    <td>{@code theme.getControlDarkShadow()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"scrollbar"
      *    <td>{@code theme.getControl()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"info"
      *    <td>{@code theme.getPrimaryControl()}
-     *  <tr valign="top"  align="left">
+     *  <tr valign="top" style="text-align:left">
      *    <td>"infoText"
      *    <td>{@code theme.getPrimaryControlInfo()}
      * </table>
--- a/jdk/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
  * in a <code>JTable</code>.
  * <p>
  *
- * <strong><a name="override">Implementation Note:</a></strong>
+ * <strong><a id="override">Implementation Note:</a></strong>
  * This class inherits from <code>JLabel</code>, a standard component class.
  * However <code>JTable</code> employs a unique mechanism for rendering
  * its cells and therefore requires some slightly modified behavior
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -999,17 +999,17 @@
      * </pre>
      *
      * <p>Invoking <code>setInnerHTML(elem, "&lt;ul&gt;&lt;li&gt;")</code>
-     * results in the following structure (new elements are <font
-     * style="color: red;">in red</font>).</p>
+     * results in the following structure (new elements are <span
+     * style="color: red;">in red</span>).</p>
      *
      * <pre>
      *     &lt;body&gt;
      *       |
      *     <b>&lt;div&gt;</b>
      *         \
-     *         <font style="color: red;">&lt;ul&gt;</font>
+     *         <span style="color: red;">&lt;ul&gt;</span>
      *           \
-     *           <font style="color: red;">&lt;li&gt;</font>
+     *           <span style="color: red;">&lt;li&gt;</span>
      * </pre>
      *
      * <p>Parameter <code>elem</code> must not be a leaf element,
@@ -1083,15 +1083,15 @@
      * </pre>
      *
      * <p>Invoking <code>setOuterHTML(elem, "&lt;ul&gt;&lt;li&gt;")</code>
-     * results in the following structure (new elements are <font
-     * style="color: red;">in red</font>).</p>
+     * results in the following structure (new elements are <span
+     * style="color: red;">in red</span>).</p>
      *
      * <pre>
      *    &lt;body&gt;
      *      |
-     *     <font style="color: red;">&lt;ul&gt;</font>
+     *     <span style="color: red;">&lt;ul&gt;</span>
      *       \
-     *       <font style="color: red;">&lt;li&gt;</font>
+     *       <span style="color: red;">&lt;li&gt;</span>
      * </pre>
      *
      * <p>If either <code>elem</code> or <code>htmlText</code>
@@ -1157,16 +1157,16 @@
      *
      * <p>Invoking <code>insertAfterStart(elem,
      * "&lt;ul&gt;&lt;li&gt;")</code> results in the following structure
-     * (new elements are <font style="color: red;">in red</font>).</p>
+     * (new elements are <span style="color: red;">in red</span>).</p>
      *
      * <pre>
      *        &lt;body&gt;
      *          |
      *        <b>&lt;div&gt;</b>
      *       /  |  \
-     *    <font style="color: red;">&lt;ul&gt;</font> &lt;p&gt; &lt;p&gt;
+     *    <span style="color: red;">&lt;ul&gt;</span> &lt;p&gt; &lt;p&gt;
      *     /
-     *  <font style="color: red;">&lt;li&gt;</font>
+     *  <span style="color: red;">&lt;li&gt;</span>
      * </pre>
      *
      * <p>Unlike the <code>insertBeforeStart</code> method, new
@@ -1229,17 +1229,17 @@
      * </pre>
      *
      * <p>Invoking <code>insertBeforeEnd(elem, "&lt;ul&gt;&lt;li&gt;")</code>
-     * results in the following structure (new elements are <font
-     * style="color: red;">in red</font>).</p>
+     * results in the following structure (new elements are <span
+     * style="color: red;">in red</span>).</p>
      *
      * <pre>
      *        &lt;body&gt;
      *          |
      *        <b>&lt;div&gt;</b>
      *       /  |  \
-     *     &lt;p&gt; &lt;p&gt; <font style="color: red;">&lt;ul&gt;</font>
+     *     &lt;p&gt; &lt;p&gt; <span style="color: red;">&lt;ul&gt;</span>
      *               \
-     *               <font style="color: red;">&lt;li&gt;</font>
+     *               <span style="color: red;">&lt;li&gt;</span>
      * </pre>
      *
      * <p>Unlike the <code>insertAfterEnd</code> method, new elements
@@ -1300,14 +1300,14 @@
      *
      * <p>Invoking <code>insertBeforeStart(elem,
      * "&lt;ul&gt;&lt;li&gt;")</code> results in the following structure
-     * (new elements are <font style="color: red;">in red</font>).</p>
+     * (new elements are <span style="color: red;">in red</span>).</p>
      *
      * <pre>
      *        &lt;body&gt;
      *         /  \
-     *      <font style="color: red;">&lt;ul&gt;</font> <b>&lt;div&gt;</b>
+     *      <span style="color: red;">&lt;ul&gt;</span> <b>&lt;div&gt;</b>
      *       /    /  \
-     *     <font style="color: red;">&lt;li&gt;</font> &lt;p&gt;  &lt;p&gt;
+     *     <span style="color: red;">&lt;li&gt;</span> &lt;p&gt;  &lt;p&gt;
      * </pre>
      *
      * <p>Unlike the <code>insertAfterStart</code> method, new
@@ -1360,15 +1360,15 @@
      * </pre>
      *
      * <p>Invoking <code>insertAfterEnd(elem, "&lt;ul&gt;&lt;li&gt;")</code>
-     * results in the following structure (new elements are <font
-     * style="color: red;">in red</font>).</p>
+     * results in the following structure (new elements are <span
+     * style="color: red;">in red</span>).</p>
      *
      * <pre>
      *        &lt;body&gt;
      *         /  \
-     *      <b>&lt;div&gt;</b> <font style="color: red;">&lt;ul&gt;</font>
+     *      <b>&lt;div&gt;</b> <span style="color: red;">&lt;ul&gt;</span>
      *       / \    \
-     *     &lt;p&gt; &lt;p&gt;  <font style="color: red;">&lt;li&gt;</font>
+     *     &lt;p&gt; &lt;p&gt;  <span style="color: red;">&lt;li&gt;</span>
      * </pre>
      *
      * <p>Unlike the <code>insertBeforeEnd</code> method, new elements
--- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1120,7 +1120,7 @@
      *
      * <table summary="Describes the tag and view created by this factory by default">
      * <tr>
-     * <th align=left>Tag<th align=left>View created
+     * <th style="text-align:left">Tag<th style="text-align:left">View created
      * </tr><tr>
      * <td>HTML.Tag.CONTENT<td>InlineView
      * </tr><tr>
--- a/jdk/src/java.desktop/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/tree/DefaultTreeCellRenderer.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,9 +61,9 @@
  * defaults table. The following table lists the mapping between
  * {@code DefaultTreeCellRenderer} property and defaults table key:
  * <table border="1" cellpadding="1" cellspacing="0" summary="">
- *   <tr valign="top"  align="left">
- *     <th style="background-color:#CCCCFF" align="left">Property:
- *     <th style="background-color:#CCCCFF" align="left">Key:
+ *   <tr valign="top" style="text-align:left">
+ *     <th style="background-color:#CCCCFF;text-align:left">Property:
+ *     <th style="background-color:#CCCCFF;text-align:left">Key:
  *   <tr><td>"leafIcon"<td>"Tree.leafIcon"
  *   <tr><td>"closedIcon"<td>"Tree.closedIcon"
  *   <tr><td>"openIcon"<td>"Tree.openIcon"
@@ -74,7 +74,7 @@
  *   <tr><td>"borderSelectionColor"<td>"Tree.selectionBorderColor"
  * </table>
  * <p>
- * <strong><a name="override">Implementation Note:</a></strong>
+ * <strong><a id="override">Implementation Note:</a></strong>
  * This class overrides
  * <code>invalidate</code>,
  * <code>validate</code>,
--- a/jdk/src/java.desktop/share/classes/javax/swing/undo/UndoManager.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/javax/swing/undo/UndoManager.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -57,11 +57,11 @@
  * upper-case letter in bold are significant, those in lower-case
  * and italicized are insignificant.
  * <p>
- * <a name="figure1"></a>
+ * <a id="figure1"></a>
  * <table border=0 summary="">
  * <tr><td>
  *     <img src="doc-files/UndoManager-1.gif" alt="">
- * <tr><td align=center>Figure 1
+ * <tr><td style="text-align:center">Figure 1
  * </table>
  * <p>
  * As shown in <a href="#figure1">figure 1</a>, if <b>D</b> was just added, the
@@ -70,11 +70,11 @@
  * index of the next edit to 3 (edit <i>c</i>), as shown in the following
  * figure.
  * <p>
- * <a name="figure2"></a>
+ * <a id="figure2"></a>
  * <table border=0 summary="">
  * <tr><td>
  *     <img src="doc-files/UndoManager-2.gif" alt="">
- * <tr><td align=center>Figure 2
+ * <tr><td style="text-align:center">Figure 2
  * </table>
  * <p>
  * The last significant edit is <b>A</b>, so that invoking
@@ -82,11 +82,11 @@
  * <i>b</i>, and <b>A</b>, in that order, setting the index of the
  * next edit to 0, as shown in the following figure.
  * <p>
- * <a name="figure3"></a>
+ * <a id="figure3"></a>
  * <table border=0 summary="">
  * <tr><td>
  *     <img src="doc-files/UndoManager-3.gif" alt="">
- * <tr><td align=center>Figure 3
+ * <tr><td style="text-align:center">Figure 3
  * </table>
  * <p>
  * Invoking <code>redo</code> results in invoking <code>redo</code> on
@@ -108,11 +108,11 @@
  * the new edit is added after <i>c</i>, as shown in the following
  * figure.
  * <p>
- * <a name="figure4"></a>
+ * <a id="figure4"></a>
  * <table border=0 summary="">
  * <tr><td>
  *     <img src="doc-files/UndoManager-4.gif" alt="">
- * <tr><td align=center>Figure 4
+ * <tr><td style="text-align:center">Figure 4
  * </table>
  * <p>
  * Once <code>end</code> has been invoked on an <code>UndoManager</code>
--- a/jdk/src/java.desktop/share/classes/module-info.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/module-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -114,10 +114,17 @@
     uses javax.sound.sampled.spi.FormatConversionProvider;
     uses javax.sound.sampled.spi.MixerProvider;
 
-    provides sun.datatransfer.DesktopDatatransferService with sun.awt.datatransfer.DesktopDatatransferServiceImpl;
-    provides java.net.ContentHandlerFactory with sun.awt.www.content.MultimediaContentHandlers;
-    provides javax.print.PrintServiceLookup with sun.print.PrintServiceLookupProvider;
-    provides javax.print.StreamPrintServiceFactory with sun.print.PSStreamPrinterFactory;
+    provides sun.datatransfer.DesktopDatatransferService with
+        sun.awt.datatransfer.DesktopDatatransferServiceImpl;
+
+    provides java.net.ContentHandlerFactory with
+        sun.awt.www.content.MultimediaContentHandlers;
+
+    provides javax.print.PrintServiceLookup with
+        sun.print.PrintServiceLookupProvider;
+
+    provides javax.print.StreamPrintServiceFactory with
+        sun.print.PSStreamPrinterFactory;
 
     provides javax.sound.midi.spi.MidiDeviceProvider with
         com.sun.media.sound.MidiInDeviceProvider,
@@ -125,14 +132,17 @@
         com.sun.media.sound.RealTimeSequencerProvider,
         com.sun.media.sound.SoftProvider;
 
-    provides javax.sound.midi.spi.MidiFileReader with com.sun.media.sound.StandardMidiFileReader;
-    provides javax.sound.midi.spi.MidiFileWriter with com.sun.media.sound.StandardMidiFileWriter;
+    provides javax.sound.midi.spi.MidiFileReader with
+        com.sun.media.sound.StandardMidiFileReader;
+
+    provides javax.sound.midi.spi.MidiFileWriter with
+        com.sun.media.sound.StandardMidiFileWriter;
 
     provides javax.sound.midi.spi.SoundbankReader with
-         com.sun.media.sound.AudioFileSoundbankReader,
-         com.sun.media.sound.DLSSoundbankReader,
-         com.sun.media.sound.JARSoundbankReader,
-         com.sun.media.sound.SF2SoundbankReader;
+        com.sun.media.sound.AudioFileSoundbankReader,
+        com.sun.media.sound.DLSSoundbankReader,
+        com.sun.media.sound.JARSoundbankReader,
+        com.sun.media.sound.SF2SoundbankReader;
 
     provides javax.sound.sampled.spi.AudioFileReader with
         com.sun.media.sound.AiffFileReader,
@@ -158,4 +168,3 @@
         com.sun.media.sound.DirectAudioDeviceProvider,
         com.sun.media.sound.PortMixerProvider;
 }
-
--- a/jdk/src/java.desktop/share/classes/sun/swing/LightweightContent.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/classes/sun/swing/LightweightContent.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/src/java.desktop/share/native/include/jawt.h	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/share/native/include/jawt.h	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,18 +38,22 @@
  * The AWT native interface allows a native C or C++ application a means
  * by which to access native structures in AWT.  This is to facilitate moving
  * legacy C and C++ applications to Java and to target the needs of the
- * community who, at present, wish to do their own native rendering to canvases
- * for performance reasons.  Standard extensions such as Java3D also require a
- * means to access the underlying native data structures of AWT.
+ * developers who need to do their own native rendering to canvases
+ * for performance or other reasons.
  *
- * There may be future extensions to this API depending on demand.
+ * Conversely it also provides mechanisms for an application which already
+ * has a native window to provide that to AWT for AWT rendering.
  *
- * A VM does not have to implement this API in order to pass the JCK.
- * It is recommended, however, that this API is implemented on VMs that support
- * standard extensions, such as Java3D.
+ * Since every platform may be different in its native data structures
+ * and APIs for windowing systems the application must necessarily
+ * provided per-platform source and compile and deliver per-platform
+ * native code  to use this API.
  *
- * Since this is a native API, any program which uses it cannot be considered
- * 100% pure java.
+ * These interfaces are not part of the Java SE specification and
+ * a VM is not required to implement this API. However it is strongly
+ * recommended that all implementations which support headful AWT
+ * also support these interfaces.
+ *
  */
 
 /*
@@ -58,7 +62,7 @@
  * For each platform, there is a native drawing surface structure.  This
  * platform-specific structure can be found in jawt_md.h.  It is recommended
  * that additional platforms follow the same model.  It is also recommended
- * that VMs on Win32 and Solaris support the existing structures in jawt_md.h.
+ * that VMs on all platforms support the existing structures in jawt_md.h.
  *
  *******************
  * EXAMPLE OF USAGE:
@@ -98,8 +102,8 @@
  *     jboolean result;
  *     jint lock;
  *
- *     // Get the AWT
- *     awt.version = JAWT_VERSION_1_3;
+ *     // Get the AWT. Request version 9 to access features in that release.
+ *     awt.version = JAWT_VERSION_9;
  *     result = JAWT_GetAWT(env, &awt);
  *     assert(result != JNI_FALSE);
  *
@@ -154,7 +158,7 @@
     /*
      * Pointer to the platform-specific information.  This can be safely
      * cast to a JAWT_Win32DrawingSurfaceInfo on Windows or a
-     * JAWT_X11DrawingSurfaceInfo on Solaris. On Mac OS X this is a
+     * JAWT_X11DrawingSurfaceInfo on Linux and Solaris. On Mac OS X this is a
      * pointer to a NSObject that conforms to the JAWT_SurfaceLayers
      * protocol. See jawt_md.h for details.
      */
@@ -237,7 +241,8 @@
 typedef struct jawt {
     /*
      * Version of this structure.  This must always be set before
-     * calling JAWT_GetAWT()
+     * calling JAWT_GetAWT(). It affects the functions returned.
+     * Must be one of the known pre-defined versions.
      */
     jint version;
     /*
@@ -332,6 +337,13 @@
 _JNI_IMPORT_OR_EXPORT_
 jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt);
 
+/*
+ * Specify one of these constants as the JAWT.version
+ * Specifying an earlier version will limit the available functions to
+ * those provided in that earlier version of JAWT.
+ * See the "Since" note on each API. Methods with no "Since"
+ * may be presumed to be present in JAWT_VERSION_1_3.
+ */
 #define JAWT_VERSION_1_3 0x00010003
 #define JAWT_VERSION_1_4 0x00010004
 #define JAWT_VERSION_1_7 0x00010007
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.desktop/share/specs/AWT_Native_Interface.html	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,776 @@
+<!--
+ Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+
+ This code is free software; you can redistribute it and/or modify it
+ 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.
+-->
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" xml:lang=
+"en-US">
+<head>
+<title>Java AWT Native Interface Specification and Guide</title>
+</head>
+<body>
+<h2>The Java AWT Native Interface Specification and Guide</h2>
+<h3>Introduction</h3>
+<p>The Java AWT Native Interface (JAWT) comprises a small set of native
+(eg C language-based) APIs that provide a standard supported way
+for interaction between Java API windows and surfaces, and
+platform native API windows and surfaces.
+Non-Java libraries may then render to a Java owned window.
+<p>
+Note: in this document the terms "Java AWT Native Interface",
+"AWT Native Interface" and "JAWT" are interchangeable and
+refer to this same specification.
+<p>
+The fundamental obstacle to native rendering without JAWT is that
+is that the rendering code cannot identify where to draw.
+The native code needs access to information about a Java
+drawing surface (such as a handle to the underlying native ID of a
+<tt>Canvas</tt>), but cannot get it.</p>
+Without that information (ie without JAWT) an application could
+use native rendering only by creating its own top-level window
+not shared at all with Java. This is unacceptable for most uses.
+Except for usage via JAWT, this is considered to be entirely
+internal to the Java platform implementation: private, unsupported
+and undocumented.
+<p>
+JAWT should be supported in all headful implementations
+where technically possible although this is not enforced by the JCK.
+There is a platform-specific and a platform
+independent portion to the API, to account for the differing
+data structures and requirements of each platform.
+This document specifies the platform independent portions and
+also documents the platform dependent portions for the Oracle JDK
+supported desktop operating environments.
+For AWT the term platform is less tied to the underlying operating
+system than it is to the desktop windowing environment.
+<p>
+Reasons for using the AWT Native Interface include
+<ul>
+<li>Use of a 3rd party native library not available in Java
+<li>A temporary porting aid before converting legacy code to Java
+<li>Rendering performance available only to native hardware accelerated APIs
+<li>Interoperation with another toolkit
+</ul>
+<p>
+Drawbacks include
+<ul>
+<li>A more complex application implementation, eg for painting
+<li>Potential for application instability if the native library does
+not interoperate properly with AWT.
+<li>Increased application delivery complexity - per platform binaries
+</ul>
+The header file <a href="#jawt.h"> "jawt.h"</a>
+in the Appendix fully specifies the APIs provided by JAWT.
+<p>
+An example illustrating how easy it is to use the AWT Native Interface
+is presented and discussed later in this document.</p>
+
+<p><b>JAWT usage depends on JNI</b></p>
+<p>The definition of Java Standard Edition includes JNI, the Java
+Native Interface. Many Java developers will never need to use it,
+but the interface is the only standard supported way for a Java
+language program to interact directly with
+application code that has been compiled to the native machine
+instructions for the host processor architecture.
+JNI is used where ever there is a need for mixed languages.
+These are by no means limited to cases like AWT. For example, you
+could use JNI to integrate with native code that communicates with
+a peripheral device, such as a scanner, connected to a system via a
+USB port.</p>
+<p>So JNI is general enough to be used to access almost any
+sort of native library.
+The rest of this document assumes a familiarity with how
+to use JNI.
+
+<p><b>How to use JAWT </b></p>
+<p>In this section we describe the most common usage of the AWT
+Native Interface &mdash; overriding the <tt>paint</tt> method to
+direct drawing operations to a native rendering library which then
+queries the Java VM to determine the information it needs in order
+to render. Note, however, that any native code may use the AWT
+Native Interface to learn about a target drawing surface, not just
+code in a <tt>paint</tt> method.</p>
+<p>The first step in hooking up a native rendering library to a
+Java <tt>Canvas</tt> is to define a new class that extends
+<tt>Canvas</tt> and overrides the <tt>paint</tt> method. The Java
+system routes all drawing operations for a <tt>Canvas</tt> object
+through the <tt>paint</tt> method, as it does for all other GUI
+objects. Canvas is a good candidate for the rendering surface as
+it does not have any content as a Button would.</p>
+<p>The new <tt>paint</tt> method, to be implemented in the native
+rendering library, must be declared as <tt>public native void</tt>
+, and the native library itself is loaded at runtime by including a
+call to <tt>System.loadLibrary( &quot;myRenderingLib&quot;)</tt>in
+the <tt>static</tt> block of the class. The <tt>myRenderingLib</tt>
+name is used for the native shared library; for Linux or the Solaris
+operating environment, the actual name for the library file on disk
+is <tt>libmyRenderingLib.so</tt> .</p>
+<p>Here is a simple example of such a class:</p>
+<pre>
+import java.awt.*;
+import java.awt.event.*;
+
+public class MyCanvas extends Canvas {
+    static {
+        System.loadLibrary("myRenderingLib");
+    }
+    public native void paint(Graphics g);
+
+    public static void main(String[] args) {
+        Frame f = new Frame();
+        f.setBounds(0, 0, 500, 110);
+        f.add(new MyCanvas());
+        f.addWindowListener( new WindowAdapter() {
+            public void windowClosing(WindowEvent ev) {
+                System.exit(0);
+            }
+        } );
+        f.show();
+    }
+}
+<br />
+</pre>
+<p>Note that this class has a <tt>main</tt> method that can be used
+to run this code as an application for testing purposes.</p>
+<p>The next step is to run the <tt>javah</tt> tool on the
+<tt>MyCanvas</tt> class file above to generate a C/C++ header file
+that describes the interface to the native <tt>paint</tt> method
+that Java expects to be used. <tt>javah</tt> is a standard tool
+included with the JDK. NB: <tt>javac -h outputdir</tt> may also be used.</p>
+
+<p>The final step &#173; and the most interesting one &#173; is to
+write the native rendering method, with an interface that conforms
+to the header file that <tt>javah</tt> generated, and build it as a
+standard shared library (called <tt>myRenderingLib</tt> in the
+above example) by linking it, against the appropriate JDK provided
+$JDK_HOME/lib/$JAWT_LIB library for the target platform.
+Where JAWT_LIB has the base name "jawt" and follows platform
+shared object naming rules. i.e.:
+<ul>
+<li>Windows: jawt.dll
+<li>MacOS: libjawt.dylib
+<li>Linux: libjawt.so
+<li>Solaris: libjawt.so
+</ul>
+
+This code will call back to the Java virtual machine to
+get the drawing surface information it needs to access the
+<tt>MyCanvas</tt> peer. Once this information is available, the
+code can draw directly to <tt>MyCanvas</tt> using standard drawing
+routines supplied by the underlying operating system.</p>
+<p>Here is sample source code for a native <tt>paint</tt> method
+designed for use in a X11-based drawing environment (Linux
+or Solaris) and a Java VM where the AWT Native Interface is present:</p>
+<pre>
+#include "MyCanvas.h"
+#include "jawt_md.h"
+
+/*
+ * Class:     MyCanvas
+ * Method:    paint
+ * Signature: (Ljava/awt/Graphics;)V
+ */
+JNIEXPORT void JNICALL Java_MyCanvas_paint
+(JNIEnv* env, jobject canvas, jobject graphics)
+{
+    JAWT awt;
+    JAWT_DrawingSurface* ds;
+    JAWT_DrawingSurfaceInfo* dsi;
+    JAWT_X11DrawingSurfaceInfo* dsi_x11;
+    jboolean result;
+    jint lock;
+    GC gc;
+
+    short       i;
+    char        *testString = "^^^ rendered from native code ^^^";
+
+    /* Get the AWT */
+    awt.version = JAWT_VERSION_9;
+    if (JAWT_GetAWT(env, &amp;awt) == JNI_FALSE) {
+        printf("AWT Not found\n");
+        return;
+    }
+
+    /* Get the drawing surface */
+    ds = awt.GetDrawingSurface(env, canvas);
+    if (ds == NULL) {
+        printf("NULL drawing surface\n");
+        return;
+    }
+
+    /* Lock the drawing surface */
+    lock = ds-&gt;Lock(ds);
+    if((lock &amp; JAWT_LOCK_ERROR) != 0) {
+        printf("Error locking surface\n");
+        awt.FreeDrawingSurface(ds);
+        return;
+    }
+
+    /* Get the drawing surface info */
+    dsi = ds-&gt;GetDrawingSurfaceInfo(ds);
+    if (dsi == NULL) {
+        printf("Error getting surface info\n");
+        ds-&gt;Unlock(ds);
+        awt.FreeDrawingSurface(ds);
+        return;
+    }
+
+    /* Get the platform-specific drawing info */
+    dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi-&gt;platformInfo;
+
+
+    /* Now paint */
+    gc = XCreateGC(dsi_x11-&gt;display, dsi_x11-&gt;drawable, 0, 0);
+    XSetBackground(dsi_x11-&gt;display, gc, 0);
+    for (i=0; i&lt;36;i++)
+    {
+        XSetForeground(dsi_x11-&gt;display, gc, 10*i);
+        XFillRectangle(dsi_x11-&gt;display, dsi_x11-&gt;drawable, gc,
+                        10*i, 5, 90, 90);
+    }
+    XSetForeground(dsi_x11-&gt;display, gc, 155);
+    XDrawImageString(dsi_x11-&gt;display, dsi_x11-&gt;drawable, gc,
+                        100, 110, testString, strlen(testString));
+    XFreeGC(dsi_x11-&gt;display, gc);
+
+
+    /* Free the drawing surface info */
+    ds-&gt;FreeDrawingSurfaceInfo(dsi);
+
+    /* Unlock the drawing surface */
+    ds-&gt;Unlock(ds);
+
+    /* Free the drawing surface */
+    awt.FreeDrawingSurface(ds);
+}
+</pre>
+<p>The key data structure here is <tt>JAWT</tt> , which is defined
+in <tt>jawt.h</tt> (included by <tt>jawt_md.h)</tt> ; it provides
+access to all the information the native code needs to get the job
+done. The first part of the native method is boilerplate: it
+populates the <tt>JAWT</tt> structure, gets a
+<tt>JAWT_DrawingSurface</tt> structure, locks the surface (only one
+drawing engine at a time, please!), then gets a
+<tt>JAWT_DrawingSurfaceInfo</tt> structure that contains a pointer
+(in the <tt>platformInfo</tt> field) to the necessary
+platform-specific drawing information. It also includes the
+bounding rectangle of the drawing surface and the current clipping
+region.</p>
+<p>The structure of the information pointed to by
+<tt>platformInfo</tt> is defined in a machine-dependent header file
+called <tt>jawt_md.h</tt>. For X11 drawing, it includes
+information about the X11 display and X11 drawable associated with
+<tt>MyCanvas</tt>. After the drawing operations are completed,
+there is more boilerplate code as <tt>JAWT_DrawingSurfaceInfo</tt>
+is freed and <tt>JAWT_DrawingSurface</tt> is unlocked and
+freed.</p>
+<p>The corresponding code for the GDI API on the Microsoft Windows platform would
+be structured similarly, but would include the version of
+<tt>jawt_md.h</tt> for Microsoft Windows and the structure located
+in the <tt>platformInfo</tt> field of drawing surface info would be
+cast as a <tt>JAWT_Win32DrawingSurfaceInfo*</tt> . And, of course,
+the actual drawing operations would need to be changed to those
+appropriate for the Microsoft Windows platform.
+The same also for MacOS.
+</p>
+<p><b>Summary</b></p>
+<p>The ability to draw directly into a Java <tt>Canvas</tt> from a
+native code library is extremely useful for developers planning to
+migrate a legacy software system to Java, especially one that
+includes a high-performance rendering engine. It makes it much
+easier to migrate in stages, leaving performance-sensitive
+rendering code alone, while other less-sensitive portions of code
+are converted to Java. The result can be a modern Java-centric
+application, providing the benefit of portability and development
+efficiency, but one that does not sacrifice an investment in
+performance of a key piece of native code.</p>
+<p><b>References</b></p>
+<p>The definitive reference to the Java Native Interface is <i>The
+Java Native Interface: Programmer's Guide and Specification</i> by
+Sheng Liang. This book was published in June
+1999 by Addison-Wesley. The ISBN is 0-201-32577-2.</p>
+<p><b>Appendix</b></p>
+<p><b>Header Files for jawt.h and jawt_md.h</b></p>
+<a name="jawt.h"></a>
+<p>jawt.h</p>
+<pre>
+#ifndef _JAVASOFT_JAWT_H_
+#define _JAVASOFT_JAWT_H_
+
+#include "jni.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * AWT native interface.
+ *
+ * The AWT native interface allows a native C or C++ application a means
+ * by which to access native structures in AWT.  This is to facilitate moving
+ * legacy C and C++ applications to Java and to target the needs of the
+ * developers who need to do their own native rendering to canvases
+ * for performance or other reasons.
+ *
+ * Conversely it also provides mechanisms for an application which already
+ * has a native window to provide that to AWT for AWT rendering.
+ *
+ * Since every platform may be different in its native data structures
+ * and APIs for windowing systems the application must necessarily
+ * provided per-platform source and compile and deliver per-platform
+ * native code  to use this API.
+ *
+ * These interfaces are not part of the Java SE specification and
+ * a VM is not required to implement this API. However it is strongly
+ * recommended that all implementations which support headful AWT
+ * also support these interfaces.
+ *
+ */
+
+/*
+ * AWT Native Drawing Surface (JAWT_DrawingSurface).
+ *
+ * For each platform, there is a native drawing surface structure.  This
+ * platform-specific structure can be found in jawt_md.h.  It is recommended
+ * that additional platforms follow the same model.  It is also recommended
+ * that VMs on all platforms support the existing structures in jawt_md.h.
+ *
+ *******************
+ * EXAMPLE OF USAGE:
+ *******************
+ *
+ * On Microsoft Windows, a programmer wishes to access the HWND of a canvas
+ * to perform native rendering into it.  The programmer has declared the
+ * paint() method for their canvas subclass to be native:
+ *
+ *
+ * MyCanvas.java:
+ *
+ * import java.awt.*;
+ *
+ * public class MyCanvas extends Canvas {
+ *
+ *     static {
+ *         System.loadLibrary("mylib");
+ *     }
+ *
+ *     public native void paint(Graphics g);
+ * }
+ *
+ *
+ * myfile.c:
+ *
+ * #include "jawt_md.h"
+ * #include &lt;assert.h&gt;
+ *
+ * JNIEXPORT void JNICALL
+ * Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics)
+ * {
+ *     JAWT awt;
+ *     JAWT_DrawingSurface* ds;
+ *     JAWT_DrawingSurfaceInfo* dsi;
+ *     JAWT_Win32DrawingSurfaceInfo* dsi_win;
+ *     jboolean result;
+ *     jint lock;
+ *
+ *     // Get the AWT. Request version 9 to access features in that release.
+ *     awt.version = JAWT_VERSION_9;
+ *     result = JAWT_GetAWT(env, &amp;awt);
+ *     assert(result != JNI_FALSE);
+ *
+ *     // Get the drawing surface
+ *     ds = awt.GetDrawingSurface(env, canvas);
+ *     assert(ds != NULL);
+ *
+ *     // Lock the drawing surface
+ *     lock = ds-&gt;Lock(ds);
+ *     assert((lock &amp; JAWT_LOCK_ERROR) == 0);
+ *
+ *     // Get the drawing surface info
+ *     dsi = ds-&gt;GetDrawingSurfaceInfo(ds);
+ *
+ *     // Get the platform-specific drawing info
+ *     dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi-&gt;platformInfo;
+ *
+ *     //////////////////////////////
+ *     // !!! DO PAINTING HERE !!! //
+ *     //////////////////////////////
+ *
+ *     // Free the drawing surface info
+ *     ds-&gt;FreeDrawingSurfaceInfo(dsi);
+ *
+ *     // Unlock the drawing surface
+ *     ds-&gt;Unlock(ds);
+ *
+ *     // Free the drawing surface
+ *     awt.FreeDrawingSurface(ds);
+ * }
+ *
+ */
+
+/*
+ * JAWT_Rectangle
+ * Structure for a native rectangle.
+ */
+typedef struct jawt_Rectangle {
+    jint x;
+    jint y;
+    jint width;
+    jint height;
+} JAWT_Rectangle;
+
+struct jawt_DrawingSurface;
+
+/*
+ * JAWT_DrawingSurfaceInfo
+ * Structure for containing the underlying drawing information of a component.
+ */
+typedef struct jawt_DrawingSurfaceInfo {
+    /*
+     * Pointer to the platform-specific information.  This can be safely
+     * cast to a JAWT_Win32DrawingSurfaceInfo on Microsoft Windows or a
+     * JAWT_X11DrawingSurfaceInfo on Linux and Solaris. On MacOS this is a
+     * pointer to a NSObject that conforms to the JAWT_SurfaceLayers protocol.
+     * See jawt_md.h for details.
+     */
+    void* platformInfo;
+    /* Cached pointer to the underlying drawing surface */
+    struct jawt_DrawingSurface* ds;
+    /* Bounding rectangle of the drawing surface */
+    JAWT_Rectangle bounds;
+    /* Number of rectangles in the clip */
+    jint clipSize;
+    /* Clip rectangle array */
+    JAWT_Rectangle* clip;
+} JAWT_DrawingSurfaceInfo;
+
+#define JAWT_LOCK_ERROR                 0x00000001
+#define JAWT_LOCK_CLIP_CHANGED          0x00000002
+#define JAWT_LOCK_BOUNDS_CHANGED        0x00000004
+#define JAWT_LOCK_SURFACE_CHANGED       0x00000008
+
+/*
+ * JAWT_DrawingSurface
+ * Structure for containing the underlying drawing information of a component.
+ * All operations on a JAWT_DrawingSurface MUST be performed from the same
+ * thread as the call to GetDrawingSurface.
+ */
+typedef struct jawt_DrawingSurface {
+    /* Cached reference to the Java environment of the calling thread.
+     * If Lock(), Unlock(), GetDrawingSurfaceInfo() or
+     * FreeDrawingSurfaceInfo() are called from a different thread,
+     * this data member should be set before calling those functions.
+     */
+    JNIEnv* env;
+    /* Cached reference to the target object */
+    jobject target;
+    /*
+     * Lock the surface of the target component for native rendering.
+     * When finished drawing, the surface must be unlocked with
+     * Unlock().  This function returns a bitmask with one or more of the
+     * following values:
+     *
+     * JAWT_LOCK_ERROR - When an error has occurred and the surface could not
+     * be locked.
+     *
+     * JAWT_LOCK_CLIP_CHANGED - When the clip region has changed.
+     *
+     * JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed.
+     *
+     * JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed
+     */
+    jint (JNICALL *Lock)
+        (struct jawt_DrawingSurface* ds);
+    /*
+     * Get the drawing surface info.
+     * The value returned may be cached, but the values may change if
+     * additional calls to Lock() or Unlock() are made.
+     * Lock() must be called before this can return a valid value.
+     * Returns NULL if an error has occurred.
+     * When finished with the returned value, FreeDrawingSurfaceInfo must be
+     * called.
+     */
+    JAWT_DrawingSurfaceInfo* (JNICALL *GetDrawingSurfaceInfo)
+        (struct jawt_DrawingSurface* ds);
+    /*
+     * Free the drawing surface info.
+     */
+    void (JNICALL *FreeDrawingSurfaceInfo)
+        (JAWT_DrawingSurfaceInfo* dsi);
+    /*
+     * Unlock the drawing surface of the target component for native rendering.
+     */
+    void (JNICALL *Unlock)
+        (struct jawt_DrawingSurface* ds);
+} JAWT_DrawingSurface;
+
+/*
+ * JAWT
+ * Structure for containing native AWT functions.
+ */
+typedef struct jawt {
+    /*
+     * Version of this structure.  This must always be set before
+     * calling JAWT_GetAWT(). It affects the functions returned.
+     * Must be one of the known pre-defined versions.
+     */
+    jint version;
+    /*
+     * Return a drawing surface from a target jobject.  This value
+     * may be cached.
+     * Returns NULL if an error has occurred.
+     * Target must be a java.awt.Component (should be a Canvas
+     * or Window for native rendering).
+     * FreeDrawingSurface() must be called when finished with the
+     * returned JAWT_DrawingSurface.
+     */
+    JAWT_DrawingSurface* (JNICALL *GetDrawingSurface)
+        (JNIEnv* env, jobject target);
+    /*
+     * Free the drawing surface allocated in GetDrawingSurface.
+     */
+    void (JNICALL *FreeDrawingSurface)
+        (JAWT_DrawingSurface* ds);
+    /*
+     * Since 1.4
+     * Locks the entire AWT for synchronization purposes
+     */
+    void (JNICALL *Lock)(JNIEnv* env);
+    /*
+     * Since 1.4
+     * Unlocks the entire AWT for synchronization purposes
+     */
+    void (JNICALL *Unlock)(JNIEnv* env);
+    /*
+     * Since 1.4
+     * Returns a reference to a java.awt.Component from a native
+     * platform handle.  On Windows, this corresponds to an HWND;
+     * on Solaris and Linux, this is a Drawable.  For other platforms,
+     * see the appropriate machine-dependent header file for a description.
+     * The reference returned by this function is a local
+     * reference that is only valid in this environment.
+     * This function returns a NULL reference if no component could be
+     * found with matching platform information.
+     */
+    jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo);
+
+    /**
+     * Since 9
+     * Creates a java.awt.Frame placed in a native container. Container is
+     * referenced by the native platform handle. For example on Windows this
+     * corresponds to an HWND. For other platforms, see the appropriate
+     * machine-dependent header file for a description. The reference returned
+     * by this function is a local reference that is only valid in this
+     * environment. This function returns a NULL reference if no frame could be
+     * created with matching platform information.
+     */
+    jobject (JNICALL *CreateEmbeddedFrame) (JNIEnv *env, void* platformInfo);
+
+    /**
+     * Since 9
+     * Moves and resizes the embedded frame. The new location of the top-left
+     * corner is specified by x and y parameters relative to the native parent
+     * component. The new size is specified by width and height.
+     *
+     * The embedded frame should be created by CreateEmbeddedFrame() method, or
+     * this function will not have any effect.
+     *
+     * java.awt.Component.setLocation() and java.awt.Component.setBounds() for
+     * EmbeddedFrame really don't move it within the native parent. These
+     * methods always locate the embedded frame at (0, 0) for backward
+     * compatibility. To allow moving embedded frames this method was
+     * introduced, and it works just the same way as setLocation() and
+     * setBounds() for usual, non-embedded components.
+     *
+     * Using usual get/setLocation() and get/setBounds() together with this new
+     * method is not recommended.
+     */
+    void (JNICALL *SetBounds) (JNIEnv *env, jobject embeddedFrame,
+            jint x, jint y, jint w, jint h);
+    /**
+     * Since 9
+     * Synthesize a native message to activate or deactivate an EmbeddedFrame
+     * window depending on the value of parameter doActivate, if "true"
+     * activates the window; otherwise, deactivates the window.
+     *
+     * The embedded frame should be created by CreateEmbeddedFrame() method, or
+     * this function will not have any effect.
+     */
+    void (JNICALL *SynthesizeWindowActivation) (JNIEnv *env,
+            jobject embeddedFrame, jboolean doActivate);
+} JAWT;
+
+/*
+ * Get the AWT native structure.  This function returns JNI_FALSE if
+ * an error occurs.
+ */
+_JNI_IMPORT_OR_EXPORT_
+jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt);
+
+/*
+ * Specify one of these constants as the JAWT.version
+ * Specifying an earlier version will limit the available functions to
+ * those provided in that earlier version of JAWT.
+ * See the "Since" note on each API. Methods with no "Since"
+ * may be presumed to be present in JAWT_VERSION_1_3.
+ */
+#define JAWT_VERSION_1_3 0x00010003
+#define JAWT_VERSION_1_4 0x00010004
+#define JAWT_VERSION_1_7 0x00010007
+#define JAWT_VERSION_9 0x00090000
+
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* !_JAVASOFT_JAWT_H_ */
+
+</pre>
+<p>jawt_md.h (Linux/Solaris/X11 operating environment version)</p>
+<pre>
+#ifndef _JAVASOFT_JAWT_MD_H_
+#define _JAVASOFT_JAWT_MD_H_
+
+#include &lt;X11/Xlib.h&gt;
+#include &lt;X11/Xutil.h&gt;
+#include &lt;X11/Intrinsic.h&gt;
+#include "jawt.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * X11-specific declarations for AWT native interface.
+ * See notes in jawt.h for an example of use.
+ */
+typedef struct jawt_X11DrawingSurfaceInfo {
+    Drawable drawable;
+    Display* display;
+    VisualID visualID;
+    Colormap colormapID;
+    int depth;
+} JAWT_X11DrawingSurfaceInfo;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_JAVASOFT_JAWT_MD_H_ */
+</pre>
+<p>jawt_md.h (Microsoft Windows version)</p>
+<pre>
+#ifndef _JAVASOFT_JAWT_MD_H_
+#define _JAVASOFT_JAWT_MD_H_
+
+#include &lt;windows.h&gt;
+#include "jawt.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Microsoft Windows specific declarations for AWT native interface.
+ * See notes in jawt.h for an example of use.
+ */
+typedef struct jawt_Win32DrawingSurfaceInfo {
+    /* Native window, DDB, or DIB handle */
+    union {
+        HWND hwnd;
+        HBITMAP hbitmap;
+        void* pbits;
+    };
+    /*
+     * This HDC should always be used instead of the HDC returned from
+     * BeginPaint() or any calls to GetDC().
+     */
+    HDC hdc;
+    HPALETTE hpalette;
+} JAWT_Win32DrawingSurfaceInfo;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_JAVASOFT_JAWT_MD_H_ */
+</pre>
+<p>jawt_md.h (MacOS version)</p>
+<pre>
+#ifndef _JAVASOFT_JAWT_MD_H_
+#define _JAVASOFT_JAWT_MD_H_
+
+#include "jawt.h"
+
+#ifdef __OBJC__
+#import <QuartzCore/CALayer.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * MacOS specific declarations for AWT native interface.
+ * See notes in jawt.h for an example of use.
+ */
+
+/*
+ * When calling JAWT_GetAWT with a JAWT version less than 1.7, you must pass this
+ * flag or you will not be able to get a valid drawing surface and JAWT_GetAWT will
+ * return false. This is to maintain compatibility with applications that used the
+ * interface with Java 6 which had multiple rendering models. This flag is not necessary
+ * when JAWT version 1.7 or greater is used as this is the only supported rendering mode.
+ *
+ * Example:
+ *   JAWT awt;
+ *   awt.version = JAWT_VERSION_1_4 | JAWT_MACOSX_USE_CALAYER;
+ *   jboolean success = JAWT_GetAWT(env, &awt);
+ */
+#define JAWT_MACOSX_USE_CALAYER 0x80000000
+
+/*
+ * When the native Cocoa toolkit is in use, the pointer stored in
+ * JAWT_DrawingSurfaceInfo->platformInfo points to a NSObject that conforms to the
+ * JAWT_SurfaceLayers protocol. Setting the layer property of this object will cause the
+ * specified layer to be overlaid on the Components rectangle. If the window the
+ * Component belongs to has a CALayer attached to it, this layer will be accessible via
+ * the windowLayer property.
+ */
+#ifdef __OBJC__
+@protocol JAWT_SurfaceLayers
+@property (readwrite, retain) CALayer *layer;
+@property (readonly) CALayer *windowLayer;
+@end
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_JAVASOFT_JAWT_MD_H_ */
+</pre>
+<!-- Body text ends here -->
+</body>
+</html>
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XContentWindow.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XContentWindow.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -139,6 +139,12 @@
 
     @Override
     public void handleExposeEvent(XEvent xev) {
+        if(parentFrame.isTargetUndecorated() &&
+           XWM.getWMID() != XWM.UNITY_COMPIZ_WM &&
+                width <= 0 && height <= 0) {
+            // WM didn't send initial ConfigureNotify, so set the bounds here
+            setContentBounds(parentFrame.getDimensions());
+        }
         if (width <= 0 || height <= 0) {
             return;
         }
--- a/jdk/src/java.desktop/unix/classes/sun/java2d/opengl/GLXSurfaceData.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.desktop/unix/classes/sun/java2d/opengl/GLXSurfaceData.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -112,11 +112,13 @@
     }
 
     public static class GLXWindowSurfaceData extends GLXSurfaceData {
+        protected final int scale;
 
         public GLXWindowSurfaceData(X11ComponentPeer peer,
                                     GLXGraphicsConfig gc)
         {
             super(peer, gc, peer.getColorModel(), WINDOW);
+            scale = gc.getScale();
         }
 
         public SurfaceData getReplacement() {
@@ -126,6 +128,8 @@
         public Rectangle getBounds() {
             Rectangle r = peer.getBounds();
             r.x = r.y = 0;
+            r.width = (int) Math.ceil(r.width * scale);
+            r.height = (int) Math.ceil(r.height * scale);
             return r;
         }
 
@@ -135,6 +139,16 @@
         public Object getDestination() {
             return peer.getTarget();
         }
+
+        @Override
+        public double getDefaultScaleX() {
+            return scale;
+        }
+
+        @Override
+        public double getDefaultScaleY() {
+            return scale;
+        }
     }
 
     /**
@@ -177,6 +191,7 @@
 
         private Image offscreenImage;
         private int width, height;
+        private final int scale;
 
         public GLXOffScreenSurfaceData(X11ComponentPeer peer,
                                        GLXGraphicsConfig gc,
@@ -186,11 +201,12 @@
         {
             super(peer, gc, cm, type);
 
-            this.width = width;
-            this.height = height;
+            scale = gc.getDevice().getScaleFactor();
+            this.width = width * scale;
+            this.height = height * scale;
             offscreenImage = image;
 
-            initSurface(width, height);
+            initSurface(this.width, this.height);
         }
 
         public SurfaceData getReplacement() {
@@ -201,6 +217,8 @@
             if (type == FLIP_BACKBUFFER) {
                 Rectangle r = peer.getBounds();
                 r.x = r.y = 0;
+                r.width = (int) Math.ceil(r.width * scale);
+                r.height = (int) Math.ceil(r.height * scale);
                 return r;
             } else {
                 return new Rectangle(width, height);
@@ -213,5 +231,15 @@
         public Object getDestination() {
             return offscreenImage;
         }
+
+        @Override
+        public double getDefaultScaleX() {
+            return scale;
+        }
+
+        @Override
+        public double getDefaultScaleY() {
+            return scale;
+        }
     }
 }
--- a/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/Instrumentation.java	Wed Jul 05 23:25:53 2017 +0200
@@ -729,7 +729,8 @@
      * Tests whether a module can be modified with {@link #redefineModule
      * redefineModule}. If a module is modifiable then this method returns
      * {@code true}. If a module is not modifiable then this method returns
-     * {@code false}.
+     * {@code false}. This method always returns {@code true} when the module
+     * is an unnamed module (as redefining an unnamed module is a no-op).
      *
      * @param module the module to test if it can be modified
      * @return {@code true} if the module is modifiable, otherwise {@code false}
--- a/jdk/src/java.instrument/share/classes/java/lang/instrument/package.html	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.instrument/share/classes/java/lang/instrument/package.html	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -112,7 +112,9 @@
 The <code>premain</code> methods will be run under the same security and classloader 
 rules as the application <code>main</code> method.
 There are no modeling restrictions on what the agent <code>premain</code> method may do.
-Anything application <code>main</code> can do, including creating threads, is legal from <code>premain</code>.
+Anything application <code>main</code> can do, including creating threads, is legal from
+<code>premain</code>.
+
 
 <P>
 Each agent is passed its agent options via the <code>agentArgs</code> parameter.
@@ -126,7 +128,6 @@
 If a <code>premain</code> method throws an uncaught exception, the JVM will abort.
 
 
-
 <h3>Starting Agents After VM Startup</h3>
 
 <p>
@@ -191,76 +192,134 @@
 not abort. If the <code>agentmain</code> method throws an uncaught exception it will be ignored.
 
 
+<h3>Deploying Agents in Executable JAR file</h3>
+
+The JAR File Specification defines manifest attributes for standalone applications that are
+bundled as <em>executable JAR files</em>. If an implementation supports a mechanism to start
+an application as an executable JAR then the main manifest may include the
+<code>Launcher-Agent-Class</code> attribute to specify the class name
+of an agent to start before the application <code>main</code> method is invoked. The Java
+virtual machine attempts to invoke the following method on the agent class:
+
+<blockquote>
+    <code>public static void
+        agentmain(String agentArgs, Instrumentation inst);
+    </code>
+</blockquote>
+
+<P>
+If the agent class does not implement this method then the JVM will attempt to invoke:
+
+<blockquote>
+    <code>public static void
+        agentmain(String agentArgs);
+    </code>
+</blockquote>
+
+<p>
+The value of the <code>agentArgs</code> parameter is always the empty string.
+
+<P>
+The <code>agentmain</code> method should do any necessary initialization
+required to start the agent and return. If the agent cannot be started, for
+example the agent class cannot be loaded, the agent class does not define a
+conformant <code>agentmain</code> method, or the <code>agentmain</code> method
+throws an uncaught exception or error, the JVM will abort.
+
+
+<h3>Visibility</h3>
+
+The types visible to the agent class are the types visible to the system class
+loader. They minimally include the types in packages exported by
+<a href="{@docRoot}/java.base-summary.html">java.base</a> and
+<a href="{@docRoot}/java.instrument-summary.html">java.instrument</a>.
+Whether all {@linkplain ClassLoader#getPlatformClassLoader() platform classes}
+are visible or not will depend on the initial module or application.
+
+<p>
+Supporting classes that the agent makes visible to the bootstrap class loader
+(by means of {@link Instrumentation#appendToBootstrapClassLoaderSearch
+appendToBootstrapClassLoaderSearch} or the <code>Boot-Class-Path</code> attribute
+specified below) can only link to types defined to the bootstrap class loader.
+There is no guarantee that all platform classes are visible to the boot class
+loader.
+
 
 <h3>Manifest Attributes</h3>
+
 The following manifest attributes are defined for an agent JAR file:
 <blockquote>
 <dl>
 <dt><code>Premain-Class</code></dt>
 <dd>
-                        When an agent is specified at JVM launch time this attribute
-			specifies the agent class.
-			That is, the class containing the <code>premain</code> method.
-                        When an agent is specified at JVM launch time this attribute
-			is required. If the attribute is not present the JVM will abort.
-                        Note: this is a class name, not a file name or path.							
+            When an agent is specified at JVM launch time this attribute
+            specifies the agent class.
+            That is, the class containing the <code>premain</code> method.
+            When an agent is specified at JVM launch time this attribute
+            is required. If the attribute is not present the JVM will abort.
+            Note: this is a class name, not a file name or path.
 </dd>
-
 <dt><code>Agent-Class</code></dt>
 <dd>
-                        If an implementation supports a mechanism to start agents 
-                        sometime after the VM has started then this attribute specifies
-                        the agent class.
-                        That is, the class containing the <code>agentmain</code> method.
-                        This attribute is required, if it is not present the agent
-                        will not be started.
-                        Note: this is a class name, not a file name or path.
-</dd>			
-
+            If an implementation supports a mechanism to start agents
+            sometime after the VM has started then this attribute specifies
+            the agent class.
+            That is, the class containing the <code>agentmain</code> method.
+            This attribute is required, if it is not present the agent
+            will not be started.
+            Note: this is a class name, not a file name or path.
+</dd>
+<dt><code>Launcher-Agent-Class</code></dt>
+<dd>
+            If an implementation supports a mechanism to start an application
+            as an executable JAR then the main manifest may include this
+            attribute to specify the class name of an agent to start before the
+            application <code>main</code> method is invoked.
+</dd>
 <dt><code>Boot-Class-Path</code></dt>
 <dd>
-                        A list of paths to be searched by the bootstrap class
-                        loader. Paths represent directories or libraries
-                        (commonly referred to as JAR or zip libraries on
-                        many platforms). 			
-                        These paths are searched by the
-                        bootstrap class loader after the platform specific
-                        mechanisms of locating a class have failed.
-                        Paths are searched in the order listed.
-                        Paths in the list are separated by one or more spaces.
-                        A path takes the syntax of the path component of a
-                        hierarchical URI. The path is
-                        absolute if it begins with a slash character ('/'),
-                        otherwise it is relative. A relative path is resolved
-                        against the absolute path of the agent JAR file.
-                        Malformed and non-existent paths are ignored.	
-			When an agent is started sometime after the VM has
-			started then paths that do not represent a JAR file
-			are ignored.
-                        This attribute is optional.
+            A list of paths to be searched by the bootstrap class
+            loader. Paths represent directories or libraries
+            (commonly referred to as JAR or zip libraries on
+            many platforms).
+            These paths are searched by the
+            bootstrap class loader after the platform specific
+            mechanisms of locating a class have failed.
+            Paths are searched in the order listed.
+            Paths in the list are separated by one or more spaces.
+            A path takes the syntax of the path component of a
+            hierarchical URI. The path is
+            absolute if it begins with a slash character ('/'),
+            otherwise it is relative. A relative path is resolved
+            against the absolute path of the agent JAR file.
+            Malformed and non-existent paths are ignored.
+            When an agent is started sometime after the VM has
+            started then paths that do not represent a JAR file
+            are ignored.
+            This attribute is optional.
 </dd>
 <dt><code>Can-Redefine-Classes</code></dt>
 <dd>
-                        Boolean (<code>true</code> or <code>false</code>, case irrelevant).
-                        Is the ability to redefine classes
-                        needed by this agent.
-                        Values other than <code>true</code> are considered <code>false</code>.
-                        This attribute is optional, the default is <code>false</code>.
+            Boolean (<code>true</code> or <code>false</code>, case irrelevant).
+            Is the ability to redefine classes
+            needed by this agent.
+            Values other than <code>true</code> are considered <code>false</code>.
+            This attribute is optional, the default is <code>false</code>.
 </dd>
 <dt><code>Can-Retransform-Classes</code></dt>
 <dd>
-                        Boolean (<code>true</code> or <code>false</code>, case irrelevant).
-                        Is the ability to retransform classes
-                        needed by this agent.
-                        Values other than <code>true</code> are considered <code>false</code>.
-                        This attribute is optional, the default is <code>false</code>.
+            Boolean (<code>true</code> or <code>false</code>, case irrelevant).
+            Is the ability to retransform classes
+            needed by this agent.
+            Values other than <code>true</code> are considered <code>false</code>.
+            This attribute is optional, the default is <code>false</code>.
 </dd>
 <dt><code>Can-Set-Native-Method-Prefix</code></dt>
 <dd>
-                        Boolean (<code>true</code> or <code>false</code>, case irrelevant).
-                        Is the ability to set native method prefix needed by this agent.
-                        Values other than <code>true</code> are considered <code>false</code>.
-                        This attribute is optional, the default is <code>false</code>.
+            Boolean (<code>true</code> or <code>false</code>, case irrelevant).
+            Is the ability to set native method prefix needed by this agent.
+            Values other than <code>true</code> are considered <code>false</code>.
+            This attribute is optional, the default is <code>false</code>.
 </dd>
 </dl>
 </blockquote>
--- a/jdk/src/java.instrument/share/classes/module-info.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.instrument/share/classes/module-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -32,5 +32,8 @@
  */
 module java.instrument {
     exports java.lang.instrument;
+
+    // allow java launcher to load agents in executable JAR files
+    exports sun.instrument to java.base;
 }
 
--- a/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.instrument/share/classes/sun/instrument/InstrumentationImpl.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -555,4 +555,15 @@
                                     classfileBuffer);
         }
     }
+
+
+    /**
+     * Invoked by the java launcher to load a java agent that is packaged with
+     * the main application in an executable JAR file.
+     */
+    public static void loadAgent(String path) {
+        loadAgent0(path);
+    }
+
+    private static native void loadAgent0(String path);
 }
--- a/jdk/src/java.instrument/share/native/libinstrument/InstrumentationImplNativeMethods.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.instrument/share/native/libinstrument/InstrumentationImplNativeMethods.c	Wed Jul 05 23:25:53 2017 +0200
@@ -159,3 +159,20 @@
   (JNIEnv * jnienv, jobject implThis, jlong agent, jobjectArray prefixArray, jboolean isRetransformable) {
     setNativeMethodPrefixes(jnienv, (JPLISAgent*)(intptr_t)agent, prefixArray, isRetransformable);
 }
+
+
+/*
+ * Class:     sun_instrument_InstrumentationImpl
+ * Method:    loadAgent0
+ */
+JNIEXPORT void JNICALL Java_sun_instrument_InstrumentationImpl_loadAgent0
+   (JNIEnv* env, jclass clazz, jstring jarfile)
+{
+    extern jint loadAgent(JNIEnv* env, jstring path);
+    if (loadAgent(env, jarfile) != JNI_OK) {
+        if (!(*env)->ExceptionCheck(env)) {
+            createAndThrowInternalError(env);
+        }
+    }
+}
+
--- a/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -106,7 +106,7 @@
  * convert them to JVM TI capabilities.
  */
 void
-convertCapabilityAtrributes(const jarAttribute* attributes, JPLISAgent* agent) {
+convertCapabilityAttributes(const jarAttribute* attributes, JPLISAgent* agent) {
     /* set redefineClasses capability */
     if (getBooleanAttribute(attributes, "Can-Redefine-Classes")) {
         addRedefineClassesCapability(agent);
@@ -229,7 +229,7 @@
         /*
          * Convert JAR attributes into agent capabilities
          */
-        convertCapabilityAtrributes(attributes, agent);
+        convertCapabilityAttributes(attributes, agent);
 
         /*
          * Track (record) the agent class name and options data
@@ -386,7 +386,7 @@
         /*
          * Convert JAR attributes into agent capabilities
          */
-        convertCapabilityAtrributes(attributes, agent);
+        convertCapabilityAttributes(attributes, agent);
 
         /*
          * Create the java.lang.instrument.Instrumentation instance
@@ -435,6 +435,109 @@
 DEF_Agent_OnUnload(JavaVM *vm) {
 }
 
+/**
+ * Invoked by the java launcher to load an agent in the main executable JAR.
+ * The Launcher-Agent-Class attribute in the main manifest of the JAR file
+ * is the agent class.
+ *
+ * Returns JNI_OK if the agent is loaded and initialized; JNI_ERR if this
+ * function fails, possibly with a pending exception.
+ */
+jint loadAgent(JNIEnv* env, jstring path) {
+    JavaVM* vm;
+    JPLISAgent* agent;
+    const char* jarfile = NULL;
+    jarAttribute* attributes = NULL;
+    char* agentClass = NULL;
+    char* bootClassPath;
+    int oldLen, newLen;
+    jint result = JNI_ERR;
+
+    if ((*env)->GetJavaVM(env, &vm) < 0) {
+        return JNI_ERR;
+    }
+
+    // create JPLISAgent with JVMTI environment
+    if (createNewJPLISAgent(vm, &agent) != JPLIS_INIT_ERROR_NONE) {
+        return JNI_ERR;
+    }
+
+    // get path to JAR file as UTF-8 string
+    jarfile = (*env)->GetStringUTFChars(env, path, NULL);
+    if (jarfile == NULL) {
+        return JNI_ERR;
+    }
+
+    // read the attributes in the main section of JAR manifest
+    attributes = readAttributes(jarfile);
+    if (attributes == NULL) {
+        goto releaseAndReturn;
+    }
+
+    // Launcher-Agent-Class is required
+    agentClass = getAttribute(attributes, "Launcher-Agent-Class");
+    if (agentClass == NULL) {
+        goto releaseAndReturn;
+    }
+
+    // The value of Launcher-Agent-Class is in UTF-8, convert it to modified UTF-8
+    oldLen = (int) strlen(agentClass);
+    newLen = modifiedUtf8LengthOfUtf8(agentClass, oldLen);
+    if (newLen == oldLen) {
+        agentClass = strdup(agentClass);
+    } else {
+        char* str = (char*) malloc(newLen + 1);
+        if (str != NULL) {
+            convertUtf8ToModifiedUtf8(agentClass, oldLen, str, newLen);
+        }
+        agentClass = str;
+    }
+    if (agentClass == NULL) {
+         jthrowable oome = createThrowable(env, "java/lang/OutOfMemoryError", NULL);
+         if (oome != NULL) (*env)->Throw(env, oome);
+         goto releaseAndReturn;
+    }
+
+    // Boot-Class-Path
+    bootClassPath = getAttribute(attributes, "Boot-Class-Path");
+    if (bootClassPath != NULL) {
+        appendBootClassPath(agent, jarfile, bootClassPath);
+    }
+
+    // Can-XXXX capabilities
+    convertCapabilityAttributes(attributes, agent);
+
+    // Create the java.lang.instrument.Instrumentation object
+    if (!createInstrumentationImpl(env, agent)) {
+        goto releaseAndReturn;
+    }
+
+    // Enable the ClassFileLoadHook
+    if (!setLivePhaseEventHandlers(agent)) {
+        goto releaseAndReturn;
+    }
+
+    // invoke the agentmain method
+    if (!startJavaAgent(agent, env, agentClass, "", agent->mAgentmainCaller)) {
+        goto releaseAndReturn;
+    }
+
+    // initialization complete
+    result = JNI_OK;
+
+    releaseAndReturn:
+        if (agentClass != NULL) {
+            free(agentClass);
+        }
+        if (attributes != NULL) {
+            freeAttributes(attributes);
+        }
+        if (jarfile != NULL) {
+            (*env)->ReleaseStringUTFChars(env, path, jarfile);
+        }
+
+    return result;
+}
 
 /*
  *  JVMTI callback support
--- a/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1258,7 +1258,7 @@
                     + ", listener=" + listener);
 
             final Integer[] ret =
-                    rmiNotifClient.removeNotificationListener(name, listener);
+                    rmiNotifClient.getListenerIds(name, listener);
 
             if (debug) logger.debug("removeNotificationListener",
                     "listenerIDs=" + objects(ret));
@@ -1278,7 +1278,7 @@
             } finally {
                 popDefaultClassLoader(old);
             }
-
+            rmiNotifClient.removeNotificationListener(name, listener);
         }
 
         public void removeNotificationListener(ObjectName name,
@@ -1300,7 +1300,7 @@
                         + ", handback=" + handback);
 
             final Integer ret =
-                    rmiNotifClient.removeNotificationListener(name, listener,
+                    rmiNotifClient.getListenerId(name, listener,
                     filter, handback);
 
             if (debug) logger.debug("removeNotificationListener",
@@ -1320,7 +1320,8 @@
             } finally {
                 popDefaultClassLoader(old);
             }
-
+            rmiNotifClient.removeNotificationListener(name, listener,
+                    filter, handback);
         }
     }
 
--- a/jdk/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Wed Jul 05 23:25:53 2017 +0200
@@ -188,6 +188,53 @@
     }
 
     public synchronized Integer[]
+    getListenerIds(ObjectName name,
+                   NotificationListener listener)
+            throws ListenerNotFoundException, IOException {
+
+        List<Integer> ids = new ArrayList<Integer>();
+        List<ClientListenerInfo> values =
+                new ArrayList<ClientListenerInfo>(infoList.values());
+        for (int i=values.size()-1; i>=0; i--) {
+            ClientListenerInfo li = values.get(i);
+
+            if (li.sameAs(name, listener)) {
+                ids.add(li.getListenerID());
+            }
+        }
+
+        if (ids.isEmpty())
+            throw new ListenerNotFoundException("Listener not found");
+
+        return ids.toArray(new Integer[0]);
+    }
+
+    public synchronized Integer
+    getListenerId(ObjectName name,
+                   NotificationListener listener,
+                   NotificationFilter filter,
+                   Object handback)
+            throws ListenerNotFoundException, IOException {
+
+        Integer id = null;
+
+        List<ClientListenerInfo> values =
+                new ArrayList<ClientListenerInfo>(infoList.values());
+        for (int i=values.size()-1; i>=0; i--) {
+            ClientListenerInfo li = values.get(i);
+            if (li.sameAs(name, listener, filter, handback)) {
+                id=li.getListenerID();
+                break;
+            }
+        }
+
+        if (id == null)
+            throw new ListenerNotFoundException("Listener not found");
+
+        return id;
+    }
+
+    public synchronized Integer[]
         removeNotificationListener(ObjectName name,
                                    NotificationListener listener)
         throws ListenerNotFoundException, IOException {
@@ -198,24 +245,12 @@
             logger.trace("removeNotificationListener",
                          "Remove the listener "+listener+" from "+name);
         }
-
-        List<Integer> ids = new ArrayList<Integer>();
-        List<ClientListenerInfo> values =
-                new ArrayList<ClientListenerInfo>(infoList.values());
-        for (int i=values.size()-1; i>=0; i--) {
-            ClientListenerInfo li = values.get(i);
-
-            if (li.sameAs(name, listener)) {
-                ids.add(li.getListenerID());
-
-                infoList.remove(li.getListenerID());
-            }
+        Integer[] liIds = getListenerIds(name, listener);
+        for (int i = 0; i < liIds.length; i++) {
+            infoList.remove(liIds[i]);
         }
 
-        if (ids.isEmpty())
-            throw new ListenerNotFoundException("Listener not found");
-
-        return ids.toArray(new Integer[0]);
+        return liIds;
     }
 
     public synchronized Integer
@@ -231,26 +266,11 @@
         }
 
         beforeRemove();
-
-        Integer id = null;
-
-        List<ClientListenerInfo> values =
-                new ArrayList<ClientListenerInfo>(infoList.values());
-        for (int i=values.size()-1; i>=0; i--) {
-            ClientListenerInfo li = values.get(i);
-            if (li.sameAs(name, listener, filter, handback)) {
-                id=li.getListenerID();
+        Integer liId = getListenerId(name, listener,
+                filter, handback);
+        infoList.remove(liId);
 
-                infoList.remove(id);
-
-                break;
-            }
-        }
-
-        if (id == null)
-            throw new ListenerNotFoundException("Listener not found");
-
-        return id;
+        return liId;
     }
 
     public synchronized Integer[] removeNotificationListener(ObjectName name) {
--- a/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.management/share/classes/java/lang/management/ThreadInfo.java	Wed Jul 05 23:25:53 2017 +0200
@@ -843,6 +843,9 @@
      * @return a {@code ThreadInfo} object represented
      *         by {@code cd} if {@code cd} is not {@code null};
      *         {@code null} otherwise.
+     *
+     * @revised 9
+     * @spec JPMS
      */
     public static ThreadInfo from(CompositeData cd) {
         if (cd == null) {
--- a/jdk/src/java.rmi/share/classes/java/rmi/Remote.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.rmi/share/classes/java/rmi/Remote.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,8 @@
  * <code>java.rmi.activation.Activatable</code>.
  *
  * <p>For complete details on RMI, see the <a
- href=../../../platform/rmi/spec/rmiTOC.html>RMI Specification</a> which describes the RMI API and system.
+ * href="{@docRoot}/../specs/rmi/index.html">RMI Specification</a> which
+ * describes the RMI API and system.
  *
  * @since   1.1
  * @author  Ann Wollrath
--- a/jdk/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.rmi/share/classes/java/rmi/server/UnicastRemoteObject.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -171,9 +171,9 @@
  * By default, server sockets created by {@link RMISocketFactory}
  * listen on all network interfaces. See the
  * {@link RMISocketFactory} class and the section
- * <a href="{@docRoot}/../platform/rmi/spec/rmi-server29.html">RMI Socket Factories</a>
+ * <a href="{@docRoot}/../specs/rmi/server.html#rmi-socket-factories">RMI Socket Factories</a>
  * in the
- * <a href="{@docRoot}/../platform/rmi/spec/rmiTOC.html">Java RMI Specification</a>.
+ * <a href="{@docRoot}/../specs/rmi/index.html">Java RMI Specification</a>.
  *
  * @author  Ann Wollrath
  * @author  Peter Jones
--- a/jdk/src/java.sql/share/classes/java/sql/package.html	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.sql/share/classes/java/sql/package.html	Wed Jul 05 23:25:53 2017 +0200
@@ -59,6 +59,7 @@
 <h2>Versions</h2>
 The JDBC 4.3 API incorporates all of the previous JDBC API versions:
 <UL>
+    <LI> The JDBC 4.2 API</li>
     <LI> The JDBC 4.1 API</li>
     <LI> The JDBC 4.0 API</li>
     <LI> The JDBC 3.0 API</li>
--- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignContext.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLSignContext.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
  * (for example, you should not use the same <code>XMLSignContext</code>
  * instance to sign two different {@link XMLSignature} objects).
  * <p>
- * <b><a name="SupportedProperties"></a>Supported Properties</b>
+ * <b><a id="SupportedProperties"></a>Supported Properties</b>
  * <p>The following properties can be set using the
  * {@link #setProperty setProperty} method.
  * <ul>
--- a/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLValidateContext.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/XMLValidateContext.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@
  * (for example, you should not use the same <code>XMLValidateContext</code>
  * instance to validate two different {@link XMLSignature} objects).
  * <p>
- * <b><a name="SupportedProperties"></a>Supported Properties</b>
+ * <b><a id="SupportedProperties"></a>Supported Properties</b>
  * <p>The following properties can be set by an application using the
  * {@link #setProperty setProperty} method.
  * <ul>
--- a/jdk/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java	Wed Jul 05 23:25:53 2017 +0200
@@ -214,13 +214,14 @@
             // Special-case the "load" command so that the right exception is
             // thrown.
             if (cmd.equals("load")) {
-                throw new AgentLoadException("Failed to load agent library");
+                String msg = "Failed to load agent library";
+                if (!message.isEmpty())
+                    msg += ": " + message;
+                throw new AgentLoadException(msg);
             } else {
-                if (message == null) {
-                    throw new AttachOperationFailedException("Command failed in target VM");
-                } else {
-                    throw new AttachOperationFailedException(message);
-                }
+                if (message.isEmpty())
+                    message = "Command failed in target VM";
+                throw new AttachOperationFailedException(message);
             }
         }
 
--- a/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java	Wed Jul 05 23:25:53 2017 +0200
@@ -211,13 +211,14 @@
             // Special-case the "load" command so that the right exception is
             // thrown.
             if (cmd.equals("load")) {
-                throw new AgentLoadException("Failed to load agent library");
+                String msg = "Failed to load agent library";
+                if (!message.isEmpty())
+                    msg += ": " + message;
+                throw new AgentLoadException(msg);
             } else {
-                if (message == null) {
-                    throw new AttachOperationFailedException("Command failed in target VM");
-                } else {
-                    throw new AttachOperationFailedException(message);
-                }
+                if (message.isEmpty())
+                    message = "Command failed in target VM";
+                throw new AttachOperationFailedException(message);
             }
         }
 
--- a/jdk/src/jdk.attach/macosx/classes/sun/tools/attach/VirtualMachineImpl.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.attach/macosx/classes/sun/tools/attach/VirtualMachineImpl.java	Wed Jul 05 23:25:53 2017 +0200
@@ -213,13 +213,14 @@
             // Special-case the "load" command so that the right exception is
             // thrown.
             if (cmd.equals("load")) {
-                throw new AgentLoadException("Failed to load agent library");
+                String msg = "Failed to load agent library";
+                if (!message.isEmpty())
+                    msg += ": " + message;
+                throw new AgentLoadException(msg);
             } else {
-                if (message == null) {
-                    throw new AttachOperationFailedException("Command failed in target VM");
-                } else {
-                    throw new AttachOperationFailedException(message);
-                }
+                if (message.isEmpty())
+                    message = "Command failed in target VM";
+                throw new AttachOperationFailedException(message);
             }
         }
 
--- a/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,15 +25,19 @@
 
 package sun.tools.attach;
 
+import com.sun.tools.attach.AttachNotSupportedException;
 import com.sun.tools.attach.VirtualMachine;
 import com.sun.tools.attach.AgentLoadException;
 import com.sun.tools.attach.AgentInitializationException;
 import com.sun.tools.attach.spi.AttachProvider;
+import jdk.internal.misc.VM;
 
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.Properties;
 import java.util.stream.Collectors;
 
@@ -43,8 +47,33 @@
 
 public abstract class HotSpotVirtualMachine extends VirtualMachine {
 
-    HotSpotVirtualMachine(AttachProvider provider, String id) {
+    private static final long CURRENT_PID;
+    private static final boolean ALLOW_ATTACH_SELF;
+    static {
+        PrivilegedAction<ProcessHandle> pa = ProcessHandle::current;
+        CURRENT_PID = AccessController.doPrivileged(pa).pid();
+
+        String s = VM.getSavedProperty("jdk.attach.allowAttachSelf");
+        ALLOW_ATTACH_SELF = "".equals(s) || Boolean.parseBoolean(s);
+    }
+
+    HotSpotVirtualMachine(AttachProvider provider, String id)
+        throws AttachNotSupportedException, IOException
+    {
         super(provider, id);
+
+        int pid;
+        try {
+            pid = Integer.parseInt(id);
+        } catch (NumberFormatException e) {
+            throw new AttachNotSupportedException("Invalid process identifier");
+        }
+
+        // The tool should be a different VM to the target. This check will
+        // eventually be enforced by the target VM.
+        if (!ALLOW_ATTACH_SELF && (pid == 0 || pid == CURRENT_PID)) {
+            throw new IOException("Can not attach to current VM");
+        }
     }
 
     /*
@@ -103,8 +132,6 @@
         }
         try {
             loadAgentLibrary("instrument", args);
-        } catch (AgentLoadException x) {
-            throw new InternalError("instrument library is missing in target VM", x);
         } catch (AgentInitializationException x) {
             /*
              * Translate interesting errors into the right exception and
@@ -116,13 +143,17 @@
                 case JNI_ENOMEM:
                     throw new AgentLoadException("Insuffient memory");
                 case ATTACH_ERROR_BADJAR:
-                    throw new AgentLoadException("Agent JAR not found or no Agent-Class attribute");
+                    throw new AgentLoadException(
+                        "Agent JAR not found or no Agent-Class attribute");
                 case ATTACH_ERROR_NOTONCP:
-                    throw new AgentLoadException("Unable to add JAR file to system class path");
+                    throw new AgentLoadException(
+                        "Unable to add JAR file to system class path");
                 case ATTACH_ERROR_STARTFAIL:
-                    throw new AgentInitializationException("Agent JAR loaded but agent failed to initialize");
+                    throw new AgentInitializationException(
+                        "Agent JAR loaded but agent failed to initialize");
                 default :
-                    throw new AgentLoadException("Failed to load agent - unknown reason: " + rc);
+                    throw new AgentLoadException("" +
+                        "Failed to load agent - unknown reason: " + rc);
             }
         }
     }
@@ -163,20 +194,20 @@
         return props;
     }
 
-    private static final String MANAGMENT_PREFIX = "com.sun.management.";
+    private static final String MANAGEMENT_PREFIX = "com.sun.management.";
 
     private static boolean checkedKeyName(Object key) {
         if (!(key instanceof String)) {
             throw new IllegalArgumentException("Invalid option (not a String): "+key);
         }
-        if (!((String)key).startsWith(MANAGMENT_PREFIX)) {
+        if (!((String)key).startsWith(MANAGEMENT_PREFIX)) {
             throw new IllegalArgumentException("Invalid option: "+key);
         }
         return true;
     }
 
     private static String stripKeyName(Object key) {
-        return ((String)key).substring(MANAGMENT_PREFIX.length());
+        return ((String)key).substring(MANAGEMENT_PREFIX.length());
     }
 
     @Override
@@ -204,9 +235,11 @@
     @Override
     public String startLocalManagementAgent() throws IOException {
         executeJCmd("ManagementAgent.start_local").close();
-        return getAgentProperties().getProperty("com.sun.management.jmxremote.localConnectorAddress");
+        String prop = MANAGEMENT_PREFIX + "jmxremote.localConnectorAddress";
+        return getAgentProperties().getProperty(prop);
     }
 
+
     // --- HotSpot specific methods ---
 
     // same as SIGQUIT
@@ -245,9 +278,9 @@
         return executeCommand("jcmd", command);
     }
 
+
     // -- Supporting methods
 
-
     /*
      * Execute the given command in the target VM - specific platform
      * implementation must implement this.
@@ -306,10 +339,10 @@
     /*
      * Utility method to read data into a String.
      */
-    String readErrorMessage(InputStream sis) throws IOException {
+    String readErrorMessage(InputStream in) throws IOException {
         String s;
         StringBuilder message = new StringBuilder();
-        BufferedReader br = new BufferedReader(new InputStreamReader(sis));
+        BufferedReader br = new BufferedReader(new InputStreamReader(in));
         while ((s = br.readLine()) != null) {
             message.append(s);
         }
--- a/jdk/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java	Wed Jul 05 23:25:53 2017 +0200
@@ -160,13 +160,14 @@
             String message = readErrorMessage(sis);
             sis.close();
             if (cmd.equals("load")) {
-                throw new AgentLoadException("Failed to load agent library");
+                String msg = "Failed to load agent library";
+                if (!message.isEmpty())
+                    msg += ": " + message;
+                throw new AgentLoadException(msg);
             } else {
-                if (message == null) {
-                    throw new AttachOperationFailedException("Command failed in target VM");
-                } else {
-                    throw new AttachOperationFailedException(message);
-                }
+                if (message.isEmpty())
+                    message = "Command failed in target VM";
+                throw new AttachOperationFailedException(message);
             }
         }
 
--- a/jdk/src/jdk.attach/windows/classes/sun/tools/attach/VirtualMachineImpl.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.attach/windows/classes/sun/tools/attach/VirtualMachineImpl.java	Wed Jul 05 23:25:53 2017 +0200
@@ -100,28 +100,29 @@
             connectPipe(hPipe);
 
             // create an input stream for the pipe
-            PipedInputStream is = new PipedInputStream(hPipe);
+            PipedInputStream in = new PipedInputStream(hPipe);
 
             // read completion status
-            int status = readInt(is);
+            int status = readInt(in);
             if (status != 0) {
                 // read from the stream and use that as the error message
-                String message = readErrorMessage(is);
-                is.close();
+                String message = readErrorMessage(in);
+                in.close();
                 // special case the load command so that the right exception is thrown
                 if (cmd.equals("load")) {
-                    throw new AgentLoadException("Failed to load agent library");
+                    String msg = "Failed to load agent library";
+                    if (!message.isEmpty())
+                        msg += ": " + message;
+                    throw new AgentLoadException(msg);
                 } else {
-                    if (message == null) {
-                        throw new AttachOperationFailedException("Command failed in target VM");
-                    } else {
-                        throw new AttachOperationFailedException(message);
-                    }
+                    if (message.isEmpty())
+                        message = "Command failed in target VM";
+                    throw new AttachOperationFailedException(message);
                 }
             }
 
             // return the input stream
-            return is;
+            return in;
 
         } catch (IOException ioe) {
             closePipe(hPipe);
--- a/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WindowUpdateSender.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/WindowUpdateSender.java	Wed Jul 05 23:25:53 2017 +0200
@@ -20,6 +20,7 @@
  *
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
+ * questions.
  */
 package jdk.incubator.http;
 
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Main.java	Wed Jul 05 23:25:53 2017 +0200
@@ -71,6 +71,7 @@
 import static java.util.jar.JarFile.MANIFEST_NAME;
 import static java.util.stream.Collectors.joining;
 import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+import static sun.tools.jar.Validator.ENTRYNAME_COMPARATOR;
 
 /**
  * This class implements a simple utility for creating files in the JAR
@@ -132,6 +133,10 @@
     // if --release option found followed by at least file
     boolean isMultiRelease;
 
+    // The last parsed --release value, if any. Used in conjunction with
+    // "-d,--describe-module" to select the operative module descriptor.
+    int releaseValue = -1;
+
     /*
      * cflag: create
      * uflag: update
@@ -413,7 +418,7 @@
                     }
                 } else {
                     try (FileInputStream fin = new FileInputStream(FileDescriptor.in)) {
-                        found = describeModule(fin);
+                        found = describeModuleFromStream(fin);
                     }
                 }
                 if (!found)
@@ -604,11 +609,6 @@
         /* parse file arguments */
         int n = args.length - count;
         if (n > 0) {
-            if (dflag) {
-                // "--describe-module/-d" does not require file argument(s)
-                usageError(formatMsg("error.bad.dflag", args[count]));
-                return false;
-            }
             int version = BASE_VERSION;
             int k = 0;
             String[] nameBuf = new String[n];
@@ -616,6 +616,12 @@
             try {
                 for (int i = count; i < args.length; i++) {
                     if (args[i].equals("-C")) {
+                        if (dflag) {
+                            // "--describe-module/-d" does not require file argument(s),
+                            // but does accept --release
+                            usageError(getMsg("error.bad.dflag"));
+                            return false;
+                        }
                         /* change the directory */
                         String dir = args[++i];
                         dir = (dir.endsWith(File.separator) ?
@@ -649,8 +655,15 @@
                         k = 0;
                         nameBuf = new String[n];
                         version = v;
+                        releaseValue = version;
                         pathsMap.put(version, new HashSet<>());
                     } else {
+                        if (dflag) {
+                            // "--describe-module/-d" does not require file argument(s),
+                            // but does accept --release
+                            usageError(getMsg("error.bad.dflag"));
+                            return false;
+                        }
                         nameBuf[k++] = args[i];
                     }
                 }
@@ -756,7 +769,7 @@
      * can be found by recursively descending directories.
      *
      * @param dir    parent directory
-     * @param file s list of files to expand
+     * @param files  list of files to expand
      * @param cpaths set of directories specified by -C option for the files
      * @throws IOException if an I/O error occurs
      */
@@ -1721,23 +1734,62 @@
 
     // Modular jar support
 
-    static <T> String toString(Collection<T> c,
-                               CharSequence prefix,
-                               CharSequence suffix ) {
-        if (c.isEmpty())
-            return "";
-        return c.stream().map(e -> e.toString())
-                           .collect(joining(", ", prefix, suffix));
+    /**
+     * Associates a module descriptor's zip entry name along with its
+     * bytes and an optional URI. Used when describing modules.
+     */
+    interface ModuleInfoEntry {
+       String name();
+       Optional<String> uriString();
+       InputStream bytes() throws IOException;
     }
 
+    static class ZipFileModuleInfoEntry implements ModuleInfoEntry {
+        private final ZipFile zipFile;
+        private final ZipEntry entry;
+        ZipFileModuleInfoEntry(ZipFile zipFile, ZipEntry entry) {
+            this.zipFile = zipFile;
+            this.entry = entry;
+        }
+        @Override public String name() { return entry.getName(); }
+        @Override public InputStream bytes() throws IOException {
+            return zipFile.getInputStream(entry);
+        }
+        /** Returns an optional containing the effective URI. */
+        @Override public Optional<String> uriString() {
+            String uri = (Paths.get(zipFile.getName())).toUri().toString();
+            uri = "jar:" + uri + "/!" + entry.getName();
+            return Optional.of(uri);
+        }
+    }
+
+    static class StreamedModuleInfoEntry implements ModuleInfoEntry {
+        private final String name;
+        private final byte[] bytes;
+        StreamedModuleInfoEntry(String name, byte[] bytes) {
+            this.name = name;
+            this.bytes = bytes;
+        }
+        @Override public String name() { return name; }
+        @Override public InputStream bytes() throws IOException {
+            return new ByteArrayInputStream(bytes);
+        }
+        /** Returns an empty optional. */
+        @Override public Optional<String> uriString() {
+            return Optional.empty();  // no URI can be derived
+        }
+    }
+
+    /** Describes a module from a given zip file. */
     private boolean describeModule(ZipFile zipFile) throws IOException {
-        ZipEntry[] zes = zipFile.stream()
-            .filter(e -> isModuleInfoEntry(e.getName()))
-            .sorted(Validator.ENTRY_COMPARATOR)
-            .toArray(ZipEntry[]::new);
+        ZipFileModuleInfoEntry[] infos = zipFile.stream()
+                .filter(e -> isModuleInfoEntry(e.getName()))
+                .sorted(Validator.ENTRY_COMPARATOR)
+                .map(e -> new ZipFileModuleInfoEntry(zipFile, e))
+                .toArray(ZipFileModuleInfoEntry[]::new);
 
-        if (zes.length == 0) {
-            // No module descriptor found, derive the automatic module name
+        if (infos.length == 0) {
+            // No module descriptor found, derive and describe the automatic module
             String fn = zipFile.getName();
             ModuleFinder mf = ModuleFinder.of(Paths.get(fn));
             try {
@@ -1747,8 +1799,8 @@
                     return true;
                 }
                 ModuleDescriptor md = mref.iterator().next().descriptor();
-                output(getMsg("out.automodule"));
-                describeModule(md, null, null, "automatic");
+                output(getMsg("out.automodule") + "\n");
+                describeModule(md, null, null, "");
             } catch (FindException e) {
                 String msg = formatMsg("error.unable.derive.automodule", fn);
                 Throwable t = e.getCause();
@@ -1757,46 +1809,117 @@
                 output(msg);
             }
         } else {
-            for (ZipEntry ze : zes) {
-                try (InputStream is = zipFile.getInputStream(ze)) {
-                    describeModule(is, ze.getName());
-                }
-            }
+            return describeModuleFromEntries(infos);
         }
         return true;
     }
 
-    private boolean describeModule(FileInputStream fis)
+    private boolean describeModuleFromStream(FileInputStream fis)
         throws IOException
     {
+        List<ModuleInfoEntry> infos = new LinkedList<>();
+
         try (BufferedInputStream bis = new BufferedInputStream(fis);
              ZipInputStream zis = new ZipInputStream(bis)) {
             ZipEntry e;
             while ((e = zis.getNextEntry()) != null) {
                 String ename = e.getName();
-                if (isModuleInfoEntry(ename)){
-                    moduleInfos.put(ename, zis.readAllBytes());
+                if (isModuleInfoEntry(ename)) {
+                    infos.add(new StreamedModuleInfoEntry(ename, zis.readAllBytes()));
                 }
             }
         }
-        if (moduleInfos.size() == 0)
+
+        if (infos.size() == 0)
             return false;
-        String[] names = moduleInfos.keySet().stream()
-            .sorted(Validator.ENTRYNAME_COMPARATOR)
-            .toArray(String[]::new);
-        for (String name : names) {
-            describeModule(new ByteArrayInputStream(moduleInfos.get(name)), name);
+
+        ModuleInfoEntry[] sorted = infos.stream()
+                .sorted(Comparator.comparing(ModuleInfoEntry::name, ENTRYNAME_COMPARATOR))
+                .toArray(ModuleInfoEntry[]::new);
+
+        return describeModuleFromEntries(sorted);
+    }
+
+    private boolean lessThanEqualReleaseValue(ModuleInfoEntry entry) {
+        return intVersionFromEntry(entry) <= releaseValue ? true : false;
+    }
+
+    private static String versionFromEntryName(String name) {
+        String s = name.substring(VERSIONS_DIR_LENGTH);
+        return s.substring(0, s.indexOf("/"));
+    }
+
+    private static int intVersionFromEntry(ModuleInfoEntry entry) {
+        String name = entry.name();
+        if (!name.startsWith(VERSIONS_DIR))
+            return BASE_VERSION;
+
+        String s = name.substring(VERSIONS_DIR_LENGTH);
+        s = s.substring(0, s.indexOf('/'));
+        return Integer.valueOf(s);
+    }
+
+    /**
+     * Describes a single module descriptor, determined by the specified
+     * --release, if any, from the given ordered entries.
+     * The given infos must be ordered as per ENTRY_COMPARATOR.
+     */
+    private boolean describeModuleFromEntries(ModuleInfoEntry[] infos)
+        throws IOException
+    {
+        assert infos.length > 0;
+
+        // Informative: output all non-root descriptors, if any
+        String releases = Arrays.stream(infos)
+                .filter(e -> !e.name().equals(MODULE_INFO))
+                .map(ModuleInfoEntry::name)
+                .map(Main::versionFromEntryName)
+                .collect(joining(" "));
+        if (!releases.equals(""))
+            output("releases: " + releases + "\n");
+
+        // Describe the operative descriptor for the specified --release, if any
+        if (releaseValue != -1) {
+            ModuleInfoEntry entry = null;
+            int i = 0;
+            while (i < infos.length && lessThanEqualReleaseValue(infos[i])) {
+                entry = infos[i];
+                i++;
+            }
+
+            if (entry == null) {
+                output(formatMsg("error.no.operative.descriptor",
+                                 String.valueOf(releaseValue)));
+                return false;
+            }
+
+            String uriString = entry.uriString().orElse("");
+            try (InputStream is = entry.bytes()) {
+                describeModule(is, uriString);
+            }
+        } else {
+            // no specific --release specified, output the root, if any
+            if (infos[0].name().equals(MODULE_INFO)) {
+                String uriString = infos[0].uriString().orElse("");
+                try (InputStream is = infos[0].bytes()) {
+                    describeModule(is, uriString);
+                }
+            } else {
+                // no root, output message to specify --release
+                output(getMsg("error.no.root.descriptor"));
+            }
         }
         return true;
     }
 
     static <T> String toString(Collection<T> set) {
         if (set.isEmpty()) { return ""; }
-        return set.stream().map(e -> e.toString().toLowerCase(Locale.ROOT))
-                  .collect(joining(" "));
+        return " " + set.stream().map(e -> e.toString().toLowerCase(Locale.ROOT))
+                  .sorted().collect(joining(" "));
     }
 
-    private void describeModule(InputStream entryInputStream, String ename)
+
+    private void describeModule(InputStream entryInputStream, String uriString)
         throws IOException
     {
         ModuleInfo.Attributes attrs = ModuleInfo.read(entryInputStream, null);
@@ -1804,71 +1927,94 @@
         ModuleTarget target = attrs.target();
         ModuleHashes hashes = attrs.recordedHashes();
 
-        describeModule(md, target, hashes, ename);
+        describeModule(md, target, hashes, uriString);
     }
 
     private void describeModule(ModuleDescriptor md,
                                 ModuleTarget target,
                                 ModuleHashes hashes,
-                                String ename)
+                                String uriString)
         throws IOException
     {
         StringBuilder sb = new StringBuilder();
-        sb.append("\nmodule ")
-          .append(md.toNameAndVersion())
-          .append(" (").append(ename).append(")");
+
+        sb.append(md.toNameAndVersion());
+
+        if (!uriString.equals(""))
+            sb.append(" ").append(uriString);
+        if (md.isOpen())
+            sb.append(" open");
+        if (md.isAutomatic())
+            sb.append(" automatic");
+        sb.append("\n");
 
-        if (md.isOpen())
-            sb.append("\n  open ");
+        // unqualified exports (sorted by package)
+        md.exports().stream()
+                .sorted(Comparator.comparing(Exports::source))
+                .filter(e -> !e.isQualified())
+                .forEach(e -> sb.append("exports ").append(e.source())
+                                .append(toString(e.modifiers())).append("\n"));
+
+        // dependences
+        md.requires().stream().sorted()
+                .forEach(r -> sb.append("requires ").append(r.name())
+                                .append(toString(r.modifiers())).append("\n"));
 
-        md.requires().stream()
-            .sorted(Comparator.comparing(Requires::name))
-            .forEach(r -> {
-                sb.append("\n  requires ");
-                if (!r.modifiers().isEmpty())
-                    sb.append(toString(r.modifiers())).append(" ");
-                sb.append(r.name());
-            });
+        // service use and provides
+        md.uses().stream().sorted()
+                .forEach(s -> sb.append("uses ").append(s).append("\n"));
+
+        md.provides().stream()
+                .sorted(Comparator.comparing(Provides::service))
+                .forEach(p -> sb.append("provides ").append(p.service())
+                                .append(" with")
+                                .append(toString(p.providers()))
+                                .append("\n"));
 
-        md.uses().stream().sorted()
-            .forEach(p -> sb.append("\n  uses ").append(p));
+        // qualified exports
+        md.exports().stream()
+                .sorted(Comparator.comparing(Exports::source))
+                .filter(Exports::isQualified)
+                .forEach(e -> sb.append("qualified exports ").append(e.source())
+                                .append(" to").append(toString(e.targets()))
+                                .append("\n"));
 
-        md.exports().stream()
-            .sorted(Comparator.comparing(Exports::source))
-            .forEach(p -> sb.append("\n  exports ").append(p));
+        // open packages
+        md.opens().stream()
+                .sorted(Comparator.comparing(Opens::source))
+                .filter(o -> !o.isQualified())
+                .forEach(o -> sb.append("opens ").append(o.source())
+                                 .append(toString(o.modifiers()))
+                                 .append("\n"));
 
         md.opens().stream()
-            .sorted(Comparator.comparing(Opens::source))
-            .forEach(p -> sb.append("\n  opens ").append(p));
+                .sorted(Comparator.comparing(Opens::source))
+                .filter(Opens::isQualified)
+                .forEach(o -> sb.append("qualified opens ").append(o.source())
+                                 .append(toString(o.modifiers()))
+                                 .append(" to").append(toString(o.targets()))
+                                 .append("\n"));
 
-        Set<String> concealed = new HashSet<>(md.packages());
+        // non-exported/non-open packages
+        Set<String> concealed = new TreeSet<>(md.packages());
         md.exports().stream().map(Exports::source).forEach(concealed::remove);
         md.opens().stream().map(Opens::source).forEach(concealed::remove);
-        concealed.stream().sorted()
-            .forEach(p -> sb.append("\n  contains ").append(p));
+        concealed.forEach(p -> sb.append("contains ").append(p).append("\n"));
 
-        md.provides().stream()
-            .sorted(Comparator.comparing(Provides::service))
-            .forEach(p -> sb.append("\n  provides ").append(p.service())
-                            .append(" with ")
-                            .append(toString(p.providers())));
-
-        md.mainClass().ifPresent(v -> sb.append("\n  main-class " + v));
+        md.mainClass().ifPresent(v -> sb.append("main-class ").append(v).append("\n"));
 
         if (target != null) {
-            String osName = target.osName();
-            if (osName != null)
-                sb.append("\n  operating-system-name " + osName);
-            String osArch = target.osArch();
-            if (osArch != null)
-                sb.append("\n  operating-system-architecture " + osArch);
+            String targetPlatform = target.targetPlatform();
+            if (!targetPlatform.isEmpty())
+                sb.append("platform ").append(targetPlatform).append("\n");
        }
 
        if (hashes != null) {
            hashes.names().stream().sorted().forEach(
-                   mod -> sb.append("\n  hashes ").append(mod).append(" ")
+                   mod -> sb.append("hashes ").append(mod).append(" ")
                             .append(hashes.algorithm()).append(" ")
-                            .append(toHex(hashes.hashFor(mod))));
+                            .append(toHex(hashes.hashFor(mod)))
+                            .append("\n"));
         }
 
         output(sb.toString());
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/Validator.java	Wed Jul 05 23:25:53 2017 +0200
@@ -116,7 +116,7 @@
             // version number strings need to be sorted numerically
             n = VERSIONS_DIR.length();   // skip the common prefix
             int i1 = s1.indexOf('/', n);
-            int i2 = s1.indexOf('/', n);
+            int i2 = s2.indexOf('/', n);
             if (i1 == -1) throw new InvalidJarException(s1);
             if (i2 == -1) throw new InvalidJarException(s2);
             // shorter version numbers go first
--- a/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jartool/share/classes/sun/tools/jar/resources/jar.properties	Wed Jul 05 23:25:53 2017 +0200
@@ -45,7 +45,7 @@
 	'e' flag and manifest with the 'Main-Class' attribute cannot be specified \n\
 	 together!
 error.bad.dflag=\
-        '-d, --describe-module' option requires no input file(s) to be specified: {0}
+        '-d, --describe-module' option requires no input file(s) to be specified
 error.bad.reason=\
         bad reason: {0}, must be one of deprecated, deprecated-for-removal, or incubating
 error.nosuch.fileordir=\
@@ -62,6 +62,10 @@
         Hashing module {0} dependences, unable to find module {1} on module path
 error.module.options.without.info=\
         One of --module-version or --hash-modules without module-info.class
+error.no.operative.descriptor=\
+        No operative descriptor for release: {0}
+error.no.root.descriptor=\
+        No root module descriptor, specify --release
 error.unable.derive.automodule=\
         Unable to derive module descriptor for: {0}
 error.unexpected.module-info=\
--- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassType.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ClassType.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -217,9 +217,6 @@
      * a member of this class or a superclass, if the size of the argument list
      * does not match the number of declared arguments for the method, or
      * if the method is an initializer, constructor or static intializer.
-     * @throws {@link InvalidTypeException} if any argument in the
-     * argument list is not assignable to the corresponding method argument
-     * type.
      * @throws ClassNotLoadedException if any argument type has not yet been loaded
      * through the appropriate class loader.
      * @throws IncompatibleThreadStateException if the specified thread has not
@@ -322,9 +319,6 @@
      * a member of this class, if the size of the argument list
      * does not match the number of declared arguments for the constructor,
      * or if the method is not a constructor.
-     * @throws {@link InvalidTypeException} if any argument in the
-     * argument list is not assignable to the corresponding method argument
-     * type.
      * @throws ClassNotLoadedException if any argument type has not yet been loaded
      * through the appropriate class loader.
      * @throws IncompatibleThreadStateException if the specified thread has not
--- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InterfaceType.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/InterfaceType.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -168,9 +168,6 @@
      * a member of this interface, if the size of the argument list
      * does not match the number of declared arguments for the method, or
      * if the method is not static or is a static initializer.
-     * @throws {@link InvalidTypeException} if any argument in the
-     * argument list is not assignable to the corresponding method argument
-     * type.
      * @throws ClassNotLoadedException if any argument type has not yet been loaded
      * through the appropriate class loader.
      * @throws IncompatibleThreadStateException if the specified thread has not
--- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/JDIPermission.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/JDIPermission.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,8 +40,9 @@
  * permission allows, and discusses the risks of granting code the
  * permission.
  *
- * <table border=1 cellpadding=5 summary="Table shows permission
- * target name, what the permission allows, and associated risks">
+ * <table border="1" cellpadding=5>
+ * <caption style="display:none">Table shows permission target name, what the
+ * permission allows, and associated risks</caption>
  * <tr>
  * <th>Permission Target Name</th>
  * <th>What the Permission Allows</th>
--- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Location.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Location.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,7 +41,7 @@
  * Several mirror interfaces have locations. Each such mirror
  * extends a {@link Locatable} interface.
  * <p>
- * <a name="strata"><b>Strata</b></a>
+ * <a id="strata"><b>Strata</b></a>
  * <p>
  * The source information for a Location is dependent on the
  * <i>stratum</i> which is used. A stratum is a source code
--- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ObjectReference.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/ObjectReference.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -249,9 +249,6 @@
      * if the method is a constructor or static initializer, or
      * if {@link #INVOKE_NONVIRTUAL} is specified and the method is
      * abstract.
-     * @throws {@link InvalidTypeException} if any argument in the
-     * argument list is not assignable to the corresponding method argument
-     * type.
      * @throws ClassNotLoadedException if any argument type has not yet been loaded
      * through the appropriate class loader.
      * @throws IncompatibleThreadStateException if the specified thread has not
--- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Type.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Type.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,13 +45,14 @@
  * <P>
  * The following table illustrates which subinterfaces of Type
  * are used to mirror types in the target VM --
- * <TABLE BORDER=1 SUMMARY="Maps each type declared in target to a mirrored
- *  instance of a subinterface of PrimitiveType or ReferenceType">
- * <TR BGCOLOR="#EEEEFF">
+ * <TABLE BORDER="1">
+ * <CAPTION style="display:none">Maps each type declared in target to a mirrored
+ *  instance of a subinterface of PrimitiveType or ReferenceType"</CAPTION>
+ * <TR style="background-color:#EEEEFF">
  *   <TH id="primtype" colspan=3>Subinterfaces of {@link PrimitiveType}</TH>
- * <TR BGCOLOR="#EEEEFF">
- *   <TH id="declared" align="left" colspan=2>Type declared in target as</TH>
- *   <TH id="mirrored" align="left">Is mirrored as an instance of</TH>
+ * <TR style="background-color:#EEEEFF">
+ *   <TH id="declared" style="text-align:left" colspan=2>Type declared in target as</TH>
+ *   <TH id="mirrored" style="text-align:left">Is mirrored as an instance of</TH>
  * <TR>
  *   <TD headers="primtype declared" colspan=2><CODE>boolean</CODE></TD>
  *   <TD headers="primtype mirrored"> {@link BooleanType}</TD>
@@ -79,12 +80,12 @@
  * <TR>
  *   <TD headers="primtype declared" colspan=2><CODE>void</CODE></TD>
  *   <TD headers="primtype mirrored">{@link VoidType}</TD>
- * <TR BGCOLOR="#EEEEFF">
+ * <TR style="background-color:#EEEEFF">
  *   <TH id="reftype"  colspan=3>Subinterfaces of {@link ReferenceType}</TH>
- * <TR BGCOLOR="#EEEEFF">
- *   <TH id="declared2" align="left">Type declared in target as</TH>
- *   <TH id="example2"  align="left">For example</TH>
- *   <TH id="mirrored2" align="left">Is mirrored as an instance of</TH>
+ * <TR style="background-color:#EEEEFF">
+ *   <TH id="declared2"style="text-align:left">Type declared in target as</TH>
+ *   <TH id="example2"  style="text-align:left">For example</TH>
+ *   <TH id="mirrored2" style="text-align:left">Is mirrored as an instance of</TH>
  * <TR>
  *   <TD headers="reftype declared2"><I>a class</I></TD>
  *   <TD headers="reftype example2"><CODE>Date</CODE></TD>
--- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Value.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/Value.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@
  * value hierarchy encompassing primitive values and object values.
  * <P>
  * Some examples of where values may be accessed:
- * <BLOCKQUOTE><TABLE SUMMARY="layout">
+ * <BLOCKQUOTE><TABLE><CAPTION style="display:none">layout</CAPTION>
  * <TR>
  *   <TD>{@link ObjectReference#getValue(com.sun.jdi.Field)
  *                 ObjectReference.getValue(Field)}
@@ -52,15 +52,16 @@
  * <P>
  * The following table illustrates which subinterfaces of Value
  * are used to mirror values in the target VM --
- * <TABLE BORDER=1 SUMMARY="Maps each kind of value to a mirrored
- *  instance of a subinterface of Value">
- * <TR BGCOLOR="#EEEEFF">
+ * <TABLE BORDER="1">
+ * <CAPTION style="display:none">Maps each kind of value to a mirrored
+ *  instance of a subinterface of Value</CAPTION>
+ * <TR style="background-color:#EEEEFF">
  *   <TH id="primval" colspan=4>Subinterfaces of {@link PrimitiveValue}</TH>
- * <TR BGCOLOR="#EEEEFF">
- *   <TH id="kind"     align="left">Kind of value</TH>
- *   <TH id="example"  align="left">For example -<br>expression in target</TH>
- *   <TH id="mirrored" align="left">Is mirrored as an<br>instance of</TH>
- *   <TH id="type"     align="left">{@link Type} of value<br>{@link #type() Value.type()}</TH>
+ * <TR style="background-color:#EEEEFF">
+ *   <TH id="kind"     style="text-align:left">Kind of value</TH>
+ *   <TH id="example"  style="text-align:left">For example -<br>expression in target</TH>
+ *   <TH id="mirrored" style="text-align:left">Is mirrored as an<br>instance of</TH>
+ *   <TH id="type"     style="text-align:left">{@link Type} of value<br>{@link #type() Value.type()}</TH>
  * <TR>
  *   <TD headers="primval kind">     a boolean</TD>
  *   <TD headers="primval example">  {@code true}</TD>
@@ -106,13 +107,13 @@
  *   <TD headers="primval example">  </TD>
  *   <TD headers="primval mirrored"> {@link VoidValue}</TD>
  *   <TD headers="primval type">     {@link VoidType}</TD>
- * <TR BGCOLOR="#EEEEFF">
+ * <TR style="background-color:#EEEEFF">
  *   <TH id="objref" colspan=4>Subinterfaces of {@link ObjectReference}</TH>
- * <TR BGCOLOR="#EEEEFF">
- *   <TH id="kind2"     align="left">Kind of value</TH>
- *   <TH id="example2"  align="left">For example -<br>expression in target</TH>
- *   <TH id="mirrored2" align="left">Is mirrored as an<br>instance of</TH>
- *   <TH id="type2"     align="left">{@link Type} of value<br>{@link #type() Value.type()}</TH>
+ * <TR style="background-color:#EEEEFF">
+ *   <TH id="kind2"     style="text-align:left">Kind of value</TH>
+ *   <TH id="example2"  style="text-align:left">For example -<br>expression in target</TH>
+ *   <TH id="mirrored2" style="text-align:left">Is mirrored as an<br>instance of</TH>
+ *   <TH id="type2"     style="text-align:left">{@link Type} of value<br>{@link #type() Value.type()}</TH>
  * <TR>
  *   <TD headers="objref kind2">     a class instance</TD>
  *   <TD headers="objref example2">  {@code this}</TD>
@@ -148,13 +149,13 @@
  *   <TD headers="objref example2">  {@code this.getClass()}<br>&nbsp;&nbsp;{@code .getClassLoader()}</TD>
  *   <TD headers="objref mirrored2"> {@link ClassLoaderReference}</TD>
  *   <TD headers="objref type2">     {@link ClassType}</TD>
- * <TR BGCOLOR="#EEEEFF">
+ * <TR style="background-color:#EEEEFF">
  *   <TH id="other" colspan=4>Other</TH>
- * <TR BGCOLOR="#EEEEFF">
- *   <TD id="kind3"     align="left">Kind of value</TD>
- *   <TD id="example3"  align="left">For example -<br>expression in target</TD>
- *   <TD id="mirrored3" align="left">Is mirrored as</TD>
- *   <TD id="type3"     align="left">{@link Type} of value</TD>
+ * <TR style="background-color:#EEEEFF">
+ *   <TD id="kind3"     style="text-align:left">Kind of value</TD>
+ *   <TD id="example3"  style="text-align:left">For example -<br>expression in target</TD>
+ *   <TD id="mirrored3" style="text-align:left">Is mirrored as</TD>
+ *   <TD id="type3"     style="text-align:left">{@link Type} of value</TD>
  * <TR>
  *   <TD headers="other kind3">     null</TD>
  *   <TD headers="other example3">  {@code null}</TD>
--- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/VirtualMachineManager.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,8 +51,8 @@
  * Some {@link com.sun.jdi.connect.Connector} implementations may require slightly
  * different handling than presented below.
  *
- * <TABLE BORDER WIDTH="75%" SUMMARY="Four scenarios for connecting a debugger
- *  to a virtual machine">
+ * <TABLE BORDER="1" style="width:75%">
+ * <CAPTION style="display:none">Four scenarios for connecting a debugger to a virtual machine"</CAPTION>
  * <TR>
  * <TH scope=col>Scenario</TH>
  * <TH scope=col>Description</TH>
--- a/jdk/src/jdk.jdi/share/classes/com/sun/jdi/doc-files/signature.html	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jdi/share/classes/com/sun/jdi/doc-files/signature.html	Wed Jul 05 23:25:53 2017 +0200
@@ -4,7 +4,7 @@
 JDI Type Signatures
 </TITLE>
 </HEAD>
-<BODY BGCOLOR="white">
+<BODY style="background-color:white">
 <dl><dd>
 <Table Border="0">
 <caption><font size=5><b>JDI Type Signatures</b></font></caption>
--- a/jdk/src/jdk.jdi/share/classes/module-info.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jdi/share/classes/module-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -45,8 +45,8 @@
  * Platform Debugger Architecture documentation</a> for this release and the <a
  * href="http://java.sun.com/products/jpda">Java Platform Debugger Architecture
  * website</a>.
- * <p>
- * <font size="+1"><b>Global Exceptions:</b></font>
+ * <p style="font-size:larger">
+ * <b>Global Exceptions:</b>
  * <p>
  * This section documents exceptions which apply to the entire API and are thus
  * not documented on individual methods.
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java	Wed Jul 05 23:25:53 2017 +0200
@@ -152,14 +152,14 @@
     @Override
     public void storeFiles(ResourcePool files) {
         try {
-            String targetOsName = files.moduleView()
-                                       .findModule("java.base")
-                                       .map(ResourcePoolModule::osName)
-                                       .orElse(null);
-            if (targetOsName == null) {
+            String value = files.moduleView()
+                                .findModule("java.base")
+                                .map(ResourcePoolModule::targetPlatform)
+                                .orElse(null);
+            if (value == null) {
                 throw new PluginException("ModuleTarget attribute is missing for java.base module");
             }
-            this.targetPlatform = Platform.toPlatform(targetOsName);
+            this.targetPlatform = Platform.toPlatform(value);
 
             checkResourcePool(files);
 
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImagePluginStack.java	Wed Jul 05 23:25:53 2017 +0200
@@ -324,15 +324,9 @@
             }
 
             @Override
-            public String osName() {
+            public String targetPlatform() {
                 initModuleAttributes();
-                return target != null? target.osName() : null;
-            }
-
-            @Override
-            public String osArch() {
-                initModuleAttributes();
-                return target != null? target.osArch() : null;
+                return target != null? target.targetPlatform() : null;
             }
 
             private void initModuleAttributes() {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Platform.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Platform.java	Wed Jul 05 23:25:53 2017 +0200
@@ -40,12 +40,17 @@
     UNKNOWN;
 
     /**
-     * Returns the {@code Platform} of the given OS name specified
+     * Returns the {@code Platform} derived from the target platform
      * in the {@code ModuleTarget} attribute.
-     *
-     * @param osName OS name in ModuleTarget attribute
      */
-    public static Platform toPlatform(String osName) {
+    public static Platform toPlatform(String targetPlatform) {
+        String osName;
+        int index = targetPlatform.indexOf("-");
+        if (index < 0) {
+            osName = targetPlatform;
+        } else {
+            osName = targetPlatform.substring(0, index);
+        }
         try {
             return Platform.valueOf(osName.toUpperCase(Locale.ENGLISH));
         } catch (IllegalArgumentException e) {
@@ -57,9 +62,9 @@
      * Returns the {@code Platform} to which the given module is target to.
      */
     public static Platform getTargetPlatform(ResourcePoolModule module) {
-        String osName = module.osName();
-        if (osName != null) {
-            return toPlatform(osName);
+        String targetPlatform = module.targetPlatform();
+        if (targetPlatform != null) {
+            return toPlatform(targetPlatform);
         } else {
             return Platform.UNKNOWN;
         }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePoolManager.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -110,15 +110,9 @@
         }
 
         @Override
-        public String osName() {
+        public String targetPlatform() {
             initModuleAttributes();
-            return target != null? target.osName() : null;
-        }
-
-        @Override
-        public String osArch() {
-            initModuleAttributes();
-            return target != null? target.osArch() : null;
+            return target != null? target.targetPlatform() : null;
         }
 
         private void initModuleAttributes() {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java	Wed Jul 05 23:25:53 2017 +0200
@@ -33,13 +33,13 @@
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Optional;
 import java.util.Properties;
 import java.util.Set;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 import jdk.tools.jlink.internal.ModuleSorter;
 import jdk.tools.jlink.internal.Utils;
+import jdk.tools.jlink.plugin.PluginException;
 import jdk.tools.jlink.plugin.ResourcePool;
 import jdk.tools.jlink.plugin.ResourcePoolBuilder;
 import jdk.tools.jlink.plugin.ResourcePoolEntry;
@@ -132,18 +132,16 @@
     public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
         in.transformAndCopy(Function.identity(), out);
 
-        Optional<ResourcePoolModule> javaBase = in.moduleView().findModule("java.base");
-        javaBase.ifPresent(mod -> {
-            // fill release information available from transformed "java.base" module!
-            ModuleDescriptor desc = mod.descriptor();
-            desc.version().ifPresent(s -> release.put("JAVA_VERSION",
-                    quote(parseVersion(s.toString()))));
-            desc.version().ifPresent(s -> release.put("JAVA_FULL_VERSION",
-                    quote(s.toString())));
+        ResourcePoolModule javaBase = in.moduleView().findModule("java.base")
+                                                     .orElse(null);
+        if (javaBase == null || javaBase.targetPlatform() == null) {
+            throw new PluginException("ModuleTarget attribute is missing for java.base module");
+        }
 
-            release.put("OS_NAME", quote(mod.osName()));
-            release.put("OS_ARCH", quote(mod.osArch()));
-        });
+        // fill release information available from transformed "java.base" module!
+        ModuleDescriptor desc = javaBase.descriptor();
+        desc.version().ifPresent(v -> release.put("JAVA_VERSION",
+                                                  quote(parseVersion(v))));
 
         // put topological sorted module names separated by space
         release.put("MODULES",  new ModuleSorter(in.moduleView())
@@ -152,14 +150,15 @@
 
         // create a TOP level ResourcePoolEntry for "release" file.
         out.add(ResourcePoolEntry.create("/java.base/release",
-            ResourcePoolEntry.Type.TOP, releaseFileContent()));
+                                         ResourcePoolEntry.Type.TOP,
+                                         releaseFileContent()));
         return out.build();
     }
 
     // Parse version string and return a string that includes only version part
     // leaving "pre", "build" information. See also: java.lang.Runtime.Version.
-    private static String parseVersion(String str) {
-        return Runtime.Version.parse(str)
+    private static String parseVersion(ModuleDescriptor.Version v) {
+        return Runtime.Version.parse(v.toString())
                       .version()
                       .stream()
                       .map(Object::toString)
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java	Wed Jul 05 23:25:53 2017 +0200
@@ -211,8 +211,7 @@
             // drop target attribute only if any OS property is present
             ModuleTarget target = attrs.target();
             if (dropModuleTarget && target != null) {
-                this.dropModuleTarget = (target.osName() != null)
-                                        || (target.osArch() != null);
+                this.dropModuleTarget = (target.targetPlatform() != null);
             } else {
                 this.dropModuleTarget = false;
             }
@@ -377,7 +376,7 @@
             }
 
             void dropModuleTarget() {
-                extender.targetPlatform("", "");
+                extender.targetPlatform("");
             }
 
             byte[] getBytes() throws IOException {
@@ -527,8 +526,7 @@
                 ModuleDescriptor md = moduleInfo.descriptor;
                 // drop ModuleTarget attribute if java.base has all OS properties
                 ModuleTarget target = moduleInfo.target();
-                if (dropModuleTarget
-                    && (target.osName() != null) && (target.osArch() != null)) {
+                if (dropModuleTarget && target.targetPlatform() != null) {
                     dropModuleTarget = true;
                 } else {
                     dropModuleTarget = false;
@@ -543,7 +541,7 @@
             moduleInfo.validatePackages();
 
             // module-info.class may be overridden for optimization
-            // 1. update ModuleTarget attribute to drop osName, osArch, osVersion
+            // 1. update ModuleTarget attribute to drop targetPlartform
             // 2. add/update ModulePackages attribute
             if (moduleInfo.shouldRewrite()) {
                 entry = entry.copyWithContent(moduleInfo.getBytes());
@@ -655,10 +653,9 @@
                     // new ModuleTarget(String, String)
                     mv.visitTypeInsn(NEW, MODULE_TARGET_CLASSNAME);
                     mv.visitInsn(DUP);
-                    mv.visitLdcInsn(minfo.target().osName());
-                    mv.visitLdcInsn(minfo.target().osArch());
+                    mv.visitLdcInsn(minfo.target().targetPlatform());
                     mv.visitMethodInsn(INVOKESPECIAL, MODULE_TARGET_CLASSNAME,
-                        "<init>", "(Ljava/lang/String;Ljava/lang/String;)V", false);
+                        "<init>", "(Ljava/lang/String;)V", false);
 
                     mv.visitInsn(AASTORE);
                 }
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ResourcePoolModule.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ResourcePoolModule.java	Wed Jul 05 23:25:53 2017 +0200
@@ -58,18 +58,11 @@
     public ModuleDescriptor descriptor();
 
     /**
-     * The module target OS name for this module.
+     * The target platform
      *
-     * @return The module target OS name
+     * @return The target platform
      */
-    public String osName();
-
-    /**
-     * The module target OS arch for this module.
-     *
-     * @return The module target OS arch
-     */
-    public String osArch();
+    public String targetPlatform();
 
     /**
      * Retrieves all the packages located in this module.
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java	Wed Jul 05 23:25:53 2017 +0200
@@ -177,8 +177,7 @@
         ModuleFinder moduleFinder;
         Version moduleVersion;
         String mainClass;
-        String osName;
-        String osArch;
+        String targetPlatform;
         Pattern modulesToHash;
         ModuleResolution moduleResolution;
         boolean dryrun;
@@ -311,9 +310,9 @@
         try (JmodFile jf = new JmodFile(options.jmodFile)) {
             try (InputStream in = jf.getInputStream(Section.CLASSES, MODULE_INFO)) {
                 ModuleInfo.Attributes attrs = ModuleInfo.read(in, null);
-                printModuleDescriptor(attrs.descriptor(),
-                                      attrs.target(),
-                                      attrs.recordedHashes());
+                describeModule(attrs.descriptor(),
+                               attrs.target(),
+                               attrs.recordedHashes());
                 return true;
             } catch (IOException e) {
                 throw new CommandException("err.module.descriptor.not.found");
@@ -323,66 +322,92 @@
 
     static <T> String toString(Collection<T> c) {
         if (c.isEmpty()) { return ""; }
-        return c.stream().map(e -> e.toString().toLowerCase(Locale.ROOT))
-                  .collect(joining(" "));
+        return " " + c.stream().map(e -> e.toString().toLowerCase(Locale.ROOT))
+                .sorted().collect(joining(" "));
     }
 
-    private void printModuleDescriptor(ModuleDescriptor md,
-                                       ModuleTarget target,
-                                       ModuleHashes hashes)
+    private void describeModule(ModuleDescriptor md,
+                                ModuleTarget target,
+                                ModuleHashes hashes)
         throws IOException
     {
         StringBuilder sb = new StringBuilder();
-        sb.append("\n").append(md.toNameAndVersion());
+
+        sb.append(md.toNameAndVersion());
+
+        if (md.isOpen())
+            sb.append(" open");
+        if (md.isAutomatic())
+            sb.append(" automatic");
+        sb.append("\n");
+
+        // unqualified exports (sorted by package)
+        md.exports().stream()
+                .sorted(Comparator.comparing(Exports::source))
+                .filter(e -> !e.isQualified())
+                .forEach(e -> sb.append("exports ").append(e.source())
+                                .append(toString(e.modifiers())).append("\n"));
+
+        // dependences
+        md.requires().stream().sorted()
+                .forEach(r -> sb.append("requires ").append(r.name())
+                                .append(toString(r.modifiers())).append("\n"));
 
-        md.requires().stream()
-            .sorted(Comparator.comparing(Requires::name))
-            .forEach(r -> {
-                sb.append("\n  requires ");
-                if (!r.modifiers().isEmpty())
-                    sb.append(toString(r.modifiers())).append(" ");
-                sb.append(r.name());
-            });
+        // service use and provides
+        md.uses().stream().sorted()
+                .forEach(s -> sb.append("uses ").append(s).append("\n"));
+
+        md.provides().stream()
+                .sorted(Comparator.comparing(Provides::service))
+                .forEach(p -> sb.append("provides ").append(p.service())
+                                .append(" with")
+                                .append(toString(p.providers()))
+                                .append("\n"));
 
-        md.uses().stream().sorted()
-            .forEach(s -> sb.append("\n  uses ").append(s));
+        // qualified exports
+        md.exports().stream()
+                .sorted(Comparator.comparing(Exports::source))
+                .filter(Exports::isQualified)
+                .forEach(e -> sb.append("qualified exports ").append(e.source())
+                                .append(" to").append(toString(e.targets()))
+                                .append("\n"));
 
-        md.exports().stream()
-            .sorted(Comparator.comparing(Exports::source))
-            .forEach(p -> sb.append("\n  exports ").append(p));
+        // open packages
+        md.opens().stream()
+                .sorted(Comparator.comparing(Opens::source))
+                .filter(o -> !o.isQualified())
+                .forEach(o -> sb.append("opens ").append(o.source())
+                                 .append(toString(o.modifiers()))
+                                 .append("\n"));
 
         md.opens().stream()
-            .sorted(Comparator.comparing(Opens::source))
-            .forEach(p -> sb.append("\n  opens ").append(p));
+                .sorted(Comparator.comparing(Opens::source))
+                .filter(Opens::isQualified)
+                .forEach(o -> sb.append("qualified opens ").append(o.source())
+                                 .append(toString(o.modifiers()))
+                                 .append(" to").append(toString(o.targets()))
+                                 .append("\n"));
 
-        Set<String> concealed = new HashSet<>(md.packages());
+        // non-exported/non-open packages
+        Set<String> concealed = new TreeSet<>(md.packages());
         md.exports().stream().map(Exports::source).forEach(concealed::remove);
         md.opens().stream().map(Opens::source).forEach(concealed::remove);
-        concealed.stream().sorted()
-                 .forEach(p -> sb.append("\n  contains ").append(p));
+        concealed.forEach(p -> sb.append("contains ").append(p).append("\n"));
 
-        md.provides().stream()
-            .sorted(Comparator.comparing(Provides::service))
-            .forEach(p -> sb.append("\n  provides ").append(p.service())
-                            .append(" with ")
-                            .append(toString(p.providers())));
-
-        md.mainClass().ifPresent(v -> sb.append("\n  main-class " + v));
+        md.mainClass().ifPresent(v -> sb.append("main-class ").append(v).append("\n"));
 
         if (target != null) {
-            String osName = target.osName();
-            if (osName != null)
-                sb.append("\n  operating-system-name " + osName);
-            String osArch = target.osArch();
-            if (osArch != null)
-                sb.append("\n  operating-system-architecture " + osArch);
-        }
+            String targetPlatform = target.targetPlatform();
+            if (!targetPlatform.isEmpty())
+                sb.append("platform ").append(targetPlatform).append("\n");
+       }
 
-        if (hashes != null) {
-            hashes.names().stream().sorted().forEach(
-                    mod -> sb.append("\n  hashes ").append(mod).append(" ")
-                             .append(hashes.algorithm()).append(" ")
-                             .append(toHex(hashes.hashFor(mod))));
+       if (hashes != null) {
+           hashes.names().stream().sorted().forEach(
+                   mod -> sb.append("hashes ").append(mod).append(" ")
+                            .append(hashes.algorithm()).append(" ")
+                            .append(toHex(hashes.hashFor(mod)))
+                            .append("\n"));
         }
 
         out.println(sb.toString());
@@ -437,8 +462,7 @@
 
         final Version moduleVersion = options.moduleVersion;
         final String mainClass = options.mainClass;
-        final String osName = options.osName;
-        final String osArch = options.osArch;
+        final String targetPlatform = options.targetPlatform;
         final List<PathMatcher> excludes = options.excludes;
         final ModuleResolution moduleResolution = options.moduleResolution;
 
@@ -534,9 +558,10 @@
                 if (mainClass != null)
                     extender.mainClass(mainClass);
 
-                // --os-name, --os-arch
-                if (osName != null || osArch != null)
-                    extender.targetPlatform(osName, osArch);
+                // --target-platform
+                if (targetPlatform != null) {
+                    extender.targetPlatform(targetPlatform);
+                }
 
                 // --module-version
                 if (moduleVersion != null)
@@ -1327,15 +1352,10 @@
                         .withRequiredArg()
                         .withValuesConvertedBy(new ModuleVersionConverter());
 
-        OptionSpec<String> osName
-                = parser.accepts("os-name", getMessage("main.opt.os-name"))
+        OptionSpec<String> targetPlatform
+                = parser.accepts("target-platform", getMessage("main.opt.target-platform"))
                         .withRequiredArg()
-                        .describedAs(getMessage("main.opt.os-name.arg"));
-
-        OptionSpec<String> osArch
-                = parser.accepts("os-arch", getMessage("main.opt.os-arch"))
-                        .withRequiredArg()
-                        .describedAs(getMessage("main.opt.os-arch.arg"));
+                        .describedAs(getMessage("main.opt.target-platform.arg"));
 
         OptionSpec<Void> doNotResolveByDefault
                 = parser.accepts("do-not-resolve-by-default",
@@ -1400,10 +1420,8 @@
                 options.moduleVersion = getLastElement(opts.valuesOf(moduleVersion));
             if (opts.has(mainClass))
                 options.mainClass = getLastElement(opts.valuesOf(mainClass));
-            if (opts.has(osName))
-                options.osName = getLastElement(opts.valuesOf(osName));
-            if (opts.has(osArch))
-                options.osArch = getLastElement(opts.valuesOf(osArch));
+            if (opts.has(targetPlatform))
+                options.targetPlatform = getLastElement(opts.valuesOf(targetPlatform));
             if (opts.has(warnIfResolved))
                 options.moduleResolution = getLastElement(opts.valuesOf(warnIfResolved));
             if (opts.has(doNotResolveByDefault)) {
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties	Wed Jul 05 23:25:53 2017 +0200
@@ -64,10 +64,8 @@
 main.opt.main-class=Main class
 main.opt.main-class.arg=class-name
 main.opt.man-pages=Location of man pages
-main.opt.os-name=Operating system name
-main.opt.os-name.arg=os-name
-main.opt.os-arch=Operating system architecture
-main.opt.os-arch.arg=os-arch
+main.opt.target-platform=Target platform
+main.opt.target-platform.arg=target-platform
 main.opt.module-path=Module path
 main.opt.hash-modules=Compute and record hashes to tie a packaged module\
 \ with modules matching the given <regex-pattern> and depending upon it directly\
--- a/jdk/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.management.agent/share/classes/jdk/internal/agent/Agent.java	Wed Jul 05 23:25:53 2017 +0200
@@ -393,7 +393,7 @@
         } catch (JdpException e) {
             error(e);
         } catch (AgentConfigurationError err) {
-            error(err.getError(), err.getParams());
+            error(err);
         }
     }
 
@@ -454,7 +454,7 @@
             }
 
         } catch (AgentConfigurationError e) {
-            error(e.getError(), e.getParams());
+            error(e);
         } catch (Exception e) {
             error(e);
         }
@@ -665,18 +665,6 @@
         throw new RuntimeException(keyText);
     }
 
-    public static void error(String key, String[] params) {
-        if (params == null || params.length == 0) {
-            error(key);
-        } else {
-            StringBuilder message = new StringBuilder(params[0]);
-            for (int i = 1; i < params.length; i++) {
-                message.append(' ').append(params[i]);
-            }
-            error(key, message.toString());
-        }
-    }
-
     public static void error(String key, String message) {
         String keyText = getText(key);
         System.err.print(getText("agent.err.error") + ": " + keyText);
@@ -690,6 +678,23 @@
         throw new RuntimeException(e);
     }
 
+    public static void error(AgentConfigurationError e) {
+        String keyText = getText(e.getError());
+        String[] params = e.getParams();
+
+        System.err.print(getText("agent.err.error") + ": " + keyText);
+
+        if (params != null && params.length != 0) {
+           StringBuffer message = new StringBuffer(params[0]);
+           for (int i = 1; i < params.length; i++) {
+               message.append(" " + params[i]);
+           }
+           System.err.println(": " + message);
+        }
+        e.printStackTrace();
+        throw new RuntimeException(e);
+    }
+
     public static void warning(String key, String message) {
         System.err.print(getText("agent.err.warning") + ": " + getText(key));
         System.err.println(": " + message);
--- a/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -872,7 +872,7 @@
     public final boolean compareAndSwapObject(Object o, long offset,
                                               Object expected,
                                               Object x) {
-        return theInternalUnsafe.compareAndSwapObject(o, offset, expected, x);
+        return theInternalUnsafe.compareAndSetObject(o, offset, expected, x);
     }
 
     /**
@@ -888,7 +888,7 @@
     public final boolean compareAndSwapInt(Object o, long offset,
                                            int expected,
                                            int x) {
-        return theInternalUnsafe.compareAndSwapInt(o, offset, expected, x);
+        return theInternalUnsafe.compareAndSetInt(o, offset, expected, x);
     }
 
     /**
@@ -904,7 +904,7 @@
     public final boolean compareAndSwapLong(Object o, long offset,
                                             long expected,
                                             long x) {
-        return theInternalUnsafe.compareAndSwapLong(o, offset, expected, x);
+        return theInternalUnsafe.compareAndSetLong(o, offset, expected, x);
     }
 
     /**
--- a/jdk/test/ProblemList.txt	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/ProblemList.txt	Wed Jul 05 23:25:53 2017 +0200
@@ -99,9 +99,8 @@
 #  1. Make sure test passes on all platforms with samevm, or mark it othervm
 #  2. Make sure test passes on all platforms when run with it's entire group
 #  3. Make sure both VMs are tested, -server and -client, if possible
-#  4. Make sure you try the -d64 option on Solaris
-#  5. Use a tool like JPRT or something to verify these results
-#  6. Delete lines in this file, include the changes with your test changes
+#  4. Use a tool like JPRT or something to verify these results
+#  5. Delete lines in this file, include the changes with your test changes
 #
 # You may need to repeat your testing 2 or even 3 times to verify good
 #   results, some of these samevm failures are not very predictable.
@@ -143,6 +142,8 @@
 
 # jdk_io
 
+java/io/pathNames/GeneralWin32.java                             8180264 windows-all
+
 ############################################################################
 
 # jdk_management
@@ -211,6 +212,8 @@
 javax/net/ssl/DTLS/PacketLossRetransmission.java                8169086 macosx-x64
 javax/net/ssl/DTLS/RespondToRetransmit.java                     8169086 macosx-x64
 
+sun/security/krb5/auto/UnboundSSL.java                          8180265 windows-all
+sun/security/provider/KeyStore/DKSTest.sh                       8180266 windows-all
 sun/security/ssl/X509KeyManager/PreferredKey.java               8176354 generic-all
 
 ############################################################################
@@ -306,7 +309,4 @@
 
 org/omg/CORBA/OrbPropertiesTest.java			        8175177 generic-all
 
-sample/mergesort/MergeSortTest.java				8178912 generic-all
-sample/chatserver/ChatTest.java					8178912 generic-all
-
 ############################################################################
--- a/jdk/test/TEST.groups	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/TEST.groups	Wed Jul 05 23:25:53 2017 +0200
@@ -272,8 +272,7 @@
     com/sun/jndi \
     com/sun/corba \
     org/omg/CORBA \
-    lib/testlibrary \
-    sample
+    lib/testlibrary
 
 #
 # SCTP is its own group as it is highly sensitive to kernel/network config
@@ -465,7 +464,6 @@
 needs_jdk = \
   :jdk_jdi \
   com/sun/tools \
-  demo \
   jdk/security/jarsigner \
   sun/security/tools/jarsigner \
   sun/security/tools/policytool \
@@ -775,7 +773,6 @@
   javax \
   jdk \
   lib \
-  sample \
   sun \
   vm \
  -:needs_full_vm_compact1 \
--- a/jdk/test/com/apple/laf/ScreenMenu/ScreenMenuMemoryLeakTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/apple/laf/ScreenMenu/ScreenMenuMemoryLeakTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -102,4 +102,4 @@
         Objects.requireNonNull(menuItem, "The menu item should still be available at this point");
         sMenu.remove(menuItem);
     }
-}
\ No newline at end of file
+}
--- a/jdk/test/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCMAndAAD.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCMAndAAD.java	Wed Jul 05 23:25:53 2017 +0200
@@ -17,7 +17,7 @@
  * 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
+ * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 
--- a/jdk/test/com/sun/jdi/ArrayLengthDumpTest.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/ArrayLengthDumpTest.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -98,7 +98,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/BreakpointWithFullGC.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/BreakpointWithFullGC.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2009, 2013 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 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
--- a/jdk/test/com/sun/jdi/CatchAllTest.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/CatchAllTest.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -76,7 +76,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/CatchCaughtTest.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/CatchCaughtTest.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -67,7 +67,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/CatchPatternTest.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/CatchPatternTest.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -108,7 +108,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/CommandCommentDelimiter.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/CommandCommentDelimiter.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2004, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -70,7 +70,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/DeferredStepTest.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/DeferredStepTest.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,7 @@
   static class  jj1 implements Runnable {
     public void  run() {
         int count = 0;
-        
+
         for ( int ii = 0; ii < 10; ii++) {  // line 6
             int intInPotato04 = 666;        // line 7
             ++count;                        // line 8; @1 breakpoint
@@ -65,7 +65,7 @@
   static class jj2 implements Runnable {
     public void run() {
         int count2 = 0;
-        
+
         for (int ii = 0; ii < 10; ii++) {      // line 18
             String StringInPotato05 = "I am";  // line 19
             ++count2;                          // line 20; @1 breakpoint
@@ -139,7 +139,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
@@ -157,7 +157,7 @@
 If this works right, you should see StepEvents/Breakpoint events for lines
    8, 9, 6, 7, 8, 9, 6, ....   for thread jj11
 and
-  20, 21, 18, 19, 20, 21, 18, ... for thread jj2 
+  20, 21, 18, 19, 20, 21, 18, ... for thread jj2
 
 Since both threads are running at the same time, these
 events can be intermixed.
@@ -179,5 +179,5 @@
 
 EOF
 runit
-#jdbFailIfPresent "Nothing suspended" 
+#jdbFailIfPresent "Nothing suspended"
 #pass
--- a/jdk/test/com/sun/jdi/DeoptimizeWalk.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/DeoptimizeWalk.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -96,7 +96,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/EvalArgs.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/EvalArgs.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 #  @test
 #  @bug 4663146
-#  @summary Arguments match no method error 
+#  @summary Arguments match no method error
 #  @author Jim Holmlund/Suvasis
 #
 #  @run shell/timeout=300 EvalArgs.sh
@@ -72,13 +72,13 @@
         System.out.println( ffjj1(myjj1));
         System.out.println( ffjj1(myjj2));
 
-        System.out.println("$classname.ffoverload($classname.jjboolean) = " + 
+        System.out.println("$classname.ffoverload($classname.jjboolean) = " +
                             $classname.ffoverload($classname.jjboolean));
-        System.out.println("$classname.ffoverload($classname.jjbyte) = " + 
+        System.out.println("$classname.ffoverload($classname.jjbyte) = " +
                             $classname.ffoverload($classname.jjbyte));
-        System.out.println("$classname.ffoverload($classname.jjchar) = " + 
+        System.out.println("$classname.ffoverload($classname.jjchar) = " +
                             $classname.ffoverload($classname.jjchar));
-        System.out.println("$classname.ffoverload($classname.jjdouble) = " + 
+        System.out.println("$classname.ffoverload($classname.jjdouble) = " +
                             $classname.ffoverload($classname.jjdouble));
 
 
@@ -94,11 +94,11 @@
     public static String ffjj1(jj1 arg) {
         return arg.me;
     }
-    
+
     public static String ffjj2(jj2 arg) {
         return arg.me;
     }
-    
+
     static String ffboolean(boolean p1) {
         return "ffbool: p1 = " + p1;
     }
@@ -106,31 +106,31 @@
     static String ffbyte(byte p1) {
         return "ffbyte: p1 = " + p1;
     }
-        
+
     static String ffchar(char p1) {
         return "ffchar: p1 = " + p1;
     }
-        
+
     static String ffdouble(double p1) {
         return "ffdouble: p1 = " + p1;
     }
-        
+
     static String fffloat(float p1) {
         return "fffloat: p1 = " + p1;
     }
-        
+
     static String ffint(int p1) {
         return "ffint: p1 = " + p1;
     }
-        
+
     static String fflong(long p1) {
         return "fflong: p1 = " + p1;
     }
-        
+
     static String ffshort(short p1) {
         return "ffshort: p1 = " + p1;
     }
-        
+
     static String ffintArray(int[] p1) {
         return "ffintArray: p1 = " + p1;
     }
@@ -139,15 +139,15 @@
     public static String ffoverload(jj1 arg) {
         return arg.me;
     }
-    
+
     static String ffoverload(boolean p1) {
         return "ffoverload: boolean p1 = " + p1;
     }
-/***        
+/***
     static String ffoverload(byte p1) {
         return "ffoverload: byte p1 = " + p1;
     }
-***/        
+***/
     static String ffoverload(char p1) {
         return "ffoverload: char p1 = " + p1;
     }
@@ -159,11 +159,11 @@
     static String ffoverload(float p1) {
         return "ffoverload: float p1 = " + p1;
     }
-/***        
+/***
     static String ffoverload(int p1) {
         return "ffoverload: int p1 = " + p1;
     }
-***/        
+***/
     static String ffoverload(long p1) {
         return "ffoverload: long p1 = " + p1;
     }
@@ -171,7 +171,7 @@
     static String ffoverload(short p1) {
         return "ffoverload: short p1 = " + p1;
     }
-      
+
     static String ffoverload(int[] p1) {
         return "ffoverload: int array p1 = " + p1;
     }
@@ -184,7 +184,7 @@
     public String toString() {
         return me;
     }
-    
+
   }
 
   static class jj2 extends jj1 {
@@ -227,7 +227,7 @@
     # Provide a visual break in the output
     cmd print 1
 
-    # Verify mixing primitive types works ok 
+    # Verify mixing primitive types works ok
     # These should work even though the arg types are
     # not the same because there is only one
     # method with each name.
@@ -302,7 +302,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/GetLocalVariables3Test.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/GetLocalVariables3Test.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -67,7 +67,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/GetLocalVariables4Test.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/GetLocalVariables4Test.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -69,7 +69,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/JdbExprTest.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/JdbExprTest.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,7 @@
     public static void bkpt() {
        int i = 0;     //@1 breakpoint
     }
-    
+
     public static void main(String[] args) {
         bkpt();
     }
@@ -73,7 +73,7 @@
 
     cmd print java.lang.Long.MIN_VALUE
     jdbFailIfNotPresent " \= \-9223372036854775808" 3
-    
+
     cmd print 9223372036854775807L
     jdbFailIfNotPresent "9223372036854775807L = 9223372036854775807" 3
     cmd print 9223372036854775807
@@ -83,7 +83,7 @@
     jdbFailIfNotPresent "\-9223372036854775807L = \-9223372036854775807" 3
     cmd print -9223372036854775807
     jdbFailIfNotPresent "\-9223372036854775807 = \-9223372036854775807" 3
-    
+
     cmd print -1
     jdbFailIfNotPresent "\-1 = \-1" 3
     cmd print 1L
@@ -92,7 +92,7 @@
     jdbFailIfNotPresent "\-1L = \-1" 3
     cmd print 0x1
     jdbFailIfNotPresent "0x1 = 1" 3
-    
+
     cmd set $classname.aLong = 9223372036854775807L
     cmd print $classname.aLong
     jdbFailIfNotPresent "$classname.aLong = 9223372036854775807" 3
@@ -142,7 +142,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/JdbLockTest.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/JdbLockTest.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2003, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -94,7 +94,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/MixedSuspendTest.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/MixedSuspendTest.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2005, 2015 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2005, 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
--- a/jdk/test/com/sun/jdi/NullLocalVariable.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/NullLocalVariable.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -40,10 +40,10 @@
     public static final void main(String args[]) {
         try {
             System.out.println("hi!");               // @1 breakpoint
-        } catch (Exception e) {         
+        } catch (Exception e) {
             e.printStackTrace();
         } finally {
-            System.out.println("done"); 
+            System.out.println("done");
         }
     }
 }
@@ -71,7 +71,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/NullThreadGroupNameTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/NullThreadGroupNameTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
--- a/jdk/test/com/sun/jdi/RedefineChangeClassOrder.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/RedefineChangeClassOrder.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2006, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -135,7 +135,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/RedefineException.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/RedefineException.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
 # 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 @@
       }
       System.out.println("a2: done");
     }
-  
+
     public void a3() throws Exception {
       int a3local = 3;
       String a3string = "a3";
@@ -105,7 +105,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/RedefineImplementor.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/RedefineImplementor.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2006, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -81,7 +81,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/jdi/RedefineIntConstantToLong.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/jdi/RedefineIntConstantToLong.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2006, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -50,13 +50,13 @@
     }
 
     public long m2(int j) {
-        System.out.println(System.getProperty("line.separator") + 
+        System.out.println(System.getProperty("line.separator") +
                            "**** public long m2(int j) with value: " + j);
         return j;
     }
 
     public long m2(long j) {
-        System.out.println(System.getProperty("line.separator") + 
+        System.out.println(System.getProperty("line.separator") +
                            "**** public long m2(long j) with value: " + j);
         return j;
     }
@@ -102,7 +102,7 @@
 
     for ii in . $TESTSRC $TESTSRC/.. ; do
         if [ -r "$ii/ShellScaffold.sh" ] ; then
-            . $ii/ShellScaffold.sh 
+            . $ii/ShellScaffold.sh
             break
         fi
     done
--- a/jdk/test/com/sun/management/GarbageCollectorMXBean/LastGCInfo.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/management/GarbageCollectorMXBean/LastGCInfo.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Wed Jul 05 23:25:53 2017 +0200
@@ -66,6 +66,7 @@
                     "-XX:+UseCodeAging",
                     "-XX:+UseCerealGC",         // Should be ignored.
                     "-XX:Flags=" + flagsFile.getAbsolutePath(),
+                    "-Djdk.attach.allowAttachSelf",
                     "-cp", System.getProperty("test.class.path"),
                     "CheckOrigin",
                     "-runtests");
--- a/jdk/test/com/sun/net/httpserver/SimpleHttpServerTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/net/httpserver/SimpleHttpServerTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/com/sun/net/httpserver/StopNoStartTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/net/httpserver/StopNoStartTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/com/sun/net/httpserver/bugs/B6433018.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/net/httpserver/bugs/B6433018.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
@@ -103,4 +103,3 @@
         }
     }
 }
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/tools/attach/AttachSelf.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import com.sun.tools.attach.VirtualMachine;
+
+import java.io.IOException;
+
+/**
+ * @test
+ * @modules jdk.attach
+ * @run main AttachSelf
+ * @run main/othervm -Djdk.attach.allowAttachSelf AttachSelf
+ * @run main/othervm -Djdk.attach.allowAttachSelf=true AttachSelf
+ * @run main/othervm -Djdk.attach.allowAttachSelf=false AttachSelf
+ */
+
+public class AttachSelf {
+
+    public static void main(String[] args) throws Exception {
+
+        String value = System.getProperty("jdk.attach.allowAttachSelf");
+        boolean canAttachSelf = (value != null) && !value.equals("false");
+
+        String vmid = "" + ProcessHandle.current().pid();
+
+        VirtualMachine vm = null;
+        try {
+            vm = VirtualMachine.attach(vmid);
+            if (!canAttachSelf)
+                throw new RuntimeException("Attached to self not expected");
+        } catch (IOException ioe) {
+            if (canAttachSelf)
+                throw ioe;
+        } finally {
+            if (vm != null) vm.detach();
+        }
+
+    }
+
+}
+
--- a/jdk/test/com/sun/tools/attach/PermissionTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/tools/attach/PermissionTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
--- a/jdk/test/com/sun/tools/attach/ProviderTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/tools/attach/ProviderTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
--- a/jdk/test/com/sun/tools/attach/RunnerUtil.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/tools/attach/RunnerUtil.java	Wed Jul 05 23:25:53 2017 +0200
@@ -48,7 +48,10 @@
      */
     public static ProcessThread startApplication(String... additionalOpts) throws Throwable {
         String classpath = System.getProperty("test.class.path", ".");
-        String[] myArgs = concat(additionalOpts, new String [] { "-XX:+UsePerfData", "-Dattach.test=true", "-classpath", classpath, "Application" });
+        String[] myArgs = concat(additionalOpts, new String [] {
+            "-XX:+UsePerfData", "-XX:+EnableDynamicAgentLoading",
+            "-Dattach.test=true", "-classpath", classpath, "Application"
+        });
         String[] args = Utils.addTestJavaOpts(myArgs);
         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
         ProcessThread pt = new ProcessThread("runApplication", (line) -> line.equals(Application.READY_MSG), pb);
--- a/jdk/test/com/sun/tools/attach/StartManagementAgent.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/tools/attach/StartManagementAgent.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
+ * 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
--- a/jdk/test/com/sun/tools/attach/TempDirTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/tools/attach/TempDirTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
+ * 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
--- a/jdk/test/com/sun/tools/attach/java.policy.allow	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/com/sun/tools/attach/java.policy.allow	Wed Jul 05 23:25:53 2017 +0200
@@ -8,7 +8,8 @@
     permission com.sun.tools.attach.AttachPermission "createAttachProvider";
 
     /* implementation specific */
-    permission java.lang.RuntimePermission "accessClassInPackage.sun.misc";
+    permission java.lang.RuntimePermission "manageProcess";
+    permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.misc";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.tools.attach";
     permission java.lang.RuntimePermission "accessClassInPackage.sun.jvmstat.monitor";
     permission java.lang.RuntimePermission "loadLibrary.attach";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/tools/attach/modules/Agent.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.lang.instrument.Instrumentation;
+
+public class Agent {
+
+    public static void agentmain(String agentArgs, Instrumentation inst) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/tools/attach/modules/Driver.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @modules jdk.attach
+ * @build m/* Agent
+ * @run main/othervm -Djdk.attach.allowAttachSelf m/p.Main jmx javaagent
+ * @run main/othervm -Djdk.attach.allowAttachSelf m/p.Main javaagent jmx
+ * @run main/othervm --limit-modules=jdk.attach -Djdk.attach.allowAttachSelf m/p.Main jmx javaagent
+ * @run main/othervm --limit-modules=jdk.attach -Djdk.attach.allowAttachSelf m/p.Main javaagent jmx
+ * @summary Basic test to ensure that a JMX agent or a tool agent can be loaded/started in
+  *         a modular application.
+ */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/tools/attach/modules/m/module-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m {
+    exports p;
+    requires jdk.attach;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/tools/attach/modules/m/p/Main.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+import com.sun.tools.attach.VirtualMachine;
+
+public class Main {
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("#modules loaded: " + moduleInfoCont());
+
+        String vmid = "" + ProcessHandle.current().pid();
+        VirtualMachine vm = VirtualMachine.attach(vmid);
+
+        for (String test : args) {
+            switch (test) {
+                case "jmx" :
+                    startJMXAgent(vm);
+                    break;
+                case "javaagent" :
+                    startJavaAgent(vm, createAgentJar());
+                    break;
+            }
+
+            System.out.println("#modules loaded: " + moduleInfoCont());
+        }
+    }
+
+    /**
+     * Locates module-info.class resources to get a count of the module of system
+     * modules.
+     */
+    static long moduleInfoCont() {
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+        return scl.resources("module-info.class").count();
+    }
+
+    /**
+     * Starts a JMX agent and checks that java.management is loaded.
+     */
+    static void startJMXAgent(VirtualMachine vm) throws Exception {
+        System.out.println("Start JMX agent");
+        vm.startLocalManagementAgent();
+
+        // types in java.management should be visible
+        Class.forName("javax.management.MXBean");
+    }
+
+    /**
+     * Loads a java agent into the VM and checks that java.instrument is loaded.
+     */
+    static void startJavaAgent(VirtualMachine vm, Path agent) throws Exception {
+        System.out.println("Load java agent ...");
+        vm.loadAgent(agent.toString());
+
+        // the Agent class should be visible
+        Class.forName("Agent");
+
+        // types in java.instrument should be visible
+        Class.forName("java.lang.instrument.Instrumentation");
+    }
+
+    /**
+     * Creates a java agent, return the file path to the agent JAR file.
+     */
+    static Path createAgentJar() throws IOException {
+        Manifest man = new Manifest();
+        Attributes attrs = man.getMainAttributes();
+        attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0.0");
+        attrs.put(new Attributes.Name("Agent-Class"), "Agent");
+        Path agent = Paths.get("agent.jar");
+        Path dir = Paths.get(System.getProperty("test.classes"));
+        createJarFile(agent, man, dir, "Agent.class");
+        return agent;
+    }
+
+    /**
+     * Creates a JAR file.
+     *
+     * Equivalent to {@code jar cfm <jarfile> <manifest> -C <dir> file...}
+     *
+     * The input files are resolved against the given directory. Any input
+     * files that are directories are processed recursively.
+     */
+    static void createJarFile(Path jarfile, Manifest man, Path dir, String... files)
+        throws IOException
+    {
+        // create the target directory
+        Path parent = jarfile.getParent();
+        if (parent != null)
+            Files.createDirectories(parent);
+
+        List<Path> entries = new ArrayList<>();
+        for (String file : files) {
+            Files.find(dir.resolve(file), Integer.MAX_VALUE,
+                    (p, attrs) -> attrs.isRegularFile())
+                    .map(e -> dir.relativize(e))
+                    .forEach(entries::add);
+        }
+
+        try (OutputStream out = Files.newOutputStream(jarfile);
+             JarOutputStream jos = new JarOutputStream(out))
+        {
+            if (man != null) {
+                JarEntry je = new JarEntry(JarFile.MANIFEST_NAME);
+                jos.putNextEntry(je);
+                man.write(jos);
+                jos.closeEntry();
+            }
+
+            for (Path entry : entries) {
+                String name = toJarEntryName(entry);
+                jos.putNextEntry(new JarEntry(name));
+                Files.copy(dir.resolve(entry), jos);
+                jos.closeEntry();
+            }
+        }
+    }
+
+    /**
+     * Map a file path to the equivalent name in a JAR file
+     */
+    static String toJarEntryName(Path file) {
+        Path normalized = file.normalize();
+        return normalized.subpath(0, normalized.getNameCount())
+                .toString()
+                .replace(File.separatorChar, '/');
+    }
+}
--- a/jdk/test/java/awt/Choice/UnfocusableToplevel/UnfocusableToplevel.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/Choice/UnfocusableToplevel/UnfocusableToplevel.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
--- a/jdk/test/java/awt/Clipboard/HTMLTransferTest/HTMLTransferTest.html	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/Clipboard/HTMLTransferTest/HTMLTransferTest.html	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/awt/Clipboard/HTMLTransferTest/HTMLTransferTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/Clipboard/HTMLTransferTest/HTMLTransferTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/awt/Dialog/NestedDialogs/Modal/NestedModalDialogTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/Dialog/NestedDialogs/Modal/NestedModalDialogTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/awt/Dialog/NestedDialogs/Modeless/NestedModelessDialogTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/Dialog/NestedDialogs/Modeless/NestedModelessDialogTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/awt/EventQueue/MainAppContext/MainAppContext.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/EventQueue/MainAppContext/MainAppContext.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011,2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 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
--- a/jdk/test/java/awt/FileDialog/RegexpFilterTest/RegexpFilterTest.html	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/FileDialog/RegexpFilterTest/RegexpFilterTest.html	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 <!--
- Copyright (c) 2007 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
 -->
 
 <html>
-<!--  
+<!--
   @test
   @bug 4934185
   @summary JCK1.5-runtime-interactive: XToolkit FileDialog does not work as expected
--- a/jdk/test/java/awt/Focus/WindowIsFocusableAccessByThreadsTest/WindowIsFocusableAccessByThreadsTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/Focus/WindowIsFocusableAccessByThreadsTest/WindowIsFocusableAccessByThreadsTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/awt/Frame/FrameResize/ShowChildWhileResizingTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/Frame/FrameResize/ShowChildWhileResizingTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,6 +1,5 @@
-
 /*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/awt/FullScreen/AltTabCrashTest/AltTabCrashTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/FullScreen/AltTabCrashTest/AltTabCrashTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/awt/JAWT/JAWT.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/JAWT/JAWT.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -85,7 +85,7 @@
     MAKEFILE="Makefile.win"
     CC="cl"
 	MAKE="nmake"
-	${TESTJAVA}${FS}bin${FS}java -d64 -version 2>&1 | grep '64-Bit' > $NULL
+	${TESTJAVA}${FS}bin${FS}java -version 2>&1 | grep '64-Bit' > $NULL
     if [ "$?" -eq '0' ]
     then
         ARCH="amd64"
@@ -100,7 +100,7 @@
     FS="/"
     MAKEFILE="Makefile.cygwin"
     CC="gcc"
-	${TESTJAVA}${FS}bin${FS}java -d64 -version 2>&1 | grep '64-Bit' > $NULL
+	${TESTJAVA}${FS}bin${FS}java -version 2>&1 | grep '64-Bit' > $NULL
     if [ "$?" -eq '0' ]
     then
         ARCH="amd64"
--- a/jdk/test/java/awt/LightweightComponent/LightweightEventTest/LightweightEventTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/LightweightComponent/LightweightEventTest/LightweightEventTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/GlassPaneOverlappingTestBase.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/GlassPaneOverlappingTestBase.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/awt/Mixing/AWT_Mixing/SimpleOverlappingTestBase.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/Mixing/AWT_Mixing/SimpleOverlappingTestBase.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -165,4 +165,3 @@
     }
 
 }
-
--- a/jdk/test/java/awt/Mouse/MaximizedFrameTest/MaximizedFrameTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/Mouse/MaximizedFrameTest/MaximizedFrameTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
--- a/jdk/test/java/awt/MouseInfo/JContainerMousePositionTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/MouseInfo/JContainerMousePositionTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/awt/Toolkit/AutoShutdown/EventQueuePush/EventQueuePushAutoshutdown.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/Toolkit/AutoShutdown/EventQueuePush/EventQueuePushAutoshutdown.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/ksh -p
 
 #
-# Copyright (c) 20015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
 
 #Call this from anywhere to fail the test with an error message
 # usage: fail "reason why the test failed"
-fail() 
+fail()
  { echo "The test failed :-("
    echo "$*" 1>&2
    echo "exit status was $status"
@@ -48,7 +48,7 @@
 
 #Call this from anywhere to pass the test with a message
 # usage: pass "reason why the test passed if applicable"
-pass() 
+pass()
  { echo "The test passed!!!"
    echo "$*" 1>&2
    exit 0
@@ -76,8 +76,8 @@
 esac
 
 
-# Want this test to run standalone as well as in the harness, so do the 
-#  following to copy the test's directory into the harness's scratch directory 
+# Want this test to run standalone as well as in the harness, so do the
+#  following to copy the test's directory into the harness's scratch directory
 #  and set all appropriate variables:
 
 if [ -z "${TESTJAVA}" ] ; then
@@ -100,25 +100,25 @@
 echo "JDK under test is: $TESTJAVA"
 
 #Deal with .class files:
-if [ -n "${STANDALONE}" ] ; 
-   then 
+if [ -n "${STANDALONE}" ] ;
+   then
    #if standalone, remind user to cd to dir. containing test before running it
    echo "Just a reminder: cd to the dir containing this test when running it"
    # then compile all .java files (if there are any) into .class files
-   if [ -a *.java ] ; 
+   if [ -a *.java ] ;
       then echo "Reminder, this test should be in its own directory with all"
       echo "supporting files it needs in the directory with it."
-      ${TESTJAVA}/bin/javac ./*.java ; 
+      ${TESTJAVA}/bin/javac ./*.java ;
    fi
    # else in harness so copy all the class files from where jtreg put them
-   # over to the scratch directory this test is running in. 
+   # over to the scratch directory this test is running in.
    else cp ${TESTCLASSES}/*.class . ;
 fi
 
-#if in test harness, then copy the entire directory that the test is in over 
+#if in test harness, then copy the entire directory that the test is in over
 # to the scratch directory.  This catches any support files needed by the test.
-if [ -z "${STANDALONE}" ] ; 
-   then cp ${TESTSRC}/* . 
+if [ -z "${STANDALONE}" ] ;
+   then cp ${TESTSRC}/* .
 fi
 
 #Just before executing anything, make sure it has executable permission!
@@ -156,4 +156,3 @@
 
 #For additional examples of how to write platform independent KSH scripts,
 # see the jtreg file itself.  It is a KSH script for both Solaris and Win32
-
--- a/jdk/test/java/awt/Toolkit/ToolkitPropertyTest/bug7129133.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/Toolkit/ToolkitPropertyTest/bug7129133.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/awt/Window/FindOwner/FindOwnerTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/Window/FindOwner/FindOwnerTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -107,4 +107,4 @@
             stop();
         }
     }
-}
\ No newline at end of file
+}
--- a/jdk/test/java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/dnd/DisposeFrameOnDragCrash/DisposeFrameOnDragTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/awt/dnd/MissingEventsOnModalDialog/MissingEventsOnModalDialogTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/dnd/MissingEventsOnModalDialog/MissingEventsOnModalDialogTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -76,7 +76,7 @@
 
         mouseDragAndDrop(robot, point, getCenterPoint(targetFrame));
 
-        long time = System.currentTimeMillis() + 200;
+        long time = System.currentTimeMillis() + 1000;
 
         while (!passed) {
             if (time < System.currentTimeMillis()) {
@@ -222,10 +222,12 @@
                 }
                 Thread.sleep(10);
             }
+            Robot robot = new Robot();
+            robot.setAutoDelay(50);
+            robot.waitForIdle();
+            robot.delay(200);
 
             Point point = getCenterPoint(dialog);
-            Robot robot = new Robot();
-            robot.setAutoDelay(50);
 
             robot.mouseMove(point.x, point.y);
             robot.mousePress(InputEvent.BUTTON1_MASK);
--- a/jdk/test/java/awt/event/MouseEvent/DisabledComponents/DisabledComponentsTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/event/MouseEvent/DisabledComponents/DisabledComponentsTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
+ * 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
--- a/jdk/test/java/awt/font/TextLayout/ArabicDiacriticTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/font/TextLayout/ArabicDiacriticTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -18,6 +18,7 @@
  *
  * 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
--- a/jdk/test/java/awt/font/TextLayout/MissingCodePointLayoutTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/awt/font/TextLayout/MissingCodePointLayoutTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -18,6 +18,7 @@
  *
  * 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
--- a/jdk/test/java/io/RandomAccessFile/FileLengthTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/io/RandomAccessFile/FileLengthTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -9,7 +9,7 @@
  * 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 randomAccessFile that
+ * 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ClassLoader/CustomSystemLoader/CustomLoader.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.PrintStream;
+
+/*
+ * Custom system class loader.
+ */
+public class CustomLoader extends ClassLoader {
+    private static PrintStream out = System.out;
+    public  static ClassLoader INSTANCE;
+
+    public CustomLoader(ClassLoader classLoader) {
+        super("CustomSystemLoader", classLoader);
+        assert INSTANCE == null;
+        INSTANCE = this;
+
+        // test cases to validate that ClassLoader::getSystemClassLoader
+        // is not triggered during custom system class loader initialization
+        testEnumValueOf();
+    }
+
+    static void testEnumValueOf() {
+        TestEnum e = java.lang.Enum.valueOf(TestEnum.class, "C1");
+        if (e != TestEnum.C1) {
+            throw new RuntimeException("Expected: " + TestEnum.C1 + " got: " + e);
+        }
+    }
+
+    @Override
+    public Class<?> loadClass(String name) throws ClassNotFoundException {
+        out.println("CustomLoader: loading class: " + name);
+        return super.loadClass(name);
+    }
+
+    static enum TestEnum {
+        C1, C2, C3
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ClassLoader/CustomSystemLoader/InitSystemLoaderTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8179950
+ * @build CustomLoader InitSystemLoaderTest
+ * @run main/othervm -Djava.system.class.loader=CustomLoader InitSystemLoaderTest
+ * @summary Test custom system loader initialization and verify their ancestors
+ */
+
+public class InitSystemLoaderTest {
+    public static void main(String... args) {
+        // check that system class loader is the custom loader
+        ClassLoader loader = ClassLoader.getSystemClassLoader();
+        if (loader != CustomLoader.INSTANCE) {
+            throw new RuntimeException("Expected custom loader: "
+                + CustomLoader.INSTANCE + " got: " + loader);
+        }
+
+        // parent of the custom loader should be builtin system class loader
+        ClassLoader builtinSystemLoader = loader.getParent();
+        ClassLoader grandparent = builtinSystemLoader.getParent();
+        if (grandparent != ClassLoader.getPlatformClassLoader()) {
+            throw new RuntimeException("Expected class loader ancestor: "
+                + ClassLoader.getPlatformClassLoader() + " got: " + grandparent);
+        }
+    }
+}
--- a/jdk/test/java/lang/instrument/RedefineBigClass.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/lang/instrument/RedefineBigClass.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2015 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
@@ -73,7 +73,7 @@
     -Xlog:redefine+class+load=debug,redefine+class+load+exceptions=info ${NMT} \
     -javaagent:RedefineBigClassAgent.jar=BigClass.class \
     -classpath "${TESTCLASSES}" RedefineBigClassApp \
-    > output.log 2>&1 
+    > output.log 2>&1
 result=$?
 
 cat output.log
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/executableJAR/Agent.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.instrument.Instrumentation;
+
+public class Agent {
+
+    public static Instrumentation inst;
+
+    public static void agentmain(String agentArgs, Instrumentation inst) {
+        Agent.inst = inst;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/executableJAR/AgentHelper.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+public class AgentHelper {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/executableJAR/ExecJarWithAgent.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @library /lib/testlibrary
+ * @build ExecJarWithAgent Main Agent AgentHelper JarUtils jdk.testlibrary.*
+ * @run testng ExecJarWithAgent
+ * @summary Test starting agents in executable JAR files
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+import java.util.stream.Stream;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+import jdk.testlibrary.ProcessTools;
+import jdk.testlibrary.OutputAnalyzer;
+
+@Test
+public class ExecJarWithAgent {
+
+    /**
+     * Basic test of java -jar with agent in the executable JAR
+     */
+    public void testBasic() throws Exception {
+        Manifest man = new Manifest();
+        Attributes attrs = man.getMainAttributes();
+        attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0.0");
+        attrs.put(Attributes.Name.MAIN_CLASS, "Main");
+        attrs.put(new Attributes.Name("Launcher-Agent-Class"), "Agent");
+
+        // require all capabilities
+        attrs.put(new Attributes.Name("Can-Redefine-Classes"), "true");
+        attrs.put(new Attributes.Name("Can-Retransform-Classes"), "true");
+        attrs.put(new Attributes.Name("Can-Set-Native-Method-Prefix"), "true");
+        attrs.put(new Attributes.Name("Boot-Class-Path"), "helper.jar");
+
+        Path app = Paths.get("app.jar");
+        Path dir = Paths.get(System.getProperty("test.classes"));
+
+        Path[] paths = Stream.of("Main.class", "Agent.class")
+                .map(Paths::get)
+                .toArray(Path[]::new);
+
+        JarUtils.createJarFile(app, man, dir, paths);
+
+        // helper API to test that the BCP has been extended
+        Path helper = Paths.get("helper.jar");
+        JarUtils.createJarFile(helper, dir, "AgentHelper.class");
+
+        // java -jar app.jar
+        assertEquals(exec(app).getExitValue(), 0);
+    }
+
+    /**
+     * Test that java -jar fails when the executable JAR has the
+     * Launcher-Agent-Class attribute but the class cannot be loaded.
+     */
+    public void testBadAgentClass() throws Exception {
+        Manifest man = new Manifest();
+        Attributes attrs = man.getMainAttributes();
+        attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0.0");
+        attrs.put(Attributes.Name.MAIN_CLASS, "Main");
+
+        // agent class does not exist
+        attrs.put(new Attributes.Name("Launcher-Agent-Class"), "BadAgent");
+
+        Path app = Paths.get("app.jar");
+        Path dir = Paths.get(System.getProperty("test.classes"));
+
+        JarUtils.createJarFile(app, man, dir, Paths.get("Main.class"));
+
+        // java -jar app.jar
+        int exitCode = exec(app).shouldContain("ClassNotFoundException").getExitValue();
+        assertNotEquals(exitCode, 0);
+    }
+
+    /**
+     * Test that java -jar fails when the executable JAR has the
+     * Launcher-Agent-Class attribute and the class does not define an
+     * agentmain method.
+     */
+    public void testNoAgentMain() throws Exception {
+        // manifest for the executable JAR
+        Manifest man = new Manifest();
+        Attributes attrs = man.getMainAttributes();
+        attrs.put(Attributes.Name.MANIFEST_VERSION, "1.0.0");
+        attrs.put(Attributes.Name.MAIN_CLASS, "Main");
+
+        // the main class does not define the agentmain method
+        attrs.put(new Attributes.Name("Launcher-Agent-Class"), "Main");
+
+        Path app = Paths.get("app.jar");
+        Path dir = Paths.get(System.getProperty("test.classes"));
+
+        JarUtils.createJarFile(app, man, dir, Paths.get("Main.class"));
+
+        // java -jar app.jar
+        int exitCode = exec(app).shouldContain("NoSuchMethodException").getExitValue();
+        assertNotEquals(exitCode, 0);
+    }
+
+    /**
+     * java -jar app.jar, returning the OutputAnalyzer to analyze the output
+     */
+    private OutputAnalyzer exec(Path appJar) throws Exception {
+        return ProcessTools.executeTestJava("-jar", appJar.toString())
+                .outputTo(System.out)
+                .errorTo(System.out);
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/instrument/executableJAR/Main.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.lang.instrument.Instrumentation;
+
+public class Main {
+    public static void main(String[] args) throws Exception {
+        Instrumentation inst = Agent.inst;
+        if (inst == null)
+            throw new RuntimeException("Agent not loaded");
+
+        // check boot class path has been extended
+        Class<?> helper = Class.forName("AgentHelper");
+        if (helper.getClassLoader() != null)
+            throw new RuntimeException("AgentHelper not loaded by boot loader");
+
+        // check Instrumentation object can be used
+        Class<?>[] classes = inst.getAllLoadedClasses();
+        System.out.println(classes.length + " classes loaded");
+    }
+}
--- a/jdk/test/java/lang/invoke/DefineClassTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/lang/invoke/DefineClassTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -75,7 +75,7 @@
     @Test
     public void testDefineClass() throws Exception {
         final String CLASS_NAME = THIS_PACKAGE + ".Foo";
-        Lookup lookup = lookup().dropLookupMode(PRIVATE);
+        Lookup lookup = lookup();
         Class<?> clazz = lookup.defineClass(generateClass(CLASS_NAME));
 
         // test name
@@ -101,7 +101,7 @@
     public void testAccess() throws Exception {
         final String THIS_CLASS = this.getClass().getName();
         final String CLASS_NAME = THIS_PACKAGE + ".Runner";
-        Lookup lookup = lookup().dropLookupMode(PRIVATE);
+        Lookup lookup = lookup();
 
         // public
         byte[] classBytes = generateRunner(CLASS_NAME + nextNumber(), THIS_CLASS, "method1");
@@ -144,9 +144,8 @@
         final String CLASS_NAME = THIS_PACKAGE + ".ClassWithClinit";
 
         byte[] classBytes = generateClassWithInitializer(CLASS_NAME, THIS_CLASS, "fail");
-        Lookup lookup = lookup().dropLookupMode(PRIVATE);
+        Class<?> clazz = lookup().defineClass(classBytes);
 
-        Class<?> clazz = lookup.defineClass(classBytes);
         // trigger initializer to run
         try {
             clazz.newInstance();
@@ -186,14 +185,14 @@
         assertNotEquals(target1.getProtectionDomain(), target2.getProtectionDomain());
 
         // protection domain 1
-        Lookup lookup1 = privateLookupIn(target1, lookup()).dropLookupMode(PRIVATE);
+        Lookup lookup1 = privateLookupIn(target1, lookup());
 
         Class<?> clazz = lookup1.defineClass(generateClass("p.Foo"));
         testSameAbode(clazz, lookup1.lookupClass());
         testDiscoverable(clazz, lookup1);
 
         // protection domain 2
-        Lookup lookup2 = privateLookupIn(target2, lookup()).dropLookupMode(PRIVATE);
+        Lookup lookup2 = privateLookupIn(target2, lookup());
 
         clazz = lookup2.defineClass(generateClass("p.Bar"));
         testSameAbode(clazz, lookup2.lookupClass());
@@ -205,7 +204,7 @@
      */
     @Test
     public void testBootLoader() throws Exception {
-        Lookup lookup = privateLookupIn(Thread.class, lookup()).dropLookupMode(PRIVATE);
+        Lookup lookup = privateLookupIn(Thread.class, lookup());
         assertTrue(lookup.getClass().getClassLoader() == null);
 
         Class<?> clazz = lookup.defineClass(generateClass("java.lang.Foo"));
@@ -216,8 +215,7 @@
 
     @Test(expectedExceptions = { IllegalArgumentException.class })
     public void testWrongPackage() throws Exception {
-        Lookup lookup = lookup().dropLookupMode(PRIVATE);
-        lookup.defineClass(generateClass("other.C"));
+        lookup().defineClass(generateClass("other.C"));
     }
 
     @Test(expectedExceptions = { IllegalAccessException.class })
@@ -226,23 +224,14 @@
         lookup.defineClass(generateClass(THIS_PACKAGE + ".C"));
     }
 
-    @Test(expectedExceptions = { UnsupportedOperationException.class })
-    public void testHasPrivateAccess() throws Exception {
-        Lookup lookup = lookup();
-        assertTrue(lookup.hasPrivateAccess());
-        lookup.defineClass(generateClass(THIS_PACKAGE + ".C"));
-    }
-
     @Test(expectedExceptions = { ClassFormatError.class })
     public void testTruncatedClassFile() throws Exception {
-        Lookup lookup = lookup().dropLookupMode(PRIVATE);
-        lookup.defineClass(new byte[0]);
+        lookup().defineClass(new byte[0]);
     }
 
     @Test(expectedExceptions = { NullPointerException.class })
     public void testNull() throws Exception {
-        Lookup lookup = lookup().dropLookupMode(PRIVATE);
-        lookup.defineClass(null);
+        lookup().defineClass(null);
     }
 
     /**
--- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3288,4 +3288,3 @@
 #end[Bitwise]
     }
 }
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/lookup/ReflectiveLookupTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  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.
+ */
+
+/*
+ * @test
+ * @bug 8020801
+ * @summary Restriction on reflective call to MethodHandles.lookup method
+ * @run main java.base/java.lang.LookupTest
+ * @run main ReflectiveLookupTest
+ * @run main/othervm -Dsun.reflect.noInflation=true ReflectiveLookupTest
+ */
+
+import java.lang.invoke.*;
+import java.lang.invoke.MethodHandles.Lookup;
+import java.lang.reflect.Method;
+
+import static java.lang.invoke.MethodType.*;
+
+/*
+ * Lookup object can be obtained statically or reflectively.
+ */
+public class ReflectiveLookupTest {
+    public static void main(String... args) throws Throwable {
+        // Get a full power lookup
+        Lookup lookup1 =  MethodHandles.lookup();
+        MethodHandle mh1 = lookup1.findStatic(lookup1.lookupClass(),
+                                              "foo",
+                                              methodType(String.class));
+        assertEquals((String) mh1.invokeExact(), foo());
+
+        Method lookupMethod =  MethodHandles.class.getMethod("lookup");
+        System.out.println("reflection method: " + lookupMethod);
+        if (!lookupMethod.getName().equals("lookup")) {
+            throw new RuntimeException("Unexpected name: " + lookupMethod.getName());
+        }
+
+        // Get a full power Lookup reflectively.
+        Lookup lookup2 = (Lookup) lookupMethod.invoke(null);
+        assertEquals(lookup1.lookupClass(), lookup2.lookupClass());
+        assertEquals(lookup1.lookupModes(), lookup2.lookupModes());
+        MethodHandle mh2 = lookup2.findStatic(lookup2.lookupClass(),
+                                             "foo",
+                                              methodType(String.class));
+        assertEquals((String) mh2.invokeExact(), foo());
+    }
+
+    static String foo() {
+        return "foo!";
+    }
+
+    static void assertEquals(Object o1, Object o2) {
+        if (!o1.equals(o2)) {
+            throw new RuntimeException(o1 + " != " + o2);
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/lookup/java.base/java/lang/LookupTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.lang;
+
+import java.lang.invoke.*;
+import java.lang.invoke.MethodHandles.Lookup;
+import java.lang.reflect.InvocationTargetException;
+
+import static java.lang.invoke.MethodType.*;
+
+/*
+ * Verify that a Lookup object can be obtained statically from java.base
+ * but fails when it's obtained via reflection from java.base.
+ */
+public class LookupTest {
+    public static void main(String... args) throws Throwable {
+        // Get a full power lookup
+        Lookup lookup1 =  MethodHandles.lookup();
+        MethodHandle mh1 = lookup1.findStatic(lookup1.lookupClass(),
+                                              "foo",
+                                              methodType(String.class));
+        assertEquals((String) mh1.invokeExact(), foo());
+
+        // access protected member
+        MethodHandle mh2 = lookup1.findVirtual(java.lang.ClassLoader.class,
+                                               "getPackage",
+                                               methodType(Package.class, String.class));
+        ClassLoader loader = ClassLoader.getPlatformClassLoader();
+        Package pkg = (Package)mh2.invokeExact(loader, "java.lang");
+        assertEquals(pkg.getName(), "java.lang");
+
+        // MethodHandles.lookup will fail if it's called reflectively
+        try {
+            MethodHandles.class.getMethod("lookup").invoke(null);
+        } catch (InvocationTargetException e) {
+            if (!(e.getCause() instanceof IllegalArgumentException)) {
+                throw e.getCause();
+            }
+        }
+    }
+
+    static String foo() { return "foo!"; }
+
+    static void assertEquals(Object o1, Object o2) {
+        if (!o1.equals(o2)) {
+            throw new RuntimeException(o1 + " != " + o2);
+        }
+    }
+}
--- a/jdk/test/java/lang/module/AutomaticModulesTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/lang/module/AutomaticModulesTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -402,9 +402,7 @@
     // Main-Class files that do not map to a legal qualified type name
     @DataProvider(name = "badmainclass")
     public Object[][] createBadMainClass() {
-        return new Object[][]{
-
-            { "Main",        null },
+        return new Object[][] {
             { "p..Main",     null },
             { "p-.Main",     null },
 
@@ -415,7 +413,7 @@
      * Test that a JAR file with a Main-Class attribute that is not a qualified
      * type name.
      */
-    @Test(dataProvider = "badmainclass", expectedExceptions = FindException.class)
+    @Test(dataProvider = "badmainclass")
     public void testBadMainClass(String mainClass, String ignore) throws IOException {
         Manifest man = new Manifest();
         Attributes attrs = man.getMainAttributes();
@@ -426,14 +424,16 @@
         String entry = mainClass.replace('.', '/') + ".class";
         createDummyJarFile(dir.resolve("m.jar"), man, entry);
 
-        // should throw FindException
-        ModuleFinder.of(dir).findAll();
+        // bad Main-Class value should be ignored
+        Optional<ModuleReference> omref = ModuleFinder.of(dir).find("m");
+        assertTrue(omref.isPresent());
+        ModuleDescriptor descriptor = omref.get().descriptor();
+        assertFalse(descriptor.mainClass().isPresent());
     }
 
     /**
      * Test that a JAR file with a Main-Class attribute that is not in the module
      */
-    @Test(expectedExceptions = FindException.class)
     public void testMissingMainClassPackage() throws IOException {
         Manifest man = new Manifest();
         Attributes attrs = man.getMainAttributes();
@@ -443,8 +443,11 @@
         Path dir = Files.createTempDirectory(USER_DIR, "mods");
         createDummyJarFile(dir.resolve("m.jar"), man);
 
-        // should throw FindException
-        ModuleFinder.of(dir).findAll();
+        // Main-Class should be ignored because package p is not in module
+        Optional<ModuleReference> omref = ModuleFinder.of(dir).find("m");
+        assertTrue(omref.isPresent());
+        ModuleDescriptor descriptor = omref.get().descriptor();
+        assertFalse(descriptor.mainClass().isPresent());
     }
 
 
--- a/jdk/test/java/lang/module/ConfigurationTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/lang/module/ConfigurationTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1843,17 +1843,9 @@
     public Object[][] createPlatformMatches() {
         return new Object[][]{
 
-            { "linux-arm",     "*-*" },
-            { "linux-*",       "*-*" },
-            { "*-arm",         "*-*" },
-
-            { "linux-*",       "linux-*" },
-            { "linux-arm",     "linux-*" },
-
-            { "*-arm",         "*-arm" },
-            { "linux-arm",     "*-arm" },
-
-            { "linux-arm",   "linux-arm" },
+            { "",              "" },
+            { "linux-arm",     "" },
+            { "linux-arm",     "linux-arm" },
 
         };
 
@@ -1863,9 +1855,8 @@
     public Object[][] createBad() {
         return new Object[][] {
 
-            { "linux-*",        "solaris-*"     },
-            { "*-arm",          "*-sparc"       },
-            { "linux-x86",      "solaris-sparc" },
+            { "linux-x64",        "linux-arm" },
+            { "linux-x64",        "windows-x64" },
 
         };
     }
@@ -1877,7 +1868,7 @@
     public void testPlatformMatch(String s1, String s2) throws IOException {
 
         ModuleDescriptor base =  ModuleDescriptor.newModule("java.base").build();
-        Path system = writeModule(base, "*-*");
+        Path system = writeModule(base, null);
 
         ModuleDescriptor descriptor1 = ModuleDescriptor.newModule("m1")
                 .requires("m2")
@@ -1928,7 +1919,7 @@
         throws IOException
     {
         ModuleDescriptor base =  ModuleDescriptor.newModule("java.base").build();
-        Path system = writeModule(base, "*-*");
+        Path system = writeModule(base, null);
 
         ModuleDescriptor descriptor1 = ModuleDescriptor.newModule("m1").build();
         Path dir1 = writeModule(descriptor1, s1);
@@ -2113,17 +2104,18 @@
 
 
     /**
-     * Decodes the platform string and calls the builder osName/osArch/osVersion
-     * methods to set the platform constraints.
+     * Writes a module-info.class. If {@code targetPlatform} is not null then
+     * it includes the ModuleTarget class file attribute with the target platform.
      */
-    static Path writeModule(ModuleDescriptor descriptor, String platformString)
+    static Path writeModule(ModuleDescriptor descriptor, String targetPlatform)
         throws IOException
     {
-        String[] s = platformString.split("-");
-        String osName = !s[0].equals("*") ? s[0] : null;
-        String osArch = !s[1].equals("*") ? s[1] : null;
-        ModuleTarget target = new ModuleTarget(osName, osArch);
-
+        ModuleTarget target;
+        if (targetPlatform != null) {
+            target = new ModuleTarget(targetPlatform);
+        } else {
+            target = null;
+        }
         String name = descriptor.name();
         Path dir = Files.createTempDirectory(name);
         Path mi = dir.resolve("module-info.class");
--- a/jdk/test/java/lang/module/ModuleDescriptorTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/lang/module/ModuleDescriptorTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -65,8 +65,8 @@
 @Test
 public class ModuleDescriptorTest {
 
-    @DataProvider(name = "invalidjavaidentifiers")
-    public Object[][] invalidJavaIdentifiers() {
+    @DataProvider(name = "invalidNames")
+    public Object[][] invalidNames() {
         return new Object[][]{
 
             { null,             null },
@@ -84,6 +84,32 @@
             { "foo.bar.1gus",   null },
             { "foo.bar.[gus]",  null },
 
+            { "class",          null },
+            { "interface",      null },
+            { "true",           null },
+            { "false",          null },
+            { "null",           null },
+
+            { "x.class",        null },
+            { "x.interface",    null },
+            { "x.true",         null },
+            { "x.false",        null },
+            { "x.null",         null },
+
+            { "class.x",        null },
+            { "interface.x",    null },
+            { "true.x",         null },
+            { "false.x",        null },
+            { "null.x",         null },
+
+            { "x.class.x",      null },
+            { "x.interface.x",  null },
+            { "x.true.x",       null },
+            { "x.false.x",      null },
+            { "x.null.x",       null },
+
+            { "_",              null },
+
         };
     }
 
@@ -199,7 +225,7 @@
         ModuleDescriptor.newModule("m").requires(EnumSet.allOf(Modifier.class), "m");
     }
 
-    @Test(dataProvider = "invalidjavaidentifiers",
+    @Test(dataProvider = "invalidNames",
           expectedExceptions = IllegalArgumentException.class )
     public void testRequiresWithBadModuleName(String mn, String ignore) {
         requires(EnumSet.noneOf(Modifier.class), mn);
@@ -406,7 +432,7 @@
         ModuleDescriptor.newModule("foo").exports("p", Collections.emptySet());
     }
 
-    @Test(dataProvider = "invalidjavaidentifiers",
+    @Test(dataProvider = "invalidNames",
           expectedExceptions = IllegalArgumentException.class )
     public void testExportsWithBadName(String pn, String ignore) {
         ModuleDescriptor.newModule("foo").exports(pn);
@@ -568,7 +594,7 @@
         ModuleDescriptor.newModule("foo").opens("p", Collections.emptySet());
     }
 
-    @Test(dataProvider = "invalidjavaidentifiers",
+    @Test(dataProvider = "invalidNames",
             expectedExceptions = IllegalArgumentException.class )
     public void testOpensWithBadName(String pn, String ignore) {
         ModuleDescriptor.newModule("foo").opens(pn);
@@ -664,7 +690,7 @@
         ModuleDescriptor.newModule("foo").uses("S");
     }
 
-    @Test(dataProvider = "invalidjavaidentifiers",
+    @Test(dataProvider = "invalidNames",
           expectedExceptions = IllegalArgumentException.class )
     public void testUsesWithBadName(String service, String ignore) {
         ModuleDescriptor.newModule("foo").uses(service);
@@ -737,13 +763,13 @@
         ModuleDescriptor.newModule("foo").provides("p.S", List.of("P"));
     }
 
-    @Test(dataProvider = "invalidjavaidentifiers",
+    @Test(dataProvider = "invalidNames",
           expectedExceptions = IllegalArgumentException.class )
     public void testProvidesWithBadService(String service, String ignore) {
         ModuleDescriptor.newModule("foo").provides(service, List.of("p.Provider"));
     }
 
-    @Test(dataProvider = "invalidjavaidentifiers",
+    @Test(dataProvider = "invalidNames",
           expectedExceptions = IllegalArgumentException.class )
     public void testProvidesWithBadProvider(String provider, String ignore) {
         List<String> names = new ArrayList<>(); // allows nulls
@@ -928,7 +954,7 @@
         assertTrue(Objects.equals(packages, Set.of("p1", "p2", "p3", "p4", "p5")));
     }
 
-    @Test(dataProvider = "invalidjavaidentifiers",
+    @Test(dataProvider = "invalidNames",
           expectedExceptions = IllegalArgumentException.class )
     public void testPackagesWithBadName(String pn, String ignore) {
         Set<String> pkgs = new HashSet<>();  // allows nulls
@@ -943,7 +969,7 @@
         assertEquals(mn, "foo");
     }
 
-    @Test(dataProvider = "invalidjavaidentifiers",
+    @Test(dataProvider = "invalidNames",
           expectedExceptions = IllegalArgumentException.class )
     public void testBadModuleName(String mn, String ignore) {
         ModuleDescriptor.newModule(mn);
@@ -1264,7 +1290,7 @@
         ModuleDescriptor.newModule("foo").mainClass("Main");
     }
 
-    @Test(dataProvider = "invalidjavaidentifiers",
+    @Test(dataProvider = "invalidNames",
           expectedExceptions = IllegalArgumentException.class )
     public void testMainClassWithBadName(String mainClass, String ignore) {
         Builder builder = ModuleDescriptor.newModule("foo");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/module/customfs/ModulesInCustomFileSystem.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @modules jdk.zipfs
+ * @library /lib/testlibrary
+ * @build ModulesInCustomFileSystem JarUtils m1/* m2/*
+ * @run testng/othervm ModulesInCustomFileSystem
+ * @summary Test ModuleFinder to find modules in a custom file system
+ */
+
+import java.io.File;
+import java.lang.module.Configuration;
+import java.lang.module.ModuleFinder;
+import java.lang.module.ModuleReader;
+import java.lang.module.ModuleReference;
+import java.lang.reflect.Method;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Set;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+@Test
+public class ModulesInCustomFileSystem {
+
+    /**
+     * Test exploded modules in a JAR file system.
+     */
+    public void testExplodedModulesInJarFileSystem() throws Exception {
+        Path m1 = findModuleDirectory("m1");
+        Path m2 = findModuleDirectory("m2");
+        Path mlib = m1.getParent();
+        assertEquals(mlib, m2.getParent());
+
+        // create JAR file containing m1/** and m2/**
+        Path jar = Files.createTempDirectory("mlib").resolve("modules.jar");
+        JarUtils.createJarFile(jar, mlib);
+        testJarFileSystem(jar);
+    }
+
+    /**
+     * Test modular JARs in a JAR file system
+     */
+    public void testModularJARsInJarFileSystem() throws Exception {
+        Path m1 = findModuleDirectory("m1");
+        Path m2 = findModuleDirectory("m2");
+        Path contents = Files.createTempDirectory("contents");
+        JarUtils.createJarFile(contents.resolve("m1.jar"), m1);
+        JarUtils.createJarFile(contents.resolve("m2.jar"), m2);
+
+        // create JAR file containing m1.jar and m2.jar
+        Path jar = Files.createTempDirectory("mlib").resolve("modules.jar");
+        JarUtils.createJarFile(jar, contents);
+        testJarFileSystem(jar);
+    }
+
+    /**
+     * Opens a JAR file as a file system
+     */
+    private void testJarFileSystem(Path jar) throws Exception {
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+        try (FileSystem fs = FileSystems.newFileSystem(jar, scl)) {
+            // ModuleFinder to find modules in top-level directory
+            Path top = fs.getPath("/");
+            ModuleFinder finder = ModuleFinder.of(top);
+
+            // list the modules
+            listAllModules(finder);
+
+            // load modules into child layer, invoking m1/p.Main
+            loadAndRunModule(finder);
+        }
+    }
+
+    /**
+     * List all modules that the finder finds and the resources in the module.
+     */
+    private void listAllModules(ModuleFinder finder) throws Exception {
+        for (ModuleReference mref : finder.findAll()) {
+            System.out.println(mref.descriptor());
+            try (ModuleReader reader = mref.open()) {
+                reader.list().forEach(name -> System.out.format("  %s%n", name));
+            }
+        }
+    }
+
+    /**
+     * Creates a child layer with m1 and m2, invokes m1/p.Main to ensure that
+     * classes can be loaded.
+     */
+    private void loadAndRunModule(ModuleFinder finder) throws Exception {
+        ModuleLayer bootLayer = ModuleLayer.boot();
+        Configuration cf = bootLayer.configuration()
+                .resolve(finder, ModuleFinder.of(), Set.of("m1"));
+        ClassLoader scl = ClassLoader.getSystemClassLoader();
+        ModuleLayer layer = bootLayer.defineModulesWithOneLoader(cf, scl);
+        Class<?> c = layer.findLoader("m1").loadClass("p.Main");
+        Method m = c.getMethod("main", String[].class);
+        m.invoke(null, (Object)new String[0]);
+    }
+
+    /**
+     * Find the directory for a module on the module path
+     */
+    private Path findModuleDirectory(String name) {
+        String mp = System.getProperty("jdk.module.path");
+        for (String element : mp.split(File.pathSeparator)) {
+            Path dir = Paths.get(element).resolve(name);
+            if (Files.exists(dir)) {
+                return dir;
+            }
+        }
+        assertFalse(true);
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/module/customfs/m1/module-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m1 {
+    exports p;
+    requires m2;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/module/customfs/m1/p/Main.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 p;
+
+public class Main {
+    public static void main(String[] args) {
+        q.Hello.hello();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/module/customfs/m2/module-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+module m2 {
+    exports q;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/module/customfs/m2/q/Hello.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 q;
+
+public class Hello {
+    public static void hello() {
+        System.out.println("hello");
+    }
+}
--- a/jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 /* @test
  * @bug 8081678 8131155
  * @summary Tests for stream returning methods
- * @library ../../util/stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.stream.OpTestCase
  * @run testng/othervm NetworkInterfaceStreamTest
  * @run testng/othervm -Djava.net.preferIPv4Stack=true NetworkInterfaceStreamTest
--- a/jdk/test/java/net/httpclient/ProxyAuthTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/net/httpclient/ProxyAuthTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -20,6 +20,7 @@
  *
  * 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.
  */
 
 /*
--- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -47,12 +47,7 @@
     TESTCLASSES=`pwd`
     JAVA=java
     which $JAVA
-    ${JAVA} -d64 -version > /dev/null 2<&1
-    if [ $? = 1 ]; then
 	${JAVA} -version
-    else
-	${JAVA} -d64 -version
-    fi
 else
     JAVA="${TESTJAVA}/bin/java"
 fi
--- a/jdk/test/java/nio/file/Files/StreamLinesTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/nio/file/Files/StreamLinesTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /* @test
  * @bug 8072773
- * @library /lib/testlibrary/ ../../../util/stream/bootlib
+ * @library /lib/testlibrary/ /lib/testlibrary/bootlib
  * @build java.base/java.util.stream.OpTestCase
  * @build jdk.testlibrary.RandomFactory
  * @run testng/othervm StreamLinesTest
--- a/jdk/test/java/nio/file/WatchService/DeleteInterference.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/nio/file/WatchService/DeleteInterference.java	Wed Jul 05 23:25:53 2017 +0200
@@ -15,6 +15,10 @@
  * 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.
  */
 
 /**
--- a/jdk/test/java/nio/file/attribute/BasicFileAttributeView/UnixSocketFile.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/nio/file/attribute/BasicFileAttributeView/UnixSocketFile.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/nio/file/spi/SetDefaultProvider.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/nio/file/spi/SetDefaultProvider.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,23 +21,141 @@
  * questions.
  */
 
-/* @test
- * @bug 4313887 7006126
- * @summary Unit test for java.nio.file.spi.FileSystemProvider
- * @build TestProvider SetDefaultProvider
- * @run main/othervm -Djava.nio.file.spi.DefaultFileSystemProvider=TestProvider SetDefaultProvider
+/**
+ * @test
+ * @modules jdk.jartool
+ * @library /lib/testlibrary
+ * @build SetDefaultProvider TestProvider m/* jdk.testlibrary.ProcessTools
+ * @run testng/othervm SetDefaultProvider
+ * @summary Runs tests with -Djava.nio.file.spi.DefaultFileSystemProvider set on
+ *          the command line to override the default file system provider
  */
 
-import java.nio.file.*;
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.spi.ToolProvider;
 
+import jdk.testlibrary.ProcessTools;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+@Test
 public class SetDefaultProvider {
-    public static void main(String[] args) throws Exception {
-        Class<?> c = FileSystems.getDefault().provider().getClass();
+
+    private static String SET_DEFAULT_FSP =
+        "-Djava.nio.file.spi.DefaultFileSystemProvider=TestProvider";
+
+    private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
+        .orElseThrow(() ->
+            new RuntimeException("jar tool not found")
+        );
+
+    /**
+     * Test override of default FileSystemProvider with the main application
+     * on the class path.
+     */
+    public void testClassPath() throws Exception {
+        String moduleClasses = moduleClasses();
+        String testClasses = System.getProperty("test.classes");
+        String classpath = moduleClasses + File.pathSeparator + testClasses;
+        int exitValue = exec(SET_DEFAULT_FSP, "-cp", classpath, "p.Main");
+        assertTrue(exitValue == 0);
+    }
+
+    /**
+     * Test override of default FileSystemProvider with the main application
+     * on the module path as an exploded module.
+     */
+    public void testExplodedModule() throws Exception {
+        String modulePath = System.getProperty("jdk.module.path");
+        int exitValue = exec(SET_DEFAULT_FSP, "-p", modulePath, "-m", "m/p.Main");
+        assertTrue(exitValue == 0);
+    }
+
+    /**
+     * Test override of default FileSystemProvider with the main application
+     * on the module path as a modular JAR.
+     */
+    public void testModularJar() throws Exception {
+        String jarFile = createModularJar();
+        int exitValue = exec(SET_DEFAULT_FSP, "-p", jarFile, "-m", "m/p.Main");
+        assertTrue(exitValue == 0);
+    }
 
-        Class<?> expected = Class.forName("TestProvider", false,
-            ClassLoader.getSystemClassLoader());
+    /**
+     * Test override of default FileSystemProvider where the main application
+     * is a module that is patched by an exploded patch.
+     */
+    public void testExplodedModuleWithExplodedPatch() throws Exception {
+        Path patchdir = Files.createTempDirectory("patch");
+        String modulePath = System.getProperty("jdk.module.path");
+        int exitValue = exec(SET_DEFAULT_FSP,
+                             "--patch-module", "m=" + patchdir,
+                             "-p", modulePath,
+                             "-m", "m/p.Main");
+        assertTrue(exitValue == 0);
+    }
+
+    /**
+     * Test override of default FileSystemProvider where the main application
+     * is a module that is patched by an exploded patch.
+     */
+    public void testExplodedModuleWithJarPatch() throws Exception {
+        Path patchdir = Files.createTempDirectory("patch");
+        Files.createDirectory(patchdir.resolve("m.properties"));
+        Path patch = createJarFile(patchdir);
+        String modulePath = System.getProperty("jdk.module.path");
+        int exitValue = exec(SET_DEFAULT_FSP,
+                             "--patch-module", "m=" + patch,
+                             "-p", modulePath,
+                             "-m", "m/p.Main");
+        assertTrue(exitValue == 0);
+    }
 
-        if (c != expected)
-            throw new RuntimeException();
+    /**
+     * Returns the directory containing the classes for module "m".
+     */
+    private String moduleClasses() {
+        String mp = System.getProperty("jdk.module.path");
+        for (String dir : mp.split(File.pathSeparator)) {
+            Path m = Paths.get(dir, "m");
+            if (Files.exists(m)) return m.toString();
+        }
+        assertFalse(true);
+        return null;
+    }
+
+    /**
+     * Creates a modular JAR containing module "m".
+     */
+    private String createModularJar() throws Exception {
+        Path dir = Paths.get(moduleClasses());
+        Path jar = createJarFile(dir);
+        return jar.toString();
+    }
+
+    /**
+     * Creates a JAR file containing the entries in the given file tree.
+     */
+    private Path createJarFile(Path dir) throws Exception {
+        Path jar = Files.createTempDirectory("tmp").resolve("m.jar");
+        String[] args = { "--create", "--file=" + jar, "-C", dir.toString(), "." };
+        int ret = JAR_TOOL.run(System.out, System.out, args);
+        assertTrue(ret == 0);
+        return jar;
+    }
+
+    /**
+     * Invokes the java launcher with the given arguments, returning the exit code.
+     */
+    private int exec(String... args) throws Exception {
+       return ProcessTools.executeTestJava(args)
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .getExitValue();
     }
 }
--- a/jdk/test/java/nio/file/spi/TestProvider.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/nio/file/spi/TestProvider.java	Wed Jul 05 23:25:53 2017 +0200
@@ -77,7 +77,7 @@
                              LinkOption... options)
         throws IOException
     {
-        throw new ReadOnlyFileSystemException();
+        throw new RuntimeException("not implemented");
     }
 
     @Override
@@ -110,19 +110,20 @@
 
     @Override
     public void delete(Path file) throws IOException {
-        throw new ReadOnlyFileSystemException();
+        Path delegate = theFileSystem.unwrap(file);
+        defaultProvider.delete(delegate);
     }
 
     @Override
     public void createSymbolicLink(Path link, Path target, FileAttribute<?>... attrs)
         throws IOException
     {
-        throw new ReadOnlyFileSystemException();
+        throw new RuntimeException("not implemented");
     }
 
     @Override
     public void createLink(Path link, Path existing) throws IOException {
-        throw new ReadOnlyFileSystemException();
+        throw new RuntimeException("not implemented");
     }
 
     @Override
@@ -136,14 +137,14 @@
     public void copy(Path source, Path target, CopyOption... options)
         throws IOException
     {
-        throw new ReadOnlyFileSystemException();
+        throw new RuntimeException("not implemented");
     }
 
     @Override
     public void move(Path source, Path target, CopyOption... options)
         throws IOException
     {
-        throw new ReadOnlyFileSystemException();
+        throw new RuntimeException("not implemented");
     }
 
     @Override
@@ -158,7 +159,8 @@
     public void createDirectory(Path dir, FileAttribute<?>... attrs)
         throws IOException
     {
-        throw new ReadOnlyFileSystemException();
+        Path delegate = theFileSystem.unwrap(dir);
+        defaultProvider.createDirectory(delegate, attrs);
     }
 
     @Override
@@ -167,13 +169,8 @@
                                               FileAttribute<?>... attrs)
         throws IOException
     {
-        if (options.contains(StandardOpenOption.READ) && options.size() == 1) {
-            Path delegate = theFileSystem.unwrap(file);
-            options = Collections.singleton(StandardOpenOption.READ);
-            return defaultProvider.newByteChannel(delegate, options, attrs);
-        }
-
-        throw new RuntimeException("not implemented");
+        Path delegate = theFileSystem.unwrap(file);
+        return defaultProvider.newByteChannel(delegate, options, attrs);
     }
 
     @Override
@@ -236,7 +233,7 @@
 
         @Override
         public boolean isReadOnly() {
-            return true;
+            return false;
         }
 
         @Override
@@ -419,7 +416,7 @@
 
         @Override
         public File toFile() {
-            return delegate.toFile();
+            return new File(toString());
         }
 
         @Override
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/file/spi/m/module-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+module m {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/file/spi/m/p/Main.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p;
+
+import java.io.File;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+/**
+ * Launched by SetDefaultProvider to test startup with the default file system
+ * provider overridden.
+ */
+
+public class Main {
+    public static void main(String[] args) throws Exception {
+        FileSystem fs = FileSystems.getDefault();
+        if (fs.getClass().getModule() == Object.class.getModule())
+            throw new RuntimeException("FileSystemProvider not overridden");
+
+        // exercise the file system
+        Path dir = Files.createTempDirectory("tmp");
+        if (dir.getFileSystem() != fs)
+            throw new RuntimeException("'dir' not in default file system");
+        System.out.println("created: " + dir);
+
+        Path foo = Files.createFile(dir.resolve("foo"));
+        if (foo.getFileSystem() != fs)
+            throw new RuntimeException("'foo' not in default file system");
+        System.out.println("created: " + foo);
+
+        // exercise interop with java.io.File
+        File file = foo.toFile();
+        Path path = file.toPath();
+        if (path.getFileSystem() != fs)
+            throw new RuntimeException("'path' not in default file system");
+        if (!path.equals(foo))
+            throw new RuntimeException(path + " not equal to " + foo);
+    }
+}
--- a/jdk/test/java/security/AccessController/LimitedDoPrivilegedWithNullPerms.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/security/AccessController/LimitedDoPrivilegedWithNullPerms.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013,2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/security/AccessController/LimitedDoPrivilegedWithThread.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/security/AccessController/LimitedDoPrivilegedWithThread.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013,2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/security/PermissionCollection/PermissionCollectionStreamTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/security/PermissionCollection/PermissionCollectionStreamTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 /* @test
  * @bug 8081678
  * @summary Tests for stream returning methods
- * @library ../../util/stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.stream.OpTestCase
  * @run testng/othervm PermissionCollectionStreamTest
  */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/driverModuleTests/DriverManagerModuleTests.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import static org.testng.Assert.*;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/*
+ * @test
+ * @library /java/sql/modules
+ * @build luckydogdriver/* mystubdriver/*
+ * @run testng/othervm DriverManagerModuleTests
+ * @summary Tests that a JDBC Driver that is a module can be loaded
+ * via the service-provider loading mechanism.
+ */
+public class DriverManagerModuleTests {
+
+    private final String LUCKYDOGDRIVER_URL = "jdbc:tennis:myDB";
+    private static final String STUBDRIVERURL = "jdbc:stub:myDB";
+    private static final String CONNECTION_CLASS_NAME = "com.luckydogtennis.StubConnection";
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @BeforeMethod
+    public void setUpMethod() throws Exception {
+    }
+
+    @AfterMethod
+    public void tearDownMethod() throws Exception {
+    }
+
+    /**
+     * Validate JDBC drivers as modules will be accessible. One driver will be
+     * loaded and registered via the service-provider loading mechanism. The
+     * other driver will need to be explictly loaded
+     *
+     * @throws java.lang.Exception
+     */
+    @Test
+    public void test() throws Exception {
+        System.out.println("\n$$$ runing Test()\n");
+        dumpRegisteredDrivers();
+        Driver d = DriverManager.getDriver(STUBDRIVERURL);
+        assertNotNull(d, "StubDriver should not be null");
+        assertTrue(isDriverRegistered(d));
+        Driver d2 = null;
+
+        // This driver should not be found until it is explictly loaded
+        try {
+            d2 = DriverManager.getDriver(LUCKYDOGDRIVER_URL);
+        } catch (SQLException e) {
+            // ignore expected Exception
+        }
+        assertNull(d2, "LuckyDogDriver should  be null");
+        loadDriver();
+        d2 = DriverManager.getDriver(LUCKYDOGDRIVER_URL);
+        assertNotNull(d2, "LuckyDogDriver should not be null");
+        assertTrue(isDriverRegistered(d2), "Driver was NOT registered");
+
+        dumpRegisteredDrivers();
+        DriverManager.deregisterDriver(d2);
+        assertFalse(isDriverRegistered(d2), "Driver IS STILL registered");
+        dumpRegisteredDrivers();
+
+    }
+
+    /**
+     * Validate that a Connection can be obtained from a JDBC driver which is a
+     * module and loaded via the service-provider loading mechanism.
+     *
+     * @throws java.lang.Exception
+     */
+    @Test
+    public void test00() throws Exception {
+        System.out.println("\n$$$ runing Test00()\n");
+        Connection con = DriverManager.getConnection(STUBDRIVERURL);
+        assertNotNull(con, "Returned Connection should not be NULL");
+        System.out.println("con=" + con.getClass().getName());
+        assertTrue(con.getClass().getName().equals(CONNECTION_CLASS_NAME));
+
+    }
+
+    /**
+     * Utility method to see if a driver is registered
+     */
+    private static void dumpRegisteredDrivers() {
+        System.out.println("\n+++ Loaded Drivers +++");
+
+         DriverManager.drivers().forEach(d -> System.out.println("\t\t### Driver:" + d));
+
+        System.out.println("++++++++++++++++++++++++");
+    }
+
+    /**
+     * Utility method to load the LuckyDogDriver
+     */
+    private static void loadDriver() {
+        try {
+            Class.forName("luckydogtennis.LuckyDogDriver");
+        } catch (ClassNotFoundException ex) {
+            System.out.println("**** Error: luckydogtennis.LuckyDogDriver not found");
+        }
+        System.out.println("Driver Loaded");
+    }
+
+    /**
+     * Utility method to see if a driver is registered
+     */
+    private static boolean isDriverRegistered(Driver d) {
+        return DriverManager.drivers().filter(driver-> driver == d).findFirst().isPresent();
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/modules/luckydogdriver/luckydogtennis/LuckyDogDriver.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package luckydogtennis;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class LuckyDogDriver implements Driver {
+
+    static {
+        registerDriver();
+        System.out.println("*****in static block LuckyDogDriver");
+    }
+
+    private static void registerDriver() {
+        try {
+            DriverManager.registerDriver(new LuckyDogDriver());
+        } catch (SQLException ex) {
+            Logger.getLogger(LuckyDogDriver.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public LuckyDogDriver() {
+        System.out.println("*****in LuckyDogDriver Constructor");
+    }
+
+    @Override
+    public Connection connect(String url, Properties info) throws SQLException {
+        if (acceptsURL(url)) {
+        return new StubConnection();
+        }
+        return null;
+    }
+
+    @Override
+    public boolean acceptsURL(String url) throws SQLException {
+        return url.matches("^jdbc:tennis:.*");
+    }
+
+    @Override
+    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public int getMajorVersion() {
+        return 1;
+    }
+
+    @Override
+    public int getMinorVersion() {
+        return 0;
+    }
+
+    @Override
+    public boolean jdbcCompliant() {
+        return true;
+    }
+
+    @Override
+    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/modules/luckydogdriver/luckydogtennis/StubConnection.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package luckydogtennis;
+
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+
+public class StubConnection implements Connection{
+
+    @Override
+    public Statement createStatement() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public CallableStatement prepareCall(String sql) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public String nativeSQL(String sql) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setAutoCommit(boolean autoCommit) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public boolean getAutoCommit() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void commit() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void rollback() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void close() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public boolean isClosed() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public DatabaseMetaData getMetaData() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setReadOnly(boolean readOnly) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public boolean isReadOnly() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setCatalog(String catalog) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public String getCatalog() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setTransactionIsolation(int level) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public int getTransactionIsolation() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public SQLWarning getWarnings() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void clearWarnings() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Map<String, Class<?>> getTypeMap() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setHoldability(int holdability) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public int getHoldability() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Savepoint setSavepoint() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Savepoint setSavepoint(String name) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void rollback(Savepoint savepoint) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Clob createClob() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Blob createBlob() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public NClob createNClob() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public SQLXML createSQLXML() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public boolean isValid(int timeout) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setClientInfo(String name, String value) throws SQLClientInfoException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setClientInfo(Properties properties) throws SQLClientInfoException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public String getClientInfo(String name) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Properties getClientInfo() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setSchema(String schema) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public String getSchema() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void abort(Executor executor) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public int getNetworkTimeout() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/modules/luckydogdriver/module-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+module luckydogdriver {
+    requires transitive java.logging;
+    requires transitive java.sql;
+    exports luckydogtennis;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/modules/mystubdriver/com/luckydogtennis/StubConnection.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.luckydogtennis;
+
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+
+public class StubConnection implements Connection{
+
+    @Override
+    public Statement createStatement() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public CallableStatement prepareCall(String sql) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public String nativeSQL(String sql) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setAutoCommit(boolean autoCommit) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public boolean getAutoCommit() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void commit() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void rollback() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void close() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public boolean isClosed() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public DatabaseMetaData getMetaData() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setReadOnly(boolean readOnly) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public boolean isReadOnly() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setCatalog(String catalog) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public String getCatalog() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setTransactionIsolation(int level) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public int getTransactionIsolation() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public SQLWarning getWarnings() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void clearWarnings() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Map<String, Class<?>> getTypeMap() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setHoldability(int holdability) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public int getHoldability() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Savepoint setSavepoint() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Savepoint setSavepoint(String name) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void rollback(Savepoint savepoint) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Clob createClob() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Blob createBlob() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public NClob createNClob() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public SQLXML createSQLXML() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public boolean isValid(int timeout) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setClientInfo(String name, String value) throws SQLClientInfoException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setClientInfo(Properties properties) throws SQLClientInfoException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public String getClientInfo(String name) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Properties getClientInfo() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setSchema(String schema) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public String getSchema() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void abort(Executor executor) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public int getNetworkTimeout() throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/modules/mystubdriver/com/luckydogtennis/StubDriver.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.luckydogtennis;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class StubDriver implements Driver {
+
+    static {
+        System.out.println("*****in static block StubDriver");
+        registerDriver();
+    }
+
+    private static void registerDriver() {
+        try {
+            DriverManager.registerDriver(new StubDriver());
+        } catch (SQLException ex) {
+            Logger.getLogger(StubDriver.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public StubDriver() {
+        System.out.println("*****in StubDriver Constructor*************");
+        /*
+        for (StackTraceElement ste : Thread.currentThread().getStackTrace()) {
+            System.out.println(ste);
+        }
+        System.out.println("******************");
+        */
+    }
+
+    @Override
+    public Connection connect(String url, Properties info) throws SQLException {
+        if (acceptsURL(url)) {
+            return new StubConnection();
+        }
+        return null;
+    }
+
+    @Override
+    public boolean acceptsURL(String url) throws SQLException {
+        return url.matches("^jdbc:stub:.*");
+    }
+
+    @Override
+    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    @Override
+    public int getMajorVersion() {
+        return 1;
+    }
+
+    @Override
+    public int getMinorVersion() {
+        return 0;
+    }
+
+    @Override
+    public boolean jdbcCompliant() {
+        return true;
+    }
+
+    @Override
+    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/sql/modules/mystubdriver/module-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+module mystubdriver {
+    requires transitive java.logging;
+    requires transitive java.sql;
+    exports com.luckydogtennis;
+    provides java.sql.Driver with
+        com.luckydogtennis.StubDriver;
+}
--- a/jdk/test/java/time/test/java/time/temporal/TestIsoWeekFields.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/time/test/java/time/temporal/TestIsoWeekFields.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014,2015, Oracle and/or its affiliates. All rights reserved.
+ * 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
--- a/jdk/test/java/util/Arrays/Big.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/Arrays/Big.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 
 // A proper regression test for 5045582 requires too much memory.
 // If you have a really big machine, run like this:
-// java -d64 -Xms25g -Xmx25g Big 30
+// java -Xms25g -Xmx25g Big 30
 
 import java.util.*;
 
@@ -68,7 +68,7 @@
         }
 
         // To test Object arrays larger than 1<<30, you need 13GB. Run like:
-        // java -d64 -Xms13g -Xmx13g Big 30 2
+        // java -Xms13g -Xmx13g Big 30 2
         if ((tasks & 0x2) != 0) {
             System.out.println("Integer[]");
             System.gc();
--- a/jdk/test/java/util/Arrays/ParallelPrefix.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/Arrays/ParallelPrefix.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -179,119 +179,65 @@
     @Test
     public void testNPEs() {
         // null array
-        assertThrows( () -> Arrays.parallelPrefix((int[]) null, Integer::max),
-                NullPointerException.class, "should throw NPE");
-        assertThrows( () -> Arrays.parallelPrefix((long []) null, Long::max),
-                NullPointerException.class, "should throw NPE");
-        assertThrows( () -> Arrays.parallelPrefix((double []) null, Double::max),
-                NullPointerException.class, "should throw NPE");
-        assertThrows( () -> Arrays.parallelPrefix((String []) null, String::concat),
-                NullPointerException.class, "should throw NPE");
+        assertThrowsNPE(() -> Arrays.parallelPrefix((int[]) null, Integer::max));
+        assertThrowsNPE(() -> Arrays.parallelPrefix((long []) null, Long::max));
+        assertThrowsNPE(() -> Arrays.parallelPrefix((double []) null, Double::max));
+        assertThrowsNPE(() -> Arrays.parallelPrefix((String []) null, String::concat));
 
         // null array w/ range
-        assertThrows( () -> Arrays.parallelPrefix((int[]) null, 0, 0, Integer::max),
-                NullPointerException.class, "should throw NPE");
-        assertThrows( () -> Arrays.parallelPrefix((long []) null, 0, 0, Long::max),
-                NullPointerException.class, "should throw NPE");
-        assertThrows( () -> Arrays.parallelPrefix((double []) null, 0, 0, Double::max),
-                NullPointerException.class, "should throw NPE");
-        assertThrows( () -> Arrays.parallelPrefix((String []) null, 0, 0, String::concat),
-                NullPointerException.class, "should throw NPE");
+        assertThrowsNPE(() -> Arrays.parallelPrefix((int[]) null, 0, 0, Integer::max));
+        assertThrowsNPE(() -> Arrays.parallelPrefix((long []) null, 0, 0, Long::max));
+        assertThrowsNPE(() -> Arrays.parallelPrefix((double []) null, 0, 0, Double::max));
+        assertThrowsNPE(() -> Arrays.parallelPrefix((String []) null, 0, 0, String::concat));
 
         // null op
-        assertThrows( () -> Arrays.parallelPrefix(new int[] {}, null),
-                NullPointerException.class, "should throw NPE");
-        assertThrows( () -> Arrays.parallelPrefix(new long[] {}, null),
-                NullPointerException.class, "should throw NPE");
-        assertThrows( () -> Arrays.parallelPrefix(new double[] {}, null),
-                NullPointerException.class, "should throw NPE");
-        assertThrows( () -> Arrays.parallelPrefix(new String[] {}, null),
-                NullPointerException.class, "should throw NPE");
+        assertThrowsNPE(() -> Arrays.parallelPrefix(new int[] {}, null));
+        assertThrowsNPE(() -> Arrays.parallelPrefix(new long[] {}, null));
+        assertThrowsNPE(() -> Arrays.parallelPrefix(new double[] {}, null));
+        assertThrowsNPE(() -> Arrays.parallelPrefix(new String[] {}, null));
 
         // null op w/ range
-        assertThrows( () -> Arrays.parallelPrefix(new int[] {}, 0, 0, null),
-                NullPointerException.class, "should throw NPE");
-        assertThrows( () -> Arrays.parallelPrefix(new long[] {}, 0, 0, null),
-                NullPointerException.class, "should throw NPE");
-        assertThrows( () -> Arrays.parallelPrefix(new double[] {}, 0, 0, null),
-                NullPointerException.class, "should throw NPE");
-        assertThrows( () -> Arrays.parallelPrefix(new String[] {}, 0, 0, null),
-                NullPointerException.class, "should throw NPE");
+        assertThrowsNPE(() -> Arrays.parallelPrefix(new int[] {}, 0, 0, null));
+        assertThrowsNPE(() -> Arrays.parallelPrefix(new long[] {}, 0, 0, null));
+        assertThrowsNPE(() -> Arrays.parallelPrefix(new double[] {}, 0, 0, null));
+        assertThrowsNPE(() -> Arrays.parallelPrefix(new String[] {}, 0, 0, null));
     }
 
     @Test
     public void testIAEs() {
-        assertThrows( () -> Arrays.parallelPrefix(new int[] {}, 1, 0, Integer::max),
-                IllegalArgumentException.class, "should throw IAE");
-        assertThrows( () -> Arrays.parallelPrefix(new long[] {}, 1, 0, Long::max),
-                IllegalArgumentException.class, "should throw IAE");
-        assertThrows( () -> Arrays.parallelPrefix(new double[] {}, 1, 0, Double::max),
-                IllegalArgumentException.class, "should throw IAE");
-        assertThrows( () -> Arrays.parallelPrefix(new String[] {}, 1, 0, String::concat),
-                IllegalArgumentException.class, "should throw IAE");
+        assertThrowsIAE(() -> Arrays.parallelPrefix(new int[] {}, 1, 0, Integer::max));
+        assertThrowsIAE(() -> Arrays.parallelPrefix(new long[] {}, 1, 0, Long::max));
+        assertThrowsIAE(() -> Arrays.parallelPrefix(new double[] {}, 1, 0, Double::max));
+        assertThrowsIAE(() -> Arrays.parallelPrefix(new String[] {}, 1, 0, String::concat));
     }
 
     @Test
-    public void testAIOBEs() {
+    public void testAIOOBEs() {
         // bad "fromIndex"
-        assertThrows( () -> Arrays.parallelPrefix(new int[] {}, -1, 0, Integer::max),
-                ArrayIndexOutOfBoundsException.class, "should throw AIOBE");
-        assertThrows( () -> Arrays.parallelPrefix(new long[] {}, -1, 0, Long::max),
-                ArrayIndexOutOfBoundsException.class, "should throw AIOBE");
-        assertThrows( () -> Arrays.parallelPrefix(new double[] {}, -1, 0, Double::max),
-                ArrayIndexOutOfBoundsException.class, "should throw AIOBE");
-        assertThrows( () -> Arrays.parallelPrefix(new String[] {}, -1, 0, String::concat),
-                ArrayIndexOutOfBoundsException.class, "should throw AIOBE");
+        assertThrowsAIOOB(() -> Arrays.parallelPrefix(new int[] {}, -1, 0, Integer::max));
+        assertThrowsAIOOB(() -> Arrays.parallelPrefix(new long[] {}, -1, 0, Long::max));
+        assertThrowsAIOOB(() -> Arrays.parallelPrefix(new double[] {}, -1, 0, Double::max));
+        assertThrowsAIOOB(() -> Arrays.parallelPrefix(new String[] {}, -1, 0, String::concat));
 
         // bad "toIndex"
-        assertThrows( () -> Arrays.parallelPrefix(new int[] {}, 0, 1, Integer::max),
-                ArrayIndexOutOfBoundsException.class, "should throw AIOBE");
-        assertThrows( () -> Arrays.parallelPrefix(new long[] {}, 0, 1, Long::max),
-                ArrayIndexOutOfBoundsException.class, "should throw AIOBE");
-        assertThrows( () -> Arrays.parallelPrefix(new double[] {}, 0, 1, Double::max),
-                ArrayIndexOutOfBoundsException.class, "should throw AIOBE");
-        assertThrows( () -> Arrays.parallelPrefix(new String[] {}, 0, 1, String::concat),
-                ArrayIndexOutOfBoundsException.class, "should throw AIOBE");
+        assertThrowsAIOOB(() -> Arrays.parallelPrefix(new int[] {}, 0, 1, Integer::max));
+        assertThrowsAIOOB(() -> Arrays.parallelPrefix(new long[] {}, 0, 1, Long::max));
+        assertThrowsAIOOB(() -> Arrays.parallelPrefix(new double[] {}, 0, 1, Double::max));
+        assertThrowsAIOOB(() -> Arrays.parallelPrefix(new String[] {}, 0, 1, String::concat));
     }
 
     // "library" code
 
-    public interface Thrower<T extends Throwable> {
-
-        public void run() throws T;
-    }
-
-
-    public static <T extends Throwable> void assertThrows(Thrower<T> thrower, Class<T> throwable) {
-        assertThrows(thrower, throwable, null);
+    private void assertThrowsNPE(ThrowingRunnable r) {
+        assertThrows(NullPointerException.class, r);
     }
 
-    public static <T extends Throwable> void assertThrows(Thrower<T> thrower, Class<T> throwable, String message) {
-        Throwable thrown;
-        try {
-            thrower.run();
-            thrown = null;
-        } catch (Throwable caught) {
-            thrown = caught;
-        }
-
-        assertInstance(thrown, throwable,
-            ((null != message) ? message : "") +
-            " Failed to throw " + throwable.getCanonicalName());
+    private void assertThrowsIAE(ThrowingRunnable r) {
+        assertThrows(IllegalArgumentException.class, r);
     }
 
-    public static <T extends Throwable> void assertThrows(Class<T> throwable, String message, Thrower<T>... throwers) {
-        for(Thrower<T> thrower : throwers) {
-            assertThrows(thrower, throwable, message);
-        }
-    }
-
-    public static void assertInstance(Object actual, Class<?> expected) {
-        assertInstance(expected.isInstance(actual), null);
-    }
-
-    public static void assertInstance(Object actual, Class<?> expected, String message) {
-        assertTrue(expected.isInstance(actual), message);
+    private void assertThrowsAIOOB(ThrowingRunnable r) {
+        assertThrows(ArrayIndexOutOfBoundsException.class, r);
     }
 
     static void assertArraysEqual(int[] actual, int[] expected) {
--- a/jdk/test/java/util/Arrays/StreamAndSpliterator.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/Arrays/StreamAndSpliterator.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,9 @@
 import java.util.Arrays;
 import java.util.Spliterators;
 
-import static org.testng.Assert.assertNotNull;
+import org.testng.Assert.ThrowingRunnable;
+
+import static org.testng.Assert.assertThrows;
 
 public class StreamAndSpliterator {
     @Test
@@ -124,25 +126,11 @@
         assertThrowsAIOOB(() -> Spliterators.spliterator(new String[]{}, 0, 1, 0));
     }
 
-    void assertThrowsNPE(Runnable r) {
-        NullPointerException caught = null;
-        try {
-            r.run();
-        }
-        catch (NullPointerException e) {
-            caught = e;
-        }
-        assertNotNull(caught, "NullPointerException not thrown");
+    void assertThrowsNPE(ThrowingRunnable r) {
+        assertThrows(NullPointerException.class, r);
     }
 
-    void assertThrowsAIOOB(Runnable r) {
-        ArrayIndexOutOfBoundsException caught = null;
-        try {
-            r.run();
-        }
-        catch (ArrayIndexOutOfBoundsException e) {
-            caught = e;
-        }
-        assertNotNull(caught, "ArrayIndexOutOfBoundsException not thrown");
+    void assertThrowsAIOOB(ThrowingRunnable r) {
+        assertThrows(ArrayIndexOutOfBoundsException.class, r);
     }
 }
--- a/jdk/test/java/util/BitSet/stream/BitSetStreamTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/BitSet/stream/BitSetStreamTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -42,6 +42,7 @@
 
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertThrows;
 import static org.testng.Assert.assertTrue;
 
 /**
@@ -49,7 +50,7 @@
  * @summary test BitSet stream
  * @bug 8012645 8076442
  * @requires os.maxMemory >= 2g
- * @library ../../stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.SpliteratorTestHelper
  *        java.base/java.util.SpliteratorOfIntDataBuilder
  * @run testng/othervm -Xms512m -Xmx1024m BitSetStreamTest
@@ -167,8 +168,8 @@
 
     @Test(dataProvider = "BitSet.stream.spliterator")
     public void testIntNullPointerException(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
-        executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining((IntConsumer) null));
-        executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance((IntConsumer) null));
+        assertThrows(NullPointerException.class, () -> s.get().forEachRemaining((IntConsumer) null));
+        assertThrows(NullPointerException.class, () -> s.get().tryAdvance((IntConsumer) null));
     }
 
     @Test(dataProvider = "BitSet.stream.spliterator")
--- a/jdk/test/java/util/Collections/EmptyNavigableMap.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/Collections/EmptyNavigableMap.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,10 +36,12 @@
 import java.util.NavigableMap;
 import java.util.SortedMap;
 import java.util.TreeMap;
+
+import org.testng.Assert;
+import org.testng.Assert.ThrowingRunnable;
 import org.testng.annotations.Test;
 import org.testng.annotations.DataProvider;
 
-import static org.testng.Assert.fail;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.assertFalse;
 
@@ -65,26 +67,27 @@
             ((null != message) ? message : "") + " Not empty. ");
     }
 
-    public interface Thrower<T extends Throwable> {
-
-        public void run() throws T;
-    }
-
-    public static <T extends Throwable> void assertThrows(Thrower<T> thrower, Class<T> throwable) {
-        assertThrows(thrower, throwable, null);
+    private <T extends Throwable> void assertThrows(Class<T> throwableClass,
+                                                    ThrowingRunnable runnable,
+                                                    String message) {
+        try {
+            Assert.assertThrows(throwableClass, runnable);
+        } catch (AssertionError e) {
+            throw new AssertionError(String.format("%s%n%s",
+                    ((null != message) ? message : ""), e.getMessage()), e);
+        }
     }
 
-    public static <T extends Throwable> void assertThrows(Thrower<T> thrower, Class<T> throwable, String message) {
-        Throwable result;
-        try {
-            thrower.run();
-            fail(((null != message) ? message : "") + "Failed to throw " + throwable.getCanonicalName() + ". ");
-            return;
-        } catch (Throwable caught) {
-            result = caught;
-        }
+    private void assertThrowsCCE(ThrowingRunnable r, String s) {
+        assertThrows(ClassCastException.class, r, s);
+    }
 
-        assertInstance(result, throwable, ((null != message) ? message : "") + "Failed to throw " + throwable.getCanonicalName() + ". ");
+    private void assertThrowsNPE(ThrowingRunnable r, String s) {
+        assertThrows(NullPointerException.class, r, s);
+    }
+
+    private void assertThrowsIAE(ThrowingRunnable r, String s) {
+        assertThrows(IllegalArgumentException.class, r, s);
     }
 
     public static final boolean isDescending(SortedMap<?,?> set) {
@@ -121,10 +124,9 @@
      */
     @Test(dataProvider = "NavigableMap<?,?>", dataProviderClass = EmptyNavigableMap.class)
     public void testContainsRequiresComparable(String description, NavigableMap<?,?> navigableMap) {
-        assertThrows(() -> {
+        assertThrowsCCE(() -> {
             navigableMap.containsKey(new Object());
         },
-            ClassCastException.class,
             description + ": Compareable should be required");
     }
 
@@ -175,14 +177,12 @@
      */
     @Test(dataProvider = "NavigableMap<?,?>", dataProviderClass = EmptyNavigableMap.class)
     public void testHeadMap(String description, NavigableMap navigableMap) {
-        assertThrows(
+        assertThrowsNPE(
             () -> { NavigableMap ss = navigableMap.headMap(null, false); },
-            NullPointerException.class,
             description + ": Must throw NullPointerException for null element");
 
-        assertThrows(
+        assertThrowsCCE(
             () -> { NavigableMap ss = navigableMap.headMap(new Object(), true); },
-            ClassCastException.class,
             description + ": Must throw ClassCastException for non-Comparable element");
 
         NavigableMap ss = navigableMap.headMap("1", false);
@@ -203,50 +203,44 @@
      */
     @Test(dataProvider = "NavigableMap<?,?>", dataProviderClass = EmptyNavigableMap.class)
     public void testSubMap(String description, NavigableMap navigableMap) {
-        assertThrows(
+        assertThrowsNPE(
             () -> {
                 SortedMap ss = navigableMap.subMap(null, BigInteger.TEN);
             },
-            NullPointerException.class,
             description + ": Must throw NullPointerException for null element");
 
-        assertThrows(
+        assertThrowsNPE(
             () -> {
                 SortedMap ss = navigableMap.subMap(BigInteger.ZERO, null);
             },
-            NullPointerException.class,
             description + ": Must throw NullPointerException for null element");
 
-        assertThrows(
+        assertThrowsNPE(
             () -> {
                 SortedMap ss = navigableMap.subMap(null, null);
             },
-            NullPointerException.class,
             description + ": Must throw NullPointerException for null element");
 
         Object obj1 = new Object();
         Object obj2 = new Object();
 
-        assertThrows(
+        assertThrowsCCE(
             () -> {
                 SortedMap ss = navigableMap.subMap(obj1, BigInteger.TEN);
             },
-            ClassCastException.class, description
-            + ": Must throw ClassCastException for parameter which is not Comparable.");
+            description + ": Must throw ClassCastException for parameter which is not Comparable.");
 
-        assertThrows(
+        assertThrowsCCE(
             () -> {
                 SortedMap ss = navigableMap.subMap(BigInteger.ZERO, obj2);
             },
-            ClassCastException.class, description
-            + ": Must throw ClassCastException for parameter which is not Comparable.");
+            description + ": Must throw ClassCastException for parameter which is not Comparable.");
 
-        assertThrows(
+        assertThrowsCCE(
             () -> {
                 SortedMap ss = navigableMap.subMap(obj1, obj2);
             },
-            ClassCastException.class, description
-            + ": Must throw ClassCastException for parameter which is not Comparable.");
+            description + ": Must throw ClassCastException for parameter which is not Comparable.");
 
         // minimal range
         navigableMap.subMap(BigInteger.ZERO, false, BigInteger.ZERO, false);
@@ -257,12 +251,11 @@
         Object first = isDescending(navigableMap) ? BigInteger.TEN : BigInteger.ZERO;
         Object last = (BigInteger.ZERO == first) ? BigInteger.TEN : BigInteger.ZERO;
 
-            assertThrows(
+            assertThrowsIAE(
                 () -> {
                     navigableMap.subMap(last, true, first, false);
                 },
-                IllegalArgumentException.class, description
-                + ": Must throw IllegalArgumentException when fromElement is not less than toElement.");
+                description + ": Must throw IllegalArgumentException when fromElement is not less than toElement.");
 
         navigableMap.subMap(first, true, last, false);
     }
@@ -280,10 +273,9 @@
         // slightly smaller
         NavigableMap ns = subMap.subMap(first, false, last, false);
         // slight expansion
-        assertThrows(() -> {
+        assertThrowsIAE(() -> {
             ns.subMap(first, true, last, true);
         },
-            IllegalArgumentException.class,
             description + ": Expansion should not be allowed");
 
         // much smaller
@@ -301,10 +293,9 @@
         NavigableMap ns = subMap.headMap(BigInteger.ONE, false);
 
         // slight expansion
-        assertThrows(() -> {
+        assertThrowsIAE(() -> {
             ns.headMap(BigInteger.ONE, true);
         },
-            IllegalArgumentException.class,
             description + ": Expansion should not be allowed");
 
         // much smaller
@@ -322,10 +313,9 @@
         NavigableMap ns = subMap.tailMap(BigInteger.ONE, false);
 
         // slight expansion
-        assertThrows(() -> {
+        assertThrowsIAE(() -> {
             ns.tailMap(BigInteger.ONE, true);
         },
-            IllegalArgumentException.class,
             description + ": Expansion should not be allowed");
 
         // much smaller
@@ -337,15 +327,15 @@
      */
     @Test(dataProvider = "NavigableMap<?,?>", dataProviderClass = EmptyNavigableMap.class)
     public void testTailMap(String description, NavigableMap navigableMap) {
-        assertThrows(() -> {
+        assertThrowsNPE(() -> {
             navigableMap.tailMap(null);
         },
-            NullPointerException.class,
             description + ": Must throw NullPointerException for null element");
 
-        assertThrows(() -> {
+        assertThrowsCCE(() -> {
             navigableMap.tailMap(new Object());
-        }, ClassCastException.class);
+        },
+            description);
 
         NavigableMap ss = navigableMap.tailMap("1", true);
 
--- a/jdk/test/java/util/Collections/EmptyNavigableSet.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/Collections/EmptyNavigableSet.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,10 +37,12 @@
 import java.util.NavigableSet;
 import java.util.SortedSet;
 import java.util.TreeSet;
+
+import org.testng.Assert;
+import org.testng.Assert.ThrowingRunnable;
 import org.testng.annotations.Test;
 import org.testng.annotations.DataProvider;
 
-import static org.testng.Assert.fail;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertSame;
 import static org.testng.Assert.assertTrue;
@@ -67,26 +69,31 @@
             ((null != message) ? message : "") + " Not empty. ");
     }
 
-    public interface Thrower<T extends Throwable> {
-
-        public void run() throws T;
-    }
-
-    public static <T extends Throwable> void assertThrows(Thrower<T> thrower, Class<T> throwable) {
-        assertThrows(thrower, throwable, null);
+    private <T extends Throwable> void assertThrows(Class<T> throwableClass,
+                                                    ThrowingRunnable runnable,
+                                                    String message) {
+        try {
+            Assert.assertThrows(throwableClass, runnable);
+        } catch (AssertionError e) {
+            throw new AssertionError(String.format("%s%n%s",
+                    ((null != message) ? message : ""), e.getMessage()), e);
+        }
     }
 
-    public static <T extends Throwable> void assertThrows(Thrower<T> thrower, Class<T> throwable, String message) {
-        Throwable result;
-        try {
-            thrower.run();
-            fail(((null != message) ? message : "") + "Failed to throw " + throwable.getCanonicalName() + ". ");
-            return;
-        } catch (Throwable caught) {
-            result = caught;
-        }
+    private void assertThrowsCCE(ThrowingRunnable r, String s) {
+        assertThrows(ClassCastException.class, r, s);
+    }
 
-        assertInstance(result, throwable, ((null != message) ? message : "") + "Failed to throw " + throwable.getCanonicalName() + ". ");
+    private void assertThrowsNPE(ThrowingRunnable r, String s) {
+        assertThrows(NullPointerException.class, r, s);
+    }
+
+    private void assertThrowsIAE(ThrowingRunnable r, String s) {
+        assertThrows(IllegalArgumentException.class, r, s);
+    }
+
+    private void assertThrowsNSEE(ThrowingRunnable r, String s) {
+        assertThrows(NoSuchElementException.class, r, s);
     }
 
     public static final boolean isDescending(SortedSet<?> set) {
@@ -123,10 +130,9 @@
      */
     @Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
     public void testContainsRequiresComparable(String description, NavigableSet<?> navigableSet) {
-        assertThrows(() -> {
+        assertThrowsCCE(() -> {
             navigableSet.contains(new Object());
         },
-            ClassCastException.class,
             description + ": Compareable should be required");
     }
 
@@ -176,9 +182,9 @@
      */
     @Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
     public void testFirst(String description, NavigableSet<?> navigableSet) {
-        assertThrows(() -> {
+        assertThrowsNSEE(() -> {
             navigableSet.first();
-        }, NoSuchElementException.class, description);
+        }, description);
     }
 
     /**
@@ -186,14 +192,12 @@
      */
     @Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
     public void testHeadSet(String description, NavigableSet navigableSet) {
-        assertThrows(
+        assertThrowsNPE(
             () -> { NavigableSet ns = navigableSet.headSet(null, false); },
-            NullPointerException.class,
             description + ": Must throw NullPointerException for null element");
 
-        assertThrows(
+        assertThrowsCCE(
             () -> { NavigableSet ns = navigableSet.headSet(new Object(), true); },
-            ClassCastException.class,
             description + ": Must throw ClassCastException for non-Comparable element");
 
         NavigableSet ns = navigableSet.headSet("1", false);
@@ -206,9 +210,9 @@
      */
     @Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
     public void testLast(String description, NavigableSet<?> navigableSet) {
-        assertThrows(() -> {
+        assertThrowsNSEE(() -> {
             navigableSet.last();
-        }, NoSuchElementException.class, description);
+        }, description);
     }
 
     /**
@@ -224,50 +228,44 @@
      */
     @Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
     public void testSubSet(String description, NavigableSet navigableSet) {
-        assertThrows(
+        assertThrowsNPE(
             () -> {
                 SortedSet ss = navigableSet.subSet(null, BigInteger.TEN);
             },
-            NullPointerException.class,
             description + ": Must throw NullPointerException for null element");
 
-        assertThrows(
+        assertThrowsNPE(
             () -> {
                 SortedSet ss = navigableSet.subSet(BigInteger.ZERO, null);
             },
-            NullPointerException.class,
             description + ": Must throw NullPointerException for null element");
 
-        assertThrows(
+        assertThrowsNPE(
             () -> {
                 SortedSet ss = navigableSet.subSet(null, null);
             },
-            NullPointerException.class,
             description + ": Must throw NullPointerException for null element");
 
         Object obj1 = new Object();
         Object obj2 = new Object();
 
-        assertThrows(
+        assertThrowsCCE(
             () -> {
                 SortedSet ss = navigableSet.subSet(obj1, BigInteger.TEN);
             },
-            ClassCastException.class, description
-            + ": Must throw ClassCastException for parameter which is not Comparable.");
+            description + ": Must throw ClassCastException for parameter which is not Comparable.");
 
-        assertThrows(
+        assertThrowsCCE(
             () -> {
                 SortedSet ss = navigableSet.subSet(BigInteger.ZERO, obj2);
             },
-            ClassCastException.class, description
-            + ": Must throw ClassCastException for parameter which is not Comparable.");
+            description + ": Must throw ClassCastException for parameter which is not Comparable.");
 
-        assertThrows(
+        assertThrowsCCE(
             () -> {
                 SortedSet ss = navigableSet.subSet(obj1, obj2);
             },
-            ClassCastException.class, description
-            + ": Must throw ClassCastException for parameter which is not Comparable.");
+            description + ": Must throw ClassCastException for parameter which is not Comparable.");
 
         // minimal range
         navigableSet.subSet(BigInteger.ZERO, false, BigInteger.ZERO, false);
@@ -278,11 +276,11 @@
         Object first = isDescending(navigableSet) ? BigInteger.TEN : BigInteger.ZERO;
         Object last = (BigInteger.ZERO == first) ? BigInteger.TEN : BigInteger.ZERO;
 
-            assertThrows(
+            assertThrowsIAE(
                 () -> {
                     navigableSet.subSet(last, true, first, false);
                 },
-                IllegalArgumentException.class, description
+                description
                 + ": Must throw IllegalArgumentException when fromElement is not less than toElement.");
 
         navigableSet.subSet(first, true, last, false);
@@ -301,10 +299,9 @@
         // slightly smaller
         NavigableSet ns = subSet.subSet(first, false, last, false);
         // slight expansion
-        assertThrows(() -> {
+        assertThrowsIAE(() -> {
             ns.subSet(first, true, last, true);
         },
-            IllegalArgumentException.class,
             description + ": Expansion should not be allowed");
 
         // much smaller
@@ -322,10 +319,9 @@
         NavigableSet ns = subSet.headSet(BigInteger.ONE, false);
 
         // slight expansion
-        assertThrows(() -> {
+        assertThrowsIAE(() -> {
             ns.headSet(BigInteger.ONE, true);
         },
-            IllegalArgumentException.class,
             description + ": Expansion should not be allowed");
 
         // much smaller
@@ -343,10 +339,9 @@
         NavigableSet ns = subSet.tailSet(BigInteger.ONE, false);
 
         // slight expansion
-        assertThrows(() -> {
+        assertThrowsIAE(() -> {
             ns.tailSet(BigInteger.ONE, true);
         },
-            IllegalArgumentException.class,
             description + ": Expansion should not be allowed");
 
         // much smaller
@@ -358,15 +353,14 @@
      */
     @Test(dataProvider = "NavigableSet<?>", dataProviderClass = EmptyNavigableSet.class)
     public void testTailSet(String description, NavigableSet navigableSet) {
-        assertThrows(() -> {
+        assertThrowsNPE(() -> {
             navigableSet.tailSet(null);
         },
-            NullPointerException.class,
             description + ": Must throw NullPointerException for null element");
 
-        assertThrows(() -> {
+        assertThrowsCCE(() -> {
             navigableSet.tailSet(new Object());
-        }, ClassCastException.class);
+        }, description);
 
         NavigableSet ss = navigableSet.tailSet("1", true);
 
--- a/jdk/test/java/util/Iterator/PrimitiveIteratorDefaults.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/Iterator/PrimitiveIteratorDefaults.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,16 +21,16 @@
  * questions.
  */
 
-import org.testng.annotations.Test;
-
 import java.util.PrimitiveIterator;
 import java.util.function.Consumer;
 import java.util.function.DoubleConsumer;
 import java.util.function.IntConsumer;
 import java.util.function.LongConsumer;
 
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
+import org.testng.Assert.ThrowingRunnable;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertThrows;
 
 /**
  * @test
@@ -53,8 +53,8 @@
             }
         };
 
-        executeAndCatch(() -> i.forEachRemaining((IntConsumer) null));
-        executeAndCatch(() -> i.forEachRemaining((Consumer<Integer>) null));
+        assertThrowsNPE(() -> i.forEachRemaining((IntConsumer) null));
+        assertThrowsNPE(() -> i.forEachRemaining((Consumer<Integer>) null));
     }
 
     public void testLongForEachRemainingWithNull() {
@@ -70,8 +70,8 @@
             }
         };
 
-        executeAndCatch(() -> i.forEachRemaining((LongConsumer) null));
-        executeAndCatch(() -> i.forEachRemaining((Consumer<Long>) null));
+        assertThrowsNPE(() -> i.forEachRemaining((LongConsumer) null));
+        assertThrowsNPE(() -> i.forEachRemaining((Consumer<Long>) null));
     }
 
     public void testDoubleForEachRemainingWithNull() {
@@ -87,29 +87,12 @@
             }
         };
 
-        executeAndCatch(() -> i.forEachRemaining((DoubleConsumer) null));
-        executeAndCatch(() -> i.forEachRemaining((Consumer<Double>) null));
-    }
-
-    private void executeAndCatch(Runnable r) {
-        executeAndCatch(NullPointerException.class, r);
+        assertThrowsNPE(() -> i.forEachRemaining((DoubleConsumer) null));
+        assertThrowsNPE(() -> i.forEachRemaining((Consumer<Double>) null));
     }
 
-    private void executeAndCatch(Class<? extends Exception> expected, Runnable r) {
-        Exception caught = null;
-        try {
-            r.run();
-        }
-        catch (Exception e) {
-            caught = e;
-        }
-
-        assertNotNull(caught,
-                      String.format("No Exception was thrown, expected an Exception of %s to be thrown",
-                                    expected.getName()));
-        assertTrue(expected.isInstance(caught),
-                   String.format("Exception thrown %s not an instance of %s",
-                                 caught.getClass().getName(), expected.getName()));
+    private void assertThrowsNPE(ThrowingRunnable r) {
+        assertThrows(NullPointerException.class, r);
     }
 
 }
--- a/jdk/test/java/util/Map/Defaults.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/Map/Defaults.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,15 +53,19 @@
 import java.util.function.Function;
 import java.util.function.Supplier;
 
+import org.testng.Assert.ThrowingRunnable;
 import org.testng.annotations.Test;
 import org.testng.annotations.DataProvider;
+
 import static java.util.Objects.requireNonNull;
+
 import static org.testng.Assert.fail;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertThrows;
 
 public class Defaults {
 
@@ -159,14 +163,8 @@
 
     @Test(dataProvider = "Map<IntegerEnum,String> rw=true keys=nonNull values=nonNull")
     public static void testReplaceAllNoNullReplacement(String description, Map<IntegerEnum, String> map) {
-        assertThrows(
-            () -> { map.replaceAll(null); },
-            NullPointerException.class,
-            description);
-        assertThrows(
-            () -> { map.replaceAll((k,v) -> null); },
-            NullPointerException.class,
-            description + " should not allow replacement with null value");
+        assertThrowsNPE(() -> map.replaceAll(null));
+        assertThrowsNPE(() -> map.replaceAll((k,v) -> null)); //should not allow replacement with null value
     }
 
     @Test(dataProvider = "Map<IntegerEnum,String> rw=true keys=withNull values=withNull")
@@ -209,7 +207,7 @@
     public void testReplaceKVNoNulls(String description, Map<IntegerEnum, String> map) {
         assertTrue(map.containsKey(FIRST_KEY), "expected key missing");
         assertSame(map.get(FIRST_KEY), FIRST_VALUE, "found wrong value");
-        assertThrows( () -> {map.replace(FIRST_KEY, null);}, NullPointerException.class, description + ": should throw NPE");
+        assertThrowsNPE(() -> map.replace(FIRST_KEY, null));
         assertSame(map.replace(FIRST_KEY, EXTRA_VALUE), FIRST_VALUE, description + ": replaced wrong value");
         assertSame(map.get(FIRST_KEY), EXTRA_VALUE, "found wrong value");
     }
@@ -248,8 +246,13 @@
     public void testReplaceKVVNoNulls(String description, Map<IntegerEnum, String> map) {
         assertTrue(map.containsKey(FIRST_KEY), "expected key missing");
         assertSame(map.get(FIRST_KEY), FIRST_VALUE, "found wrong value");
-        assertThrows( () -> {map.replace(FIRST_KEY, FIRST_VALUE, null);}, NullPointerException.class, description + ": should throw NPE");
-        assertThrows( () -> {if (!map.replace(FIRST_KEY, null, EXTRA_VALUE)) throw new NullPointerException("default returns false rather than throwing");}, NullPointerException.class,  description + ": should throw NPE");
+        assertThrowsNPE(() -> map.replace(FIRST_KEY, FIRST_VALUE, null));
+        assertThrowsNPE(
+                () -> {
+                    if (!map.replace(FIRST_KEY, null, EXTRA_VALUE)) {
+                        throw new NullPointerException("default returns false rather than throwing");
+                    }
+                });
         assertTrue(map.replace(FIRST_KEY, FIRST_VALUE, EXTRA_VALUE), description + ": replaced wrong value");
         assertSame(map.get(FIRST_KEY), EXTRA_VALUE, "found wrong value");
     }
@@ -319,9 +322,7 @@
 
     @Test(dataProvider = "Map<IntegerEnum,String> rw=true keys=all values=all")
     public void testComputeIfAbsentNullFunction(String description, Map<IntegerEnum, String> map) {
-        assertThrows( () -> { map.computeIfAbsent(KEYS[1], null);},
-                NullPointerException.class,
-                "Should throw NPE");
+        assertThrowsNPE(() -> map.computeIfAbsent(KEYS[1], null));
     }
 
     @Test(dataProvider = "Map<IntegerEnum,String> rw=true keys=withNull values=withNull")
@@ -366,9 +367,7 @@
 
     @Test(dataProvider = "Map<IntegerEnum,String> rw=true keys=all values=all")
     public void testComputeIfPresentNullFunction(String description, Map<IntegerEnum, String> map) {
-        assertThrows( () -> { map.computeIfPresent(KEYS[1], null);},
-                NullPointerException.class,
-                "Should throw NPE");
+        assertThrowsNPE(() -> map.computeIfPresent(KEYS[1], null));
     }
 
      @Test(dataProvider = "Map<IntegerEnum,String> rw=true keys=withNull values=withNull")
@@ -459,9 +458,7 @@
 
     @Test(dataProvider = "Map<IntegerEnum,String> rw=true keys=all values=all")
     public void testComputeNullFunction(String description, Map<IntegerEnum, String> map) {
-        assertThrows( () -> { map.compute(KEYS[1], null);},
-                NullPointerException.class,
-                "Should throw NPE");
+        assertThrowsNPE(() -> map.compute(KEYS[1], null));
     }
 
     @Test(dataProvider = "MergeCases")
@@ -531,9 +528,7 @@
 
     @Test(dataProvider = "Map<IntegerEnum,String> rw=true keys=all values=all")
     public void testMergeNullMerger(String description, Map<IntegerEnum, String> map) {
-        assertThrows( () -> { map.merge(KEYS[1], VALUES[1], null);},
-                NullPointerException.class,
-                "Should throw NPE");
+        assertThrowsNPE(() -> map.merge(KEYS[1], VALUES[1], null));
     }
 
     /** A function that flipflops between running two other functions. */
@@ -973,41 +968,8 @@
         return cases;
     }
 
-    public interface Thrower<T extends Throwable> {
-
-        public void run() throws T;
-    }
-
-    public static <T extends Throwable> void assertThrows(Thrower<T> thrower, Class<T> throwable) {
-        assertThrows(thrower, throwable, null);
-    }
-
-    public static <T extends Throwable> void assertThrows(Thrower<T> thrower, Class<T> throwable, String message) {
-        Throwable thrown;
-        try {
-            thrower.run();
-            thrown = null;
-        } catch (Throwable caught) {
-            thrown = caught;
-        }
-
-        assertInstance(thrown, throwable,
-            ((null != message) ? message : "") +
-            " Failed to throw " + throwable.getCanonicalName());
-    }
-
-    public static <T extends Throwable> void assertThrows(Class<T> throwable, String message, Thrower<T>... throwers) {
-        for (Thrower<T> thrower : throwers) {
-            assertThrows(thrower, throwable, message);
-        }
-    }
-
-    public static void assertInstance(Object actual, Class<?> expected) {
-        assertInstance(expected.isInstance(actual), null);
-    }
-
-    public static void assertInstance(Object actual, Class<?> expected, String message) {
-        assertTrue(expected.isInstance(actual), message);
+    public static void assertThrowsNPE(ThrowingRunnable r) {
+        assertThrows(NullPointerException.class, r);
     }
 
     /**
--- a/jdk/test/java/util/Random/RandomTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/Random/RandomTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,14 +21,13 @@
  * questions.
  */
 
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
 import java.util.Random;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.LongAdder;
 import java.util.function.BiConsumer;
 
+import org.testng.annotations.Test;
+
 import static org.testng.Assert.*;
 
 /**
@@ -172,12 +171,12 @@
      */
     public void testBadStreamSize() {
         Random r = new Random();
-        executeAndCatchIAE(() -> r.ints(-1L));
-        executeAndCatchIAE(() -> r.ints(-1L, 2, 3));
-        executeAndCatchIAE(() -> r.longs(-1L));
-        executeAndCatchIAE(() -> r.longs(-1L, -1L, 1L));
-        executeAndCatchIAE(() -> r.doubles(-1L));
-        executeAndCatchIAE(() -> r.doubles(-1L, .5, .6));
+        assertThrowsIAE(() -> r.ints(-1L));
+        assertThrowsIAE(() -> r.ints(-1L, 2, 3));
+        assertThrowsIAE(() -> r.longs(-1L));
+        assertThrowsIAE(() -> r.longs(-1L, -1L, 1L));
+        assertThrowsIAE(() -> r.doubles(-1L));
+        assertThrowsIAE(() -> r.doubles(-1L, .5, .6));
     }
 
     /**
@@ -186,10 +185,10 @@
      */
     public void testBadStreamBounds() {
         Random r = new Random();
-        executeAndCatchIAE(() -> r.ints(2, 1));
-        executeAndCatchIAE(() -> r.ints(10, 42, 42));
-        executeAndCatchIAE(() -> r.longs(-1L, -1L));
-        executeAndCatchIAE(() -> r.longs(10, 1L, -2L));
+        assertThrowsIAE(() -> r.ints(2, 1));
+        assertThrowsIAE(() -> r.ints(10, 42, 42));
+        assertThrowsIAE(() -> r.longs(-1L, -1L));
+        assertThrowsIAE(() -> r.longs(10, 1L, -2L));
 
         testDoubleBadOriginBound((o, b) -> r.doubles(10, o, b));
     }
@@ -198,45 +197,28 @@
     static final double FINITE = Math.PI;
 
     void testDoubleBadOriginBound(BiConsumer<Double, Double> bi) {
-        executeAndCatchIAE(() -> bi.accept(17.0, 2.0));
-        executeAndCatchIAE(() -> bi.accept(0.0, 0.0));
-        executeAndCatchIAE(() -> bi.accept(Double.NaN, FINITE));
-        executeAndCatchIAE(() -> bi.accept(FINITE, Double.NaN));
-        executeAndCatchIAE(() -> bi.accept(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY));
+        assertThrowsIAE(() -> bi.accept(17.0, 2.0));
+        assertThrowsIAE(() -> bi.accept(0.0, 0.0));
+        assertThrowsIAE(() -> bi.accept(Double.NaN, FINITE));
+        assertThrowsIAE(() -> bi.accept(FINITE, Double.NaN));
+        assertThrowsIAE(() -> bi.accept(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY));
 
         // Returns NaN
-//        executeAndCatchIAE(() -> bi.accept(Double.NEGATIVE_INFINITY, FINITE));
-//        executeAndCatchIAE(() -> bi.accept(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY));
+//        assertThrowsIAE(() -> bi.accept(Double.NEGATIVE_INFINITY, FINITE));
+//        assertThrowsIAE(() -> bi.accept(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY));
 
-        executeAndCatchIAE(() -> bi.accept(FINITE, Double.NEGATIVE_INFINITY));
+        assertThrowsIAE(() -> bi.accept(FINITE, Double.NEGATIVE_INFINITY));
 
         // Returns Double.MAX_VALUE
-//        executeAndCatchIAE(() -> bi.accept(FINITE, Double.POSITIVE_INFINITY));
+//        assertThrowsIAE(() -> bi.accept(FINITE, Double.POSITIVE_INFINITY));
 
-        executeAndCatchIAE(() -> bi.accept(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY));
-        executeAndCatchIAE(() -> bi.accept(Double.POSITIVE_INFINITY, FINITE));
-        executeAndCatchIAE(() -> bi.accept(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY));
+        assertThrowsIAE(() -> bi.accept(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY));
+        assertThrowsIAE(() -> bi.accept(Double.POSITIVE_INFINITY, FINITE));
+        assertThrowsIAE(() -> bi.accept(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY));
     }
 
-    private void executeAndCatchIAE(Runnable r) {
-        executeAndCatch(IllegalArgumentException.class, r);
-    }
-
-    private void executeAndCatch(Class<? extends Exception> expected, Runnable r) {
-        Exception caught = null;
-        try {
-            r.run();
-        }
-        catch (Exception e) {
-            caught = e;
-        }
-
-        assertNotNull(caught,
-                      String.format("No Exception was thrown, expected an Exception of %s to be thrown",
-                                    expected.getName()));
-        Assert.assertTrue(expected.isInstance(caught),
-                          String.format("Exception thrown %s not an instance of %s",
-                                        caught.getClass().getName(), expected.getName()));
+    private void assertThrowsIAE(ThrowingRunnable r) {
+        assertThrows(IllegalArgumentException.class, r);
     }
 
     /**
--- a/jdk/test/java/util/ResourceBundle/getBaseBundleName/resources/PropertyBundle.properties	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/ResourceBundle/getBaseBundleName/resources/PropertyBundle.properties	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 20013, Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -21,4 +21,3 @@
 # questions.
 #
 dummy=foo
-
--- a/jdk/test/java/util/Scanner/ScannerStreamTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/Scanner/ScannerStreamTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -47,7 +47,7 @@
  * @test
  * @bug 8072722 8150488
  * @summary Tests of stream support in java.util.Scanner
- * @library ../stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.stream.OpTestCase
  * @run testng/othervm ScannerStreamTest
  */
--- a/jdk/test/java/util/Spliterator/SpliteratorCollisions.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/Spliterator/SpliteratorCollisions.java	Wed Jul 05 23:25:53 2017 +0200
@@ -24,7 +24,7 @@
 /**
  * @test
  * @bug 8005698
- * @library ../stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.SpliteratorTestHelper
  * @run testng SpliteratorCollisions
  * @summary Spliterator traversing and splitting hash maps containing colliding hashes
@@ -212,16 +212,16 @@
     void testNullPointerException(String description,
                                   Collection<HashableInteger> exp,
                                   Supplier<Spliterator<HashableInteger>> s) {
-        executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining(null));
-        executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance(null));
+        assertThrowsNPE(() -> s.get().forEachRemaining(null));
+        assertThrowsNPE(() -> s.get().tryAdvance(null));
     }
 
     @Test(dataProvider = "HashableIntSpliteratorWithNull")
     void testNullPointerExceptionWithNull(String description,
                                           Collection<HashableInteger> exp,
                                           Supplier<Spliterator<HashableInteger>> s) {
-        executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining(null));
-        executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance(null));
+        assertThrowsNPE(() -> s.get().forEachRemaining(null));
+        assertThrowsNPE(() -> s.get().tryAdvance(null));
     }
 
 
--- a/jdk/test/java/util/Spliterator/SpliteratorFailFastTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/Spliterator/SpliteratorFailFastTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,9 +21,6 @@
  * questions.
  */
 
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.ConcurrentModificationException;
@@ -42,8 +39,11 @@
 import java.util.WeakHashMap;
 import java.util.function.Supplier;
 
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
+import org.testng.Assert.ThrowingRunnable;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertThrows;
 
 /**
  * @test
@@ -125,7 +125,7 @@
             });
             source.update();
 
-            executeAndCatch(() -> s.tryAdvance(e -> {
+            assertThrowsCME(() -> s.tryAdvance(e -> {
             }));
         }
 
@@ -137,7 +137,7 @@
             });
             source.update();
 
-            executeAndCatch(() -> s.forEachRemaining(e -> {
+            assertThrowsCME(() -> s.forEachRemaining(e -> {
             }));
         }
     }
@@ -147,7 +147,7 @@
         Source<T> source = ss.get();
         Spliterator<T> s = source.spliterator();
 
-        executeAndCatch(() -> s.forEachRemaining(e -> {
+        assertThrowsCME(() -> s.forEachRemaining(e -> {
             source.update();
         }));
     }
@@ -161,7 +161,7 @@
             s.estimateSize();
             source.update();
 
-            executeAndCatch(() -> s.tryAdvance(e -> {
+            assertThrowsCME(() -> s.tryAdvance(e -> {
             }));
         }
 
@@ -172,30 +172,13 @@
             s.estimateSize();
             source.update();
 
-            executeAndCatch(() -> s.forEachRemaining(e -> {
+            assertThrowsCME(() -> s.forEachRemaining(e -> {
             }));
         }
     }
 
-    private void executeAndCatch(Runnable r) {
-        executeAndCatch(ConcurrentModificationException.class, r);
-    }
-
-    private void executeAndCatch(Class<? extends Exception> expected, Runnable r) {
-        Exception caught = null;
-        try {
-            r.run();
-        }
-        catch (Exception e) {
-            caught = e;
-        }
-
-        assertNotNull(caught,
-                      String.format("No Exception was thrown, expected an Exception of %s to be thrown",
-                                    expected.getName()));
-        assertTrue(expected.isInstance(caught),
-                   String.format("Exception thrown %s not an instance of %s",
-                                 caught.getClass().getName(), expected.getName()));
+    private void assertThrowsCME(ThrowingRunnable r) {
+        assertThrows(ConcurrentModificationException.class, r);
     }
 
 }
--- a/jdk/test/java/util/Spliterator/SpliteratorLateBindingFailFastHelper.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/Spliterator/SpliteratorLateBindingFailFastHelper.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -24,7 +24,7 @@
 /**
  * @test
  * @summary Spliterator traversing and splitting tests
- * @library ../stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.SpliteratorOfIntDataBuilder
  *        java.base/java.util.SpliteratorTestHelper
  * @run testng SpliteratorTraversingAndSplittingTest
@@ -666,8 +666,8 @@
 
     @Test(dataProvider = "Spliterator<Integer>")
     public void testNullPointerException(String description, Collection<Integer> exp, Supplier<Spliterator<Integer>> s) {
-        executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining(null));
-        executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance(null));
+        assertThrowsNPE(() -> s.get().forEachRemaining(null));
+        assertThrowsNPE(() -> s.get().tryAdvance(null));
     }
 
     @Test(dataProvider = "Spliterator<Integer>")
@@ -866,8 +866,8 @@
 
     @Test(dataProvider = "Spliterator.OfInt")
     public void testIntNullPointerException(String description, Collection<Integer> exp, Supplier<Spliterator.OfInt> s) {
-        executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining((IntConsumer) null));
-        executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance((IntConsumer) null));
+        assertThrowsNPE(() -> s.get().forEachRemaining((IntConsumer) null));
+        assertThrowsNPE(() -> s.get().tryAdvance((IntConsumer) null));
     }
 
     @Test(dataProvider = "Spliterator.OfInt")
@@ -1009,8 +1009,8 @@
 
     @Test(dataProvider = "Spliterator.OfLong")
     public void testLongNullPointerException(String description, Collection<Long> exp, Supplier<Spliterator.OfLong> s) {
-        executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining((LongConsumer) null));
-        executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance((LongConsumer) null));
+        assertThrowsNPE(() -> s.get().forEachRemaining((LongConsumer) null));
+        assertThrowsNPE(() -> s.get().tryAdvance((LongConsumer) null));
     }
 
     @Test(dataProvider = "Spliterator.OfLong")
@@ -1152,8 +1152,8 @@
 
     @Test(dataProvider = "Spliterator.OfDouble")
     public void testDoubleNullPointerException(String description, Collection<Double> exp, Supplier<Spliterator.OfDouble> s) {
-        executeAndCatch(NullPointerException.class, () -> s.get().forEachRemaining((DoubleConsumer) null));
-        executeAndCatch(NullPointerException.class, () -> s.get().tryAdvance((DoubleConsumer) null));
+        assertThrowsNPE(() -> s.get().forEachRemaining((DoubleConsumer) null));
+        assertThrowsNPE(() -> s.get().tryAdvance((DoubleConsumer) null));
     }
 
     @Test(dataProvider = "Spliterator.OfDouble")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/jar/Pack200/SecurityTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8179645
+ * @run main/othervm SecurityTest
+ * @summary Verify Pack200 initialization with security manager
+ */
+
+import java.util.jar.Pack200;
+
+public class SecurityTest {
+    public static void main(String... args) {
+        System.setSecurityManager(new SecurityManager());
+        Pack200.newPacker();
+        Pack200.newUnpacker();
+    }
+}
--- a/jdk/test/java/util/logging/Logger/logrb/resources/PropertyBundle.properties	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/logging/Logger/logrb/resources/PropertyBundle.properties	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 20013, Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -21,4 +21,3 @@
 # questions.
 #
 dummy=foo
-
--- a/jdk/test/java/util/logging/Logger/setResourceBundle/resources/PropertyBundle.properties	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/logging/Logger/setResourceBundle/resources/PropertyBundle.properties	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 20013, Oracle and/or its affiliates. All rights reserved.
+# 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
@@ -21,4 +21,3 @@
 # questions.
 #
 dummy=foo
-
--- a/jdk/test/java/util/logging/TestLoggerWeakRefLeak.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/logging/TestLoggerWeakRefLeak.java	Wed Jul 05 23:25:53 2017 +0200
@@ -41,8 +41,8 @@
  * @modules jdk.attach/sun.tools.attach
  *          java.logging
  * @build jdk.testlibrary.ProcessTools
- * @run main/othervm TestLoggerWeakRefLeak Logger
- * @run main/othervm TestLoggerWeakRefLeak AnonymousLogger
+ * @run main/othervm -Djdk.attach.allowAttachSelf TestLoggerWeakRefLeak Logger
+ * @run main/othervm -Djdk.attach.allowAttachSelf TestLoggerWeakRefLeak AnonymousLogger
  */
 public class TestLoggerWeakRefLeak {
 
--- a/jdk/test/java/util/regex/PatternStreamTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/regex/PatternStreamTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8016846 8024341 8071479 8145006
  * @summary Unit tests stream and lambda-based methods on Pattern and Matcher
- * @library ../stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.stream.OpTestCase
  * @run testng/othervm PatternStreamTest
  */
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/SpliteratorOfIntDataBuilder.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.util;
-
-import java.util.function.Supplier;
-
-public class SpliteratorOfIntDataBuilder {
-        List<Object[]> data;
-
-        List<Integer> exp;
-
-        public SpliteratorOfIntDataBuilder(List<Object[]> data, List<Integer> exp) {
-            this.data = data;
-            this.exp = exp;
-        }
-
-        public void add(String description, List<Integer> expected, Supplier<Spliterator.OfInt> s) {
-            description = joiner(description).toString();
-            data.add(new Object[]{description, expected, s});
-        }
-
-        public void add(String description, Supplier<Spliterator.OfInt> s) {
-            add(description, exp, s);
-        }
-
-        StringBuilder joiner(String description) {
-            return new StringBuilder(description).
-                    append(" {").
-                    append("size=").append(exp.size()).
-                    append("}");
-        }
-    }
-
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/SpliteratorTestHelper.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,769 +0,0 @@
-/*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util;
-
-import java.util.function.*;
-import java.util.stream.LambdaTestHelpers;
-
-import static org.testng.Assert.*;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.fail;
-
-/**
- * Assertion methods for spliterators, to be called from other tests
- */
-public class SpliteratorTestHelper {
-
-    public interface ContentAsserter<T> {
-        void assertContents(Collection<T> actual, Collection<T> expected, boolean isOrdered);
-    }
-
-    private static ContentAsserter<Object> DEFAULT_CONTENT_ASSERTER
-            = SpliteratorTestHelper::assertContents;
-
-    @SuppressWarnings("unchecked")
-    private static <T> ContentAsserter<T> defaultContentAsserter() {
-        return (ContentAsserter<T>) DEFAULT_CONTENT_ASSERTER;
-    }
-
-    public static void testSpliterator(Supplier<Spliterator<Integer>> supplier) {
-        testSpliterator(supplier, defaultContentAsserter());
-    }
-
-    public static void testSpliterator(Supplier<Spliterator<Integer>> supplier,
-                                       ContentAsserter<Integer> asserter) {
-        testSpliterator(supplier, (Consumer<Integer> b) -> b, asserter);
-    }
-
-    public static void testIntSpliterator(Supplier<Spliterator.OfInt> supplier) {
-        testIntSpliterator(supplier, defaultContentAsserter());
-    }
-
-    public static void testIntSpliterator(Supplier<Spliterator.OfInt> supplier,
-                                          ContentAsserter<Integer> asserter) {
-        testSpliterator(supplier, intBoxingConsumer(), asserter);
-    }
-
-    public static void testLongSpliterator(Supplier<Spliterator.OfLong> supplier) {
-        testLongSpliterator(supplier, defaultContentAsserter());
-    }
-
-    public static void testLongSpliterator(Supplier<Spliterator.OfLong> supplier,
-                                           ContentAsserter<Long> asserter) {
-        testSpliterator(supplier, longBoxingConsumer(), asserter);
-    }
-
-    public static void testDoubleSpliterator(Supplier<Spliterator.OfDouble> supplier) {
-        testDoubleSpliterator(supplier, defaultContentAsserter());
-    }
-
-    public static void testDoubleSpliterator(Supplier<Spliterator.OfDouble> supplier,
-                                             ContentAsserter<Double> asserter) {
-        testSpliterator(supplier, doubleBoxingConsumer(), asserter);
-    }
-
-    public static UnaryOperator<Consumer<Integer>> intBoxingConsumer() {
-        class BoxingAdapter implements Consumer<Integer>, IntConsumer {
-            private final Consumer<Integer> b;
-
-            BoxingAdapter(Consumer<Integer> b) {
-                this.b = b;
-            }
-
-            @Override
-            public void accept(Integer value) {
-                throw new IllegalStateException();
-            }
-
-            @Override
-            public void accept(int value) {
-                b.accept(value);
-            }
-        }
-
-        return b -> new BoxingAdapter(b);
-    }
-
-    public static UnaryOperator<Consumer<Long>> longBoxingConsumer() {
-        class BoxingAdapter implements Consumer<Long>, LongConsumer {
-            private final Consumer<Long> b;
-
-            BoxingAdapter(Consumer<Long> b) {
-                this.b = b;
-            }
-
-            @Override
-            public void accept(Long value) {
-                throw new IllegalStateException();
-            }
-
-            @Override
-            public void accept(long value) {
-                b.accept(value);
-            }
-        }
-
-        return b -> new BoxingAdapter(b);
-    }
-
-    public static UnaryOperator<Consumer<Double>> doubleBoxingConsumer() {
-        class BoxingAdapter implements Consumer<Double>, DoubleConsumer {
-            private final Consumer<Double> b;
-
-            BoxingAdapter(Consumer<Double> b) {
-                this.b = b;
-            }
-
-            @Override
-            public void accept(Double value) {
-                throw new IllegalStateException();
-            }
-
-            @Override
-            public void accept(double value) {
-                b.accept(value);
-            }
-        }
-
-        return b -> new BoxingAdapter(b);
-    }
-
-    public static <T, S extends Spliterator<T>> void testSpliterator(Supplier<S> supplier,
-                                                              UnaryOperator<Consumer<T>> boxingAdapter,
-                                                              ContentAsserter<T> asserter) {
-        ArrayList<T> fromForEach = new ArrayList<>();
-        Spliterator<T> spliterator = supplier.get();
-        Consumer<T> addToFromForEach = boxingAdapter.apply(fromForEach::add);
-        spliterator.forEachRemaining(addToFromForEach);
-
-        Collection<T> exp = Collections.unmodifiableList(fromForEach);
-
-        testNullPointerException(supplier);
-        testForEach(exp, supplier, boxingAdapter, asserter);
-        testTryAdvance(exp, supplier, boxingAdapter, asserter);
-        testMixedTryAdvanceForEach(exp, supplier, boxingAdapter, asserter);
-        testMixedTraverseAndSplit(exp, supplier, boxingAdapter, asserter);
-        testSplitAfterFullTraversal(supplier, boxingAdapter);
-        testSplitOnce(exp, supplier, boxingAdapter, asserter);
-        testSplitSixDeep(exp, supplier, boxingAdapter, asserter);
-        testSplitUntilNull(exp, supplier, boxingAdapter, asserter);
-    }
-
-    public static <T, S extends Spliterator<T>> void testForEach(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testForEach(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    public static <T, S extends Spliterator<T>> void testTryAdvance(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testTryAdvance(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    public static <T, S extends Spliterator<T>> void testMixedTryAdvanceForEach(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testMixedTryAdvanceForEach(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    public static <T, S extends Spliterator<T>> void testMixedTraverseAndSplit(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testMixedTraverseAndSplit(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    public static <T, S extends Spliterator<T>> void testSplitOnce(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testSplitOnce(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    public static <T, S extends Spliterator<T>> void testSplitSixDeep(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testSplitSixDeep(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    public static <T, S extends Spliterator<T>> void testSplitUntilNull(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testSplitUntilNull(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    private static <T, S extends Spliterator<T>> void testNullPointerException(Supplier<S> s) {
-        S sp = s.get();
-        // Have to check instances and use casts to avoid tripwire messages and
-        // directly test the primitive methods
-        if (sp instanceof Spliterator.OfInt) {
-            Spliterator.OfInt psp = (Spliterator.OfInt) sp;
-            executeAndCatch(NullPointerException.class, () -> psp.forEachRemaining((IntConsumer) null));
-            executeAndCatch(NullPointerException.class, () -> psp.tryAdvance((IntConsumer) null));
-        }
-        else if (sp instanceof Spliterator.OfLong) {
-            Spliterator.OfLong psp = (Spliterator.OfLong) sp;
-            executeAndCatch(NullPointerException.class, () -> psp.forEachRemaining((LongConsumer) null));
-            executeAndCatch(NullPointerException.class, () -> psp.tryAdvance((LongConsumer) null));
-        }
-        else if (sp instanceof Spliterator.OfDouble) {
-            Spliterator.OfDouble psp = (Spliterator.OfDouble) sp;
-            executeAndCatch(NullPointerException.class, () -> psp.forEachRemaining((DoubleConsumer) null));
-            executeAndCatch(NullPointerException.class, () -> psp.tryAdvance((DoubleConsumer) null));
-        }
-        else {
-            executeAndCatch(NullPointerException.class, () -> sp.forEachRemaining(null));
-            executeAndCatch(NullPointerException.class, () -> sp.tryAdvance(null));
-        }
-    }
-
-    private static <T, S extends Spliterator<T>> void testForEach(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        S spliterator = supplier.get();
-        long sizeIfKnown = spliterator.getExactSizeIfKnown();
-        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
-
-        ArrayList<T> fromForEach = new ArrayList<>();
-        spliterator = supplier.get();
-        Consumer<T> addToFromForEach = boxingAdapter.apply(fromForEach::add);
-        spliterator.forEachRemaining(addToFromForEach);
-
-        // Assert that forEach now produces no elements
-        spliterator.forEachRemaining(boxingAdapter.apply(
-                e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
-        // Assert that tryAdvance now produce no elements
-        spliterator.tryAdvance(boxingAdapter.apply(
-                e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
-
-        // assert that size, tryAdvance, and forEach are consistent
-        if (sizeIfKnown >= 0) {
-            assertEquals(sizeIfKnown, exp.size());
-        }
-        if (exp.contains(null)) {
-            assertTrue(fromForEach.contains(null));
-        }
-        assertEquals(fromForEach.size(), exp.size());
-
-        asserter.assertContents(fromForEach, exp, isOrdered);
-    }
-
-    private static <T, S extends Spliterator<T>> void testTryAdvance(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        S spliterator = supplier.get();
-        long sizeIfKnown = spliterator.getExactSizeIfKnown();
-        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
-
-        spliterator = supplier.get();
-        ArrayList<T> fromTryAdvance = new ArrayList<>();
-        Consumer<T> addToFromTryAdvance = boxingAdapter.apply(fromTryAdvance::add);
-        while (spliterator.tryAdvance(addToFromTryAdvance)) { }
-
-        // Assert that forEach now produces no elements
-        spliterator.forEachRemaining(boxingAdapter.apply(
-                e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
-        // Assert that tryAdvance now produce no elements
-        spliterator.tryAdvance(boxingAdapter.apply(
-                e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
-
-        // assert that size, tryAdvance, and forEach are consistent
-        if (sizeIfKnown >= 0) {
-            assertEquals(sizeIfKnown, exp.size());
-        }
-        assertEquals(fromTryAdvance.size(), exp.size());
-
-        asserter.assertContents(fromTryAdvance, exp, isOrdered);
-    }
-
-    private static <T, S extends Spliterator<T>> void testMixedTryAdvanceForEach(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        S spliterator = supplier.get();
-        long sizeIfKnown = spliterator.getExactSizeIfKnown();
-        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
-
-        // tryAdvance first few elements, then forEach rest
-        ArrayList<T> dest = new ArrayList<>();
-        spliterator = supplier.get();
-        Consumer<T> addToDest = boxingAdapter.apply(dest::add);
-        for (int i = 0; i < 10 && spliterator.tryAdvance(addToDest); i++) { }
-        spliterator.forEachRemaining(addToDest);
-
-        // Assert that forEach now produces no elements
-        spliterator.forEachRemaining(boxingAdapter.apply(
-                e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
-        // Assert that tryAdvance now produce no elements
-        spliterator.tryAdvance(boxingAdapter.apply(
-                e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
-
-        if (sizeIfKnown >= 0) {
-            assertEquals(sizeIfKnown, dest.size());
-        }
-        assertEquals(dest.size(), exp.size());
-
-        asserter.assertContents(dest, exp, isOrdered);
-    }
-
-    private static <T, S extends Spliterator<T>> void testMixedTraverseAndSplit(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        S spliterator = supplier.get();
-        long sizeIfKnown = spliterator.getExactSizeIfKnown();
-        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
-
-        // tryAdvance first few elements, then forEach rest
-        ArrayList<T> dest = new ArrayList<>();
-        spliterator = supplier.get();
-        Consumer<T> b = boxingAdapter.apply(dest::add);
-
-        Spliterator<T> spl1, spl2, spl3;
-        spliterator.tryAdvance(b);
-        spl2 = spliterator.trySplit();
-        if (spl2 != null) {
-            spl2.tryAdvance(b);
-            spl1 = spl2.trySplit();
-            if (spl1 != null) {
-                spl1.tryAdvance(b);
-                spl1.forEachRemaining(b);
-            }
-            spl2.tryAdvance(b);
-            spl2.forEachRemaining(b);
-        }
-        spliterator.tryAdvance(b);
-        spl3 = spliterator.trySplit();
-        if (spl3 != null) {
-            spl3.tryAdvance(b);
-            spl3.forEachRemaining(b);
-        }
-        spliterator.tryAdvance(b);
-        spliterator.forEachRemaining(b);
-
-        if (sizeIfKnown >= 0) {
-            assertEquals(sizeIfKnown, dest.size());
-        }
-        assertEquals(dest.size(), exp.size());
-
-        asserter.assertContents(dest, exp, isOrdered);
-    }
-
-    public static <T, S extends Spliterator<T>> void testSplitAfterFullTraversal(
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        // Full traversal using tryAdvance
-        Spliterator<T> spliterator = supplier.get();
-        while (spliterator.tryAdvance(boxingAdapter.apply(e -> { }))) { }
-        Spliterator<T> split = spliterator.trySplit();
-        assertNull(split);
-
-        // Full traversal using forEach
-        spliterator = supplier.get();
-        spliterator.forEachRemaining(boxingAdapter.apply(e -> { }));
-        split = spliterator.trySplit();
-        assertNull(split);
-
-        // Full traversal using tryAdvance then forEach
-        spliterator = supplier.get();
-        spliterator.tryAdvance(boxingAdapter.apply(e -> { }));
-        spliterator.forEachRemaining(boxingAdapter.apply(e -> { }));
-        split = spliterator.trySplit();
-        assertNull(split);
-    }
-
-    private static <T, S extends Spliterator<T>> void testSplitOnce(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        S spliterator = supplier.get();
-        long sizeIfKnown = spliterator.getExactSizeIfKnown();
-        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
-
-        ArrayList<T> fromSplit = new ArrayList<>();
-        Spliterator<T> s1 = supplier.get();
-        Spliterator<T> s2 = s1.trySplit();
-        long s1Size = s1.getExactSizeIfKnown();
-        long s2Size = (s2 != null) ? s2.getExactSizeIfKnown() : 0;
-        Consumer<T> addToFromSplit = boxingAdapter.apply(fromSplit::add);
-        if (s2 != null)
-            s2.forEachRemaining(addToFromSplit);
-        s1.forEachRemaining(addToFromSplit);
-
-        if (sizeIfKnown >= 0) {
-            assertEquals(sizeIfKnown, fromSplit.size());
-            if (s1Size >= 0 && s2Size >= 0)
-                assertEquals(sizeIfKnown, s1Size + s2Size);
-        }
-
-        asserter.assertContents(fromSplit, exp, isOrdered);
-    }
-
-    private static <T, S extends Spliterator<T>> void testSplitSixDeep(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        S spliterator = supplier.get();
-        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
-
-        for (int depth=0; depth < 6; depth++) {
-            List<T> dest = new ArrayList<>();
-            spliterator = supplier.get();
-
-            assertSpliterator(spliterator);
-
-            // verify splitting with forEach
-            splitSixDeepVisitor(depth, 0, dest, spliterator, boxingAdapter, spliterator.characteristics(), false);
-            asserter.assertContents(dest, exp, isOrdered);
-
-            // verify splitting with tryAdvance
-            dest.clear();
-            spliterator = supplier.get();
-            splitSixDeepVisitor(depth, 0, dest, spliterator, boxingAdapter, spliterator.characteristics(), true);
-            asserter.assertContents(dest, exp, isOrdered);
-        }
-    }
-
-    private static <T, S extends Spliterator<T>>
-    void splitSixDeepVisitor(int depth, int curLevel,
-                             List<T> dest, S spliterator, UnaryOperator<Consumer<T>> boxingAdapter,
-                             int rootCharacteristics, boolean useTryAdvance) {
-        if (curLevel < depth) {
-            long beforeSize = spliterator.getExactSizeIfKnown();
-            Spliterator<T> split = spliterator.trySplit();
-            if (split != null) {
-                assertSpliterator(split, rootCharacteristics);
-                assertSpliterator(spliterator, rootCharacteristics);
-
-                if ((rootCharacteristics & Spliterator.SUBSIZED) != 0 &&
-                    (rootCharacteristics & Spliterator.SIZED) != 0) {
-                    assertEquals(beforeSize, split.estimateSize() + spliterator.estimateSize());
-                }
-                splitSixDeepVisitor(depth, curLevel + 1, dest, split, boxingAdapter, rootCharacteristics, useTryAdvance);
-            }
-            splitSixDeepVisitor(depth, curLevel + 1, dest, spliterator, boxingAdapter, rootCharacteristics, useTryAdvance);
-        }
-        else {
-            long sizeIfKnown = spliterator.getExactSizeIfKnown();
-            if (useTryAdvance) {
-                Consumer<T> addToDest = boxingAdapter.apply(dest::add);
-                int count = 0;
-                while (spliterator.tryAdvance(addToDest)) {
-                    ++count;
-                }
-
-                if (sizeIfKnown >= 0)
-                    assertEquals(sizeIfKnown, count);
-
-                // Assert that forEach now produces no elements
-                spliterator.forEachRemaining(boxingAdapter.apply(
-                        e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
-
-                Spliterator<T> split = spliterator.trySplit();
-                assertNull(split);
-            }
-            else {
-                List<T> leafDest = new ArrayList<>();
-                Consumer<T> addToLeafDest = boxingAdapter.apply(leafDest::add);
-                spliterator.forEachRemaining(addToLeafDest);
-
-                if (sizeIfKnown >= 0)
-                    assertEquals(sizeIfKnown, leafDest.size());
-
-                // Assert that forEach now produces no elements
-                spliterator.tryAdvance(boxingAdapter.apply(
-                        e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
-
-                Spliterator<T> split = spliterator.trySplit();
-                assertNull(split);
-
-                dest.addAll(leafDest);
-            }
-        }
-    }
-
-    private static <T, S extends Spliterator<T>> void testSplitUntilNull(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        Spliterator<T> s = supplier.get();
-        boolean isOrdered = s.hasCharacteristics(Spliterator.ORDERED);
-        assertSpliterator(s);
-
-        List<T> splits = new ArrayList<>();
-        Consumer<T> c = boxingAdapter.apply(splits::add);
-
-        testSplitUntilNull(new SplitNode<T>(c, s));
-        asserter.assertContents(splits, exp, isOrdered);
-    }
-
-    private static class SplitNode<T> {
-        // Constant for every node
-        final Consumer<T> c;
-        final int rootCharacteristics;
-
-        final Spliterator<T> s;
-
-        SplitNode(Consumer<T> c, Spliterator<T> s) {
-            this(c, s.characteristics(), s);
-        }
-
-        private SplitNode(Consumer<T> c, int rootCharacteristics, Spliterator<T> s) {
-            this.c = c;
-            this.rootCharacteristics = rootCharacteristics;
-            this.s = s;
-        }
-
-        SplitNode<T> fromSplit(Spliterator<T> split) {
-            return new SplitNode<>(c, rootCharacteristics, split);
-        }
-    }
-
-    /**
-     * Set the maximum stack capacity to 0.25MB. This should be more than enough to detect a bad spliterator
-     * while not unduly disrupting test infrastructure given the test data sizes that are used are small.
-     * Note that j.u.c.ForkJoinPool sets the max queue size to 64M (1 << 26).
-     */
-    private static final int MAXIMUM_STACK_CAPACITY = 1 << 18; // 0.25MB
-
-    private static <T> void testSplitUntilNull(SplitNode<T> e) {
-        // Use an explicit stack to avoid a StackOverflowException when testing a Spliterator
-        // that when repeatedly split produces a right-balanced (and maybe degenerate) tree, or
-        // for a spliterator that is badly behaved.
-        Deque<SplitNode<T>> stack = new ArrayDeque<>();
-        stack.push(e);
-
-        int iteration = 0;
-        while (!stack.isEmpty()) {
-            assertTrue(iteration++ < MAXIMUM_STACK_CAPACITY, "Exceeded maximum stack modification count of 1 << 18");
-
-            e = stack.pop();
-            Spliterator<T> parentAndRightSplit = e.s;
-
-            long parentEstimateSize = parentAndRightSplit.estimateSize();
-            assertTrue(parentEstimateSize >= 0,
-                       String.format("Split size estimate %d < 0", parentEstimateSize));
-
-            long parentSize = parentAndRightSplit.getExactSizeIfKnown();
-            Spliterator<T> leftSplit = parentAndRightSplit.trySplit();
-            if (leftSplit == null) {
-                parentAndRightSplit.forEachRemaining(e.c);
-                continue;
-            }
-
-            assertSpliterator(leftSplit, e.rootCharacteristics);
-            assertSpliterator(parentAndRightSplit, e.rootCharacteristics);
-
-            if (parentEstimateSize != Long.MAX_VALUE && leftSplit.estimateSize() > 0
-                && parentAndRightSplit.estimateSize() > 0) {
-                assertTrue(leftSplit.estimateSize() < parentEstimateSize,
-                           String.format("Left split size estimate %d >= parent split size estimate %d",
-                                         leftSplit.estimateSize(), parentEstimateSize));
-                assertTrue(parentAndRightSplit.estimateSize() < parentEstimateSize,
-                           String.format("Right split size estimate %d >= parent split size estimate %d",
-                                         leftSplit.estimateSize(), parentEstimateSize));
-            }
-            else {
-                assertTrue(leftSplit.estimateSize() <= parentEstimateSize,
-                           String.format("Left split size estimate %d > parent split size estimate %d",
-                                         leftSplit.estimateSize(), parentEstimateSize));
-                assertTrue(parentAndRightSplit.estimateSize() <= parentEstimateSize,
-                           String.format("Right split size estimate %d > parent split size estimate %d",
-                                         leftSplit.estimateSize(), parentEstimateSize));
-            }
-
-            long leftSize = leftSplit.getExactSizeIfKnown();
-            long rightSize = parentAndRightSplit.getExactSizeIfKnown();
-            if (parentSize >= 0 && leftSize >= 0 && rightSize >= 0)
-                assertEquals(parentSize, leftSize + rightSize,
-                             String.format("exact left split size %d + exact right split size %d != parent exact split size %d",
-                                           leftSize, rightSize, parentSize));
-
-            // Add right side to stack first so left side is popped off first
-            stack.push(e.fromSplit(parentAndRightSplit));
-            stack.push(e.fromSplit(leftSplit));
-        }
-    }
-
-    private static void assertSpliterator(Spliterator<?> s, int rootCharacteristics) {
-        if ((rootCharacteristics & Spliterator.SUBSIZED) != 0) {
-            assertTrue(s.hasCharacteristics(Spliterator.SUBSIZED),
-                       "Child split is not SUBSIZED when root split is SUBSIZED");
-        }
-        assertSpliterator(s);
-    }
-
-    private static void assertSpliterator(Spliterator<?> s) {
-        if (s.hasCharacteristics(Spliterator.SUBSIZED)) {
-            assertTrue(s.hasCharacteristics(Spliterator.SIZED));
-        }
-        if (s.hasCharacteristics(Spliterator.SIZED)) {
-            assertTrue(s.estimateSize() != Long.MAX_VALUE);
-            assertTrue(s.getExactSizeIfKnown() >= 0);
-        }
-        try {
-            s.getComparator();
-            assertTrue(s.hasCharacteristics(Spliterator.SORTED));
-        } catch (IllegalStateException e) {
-            assertFalse(s.hasCharacteristics(Spliterator.SORTED));
-        }
-    }
-
-    private static<T> void assertContents(Collection<T> actual, Collection<T> expected, boolean isOrdered) {
-        if (isOrdered) {
-            assertEquals(actual, expected);
-        }
-        else {
-            LambdaTestHelpers.assertContentsUnordered(actual, expected);
-        }
-    }
-
-    public static void executeAndCatch(Class<? extends Exception> expected, Runnable r) {
-        Exception caught = null;
-        try {
-            r.run();
-        }
-        catch (Exception e) {
-            caught = e;
-        }
-
-        assertNotNull(caught,
-                      String.format("No Exception was thrown, expected an Exception of %s to be thrown",
-                                    expected.getName()));
-        assertTrue(expected.isInstance(caught),
-                   String.format("Exception thrown %s not an instance of %s",
-                                 caught.getClass().getName(), expected.getName()));
-    }
-
-    public static<U> void mixedTraverseAndSplit(Consumer<U> b, Spliterator<U> splTop) {
-        Spliterator<U> spl1, spl2, spl3;
-        splTop.tryAdvance(b);
-        spl2 = splTop.trySplit();
-        if (spl2 != null) {
-            spl2.tryAdvance(b);
-            spl1 = spl2.trySplit();
-            if (spl1 != null) {
-                spl1.tryAdvance(b);
-                spl1.forEachRemaining(b);
-            }
-            spl2.tryAdvance(b);
-            spl2.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        spl3 = splTop.trySplit();
-        if (spl3 != null) {
-            spl3.tryAdvance(b);
-            spl3.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        splTop.forEachRemaining(b);
-    }
-
-    public static void mixedTraverseAndSplit(IntConsumer b, Spliterator.OfInt splTop) {
-        Spliterator.OfInt spl1, spl2, spl3;
-        splTop.tryAdvance(b);
-        spl2 = splTop.trySplit();
-        if (spl2 != null) {
-            spl2.tryAdvance(b);
-            spl1 = spl2.trySplit();
-            if (spl1 != null) {
-                spl1.tryAdvance(b);
-                spl1.forEachRemaining(b);
-            }
-            spl2.tryAdvance(b);
-            spl2.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        spl3 = splTop.trySplit();
-        if (spl3 != null) {
-            spl3.tryAdvance(b);
-            spl3.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        splTop.forEachRemaining(b);
-    }
-
-    public static void mixedTraverseAndSplit(LongConsumer b, Spliterator.OfLong splTop) {
-        Spliterator.OfLong spl1, spl2, spl3;
-        splTop.tryAdvance(b);
-        spl2 = splTop.trySplit();
-        if (spl2 != null) {
-            spl2.tryAdvance(b);
-            spl1 = spl2.trySplit();
-            if (spl1 != null) {
-                spl1.tryAdvance(b);
-                spl1.forEachRemaining(b);
-            }
-            spl2.tryAdvance(b);
-            spl2.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        spl3 = splTop.trySplit();
-        if (spl3 != null) {
-            spl3.tryAdvance(b);
-            spl3.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        splTop.forEachRemaining(b);
-    }
-
-    public static void mixedTraverseAndSplit(DoubleConsumer b, Spliterator.OfDouble splTop) {
-        Spliterator.OfDouble spl1, spl2, spl3;
-        splTop.tryAdvance(b);
-        spl2 = splTop.trySplit();
-        if (spl2 != null) {
-            spl2.tryAdvance(b);
-            spl1 = spl2.trySplit();
-            if (spl1 != null) {
-                spl1.tryAdvance(b);
-                spl1.forEachRemaining(b);
-            }
-            spl2.tryAdvance(b);
-            spl2.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        spl3 = splTop.trySplit();
-        if (spl3 != null) {
-            spl3.tryAdvance(b);
-            spl3.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        splTop.forEachRemaining(b);
-    }
-
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/CollectorOps.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2012, 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.
- */
-package java.util.stream;
-
-import org.testng.Assert;
-
-import java.util.Spliterator;
-import java.util.function.IntFunction;
-
-/** Test helper class for java.util.stream test framework */
-public final class CollectorOps {
-    private CollectorOps() { }
-
-    public static <E_IN> StatefulTestOp<E_IN> collector() {
-        return new StatefulCollector<>(0, StreamShape.REFERENCE);
-    }
-
-    /* Utility classes for collecting output of intermediate pipeline stages */
-    public static class StatefulCollector<E_IN> implements StatefulTestOp<E_IN> {
-        private final int opFlags;
-        private final StreamShape inputShape;
-
-        public StatefulCollector(int opFlags, StreamShape inputShape) {
-            this.opFlags = opFlags;
-            this.inputShape = inputShape;
-        }
-
-        @Override
-        public StreamShape inputShape() {
-            return inputShape;
-        }
-
-        @Override
-        public StreamShape outputShape() {
-            return inputShape;
-        }
-
-        @Override
-        public int opGetFlags() {
-            return opFlags;
-        }
-
-        @Override
-        public Sink<E_IN> opWrapSink(int flags, boolean parallel, Sink<E_IN> sink) {
-            return sink;
-        }
-
-        @Override
-        public <P_IN> Node<E_IN> opEvaluateParallel(PipelineHelper<E_IN> helper,
-                                                    Spliterator<P_IN> spliterator,
-                                                    IntFunction<E_IN[]> generator) {
-            return helper.evaluate(spliterator, false, generator);
-        }
-    }
-
-    public static class TestParallelSizedOp<T> extends StatefulCollector<T> {
-        public TestParallelSizedOp() {
-            this(StreamShape.REFERENCE);
-        }
-
-        protected TestParallelSizedOp(StreamShape shape) {
-            super(0, shape);
-        }
-
-        @Override
-        public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
-                                                 Spliterator<P_IN> spliterator,
-                                                 IntFunction<T[]> generator) {
-            int flags = helper.getStreamAndOpFlags();
-
-            Assert.assertTrue(StreamOpFlag.SIZED.isKnown(flags));
-            return super.opEvaluateParallel(helper, spliterator, generator);
-        }
-
-        public static class OfInt extends TestParallelSizedOp<Integer> {
-            public OfInt() {
-                super(StreamShape.INT_VALUE);
-            }
-        }
-
-        public static class OfLong extends TestParallelSizedOp<Long> {
-            public OfLong() {
-                super(StreamShape.LONG_VALUE);
-            }
-        }
-
-        public static class OfDouble extends TestParallelSizedOp<Double> {
-            public OfDouble() {
-                super(StreamShape.DOUBLE_VALUE);
-            }
-        }
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DefaultMethodStreams.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,984 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Comparator;
-import java.util.DoubleSummaryStatistics;
-import java.util.IntSummaryStatistics;
-import java.util.Iterator;
-import java.util.LongSummaryStatistics;
-import java.util.Optional;
-import java.util.OptionalDouble;
-import java.util.OptionalInt;
-import java.util.OptionalLong;
-import java.util.PrimitiveIterator;
-import java.util.Set;
-import java.util.Spliterator;
-import java.util.function.BiConsumer;
-import java.util.function.BiFunction;
-import java.util.function.BinaryOperator;
-import java.util.function.Consumer;
-import java.util.function.DoubleBinaryOperator;
-import java.util.function.DoubleConsumer;
-import java.util.function.DoubleFunction;
-import java.util.function.DoublePredicate;
-import java.util.function.DoubleToIntFunction;
-import java.util.function.DoubleToLongFunction;
-import java.util.function.DoubleUnaryOperator;
-import java.util.function.Function;
-import java.util.function.IntBinaryOperator;
-import java.util.function.IntConsumer;
-import java.util.function.IntFunction;
-import java.util.function.IntPredicate;
-import java.util.function.IntToDoubleFunction;
-import java.util.function.IntToLongFunction;
-import java.util.function.IntUnaryOperator;
-import java.util.function.LongBinaryOperator;
-import java.util.function.LongConsumer;
-import java.util.function.LongFunction;
-import java.util.function.LongPredicate;
-import java.util.function.LongToDoubleFunction;
-import java.util.function.LongToIntFunction;
-import java.util.function.LongUnaryOperator;
-import java.util.function.ObjDoubleConsumer;
-import java.util.function.ObjIntConsumer;
-import java.util.function.ObjLongConsumer;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-import java.util.function.ToDoubleFunction;
-
-import java.util.function.ToIntFunction;
-import java.util.function.ToLongFunction;
-
-import static java.util.stream.Collectors.*;
-
-public final class DefaultMethodStreams {
-
-    static {
-        // Verify that default methods are not overridden
-        verify(DefaultMethodRefStream.class);
-        verify(DefaultMethodIntStream.class);
-        verify(DefaultMethodLongStream.class);
-        verify(DefaultMethodDoubleStream.class);
-    }
-
-    static void verify(Class<?> del) {
-        // Find the stream interface
-        Class<?> s = Stream.of(del.getInterfaces())
-                .filter(c -> BaseStream.class.isAssignableFrom(c))
-                .findFirst().get();
-
-        // Get all default methods on the stream class
-        Set<String> dms = Stream.of(s.getMethods())
-                .filter(m -> !Modifier.isStatic(m.getModifiers()))
-                .filter(m -> !m.isBridge())
-                .filter(Method::isDefault)
-                .map(Method::getName)
-                .collect(toSet());
-
-        // Get all methods on the delegating class
-        Set<String> ims = Stream.of(del.getMethods())
-                .filter(m -> !Modifier.isStatic(m.getModifiers()))
-                .filter(m -> m.getDeclaringClass() == del)
-                .map(Method::getName)
-                .collect(toSet());
-
-        if (ims.stream().anyMatch(dms::contains)) {
-            throw new AssertionError(String.format("%s overrides default methods of %s\n", del, s));
-        }
-    }
-
-    /**
-     * Creates a stream that for the next operation either delegates to
-     * a default method on {@link Stream}, if present for that operation,
-     * otherwise delegates to an underlying stream.
-     *
-     * @param s the underlying stream to be delegated to for non-default
-     * methods.
-     * @param <T> the type of the stream elements
-     * @return the delegating stream
-     */
-    public static <T> Stream<T> delegateTo(Stream<T> s) {
-        return new DefaultMethodRefStream<>(s);
-    }
-
-    /**
-     * Creates a stream that for the next operation either delegates to
-     * a default method on {@link IntStream}, if present for that operation,
-     * otherwise delegates to an underlying stream.
-     *
-     * @param s the underlying stream to be delegated to for non-default
-     * methods.
-     * @return the delegating stream
-     */
-    public static IntStream delegateTo(IntStream s) {
-        return new DefaultMethodIntStream(s);
-    }
-
-    /**
-     * Creates a stream that for the next operation either delegates to
-     * a default method on {@link LongStream}, if present for that operation,
-     * otherwise delegates to an underlying stream.
-     *
-     * @param s the underlying stream to be delegated to for non-default
-     * methods.
-     * @return the delegating stream
-     */
-    public static LongStream delegateTo(LongStream s) {
-        return new DefaultMethodLongStream(s);
-    }
-
-    /**
-     * Creates a stream that for the next operation either delegates to
-     * a default method on {@link DoubleStream}, if present for that operation,
-     * otherwise delegates to an underlying stream.
-     *
-     * @param s the underlying stream to be delegated to for non-default
-     * methods.
-     * @return the delegating stream
-     */
-    public static DoubleStream delegateTo(DoubleStream s) {
-        return new DefaultMethodDoubleStream(s);
-    }
-
-    /**
-     * A stream that delegates the next operation to a default method, if
-     * present, or to the same operation of an underlying stream.
-     *
-     * @param <T> the type of the stream elements
-     */
-    static final class DefaultMethodRefStream<T> implements Stream<T> {
-        final Stream<T> s;
-
-        DefaultMethodRefStream(Stream<T> s) {
-            this.s = s;
-        }
-
-
-        // Delegating non-default methods
-
-        @Override
-        public Stream<T> filter(Predicate<? super T> predicate) {
-            return s.filter(predicate);
-        }
-
-        @Override
-        public <R> Stream<R> map(Function<? super T, ? extends R> mapper) {
-            return s.map(mapper);
-        }
-
-        @Override
-        public IntStream mapToInt(ToIntFunction<? super T> mapper) {
-            return s.mapToInt(mapper);
-        }
-
-        @Override
-        public LongStream mapToLong(ToLongFunction<? super T> mapper) {
-            return s.mapToLong(mapper);
-        }
-
-        @Override
-        public DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper) {
-            return s.mapToDouble(mapper);
-        }
-
-        @Override
-        public <R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper) {
-            return s.flatMap(mapper);
-        }
-
-        @Override
-        public IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper) {
-            return s.flatMapToInt(mapper);
-        }
-
-        @Override
-        public LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper) {
-            return s.flatMapToLong(mapper);
-        }
-
-        @Override
-        public DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper) {
-            return s.flatMapToDouble(mapper);
-        }
-
-        @Override
-        public Stream<T> distinct() {
-            return s.distinct();
-        }
-
-        @Override
-        public Stream<T> sorted() {
-            return s.sorted();
-        }
-
-        @Override
-        public Stream<T> sorted(Comparator<? super T> comparator) {
-            return s.sorted(comparator);
-        }
-
-        @Override
-        public Stream<T> peek(Consumer<? super T> action) {
-            return s.peek(action);
-        }
-
-        @Override
-        public Stream<T> limit(long maxSize) {
-            return s.limit(maxSize);
-        }
-
-        @Override
-        public Stream<T> skip(long n) {
-            return s.skip(n);
-        }
-
-        @Override
-        public void forEach(Consumer<? super T> action) {
-            s.forEach(action);
-        }
-
-        @Override
-        public void forEachOrdered(Consumer<? super T> action) {
-            s.forEachOrdered(action);
-        }
-
-        @Override
-        public Object[] toArray() {
-            return s.toArray();
-        }
-
-        @Override
-        public <A> A[] toArray(IntFunction<A[]> generator) {
-            return s.toArray(generator);
-        }
-
-        @Override
-        public T reduce(T identity, BinaryOperator<T> accumulator) {
-            return s.reduce(identity, accumulator);
-        }
-
-        @Override
-        public Optional<T> reduce(BinaryOperator<T> accumulator) {
-            return s.reduce(accumulator);
-        }
-
-        @Override
-        public <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) {
-            return s.reduce(identity, accumulator, combiner);
-        }
-
-        @Override
-        public <R> R collect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner) {
-            return s.collect(supplier, accumulator, combiner);
-        }
-
-        @Override
-        public <R, A> R collect(Collector<? super T, A, R> collector) {
-            return s.collect(collector);
-        }
-
-        @Override
-        public Optional<T> min(Comparator<? super T> comparator) {
-            return s.min(comparator);
-        }
-
-        @Override
-        public Optional<T> max(Comparator<? super T> comparator) {
-            return s.max(comparator);
-        }
-
-        @Override
-        public long count() {
-            return s.count();
-        }
-
-        @Override
-        public boolean anyMatch(Predicate<? super T> predicate) {
-            return s.anyMatch(predicate);
-        }
-
-        @Override
-        public boolean allMatch(Predicate<? super T> predicate) {
-            return s.allMatch(predicate);
-        }
-
-        @Override
-        public boolean noneMatch(Predicate<? super T> predicate) {
-            return s.noneMatch(predicate);
-        }
-
-        @Override
-        public Optional<T> findFirst() {
-            return s.findFirst();
-        }
-
-        @Override
-        public Optional<T> findAny() {
-            return s.findAny();
-        }
-
-        @Override
-        public Iterator<T> iterator() {
-            return s.iterator();
-        }
-
-        @Override
-        public Spliterator<T> spliterator() {
-            return s.spliterator();
-        }
-
-        @Override
-        public boolean isParallel() {
-            return s.isParallel();
-        }
-
-        @Override
-        public Stream<T> sequential() {
-            return s.sequential();
-        }
-
-        @Override
-        public Stream<T> parallel() {
-            return s.parallel();
-        }
-
-        @Override
-        public Stream<T> unordered() {
-            return s.unordered();
-        }
-
-        @Override
-        public Stream<T> onClose(Runnable closeHandler) {
-            return s.onClose(closeHandler);
-        }
-
-        @Override
-        public void close() {
-            s.close();
-        }
-    }
-
-    static final class DefaultMethodIntStream implements IntStream {
-        final IntStream s;
-
-        public DefaultMethodIntStream(IntStream s) {
-            this.s = s;
-        }
-
-
-        // Delegating non-default methods
-
-        @Override
-        public IntStream filter(IntPredicate predicate) {
-            return s.filter(predicate);
-        }
-
-        @Override
-        public IntStream map(IntUnaryOperator mapper) {
-            return s.map(mapper);
-        }
-
-        @Override
-        public <U> Stream<U> mapToObj(IntFunction<? extends U> mapper) {
-            return s.mapToObj(mapper);
-        }
-
-        @Override
-        public LongStream mapToLong(IntToLongFunction mapper) {
-            return s.mapToLong(mapper);
-        }
-
-        @Override
-        public DoubleStream mapToDouble(IntToDoubleFunction mapper) {
-            return s.mapToDouble(mapper);
-        }
-
-        @Override
-        public IntStream flatMap(IntFunction<? extends IntStream> mapper) {
-            return s.flatMap(mapper);
-        }
-
-        @Override
-        public IntStream distinct() {
-            return s.distinct();
-        }
-
-        @Override
-        public IntStream sorted() {
-            return s.sorted();
-        }
-
-        @Override
-        public IntStream peek(IntConsumer action) {
-            return s.peek(action);
-        }
-
-        @Override
-        public IntStream limit(long maxSize) {
-            return s.limit(maxSize);
-        }
-
-        @Override
-        public IntStream skip(long n) {
-            return s.skip(n);
-        }
-
-        @Override
-        public void forEach(IntConsumer action) {
-            s.forEach(action);
-        }
-
-        @Override
-        public void forEachOrdered(IntConsumer action) {
-            s.forEachOrdered(action);
-        }
-
-        @Override
-        public int[] toArray() {
-            return s.toArray();
-        }
-
-        @Override
-        public int reduce(int identity, IntBinaryOperator op) {
-            return s.reduce(identity, op);
-        }
-
-        @Override
-        public OptionalInt reduce(IntBinaryOperator op) {
-            return s.reduce(op);
-        }
-
-        @Override
-        public <R> R collect(Supplier<R> supplier, ObjIntConsumer<R> accumulator, BiConsumer<R, R> combiner) {
-            return s.collect(supplier, accumulator, combiner);
-        }
-
-        @Override
-        public int sum() {
-            return s.sum();
-        }
-
-        @Override
-        public OptionalInt min() {
-            return s.min();
-        }
-
-        @Override
-        public OptionalInt max() {
-            return s.max();
-        }
-
-        @Override
-        public long count() {
-            return s.count();
-        }
-
-        @Override
-        public OptionalDouble average() {
-            return s.average();
-        }
-
-        @Override
-        public IntSummaryStatistics summaryStatistics() {
-            return s.summaryStatistics();
-        }
-
-        @Override
-        public boolean anyMatch(IntPredicate predicate) {
-            return s.anyMatch(predicate);
-        }
-
-        @Override
-        public boolean allMatch(IntPredicate predicate) {
-            return s.allMatch(predicate);
-        }
-
-        @Override
-        public boolean noneMatch(IntPredicate predicate) {
-            return s.noneMatch(predicate);
-        }
-
-        @Override
-        public OptionalInt findFirst() {
-            return s.findFirst();
-        }
-
-        @Override
-        public OptionalInt findAny() {
-            return s.findAny();
-        }
-
-        @Override
-        public LongStream asLongStream() {
-            return s.asLongStream();
-        }
-
-        @Override
-        public DoubleStream asDoubleStream() {
-            return s.asDoubleStream();
-        }
-
-        @Override
-        public Stream<Integer> boxed() {
-            return s.boxed();
-        }
-
-        @Override
-        public IntStream sequential() {
-            return s.sequential();
-        }
-
-        @Override
-        public IntStream parallel() {
-            return s.parallel();
-        }
-
-        @Override
-        public PrimitiveIterator.OfInt iterator() {
-            return s.iterator();
-        }
-
-        @Override
-        public Spliterator.OfInt spliterator() {
-            return s.spliterator();
-        }
-
-        @Override
-        public boolean isParallel() {
-            return s.isParallel();
-        }
-
-        @Override
-        public IntStream unordered() {
-            return s.unordered();
-        }
-
-        @Override
-        public IntStream onClose(Runnable closeHandler) {
-            return s.onClose(closeHandler);
-        }
-
-        @Override
-        public void close() {
-            s.close();
-        }
-    }
-
-    static final class DefaultMethodLongStream implements LongStream {
-        final LongStream s;
-
-        public DefaultMethodLongStream(LongStream s) {
-            this.s = s;
-        }
-
-
-        // Delegating non-default methods
-
-        @Override
-        public void forEach(LongConsumer action) {
-            s.forEach(action);
-        }
-
-        @Override
-        public LongStream filter(LongPredicate predicate) {
-            return s.filter(predicate);
-        }
-
-        @Override
-        public LongStream map(LongUnaryOperator mapper) {
-            return s.map(mapper);
-        }
-
-        @Override
-        public <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
-            return s.mapToObj(mapper);
-        }
-
-        @Override
-        public IntStream mapToInt(LongToIntFunction mapper) {
-            return s.mapToInt(mapper);
-        }
-
-        @Override
-        public DoubleStream mapToDouble(LongToDoubleFunction mapper) {
-            return s.mapToDouble(mapper);
-        }
-
-        @Override
-        public LongStream flatMap(LongFunction<? extends LongStream> mapper) {
-            return s.flatMap(mapper);
-        }
-
-        @Override
-        public LongStream distinct() {
-            return s.distinct();
-        }
-
-        @Override
-        public LongStream sorted() {
-            return s.sorted();
-        }
-
-        @Override
-        public LongStream peek(LongConsumer action) {
-            return s.peek(action);
-        }
-
-        @Override
-        public LongStream limit(long maxSize) {
-            return s.limit(maxSize);
-        }
-
-        @Override
-        public LongStream skip(long n) {
-            return s.skip(n);
-        }
-
-        @Override
-        public void forEachOrdered(LongConsumer action) {
-            s.forEachOrdered(action);
-        }
-
-        @Override
-        public long[] toArray() {
-            return s.toArray();
-        }
-
-        @Override
-        public long reduce(long identity, LongBinaryOperator op) {
-            return s.reduce(identity, op);
-        }
-
-        @Override
-        public OptionalLong reduce(LongBinaryOperator op) {
-            return s.reduce(op);
-        }
-
-        @Override
-        public <R> R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R, R> combiner) {
-            return s.collect(supplier, accumulator, combiner);
-        }
-
-        @Override
-        public long sum() {
-            return s.sum();
-        }
-
-        @Override
-        public OptionalLong min() {
-            return s.min();
-        }
-
-        @Override
-        public OptionalLong max() {
-            return s.max();
-        }
-
-        @Override
-        public long count() {
-            return s.count();
-        }
-
-        @Override
-        public OptionalDouble average() {
-            return s.average();
-        }
-
-        @Override
-        public LongSummaryStatistics summaryStatistics() {
-            return s.summaryStatistics();
-        }
-
-        @Override
-        public boolean anyMatch(LongPredicate predicate) {
-            return s.anyMatch(predicate);
-        }
-
-        @Override
-        public boolean allMatch(LongPredicate predicate) {
-            return s.allMatch(predicate);
-        }
-
-        @Override
-        public boolean noneMatch(LongPredicate predicate) {
-            return s.noneMatch(predicate);
-        }
-
-        @Override
-        public OptionalLong findFirst() {
-            return s.findFirst();
-        }
-
-        @Override
-        public OptionalLong findAny() {
-            return s.findAny();
-        }
-
-        @Override
-        public DoubleStream asDoubleStream() {
-            return s.asDoubleStream();
-        }
-
-        @Override
-        public Stream<Long> boxed() {
-            return s.boxed();
-        }
-
-        @Override
-        public LongStream sequential() {
-            return s.sequential();
-        }
-
-        @Override
-        public LongStream parallel() {
-            return s.parallel();
-        }
-
-        @Override
-        public PrimitiveIterator.OfLong iterator() {
-            return s.iterator();
-        }
-
-        @Override
-        public Spliterator.OfLong spliterator() {
-            return s.spliterator();
-        }
-
-        @Override
-        public boolean isParallel() {
-            return s.isParallel();
-        }
-
-        @Override
-        public LongStream unordered() {
-            return s.unordered();
-        }
-
-        @Override
-        public LongStream onClose(Runnable closeHandler) {
-            return s.onClose(closeHandler);
-        }
-
-        @Override
-        public void close() {
-            s.close();
-        }
-    }
-
-    static final class DefaultMethodDoubleStream implements DoubleStream {
-        final DoubleStream s;
-
-        public DefaultMethodDoubleStream(DoubleStream s) {
-            this.s = s;
-        }
-
-        @Override
-        public DoubleStream filter(DoublePredicate predicate) {
-            return s.filter(predicate);
-        }
-
-        @Override
-        public DoubleStream map(DoubleUnaryOperator mapper) {
-            return s.map(mapper);
-        }
-
-        @Override
-        public <U> Stream<U> mapToObj(DoubleFunction<? extends U> mapper) {
-            return s.mapToObj(mapper);
-        }
-
-        @Override
-        public IntStream mapToInt(DoubleToIntFunction mapper) {
-            return s.mapToInt(mapper);
-        }
-
-        @Override
-        public LongStream mapToLong(DoubleToLongFunction mapper) {
-            return s.mapToLong(mapper);
-        }
-
-        @Override
-        public DoubleStream flatMap(DoubleFunction<? extends DoubleStream> mapper) {
-            return s.flatMap(mapper);
-        }
-
-        @Override
-        public DoubleStream distinct() {
-            return s.distinct();
-        }
-
-        @Override
-        public DoubleStream sorted() {
-            return s.sorted();
-        }
-
-        @Override
-        public DoubleStream peek(DoubleConsumer action) {
-            return s.peek(action);
-        }
-
-        @Override
-        public DoubleStream limit(long maxSize) {
-            return s.limit(maxSize);
-        }
-
-        @Override
-        public DoubleStream skip(long n) {
-            return s.skip(n);
-        }
-
-        @Override
-        public void forEach(DoubleConsumer action) {
-            s.forEach(action);
-        }
-
-        @Override
-        public void forEachOrdered(DoubleConsumer action) {
-            s.forEachOrdered(action);
-        }
-
-        @Override
-        public double[] toArray() {
-            return s.toArray();
-        }
-
-        @Override
-        public double reduce(double identity, DoubleBinaryOperator op) {
-            return s.reduce(identity, op);
-        }
-
-        @Override
-        public OptionalDouble reduce(DoubleBinaryOperator op) {
-            return s.reduce(op);
-        }
-
-        @Override
-        public <R> R collect(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R, R> combiner) {
-            return s.collect(supplier, accumulator, combiner);
-        }
-
-        @Override
-        public double sum() {
-            return s.sum();
-        }
-
-        @Override
-        public OptionalDouble min() {
-            return s.min();
-        }
-
-        @Override
-        public OptionalDouble max() {
-            return s.max();
-        }
-
-        @Override
-        public long count() {
-            return s.count();
-        }
-
-        @Override
-        public OptionalDouble average() {
-            return s.average();
-        }
-
-        @Override
-        public DoubleSummaryStatistics summaryStatistics() {
-            return s.summaryStatistics();
-        }
-
-        @Override
-        public boolean anyMatch(DoublePredicate predicate) {
-            return s.anyMatch(predicate);
-        }
-
-        @Override
-        public boolean allMatch(DoublePredicate predicate) {
-            return s.allMatch(predicate);
-        }
-
-        @Override
-        public boolean noneMatch(DoublePredicate predicate) {
-            return s.noneMatch(predicate);
-        }
-
-        @Override
-        public OptionalDouble findFirst() {
-            return s.findFirst();
-        }
-
-        @Override
-        public OptionalDouble findAny() {
-            return s.findAny();
-        }
-
-        @Override
-        public Stream<Double> boxed() {
-            return s.boxed();
-        }
-
-        @Override
-        public DoubleStream sequential() {
-            return s.sequential();
-        }
-
-        @Override
-        public DoubleStream parallel() {
-            return s.parallel();
-        }
-
-        @Override
-        public PrimitiveIterator.OfDouble iterator() {
-            return s.iterator();
-        }
-
-        @Override
-        public Spliterator.OfDouble spliterator() {
-            return s.spliterator();
-        }
-
-        @Override
-        public boolean isParallel() {
-            return s.isParallel();
-        }
-
-        @Override
-        public DoubleStream unordered() {
-            return s.unordered();
-        }
-
-        @Override
-        public DoubleStream onClose(Runnable closeHandler) {
-            return s.onClose(closeHandler);
-        }
-
-        @Override
-        public void close() {
-            s.close();
-        }
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DoubleStreamTestDataProvider.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import org.testng.annotations.DataProvider;
-
-import java.util.*;
-import java.util.Spliterators;
-import java.util.function.Supplier;
-
-/** TestNG DataProvider for double-valued streams */
-public class DoubleStreamTestDataProvider {
-    private static final double[] to0 = new double[0];
-    private static final double[] to1 = new double[1];
-    private static final double[] to10 = new double[10];
-    private static final double[] to100 = new double[100];
-    private static final double[] to1000 = new double[1000];
-    private static final double[] reversed = new double[100];
-    private static final double[] ones = new double[100];
-    private static final double[] twice = new double[200];
-    private static final double[] pseudoRandom;
-
-    private static final Object[][] testData;
-    private static final Object[][] testSmallData;
-    private static final Object[][] spliteratorTestData;
-
-    static {
-        double[][] arrays = {to0, to1, to10, to100, to1000};
-        for (double[] arr : arrays) {
-            for (int i = 0; i < arr.length; i++) {
-                arr[i] = i;
-            }
-        }
-        for (int i = 0; i < reversed.length; i++) {
-            reversed[i] = reversed.length - i;
-        }
-        for (int i = 0; i < ones.length; i++) {
-            ones[i] = 1;
-        }
-        System.arraycopy(to100, 0, twice, 0, to100.length);
-        System.arraycopy(to100, 0, twice, to100.length, to100.length);
-        pseudoRandom = new double[LambdaTestHelpers.LONG_STRING.length()];
-        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
-            pseudoRandom[i] = (double) LambdaTestHelpers.LONG_STRING.charAt(i);
-        }
-    }
-
-    static final Object[][] arrays = {
-            {"empty", to0},
-            {"0..1", to1},
-            {"0..10", to10},
-            {"0..100", to100},
-            {"0..1000", to1000},
-            {"100x[1]", ones},
-            {"2x[0..100]", twice},
-            {"reverse 0..100", reversed},
-            {"pseudorandom", pseudoRandom}
-    };
-
-    static {
-        {
-            List<Object[]> listSmall = new ArrayList<>();
-            List<Object[]> list1000 = new ArrayList<>();
-            List<Object[]> list = null;
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final double[] doubles = (double[]) data[1];
-
-                list = doubles.length >= 1000 ? list1000 : listSmall;
-
-                list.add(new Object[]{"array:" + name,
-                        TestData.Factory.ofArray("array:" + name, doubles)});
-
-                SpinedBuffer.OfDouble isl = new SpinedBuffer.OfDouble();
-                for (double i : doubles) {
-                    isl.accept(i);
-                }
-                list.add(new Object[]{"SpinedList:" + name,
-                        TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
-            }
-            testSmallData = listSmall.toArray(new Object[0][]);
-            list1000.addAll(listSmall);
-            testData = list1000.toArray(new Object[0][]);
-        }
-
-        {
-            List<Object[]> spliterators = new ArrayList<>();
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final double[] doubles = (double[]) data[1];
-
-                SpinedBuffer.OfDouble isl = new SpinedBuffer.OfDouble();
-                for (double i : doubles) {
-                    isl.accept(i);
-                }
-
-                spliterators.add(splitDescr("Arrays.s(array):" + name,
-                                            () -> Arrays.spliterator(doubles)));
-                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
-                                            () -> Arrays.spliterator(doubles, 0, doubles.length / 2)));
-
-                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
-                                            () -> isl.spliterator()));
-
-                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
-                                            () -> Spliterators.spliterator(isl.iterator(), doubles.length, 0)));
-                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
-                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
-                spliterators.add(splitDescr("DoubleStream.iterate(0,x->x<l;x->x+1):" + name,
-                                            () -> DoubleStream.iterate(0.0, x -> x < doubles.length, x -> x + 1.0)
-                                                              .spliterator()));
-                // Need more!
-            }
-            spliteratorTestData = spliterators.toArray(new Object[0][]);
-        }
-
-    }
-
-    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfDouble> s) {
-        return new Object[] { description, s };
-    }
-
-    // Return an array of ( String name, DoubleStreamTestData )
-    @DataProvider(name = "DoubleStreamTestData")
-    public static Object[][] makeDoubleStreamTestData() {
-        return testData;
-    }
-
-    @DataProvider(name = "DoubleStreamTestData.small")
-    public static Object[][] makeSmallDoubleStreamTestData() {
-        return testSmallData;
-    }
-
-    // returns an array of (String name, Supplier<PrimitiveSpliterator<Double>>)
-    @DataProvider(name = "DoubleSpliterator")
-    public static Object[][] spliteratorProvider() {
-        return spliteratorTestData;
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DoubleStreamTestScenario.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.PrimitiveIterator;
-import java.util.Set;
-import java.util.Spliterator;
-import java.util.SpliteratorTestHelper;
-import java.util.function.Consumer;
-import java.util.function.DoubleConsumer;
-import java.util.function.Function;
-
-/**
- * Test scenarios for double streams.
- *
- * Each scenario is provided with a data source, a function that maps a fresh
- * stream (as provided by the data source) to a new stream, and a sink to
- * receive results.  Each scenario describes a different way of computing the
- * stream contents.  The test driver will ensure that all scenarios produce
- * the same output (modulo allowable differences in ordering).
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public enum DoubleStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
-
-    STREAM_FOR_EACH(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            DoubleStream s = m.apply(source);
-            if (s.isParallel()) {
-                s = s.sequential();
-            }
-            s.forEach(b);
-        }
-    },
-
-    STREAM_TO_ARRAY(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            for (double t : m.apply(source).toArray()) {
-                b.accept(t);
-            }
-        }
-    },
-
-    STREAM_ITERATOR(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            for (PrimitiveIterator.OfDouble seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
-                b.accept(seqIter.nextDouble());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            for (Spliterator.OfDouble spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
-    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR_FOREACH(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            m.apply(source).sequential().forEach(b);
-        }
-    },
-
-    // Wrap as parallel stream + forEachOrdered
-    PAR_STREAM_FOR_EACH_ORDERED(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            // @@@ Want to explicitly select ordered equalator
-            m.apply(source).forEachOrdered(b);
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            for (Spliterator.OfDouble spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR_FOREACH(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    PAR_STREAM_TO_ARRAY(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            for (double t : m.apply(source).toArray())
-                b.accept(t);
-        }
-    },
-
-    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
-    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            DoubleStream s = m.apply(source);
-            Spliterator.OfDouble sp = s.spliterator();
-            DoubleStream ss = StreamSupport.doubleStream(() -> sp,
-                                                         StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
-                                                         | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
-            for (double t : ss.toArray())
-                b.accept(t);
-        }
-    },
-
-    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            DoubleStream pipe2 = m.apply(pipe1);
-
-            for (double t : pipe2.toArray())
-                b.accept(t);
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing
-    PAR_STREAM_FOR_EACH(true, false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            m.apply(source).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
-    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            m.apply(pipe1).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-    ;
-
-    // The set of scenarios that clean the SIZED flag
-    public static final Set<DoubleStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
-            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
-
-    private boolean isParallel;
-
-    private final boolean isOrdered;
-
-    DoubleStreamTestScenario(boolean isParallel) {
-        this(isParallel, true);
-    }
-
-    DoubleStreamTestScenario(boolean isParallel, boolean isOrdered) {
-        this.isParallel = isParallel;
-        this.isOrdered = isOrdered;
-    }
-
-    public StreamShape getShape() {
-        return StreamShape.DOUBLE_VALUE;
-    }
-
-    public boolean isParallel() {
-        return isParallel;
-    }
-
-    public boolean isOrdered() {
-        return isOrdered;
-    }
-
-    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
-        try (S_IN source = getStream(data)) {
-            run(data, source, (DoubleConsumer) b, (Function<S_IN, DoubleStream>) m);
-        }
-    }
-
-    abstract <T, S_IN extends BaseStream<T, S_IN>>
-    void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m);
-
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/FlagDeclaringOp.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2012, 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.
- */
-package java.util.stream;
-
-/**
- * An operation that injects or clears flags but otherwise performs no operation on elements.
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public class FlagDeclaringOp<T> implements StatelessTestOp<T, T> {
-    private final int flags;
-    private final StreamShape shape;
-
-    public FlagDeclaringOp(int flags) {
-        this(flags, StreamShape.REFERENCE);
-    }
-
-    public FlagDeclaringOp(int flags, StreamShape shape) {
-        this.flags = flags;
-        this.shape = shape;
-    }
-
-    @Override
-    public StreamShape outputShape() {
-        return shape;
-    }
-
-    @Override
-    public StreamShape inputShape() {
-        return shape;
-    }
-
-    @Override
-    public int opGetFlags() {
-        return flags;
-    }
-
-    @Override
-    public Sink<T> opWrapSink(int flags, boolean parallel, Sink sink) {
-        return sink;
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntStreamTestDataProvider.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import org.testng.annotations.DataProvider;
-
-import java.util.*;
-import java.util.Spliterators;
-import java.util.function.Supplier;
-
-/** TestNG DataProvider for int-valued streams */
-public class IntStreamTestDataProvider {
-    private static final int[] to0 = new int[0];
-    private static final int[] to1 = new int[1];
-    private static final int[] to10 = new int[10];
-    private static final int[] to100 = new int[100];
-    private static final int[] to1000 = new int[1000];
-    private static final int[] reversed = new int[100];
-    private static final int[] ones = new int[100];
-    private static final int[] twice = new int[200];
-    private static final int[] pseudoRandom;
-
-    private static final Object[][] testData;
-    private static final Object[][] testSmallData;
-    private static final Object[][] spliteratorTestData;
-
-    static {
-        int[][] arrays = {to0, to1, to10, to100, to1000};
-        for (int[] arr : arrays) {
-            for (int i = 0; i < arr.length; i++) {
-                arr[i] = i;
-            }
-        }
-        for (int i = 0; i < reversed.length; i++) {
-            reversed[i] = reversed.length - i;
-        }
-        for (int i = 0; i < ones.length; i++) {
-            ones[i] = 1;
-        }
-        System.arraycopy(to100, 0, twice, 0, to100.length);
-        System.arraycopy(to100, 0, twice, to100.length, to100.length);
-        pseudoRandom = new int[LambdaTestHelpers.LONG_STRING.length()];
-        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
-            pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
-        }
-    }
-
-    static final Object[][] arrays = {
-            {"empty", to0},
-            {"0..1", to1},
-            {"0..10", to10},
-            {"0..100", to100},
-            {"0..1000", to1000},
-            {"100x[1]", ones},
-            {"2x[0..100]", twice},
-            {"reverse 0..100", reversed},
-            {"pseudorandom", pseudoRandom}
-    };
-
-    static {
-        {
-            List<Object[]> listSmall = new ArrayList<>();
-            List<Object[]> list1000 = new ArrayList<>();
-            List<Object[]> list = null;
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final int[] ints = (int[]) data[1];
-
-                list = ints.length >= 1000 ? list1000 : listSmall;
-
-                list.add(new Object[]{"array:" +
-                                      name, TestData.Factory.ofArray("array:" + name, ints)});
-
-                SpinedBuffer.OfInt isl = new SpinedBuffer.OfInt();
-                for (int i : ints) {
-                    isl.accept(i);
-                }
-                list.add(new Object[]{"SpinedList:" + name,
-                         TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
-
-                list.add(streamDataDescr("IntStream.intRange(0,l): " + ints.length,
-                                         () -> IntStream.range(0, ints.length)));
-                list.add(streamDataDescr("IntStream.rangeClosed(0,l): " + ints.length,
-                                         () -> IntStream.rangeClosed(0, ints.length)));
-            }
-            testSmallData = listSmall.toArray(new Object[0][]);
-            list1000.addAll(listSmall);
-            testData = list1000.toArray(new Object[0][]);
-        }
-
-        {
-            List<Object[]> spliterators = new ArrayList<>();
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final int[] ints = (int[]) data[1];
-
-                SpinedBuffer.OfInt isl = new SpinedBuffer.OfInt();
-                for (int i : ints) {
-                    isl.accept(i);
-                }
-
-                spliterators.add(splitDescr("Arrays.s(array):" + name,
-                                            () -> Arrays.spliterator(ints)));
-                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
-                                            () -> Arrays.spliterator(ints, 0, ints.length / 2)));
-
-                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
-                                            () -> isl.spliterator()));
-
-                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
-                                            () -> Spliterators.spliterator(isl.iterator(), ints.length, 0)));
-                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
-                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
-
-                spliterators.add(splitDescr("IntStream.intRange(0,l):" + name,
-                                            () -> IntStream.range(0, ints.length).spliterator()));
-                spliterators.add(splitDescr("IntStream.intRangeClosed(0,l):" + name,
-                                            () -> IntStream.rangeClosed(0, ints.length).spliterator()));
-                spliterators.add(splitDescr("IntStream.iterate(0,x->x<l,x->x+1): " + name,
-                                            () -> IntStream.iterate(0, x -> x < ints.length, x -> x + 1).spliterator()));
-                // Need more!
-            }
-            spliteratorTestData = spliterators.toArray(new Object[0][]);
-        }
-
-    }
-
-    static <T> Object[] streamDataDescr(String description, Supplier<IntStream> s) {
-        return new Object[] { description, TestData.Factory.ofIntSupplier(description, s) };
-    }
-
-    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfInt> s) {
-        return new Object[] { description, s };
-    }
-
-    // Return an array of ( String name, IntStreamTestData )
-    @DataProvider(name = "IntStreamTestData")
-    public static Object[][] makeIntStreamTestData() {
-        return testData;
-    }
-
-    @DataProvider(name = "IntStreamTestData.small")
-    public static Object[][] makeSmallIntStreamTestData() {
-        return testSmallData;
-    }
-
-    // returns an array of (String name, Supplier<PrimitiveSpliterator<Integer>>)
-    @DataProvider(name = "IntSpliterator")
-    public static Object[][] spliteratorProvider() {
-        return spliteratorTestData;
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntStreamTestScenario.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,234 +0,0 @@
-/*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.PrimitiveIterator;
-import java.util.Set;
-import java.util.Spliterator;
-import java.util.SpliteratorTestHelper;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.function.IntConsumer;
-
-/**
- * Test scenarios for int streams.
- *
- * Each scenario is provided with a data source, a function that maps a fresh
- * stream (as provided by the data source) to a new stream, and a sink to
- * receive results.  Each scenario describes a different way of computing the
- * stream contents.  The test driver will ensure that all scenarios produce
- * the same output (modulo allowable differences in ordering).
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public enum IntStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
-
-    STREAM_FOR_EACH(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            IntStream s = m.apply(source);
-            if (s.isParallel()) {
-                s = s.sequential();
-            }
-            s.forEach(b);
-        }
-    },
-
-    STREAM_TO_ARRAY(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            for (int t : m.apply(source).toArray()) {
-                b.accept(t);
-            }
-        }
-    },
-
-    STREAM_ITERATOR(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            for (PrimitiveIterator.OfInt seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
-                b.accept(seqIter.nextInt());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            for (Spliterator.OfInt spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
-    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR_FOREACH(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            m.apply(source).sequential().forEach(b);
-        }
-    },
-
-    // Wrap as parallel stream + forEachOrdered
-    PAR_STREAM_FOR_EACH_ORDERED(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            // @@@ Want to explicitly select ordered equalator
-            m.apply(source).forEachOrdered(b);
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            for (Spliterator.OfInt spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR_FOREACH(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    PAR_STREAM_TO_ARRAY(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            for (int t : m.apply(source).toArray())
-                b.accept(t);
-        }
-    },
-
-    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
-    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            IntStream s = m.apply(source);
-            Spliterator.OfInt sp = s.spliterator();
-            IntStream ss = StreamSupport.intStream(() -> sp,
-                                                   StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
-                                                   | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED),
-                                                   true);
-            for (int t : ss.toArray())
-                b.accept(t);
-        }
-    },
-
-    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            IntStream pipe2 = m.apply(pipe1);
-
-            for (int t : pipe2.toArray())
-                b.accept(t);
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing
-    PAR_STREAM_FOR_EACH(true, false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            m.apply(source).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
-    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            m.apply(pipe1).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-    ;
-
-    // The set of scenarios that clean the SIZED flag
-    public static final Set<IntStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
-            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
-
-    private final boolean isParallel;
-
-    private final boolean isOrdered;
-
-    IntStreamTestScenario(boolean isParallel) {
-        this(isParallel, true);
-    }
-
-    IntStreamTestScenario(boolean isParallel, boolean isOrdered) {
-        this.isParallel = isParallel;
-        this.isOrdered = isOrdered;
-    }
-
-    public StreamShape getShape() {
-        return StreamShape.INT_VALUE;
-    }
-
-    public boolean isParallel() {
-        return isParallel;
-    }
-
-    public boolean isOrdered() {
-        return isOrdered;
-    }
-
-    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
-        try (S_IN source = getStream(data)) {
-            run(data, source, (IntConsumer) b, (Function<S_IN, IntStream>) m);
-        }
-    }
-
-    abstract <T, S_IN extends BaseStream<T, S_IN>>
-    void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m);
-
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntermediateTestOp.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2012, 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.
- */
-package java.util.stream;
-
-/**
- * A base type for test operations
- */
-interface IntermediateTestOp<E_IN, E_OUT> {
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public static<T> AbstractPipeline chain(AbstractPipeline upstream,
-                                            IntermediateTestOp<?, T> op) {
-        if (op instanceof StatelessTestOp)
-            return StatelessTestOp.chain(upstream, (StatelessTestOp) op);
-
-        if (op instanceof StatefulTestOp)
-            return StatefulTestOp.chain(upstream, (StatefulTestOp) op);
-
-        throw new IllegalStateException("Unknown test op type: " + op.getClass().getName());
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LambdaTestHelpers.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,473 +0,0 @@
-/*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.*;
-import java.util.function.BiConsumer;
-import java.util.function.BiPredicate;
-import java.util.function.BinaryOperator;
-import java.util.function.Consumer;
-import java.util.function.DoubleBinaryOperator;
-import java.util.function.DoubleConsumer;
-import java.util.function.DoublePredicate;
-import java.util.function.Function;
-import java.util.function.IntBinaryOperator;
-import java.util.function.IntConsumer;
-import java.util.function.IntFunction;
-import java.util.function.IntPredicate;
-import java.util.function.IntUnaryOperator;
-import java.util.function.LongBinaryOperator;
-import java.util.function.LongConsumer;
-import java.util.function.LongPredicate;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-import java.util.function.ToDoubleFunction;
-import java.util.function.ToIntFunction;
-import java.util.function.ToLongFunction;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.assertFalse;
-
-/**
- * LambdaTestHelpers -- assertion methods and useful objects for lambda test cases
- */
-public class LambdaTestHelpers {
-    public static final String LONG_STRING = "When in the Course of human events it becomes necessary for one people to dissolve the political bands which have connected them with another and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.";
-
-    @SuppressWarnings("rawtypes")
-    public static final Consumer bEmpty = x -> {  };
-    @SuppressWarnings("rawtypes")
-    public static final IntConsumer bIntEmpty = x -> {  };
-    @SuppressWarnings("rawtypes")
-    public static final BiConsumer bBiEmpty = (x,y) -> { };
-    @SuppressWarnings("rawtypes")
-    public static final Consumer bHashCode = x -> { Objects.hashCode(x); };
-    @SuppressWarnings("rawtypes")
-    public static final BiConsumer bBiHashCode = (x,y) -> { Objects.hash(x, y); };
-    public static final Function<Integer, Integer> mZero = x -> 0;
-    public static final Function<Integer, Integer> mId = x -> x;
-    public static final Function<Integer, Integer> mDoubler = x -> x * 2;
-    public static final Function<Integer, Stream<Integer>> mfId = e -> Collections.singletonList(e).stream();
-    public static final Function<Integer, Stream<Integer>> mfNull = e -> Collections.<Integer>emptyList().stream();
-    public static final Function<Integer, Stream<Integer>> mfLt = e -> {
-        List<Integer> l = new ArrayList<>();
-        for (int i=0; i<e; i++)
-            l.add(i);
-        return l.stream();
-    };
-    public static final ToIntFunction<Integer> imDoubler = x -> x * 2;
-    public static final ToLongFunction<Long> lmDoubler = x -> x * 2;
-    public static final ToDoubleFunction<Double> dmDoubler = x -> x * 2;
-    public static final Predicate<Integer> pFalse = x -> false;
-    public static final Predicate<Integer> pTrue = x -> true;
-    public static final Predicate<Integer> pEven = x -> 0 == x % 2;
-    public static final Predicate<Integer> pOdd = x -> 1 == x % 2;
-    public static final IntPredicate ipFalse = x -> false;
-    public static final IntPredicate ipTrue = x -> true;
-    public static final IntPredicate ipEven = x -> 0 == x % 2;
-    public static final IntPredicate ipOdd = x -> 1 == x % 2;
-    public static final LongPredicate lpFalse = x -> false;
-    public static final LongPredicate lpTrue = x -> true;
-    public static final LongPredicate lpEven = x -> 0 == x % 2;
-    public static final LongPredicate lpOdd = x -> 1 == x % 2;
-    public static final DoublePredicate dpFalse = x -> false;
-    public static final DoublePredicate dpTrue = x -> true;
-    public static final DoublePredicate dpEven = x -> 0 == ((long) x) % 2;
-    public static final DoublePredicate dpOdd = x -> 1 == ((long) x) % 2;
-    public static final BinaryOperator<Integer> rPlus = (x, y) -> x+y;
-    public static final BinaryOperator<Integer> rMax = (x, y) -> Math.max(x, y);
-    public static final BinaryOperator<Integer> rMin = (x, y) -> Math.min(x,y);
-    public static final IntBinaryOperator irPlus = (x, y) -> x+y;
-    public static final IntBinaryOperator irMax = (x, y) -> Math.max(x, y);
-    public static final IntBinaryOperator irMin = (x, y) -> Math.min(x,y);
-    public static final IntUnaryOperator irDoubler = x -> x * 2;
-    public static final LongBinaryOperator lrPlus = (x, y) -> x+y;
-    public static final DoubleBinaryOperator drPlus = (x, y) -> x+y;
-    public static final Comparator<Integer> cInteger = (a, b) -> Integer.compare(a, b);
-    public static final BiPredicate<?, ?> bipFalse = (x, y) -> false;
-    public static final BiPredicate<?, ?> bipTrue = (x, y) -> true;
-    public static final BiPredicate<Integer, Integer> bipBothEven = (x, y) -> 0 == (x % 2 + y % 2);
-    public static final BiPredicate<Integer, Integer> bipBothOdd = (x, y) -> 2 == (x % 2 + y % 2);
-    public static final BiPredicate<?, ?> bipSameString = (x, y) -> String.valueOf(x).equals(String.valueOf(y));
-
-    public static final IntFunction<Integer[]> integerArrayGenerator = s -> new Integer[s];
-
-    public static final IntFunction<Object[]> objectArrayGenerator = s -> new Object[s];
-
-    public static final Function<String, Stream<Character>> flattenChars = string -> {
-        List<Character> l = new ArrayList<>();
-        for (int i=0; i<string.length(); i++)
-            l.add(string.charAt(i));
-        return l.stream();
-    };
-
-    public static final Function<String, IntStream> flattenInt
-            = string -> IntStream.range(0, string.length()).map(string::charAt);
-
-    public static <T, R> Function<T, R> forPredicate(Predicate<? super T> predicate, R forTrue, R forFalse) {
-        Objects.requireNonNull(predicate);
-
-        return t -> predicate.test(t) ? forTrue : forFalse;
-    }
-
-    public static <T> Function<T, T> identity() {
-        return t -> t;
-    }
-
-    public static<V, T, R> Function<V, R> compose(Function<? super T, ? extends R> after, Function<? super V, ? extends T> before) {
-        Objects.requireNonNull(before);
-        return (V v) -> after.apply(before.apply(v));
-    }
-
-    public static List<Integer> empty() {
-        ArrayList<Integer> list = new ArrayList<>();
-        list.add(null);
-        return list;
-    }
-
-    public static List<Integer> countTo(int n) {
-        return range(1, n);
-    }
-
-    public static List<Integer> range(int l, int u) {
-        ArrayList<Integer> list = new ArrayList<>(u - l + 1);
-        for (int i=l; i<=u; i++) {
-            list.add(i);
-        }
-        return list;
-    }
-
-    public static List<Integer> repeat(int value, int n) {
-        ArrayList<Integer> list = new ArrayList<>(n);
-        for (int i=1; i<=n; i++) {
-            list.add(value);
-        }
-        return list;
-    }
-
-    public static List<Double> asDoubles(List<Integer> integers) {
-        ArrayList<Double> list = new ArrayList<>();
-        for (Integer i : integers) {
-            list.add((double) i);
-        }
-        return list;
-    }
-
-    public static List<Long> asLongs(List<Integer> integers) {
-        ArrayList<Long> list = new ArrayList<>();
-        for (Integer i : integers) {
-            list.add((long) i);
-        }
-        return list;
-    }
-
-    public static void assertCountSum(Stream<? super Integer> it, int count, int sum) {
-        assertCountSum(it.iterator(), count, sum);
-    }
-
-    public static void assertCountSum(Iterable<? super Integer> it, int count, int sum) {
-        assertCountSum(it.iterator(), count, sum);
-    }
-
-    public static void assertCountSum(Iterator<? super Integer> it, int count, int sum) {
-        int c = 0;
-        int s = 0;
-        while (it.hasNext()) {
-            int i = (Integer) it.next();
-            c++;
-            s += i;
-        }
-
-        assertEquals(c, count);
-        assertEquals(s, sum);
-    }
-
-    public static void assertConcat(Iterator<Character> it, String result) {
-        StringBuilder sb = new StringBuilder();
-        while (it.hasNext()) {
-            sb.append(it.next());
-        }
-
-        assertEquals(result, sb.toString());
-    }
-
-    public static<T extends Comparable<? super T>> void assertSorted(Iterator<T> i) {
-        i = toBoxedList(i).iterator();
-
-        if (!i.hasNext())
-            return;
-        T last = i.next();
-        while (i.hasNext()) {
-            T t = i.next();
-            assertTrue(last.compareTo(t) <= 0);
-            assertTrue(t.compareTo(last) >= 0);
-            last = t;
-        }
-    }
-
-    public static<T> void assertSorted(Iterator<T> i, Comparator<? super T> comp) {
-        if (i instanceof PrimitiveIterator.OfInt
-                || i instanceof PrimitiveIterator.OfDouble
-                || i instanceof PrimitiveIterator.OfLong) {
-            i = toBoxedList(i).iterator();
-        }
-
-        if (!i.hasNext())
-            return;
-        T last = i.next();
-        while (i.hasNext()) {
-            T t = i.next();
-            assertTrue(comp.compare(last, t) <= 0);
-            assertTrue(comp.compare(t, last) >= 0);
-            last = t;
-        }
-    }
-
-    public static<T extends Comparable<? super T>> void assertSorted(Iterable<T> iter) {
-        assertSorted(iter.iterator());
-    }
-
-    public static<T> void assertSorted(Iterable<T> iter, Comparator<? super T> comp) {
-        assertSorted(iter.iterator(), comp);
-    }
-
-    public static <T> void assertUnique(Iterable<T> iter) {
-        assertUnique(iter.iterator());
-    }
-
-    public static<T> void assertUnique(Iterator<T> iter) {
-        if (!iter.hasNext()) {
-            return;
-        }
-
-        if (iter instanceof PrimitiveIterator.OfInt
-            || iter instanceof PrimitiveIterator.OfDouble
-            || iter instanceof PrimitiveIterator.OfLong) {
-            iter = toBoxedList(iter).iterator();
-        }
-
-        Set<T> uniq = new HashSet<>();
-        while(iter.hasNext()) {
-            T each = iter.next();
-            assertTrue(!uniq.contains(each), "Not unique");
-            uniq.add(each);
-        }
-    }
-
-    public static<T> void assertContents(Iterable<T> actual, Iterable<T> expected) {
-        if (actual instanceof Collection && expected instanceof Collection) {
-            assertEquals(actual, expected);
-        } else {
-            assertContents(actual.iterator(), expected.iterator());
-        }
-    }
-
-    public static<T> void assertContents(Iterator<T> actual, Iterator<T> expected) {
-        assertEquals(toBoxedList(actual), toBoxedList(expected));
-    }
-
-    @SafeVarargs
-    @SuppressWarnings("varargs")
-    public static<T> void assertContents(Iterator<T> actual, T... expected) {
-        assertContents(actual, Arrays.asList(expected).iterator());
-    }
-
-    /**
-     * The all consuming consumer (rampant capitalist) that can accepting a reference or any primitive value.
-     */
-    private static interface OmnivorousConsumer<T>
-            extends Consumer<T>, IntConsumer, LongConsumer, DoubleConsumer { }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public static<T> Consumer<T> toBoxingConsumer(Consumer<? super T> c) {
-        return (Consumer<T>) new OmnivorousConsumer() {
-            @Override
-            public void accept(Object t) {
-                c.accept((T) t);
-            }
-
-            @Override
-            public void accept(int t) {
-                accept((Object) t);
-            }
-
-            @Override
-            public void accept(long t) {
-                accept((Object) t);
-            }
-
-            @Override
-            public void accept(double t) {
-                accept((Object) t);
-            }
-        };
-    }
-
-    /**
-     * Convert an iterator to a list using forEach with an implementation of
-     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
-     *
-     * This ensures equality comparisons for test results do not trip
-     * the boxing trip-wires.
-     */
-    private static<T> List<T> toBoxedList(Iterator<T> it) {
-        List<T> l = new ArrayList<>();
-        it.forEachRemaining(toBoxingConsumer(l::add));
-        return l;
-    }
-
-    /**
-     * Convert a spliterator to a list using forEach with an implementation of
-     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
-     *
-     * This ensures equality comparisons for test results do not trip
-     * the boxing trip-wires.
-     */
-    public static<T> List<T> toBoxedList(Spliterator<T> sp) {
-        List<T> l = new ArrayList<>();
-        sp.forEachRemaining(toBoxingConsumer(l::add));
-        return l;
-    }
-
-    /**
-     * Convert an iterator to a multi-set, represented as a Map, using forEach with an implementation of
-     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
-     *
-     * This ensures equality comparisons for test results do not trip
-     * the boxing trip-wires.
-     */
-    @SuppressWarnings("unchecked")
-    private static<T> Map<T, Integer> toBoxedMultiset(Iterator<T> it) {
-        Map<Object, Integer> result = new HashMap<>();
-
-        it.forEachRemaining(toBoxingConsumer(o -> {
-                if (result.containsKey(o))
-                    result.put(o, result.get(o) + 1);
-                else
-                    result.put(o, 1);
-            }));
-
-        return (Map<T, Integer>) result;
-    }
-
-    @SuppressWarnings("unchecked")
-    public static<T> Map<T, Integer> toBoxedMultiset(Spliterator<T> it) {
-        Map<Object, Integer> result = new HashMap<>();
-
-        it.forEachRemaining(toBoxingConsumer(o -> {
-                if (result.containsKey(o))
-                    result.put(o, result.get(o) + 1);
-                else
-                    result.put(o, 1);
-            }));
-
-        return (Map<T, Integer>) result;
-    }
-
-    @SuppressWarnings("unchecked")
-    public static void assertContentsEqual(Object a, Object b) {
-        if (a instanceof Iterable && b instanceof Iterable)
-            assertContents((Iterable) a, (Iterable) b);
-        else
-            assertEquals(a, b);
-    }
-
-    public static<T> void assertContentsUnordered(Iterable<T> actual, Iterable<T> expected) {
-        assertContentsUnordered(actual.iterator(), expected.iterator());
-    }
-
-    public static<T> void assertContentsUnordered(Iterator<T> actual, Iterator<T> expected) {
-        assertEquals(toBoxedMultiset(actual), toBoxedMultiset(expected));
-    }
-
-    public static<T> void assertContains(Optional<T> actual, Iterator<T> it) {
-        actual.ifPresentOrElse(r -> {
-            boolean contained = false;
-            while (!contained && it.hasNext()) {
-                contained = Objects.equals(r, it.next());
-            }
-            assertTrue(contained, "Not found: "+r);
-        }, () -> assertFalse(it.hasNext()));
-    }
-
-    public static void launderAssertion(Runnable r, Supplier<String> additionalInfo) {
-        try {
-            r.run();
-        }
-        catch (AssertionError ae) {
-            AssertionError cloned = new AssertionError(ae.getMessage() + String.format("%n%s", additionalInfo.get()));
-            cloned.setStackTrace(ae.getStackTrace());
-            if (ae.getCause() != null)
-                cloned.initCause(ae.getCause());
-            throw cloned;
-        }
-    }
-
-    public static <T, S extends BaseStream<T, S>>
-    List<Function<S, S>> permuteStreamFunctions(List<Function<S, S>> opFunctions) {
-        List<List<Function<S, S>>> opFunctionPermutations = perm(opFunctions);
-
-        List<Function<S, S>> appliedFunctions = new ArrayList<>();
-        for (List<Function<S, S>> fs : opFunctionPermutations) {
-            Function<S, S> applied = s -> {
-                for (Function<S, S> f : fs) {
-                    s = f.apply(s);
-                }
-                return s;
-            };
-            appliedFunctions.add(applied);
-        }
-
-        return appliedFunctions;
-    }
-
-    private static <T> List<T> sub(List<T> l, int index) {
-        List<T> subL = new ArrayList<>(l);
-        subL.remove(index);
-        return subL;
-    }
-
-    public static <T> List<List<T>> perm(List<T> l) {
-        List<List<T>> result = new ArrayList<>();
-        for (int i = 0; i < l.size(); i++) {
-            for (List<T> perm : perm(sub(l, i))) {
-                perm.add(0, l.get(i));
-                result.add(perm);
-            }
-        }
-        result.add(new ArrayList<T>());
-
-        return result;
-    }
-
-    public static String flagsToString(int flags) {
-        StringJoiner sj = new StringJoiner(", ", "StreamOpFlag[", "]");
-        if (StreamOpFlag.DISTINCT.isKnown(flags)) sj.add("IS_DISTINCT");
-        if (StreamOpFlag.ORDERED.isKnown(flags)) sj.add("IS_ORDERED");
-        if (StreamOpFlag.SIZED.isKnown(flags)) sj.add("IS_SIZED");
-        if (StreamOpFlag.SORTED.isKnown(flags)) sj.add("IS_SORTED");
-        if (StreamOpFlag.SHORT_CIRCUIT.isKnown(flags)) sj.add("IS_SHORT_CIRCUIT");
-        return sj.toString();
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LambdaTestMode.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +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.
- */
-package java.util.stream;
-
-/**
- * Runtime modes of test execution.
- */
-public enum LambdaTestMode {
-    /**
-     * Execution mode with no particular runtime constraints.
-     */
-    NORMAL,
-
-    /**
-     * Execution mode where tests are executed for testing lambda serialization
-     * and deserialization.
-     *
-     * <p>This mode may be queried by tests or data supplied by data
-     * providers, which cannot otherwise be assigned to the test group
-     * <em>serialization-hostile</em>, to not execute or declare
-     * serialization-hostile code or data.
-     *
-     * <p>This mode is enabled if the boolean system property
-     * {@code org.openjdk.java.util.stream.sand.mode} is declared with a
-     * {@code true} value.
-     */
-    SERIALIZATION;
-
-    /**
-     * {@code true} if tests are executed in the mode for testing lambda
-     * Serialization ANd Deserialization (SAND).
-     */
-    private static final boolean IS_LAMBDA_SERIALIZATION_MODE =
-            Boolean.getBoolean("org.openjdk.java.util.stream.sand.mode");
-
-    /**
-     *
-     * @return the mode of test execution.
-     */
-    public static LambdaTestMode getMode() {
-        return IS_LAMBDA_SERIALIZATION_MODE ? SERIALIZATION : NORMAL;
-    }
-
-    /**
-     *
-     * @return {@code true} if normal test mode.
-     */
-    public static boolean isNormalMode() {
-        return getMode() == NORMAL;
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LoggingTestCase.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +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.
- */
-package java.util.stream;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.testng.Assert;
-import org.testng.ITestResult;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- * LoggingTestCase
- *
- */
-@Test
-public class LoggingTestCase extends Assert {
-    private Map<String, Object> context = new HashMap<>();
-
-    @BeforeMethod
-    public void before() {
-        context.clear();
-    }
-
-    @AfterMethod
-    public void after(ITestResult result) {
-        if (!result.isSuccess()) {
-            List<Object> list = new ArrayList<>();
-            Collections.addAll(list, result.getParameters());
-            list.add(context.toString());
-            result.setParameters(list.toArray(new Object[list.size()]));
-        }
-    }
-
-    protected void setContext(String key, Object value) {
-        context.put(key, value);
-    }
-
-    protected void clearContext(String key) {
-        context.remove(key);
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LongStreamTestDataProvider.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import org.testng.annotations.DataProvider;
-
-import java.util.*;
-import java.util.Spliterators;
-import java.util.function.Supplier;
-
-/** TestNG DataProvider for long-valued streams */
-public class LongStreamTestDataProvider {
-    private static final long[] to0 = new long[0];
-    private static final long[] to1 = new long[1];
-    private static final long[] to10 = new long[10];
-    private static final long[] to100 = new long[100];
-    private static final long[] to1000 = new long[1000];
-    private static final long[] reversed = new long[100];
-    private static final long[] ones = new long[100];
-    private static final long[] twice = new long[200];
-    private static final long[] pseudoRandom;
-
-    private static final Object[][] testData;
-    private static final Object[][] testSmallData;
-    private static final Object[][] spliteratorTestData;
-
-    static {
-        long[][] arrays = {to0, to1, to10, to100, to1000};
-        for (long[] arr : arrays) {
-            for (int i = 0; i < arr.length; i++) {
-                arr[i] = i;
-            }
-        }
-        for (int i = 0; i < reversed.length; i++) {
-            reversed[i] = reversed.length - i;
-        }
-        for (int i = 0; i < ones.length; i++) {
-            ones[i] = 1;
-        }
-        System.arraycopy(to100, 0, twice, 0, to100.length);
-        System.arraycopy(to100, 0, twice, to100.length, to100.length);
-        pseudoRandom = new long[LambdaTestHelpers.LONG_STRING.length()];
-        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
-            pseudoRandom[i] = (long) LambdaTestHelpers.LONG_STRING.charAt(i);
-        }
-    }
-
-    static final Object[][] arrays = {
-            {"empty", to0},
-            {"0..1", to1},
-            {"0..10", to10},
-            {"0..100", to100},
-            {"0..1000", to1000},
-            {"100x[1]", ones},
-            {"2x[0..100]", twice},
-            {"reverse 0..100", reversed},
-            {"pseudorandom", pseudoRandom}
-    };
-
-    static {
-        {
-            List<Object[]> listSmall = new ArrayList<>();
-            List<Object[]> list1000 = new ArrayList<>();
-            List<Object[]> list = null;
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final long[] longs = (long[]) data[1];
-
-                list = longs.length >= 1000 ? list1000 : listSmall;
-
-                list.add(new Object[]{"array:" + name,
-                        TestData.Factory.ofArray("array:" + name, longs)});
-
-                SpinedBuffer.OfLong isl = new SpinedBuffer.OfLong();
-                for (long i : longs) {
-                    isl.accept(i);
-                }
-                list.add(new Object[]{"SpinedList:" + name,
-                        TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
-
-                list.add(streamDataDescr("LongStream.longRange(0,l): " + longs.length,
-                                         () -> LongStream.range(0, longs.length)));
-                list.add(streamDataDescr("LongStream.longRangeClosed(0,l): " + longs.length,
-                                         () -> LongStream.rangeClosed(0, longs.length)));
-            }
-            testSmallData = listSmall.toArray(new Object[0][]);
-            list1000.addAll(listSmall);
-            testData = list1000.toArray(new Object[0][]);
-        }
-
-        {
-            List<Object[]> spliterators = new ArrayList<>();
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final long[] longs = (long[]) data[1];
-
-                SpinedBuffer.OfLong isl = new SpinedBuffer.OfLong();
-                for (long i : longs) {
-                    isl.accept(i);
-                }
-
-                spliterators.add(splitDescr("Arrays.s(array):" + name,
-                                            () -> Arrays.spliterator(longs)));
-                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
-                                            () -> Arrays.spliterator(longs, 0, longs.length / 2)));
-
-                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
-                                            () -> isl.spliterator()));
-
-                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
-                                            () -> Spliterators.spliterator(isl.iterator(), longs.length, 0)));
-                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
-                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
-
-                spliterators.add(splitDescr("LongStream.longRange(0,l):" + name,
-                                            () -> LongStream.range(0, longs.length).spliterator()));
-                spliterators.add(splitDescr("LongStream.longRangeClosed(0,l):" + name,
-                                            () -> LongStream.rangeClosed(0, longs.length).spliterator()));
-                spliterators.add(splitDescr("LongStream.iterate(0,x->x<l;x->x+1):" + name,
-                                            () -> LongStream.iterate(0L, x -> x < longs.length, x -> x + 1L)
-                                                            .spliterator()));
-                // Need more!
-            }
-            spliteratorTestData = spliterators.toArray(new Object[0][]);
-        }
-
-    }
-
-    static <T> Object[] streamDataDescr(String description, Supplier<LongStream> s) {
-        return new Object[] { description, TestData.Factory.ofLongSupplier(description, s) };
-    }
-
-    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfLong> s) {
-        return new Object[] { description, s };
-    }
-
-    // Return an array of ( String name, LongStreamTestData )
-    @DataProvider(name = "LongStreamTestData")
-    public static Object[][] makeLongStreamTestData() {
-        return testData;
-    }
-
-    @DataProvider(name = "LongStreamTestData.small")
-    public static Object[][] makeSmallLongStreamTestData() {
-        return testSmallData;
-    }
-
-    // returns an array of (String name, Supplier<PrimitiveSpliterator<Long>>)
-    @DataProvider(name = "LongSpliterator")
-    public static Object[][] spliteratorProvider() {
-        return spliteratorTestData;
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LongStreamTestScenario.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.PrimitiveIterator;
-import java.util.Set;
-import java.util.Spliterator;
-import java.util.SpliteratorTestHelper;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.function.LongConsumer;
-
-/**
- * Test scenarios for long streams.
- *
- * Each scenario is provided with a data source, a function that maps a fresh
- * stream (as provided by the data source) to a new stream, and a sink to
- * receive results.  Each scenario describes a different way of computing the
- * stream contents.  The test driver will ensure that all scenarios produce
- * the same output (modulo allowable differences in ordering).
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public enum LongStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
-
-    STREAM_FOR_EACH(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            LongStream s = m.apply(source);
-            if (s.isParallel()) {
-                s = s.sequential();
-            }
-            s.forEach(b);
-        }
-    },
-
-    STREAM_TO_ARRAY(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            for (long t : m.apply(source).toArray()) {
-                b.accept(t);
-            }
-        }
-    },
-
-    STREAM_ITERATOR(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            for (PrimitiveIterator.OfLong seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
-                b.accept(seqIter.nextLong());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            for (Spliterator.OfLong spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
-    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR_FOREACH(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            m.apply(source).sequential().forEach(b);
-        }
-    },
-
-    // Wrap as parallel stream + forEachOrdered
-    PAR_STREAM_FOR_EACH_ORDERED(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            // @@@ Want to explicitly select ordered equalator
-            m.apply(source).forEachOrdered(b);
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            for (Spliterator.OfLong spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR_FOREACH(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    PAR_STREAM_TO_ARRAY(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            for (long t : m.apply(source).toArray())
-                b.accept(t);
-        }
-    },
-
-    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
-    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            LongStream s = m.apply(source);
-            Spliterator.OfLong sp = s.spliterator();
-            LongStream ss = StreamSupport.longStream(() -> sp,
-                                                     StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
-                                                     | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
-            for (long t : ss.toArray())
-                b.accept(t);
-        }
-    },
-
-    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            LongStream pipe2 = m.apply(pipe1);
-
-            for (long t : pipe2.toArray())
-                b.accept(t);
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing
-    PAR_STREAM_FOR_EACH(true, false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            m.apply(source).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
-    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            m.apply(pipe1).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-    ;
-
-    // The set of scenarios that clean the SIZED flag
-    public static final Set<LongStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
-            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
-
-    private boolean isParallel;
-
-    private final boolean isOrdered;
-
-    LongStreamTestScenario(boolean isParallel) {
-        this(isParallel, true);
-    }
-
-    LongStreamTestScenario(boolean isParallel, boolean isOrdered) {
-        this.isParallel = isParallel;
-        this.isOrdered = isOrdered;
-    }
-
-    public StreamShape getShape() {
-        return StreamShape.LONG_VALUE;
-    }
-
-    public boolean isParallel() {
-        return isParallel;
-    }
-
-    public boolean isOrdered() {
-        return isOrdered;
-    }
-
-    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
-        try (S_IN source = getStream(data)) {
-            run(data, source, (LongConsumer) b, (Function<S_IN, LongStream>) m);
-        }
-    }
-
-    abstract <T, S_IN extends BaseStream<T, S_IN>>
-    void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m);
-
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/OpTestCase.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,682 +0,0 @@
-/*
- * Copyright (c) 2012, 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.Spliterator;
-import java.util.function.BiConsumer;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
-import org.testng.annotations.Test;
-
-/**
- * Base class for streams test cases.  Provides 'exercise' methods for taking
- * lambdas that construct and modify streams, and evaluates them in different
- * ways and asserts that they produce equivalent results.
- */
-@Test
-public abstract class OpTestCase extends LoggingTestCase {
-
-    private final Map<StreamShape, Set<? extends BaseStreamTestScenario>> testScenarios;
-
-    protected OpTestCase() {
-        testScenarios = new EnumMap<>(StreamShape.class);
-        testScenarios.put(StreamShape.REFERENCE, Collections.unmodifiableSet(EnumSet.allOf(StreamTestScenario.class)));
-        testScenarios.put(StreamShape.INT_VALUE, Collections.unmodifiableSet(EnumSet.allOf(IntStreamTestScenario.class)));
-        testScenarios.put(StreamShape.LONG_VALUE, Collections.unmodifiableSet(EnumSet.allOf(LongStreamTestScenario.class)));
-        testScenarios.put(StreamShape.DOUBLE_VALUE, Collections.unmodifiableSet(EnumSet.allOf(DoubleStreamTestScenario.class)));
-    }
-
-    @SuppressWarnings("rawtypes")
-    public static int getStreamFlags(BaseStream s) {
-        return ((AbstractPipeline) s).getStreamFlags();
-    }
-
-    /**
-     * An asserter for results produced when exercising of stream or terminal
-     * tests.
-     *
-     * @param <R> the type of result to assert on
-     */
-    public interface ResultAsserter<R> {
-        /**
-         * Assert a result produced when exercising of stream or terminal
-         * test.
-         *
-         * @param actual the actual result
-         * @param expected the expected result
-         * @param isOrdered true if the pipeline is ordered
-         * @param isParallel true if the pipeline is parallel
-         */
-        void assertResult(R actual, R expected, boolean isOrdered, boolean isParallel);
-    }
-
-    // Exercise stream operations
-
-    public interface BaseStreamTestScenario {
-        StreamShape getShape();
-
-        boolean isParallel();
-
-        boolean isOrdered();
-
-        default <T, S_IN extends BaseStream<T, S_IN>>
-        S_IN getStream(TestData<T, S_IN> data) {
-            return isParallel()
-                   ? data.parallelStream()
-                   : data.stream();
-        }
-
-        <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-        void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m);
-    }
-
-    protected <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    Collection<U> exerciseOps(TestData<T, S_IN> data, Function<S_IN, S_OUT> m) {
-        return withData(data).stream(m).exercise();
-    }
-
-    // Run multiple versions of exercise(), returning the result of the first, and asserting that others return the same result
-    // If the first version is s -> s.foo(), can be used with s -> s.mapToInt(i -> i).foo().mapToObj(i -> i) to test all shape variants
-    @SafeVarargs
-    protected final<T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    Collection<U> exerciseOpsMulti(TestData<T, S_IN> data,
-                                   Function<S_IN, S_OUT>... ms) {
-        Collection<U> result = null;
-        for (Function<S_IN, S_OUT> m : ms) {
-            if (result == null)
-                result = withData(data).stream(m).exercise();
-            else {
-                Collection<U> r2 = withData(data).stream(m).exercise();
-                assertEquals(result, r2);
-            }
-        }
-        return result;
-    }
-
-    // Run multiple versions of exercise() for an Integer stream, returning the result of the first, and asserting that others return the same result
-    // Automates the conversion between Stream<Integer> and {Int,Long,Double}Stream and back, so client sites look like you are passing the same
-    // lambda four times, but in fact they are four different lambdas since they are transforming four different kinds of streams
-    protected final
-    Collection<Integer> exerciseOpsInt(TestData.OfRef<Integer> data,
-                                       Function<Stream<Integer>, Stream<Integer>> mRef,
-                                       Function<IntStream, IntStream> mInt,
-                                       Function<LongStream, LongStream> mLong,
-                                       Function<DoubleStream, DoubleStream> mDouble) {
-        @SuppressWarnings({ "rawtypes", "unchecked" })
-        Function<Stream<Integer>, Stream<Integer>>[] ms = new Function[4];
-        ms[0] = mRef;
-        ms[1] = s -> mInt.apply(s.mapToInt(e -> e)).mapToObj(e -> e);
-        ms[2] = s -> mLong.apply(s.mapToLong(e -> e)).mapToObj(e -> (int) e);
-        ms[3] = s -> mDouble.apply(s.mapToDouble(e -> e)).mapToObj(e -> (int) e);
-        return exerciseOpsMulti(data, ms);
-    }
-
-    // Run multiple versions of exercise() with multiple terminal operations for all kinds of stream, , and asserting against the expected result
-    // If the first version is s -> s.foo(), can be used with s -> s.mapToInt(i -> i).foo().mapToObj(i -> i) to test all shape variants
-    protected final<T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    void exerciseTerminalOpsMulti(TestData<T, S_IN> data,
-                                  R expected,
-                                  Map<String, Function<S_IN, S_OUT>> streams,
-                                  Map<String, Function<S_OUT, R>> terminals) {
-        for (Map.Entry<String, Function<S_IN, S_OUT>> se : streams.entrySet()) {
-            setContext("Intermediate stream", se.getKey());
-            for (Map.Entry<String, Function<S_OUT, R>> te : terminals.entrySet()) {
-                setContext("Terminal stream", te.getKey());
-                withData(data)
-                        .terminal(se.getValue(), te.getValue())
-                        .expectedResult(expected)
-                        .exercise();
-
-            }
-        }
-    }
-
-    // Run multiple versions of exercise() with multiple terminal operation for all kinds of stream, and asserting against the expected result
-    // Automates the conversion between Stream<Integer> and {Int,Long,Double}Stream and back, so client sites look like you are passing the same
-    // lambda four times, but in fact they are four different lambdas since they are transforming four different kinds of streams
-    protected final
-    void exerciseTerminalOpsInt(TestData<Integer, Stream<Integer>> data,
-                                Collection<Integer> expected,
-                                String desc,
-                                Function<Stream<Integer>, Stream<Integer>> mRef,
-                                Function<IntStream, IntStream> mInt,
-                                Function<LongStream, LongStream> mLong,
-                                Function<DoubleStream, DoubleStream> mDouble,
-                                Map<String, Function<Stream<Integer>, Collection<Integer>>> terminals) {
-
-        Map<String, Function<Stream<Integer>, Stream<Integer>>> m = new HashMap<>();
-        m.put("Ref " + desc, mRef);
-        m.put("Int " + desc, s -> mInt.apply(s.mapToInt(e -> e)).mapToObj(e -> e));
-        m.put("Long " + desc, s -> mLong.apply(s.mapToLong(e -> e)).mapToObj(e -> (int) e));
-        m.put("Double " + desc, s -> mDouble.apply(s.mapToDouble(e -> e)).mapToObj(e -> (int) e));
-
-        exerciseTerminalOpsMulti(data, expected, m, terminals);
-    }
-
-
-    protected <T, U, S_OUT extends BaseStream<U, S_OUT>>
-    Collection<U> exerciseOps(Collection<T> data, Function<Stream<T>, S_OUT> m) {
-        TestData.OfRef<T> data1 = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
-        return withData(data1).stream(m).exercise();
-    }
-
-    protected <T, U, S_OUT extends BaseStream<U, S_OUT>, I extends Iterable<U>>
-    Collection<U> exerciseOps(Collection<T> data, Function<Stream<T>, S_OUT> m, I expected) {
-        TestData.OfRef<T> data1 = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
-        return withData(data1).stream(m).expectedResult(expected).exercise();
-    }
-
-    @SuppressWarnings("unchecked")
-    protected <U, S_OUT extends BaseStream<U, S_OUT>>
-    Collection<U> exerciseOps(int[] data, Function<IntStream, S_OUT> m) {
-        return withData(TestData.Factory.ofArray("int array", data)).stream(m).exercise();
-    }
-
-    protected Collection<Integer> exerciseOps(int[] data, Function<IntStream, IntStream> m, int[] expected) {
-        TestData.OfInt data1 = TestData.Factory.ofArray("int array", data);
-        return withData(data1).stream(m).expectedResult(expected).exercise();
-    }
-
-    protected <T, S_IN extends BaseStream<T, S_IN>> DataStreamBuilder<T, S_IN> withData(TestData<T, S_IN> data) {
-        Objects.requireNonNull(data);
-        return new DataStreamBuilder<>(data);
-    }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public class DataStreamBuilder<T, S_IN extends BaseStream<T, S_IN>> {
-        final TestData<T, S_IN> data;
-
-        private DataStreamBuilder(TestData<T, S_IN> data) {
-            this.data = Objects.requireNonNull(data);
-        }
-
-        public <U, S_OUT extends BaseStream<U, S_OUT>>
-        ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> ops(IntermediateTestOp... ops) {
-            return new ExerciseDataStreamBuilder<>(data, (S_IN s) -> (S_OUT) chain(s, ops));
-        }
-
-        public <U, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT>
-        stream(Function<S_IN, S_OUT> m) {
-            return new ExerciseDataStreamBuilder<>(data, m);
-        }
-
-        public <U, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT>
-        stream(Function<S_IN, S_OUT> m, IntermediateTestOp<U, U> additionalOp) {
-            return new ExerciseDataStreamBuilder<>(data, s -> (S_OUT) chain(m.apply(s), additionalOp));
-        }
-
-        public <R> ExerciseDataTerminalBuilder<T, T, R, S_IN, S_IN>
-        terminal(Function<S_IN, R> terminalF) {
-            return new ExerciseDataTerminalBuilder<>(data, s -> s, terminalF);
-        }
-
-        public <U, R, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT>
-        terminal(Function<S_IN, S_OUT> streamF, Function<S_OUT, R> terminalF) {
-            return new ExerciseDataTerminalBuilder<>(data, streamF, terminalF);
-        }
-    }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public class ExerciseDataStreamBuilder<T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> {
-        final TestData<T, S_IN> data;
-        final Function<S_IN, S_OUT> m;
-        final StreamShape shape;
-
-        Set<BaseStreamTestScenario> testSet = new HashSet<>();
-
-        Collection<U> refResult;
-
-        Consumer<TestData<T, S_IN>> before = LambdaTestHelpers.bEmpty;
-
-        Consumer<TestData<T, S_IN>> after = LambdaTestHelpers.bEmpty;
-
-        ResultAsserter<Iterable<U>> resultAsserter = (act, exp, ord, par) -> {
-            if (par & !ord) {
-                LambdaTestHelpers.assertContentsUnordered(act, exp);
-            }
-            else {
-                LambdaTestHelpers.assertContentsEqual(act, exp);
-            }
-        };
-
-        private ExerciseDataStreamBuilder(TestData<T, S_IN> data, Function<S_IN, S_OUT> m) {
-            this.data = data;
-
-            this.m = Objects.requireNonNull(m);
-
-            this.shape = ((AbstractPipeline<?, U, ?>) m.apply(data.stream())).getOutputShape();
-
-            // Have to initiate from the output shape of the last stream
-            // This means the stream mapper is required first rather than last
-            testSet.addAll(testScenarios.get(shape));
-        }
-
-        //
-
-        public <I extends Iterable<U>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(I expectedResult) {
-            List<U> l = new ArrayList<>();
-            expectedResult.forEach(l::add);
-            refResult = l;
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(int[] expectedResult) {
-            List l = new ArrayList();
-            for (int anExpectedResult : expectedResult) {
-                l.add(anExpectedResult);
-            }
-            refResult = l;
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(long[] expectedResult) {
-            List l = new ArrayList();
-            for (long anExpectedResult : expectedResult) {
-                l.add(anExpectedResult);
-            }
-            refResult = l;
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(double[] expectedResult) {
-            List l = new ArrayList();
-            for (double anExpectedResult : expectedResult) {
-                l.add(anExpectedResult);
-            }
-            refResult = l;
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> before(Consumer<TestData<T, S_IN>> before) {
-            this.before = Objects.requireNonNull(before);
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> after(Consumer<TestData<T, S_IN>> after) {
-            this.after = Objects.requireNonNull(after);
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> without(BaseStreamTestScenario... tests) {
-            return without(Arrays.asList(tests));
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> without(Collection<? extends BaseStreamTestScenario> tests) {
-            for (BaseStreamTestScenario ts : tests) {
-                if (ts.getShape() == shape) {
-                    testSet.remove(ts);
-                }
-            }
-
-            if (testSet.isEmpty()) {
-                throw new IllegalStateException("Test scenario set is empty");
-            }
-
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> with(BaseStreamTestScenario... tests) {
-            return with(Arrays.asList(tests));
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> with(Collection<? extends BaseStreamTestScenario> tests) {
-            testSet = new HashSet<>();
-
-            for (BaseStreamTestScenario ts : tests) {
-                if (ts.getShape() == shape) {
-                    testSet.add(ts);
-                }
-            }
-
-            if (testSet.isEmpty()) {
-                throw new IllegalStateException("Test scenario set is empty");
-            }
-
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> resultAsserter(ResultAsserter<Iterable<U>> resultAsserter) {
-            this.resultAsserter = resultAsserter;
-            return this;
-        }
-
-        // Build method
-
-        public Collection<U> exercise() {
-            final boolean isStreamOrdered;
-            if (refResult == null) {
-                // Induce the reference result
-                before.accept(data);
-                try (S_OUT sOut = m.apply(data.stream())) {
-                    isStreamOrdered = StreamOpFlag.ORDERED.isKnown(((AbstractPipeline) sOut).getStreamFlags());
-                    Node<U> refNodeResult = ((AbstractPipeline<?, U, ?>) sOut).evaluateToArrayNode(size -> (U[]) new Object[size]);
-                    refResult = LambdaTestHelpers.toBoxedList(refNodeResult.spliterator());
-                }
-                after.accept(data);
-            }
-            else {
-                try (S_OUT sOut = m.apply(data.stream())) {
-                    isStreamOrdered = StreamOpFlag.ORDERED.isKnown(((AbstractPipeline) sOut).getStreamFlags());
-                }
-            }
-
-            List<Error> errors = new ArrayList<>();
-            for (BaseStreamTestScenario test : testSet) {
-                try {
-                    before.accept(data);
-
-                    List<U> result = new ArrayList<>();
-                    test.run(data, LambdaTestHelpers.<U>toBoxingConsumer(result::add), m);
-
-                    Runnable asserter = () -> resultAsserter.assertResult(result, refResult, isStreamOrdered && test.isOrdered(), test.isParallel());
-
-                    if (refResult.size() > 1000) {
-                        LambdaTestHelpers.launderAssertion(
-                                asserter,
-                                () -> String.format("%n%s: [actual size=%d] != [expected size=%d]", test, result.size(), refResult.size()));
-                    }
-                    else {
-                        LambdaTestHelpers.launderAssertion(
-                                asserter,
-                                () -> String.format("%n%s: [actual] %s != [expected] %s", test, result, refResult));
-                    }
-
-                    after.accept(data);
-                } catch (Throwable t) {
-                    errors.add(new Error(String.format("%s: %s", test, t), t));
-                }
-            }
-
-            if (!errors.isEmpty()) {
-                StringBuilder sb = new StringBuilder();
-                int i = 1;
-                for (Error t : errors) {
-                    sb.append(i++).append(": ");
-                    if (t instanceof AssertionError) {
-                        sb.append(t).append("\n");
-                    }
-                    else {
-                        StringWriter sw = new StringWriter();
-                        PrintWriter pw = new PrintWriter(sw);
-
-                        t.getCause().printStackTrace(pw);
-                        pw.flush();
-                        sb.append(t).append("\n").append(sw);
-                    }
-                }
-                sb.append("--");
-
-                fail(String.format("%d failure(s) for test data: %s\n%s", i - 1, data.toString(), sb));
-            }
-
-            return refResult;
-        }
-    }
-
-    // Exercise terminal operations
-
-    interface BaseTerminalTestScenario<U, R, S_OUT extends BaseStream<U, S_OUT>> {
-        boolean requiresSingleStageSource();
-
-        boolean requiresParallelSource();
-
-        default R run(Function<S_OUT, R> terminalF, S_OUT source, StreamShape shape) {
-            return terminalF.apply(source);
-        }
-    }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    enum TerminalTestScenario implements BaseTerminalTestScenario {
-        SINGLE_SEQUENTIAL(true, false),
-
-        SINGLE_SEQUENTIAL_SHORT_CIRCUIT(true, false) {
-            @Override
-            public Object run(Function terminalF, BaseStream source, StreamShape shape) {
-                source = (BaseStream) chain(source, new ShortCircuitOp(shape));
-                return terminalF.apply(source);
-            }
-        },
-
-        SINGLE_PARALLEL(true, true),
-
-        ALL_SEQUENTIAL(false, false),
-
-        ALL_SEQUENTIAL_SHORT_CIRCUIT(false, false) {
-            @Override
-            public Object run(Function terminalF, BaseStream source, StreamShape shape) {
-                source = (BaseStream) chain(source, new ShortCircuitOp(shape));
-                return terminalF.apply(source);
-            }
-        },
-
-        ALL_PARALLEL(false, true),
-
-        ALL_PARALLEL_SEQUENTIAL(false, false) {
-            @Override
-            public Object run(Function terminalF, BaseStream source, StreamShape shape) {
-                return terminalF.apply(source.sequential());
-            }
-        },
-        ;
-
-        private final boolean requiresSingleStageSource;
-        private final boolean isParallel;
-
-        TerminalTestScenario(boolean requiresSingleStageSource, boolean isParallel) {
-            this.requiresSingleStageSource = requiresSingleStageSource;
-            this.isParallel = isParallel;
-        }
-
-        @Override
-        public boolean requiresSingleStageSource() {
-            return requiresSingleStageSource;
-        }
-
-        @Override
-        public boolean requiresParallelSource() {
-            return isParallel;
-        }
-
-    }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public class ExerciseDataTerminalBuilder<T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> {
-        final TestData<T, S_IN> data;
-        final Function<S_IN, S_OUT> streamF;
-        final Function<S_OUT, R> terminalF;
-
-        R refResult;
-
-        ResultAsserter<R> resultAsserter = (act, exp, ord, par) -> LambdaTestHelpers.assertContentsEqual(act, exp);
-
-        private ExerciseDataTerminalBuilder(TestData<T, S_IN> data, Function<S_IN, S_OUT> streamF, Function<S_OUT, R> terminalF) {
-            this.data = data;
-            this.streamF = Objects.requireNonNull(streamF);
-            this.terminalF = Objects.requireNonNull(terminalF);
-        }
-
-        //
-
-        public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> expectedResult(R expectedResult) {
-            this.refResult = expectedResult;
-            return this;
-        }
-
-        public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> equalator(BiConsumer<R, R> equalityAsserter) {
-            resultAsserter = (act, exp, ord, par) -> equalityAsserter.accept(act, exp);
-            return this;
-        }
-
-        public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> resultAsserter(ResultAsserter<R> resultAsserter) {
-            this.resultAsserter = resultAsserter;
-            return this;
-        }
-
-        // Build method
-
-        public R exercise() {
-            boolean isOrdered;
-            StreamShape shape;
-            Node<U> node;
-            try (S_OUT out = streamF.apply(data.stream()).sequential()) {
-                AbstractPipeline ap = (AbstractPipeline) out;
-                isOrdered = StreamOpFlag.ORDERED.isKnown(ap.getStreamFlags());
-                shape = ap.getOutputShape();
-                // Sequentially collect the output that will be input to the terminal op
-                node = ap.evaluateToArrayNode(size -> (U[]) new Object[size]);
-            }
-
-            EnumSet<TerminalTestScenario> tests = EnumSet.allOf(TerminalTestScenario.class);
-            if (refResult == null) {
-                // Induce the reference result
-                S_OUT source = (S_OUT) createPipeline(shape, node.spliterator(),
-                                                      StreamOpFlag.IS_ORDERED | StreamOpFlag.IS_SIZED,
-                                                      false);
-
-                refResult = (R) TerminalTestScenario.SINGLE_SEQUENTIAL.run(terminalF, source, shape);
-                tests.remove(TerminalTestScenario.SINGLE_SEQUENTIAL);
-            }
-
-            for (BaseTerminalTestScenario test : tests) {
-                S_OUT source;
-                if (test.requiresSingleStageSource()) {
-                    source = (S_OUT) createPipeline(shape, node.spliterator(),
-                                                    StreamOpFlag.IS_ORDERED | StreamOpFlag.IS_SIZED,
-                                                    test.requiresParallelSource());
-                }
-                else {
-                    source = streamF.apply(test.requiresParallelSource()
-                                           ? data.parallelStream() : data.stream());
-                }
-
-                R result;
-                try (source) {
-                    result = (R) test.run(terminalF, source, shape);
-                }
-                LambdaTestHelpers.launderAssertion(
-                        () -> resultAsserter.assertResult(result, refResult, isOrdered, test.requiresParallelSource()),
-                        () -> String.format("%s: %s != %s", test, refResult, result));
-            }
-
-            return refResult;
-        }
-
-        AbstractPipeline createPipeline(StreamShape shape, Spliterator s, int flags, boolean parallel) {
-            switch (shape) {
-                case REFERENCE:    return new ReferencePipeline.Head<>(s, flags, parallel);
-                case INT_VALUE:    return new IntPipeline.Head(s, flags, parallel);
-                case LONG_VALUE:   return new LongPipeline.Head(s, flags, parallel);
-                case DOUBLE_VALUE: return new DoublePipeline.Head(s, flags, parallel);
-                default: throw new IllegalStateException("Unknown shape: " + shape);
-            }
-        }
-    }
-
-    protected <T, R> R exerciseTerminalOps(Collection<T> data, Function<Stream<T>, R> m, R expected) {
-        TestData.OfRef<T> data1
-                = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
-        return withData(data1).terminal(m).expectedResult(expected).exercise();
-    }
-
-    protected <T, R, S_IN extends BaseStream<T, S_IN>> R
-    exerciseTerminalOps(TestData<T, S_IN> data,
-                        Function<S_IN, R> terminalF) {
-        return withData(data).terminal(terminalF).exercise();
-    }
-
-    protected <T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> R
-    exerciseTerminalOps(TestData<T, S_IN> data,
-                        Function<S_IN, S_OUT> streamF,
-                        Function<S_OUT, R> terminalF) {
-        return withData(data).terminal(streamF, terminalF).exercise();
-    }
-
-    //
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    private static <T> AbstractPipeline<?, T, ?> chain(AbstractPipeline upstream, IntermediateTestOp<?, T> op) {
-        return (AbstractPipeline<?, T, ?>) IntermediateTestOp.chain(upstream, op);
-    }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    private static AbstractPipeline<?, ?, ?> chain(AbstractPipeline pipe, IntermediateTestOp... ops) {
-        for (IntermediateTestOp op : ops)
-            pipe = chain(pipe, op);
-        return pipe;
-    }
-
-    @SuppressWarnings("rawtypes")
-    private static <T> AbstractPipeline<?, T, ?> chain(BaseStream pipe, IntermediateTestOp<?, T> op) {
-        return chain((AbstractPipeline) pipe, op);
-    }
-
-    @SuppressWarnings("rawtypes")
-    public static AbstractPipeline<?, ?, ?> chain(BaseStream pipe, IntermediateTestOp... ops) {
-        return chain((AbstractPipeline) pipe, ops);
-    }
-
-    // Test data
-
-    static class ShortCircuitOp<T> implements StatelessTestOp<T,T> {
-        private final StreamShape shape;
-
-        ShortCircuitOp(StreamShape shape) {
-            this.shape = shape;
-        }
-
-        @Override
-        public Sink<T> opWrapSink(int flags, boolean parallel, Sink<T> sink) {
-            return sink;
-        }
-
-        @Override
-        public int opGetFlags() {
-            return StreamOpFlag.IS_SHORT_CIRCUIT;
-        }
-
-        @Override
-        public StreamShape outputShape() {
-            return shape;
-        }
-
-        @Override
-        public StreamShape inputShape() {
-            return shape;
-        }
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StatefulTestOp.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2012, 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.
- */
-package java.util.stream;
-
-import java.util.Spliterator;
-import java.util.function.IntFunction;
-
-/**
- * The base type for a stateful test operation.
- */
-interface StatefulTestOp<E> extends IntermediateTestOp<E, E> {
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public static<T> AbstractPipeline chain(AbstractPipeline upstream,
-                                            StatefulTestOp op) {
-        switch (op.outputShape()) {
-            case REFERENCE:
-                return new ReferencePipeline.StatefulOp<Object, T>(upstream, op.inputShape(), op.opGetFlags()) {
-                    @Override
-                    Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-
-                    @Override
-                    <P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper,
-                                                                 Spliterator<P_IN> spliterator) {
-                        return op.opEvaluateParallelLazy(helper, spliterator);
-                    }
-
-                    @Override
-                    <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
-                                                      Spliterator<P_IN> spliterator,
-                                                      IntFunction<T[]> generator) {
-                        return op.opEvaluateParallel(helper, spliterator, generator);
-                    }
-                };
-            case INT_VALUE:
-                return new IntPipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
-                    @Override
-                    Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-
-                    @Override
-                    <P_IN> Spliterator<Integer> opEvaluateParallelLazy(PipelineHelper<Integer> helper,
-                                                                 Spliterator<P_IN> spliterator) {
-                        return op.opEvaluateParallelLazy(helper, spliterator);
-                    }
-
-                    @Override
-                    <P_IN> Node<Integer> opEvaluateParallel(PipelineHelper<Integer> helper,
-                                                            Spliterator<P_IN> spliterator,
-                                                            IntFunction<Integer[]> generator) {
-                        return (Node<Integer>) op.opEvaluateParallel(helper, spliterator, generator);
-                    }
-                };
-            case LONG_VALUE:
-                return new LongPipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
-                    @Override
-                    Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-
-                    @Override
-                    <P_IN> Spliterator<Long> opEvaluateParallelLazy(PipelineHelper<Long> helper,
-                                                                 Spliterator<P_IN> spliterator) {
-                        return op.opEvaluateParallelLazy(helper, spliterator);
-                    }
-
-                    @Override
-                    <P_IN> Node<Long> opEvaluateParallel(PipelineHelper<Long> helper,
-                                                         Spliterator<P_IN> spliterator,
-                                                         IntFunction<Long[]> generator) {
-                        return (Node<Long>) op.opEvaluateParallel(helper, spliterator, generator);
-                    }
-                };
-            case DOUBLE_VALUE:
-                return new DoublePipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
-                    @Override
-                    Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-
-                    @Override
-                    <P_IN> Spliterator<Double> opEvaluateParallelLazy(PipelineHelper<Double> helper,
-                                                                    Spliterator<P_IN> spliterator) {
-                        return op.opEvaluateParallelLazy(helper, spliterator);
-                    }
-
-                    @Override
-                    <P_IN> Node<Double> opEvaluateParallel(PipelineHelper<Double> helper,
-                                                           Spliterator<P_IN> spliterator,
-                                                           IntFunction<Double[]> generator) {
-                        return (Node<Double>) op.opEvaluateParallel(helper, spliterator, generator);
-                    }
-                };
-            default: throw new IllegalStateException(op.outputShape().toString());
-        }
-    }
-
-    default StreamShape inputShape() { return StreamShape.REFERENCE; }
-
-    default StreamShape outputShape() { return StreamShape.REFERENCE; }
-
-    default int opGetFlags() { return 0; }
-
-    Sink<E> opWrapSink(int flags, boolean parallel, Sink<E> sink);
-
-    @SuppressWarnings("unchecked")
-    default <P_IN> Spliterator<E> opEvaluateParallelLazy(PipelineHelper<E> helper,
-                                                         Spliterator<P_IN> spliterator) {
-        return opEvaluateParallel(helper, spliterator, i -> (E[]) new Object[i]).spliterator();
-    }
-
-    <P_IN> Node<E> opEvaluateParallel(PipelineHelper<E> helper,
-                                      Spliterator<P_IN> spliterator,
-                                      IntFunction<E[]> generator);
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StatelessTestOp.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +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.
- */
-package java.util.stream;
-
-/**
- * The base type of a stateless test operation
- */
-interface StatelessTestOp<E_IN, E_OUT> extends IntermediateTestOp<E_IN, E_OUT> {
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public static<T> AbstractPipeline chain(AbstractPipeline upstream,
-                                            StatelessTestOp<?, T> op) {
-        int flags = op.opGetFlags();
-        switch (op.outputShape()) {
-            case REFERENCE:
-                return new ReferencePipeline.StatelessOp<Object, T>(upstream, op.inputShape(), flags) {
-                    public Sink opWrapSink(int flags, Sink<T> sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-                };
-            case INT_VALUE:
-                return new IntPipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
-                    public Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-                };
-            case LONG_VALUE:
-                return new LongPipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
-                    @Override
-                    Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-                };
-            case DOUBLE_VALUE:
-                return new DoublePipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
-                    @Override
-                    Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-                };
-            default: throw new IllegalStateException(op.outputShape().toString());
-        }
-    }
-
-    default StreamShape inputShape() { return StreamShape.REFERENCE; }
-
-    default StreamShape outputShape() { return StreamShape.REFERENCE; }
-
-    default int opGetFlags() { return 0; }
-
-    Sink<E_IN> opWrapSink(int flags, boolean parallel, Sink<E_OUT> sink);
-}
-
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamOpFlagTestHelper.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2012, 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.
- */
-package java.util.stream;
-
-import java.util.EnumSet;
-
-public class StreamOpFlagTestHelper {
-
-    /** EnumSet containing stream flags */
-    private static final EnumSet<StreamOpFlag> allStreamFlags;
-
-    static {
-        allStreamFlags = EnumSet.allOf(StreamOpFlag.class);
-        for (StreamOpFlag f : EnumSet.allOf(StreamOpFlag.class))
-            if (!f.isStreamFlag())
-                allStreamFlags.remove(f);
-    }
-
-
-    static EnumSet<StreamOpFlag> allStreamFlags() {
-        // EnumSet is mutable
-        return allStreamFlags.clone();
-    }
-
-    public static boolean isStreamOrdered(Stream<?> s) {
-        return StreamOpFlag.ORDERED.isKnown(OpTestCase.getStreamFlags(s));
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamTestDataProvider.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,228 +0,0 @@
-/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import org.testng.annotations.DataProvider;
-
-import java.util.*;
-import java.util.Spliterators;
-import java.util.function.Supplier;
-
-/**
- * StreamTestDataProvider
- *
- * @author Brian Goetz
- */
-/** TestNG DataProvider for ref-valued streams */
-public class StreamTestDataProvider {
-    private static final Integer[] to0 = new Integer[0];
-    private static final Integer[] to1 = new Integer[1];
-    private static final Integer[] to10 = new Integer[10];
-    private static final Integer[] to100 = new Integer[100];
-    private static final Integer[] to1000 = new Integer[1000];
-    private static final Integer[] reversed = new Integer[100];
-    private static final Integer[] ones = new Integer[100];
-    private static final Integer[] twice = new Integer[200];
-    private static final Integer[] pseudoRandom;
-
-    private static final Object[][] testData;
-    private static final Object[][] testSmallData;
-    private static final Object[][] testMiniData;
-    private static final Object[][] withNullTestData;
-    private static final Object[][] spliteratorTestData;
-
-    static {
-        Integer[][] arrays = {to0, to1, to10, to100, to1000};
-        for (Integer[] arr : arrays) {
-            for (int i = 0; i < arr.length; i++) {
-                arr[i] = i;
-            }
-        }
-        for (int i = 0; i < reversed.length; i++) {
-            reversed[i] = reversed.length - i;
-        }
-        for (int i = 0; i < ones.length; i++) {
-            ones[i] = 1;
-        }
-        System.arraycopy(to100, 0, twice, 0, to100.length);
-        System.arraycopy(to100, 0, twice, to100.length, to100.length);
-        pseudoRandom = new Integer[LambdaTestHelpers.LONG_STRING.length()];
-        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
-            pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
-        }
-    }
-
-    static final Object[][] arrays = {
-            {"empty", to0},
-            {"0..1", to1},
-            {"0..10", to10},
-            {"0..100", to100},
-            {"0..1000", to1000},
-            {"100x[1]", ones},
-            {"2x[0..100]", twice},
-            {"reverse 0..100", reversed},
-            {"pseudorandom", pseudoRandom}
-    };
-
-    static {
-        {
-            List<Object[]> listMini = new ArrayList<>();
-            List<Object[]> listSmall = new ArrayList<>();
-            List<Object[]> list1000 = new ArrayList<>();
-            List<Object[]> list = null;
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final Integer[] ints = (Integer[])data[1];
-                final List<Integer> intsAsList = Arrays.asList(ints);
-
-                list = ints.length >= 1000 ? list1000 : (ints.length >= 100 ? listSmall : listMini);
-
-                list.add(arrayDataDescr("array:" + name, ints));
-                list.add(collectionDataDescr("ArrayList.asList:" + name, intsAsList));
-                list.add(collectionDataDescr("ArrayList:" + name, new ArrayList<>(intsAsList)));
-                list.add(streamDataDescr("DelegatingStream(ArrayList):" + name,
-                                         () -> new ArrayList<>(intsAsList).stream()));
-                List<Integer> aList = new ArrayList<>(intsAsList);
-                if (LambdaTestMode.isNormalMode()) {
-                    // Only include sub-lists for normal test execution mode
-                    // This data is serialization-hostile since the state of the
-                    // deserialized sub-list will be out of sync with the
-                    // enclosing list.
-                    list.add(collectionDataDescr("ArrayList.Sublist:" + name,
-                                                 (ints.length) <= 1 ? aList.subList(0, 0) : aList.subList(1, ints.length / 2)));
-                }
-                list.add(collectionDataDescr("LinkedList:" + name, new LinkedList<>(intsAsList)));
-                list.add(collectionDataDescr("HashSet:" + name, new HashSet<>(intsAsList)));
-                list.add(collectionDataDescr("LinkedHashSet:" + name, new LinkedHashSet<>(intsAsList)));
-                list.add(collectionDataDescr("TreeSet:" + name, new TreeSet<>(intsAsList)));
-                SpinedBuffer<Integer> spinedBuffer = new SpinedBuffer<>();
-                intsAsList.forEach(spinedBuffer);
-                list.add(sbDataDescr("SpinedBuffer:" + name, spinedBuffer));
-
-                // @@@ Add more
-            }
-            testMiniData = listMini.toArray(new Object[0][]);
-            listSmall.addAll(listMini);
-            testSmallData = listSmall.toArray(new Object[0][]);
-            list1000.addAll(listSmall);
-            testData = list1000.toArray(new Object[0][]);
-        }
-
-        // Simple combination of numbers and null values, probably excessive but may catch
-        // errors for initialization/termination/sequence
-        // @@@ This is separate from the other data for now until nulls are consistently supported by
-        // all operations
-        {
-            List<Object[]> list = new ArrayList<>();
-            int size = 5;
-            for (int i = 0; i < (1 << size) - 2; i++) {
-                Integer[] content = new Integer[size];
-                for (int e = 0; e < size; e++) {
-                    content[e] = (i & (1 << e)) > 0 ? e + 1 : null;
-                }
-
-                // ORDERED
-                list.add(arrayDataDescr("array:" + i, content));
-                // not ORDERED, DISTINCT
-                list.add(collectionDataDescr("HashSet:" + i, new HashSet<>(Arrays.asList(content))));
-            }
-
-            withNullTestData = list.toArray(new Object[0][]);
-        }
-
-        {
-            List<Object[]> spliterators = new ArrayList<>();
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final Integer[] ints = (Integer[])data[1];
-
-                spliterators.add(splitDescr("Arrays.s(array):" + name,
-                                            () -> Arrays.spliterator(ints)));
-                spliterators.add(splitDescr("arrays.s(array,o,l):" + name,
-                                            () -> Arrays.spliterator(ints, 0, ints.length/2)));
-                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
-                                            () -> {
-                                                SpinedBuffer<Integer> sb = new SpinedBuffer<>();
-                                                for (Integer i : ints)
-                                                    sb.accept(i);
-                                                return sb.spliterator();
-                                            }));
-                spliterators.add(splitDescr("Iterators.s(Arrays.s(array).iterator(), size):" + name,
-                                            () -> Spliterators.spliterator(Arrays.asList(ints).iterator(), ints.length, 0)));
-                spliterators.add(splitDescr("Iterators.s(Arrays.s(array).iterator()):" + name,
-                                            () -> Spliterators.spliteratorUnknownSize(Arrays.asList(ints).iterator(), 0)));
-                spliterators.add(splitDescr("Stream.iterate(0,x->x<l,x->x+1): " + name,
-                                            () -> Stream.iterate(0, x -> x < ints.length, x -> x + 1).spliterator()));
-                // @@@ Add map and collection spliterators when spliterator() is exposed on Collection or Iterable
-            }
-            spliteratorTestData = spliterators.toArray(new Object[0][]);
-        }
-    }
-
-    static <T> Object[] arrayDataDescr(String description, T[] data) {
-        return new Object[] { description, TestData.Factory.ofArray(description, data)};
-    }
-
-    static <T> Object[] streamDataDescr(String description, Supplier<Stream<T>> supplier) {
-        return new Object[] { description, TestData.Factory.ofSupplier(description, supplier)};
-    }
-
-    static <T> Object[] collectionDataDescr(String description, Collection<T> data) {
-        return new Object[] { description, TestData.Factory.ofCollection(description, data)};
-    }
-
-    static <T> Object[] sbDataDescr(String description, SpinedBuffer<T> data) {
-        return new Object[] { description, TestData.Factory.ofSpinedBuffer(description, data)};
-    }
-
-    static <T> Object[] splitDescr(String description, Supplier<Spliterator<T>> ss) {
-        return new Object[] { description, ss };
-    }
-
-    // Return an array of ( String name, StreamTestData<Integer> )
-    @DataProvider(name = "StreamTestData<Integer>")
-    public static Object[][] makeStreamTestData() {
-        return testData;
-    }
-
-    @DataProvider(name = "StreamTestData<Integer>.small")
-    public static Object[][] makeSmallStreamTestData() {
-        return testSmallData;
-    }
-
-    @DataProvider(name = "StreamTestData<Integer>.mini")
-    public static Object[][] makeMiniStreamTestData() {
-        return testMiniData;
-    }
-
-    @DataProvider(name = "withNull:StreamTestData<Integer>")
-    public static Object[][] makeStreamWithNullTestData() {
-        return withNullTestData;
-    }
-
-    // returns an array of (String name, Supplier<Spliterator<Integer>>)
-    @DataProvider(name = "Spliterator<Integer>")
-    public static Object[][] spliteratorProvider() {
-        return spliteratorTestData;
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamTestScenario.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,279 +0,0 @@
-/*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.Spliterator;
-import java.util.SpliteratorTestHelper;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
-/**
- * Test scenarios for reference streams.
- *
- * Each scenario is provided with a data source, a function that maps a fresh
- * stream (as provided by the data source) to a new stream, and a sink to
- * receive results.  Each scenario describes a different way of computing the
- * stream contents.  The test driver will ensure that all scenarios produce
- * the same output (modulo allowable differences in ordering).
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public enum StreamTestScenario implements OpTestCase.BaseStreamTestScenario {
-
-    STREAM_FOR_EACH(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            Stream<U> s = m.apply(source);
-            if (s.isParallel()) {
-                s = s.sequential();
-            }
-            s.forEach(b);
-        }
-    },
-
-    // Collec to list
-    STREAM_COLLECT(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (U t : m.apply(source).collect(Collectors.toList())) {
-                b.accept(t);
-            }
-        }
-    },
-
-    // To array
-    STREAM_TO_ARRAY(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (Object t : m.apply(source).toArray()) {
-                b.accept((U) t);
-            }
-        }
-    },
-
-    // Wrap as stream, and iterate in pull mode
-    STREAM_ITERATOR(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (Iterator<U> seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
-                b.accept(seqIter.next());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (Spliterator<U> spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
-    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR_FOREACH(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    // Wrap as parallel stream + sequential
-    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            m.apply(source).sequential().forEach(b);
-        }
-    },
-
-    // Wrap as parallel stream + forEachOrdered
-    PAR_STREAM_FOR_EACH_ORDERED(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            // @@@ Want to explicitly select ordered equalator
-            m.apply(source).forEachOrdered(b);
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (Spliterator<U> spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR_FOREACH(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    // Wrap as parallel stream + toArray
-    PAR_STREAM_TO_ARRAY(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (Object t : m.apply(source).toArray())
-                b.accept((U) t);
-        }
-    },
-
-    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
-    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            Stream<U> s = m.apply(source);
-            Spliterator<U> sp = s.spliterator();
-            Stream<U> ss = StreamSupport.stream(() -> sp,
-                                                StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
-                                                | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
-            for (Object t : ss.toArray())
-                b.accept((U) t);
-        }
-    },
-
-    // Wrap as parallel stream + toArray and clear SIZED flag
-    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            Stream<U> pipe2 = m.apply(pipe1);
-
-            for (Object t : pipe2.toArray())
-                b.accept((U) t);
-        }
-    },
-
-    // Wrap as parallel + collect to list
-    PAR_STREAM_COLLECT_TO_LIST(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (U u : m.apply(source).collect(Collectors.toList()))
-                b.accept(u);
-        }
-    },
-
-    // Wrap sequential as parallel, + collect to list
-    STREAM_TO_PAR_STREAM_COLLECT_TO_LIST(true) {
-        public <T, S_IN extends BaseStream<T, S_IN>>
-        S_IN getStream(TestData<T, S_IN> data) {
-            return data.stream().parallel();
-        }
-
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (U u : m.apply(source).collect(Collectors.toList()))
-                b.accept(u);
-        }
-    },
-
-    // Wrap parallel as sequential,, + collect
-    PAR_STREAM_TO_STREAM_COLLECT_TO_LIST(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (U u : m.apply(source).collect(Collectors.toList()))
-                b.accept(u);
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing
-    PAR_STREAM_FOR_EACH(true, false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            m.apply(source).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
-    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            m.apply(pipe1).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-    ;
-
-    // The set of scenarios that clean the SIZED flag
-    public static final Set<StreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
-            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
-
-    private final boolean isParallel;
-
-    private final boolean isOrdered;
-
-    StreamTestScenario(boolean isParallel) {
-        this(isParallel, true);
-    }
-
-    StreamTestScenario(boolean isParallel, boolean isOrdered) {
-        this.isParallel = isParallel;
-        this.isOrdered = isOrdered;
-    }
-
-    public StreamShape getShape() {
-        return StreamShape.REFERENCE;
-    }
-
-    public boolean isParallel() {
-        return isParallel;
-    }
-
-    public boolean isOrdered() {
-        return isOrdered;
-    }
-
-    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
-        try (S_IN source = getStream(data)) {
-            run(data, source, b, (Function<S_IN, Stream<U>>) m);
-        }
-    }
-
-    abstract <T, U, S_IN extends BaseStream<T, S_IN>>
-    void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m);
-
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/TestData.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,355 +0,0 @@
-/*
- * Copyright (c) 2012, 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.
- */
-package java.util.stream;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.PrimitiveIterator;
-import java.util.Spliterator;
-import java.util.Spliterators;
-import java.util.function.DoubleConsumer;
-import java.util.function.Function;
-import java.util.function.IntConsumer;
-import java.util.function.LongConsumer;
-import java.util.function.Supplier;
-import java.util.function.ToIntFunction;
-
-/** Describes a test data set for use in stream tests */
-public interface TestData<T, S extends BaseStream<T, S>>
-        extends Iterable<T> {
-
-    default int size() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    default Iterator<T> iterator() {
-        return Spliterators.iterator(spliterator());
-    }
-
-    Spliterator<T> spliterator();
-
-    default boolean isOrdered() {
-        return spliterator().hasCharacteristics(Spliterator.ORDERED);
-    }
-
-    StreamShape getShape();
-
-    default <A extends Collection<? super T>> A into(A target) {
-        spliterator().forEachRemaining(target::add);
-        return target;
-    }
-
-    S stream();
-
-    S parallelStream();
-
-    public interface OfRef<T> extends TestData<T, Stream<T>> { }
-
-    public interface OfInt extends TestData<Integer, IntStream> { }
-
-    public interface OfLong extends TestData<Long, LongStream> { }
-
-    public interface OfDouble extends TestData<Double, DoubleStream> { }
-
-    // @@@ Temporary garbage class to avoid triggering bugs with lambdas in static methods in interfaces
-    public static class Factory {
-        public static <T> OfRef<T> ofArray(String name, T[] array) {
-            return new AbstractTestData.RefTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
-                                                      Arrays::spliterator, a -> a.length);
-        }
-
-        public static <T> OfRef<T> ofCollection(String name, Collection<T> collection) {
-            return new AbstractTestData.RefTestData<>(name, collection, Collection::stream, Collection::parallelStream,
-                                                      Collection::spliterator, Collection::size);
-        }
-
-        public static <T> OfRef<T> ofSpinedBuffer(String name, SpinedBuffer<T> buffer) {
-            return new AbstractTestData.RefTestData<>(name, buffer,
-                                                      b -> StreamSupport.stream(b.spliterator(), false),
-                                                      b -> StreamSupport.stream(b.spliterator(), true),
-                                                      SpinedBuffer::spliterator,
-                                                      b -> (int) b.count());
-        }
-
-        public static <T> OfRef<T> ofSupplier(String name, Supplier<Stream<T>> supplier) {
-            return new AbstractTestData.RefTestData<>(name, supplier,
-                                                      Supplier::get,
-                                                      s -> s.get().parallel(),
-                                                      s -> s.get().spliterator(),
-                                                      s -> (int) s.get().spliterator().getExactSizeIfKnown());
-        }
-
-        public static <T> OfRef<T> ofRefNode(String name, Node<T> node) {
-            return new AbstractTestData.RefTestData<>(name, node,
-                                                      n -> StreamSupport.stream(n::spliterator, Spliterator.SIZED | Spliterator.ORDERED, false),
-                                                      n -> StreamSupport.stream(n::spliterator, Spliterator.SIZED | Spliterator.ORDERED, true),
-                                                      Node::spliterator,
-                                                      n -> (int) n.count());
-        }
-
-        // int factories
-        public static <T> OfInt ofArray(String name, int[] array) {
-            return new AbstractTestData.IntTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
-                                                      Arrays::spliterator, a -> a.length);
-        }
-
-        public static OfInt ofSpinedBuffer(String name, SpinedBuffer.OfInt buffer) {
-            return new AbstractTestData.IntTestData<>(name, buffer,
-                                                      b -> StreamSupport.intStream(b.spliterator(), false),
-                                                      b -> StreamSupport.intStream(b.spliterator(), true),
-                                                      SpinedBuffer.OfInt::spliterator,
-                                                      b -> (int) b.count());
-        }
-
-        public static OfInt ofIntSupplier(String name, Supplier<IntStream> supplier) {
-            return new AbstractTestData.IntTestData<>(name, supplier,
-                                                      Supplier::get,
-                                                      s -> s.get().parallel(),
-                                                      s -> s.get().spliterator(),
-                                                      s -> (int) s.get().spliterator().getExactSizeIfKnown());
-        }
-
-        public static OfInt ofNode(String name, Node.OfInt node) {
-            int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
-            return new AbstractTestData.IntTestData<>(name, node,
-                                                      n -> StreamSupport.intStream(n::spliterator, characteristics, false),
-                                                      n -> StreamSupport.intStream(n::spliterator, characteristics, true),
-                                                      Node.OfInt::spliterator,
-                                                      n -> (int) n.count());
-        }
-
-        // long factories
-        public static <T> OfLong ofArray(String name, long[] array) {
-            return new AbstractTestData.LongTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
-                                                       Arrays::spliterator, a -> a.length);
-        }
-
-        public static OfLong ofSpinedBuffer(String name, SpinedBuffer.OfLong buffer) {
-            return new AbstractTestData.LongTestData<>(name, buffer,
-                                                      b -> StreamSupport.longStream(b.spliterator(), false),
-                                                      b -> StreamSupport.longStream(b.spliterator(), true),
-                                                      SpinedBuffer.OfLong::spliterator,
-                                                      b -> (int) b.count());
-        }
-
-        public static OfLong ofLongSupplier(String name, Supplier<LongStream> supplier) {
-            return new AbstractTestData.LongTestData<>(name, supplier,
-                                                      Supplier::get,
-                                                      s -> s.get().parallel(),
-                                                      s -> s.get().spliterator(),
-                                                      s -> (int) s.get().spliterator().getExactSizeIfKnown());
-        }
-
-        public static OfLong ofNode(String name, Node.OfLong node) {
-            int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
-            return new AbstractTestData.LongTestData<>(name, node,
-                                                      n -> StreamSupport.longStream(n::spliterator, characteristics, false),
-                                                      n -> StreamSupport.longStream(n::spliterator, characteristics, true),
-                                                      Node.OfLong::spliterator,
-                                                      n -> (int) n.count());
-        }
-
-        // double factories
-        public static <T> OfDouble ofArray(String name, double[] array) {
-            return new AbstractTestData.DoubleTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
-                                                         Arrays::spliterator, a -> a.length);
-        }
-
-        public static OfDouble ofSpinedBuffer(String name, SpinedBuffer.OfDouble buffer) {
-            return new AbstractTestData.DoubleTestData<>(name, buffer,
-                                                         b -> StreamSupport.doubleStream(b.spliterator(), false),
-                                                         b -> StreamSupport.doubleStream(b.spliterator(), true),
-                                                         SpinedBuffer.OfDouble::spliterator,
-                                                         b -> (int) b.count());
-        }
-
-        public static OfDouble ofDoubleSupplier(String name, Supplier<DoubleStream> supplier) {
-            return new AbstractTestData.DoubleTestData<>(name, supplier,
-                                                         Supplier::get,
-                                                         s -> s.get().parallel(),
-                                                         s -> s.get().spliterator(),
-                                                         s -> (int) s.get().spliterator().getExactSizeIfKnown());
-        }
-
-        public static OfDouble ofNode(String name, Node.OfDouble node) {
-            int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
-            return new AbstractTestData.DoubleTestData<>(name, node,
-                                                         n -> StreamSupport.doubleStream(n::spliterator, characteristics, false),
-                                                         n -> StreamSupport.doubleStream(n::spliterator, characteristics, true),
-                                                         Node.OfDouble::spliterator,
-                                                         n -> (int) n.count());
-        }
-    }
-
-
-    abstract class AbstractTestData<T, S extends BaseStream<T, S>,
-            T_STATE,
-                                    T_SPLITR extends Spliterator<T>>
-            implements TestData<T, S> {
-        private final String name;
-        private final StreamShape shape;
-        protected final T_STATE state;
-        private final ToIntFunction<T_STATE> sizeFn;
-        private final Function<T_STATE, S> streamFn;
-        private final Function<T_STATE, S> parStreamFn;
-        private final Function<T_STATE, T_SPLITR> splitrFn;
-
-        AbstractTestData(String name,
-                         StreamShape shape,
-                         T_STATE state,
-                         Function<T_STATE, S> streamFn,
-                         Function<T_STATE, S> parStreamFn,
-                         Function<T_STATE, T_SPLITR> splitrFn,
-                         ToIntFunction<T_STATE> sizeFn) {
-            this.name = name;
-            this.shape = shape;
-            this.state = state;
-            this.streamFn = streamFn;
-            this.parStreamFn = parStreamFn;
-            this.splitrFn = splitrFn;
-            this.sizeFn = sizeFn;
-        }
-
-        @Override
-        public StreamShape getShape() {
-            return shape;
-        }
-
-        @Override
-        public String toString() {
-            return getClass().getSimpleName() + "[" + name + "]";
-        }
-
-        @Override
-        public int size() {
-            return sizeFn.applyAsInt(state);
-        }
-
-        @Override
-        public T_SPLITR spliterator() {
-            return splitrFn.apply(state);
-        }
-
-        @Override
-        public S stream() {
-            return streamFn.apply(state);
-        }
-
-        @Override
-        public S parallelStream() {
-            return parStreamFn.apply(state);
-        }
-
-        public static class RefTestData<T, I>
-                extends AbstractTestData<T, Stream<T>, I, Spliterator<T>>
-                implements TestData.OfRef<T> {
-
-            protected RefTestData(String name,
-                                  I state,
-                                  Function<I, Stream<T>> streamFn,
-                                  Function<I, Stream<T>> parStreamFn,
-                                  Function<I, Spliterator<T>> splitrFn,
-                                  ToIntFunction<I> sizeFn) {
-                super(name, StreamShape.REFERENCE, state, streamFn, parStreamFn, splitrFn, sizeFn);
-            }
-
-        }
-
-        static class IntTestData<I>
-                extends AbstractTestData<Integer, IntStream, I, Spliterator.OfInt>
-                implements TestData.OfInt {
-
-            protected IntTestData(String name,
-                                  I state,
-                                  Function<I, IntStream> streamFn,
-                                  Function<I, IntStream> parStreamFn,
-                                  Function<I, Spliterator.OfInt> splitrFn,
-                                  ToIntFunction<I> sizeFn) {
-                super(name, StreamShape.INT_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
-            }
-
-            @Override
-            public PrimitiveIterator.OfInt iterator() {
-                return Spliterators.iterator(spliterator());
-            }
-
-            @Override
-            public <A extends Collection<? super Integer>> A into(A target) {
-                spliterator().forEachRemaining((IntConsumer) target::add);
-                return target;
-            }
-        }
-
-        static class LongTestData<I>
-                extends AbstractTestData<Long, LongStream, I, Spliterator.OfLong>
-                implements TestData.OfLong {
-
-            protected LongTestData(String name,
-                                   I state,
-                                   Function<I, LongStream> streamFn,
-                                   Function<I, LongStream> parStreamFn,
-                                   Function<I, Spliterator.OfLong> splitrFn,
-                                   ToIntFunction<I> sizeFn) {
-                super(name, StreamShape.LONG_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
-            }
-
-            @Override
-            public PrimitiveIterator.OfLong iterator() {
-                return Spliterators.iterator(spliterator());
-            }
-
-            @Override
-            public <A extends Collection<? super Long>> A into(A target) {
-                spliterator().forEachRemaining((LongConsumer) target::add);
-                return target;
-            }
-        }
-
-        static class DoubleTestData<I>
-                extends AbstractTestData<Double, DoubleStream, I, Spliterator.OfDouble>
-                implements OfDouble {
-
-            protected DoubleTestData(String name,
-                                     I state,
-                                     Function<I, DoubleStream> streamFn,
-                                     Function<I, DoubleStream> parStreamFn,
-                                     Function<I, Spliterator.OfDouble> splitrFn,
-                                     ToIntFunction<I> sizeFn) {
-                super(name, StreamShape.DOUBLE_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
-            }
-
-            @Override
-            public PrimitiveIterator.OfDouble iterator() {
-                return Spliterators.iterator(spliterator());
-            }
-
-            @Override
-            public <A extends Collection<? super Double>> A into(A target) {
-                spliterator().forEachRemaining((DoubleConsumer) target::add);
-                return target;
-            }
-        }
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/TestFlagExpectedOp.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2012, 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.
- */
-package java.util.stream;
-
-import org.testng.Assert;
-
-import java.util.EnumSet;
-
-class TestFlagExpectedOp<T> extends FlagDeclaringOp<T> {
-
-    static class Builder<T> {
-        final int flags;
-        StreamShape shape = StreamShape.REFERENCE;
-
-        EnumSet<StreamOpFlag> known = EnumSet.noneOf(StreamOpFlag.class);
-        EnumSet<StreamOpFlag> preserve = EnumSet.noneOf(StreamOpFlag.class);
-        EnumSet<StreamOpFlag> notKnown = EnumSet.noneOf(StreamOpFlag.class);
-
-        Builder(int flags) {
-            this.flags = flags;
-        }
-
-        Builder<T> known(EnumSet<StreamOpFlag> known) {
-            this.known = known;
-            return this;
-        }
-
-        Builder<T> preserve(EnumSet<StreamOpFlag> preserve) {
-            this.preserve = preserve;
-            return this;
-        }
-
-        Builder<T> notKnown(EnumSet<StreamOpFlag> notKnown) {
-            this.notKnown = notKnown;
-            return this;
-        }
-
-        Builder<T> shape(StreamShape shape) {
-            this.shape = shape;
-            return this;
-        }
-
-        TestFlagExpectedOp<T> build() {
-            return new TestFlagExpectedOp<>(flags, known, preserve, notKnown, shape);
-        }
-    }
-
-    final EnumSet<StreamOpFlag> known;
-    final EnumSet<StreamOpFlag> preserve;
-    final EnumSet<StreamOpFlag> notKnown;
-    final StreamShape shape;
-
-    TestFlagExpectedOp(int flags,
-                       EnumSet<StreamOpFlag> known,
-                       EnumSet<StreamOpFlag> preserve,
-                       EnumSet<StreamOpFlag> notKnown) {
-        this(flags, known, preserve, notKnown, StreamShape.REFERENCE);
-    }
-
-    TestFlagExpectedOp(int flags,
-                       EnumSet<StreamOpFlag> known,
-                       EnumSet<StreamOpFlag> preserve,
-                       EnumSet<StreamOpFlag> notKnown,
-                       StreamShape shape) {
-        super(flags);
-        this.known = known;
-        this.preserve = preserve;
-        this.notKnown = notKnown;
-        this.shape = shape;
-    }
-
-    @Override
-    public StreamShape outputShape() {
-        return shape;
-    }
-
-    @Override
-    public StreamShape inputShape() {
-        return shape;
-    }
-
-    @Override
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public Sink<T> opWrapSink(int flags, boolean parallel, Sink upstream) {
-        assertFlags(flags);
-        return upstream;
-    }
-
-    private void assertFlags(int flags) {
-        for (StreamOpFlag f : known) {
-            Assert.assertTrue(f.isKnown(flags),
-                              String.format("Flag %s is not known, but should be known.", f.toString()));
-        }
-
-        for (StreamOpFlag f : preserve) {
-            Assert.assertTrue(f.isPreserved(flags),
-                              String.format("Flag %s is not preserved, but should be preserved.", f.toString()));
-        }
-
-        for (StreamOpFlag f : notKnown) {
-            Assert.assertFalse(f.isKnown(flags),
-                               String.format("Flag %s is known, but should be not known.", f.toString()));
-        }
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/ThrowableHelper.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-public final class ThrowableHelper {
-
-    public static void checkException(Class<? extends Exception> ce, Runnable r) {
-        Exception caught = null;
-        try {
-            r.run();
-        } catch (Exception e) {
-            caught = e;
-        }
-
-        assertNotNull(caught);
-        assertTrue(ce.isInstance(caught));
-    }
-
-    public static void checkNPE(Runnable r) {
-        checkException(NullPointerException.class, r);
-    }
-
-    public static void checkISE(Runnable r) {
-        checkException(IllegalStateException.class, r);
-    }
-}
--- a/jdk/test/java/util/stream/boottest/TEST.properties	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/stream/boottest/TEST.properties	Wed Jul 05 23:25:53 2017 +0200
@@ -1,4 +1,4 @@
 # This file identifies root(s) of the test-ng hierarchy.
 
 TestNG.dirs = .
-lib.dirs = /java/util/stream/bootlib
+lib.dirs = /lib/testlibrary/bootlib
--- a/jdk/test/java/util/stream/test/TEST.properties	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/java/util/stream/test/TEST.properties	Wed Jul 05 23:25:53 2017 +0200
@@ -2,7 +2,7 @@
 
 TestNG.dirs = .
 
-lib.dirs = /java/util/stream/bootlib
+lib.dirs = /lib/testlibrary/bootlib
 
 # Tests that must run in othervm mode
 othervm.dirs= /java/util/stream
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/NullArgsTestCase.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util;
-
-import org.testng.annotations.Test;
-
-import java.util.Arrays;
-import java.util.function.Consumer;
-
-import static org.testng.Assert.fail;
-
-/**
- * NullArgsTestCase -- Given a Consumer&ltObject[]&gt, and an Object[] array of args, call the block with the args,
- * assert success, and then call the consumer N times, each time setting one of the args to null, and assert that
- * all these throw NPE.
- *
- * Typically this would be combined with a DataProvider that serves up combinations of things to be tested, as in
- * IteratorsNullTest.
- */
-public abstract class NullArgsTestCase {
-    public final String name;
-    public final Consumer<Object[]> sink;
-    public final Object[] args;
-
-    protected NullArgsTestCase(String name, Consumer<Object[]> sink, Object[] args) {
-        this.name = name;
-        this.sink = sink;
-        this.args = args;
-    }
-
-    @Test
-    public void goodNonNull() {
-        sink.accept(args);
-    }
-
-    @Test
-    public void throwWithNull() {
-        for (int i=0; i<args.length; i++) {
-            Object[] temp = Arrays.copyOf(args, args.length);
-            temp[i] = null;
-            try {
-                sink.accept(temp);
-                fail(String.format("Expected NullPointerException for argument %d of test case %s", i, name));
-            }
-            catch (NullPointerException e) {
-                // Success
-            }
-        }
-    }
-}
--- a/jdk/test/javax/management/loading/LibraryLoader/LibraryLoaderTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/management/loading/LibraryLoader/LibraryLoaderTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
--- a/jdk/test/javax/management/monitor/ThreadPoolAccTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/management/monitor/ThreadPoolAccTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/NoPermToRemoveTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+ /*
+ * @test
+ * @bug 6515161
+ * @summary checks the behaviour of  mbeanServerConnection.removeNotificationListener
+ * operation when there is a exception thrown during removal
+ * @modules java.management
+ * @run main NoPermToRemoveTest
+ */
+
+import java.lang.management.ManagementFactory;
+import java.security.AllPermission;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanPermission;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXConnectorServer;
+import javax.management.remote.JMXConnectorServerFactory;
+import javax.management.remote.JMXServiceURL;
+
+public class NoPermToRemoveTest {
+    public static void main(String[] args) throws Exception {
+        Policy.setPolicy(new NoRemovePolicy());
+        System.setSecurityManager(new SecurityManager());
+
+        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///");
+        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+        ObjectName name = new ObjectName("foo:type=Sender");
+        mbs.registerMBean(new Sender(), name);
+        JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(
+                url, null, mbs);
+        cs.start();
+        try {
+            JMXServiceURL addr = cs.getAddress();
+            JMXConnector cc = JMXConnectorFactory.connect(addr);
+            MBeanServerConnection mbsc = cc.getMBeanServerConnection();
+            SnoopListener listener = new SnoopListener();
+            mbsc.addNotificationListener(name, listener, null, null);
+            mbsc.invoke(name, "send", null, null);
+            if (!listener.waitForNotification(60))
+                throw new Exception("Did not receive expected notification");
+
+            try {
+                mbsc.removeNotificationListener(name, listener);
+                throw new Exception("RemoveNL did not get SecurityException");
+            } catch (SecurityException e) {
+                System.out.println("removeNL got expected exception: " + e);
+            }
+            mbsc.invoke(name, "send", null, null);
+            if (!listener.waitForNotification(60)) {
+                int listenerCount =
+                        (Integer) mbsc.getAttribute(name, "ListenerCount");
+                System.out.println("Listener count: " + listenerCount);
+                if (listenerCount != 0)
+                    throw new Exception("TEST FAILED");
+                    /* We did not receive the notification, but the MBean still
+                     * has a listener coming from the connector server, which
+                     * means the connector server still thinks there is a
+                     * listener.  If we retained the listener after the failing
+                     * removeNL that would be OK, and if the listener were
+                     * dropped by both client and server that would be OK too,
+                     * but the inconsistency is not OK.
+                     */
+            }
+            cc.close();
+        } finally {
+            cs.stop();
+        }
+    }
+
+    private static class SnoopListener implements NotificationListener {
+        private Semaphore sema = new Semaphore(0);
+
+        public void handleNotification(Notification notification, Object handback) {
+            System.out.println("Listener got: " + notification);
+            sema.release();
+        }
+
+        boolean waitForNotification(int seconds) throws InterruptedException {
+            return sema.tryAcquire(seconds, TimeUnit.SECONDS);
+        }
+    }
+
+    private static class NoRemovePolicy extends Policy {
+        public PermissionCollection getPermissions(CodeSource codesource) {
+            PermissionCollection pc = new Permissions();
+            pc.add(new AllPermission());
+            return pc;
+        }
+
+        public void refresh() {
+        }
+
+        public boolean implies(ProtectionDomain domain, Permission permission) {
+            if (!(permission instanceof MBeanPermission))
+                return true;
+            MBeanPermission jmxp = (MBeanPermission) permission;
+            if (jmxp.getActions().contains("removeNotificationListener")) {
+                System.out.println("DENIED");
+                return false;
+            }
+            return true;
+        }
+    }
+
+    public static interface SenderMBean {
+        public void send();
+        public int getListenerCount();
+    }
+
+    public static class Sender extends NotificationBroadcasterSupport
+            implements SenderMBean {
+        private AtomicInteger listenerCount = new AtomicInteger();
+
+        public void send() {
+            System.out.println("Sending notif");
+            sendNotification(new Notification("type", this, 0L));
+        }
+
+        public synchronized int getListenerCount() {
+            return listenerCount.get();
+        }
+
+        public void removeNotificationListener(
+                NotificationListener listener,
+                NotificationFilter filter,
+                Object handback) throws ListenerNotFoundException {
+            System.out.println("Sender.removeNL(3)");
+            super.removeNotificationListener(listener, filter, handback);
+            listenerCount.decrementAndGet();
+        }
+
+        public void addNotificationListener(
+                NotificationListener listener,
+                NotificationFilter filter,
+                Object handback) {
+            System.out.println("Sender.addNL(3)");
+            super.addNotificationListener(listener, filter, handback);
+            listenerCount.incrementAndGet();
+        }
+
+        public void removeNotificationListener(NotificationListener listener)
+        throws ListenerNotFoundException {
+            System.out.println("Sender.removeNL(1)");
+            super.removeNotificationListener(listener);
+            listenerCount.decrementAndGet();
+        }
+    }
+}
--- a/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java	Wed Jul 05 23:25:53 2017 +0200
@@ -2,21 +2,22 @@
  * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- * This code is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License version 2 only, as published by
- * the Free Software Foundation.
+ * This code is 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).
+ * 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.
+ * 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
+ * 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.
  */
 
--- a/jdk/test/javax/net/ssl/TLS/JSSEClient.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/net/ssl/TLS/JSSEClient.java	Wed Jul 05 23:25:53 2017 +0200
@@ -2,21 +2,22 @@
  * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- * This code is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License version 2 only, as published by
- * the Free Software Foundation.
+ * This code is 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).
+ * 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.
+ * 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
+ * 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.
  */
 
--- a/jdk/test/javax/net/ssl/TLS/JSSEServer.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/net/ssl/TLS/JSSEServer.java	Wed Jul 05 23:25:53 2017 +0200
@@ -2,21 +2,22 @@
  * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- * This code is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License version 2 only, as published by
- * the Free Software Foundation.
+ * This code is 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).
+ * 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.
+ * 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
+ * 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.
  */
 
--- a/jdk/test/javax/net/ssl/TLS/TestJSSE.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/net/ssl/TLS/TestJSSE.java	Wed Jul 05 23:25:53 2017 +0200
@@ -2,21 +2,22 @@
  * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- * This code is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License version 2 only, as published by
- * the Free Software Foundation.
+ * This code is 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).
+ * 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.
+ * 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
+ * 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.
  */
 
--- a/jdk/test/javax/net/ssl/TLS/TestJSSEClientDefaultProtocol.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/net/ssl/TLS/TestJSSEClientDefaultProtocol.java	Wed Jul 05 23:25:53 2017 +0200
@@ -2,21 +2,22 @@
  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- * This code is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License version 2 only, as published by
- * the Free Software Foundation.
+ * This code is 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).
+ * 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.
+ * 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
+ * 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.
  */
 
--- a/jdk/test/javax/net/ssl/TLS/TestJSSEClientProtocol.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/net/ssl/TLS/TestJSSEClientProtocol.java	Wed Jul 05 23:25:53 2017 +0200
@@ -2,21 +2,22 @@
  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- * This code is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License version 2 only, as published by
- * the Free Software Foundation.
+ * This code is 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).
+ * 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.
+ * 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
+ * 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.
  */
 
--- a/jdk/test/javax/net/ssl/TLS/TestJSSENoCommonProtocols.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/net/ssl/TLS/TestJSSENoCommonProtocols.java	Wed Jul 05 23:25:53 2017 +0200
@@ -2,21 +2,22 @@
  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- * This code is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License version 2 only, as published by
- * the Free Software Foundation.
+ * This code is 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).
+ * 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.
+ * 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
+ * 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.
  */
 
--- a/jdk/test/javax/net/ssl/TLS/TestJSSEServerProtocol.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/net/ssl/TLS/TestJSSEServerProtocol.java	Wed Jul 05 23:25:53 2017 +0200
@@ -2,21 +2,22 @@
  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- * This code is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License version 2 only, as published by
- * the Free Software Foundation.
+ * This code is 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).
+ * 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.
+ * 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
+ * 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.
  */
 
--- a/jdk/test/javax/print/attribute/TestUnsupportedResolution.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/print/attribute/TestUnsupportedResolution.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -104,4 +104,3 @@
     return PAGE_EXISTS;
 }
 }
-
--- a/jdk/test/javax/security/auth/Subject/Generic.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/security/auth/Subject/Generic.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASConfigSyntaxTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/JAASConfigSyntaxTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,23 +1,23 @@
-
-/**
+/*
  * Copyright (c) 2007, 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.
+ * 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).
+ * 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.
+ * 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
+ * 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.
  */
 
--- a/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/SampleLoginModule.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/security/auth/login/JAASConfigSyntaxCheck/SampleLoginModule.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,22 +1,23 @@
-/**
+/*
  * Copyright (c) 2007, 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.
+ * 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).
+ * 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.
+ * 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
+ * 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.
  */
 
--- a/jdk/test/javax/swing/JComboBox/6632953/bug6632953.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/swing/JComboBox/6632953/bug6632953.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JComboBox/WindowsComboBoxSize/WindowsComboBoxSizeTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8179027
+ * @requires (os.family == "windows")
+ * @summary JComboBox too small under Windows LAF
+ * @run main WindowsComboBoxSizeTest
+ */
+
+import javax.swing.*;
+import java.awt.FlowLayout;
+import java.awt.Robot;
+
+public class WindowsComboBoxSizeTest {
+    private static JTextField textField;
+    private static JComboBox<String> comboBox;
+    private static JComboBox<String> comboBoxEd;
+    private static JFrame frame;
+
+    public static void main(String[] args) throws Exception {
+        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+
+        SwingUtilities.invokeAndWait(() -> {
+            frame = new JFrame();
+            frame.getContentPane().setLayout( new FlowLayout() );
+
+            textField = new JTextField("item 1");
+            frame.getContentPane().add(textField);
+
+            comboBox = new JComboBox<>(new String[]
+                                                {"item 1", "item 2", "item 3"});
+            frame.getContentPane().add(comboBox);
+
+            comboBoxEd = new JComboBox<>(new String[]
+                                                {"item 1", "item 2", "item 3"});
+            comboBoxEd.setEditable( true );
+            frame.getContentPane().add(comboBoxEd);
+
+            frame.pack();
+            frame.setVisible( true );
+        });
+        Robot robot = new Robot();
+        robot.waitForIdle();
+
+        try {
+            test();
+        } finally {
+            SwingUtilities.invokeLater(frame::dispose);
+        }
+    }
+
+    private static void test() throws Exception {
+        SwingUtilities.invokeAndWait(() -> {
+            int expected = textField.getSize().height;
+            if (comboBox.getSize().height != expected ) {
+                throw new RuntimeException(
+                        "Wrong non-editable JComboBox height " +
+                                              comboBox.getSize().height);
+            }
+            if (comboBoxEd.getSize().height != expected ) {
+                throw new RuntimeException(
+                        "Wrong editable JComboBox height " +
+                                            comboBoxEd.getSize().height);
+            }
+        });
+    }
+}
+
--- a/jdk/test/javax/swing/JFileChooser/4150029/bug4150029.html	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/swing/JFileChooser/4150029/bug4150029.html	Wed Jul 05 23:25:53 2017 +0200
@@ -1,6 +1,6 @@
 <html>
 <!--
- Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 
  This code is free software; you can redistribute it and/or modify it
@@ -40,4 +40,4 @@
 3.Push OPEN button.
 4.Push DONE button.
 </body>
-</html> 
+</html>
--- a/jdk/test/javax/swing/JInternalFrame/8069348/bug8069348.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/swing/JInternalFrame/8069348/bug8069348.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
 /**
  * @test
  * @key headful
- * @bug 8069348
+ * @bug 8069348 8159902
  * @summary SunGraphics2D.copyArea() does not properly work for scaled graphics
  * @author Alexandr Scherbatiy
  * @modules java.desktop/sun.awt
--- a/jdk/test/javax/swing/JInternalFrame/Test6325652.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/swing/JInternalFrame/Test6325652.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009,2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/javax/swing/JMenu/8072900/WrongSelectionOnMouseOver.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/swing/JMenu/8072900/WrongSelectionOnMouseOver.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/javax/swing/JPopupMenu/6694823/bug6694823.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/swing/JPopupMenu/6694823/bug6694823.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2014 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/javax/swing/plaf/nimbus/8041642/bug8041642.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/swing/plaf/nimbus/8041642/bug8041642.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 /*
  * @test
  * @key headful
- * @bug 8041642 8079450
+ * @bug 8041642 8079450 8140237
  * @summary Incorrect paint of JProgressBar in Nimbus LF
  * @author Semyon Sadetsky
  */
@@ -39,16 +39,7 @@
     private static JProgressBar bar;
 
     public static void main(String[] args) throws Exception {
-        for (UIManager.LookAndFeelInfo info : UIManager
-                .getInstalledLookAndFeels()) {
-            if ("Nimbus".equals(info.getName())) {
-                try {
-                    UIManager.setLookAndFeel(info.getClassName());
-                } catch (Exception ex) {
-                }
-                break;
-            }
-        }
+        UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
         try {
             SwingUtilities.invokeAndWait(new Runnable() {
                 public void run() {
@@ -58,14 +49,14 @@
                     setup(frame);
                 }
             });
+            final Robot robot = new Robot();
+            robot.delay(300);
             SwingUtilities.invokeAndWait(new Runnable() {
                 @Override
                 public void run() {
                     point = bar.getLocationOnScreen();
                 }
             });
-            final Robot robot = new Robot();
-            robot.delay(100);
             Color color = robot.getPixelColor(point.x + 1, point.y + 7);
             System.out.println(color);
             if (color.getGreen() < 150 || color.getBlue() > 30 ||
@@ -77,7 +68,7 @@
             SwingUtilities.invokeAndWait(new Runnable() {
                 @Override
                 public void run() {
-                    //frame.dispose();
+                    frame.dispose();
                 }
             });
         }
--- a/jdk/test/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/swing/plaf/synth/SynthButtonUI/6276188/bug6276188.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/javax/swing/text/html/parser/Parser/8028616/bug8028616.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/javax/swing/text/html/parser/Parser/8028616/bug8028616.java	Wed Jul 05 23:25:53 2017 +0200
@@ -8,7 +8,7 @@
  *
  * 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
+ * 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).
  *
--- a/jdk/test/lib/testlibrary/ModuleTargetHelper.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/lib/testlibrary/ModuleTargetHelper.java	Wed Jul 05 23:25:53 2017 +0200
@@ -41,19 +41,14 @@
     private ModuleTargetHelper() {}
 
     public static final class ModuleTarget {
-        private String osName, osArch;
+        private String targetPlatform;
 
-        public ModuleTarget(String osName, String osArch) {
-            this.osName = osName;
-            this.osArch = osArch;
+        public ModuleTarget(String targetPlatform) {
+            this.targetPlatform = targetPlatform;
         }
 
-        public String osName() {
-            return osName;
-        }
-
-        public String osArch() {
-            return osArch;
+        public String targetPlatform() {
+            return targetPlatform;
         }
     }
 
@@ -84,7 +79,7 @@
         ClassReader cr = new ClassReader(in);
         cr.accept(cv, attrs, 0);
         if (modTargets[0] != null) {
-            return new ModuleTarget(modTargets[0].osName(), modTargets[0].osArch());
+            return new ModuleTarget(modTargets[0].targetPlatform());
         }
 
         return null;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/SpliteratorOfIntDataBuilder.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.util;
+
+import java.util.function.Supplier;
+
+public class SpliteratorOfIntDataBuilder {
+        List<Object[]> data;
+
+        List<Integer> exp;
+
+        public SpliteratorOfIntDataBuilder(List<Object[]> data, List<Integer> exp) {
+            this.data = data;
+            this.exp = exp;
+        }
+
+        public void add(String description, List<Integer> expected, Supplier<Spliterator.OfInt> s) {
+            description = joiner(description).toString();
+            data.add(new Object[]{description, expected, s});
+        }
+
+        public void add(String description, Supplier<Spliterator.OfInt> s) {
+            add(description, exp, s);
+        }
+
+        StringBuilder joiner(String description) {
+            return new StringBuilder(description).
+                    append(" {").
+                    append("size=").append(exp.size()).
+                    append("}");
+        }
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/SpliteratorTestHelper.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,754 @@
+/*
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util;
+
+import java.util.function.*;
+import java.util.stream.LambdaTestHelpers;
+
+import static org.testng.Assert.*;
+
+/**
+ * Assertion methods for spliterators, to be called from other tests
+ */
+public class SpliteratorTestHelper {
+
+    public interface ContentAsserter<T> {
+        void assertContents(Collection<T> actual, Collection<T> expected, boolean isOrdered);
+    }
+
+    private static ContentAsserter<Object> DEFAULT_CONTENT_ASSERTER
+            = SpliteratorTestHelper::assertContents;
+
+    @SuppressWarnings("unchecked")
+    private static <T> ContentAsserter<T> defaultContentAsserter() {
+        return (ContentAsserter<T>) DEFAULT_CONTENT_ASSERTER;
+    }
+
+    public static void testSpliterator(Supplier<Spliterator<Integer>> supplier) {
+        testSpliterator(supplier, defaultContentAsserter());
+    }
+
+    public static void testSpliterator(Supplier<Spliterator<Integer>> supplier,
+                                       ContentAsserter<Integer> asserter) {
+        testSpliterator(supplier, (Consumer<Integer> b) -> b, asserter);
+    }
+
+    public static void testIntSpliterator(Supplier<Spliterator.OfInt> supplier) {
+        testIntSpliterator(supplier, defaultContentAsserter());
+    }
+
+    public static void testIntSpliterator(Supplier<Spliterator.OfInt> supplier,
+                                          ContentAsserter<Integer> asserter) {
+        testSpliterator(supplier, intBoxingConsumer(), asserter);
+    }
+
+    public static void testLongSpliterator(Supplier<Spliterator.OfLong> supplier) {
+        testLongSpliterator(supplier, defaultContentAsserter());
+    }
+
+    public static void testLongSpliterator(Supplier<Spliterator.OfLong> supplier,
+                                           ContentAsserter<Long> asserter) {
+        testSpliterator(supplier, longBoxingConsumer(), asserter);
+    }
+
+    public static void testDoubleSpliterator(Supplier<Spliterator.OfDouble> supplier) {
+        testDoubleSpliterator(supplier, defaultContentAsserter());
+    }
+
+    public static void testDoubleSpliterator(Supplier<Spliterator.OfDouble> supplier,
+                                             ContentAsserter<Double> asserter) {
+        testSpliterator(supplier, doubleBoxingConsumer(), asserter);
+    }
+
+    public static UnaryOperator<Consumer<Integer>> intBoxingConsumer() {
+        class BoxingAdapter implements Consumer<Integer>, IntConsumer {
+            private final Consumer<Integer> b;
+
+            BoxingAdapter(Consumer<Integer> b) {
+                this.b = b;
+            }
+
+            @Override
+            public void accept(Integer value) {
+                throw new IllegalStateException();
+            }
+
+            @Override
+            public void accept(int value) {
+                b.accept(value);
+            }
+        }
+
+        return b -> new BoxingAdapter(b);
+    }
+
+    public static UnaryOperator<Consumer<Long>> longBoxingConsumer() {
+        class BoxingAdapter implements Consumer<Long>, LongConsumer {
+            private final Consumer<Long> b;
+
+            BoxingAdapter(Consumer<Long> b) {
+                this.b = b;
+            }
+
+            @Override
+            public void accept(Long value) {
+                throw new IllegalStateException();
+            }
+
+            @Override
+            public void accept(long value) {
+                b.accept(value);
+            }
+        }
+
+        return b -> new BoxingAdapter(b);
+    }
+
+    public static UnaryOperator<Consumer<Double>> doubleBoxingConsumer() {
+        class BoxingAdapter implements Consumer<Double>, DoubleConsumer {
+            private final Consumer<Double> b;
+
+            BoxingAdapter(Consumer<Double> b) {
+                this.b = b;
+            }
+
+            @Override
+            public void accept(Double value) {
+                throw new IllegalStateException();
+            }
+
+            @Override
+            public void accept(double value) {
+                b.accept(value);
+            }
+        }
+
+        return b -> new BoxingAdapter(b);
+    }
+
+    public static <T, S extends Spliterator<T>> void testSpliterator(Supplier<S> supplier,
+                                                              UnaryOperator<Consumer<T>> boxingAdapter,
+                                                              ContentAsserter<T> asserter) {
+        ArrayList<T> fromForEach = new ArrayList<>();
+        Spliterator<T> spliterator = supplier.get();
+        Consumer<T> addToFromForEach = boxingAdapter.apply(fromForEach::add);
+        spliterator.forEachRemaining(addToFromForEach);
+
+        Collection<T> exp = Collections.unmodifiableList(fromForEach);
+
+        testNullPointerException(supplier);
+        testForEach(exp, supplier, boxingAdapter, asserter);
+        testTryAdvance(exp, supplier, boxingAdapter, asserter);
+        testMixedTryAdvanceForEach(exp, supplier, boxingAdapter, asserter);
+        testMixedTraverseAndSplit(exp, supplier, boxingAdapter, asserter);
+        testSplitAfterFullTraversal(supplier, boxingAdapter);
+        testSplitOnce(exp, supplier, boxingAdapter, asserter);
+        testSplitSixDeep(exp, supplier, boxingAdapter, asserter);
+        testSplitUntilNull(exp, supplier, boxingAdapter, asserter);
+    }
+
+    public static <T, S extends Spliterator<T>> void testForEach(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testForEach(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    public static <T, S extends Spliterator<T>> void testTryAdvance(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testTryAdvance(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    public static <T, S extends Spliterator<T>> void testMixedTryAdvanceForEach(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testMixedTryAdvanceForEach(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    public static <T, S extends Spliterator<T>> void testMixedTraverseAndSplit(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testMixedTraverseAndSplit(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    public static <T, S extends Spliterator<T>> void testSplitOnce(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testSplitOnce(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    public static <T, S extends Spliterator<T>> void testSplitSixDeep(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testSplitSixDeep(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    public static <T, S extends Spliterator<T>> void testSplitUntilNull(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testSplitUntilNull(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    private static <T, S extends Spliterator<T>> void testNullPointerException(Supplier<S> s) {
+        S sp = s.get();
+        // Have to check instances and use casts to avoid tripwire messages and
+        // directly test the primitive methods
+        if (sp instanceof Spliterator.OfInt) {
+            Spliterator.OfInt psp = (Spliterator.OfInt) sp;
+            assertThrowsNPE(() -> psp.forEachRemaining((IntConsumer) null));
+            assertThrowsNPE(() -> psp.tryAdvance((IntConsumer) null));
+        }
+        else if (sp instanceof Spliterator.OfLong) {
+            Spliterator.OfLong psp = (Spliterator.OfLong) sp;
+            assertThrowsNPE(() -> psp.forEachRemaining((LongConsumer) null));
+            assertThrowsNPE(() -> psp.tryAdvance((LongConsumer) null));
+        }
+        else if (sp instanceof Spliterator.OfDouble) {
+            Spliterator.OfDouble psp = (Spliterator.OfDouble) sp;
+            assertThrowsNPE(() -> psp.forEachRemaining((DoubleConsumer) null));
+            assertThrowsNPE(() -> psp.tryAdvance((DoubleConsumer) null));
+        }
+        else {
+            assertThrowsNPE(() -> sp.forEachRemaining(null));
+            assertThrowsNPE(() -> sp.tryAdvance(null));
+        }
+    }
+
+    private static <T, S extends Spliterator<T>> void testForEach(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        S spliterator = supplier.get();
+        long sizeIfKnown = spliterator.getExactSizeIfKnown();
+        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+        ArrayList<T> fromForEach = new ArrayList<>();
+        spliterator = supplier.get();
+        Consumer<T> addToFromForEach = boxingAdapter.apply(fromForEach::add);
+        spliterator.forEachRemaining(addToFromForEach);
+
+        // Assert that forEach now produces no elements
+        spliterator.forEachRemaining(boxingAdapter.apply(
+                e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
+        // Assert that tryAdvance now produce no elements
+        spliterator.tryAdvance(boxingAdapter.apply(
+                e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
+
+        // assert that size, tryAdvance, and forEach are consistent
+        if (sizeIfKnown >= 0) {
+            assertEquals(sizeIfKnown, exp.size());
+        }
+        if (exp.contains(null)) {
+            assertTrue(fromForEach.contains(null));
+        }
+        assertEquals(fromForEach.size(), exp.size());
+
+        asserter.assertContents(fromForEach, exp, isOrdered);
+    }
+
+    private static <T, S extends Spliterator<T>> void testTryAdvance(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        S spliterator = supplier.get();
+        long sizeIfKnown = spliterator.getExactSizeIfKnown();
+        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+        spliterator = supplier.get();
+        ArrayList<T> fromTryAdvance = new ArrayList<>();
+        Consumer<T> addToFromTryAdvance = boxingAdapter.apply(fromTryAdvance::add);
+        while (spliterator.tryAdvance(addToFromTryAdvance)) { }
+
+        // Assert that forEach now produces no elements
+        spliterator.forEachRemaining(boxingAdapter.apply(
+                e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
+        // Assert that tryAdvance now produce no elements
+        spliterator.tryAdvance(boxingAdapter.apply(
+                e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
+
+        // assert that size, tryAdvance, and forEach are consistent
+        if (sizeIfKnown >= 0) {
+            assertEquals(sizeIfKnown, exp.size());
+        }
+        assertEquals(fromTryAdvance.size(), exp.size());
+
+        asserter.assertContents(fromTryAdvance, exp, isOrdered);
+    }
+
+    private static <T, S extends Spliterator<T>> void testMixedTryAdvanceForEach(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        S spliterator = supplier.get();
+        long sizeIfKnown = spliterator.getExactSizeIfKnown();
+        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+        // tryAdvance first few elements, then forEach rest
+        ArrayList<T> dest = new ArrayList<>();
+        spliterator = supplier.get();
+        Consumer<T> addToDest = boxingAdapter.apply(dest::add);
+        for (int i = 0; i < 10 && spliterator.tryAdvance(addToDest); i++) { }
+        spliterator.forEachRemaining(addToDest);
+
+        // Assert that forEach now produces no elements
+        spliterator.forEachRemaining(boxingAdapter.apply(
+                e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
+        // Assert that tryAdvance now produce no elements
+        spliterator.tryAdvance(boxingAdapter.apply(
+                e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
+
+        if (sizeIfKnown >= 0) {
+            assertEquals(sizeIfKnown, dest.size());
+        }
+        assertEquals(dest.size(), exp.size());
+
+        asserter.assertContents(dest, exp, isOrdered);
+    }
+
+    private static <T, S extends Spliterator<T>> void testMixedTraverseAndSplit(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        S spliterator = supplier.get();
+        long sizeIfKnown = spliterator.getExactSizeIfKnown();
+        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+        // tryAdvance first few elements, then forEach rest
+        ArrayList<T> dest = new ArrayList<>();
+        spliterator = supplier.get();
+        Consumer<T> b = boxingAdapter.apply(dest::add);
+
+        Spliterator<T> spl1, spl2, spl3;
+        spliterator.tryAdvance(b);
+        spl2 = spliterator.trySplit();
+        if (spl2 != null) {
+            spl2.tryAdvance(b);
+            spl1 = spl2.trySplit();
+            if (spl1 != null) {
+                spl1.tryAdvance(b);
+                spl1.forEachRemaining(b);
+            }
+            spl2.tryAdvance(b);
+            spl2.forEachRemaining(b);
+        }
+        spliterator.tryAdvance(b);
+        spl3 = spliterator.trySplit();
+        if (spl3 != null) {
+            spl3.tryAdvance(b);
+            spl3.forEachRemaining(b);
+        }
+        spliterator.tryAdvance(b);
+        spliterator.forEachRemaining(b);
+
+        if (sizeIfKnown >= 0) {
+            assertEquals(sizeIfKnown, dest.size());
+        }
+        assertEquals(dest.size(), exp.size());
+
+        asserter.assertContents(dest, exp, isOrdered);
+    }
+
+    public static <T, S extends Spliterator<T>> void testSplitAfterFullTraversal(
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        // Full traversal using tryAdvance
+        Spliterator<T> spliterator = supplier.get();
+        while (spliterator.tryAdvance(boxingAdapter.apply(e -> { }))) { }
+        Spliterator<T> split = spliterator.trySplit();
+        assertNull(split);
+
+        // Full traversal using forEach
+        spliterator = supplier.get();
+        spliterator.forEachRemaining(boxingAdapter.apply(e -> { }));
+        split = spliterator.trySplit();
+        assertNull(split);
+
+        // Full traversal using tryAdvance then forEach
+        spliterator = supplier.get();
+        spliterator.tryAdvance(boxingAdapter.apply(e -> { }));
+        spliterator.forEachRemaining(boxingAdapter.apply(e -> { }));
+        split = spliterator.trySplit();
+        assertNull(split);
+    }
+
+    private static <T, S extends Spliterator<T>> void testSplitOnce(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        S spliterator = supplier.get();
+        long sizeIfKnown = spliterator.getExactSizeIfKnown();
+        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+        ArrayList<T> fromSplit = new ArrayList<>();
+        Spliterator<T> s1 = supplier.get();
+        Spliterator<T> s2 = s1.trySplit();
+        long s1Size = s1.getExactSizeIfKnown();
+        long s2Size = (s2 != null) ? s2.getExactSizeIfKnown() : 0;
+        Consumer<T> addToFromSplit = boxingAdapter.apply(fromSplit::add);
+        if (s2 != null)
+            s2.forEachRemaining(addToFromSplit);
+        s1.forEachRemaining(addToFromSplit);
+
+        if (sizeIfKnown >= 0) {
+            assertEquals(sizeIfKnown, fromSplit.size());
+            if (s1Size >= 0 && s2Size >= 0)
+                assertEquals(sizeIfKnown, s1Size + s2Size);
+        }
+
+        asserter.assertContents(fromSplit, exp, isOrdered);
+    }
+
+    private static <T, S extends Spliterator<T>> void testSplitSixDeep(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        S spliterator = supplier.get();
+        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+        for (int depth=0; depth < 6; depth++) {
+            List<T> dest = new ArrayList<>();
+            spliterator = supplier.get();
+
+            assertSpliterator(spliterator);
+
+            // verify splitting with forEach
+            splitSixDeepVisitor(depth, 0, dest, spliterator, boxingAdapter, spliterator.characteristics(), false);
+            asserter.assertContents(dest, exp, isOrdered);
+
+            // verify splitting with tryAdvance
+            dest.clear();
+            spliterator = supplier.get();
+            splitSixDeepVisitor(depth, 0, dest, spliterator, boxingAdapter, spliterator.characteristics(), true);
+            asserter.assertContents(dest, exp, isOrdered);
+        }
+    }
+
+    private static <T, S extends Spliterator<T>>
+    void splitSixDeepVisitor(int depth, int curLevel,
+                             List<T> dest, S spliterator, UnaryOperator<Consumer<T>> boxingAdapter,
+                             int rootCharacteristics, boolean useTryAdvance) {
+        if (curLevel < depth) {
+            long beforeSize = spliterator.getExactSizeIfKnown();
+            Spliterator<T> split = spliterator.trySplit();
+            if (split != null) {
+                assertSpliterator(split, rootCharacteristics);
+                assertSpliterator(spliterator, rootCharacteristics);
+
+                if ((rootCharacteristics & Spliterator.SUBSIZED) != 0 &&
+                    (rootCharacteristics & Spliterator.SIZED) != 0) {
+                    assertEquals(beforeSize, split.estimateSize() + spliterator.estimateSize());
+                }
+                splitSixDeepVisitor(depth, curLevel + 1, dest, split, boxingAdapter, rootCharacteristics, useTryAdvance);
+            }
+            splitSixDeepVisitor(depth, curLevel + 1, dest, spliterator, boxingAdapter, rootCharacteristics, useTryAdvance);
+        }
+        else {
+            long sizeIfKnown = spliterator.getExactSizeIfKnown();
+            if (useTryAdvance) {
+                Consumer<T> addToDest = boxingAdapter.apply(dest::add);
+                int count = 0;
+                while (spliterator.tryAdvance(addToDest)) {
+                    ++count;
+                }
+
+                if (sizeIfKnown >= 0)
+                    assertEquals(sizeIfKnown, count);
+
+                // Assert that forEach now produces no elements
+                spliterator.forEachRemaining(boxingAdapter.apply(
+                        e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
+
+                Spliterator<T> split = spliterator.trySplit();
+                assertNull(split);
+            }
+            else {
+                List<T> leafDest = new ArrayList<>();
+                Consumer<T> addToLeafDest = boxingAdapter.apply(leafDest::add);
+                spliterator.forEachRemaining(addToLeafDest);
+
+                if (sizeIfKnown >= 0)
+                    assertEquals(sizeIfKnown, leafDest.size());
+
+                // Assert that forEach now produces no elements
+                spliterator.tryAdvance(boxingAdapter.apply(
+                        e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
+
+                Spliterator<T> split = spliterator.trySplit();
+                assertNull(split);
+
+                dest.addAll(leafDest);
+            }
+        }
+    }
+
+    private static <T, S extends Spliterator<T>> void testSplitUntilNull(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        Spliterator<T> s = supplier.get();
+        boolean isOrdered = s.hasCharacteristics(Spliterator.ORDERED);
+        assertSpliterator(s);
+
+        List<T> splits = new ArrayList<>();
+        Consumer<T> c = boxingAdapter.apply(splits::add);
+
+        testSplitUntilNull(new SplitNode<T>(c, s));
+        asserter.assertContents(splits, exp, isOrdered);
+    }
+
+    private static class SplitNode<T> {
+        // Constant for every node
+        final Consumer<T> c;
+        final int rootCharacteristics;
+
+        final Spliterator<T> s;
+
+        SplitNode(Consumer<T> c, Spliterator<T> s) {
+            this(c, s.characteristics(), s);
+        }
+
+        private SplitNode(Consumer<T> c, int rootCharacteristics, Spliterator<T> s) {
+            this.c = c;
+            this.rootCharacteristics = rootCharacteristics;
+            this.s = s;
+        }
+
+        SplitNode<T> fromSplit(Spliterator<T> split) {
+            return new SplitNode<>(c, rootCharacteristics, split);
+        }
+    }
+
+    /**
+     * Set the maximum stack capacity to 0.25MB. This should be more than enough to detect a bad spliterator
+     * while not unduly disrupting test infrastructure given the test data sizes that are used are small.
+     * Note that j.u.c.ForkJoinPool sets the max queue size to 64M (1 << 26).
+     */
+    private static final int MAXIMUM_STACK_CAPACITY = 1 << 18; // 0.25MB
+
+    private static <T> void testSplitUntilNull(SplitNode<T> e) {
+        // Use an explicit stack to avoid a StackOverflowException when testing a Spliterator
+        // that when repeatedly split produces a right-balanced (and maybe degenerate) tree, or
+        // for a spliterator that is badly behaved.
+        Deque<SplitNode<T>> stack = new ArrayDeque<>();
+        stack.push(e);
+
+        int iteration = 0;
+        while (!stack.isEmpty()) {
+            assertTrue(iteration++ < MAXIMUM_STACK_CAPACITY, "Exceeded maximum stack modification count of 1 << 18");
+
+            e = stack.pop();
+            Spliterator<T> parentAndRightSplit = e.s;
+
+            long parentEstimateSize = parentAndRightSplit.estimateSize();
+            assertTrue(parentEstimateSize >= 0,
+                       String.format("Split size estimate %d < 0", parentEstimateSize));
+
+            long parentSize = parentAndRightSplit.getExactSizeIfKnown();
+            Spliterator<T> leftSplit = parentAndRightSplit.trySplit();
+            if (leftSplit == null) {
+                parentAndRightSplit.forEachRemaining(e.c);
+                continue;
+            }
+
+            assertSpliterator(leftSplit, e.rootCharacteristics);
+            assertSpliterator(parentAndRightSplit, e.rootCharacteristics);
+
+            if (parentEstimateSize != Long.MAX_VALUE && leftSplit.estimateSize() > 0
+                && parentAndRightSplit.estimateSize() > 0) {
+                assertTrue(leftSplit.estimateSize() < parentEstimateSize,
+                           String.format("Left split size estimate %d >= parent split size estimate %d",
+                                         leftSplit.estimateSize(), parentEstimateSize));
+                assertTrue(parentAndRightSplit.estimateSize() < parentEstimateSize,
+                           String.format("Right split size estimate %d >= parent split size estimate %d",
+                                         leftSplit.estimateSize(), parentEstimateSize));
+            }
+            else {
+                assertTrue(leftSplit.estimateSize() <= parentEstimateSize,
+                           String.format("Left split size estimate %d > parent split size estimate %d",
+                                         leftSplit.estimateSize(), parentEstimateSize));
+                assertTrue(parentAndRightSplit.estimateSize() <= parentEstimateSize,
+                           String.format("Right split size estimate %d > parent split size estimate %d",
+                                         leftSplit.estimateSize(), parentEstimateSize));
+            }
+
+            long leftSize = leftSplit.getExactSizeIfKnown();
+            long rightSize = parentAndRightSplit.getExactSizeIfKnown();
+            if (parentSize >= 0 && leftSize >= 0 && rightSize >= 0)
+                assertEquals(parentSize, leftSize + rightSize,
+                             String.format("exact left split size %d + exact right split size %d != parent exact split size %d",
+                                           leftSize, rightSize, parentSize));
+
+            // Add right side to stack first so left side is popped off first
+            stack.push(e.fromSplit(parentAndRightSplit));
+            stack.push(e.fromSplit(leftSplit));
+        }
+    }
+
+    private static void assertSpliterator(Spliterator<?> s, int rootCharacteristics) {
+        if ((rootCharacteristics & Spliterator.SUBSIZED) != 0) {
+            assertTrue(s.hasCharacteristics(Spliterator.SUBSIZED),
+                       "Child split is not SUBSIZED when root split is SUBSIZED");
+        }
+        assertSpliterator(s);
+    }
+
+    private static void assertSpliterator(Spliterator<?> s) {
+        if (s.hasCharacteristics(Spliterator.SUBSIZED)) {
+            assertTrue(s.hasCharacteristics(Spliterator.SIZED));
+        }
+        if (s.hasCharacteristics(Spliterator.SIZED)) {
+            assertTrue(s.estimateSize() != Long.MAX_VALUE);
+            assertTrue(s.getExactSizeIfKnown() >= 0);
+        }
+        try {
+            s.getComparator();
+            assertTrue(s.hasCharacteristics(Spliterator.SORTED));
+        } catch (IllegalStateException e) {
+            assertFalse(s.hasCharacteristics(Spliterator.SORTED));
+        }
+    }
+
+    private static<T> void assertContents(Collection<T> actual, Collection<T> expected, boolean isOrdered) {
+        if (isOrdered) {
+            assertEquals(actual, expected);
+        }
+        else {
+            LambdaTestHelpers.assertContentsUnordered(actual, expected);
+        }
+    }
+
+    public static void assertThrowsNPE(ThrowingRunnable r) {
+        assertThrows(NullPointerException.class, r);
+    }
+
+    public static<U> void mixedTraverseAndSplit(Consumer<U> b, Spliterator<U> splTop) {
+        Spliterator<U> spl1, spl2, spl3;
+        splTop.tryAdvance(b);
+        spl2 = splTop.trySplit();
+        if (spl2 != null) {
+            spl2.tryAdvance(b);
+            spl1 = spl2.trySplit();
+            if (spl1 != null) {
+                spl1.tryAdvance(b);
+                spl1.forEachRemaining(b);
+            }
+            spl2.tryAdvance(b);
+            spl2.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        spl3 = splTop.trySplit();
+        if (spl3 != null) {
+            spl3.tryAdvance(b);
+            spl3.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        splTop.forEachRemaining(b);
+    }
+
+    public static void mixedTraverseAndSplit(IntConsumer b, Spliterator.OfInt splTop) {
+        Spliterator.OfInt spl1, spl2, spl3;
+        splTop.tryAdvance(b);
+        spl2 = splTop.trySplit();
+        if (spl2 != null) {
+            spl2.tryAdvance(b);
+            spl1 = spl2.trySplit();
+            if (spl1 != null) {
+                spl1.tryAdvance(b);
+                spl1.forEachRemaining(b);
+            }
+            spl2.tryAdvance(b);
+            spl2.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        spl3 = splTop.trySplit();
+        if (spl3 != null) {
+            spl3.tryAdvance(b);
+            spl3.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        splTop.forEachRemaining(b);
+    }
+
+    public static void mixedTraverseAndSplit(LongConsumer b, Spliterator.OfLong splTop) {
+        Spliterator.OfLong spl1, spl2, spl3;
+        splTop.tryAdvance(b);
+        spl2 = splTop.trySplit();
+        if (spl2 != null) {
+            spl2.tryAdvance(b);
+            spl1 = spl2.trySplit();
+            if (spl1 != null) {
+                spl1.tryAdvance(b);
+                spl1.forEachRemaining(b);
+            }
+            spl2.tryAdvance(b);
+            spl2.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        spl3 = splTop.trySplit();
+        if (spl3 != null) {
+            spl3.tryAdvance(b);
+            spl3.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        splTop.forEachRemaining(b);
+    }
+
+    public static void mixedTraverseAndSplit(DoubleConsumer b, Spliterator.OfDouble splTop) {
+        Spliterator.OfDouble spl1, spl2, spl3;
+        splTop.tryAdvance(b);
+        spl2 = splTop.trySplit();
+        if (spl2 != null) {
+            spl2.tryAdvance(b);
+            spl1 = spl2.trySplit();
+            if (spl1 != null) {
+                spl1.tryAdvance(b);
+                spl1.forEachRemaining(b);
+            }
+            spl2.tryAdvance(b);
+            spl2.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        spl3 = splTop.trySplit();
+        if (spl3 != null) {
+            spl3.tryAdvance(b);
+            spl3.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        splTop.forEachRemaining(b);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/CollectorOps.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+package java.util.stream;
+
+import org.testng.Assert;
+
+import java.util.Spliterator;
+import java.util.function.IntFunction;
+
+/** Test helper class for java.util.stream test framework */
+public final class CollectorOps {
+    private CollectorOps() { }
+
+    public static <E_IN> StatefulTestOp<E_IN> collector() {
+        return new StatefulCollector<>(0, StreamShape.REFERENCE);
+    }
+
+    /* Utility classes for collecting output of intermediate pipeline stages */
+    public static class StatefulCollector<E_IN> implements StatefulTestOp<E_IN> {
+        private final int opFlags;
+        private final StreamShape inputShape;
+
+        public StatefulCollector(int opFlags, StreamShape inputShape) {
+            this.opFlags = opFlags;
+            this.inputShape = inputShape;
+        }
+
+        @Override
+        public StreamShape inputShape() {
+            return inputShape;
+        }
+
+        @Override
+        public StreamShape outputShape() {
+            return inputShape;
+        }
+
+        @Override
+        public int opGetFlags() {
+            return opFlags;
+        }
+
+        @Override
+        public Sink<E_IN> opWrapSink(int flags, boolean parallel, Sink<E_IN> sink) {
+            return sink;
+        }
+
+        @Override
+        public <P_IN> Node<E_IN> opEvaluateParallel(PipelineHelper<E_IN> helper,
+                                                    Spliterator<P_IN> spliterator,
+                                                    IntFunction<E_IN[]> generator) {
+            return helper.evaluate(spliterator, false, generator);
+        }
+    }
+
+    public static class TestParallelSizedOp<T> extends StatefulCollector<T> {
+        public TestParallelSizedOp() {
+            this(StreamShape.REFERENCE);
+        }
+
+        protected TestParallelSizedOp(StreamShape shape) {
+            super(0, shape);
+        }
+
+        @Override
+        public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
+                                                 Spliterator<P_IN> spliterator,
+                                                 IntFunction<T[]> generator) {
+            int flags = helper.getStreamAndOpFlags();
+
+            Assert.assertTrue(StreamOpFlag.SIZED.isKnown(flags));
+            return super.opEvaluateParallel(helper, spliterator, generator);
+        }
+
+        public static class OfInt extends TestParallelSizedOp<Integer> {
+            public OfInt() {
+                super(StreamShape.INT_VALUE);
+            }
+        }
+
+        public static class OfLong extends TestParallelSizedOp<Long> {
+            public OfLong() {
+                super(StreamShape.LONG_VALUE);
+            }
+        }
+
+        public static class OfDouble extends TestParallelSizedOp<Double> {
+            public OfDouble() {
+                super(StreamShape.DOUBLE_VALUE);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/DefaultMethodStreams.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,984 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Comparator;
+import java.util.DoubleSummaryStatistics;
+import java.util.IntSummaryStatistics;
+import java.util.Iterator;
+import java.util.LongSummaryStatistics;
+import java.util.Optional;
+import java.util.OptionalDouble;
+import java.util.OptionalInt;
+import java.util.OptionalLong;
+import java.util.PrimitiveIterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.BinaryOperator;
+import java.util.function.Consumer;
+import java.util.function.DoubleBinaryOperator;
+import java.util.function.DoubleConsumer;
+import java.util.function.DoubleFunction;
+import java.util.function.DoublePredicate;
+import java.util.function.DoubleToIntFunction;
+import java.util.function.DoubleToLongFunction;
+import java.util.function.DoubleUnaryOperator;
+import java.util.function.Function;
+import java.util.function.IntBinaryOperator;
+import java.util.function.IntConsumer;
+import java.util.function.IntFunction;
+import java.util.function.IntPredicate;
+import java.util.function.IntToDoubleFunction;
+import java.util.function.IntToLongFunction;
+import java.util.function.IntUnaryOperator;
+import java.util.function.LongBinaryOperator;
+import java.util.function.LongConsumer;
+import java.util.function.LongFunction;
+import java.util.function.LongPredicate;
+import java.util.function.LongToDoubleFunction;
+import java.util.function.LongToIntFunction;
+import java.util.function.LongUnaryOperator;
+import java.util.function.ObjDoubleConsumer;
+import java.util.function.ObjIntConsumer;
+import java.util.function.ObjLongConsumer;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.function.ToDoubleFunction;
+
+import java.util.function.ToIntFunction;
+import java.util.function.ToLongFunction;
+
+import static java.util.stream.Collectors.*;
+
+public final class DefaultMethodStreams {
+
+    static {
+        // Verify that default methods are not overridden
+        verify(DefaultMethodRefStream.class);
+        verify(DefaultMethodIntStream.class);
+        verify(DefaultMethodLongStream.class);
+        verify(DefaultMethodDoubleStream.class);
+    }
+
+    static void verify(Class<?> del) {
+        // Find the stream interface
+        Class<?> s = Stream.of(del.getInterfaces())
+                .filter(c -> BaseStream.class.isAssignableFrom(c))
+                .findFirst().get();
+
+        // Get all default methods on the stream class
+        Set<String> dms = Stream.of(s.getMethods())
+                .filter(m -> !Modifier.isStatic(m.getModifiers()))
+                .filter(m -> !m.isBridge())
+                .filter(Method::isDefault)
+                .map(Method::getName)
+                .collect(toSet());
+
+        // Get all methods on the delegating class
+        Set<String> ims = Stream.of(del.getMethods())
+                .filter(m -> !Modifier.isStatic(m.getModifiers()))
+                .filter(m -> m.getDeclaringClass() == del)
+                .map(Method::getName)
+                .collect(toSet());
+
+        if (ims.stream().anyMatch(dms::contains)) {
+            throw new AssertionError(String.format("%s overrides default methods of %s\n", del, s));
+        }
+    }
+
+    /**
+     * Creates a stream that for the next operation either delegates to
+     * a default method on {@link Stream}, if present for that operation,
+     * otherwise delegates to an underlying stream.
+     *
+     * @param s the underlying stream to be delegated to for non-default
+     * methods.
+     * @param <T> the type of the stream elements
+     * @return the delegating stream
+     */
+    public static <T> Stream<T> delegateTo(Stream<T> s) {
+        return new DefaultMethodRefStream<>(s);
+    }
+
+    /**
+     * Creates a stream that for the next operation either delegates to
+     * a default method on {@link IntStream}, if present for that operation,
+     * otherwise delegates to an underlying stream.
+     *
+     * @param s the underlying stream to be delegated to for non-default
+     * methods.
+     * @return the delegating stream
+     */
+    public static IntStream delegateTo(IntStream s) {
+        return new DefaultMethodIntStream(s);
+    }
+
+    /**
+     * Creates a stream that for the next operation either delegates to
+     * a default method on {@link LongStream}, if present for that operation,
+     * otherwise delegates to an underlying stream.
+     *
+     * @param s the underlying stream to be delegated to for non-default
+     * methods.
+     * @return the delegating stream
+     */
+    public static LongStream delegateTo(LongStream s) {
+        return new DefaultMethodLongStream(s);
+    }
+
+    /**
+     * Creates a stream that for the next operation either delegates to
+     * a default method on {@link DoubleStream}, if present for that operation,
+     * otherwise delegates to an underlying stream.
+     *
+     * @param s the underlying stream to be delegated to for non-default
+     * methods.
+     * @return the delegating stream
+     */
+    public static DoubleStream delegateTo(DoubleStream s) {
+        return new DefaultMethodDoubleStream(s);
+    }
+
+    /**
+     * A stream that delegates the next operation to a default method, if
+     * present, or to the same operation of an underlying stream.
+     *
+     * @param <T> the type of the stream elements
+     */
+    static final class DefaultMethodRefStream<T> implements Stream<T> {
+        final Stream<T> s;
+
+        DefaultMethodRefStream(Stream<T> s) {
+            this.s = s;
+        }
+
+
+        // Delegating non-default methods
+
+        @Override
+        public Stream<T> filter(Predicate<? super T> predicate) {
+            return s.filter(predicate);
+        }
+
+        @Override
+        public <R> Stream<R> map(Function<? super T, ? extends R> mapper) {
+            return s.map(mapper);
+        }
+
+        @Override
+        public IntStream mapToInt(ToIntFunction<? super T> mapper) {
+            return s.mapToInt(mapper);
+        }
+
+        @Override
+        public LongStream mapToLong(ToLongFunction<? super T> mapper) {
+            return s.mapToLong(mapper);
+        }
+
+        @Override
+        public DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper) {
+            return s.mapToDouble(mapper);
+        }
+
+        @Override
+        public <R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper) {
+            return s.flatMap(mapper);
+        }
+
+        @Override
+        public IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper) {
+            return s.flatMapToInt(mapper);
+        }
+
+        @Override
+        public LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper) {
+            return s.flatMapToLong(mapper);
+        }
+
+        @Override
+        public DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper) {
+            return s.flatMapToDouble(mapper);
+        }
+
+        @Override
+        public Stream<T> distinct() {
+            return s.distinct();
+        }
+
+        @Override
+        public Stream<T> sorted() {
+            return s.sorted();
+        }
+
+        @Override
+        public Stream<T> sorted(Comparator<? super T> comparator) {
+            return s.sorted(comparator);
+        }
+
+        @Override
+        public Stream<T> peek(Consumer<? super T> action) {
+            return s.peek(action);
+        }
+
+        @Override
+        public Stream<T> limit(long maxSize) {
+            return s.limit(maxSize);
+        }
+
+        @Override
+        public Stream<T> skip(long n) {
+            return s.skip(n);
+        }
+
+        @Override
+        public void forEach(Consumer<? super T> action) {
+            s.forEach(action);
+        }
+
+        @Override
+        public void forEachOrdered(Consumer<? super T> action) {
+            s.forEachOrdered(action);
+        }
+
+        @Override
+        public Object[] toArray() {
+            return s.toArray();
+        }
+
+        @Override
+        public <A> A[] toArray(IntFunction<A[]> generator) {
+            return s.toArray(generator);
+        }
+
+        @Override
+        public T reduce(T identity, BinaryOperator<T> accumulator) {
+            return s.reduce(identity, accumulator);
+        }
+
+        @Override
+        public Optional<T> reduce(BinaryOperator<T> accumulator) {
+            return s.reduce(accumulator);
+        }
+
+        @Override
+        public <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) {
+            return s.reduce(identity, accumulator, combiner);
+        }
+
+        @Override
+        public <R> R collect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner) {
+            return s.collect(supplier, accumulator, combiner);
+        }
+
+        @Override
+        public <R, A> R collect(Collector<? super T, A, R> collector) {
+            return s.collect(collector);
+        }
+
+        @Override
+        public Optional<T> min(Comparator<? super T> comparator) {
+            return s.min(comparator);
+        }
+
+        @Override
+        public Optional<T> max(Comparator<? super T> comparator) {
+            return s.max(comparator);
+        }
+
+        @Override
+        public long count() {
+            return s.count();
+        }
+
+        @Override
+        public boolean anyMatch(Predicate<? super T> predicate) {
+            return s.anyMatch(predicate);
+        }
+
+        @Override
+        public boolean allMatch(Predicate<? super T> predicate) {
+            return s.allMatch(predicate);
+        }
+
+        @Override
+        public boolean noneMatch(Predicate<? super T> predicate) {
+            return s.noneMatch(predicate);
+        }
+
+        @Override
+        public Optional<T> findFirst() {
+            return s.findFirst();
+        }
+
+        @Override
+        public Optional<T> findAny() {
+            return s.findAny();
+        }
+
+        @Override
+        public Iterator<T> iterator() {
+            return s.iterator();
+        }
+
+        @Override
+        public Spliterator<T> spliterator() {
+            return s.spliterator();
+        }
+
+        @Override
+        public boolean isParallel() {
+            return s.isParallel();
+        }
+
+        @Override
+        public Stream<T> sequential() {
+            return s.sequential();
+        }
+
+        @Override
+        public Stream<T> parallel() {
+            return s.parallel();
+        }
+
+        @Override
+        public Stream<T> unordered() {
+            return s.unordered();
+        }
+
+        @Override
+        public Stream<T> onClose(Runnable closeHandler) {
+            return s.onClose(closeHandler);
+        }
+
+        @Override
+        public void close() {
+            s.close();
+        }
+    }
+
+    static final class DefaultMethodIntStream implements IntStream {
+        final IntStream s;
+
+        public DefaultMethodIntStream(IntStream s) {
+            this.s = s;
+        }
+
+
+        // Delegating non-default methods
+
+        @Override
+        public IntStream filter(IntPredicate predicate) {
+            return s.filter(predicate);
+        }
+
+        @Override
+        public IntStream map(IntUnaryOperator mapper) {
+            return s.map(mapper);
+        }
+
+        @Override
+        public <U> Stream<U> mapToObj(IntFunction<? extends U> mapper) {
+            return s.mapToObj(mapper);
+        }
+
+        @Override
+        public LongStream mapToLong(IntToLongFunction mapper) {
+            return s.mapToLong(mapper);
+        }
+
+        @Override
+        public DoubleStream mapToDouble(IntToDoubleFunction mapper) {
+            return s.mapToDouble(mapper);
+        }
+
+        @Override
+        public IntStream flatMap(IntFunction<? extends IntStream> mapper) {
+            return s.flatMap(mapper);
+        }
+
+        @Override
+        public IntStream distinct() {
+            return s.distinct();
+        }
+
+        @Override
+        public IntStream sorted() {
+            return s.sorted();
+        }
+
+        @Override
+        public IntStream peek(IntConsumer action) {
+            return s.peek(action);
+        }
+
+        @Override
+        public IntStream limit(long maxSize) {
+            return s.limit(maxSize);
+        }
+
+        @Override
+        public IntStream skip(long n) {
+            return s.skip(n);
+        }
+
+        @Override
+        public void forEach(IntConsumer action) {
+            s.forEach(action);
+        }
+
+        @Override
+        public void forEachOrdered(IntConsumer action) {
+            s.forEachOrdered(action);
+        }
+
+        @Override
+        public int[] toArray() {
+            return s.toArray();
+        }
+
+        @Override
+        public int reduce(int identity, IntBinaryOperator op) {
+            return s.reduce(identity, op);
+        }
+
+        @Override
+        public OptionalInt reduce(IntBinaryOperator op) {
+            return s.reduce(op);
+        }
+
+        @Override
+        public <R> R collect(Supplier<R> supplier, ObjIntConsumer<R> accumulator, BiConsumer<R, R> combiner) {
+            return s.collect(supplier, accumulator, combiner);
+        }
+
+        @Override
+        public int sum() {
+            return s.sum();
+        }
+
+        @Override
+        public OptionalInt min() {
+            return s.min();
+        }
+
+        @Override
+        public OptionalInt max() {
+            return s.max();
+        }
+
+        @Override
+        public long count() {
+            return s.count();
+        }
+
+        @Override
+        public OptionalDouble average() {
+            return s.average();
+        }
+
+        @Override
+        public IntSummaryStatistics summaryStatistics() {
+            return s.summaryStatistics();
+        }
+
+        @Override
+        public boolean anyMatch(IntPredicate predicate) {
+            return s.anyMatch(predicate);
+        }
+
+        @Override
+        public boolean allMatch(IntPredicate predicate) {
+            return s.allMatch(predicate);
+        }
+
+        @Override
+        public boolean noneMatch(IntPredicate predicate) {
+            return s.noneMatch(predicate);
+        }
+
+        @Override
+        public OptionalInt findFirst() {
+            return s.findFirst();
+        }
+
+        @Override
+        public OptionalInt findAny() {
+            return s.findAny();
+        }
+
+        @Override
+        public LongStream asLongStream() {
+            return s.asLongStream();
+        }
+
+        @Override
+        public DoubleStream asDoubleStream() {
+            return s.asDoubleStream();
+        }
+
+        @Override
+        public Stream<Integer> boxed() {
+            return s.boxed();
+        }
+
+        @Override
+        public IntStream sequential() {
+            return s.sequential();
+        }
+
+        @Override
+        public IntStream parallel() {
+            return s.parallel();
+        }
+
+        @Override
+        public PrimitiveIterator.OfInt iterator() {
+            return s.iterator();
+        }
+
+        @Override
+        public Spliterator.OfInt spliterator() {
+            return s.spliterator();
+        }
+
+        @Override
+        public boolean isParallel() {
+            return s.isParallel();
+        }
+
+        @Override
+        public IntStream unordered() {
+            return s.unordered();
+        }
+
+        @Override
+        public IntStream onClose(Runnable closeHandler) {
+            return s.onClose(closeHandler);
+        }
+
+        @Override
+        public void close() {
+            s.close();
+        }
+    }
+
+    static final class DefaultMethodLongStream implements LongStream {
+        final LongStream s;
+
+        public DefaultMethodLongStream(LongStream s) {
+            this.s = s;
+        }
+
+
+        // Delegating non-default methods
+
+        @Override
+        public void forEach(LongConsumer action) {
+            s.forEach(action);
+        }
+
+        @Override
+        public LongStream filter(LongPredicate predicate) {
+            return s.filter(predicate);
+        }
+
+        @Override
+        public LongStream map(LongUnaryOperator mapper) {
+            return s.map(mapper);
+        }
+
+        @Override
+        public <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
+            return s.mapToObj(mapper);
+        }
+
+        @Override
+        public IntStream mapToInt(LongToIntFunction mapper) {
+            return s.mapToInt(mapper);
+        }
+
+        @Override
+        public DoubleStream mapToDouble(LongToDoubleFunction mapper) {
+            return s.mapToDouble(mapper);
+        }
+
+        @Override
+        public LongStream flatMap(LongFunction<? extends LongStream> mapper) {
+            return s.flatMap(mapper);
+        }
+
+        @Override
+        public LongStream distinct() {
+            return s.distinct();
+        }
+
+        @Override
+        public LongStream sorted() {
+            return s.sorted();
+        }
+
+        @Override
+        public LongStream peek(LongConsumer action) {
+            return s.peek(action);
+        }
+
+        @Override
+        public LongStream limit(long maxSize) {
+            return s.limit(maxSize);
+        }
+
+        @Override
+        public LongStream skip(long n) {
+            return s.skip(n);
+        }
+
+        @Override
+        public void forEachOrdered(LongConsumer action) {
+            s.forEachOrdered(action);
+        }
+
+        @Override
+        public long[] toArray() {
+            return s.toArray();
+        }
+
+        @Override
+        public long reduce(long identity, LongBinaryOperator op) {
+            return s.reduce(identity, op);
+        }
+
+        @Override
+        public OptionalLong reduce(LongBinaryOperator op) {
+            return s.reduce(op);
+        }
+
+        @Override
+        public <R> R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R, R> combiner) {
+            return s.collect(supplier, accumulator, combiner);
+        }
+
+        @Override
+        public long sum() {
+            return s.sum();
+        }
+
+        @Override
+        public OptionalLong min() {
+            return s.min();
+        }
+
+        @Override
+        public OptionalLong max() {
+            return s.max();
+        }
+
+        @Override
+        public long count() {
+            return s.count();
+        }
+
+        @Override
+        public OptionalDouble average() {
+            return s.average();
+        }
+
+        @Override
+        public LongSummaryStatistics summaryStatistics() {
+            return s.summaryStatistics();
+        }
+
+        @Override
+        public boolean anyMatch(LongPredicate predicate) {
+            return s.anyMatch(predicate);
+        }
+
+        @Override
+        public boolean allMatch(LongPredicate predicate) {
+            return s.allMatch(predicate);
+        }
+
+        @Override
+        public boolean noneMatch(LongPredicate predicate) {
+            return s.noneMatch(predicate);
+        }
+
+        @Override
+        public OptionalLong findFirst() {
+            return s.findFirst();
+        }
+
+        @Override
+        public OptionalLong findAny() {
+            return s.findAny();
+        }
+
+        @Override
+        public DoubleStream asDoubleStream() {
+            return s.asDoubleStream();
+        }
+
+        @Override
+        public Stream<Long> boxed() {
+            return s.boxed();
+        }
+
+        @Override
+        public LongStream sequential() {
+            return s.sequential();
+        }
+
+        @Override
+        public LongStream parallel() {
+            return s.parallel();
+        }
+
+        @Override
+        public PrimitiveIterator.OfLong iterator() {
+            return s.iterator();
+        }
+
+        @Override
+        public Spliterator.OfLong spliterator() {
+            return s.spliterator();
+        }
+
+        @Override
+        public boolean isParallel() {
+            return s.isParallel();
+        }
+
+        @Override
+        public LongStream unordered() {
+            return s.unordered();
+        }
+
+        @Override
+        public LongStream onClose(Runnable closeHandler) {
+            return s.onClose(closeHandler);
+        }
+
+        @Override
+        public void close() {
+            s.close();
+        }
+    }
+
+    static final class DefaultMethodDoubleStream implements DoubleStream {
+        final DoubleStream s;
+
+        public DefaultMethodDoubleStream(DoubleStream s) {
+            this.s = s;
+        }
+
+        @Override
+        public DoubleStream filter(DoublePredicate predicate) {
+            return s.filter(predicate);
+        }
+
+        @Override
+        public DoubleStream map(DoubleUnaryOperator mapper) {
+            return s.map(mapper);
+        }
+
+        @Override
+        public <U> Stream<U> mapToObj(DoubleFunction<? extends U> mapper) {
+            return s.mapToObj(mapper);
+        }
+
+        @Override
+        public IntStream mapToInt(DoubleToIntFunction mapper) {
+            return s.mapToInt(mapper);
+        }
+
+        @Override
+        public LongStream mapToLong(DoubleToLongFunction mapper) {
+            return s.mapToLong(mapper);
+        }
+
+        @Override
+        public DoubleStream flatMap(DoubleFunction<? extends DoubleStream> mapper) {
+            return s.flatMap(mapper);
+        }
+
+        @Override
+        public DoubleStream distinct() {
+            return s.distinct();
+        }
+
+        @Override
+        public DoubleStream sorted() {
+            return s.sorted();
+        }
+
+        @Override
+        public DoubleStream peek(DoubleConsumer action) {
+            return s.peek(action);
+        }
+
+        @Override
+        public DoubleStream limit(long maxSize) {
+            return s.limit(maxSize);
+        }
+
+        @Override
+        public DoubleStream skip(long n) {
+            return s.skip(n);
+        }
+
+        @Override
+        public void forEach(DoubleConsumer action) {
+            s.forEach(action);
+        }
+
+        @Override
+        public void forEachOrdered(DoubleConsumer action) {
+            s.forEachOrdered(action);
+        }
+
+        @Override
+        public double[] toArray() {
+            return s.toArray();
+        }
+
+        @Override
+        public double reduce(double identity, DoubleBinaryOperator op) {
+            return s.reduce(identity, op);
+        }
+
+        @Override
+        public OptionalDouble reduce(DoubleBinaryOperator op) {
+            return s.reduce(op);
+        }
+
+        @Override
+        public <R> R collect(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R, R> combiner) {
+            return s.collect(supplier, accumulator, combiner);
+        }
+
+        @Override
+        public double sum() {
+            return s.sum();
+        }
+
+        @Override
+        public OptionalDouble min() {
+            return s.min();
+        }
+
+        @Override
+        public OptionalDouble max() {
+            return s.max();
+        }
+
+        @Override
+        public long count() {
+            return s.count();
+        }
+
+        @Override
+        public OptionalDouble average() {
+            return s.average();
+        }
+
+        @Override
+        public DoubleSummaryStatistics summaryStatistics() {
+            return s.summaryStatistics();
+        }
+
+        @Override
+        public boolean anyMatch(DoublePredicate predicate) {
+            return s.anyMatch(predicate);
+        }
+
+        @Override
+        public boolean allMatch(DoublePredicate predicate) {
+            return s.allMatch(predicate);
+        }
+
+        @Override
+        public boolean noneMatch(DoublePredicate predicate) {
+            return s.noneMatch(predicate);
+        }
+
+        @Override
+        public OptionalDouble findFirst() {
+            return s.findFirst();
+        }
+
+        @Override
+        public OptionalDouble findAny() {
+            return s.findAny();
+        }
+
+        @Override
+        public Stream<Double> boxed() {
+            return s.boxed();
+        }
+
+        @Override
+        public DoubleStream sequential() {
+            return s.sequential();
+        }
+
+        @Override
+        public DoubleStream parallel() {
+            return s.parallel();
+        }
+
+        @Override
+        public PrimitiveIterator.OfDouble iterator() {
+            return s.iterator();
+        }
+
+        @Override
+        public Spliterator.OfDouble spliterator() {
+            return s.spliterator();
+        }
+
+        @Override
+        public boolean isParallel() {
+            return s.isParallel();
+        }
+
+        @Override
+        public DoubleStream unordered() {
+            return s.unordered();
+        }
+
+        @Override
+        public DoubleStream onClose(Runnable closeHandler) {
+            return s.onClose(closeHandler);
+        }
+
+        @Override
+        public void close() {
+            s.close();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/DoubleStreamTestDataProvider.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+
+/** TestNG DataProvider for double-valued streams */
+public class DoubleStreamTestDataProvider {
+    private static final double[] to0 = new double[0];
+    private static final double[] to1 = new double[1];
+    private static final double[] to10 = new double[10];
+    private static final double[] to100 = new double[100];
+    private static final double[] to1000 = new double[1000];
+    private static final double[] reversed = new double[100];
+    private static final double[] ones = new double[100];
+    private static final double[] twice = new double[200];
+    private static final double[] pseudoRandom;
+
+    private static final Object[][] testData;
+    private static final Object[][] testSmallData;
+    private static final Object[][] spliteratorTestData;
+
+    static {
+        double[][] arrays = {to0, to1, to10, to100, to1000};
+        for (double[] arr : arrays) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = i;
+            }
+        }
+        for (int i = 0; i < reversed.length; i++) {
+            reversed[i] = reversed.length - i;
+        }
+        for (int i = 0; i < ones.length; i++) {
+            ones[i] = 1;
+        }
+        System.arraycopy(to100, 0, twice, 0, to100.length);
+        System.arraycopy(to100, 0, twice, to100.length, to100.length);
+        pseudoRandom = new double[LambdaTestHelpers.LONG_STRING.length()];
+        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+            pseudoRandom[i] = (double) LambdaTestHelpers.LONG_STRING.charAt(i);
+        }
+    }
+
+    static final Object[][] arrays = {
+            {"empty", to0},
+            {"0..1", to1},
+            {"0..10", to10},
+            {"0..100", to100},
+            {"0..1000", to1000},
+            {"100x[1]", ones},
+            {"2x[0..100]", twice},
+            {"reverse 0..100", reversed},
+            {"pseudorandom", pseudoRandom}
+    };
+
+    static {
+        {
+            List<Object[]> listSmall = new ArrayList<>();
+            List<Object[]> list1000 = new ArrayList<>();
+            List<Object[]> list = null;
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final double[] doubles = (double[]) data[1];
+
+                list = doubles.length >= 1000 ? list1000 : listSmall;
+
+                list.add(new Object[]{"array:" + name,
+                        TestData.Factory.ofArray("array:" + name, doubles)});
+
+                SpinedBuffer.OfDouble isl = new SpinedBuffer.OfDouble();
+                for (double i : doubles) {
+                    isl.accept(i);
+                }
+                list.add(new Object[]{"SpinedList:" + name,
+                        TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
+            }
+            testSmallData = listSmall.toArray(new Object[0][]);
+            list1000.addAll(listSmall);
+            testData = list1000.toArray(new Object[0][]);
+        }
+
+        {
+            List<Object[]> spliterators = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final double[] doubles = (double[]) data[1];
+
+                SpinedBuffer.OfDouble isl = new SpinedBuffer.OfDouble();
+                for (double i : doubles) {
+                    isl.accept(i);
+                }
+
+                spliterators.add(splitDescr("Arrays.s(array):" + name,
+                                            () -> Arrays.spliterator(doubles)));
+                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
+                                            () -> Arrays.spliterator(doubles, 0, doubles.length / 2)));
+
+                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+                                            () -> isl.spliterator()));
+
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
+                                            () -> Spliterators.spliterator(isl.iterator(), doubles.length, 0)));
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
+                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
+                spliterators.add(splitDescr("DoubleStream.iterate(0,x->x<l;x->x+1):" + name,
+                                            () -> DoubleStream.iterate(0.0, x -> x < doubles.length, x -> x + 1.0)
+                                                              .spliterator()));
+                // Need more!
+            }
+            spliteratorTestData = spliterators.toArray(new Object[0][]);
+        }
+
+    }
+
+    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfDouble> s) {
+        return new Object[] { description, s };
+    }
+
+    // Return an array of ( String name, DoubleStreamTestData )
+    @DataProvider(name = "DoubleStreamTestData")
+    public static Object[][] makeDoubleStreamTestData() {
+        return testData;
+    }
+
+    @DataProvider(name = "DoubleStreamTestData.small")
+    public static Object[][] makeSmallDoubleStreamTestData() {
+        return testSmallData;
+    }
+
+    // returns an array of (String name, Supplier<PrimitiveSpliterator<Double>>)
+    @DataProvider(name = "DoubleSpliterator")
+    public static Object[][] spliteratorProvider() {
+        return spliteratorTestData;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/DoubleStreamTestScenario.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.PrimitiveIterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.SpliteratorTestHelper;
+import java.util.function.Consumer;
+import java.util.function.DoubleConsumer;
+import java.util.function.Function;
+
+/**
+ * Test scenarios for double streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results.  Each scenario describes a different way of computing the
+ * stream contents.  The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum DoubleStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+    STREAM_FOR_EACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            DoubleStream s = m.apply(source);
+            if (s.isParallel()) {
+                s = s.sequential();
+            }
+            s.forEach(b);
+        }
+    },
+
+    STREAM_TO_ARRAY(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (double t : m.apply(source).toArray()) {
+                b.accept(t);
+            }
+        }
+    },
+
+    STREAM_ITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (PrimitiveIterator.OfDouble seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
+                b.accept(seqIter.nextDouble());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (Spliterator.OfDouble spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR_FOREACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            m.apply(source).sequential().forEach(b);
+        }
+    },
+
+    // Wrap as parallel stream + forEachOrdered
+    PAR_STREAM_FOR_EACH_ORDERED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            // @@@ Want to explicitly select ordered equalator
+            m.apply(source).forEachOrdered(b);
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (Spliterator.OfDouble spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR_FOREACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (double t : m.apply(source).toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            DoubleStream s = m.apply(source);
+            Spliterator.OfDouble sp = s.spliterator();
+            DoubleStream ss = StreamSupport.doubleStream(() -> sp,
+                                                         StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+                                                         | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
+            for (double t : ss.toArray())
+                b.accept(t);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            DoubleStream pipe2 = m.apply(pipe1);
+
+            for (double t : pipe2.toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing
+    PAR_STREAM_FOR_EACH(true, false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            m.apply(source).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
+    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            m.apply(pipe1).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+    ;
+
+    // The set of scenarios that clean the SIZED flag
+    public static final Set<DoubleStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
+            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
+
+    private boolean isParallel;
+
+    private final boolean isOrdered;
+
+    DoubleStreamTestScenario(boolean isParallel) {
+        this(isParallel, true);
+    }
+
+    DoubleStreamTestScenario(boolean isParallel, boolean isOrdered) {
+        this.isParallel = isParallel;
+        this.isOrdered = isOrdered;
+    }
+
+    public StreamShape getShape() {
+        return StreamShape.DOUBLE_VALUE;
+    }
+
+    public boolean isParallel() {
+        return isParallel;
+    }
+
+    public boolean isOrdered() {
+        return isOrdered;
+    }
+
+    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+        try (S_IN source = getStream(data)) {
+            run(data, source, (DoubleConsumer) b, (Function<S_IN, DoubleStream>) m);
+        }
+    }
+
+    abstract <T, S_IN extends BaseStream<T, S_IN>>
+    void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/FlagDeclaringOp.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+package java.util.stream;
+
+/**
+ * An operation that injects or clears flags but otherwise performs no operation on elements.
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class FlagDeclaringOp<T> implements StatelessTestOp<T, T> {
+    private final int flags;
+    private final StreamShape shape;
+
+    public FlagDeclaringOp(int flags) {
+        this(flags, StreamShape.REFERENCE);
+    }
+
+    public FlagDeclaringOp(int flags, StreamShape shape) {
+        this.flags = flags;
+        this.shape = shape;
+    }
+
+    @Override
+    public StreamShape outputShape() {
+        return shape;
+    }
+
+    @Override
+    public StreamShape inputShape() {
+        return shape;
+    }
+
+    @Override
+    public int opGetFlags() {
+        return flags;
+    }
+
+    @Override
+    public Sink<T> opWrapSink(int flags, boolean parallel, Sink sink) {
+        return sink;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/IntStreamTestDataProvider.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+
+/** TestNG DataProvider for int-valued streams */
+public class IntStreamTestDataProvider {
+    private static final int[] to0 = new int[0];
+    private static final int[] to1 = new int[1];
+    private static final int[] to10 = new int[10];
+    private static final int[] to100 = new int[100];
+    private static final int[] to1000 = new int[1000];
+    private static final int[] reversed = new int[100];
+    private static final int[] ones = new int[100];
+    private static final int[] twice = new int[200];
+    private static final int[] pseudoRandom;
+
+    private static final Object[][] testData;
+    private static final Object[][] testSmallData;
+    private static final Object[][] spliteratorTestData;
+
+    static {
+        int[][] arrays = {to0, to1, to10, to100, to1000};
+        for (int[] arr : arrays) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = i;
+            }
+        }
+        for (int i = 0; i < reversed.length; i++) {
+            reversed[i] = reversed.length - i;
+        }
+        for (int i = 0; i < ones.length; i++) {
+            ones[i] = 1;
+        }
+        System.arraycopy(to100, 0, twice, 0, to100.length);
+        System.arraycopy(to100, 0, twice, to100.length, to100.length);
+        pseudoRandom = new int[LambdaTestHelpers.LONG_STRING.length()];
+        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+            pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
+        }
+    }
+
+    static final Object[][] arrays = {
+            {"empty", to0},
+            {"0..1", to1},
+            {"0..10", to10},
+            {"0..100", to100},
+            {"0..1000", to1000},
+            {"100x[1]", ones},
+            {"2x[0..100]", twice},
+            {"reverse 0..100", reversed},
+            {"pseudorandom", pseudoRandom}
+    };
+
+    static {
+        {
+            List<Object[]> listSmall = new ArrayList<>();
+            List<Object[]> list1000 = new ArrayList<>();
+            List<Object[]> list = null;
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final int[] ints = (int[]) data[1];
+
+                list = ints.length >= 1000 ? list1000 : listSmall;
+
+                list.add(new Object[]{"array:" +
+                                      name, TestData.Factory.ofArray("array:" + name, ints)});
+
+                SpinedBuffer.OfInt isl = new SpinedBuffer.OfInt();
+                for (int i : ints) {
+                    isl.accept(i);
+                }
+                list.add(new Object[]{"SpinedList:" + name,
+                         TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
+
+                list.add(streamDataDescr("IntStream.intRange(0,l): " + ints.length,
+                                         () -> IntStream.range(0, ints.length)));
+                list.add(streamDataDescr("IntStream.rangeClosed(0,l): " + ints.length,
+                                         () -> IntStream.rangeClosed(0, ints.length)));
+            }
+            testSmallData = listSmall.toArray(new Object[0][]);
+            list1000.addAll(listSmall);
+            testData = list1000.toArray(new Object[0][]);
+        }
+
+        {
+            List<Object[]> spliterators = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final int[] ints = (int[]) data[1];
+
+                SpinedBuffer.OfInt isl = new SpinedBuffer.OfInt();
+                for (int i : ints) {
+                    isl.accept(i);
+                }
+
+                spliterators.add(splitDescr("Arrays.s(array):" + name,
+                                            () -> Arrays.spliterator(ints)));
+                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
+                                            () -> Arrays.spliterator(ints, 0, ints.length / 2)));
+
+                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+                                            () -> isl.spliterator()));
+
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
+                                            () -> Spliterators.spliterator(isl.iterator(), ints.length, 0)));
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
+                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
+
+                spliterators.add(splitDescr("IntStream.intRange(0,l):" + name,
+                                            () -> IntStream.range(0, ints.length).spliterator()));
+                spliterators.add(splitDescr("IntStream.intRangeClosed(0,l):" + name,
+                                            () -> IntStream.rangeClosed(0, ints.length).spliterator()));
+                spliterators.add(splitDescr("IntStream.iterate(0,x->x<l,x->x+1): " + name,
+                                            () -> IntStream.iterate(0, x -> x < ints.length, x -> x + 1).spliterator()));
+                // Need more!
+            }
+            spliteratorTestData = spliterators.toArray(new Object[0][]);
+        }
+
+    }
+
+    static <T> Object[] streamDataDescr(String description, Supplier<IntStream> s) {
+        return new Object[] { description, TestData.Factory.ofIntSupplier(description, s) };
+    }
+
+    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfInt> s) {
+        return new Object[] { description, s };
+    }
+
+    // Return an array of ( String name, IntStreamTestData )
+    @DataProvider(name = "IntStreamTestData")
+    public static Object[][] makeIntStreamTestData() {
+        return testData;
+    }
+
+    @DataProvider(name = "IntStreamTestData.small")
+    public static Object[][] makeSmallIntStreamTestData() {
+        return testSmallData;
+    }
+
+    // returns an array of (String name, Supplier<PrimitiveSpliterator<Integer>>)
+    @DataProvider(name = "IntSpliterator")
+    public static Object[][] spliteratorProvider() {
+        return spliteratorTestData;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/IntStreamTestScenario.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.PrimitiveIterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.SpliteratorTestHelper;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.IntConsumer;
+
+/**
+ * Test scenarios for int streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results.  Each scenario describes a different way of computing the
+ * stream contents.  The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum IntStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+    STREAM_FOR_EACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            IntStream s = m.apply(source);
+            if (s.isParallel()) {
+                s = s.sequential();
+            }
+            s.forEach(b);
+        }
+    },
+
+    STREAM_TO_ARRAY(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (int t : m.apply(source).toArray()) {
+                b.accept(t);
+            }
+        }
+    },
+
+    STREAM_ITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (PrimitiveIterator.OfInt seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
+                b.accept(seqIter.nextInt());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (Spliterator.OfInt spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR_FOREACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            m.apply(source).sequential().forEach(b);
+        }
+    },
+
+    // Wrap as parallel stream + forEachOrdered
+    PAR_STREAM_FOR_EACH_ORDERED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            // @@@ Want to explicitly select ordered equalator
+            m.apply(source).forEachOrdered(b);
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (Spliterator.OfInt spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR_FOREACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (int t : m.apply(source).toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            IntStream s = m.apply(source);
+            Spliterator.OfInt sp = s.spliterator();
+            IntStream ss = StreamSupport.intStream(() -> sp,
+                                                   StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+                                                   | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED),
+                                                   true);
+            for (int t : ss.toArray())
+                b.accept(t);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            IntStream pipe2 = m.apply(pipe1);
+
+            for (int t : pipe2.toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing
+    PAR_STREAM_FOR_EACH(true, false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            m.apply(source).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
+    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            m.apply(pipe1).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+    ;
+
+    // The set of scenarios that clean the SIZED flag
+    public static final Set<IntStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
+            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
+
+    private final boolean isParallel;
+
+    private final boolean isOrdered;
+
+    IntStreamTestScenario(boolean isParallel) {
+        this(isParallel, true);
+    }
+
+    IntStreamTestScenario(boolean isParallel, boolean isOrdered) {
+        this.isParallel = isParallel;
+        this.isOrdered = isOrdered;
+    }
+
+    public StreamShape getShape() {
+        return StreamShape.INT_VALUE;
+    }
+
+    public boolean isParallel() {
+        return isParallel;
+    }
+
+    public boolean isOrdered() {
+        return isOrdered;
+    }
+
+    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+        try (S_IN source = getStream(data)) {
+            run(data, source, (IntConsumer) b, (Function<S_IN, IntStream>) m);
+        }
+    }
+
+    abstract <T, S_IN extends BaseStream<T, S_IN>>
+    void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/IntermediateTestOp.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+package java.util.stream;
+
+/**
+ * A base type for test operations
+ */
+interface IntermediateTestOp<E_IN, E_OUT> {
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static<T> AbstractPipeline chain(AbstractPipeline upstream,
+                                            IntermediateTestOp<?, T> op) {
+        if (op instanceof StatelessTestOp)
+            return StatelessTestOp.chain(upstream, (StatelessTestOp) op);
+
+        if (op instanceof StatefulTestOp)
+            return StatefulTestOp.chain(upstream, (StatefulTestOp) op);
+
+        throw new IllegalStateException("Unknown test op type: " + op.getClass().getName());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LambdaTestHelpers.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,473 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.*;
+import java.util.function.BiConsumer;
+import java.util.function.BiPredicate;
+import java.util.function.BinaryOperator;
+import java.util.function.Consumer;
+import java.util.function.DoubleBinaryOperator;
+import java.util.function.DoubleConsumer;
+import java.util.function.DoublePredicate;
+import java.util.function.Function;
+import java.util.function.IntBinaryOperator;
+import java.util.function.IntConsumer;
+import java.util.function.IntFunction;
+import java.util.function.IntPredicate;
+import java.util.function.IntUnaryOperator;
+import java.util.function.LongBinaryOperator;
+import java.util.function.LongConsumer;
+import java.util.function.LongPredicate;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.function.ToDoubleFunction;
+import java.util.function.ToIntFunction;
+import java.util.function.ToLongFunction;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
+
+/**
+ * LambdaTestHelpers -- assertion methods and useful objects for lambda test cases
+ */
+public class LambdaTestHelpers {
+    public static final String LONG_STRING = "When in the Course of human events it becomes necessary for one people to dissolve the political bands which have connected them with another and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.";
+
+    @SuppressWarnings("rawtypes")
+    public static final Consumer bEmpty = x -> {  };
+    @SuppressWarnings("rawtypes")
+    public static final IntConsumer bIntEmpty = x -> {  };
+    @SuppressWarnings("rawtypes")
+    public static final BiConsumer bBiEmpty = (x,y) -> { };
+    @SuppressWarnings("rawtypes")
+    public static final Consumer bHashCode = x -> { Objects.hashCode(x); };
+    @SuppressWarnings("rawtypes")
+    public static final BiConsumer bBiHashCode = (x,y) -> { Objects.hash(x, y); };
+    public static final Function<Integer, Integer> mZero = x -> 0;
+    public static final Function<Integer, Integer> mId = x -> x;
+    public static final Function<Integer, Integer> mDoubler = x -> x * 2;
+    public static final Function<Integer, Stream<Integer>> mfId = e -> Collections.singletonList(e).stream();
+    public static final Function<Integer, Stream<Integer>> mfNull = e -> Collections.<Integer>emptyList().stream();
+    public static final Function<Integer, Stream<Integer>> mfLt = e -> {
+        List<Integer> l = new ArrayList<>();
+        for (int i=0; i<e; i++)
+            l.add(i);
+        return l.stream();
+    };
+    public static final ToIntFunction<Integer> imDoubler = x -> x * 2;
+    public static final ToLongFunction<Long> lmDoubler = x -> x * 2;
+    public static final ToDoubleFunction<Double> dmDoubler = x -> x * 2;
+    public static final Predicate<Integer> pFalse = x -> false;
+    public static final Predicate<Integer> pTrue = x -> true;
+    public static final Predicate<Integer> pEven = x -> 0 == x % 2;
+    public static final Predicate<Integer> pOdd = x -> 1 == x % 2;
+    public static final IntPredicate ipFalse = x -> false;
+    public static final IntPredicate ipTrue = x -> true;
+    public static final IntPredicate ipEven = x -> 0 == x % 2;
+    public static final IntPredicate ipOdd = x -> 1 == x % 2;
+    public static final LongPredicate lpFalse = x -> false;
+    public static final LongPredicate lpTrue = x -> true;
+    public static final LongPredicate lpEven = x -> 0 == x % 2;
+    public static final LongPredicate lpOdd = x -> 1 == x % 2;
+    public static final DoublePredicate dpFalse = x -> false;
+    public static final DoublePredicate dpTrue = x -> true;
+    public static final DoublePredicate dpEven = x -> 0 == ((long) x) % 2;
+    public static final DoublePredicate dpOdd = x -> 1 == ((long) x) % 2;
+    public static final BinaryOperator<Integer> rPlus = (x, y) -> x+y;
+    public static final BinaryOperator<Integer> rMax = (x, y) -> Math.max(x, y);
+    public static final BinaryOperator<Integer> rMin = (x, y) -> Math.min(x,y);
+    public static final IntBinaryOperator irPlus = (x, y) -> x+y;
+    public static final IntBinaryOperator irMax = (x, y) -> Math.max(x, y);
+    public static final IntBinaryOperator irMin = (x, y) -> Math.min(x,y);
+    public static final IntUnaryOperator irDoubler = x -> x * 2;
+    public static final LongBinaryOperator lrPlus = (x, y) -> x+y;
+    public static final DoubleBinaryOperator drPlus = (x, y) -> x+y;
+    public static final Comparator<Integer> cInteger = (a, b) -> Integer.compare(a, b);
+    public static final BiPredicate<?, ?> bipFalse = (x, y) -> false;
+    public static final BiPredicate<?, ?> bipTrue = (x, y) -> true;
+    public static final BiPredicate<Integer, Integer> bipBothEven = (x, y) -> 0 == (x % 2 + y % 2);
+    public static final BiPredicate<Integer, Integer> bipBothOdd = (x, y) -> 2 == (x % 2 + y % 2);
+    public static final BiPredicate<?, ?> bipSameString = (x, y) -> String.valueOf(x).equals(String.valueOf(y));
+
+    public static final IntFunction<Integer[]> integerArrayGenerator = s -> new Integer[s];
+
+    public static final IntFunction<Object[]> objectArrayGenerator = s -> new Object[s];
+
+    public static final Function<String, Stream<Character>> flattenChars = string -> {
+        List<Character> l = new ArrayList<>();
+        for (int i=0; i<string.length(); i++)
+            l.add(string.charAt(i));
+        return l.stream();
+    };
+
+    public static final Function<String, IntStream> flattenInt
+            = string -> IntStream.range(0, string.length()).map(string::charAt);
+
+    public static <T, R> Function<T, R> forPredicate(Predicate<? super T> predicate, R forTrue, R forFalse) {
+        Objects.requireNonNull(predicate);
+
+        return t -> predicate.test(t) ? forTrue : forFalse;
+    }
+
+    public static <T> Function<T, T> identity() {
+        return t -> t;
+    }
+
+    public static<V, T, R> Function<V, R> compose(Function<? super T, ? extends R> after, Function<? super V, ? extends T> before) {
+        Objects.requireNonNull(before);
+        return (V v) -> after.apply(before.apply(v));
+    }
+
+    public static List<Integer> empty() {
+        ArrayList<Integer> list = new ArrayList<>();
+        list.add(null);
+        return list;
+    }
+
+    public static List<Integer> countTo(int n) {
+        return range(1, n);
+    }
+
+    public static List<Integer> range(int l, int u) {
+        ArrayList<Integer> list = new ArrayList<>(u - l + 1);
+        for (int i=l; i<=u; i++) {
+            list.add(i);
+        }
+        return list;
+    }
+
+    public static List<Integer> repeat(int value, int n) {
+        ArrayList<Integer> list = new ArrayList<>(n);
+        for (int i=1; i<=n; i++) {
+            list.add(value);
+        }
+        return list;
+    }
+
+    public static List<Double> asDoubles(List<Integer> integers) {
+        ArrayList<Double> list = new ArrayList<>();
+        for (Integer i : integers) {
+            list.add((double) i);
+        }
+        return list;
+    }
+
+    public static List<Long> asLongs(List<Integer> integers) {
+        ArrayList<Long> list = new ArrayList<>();
+        for (Integer i : integers) {
+            list.add((long) i);
+        }
+        return list;
+    }
+
+    public static void assertCountSum(Stream<? super Integer> it, int count, int sum) {
+        assertCountSum(it.iterator(), count, sum);
+    }
+
+    public static void assertCountSum(Iterable<? super Integer> it, int count, int sum) {
+        assertCountSum(it.iterator(), count, sum);
+    }
+
+    public static void assertCountSum(Iterator<? super Integer> it, int count, int sum) {
+        int c = 0;
+        int s = 0;
+        while (it.hasNext()) {
+            int i = (Integer) it.next();
+            c++;
+            s += i;
+        }
+
+        assertEquals(c, count);
+        assertEquals(s, sum);
+    }
+
+    public static void assertConcat(Iterator<Character> it, String result) {
+        StringBuilder sb = new StringBuilder();
+        while (it.hasNext()) {
+            sb.append(it.next());
+        }
+
+        assertEquals(result, sb.toString());
+    }
+
+    public static<T extends Comparable<? super T>> void assertSorted(Iterator<T> i) {
+        i = toBoxedList(i).iterator();
+
+        if (!i.hasNext())
+            return;
+        T last = i.next();
+        while (i.hasNext()) {
+            T t = i.next();
+            assertTrue(last.compareTo(t) <= 0);
+            assertTrue(t.compareTo(last) >= 0);
+            last = t;
+        }
+    }
+
+    public static<T> void assertSorted(Iterator<T> i, Comparator<? super T> comp) {
+        if (i instanceof PrimitiveIterator.OfInt
+                || i instanceof PrimitiveIterator.OfDouble
+                || i instanceof PrimitiveIterator.OfLong) {
+            i = toBoxedList(i).iterator();
+        }
+
+        if (!i.hasNext())
+            return;
+        T last = i.next();
+        while (i.hasNext()) {
+            T t = i.next();
+            assertTrue(comp.compare(last, t) <= 0);
+            assertTrue(comp.compare(t, last) >= 0);
+            last = t;
+        }
+    }
+
+    public static<T extends Comparable<? super T>> void assertSorted(Iterable<T> iter) {
+        assertSorted(iter.iterator());
+    }
+
+    public static<T> void assertSorted(Iterable<T> iter, Comparator<? super T> comp) {
+        assertSorted(iter.iterator(), comp);
+    }
+
+    public static <T> void assertUnique(Iterable<T> iter) {
+        assertUnique(iter.iterator());
+    }
+
+    public static<T> void assertUnique(Iterator<T> iter) {
+        if (!iter.hasNext()) {
+            return;
+        }
+
+        if (iter instanceof PrimitiveIterator.OfInt
+            || iter instanceof PrimitiveIterator.OfDouble
+            || iter instanceof PrimitiveIterator.OfLong) {
+            iter = toBoxedList(iter).iterator();
+        }
+
+        Set<T> uniq = new HashSet<>();
+        while(iter.hasNext()) {
+            T each = iter.next();
+            assertTrue(!uniq.contains(each), "Not unique");
+            uniq.add(each);
+        }
+    }
+
+    public static<T> void assertContents(Iterable<T> actual, Iterable<T> expected) {
+        if (actual instanceof Collection && expected instanceof Collection) {
+            assertEquals(actual, expected);
+        } else {
+            assertContents(actual.iterator(), expected.iterator());
+        }
+    }
+
+    public static<T> void assertContents(Iterator<T> actual, Iterator<T> expected) {
+        assertEquals(toBoxedList(actual), toBoxedList(expected));
+    }
+
+    @SafeVarargs
+    @SuppressWarnings("varargs")
+    public static<T> void assertContents(Iterator<T> actual, T... expected) {
+        assertContents(actual, Arrays.asList(expected).iterator());
+    }
+
+    /**
+     * The all consuming consumer (rampant capitalist) that can accepting a reference or any primitive value.
+     */
+    private static interface OmnivorousConsumer<T>
+            extends Consumer<T>, IntConsumer, LongConsumer, DoubleConsumer { }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static<T> Consumer<T> toBoxingConsumer(Consumer<? super T> c) {
+        return (Consumer<T>) new OmnivorousConsumer() {
+            @Override
+            public void accept(Object t) {
+                c.accept((T) t);
+            }
+
+            @Override
+            public void accept(int t) {
+                accept((Object) t);
+            }
+
+            @Override
+            public void accept(long t) {
+                accept((Object) t);
+            }
+
+            @Override
+            public void accept(double t) {
+                accept((Object) t);
+            }
+        };
+    }
+
+    /**
+     * Convert an iterator to a list using forEach with an implementation of
+     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
+     *
+     * This ensures equality comparisons for test results do not trip
+     * the boxing trip-wires.
+     */
+    private static<T> List<T> toBoxedList(Iterator<T> it) {
+        List<T> l = new ArrayList<>();
+        it.forEachRemaining(toBoxingConsumer(l::add));
+        return l;
+    }
+
+    /**
+     * Convert a spliterator to a list using forEach with an implementation of
+     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
+     *
+     * This ensures equality comparisons for test results do not trip
+     * the boxing trip-wires.
+     */
+    public static<T> List<T> toBoxedList(Spliterator<T> sp) {
+        List<T> l = new ArrayList<>();
+        sp.forEachRemaining(toBoxingConsumer(l::add));
+        return l;
+    }
+
+    /**
+     * Convert an iterator to a multi-set, represented as a Map, using forEach with an implementation of
+     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
+     *
+     * This ensures equality comparisons for test results do not trip
+     * the boxing trip-wires.
+     */
+    @SuppressWarnings("unchecked")
+    private static<T> Map<T, Integer> toBoxedMultiset(Iterator<T> it) {
+        Map<Object, Integer> result = new HashMap<>();
+
+        it.forEachRemaining(toBoxingConsumer(o -> {
+                if (result.containsKey(o))
+                    result.put(o, result.get(o) + 1);
+                else
+                    result.put(o, 1);
+            }));
+
+        return (Map<T, Integer>) result;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static<T> Map<T, Integer> toBoxedMultiset(Spliterator<T> it) {
+        Map<Object, Integer> result = new HashMap<>();
+
+        it.forEachRemaining(toBoxingConsumer(o -> {
+                if (result.containsKey(o))
+                    result.put(o, result.get(o) + 1);
+                else
+                    result.put(o, 1);
+            }));
+
+        return (Map<T, Integer>) result;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static void assertContentsEqual(Object a, Object b) {
+        if (a instanceof Iterable && b instanceof Iterable)
+            assertContents((Iterable) a, (Iterable) b);
+        else
+            assertEquals(a, b);
+    }
+
+    public static<T> void assertContentsUnordered(Iterable<T> actual, Iterable<T> expected) {
+        assertContentsUnordered(actual.iterator(), expected.iterator());
+    }
+
+    public static<T> void assertContentsUnordered(Iterator<T> actual, Iterator<T> expected) {
+        assertEquals(toBoxedMultiset(actual), toBoxedMultiset(expected));
+    }
+
+    public static<T> void assertContains(Optional<T> actual, Iterator<T> it) {
+        actual.ifPresentOrElse(r -> {
+            boolean contained = false;
+            while (!contained && it.hasNext()) {
+                contained = Objects.equals(r, it.next());
+            }
+            assertTrue(contained, "Not found: "+r);
+        }, () -> assertFalse(it.hasNext()));
+    }
+
+    public static void launderAssertion(Runnable r, Supplier<String> additionalInfo) {
+        try {
+            r.run();
+        }
+        catch (AssertionError ae) {
+            AssertionError cloned = new AssertionError(ae.getMessage() + String.format("%n%s", additionalInfo.get()));
+            cloned.setStackTrace(ae.getStackTrace());
+            if (ae.getCause() != null)
+                cloned.initCause(ae.getCause());
+            throw cloned;
+        }
+    }
+
+    public static <T, S extends BaseStream<T, S>>
+    List<Function<S, S>> permuteStreamFunctions(List<Function<S, S>> opFunctions) {
+        List<List<Function<S, S>>> opFunctionPermutations = perm(opFunctions);
+
+        List<Function<S, S>> appliedFunctions = new ArrayList<>();
+        for (List<Function<S, S>> fs : opFunctionPermutations) {
+            Function<S, S> applied = s -> {
+                for (Function<S, S> f : fs) {
+                    s = f.apply(s);
+                }
+                return s;
+            };
+            appliedFunctions.add(applied);
+        }
+
+        return appliedFunctions;
+    }
+
+    private static <T> List<T> sub(List<T> l, int index) {
+        List<T> subL = new ArrayList<>(l);
+        subL.remove(index);
+        return subL;
+    }
+
+    public static <T> List<List<T>> perm(List<T> l) {
+        List<List<T>> result = new ArrayList<>();
+        for (int i = 0; i < l.size(); i++) {
+            for (List<T> perm : perm(sub(l, i))) {
+                perm.add(0, l.get(i));
+                result.add(perm);
+            }
+        }
+        result.add(new ArrayList<T>());
+
+        return result;
+    }
+
+    public static String flagsToString(int flags) {
+        StringJoiner sj = new StringJoiner(", ", "StreamOpFlag[", "]");
+        if (StreamOpFlag.DISTINCT.isKnown(flags)) sj.add("IS_DISTINCT");
+        if (StreamOpFlag.ORDERED.isKnown(flags)) sj.add("IS_ORDERED");
+        if (StreamOpFlag.SIZED.isKnown(flags)) sj.add("IS_SIZED");
+        if (StreamOpFlag.SORTED.isKnown(flags)) sj.add("IS_SORTED");
+        if (StreamOpFlag.SHORT_CIRCUIT.isKnown(flags)) sj.add("IS_SHORT_CIRCUIT");
+        return sj.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LambdaTestMode.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+package java.util.stream;
+
+/**
+ * Runtime modes of test execution.
+ */
+public enum LambdaTestMode {
+    /**
+     * Execution mode with no particular runtime constraints.
+     */
+    NORMAL,
+
+    /**
+     * Execution mode where tests are executed for testing lambda serialization
+     * and deserialization.
+     *
+     * <p>This mode may be queried by tests or data supplied by data
+     * providers, which cannot otherwise be assigned to the test group
+     * <em>serialization-hostile</em>, to not execute or declare
+     * serialization-hostile code or data.
+     *
+     * <p>This mode is enabled if the boolean system property
+     * {@code org.openjdk.java.util.stream.sand.mode} is declared with a
+     * {@code true} value.
+     */
+    SERIALIZATION;
+
+    /**
+     * {@code true} if tests are executed in the mode for testing lambda
+     * Serialization ANd Deserialization (SAND).
+     */
+    private static final boolean IS_LAMBDA_SERIALIZATION_MODE =
+            Boolean.getBoolean("org.openjdk.java.util.stream.sand.mode");
+
+    /**
+     *
+     * @return the mode of test execution.
+     */
+    public static LambdaTestMode getMode() {
+        return IS_LAMBDA_SERIALIZATION_MODE ? SERIALIZATION : NORMAL;
+    }
+
+    /**
+     *
+     * @return {@code true} if normal test mode.
+     */
+    public static boolean isNormalMode() {
+        return getMode() == NORMAL;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LoggingTestCase.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+package java.util.stream;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.testng.Assert;
+import org.testng.ITestResult;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * LoggingTestCase
+ *
+ */
+@Test
+public class LoggingTestCase extends Assert {
+    private Map<String, Object> context = new HashMap<>();
+
+    @BeforeMethod
+    public void before() {
+        context.clear();
+    }
+
+    @AfterMethod
+    public void after(ITestResult result) {
+        if (!result.isSuccess()) {
+            List<Object> list = new ArrayList<>();
+            Collections.addAll(list, result.getParameters());
+            list.add(context.toString());
+            result.setParameters(list.toArray(new Object[list.size()]));
+        }
+    }
+
+    protected void setContext(String key, Object value) {
+        context.put(key, value);
+    }
+
+    protected void clearContext(String key) {
+        context.remove(key);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LongStreamTestDataProvider.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+
+/** TestNG DataProvider for long-valued streams */
+public class LongStreamTestDataProvider {
+    private static final long[] to0 = new long[0];
+    private static final long[] to1 = new long[1];
+    private static final long[] to10 = new long[10];
+    private static final long[] to100 = new long[100];
+    private static final long[] to1000 = new long[1000];
+    private static final long[] reversed = new long[100];
+    private static final long[] ones = new long[100];
+    private static final long[] twice = new long[200];
+    private static final long[] pseudoRandom;
+
+    private static final Object[][] testData;
+    private static final Object[][] testSmallData;
+    private static final Object[][] spliteratorTestData;
+
+    static {
+        long[][] arrays = {to0, to1, to10, to100, to1000};
+        for (long[] arr : arrays) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = i;
+            }
+        }
+        for (int i = 0; i < reversed.length; i++) {
+            reversed[i] = reversed.length - i;
+        }
+        for (int i = 0; i < ones.length; i++) {
+            ones[i] = 1;
+        }
+        System.arraycopy(to100, 0, twice, 0, to100.length);
+        System.arraycopy(to100, 0, twice, to100.length, to100.length);
+        pseudoRandom = new long[LambdaTestHelpers.LONG_STRING.length()];
+        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+            pseudoRandom[i] = (long) LambdaTestHelpers.LONG_STRING.charAt(i);
+        }
+    }
+
+    static final Object[][] arrays = {
+            {"empty", to0},
+            {"0..1", to1},
+            {"0..10", to10},
+            {"0..100", to100},
+            {"0..1000", to1000},
+            {"100x[1]", ones},
+            {"2x[0..100]", twice},
+            {"reverse 0..100", reversed},
+            {"pseudorandom", pseudoRandom}
+    };
+
+    static {
+        {
+            List<Object[]> listSmall = new ArrayList<>();
+            List<Object[]> list1000 = new ArrayList<>();
+            List<Object[]> list = null;
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final long[] longs = (long[]) data[1];
+
+                list = longs.length >= 1000 ? list1000 : listSmall;
+
+                list.add(new Object[]{"array:" + name,
+                        TestData.Factory.ofArray("array:" + name, longs)});
+
+                SpinedBuffer.OfLong isl = new SpinedBuffer.OfLong();
+                for (long i : longs) {
+                    isl.accept(i);
+                }
+                list.add(new Object[]{"SpinedList:" + name,
+                        TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
+
+                list.add(streamDataDescr("LongStream.longRange(0,l): " + longs.length,
+                                         () -> LongStream.range(0, longs.length)));
+                list.add(streamDataDescr("LongStream.longRangeClosed(0,l): " + longs.length,
+                                         () -> LongStream.rangeClosed(0, longs.length)));
+            }
+            testSmallData = listSmall.toArray(new Object[0][]);
+            list1000.addAll(listSmall);
+            testData = list1000.toArray(new Object[0][]);
+        }
+
+        {
+            List<Object[]> spliterators = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final long[] longs = (long[]) data[1];
+
+                SpinedBuffer.OfLong isl = new SpinedBuffer.OfLong();
+                for (long i : longs) {
+                    isl.accept(i);
+                }
+
+                spliterators.add(splitDescr("Arrays.s(array):" + name,
+                                            () -> Arrays.spliterator(longs)));
+                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
+                                            () -> Arrays.spliterator(longs, 0, longs.length / 2)));
+
+                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+                                            () -> isl.spliterator()));
+
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
+                                            () -> Spliterators.spliterator(isl.iterator(), longs.length, 0)));
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
+                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
+
+                spliterators.add(splitDescr("LongStream.longRange(0,l):" + name,
+                                            () -> LongStream.range(0, longs.length).spliterator()));
+                spliterators.add(splitDescr("LongStream.longRangeClosed(0,l):" + name,
+                                            () -> LongStream.rangeClosed(0, longs.length).spliterator()));
+                spliterators.add(splitDescr("LongStream.iterate(0,x->x<l;x->x+1):" + name,
+                                            () -> LongStream.iterate(0L, x -> x < longs.length, x -> x + 1L)
+                                                            .spliterator()));
+                // Need more!
+            }
+            spliteratorTestData = spliterators.toArray(new Object[0][]);
+        }
+
+    }
+
+    static <T> Object[] streamDataDescr(String description, Supplier<LongStream> s) {
+        return new Object[] { description, TestData.Factory.ofLongSupplier(description, s) };
+    }
+
+    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfLong> s) {
+        return new Object[] { description, s };
+    }
+
+    // Return an array of ( String name, LongStreamTestData )
+    @DataProvider(name = "LongStreamTestData")
+    public static Object[][] makeLongStreamTestData() {
+        return testData;
+    }
+
+    @DataProvider(name = "LongStreamTestData.small")
+    public static Object[][] makeSmallLongStreamTestData() {
+        return testSmallData;
+    }
+
+    // returns an array of (String name, Supplier<PrimitiveSpliterator<Long>>)
+    @DataProvider(name = "LongSpliterator")
+    public static Object[][] spliteratorProvider() {
+        return spliteratorTestData;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LongStreamTestScenario.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.PrimitiveIterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.SpliteratorTestHelper;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.LongConsumer;
+
+/**
+ * Test scenarios for long streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results.  Each scenario describes a different way of computing the
+ * stream contents.  The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum LongStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+    STREAM_FOR_EACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            LongStream s = m.apply(source);
+            if (s.isParallel()) {
+                s = s.sequential();
+            }
+            s.forEach(b);
+        }
+    },
+
+    STREAM_TO_ARRAY(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (long t : m.apply(source).toArray()) {
+                b.accept(t);
+            }
+        }
+    },
+
+    STREAM_ITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (PrimitiveIterator.OfLong seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
+                b.accept(seqIter.nextLong());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (Spliterator.OfLong spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR_FOREACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            m.apply(source).sequential().forEach(b);
+        }
+    },
+
+    // Wrap as parallel stream + forEachOrdered
+    PAR_STREAM_FOR_EACH_ORDERED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            // @@@ Want to explicitly select ordered equalator
+            m.apply(source).forEachOrdered(b);
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (Spliterator.OfLong spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR_FOREACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (long t : m.apply(source).toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            LongStream s = m.apply(source);
+            Spliterator.OfLong sp = s.spliterator();
+            LongStream ss = StreamSupport.longStream(() -> sp,
+                                                     StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+                                                     | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
+            for (long t : ss.toArray())
+                b.accept(t);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            LongStream pipe2 = m.apply(pipe1);
+
+            for (long t : pipe2.toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing
+    PAR_STREAM_FOR_EACH(true, false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            m.apply(source).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
+    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            m.apply(pipe1).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+    ;
+
+    // The set of scenarios that clean the SIZED flag
+    public static final Set<LongStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
+            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
+
+    private boolean isParallel;
+
+    private final boolean isOrdered;
+
+    LongStreamTestScenario(boolean isParallel) {
+        this(isParallel, true);
+    }
+
+    LongStreamTestScenario(boolean isParallel, boolean isOrdered) {
+        this.isParallel = isParallel;
+        this.isOrdered = isOrdered;
+    }
+
+    public StreamShape getShape() {
+        return StreamShape.LONG_VALUE;
+    }
+
+    public boolean isParallel() {
+        return isParallel;
+    }
+
+    public boolean isOrdered() {
+        return isOrdered;
+    }
+
+    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+        try (S_IN source = getStream(data)) {
+            run(data, source, (LongConsumer) b, (Function<S_IN, LongStream>) m);
+        }
+    }
+
+    abstract <T, S_IN extends BaseStream<T, S_IN>>
+    void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/OpTestCase.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,682 @@
+/*
+ * Copyright (c) 2012, 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+import org.testng.annotations.Test;
+
+/**
+ * Base class for streams test cases.  Provides 'exercise' methods for taking
+ * lambdas that construct and modify streams, and evaluates them in different
+ * ways and asserts that they produce equivalent results.
+ */
+@Test
+public abstract class OpTestCase extends LoggingTestCase {
+
+    private final Map<StreamShape, Set<? extends BaseStreamTestScenario>> testScenarios;
+
+    protected OpTestCase() {
+        testScenarios = new EnumMap<>(StreamShape.class);
+        testScenarios.put(StreamShape.REFERENCE, Collections.unmodifiableSet(EnumSet.allOf(StreamTestScenario.class)));
+        testScenarios.put(StreamShape.INT_VALUE, Collections.unmodifiableSet(EnumSet.allOf(IntStreamTestScenario.class)));
+        testScenarios.put(StreamShape.LONG_VALUE, Collections.unmodifiableSet(EnumSet.allOf(LongStreamTestScenario.class)));
+        testScenarios.put(StreamShape.DOUBLE_VALUE, Collections.unmodifiableSet(EnumSet.allOf(DoubleStreamTestScenario.class)));
+    }
+
+    @SuppressWarnings("rawtypes")
+    public static int getStreamFlags(BaseStream s) {
+        return ((AbstractPipeline) s).getStreamFlags();
+    }
+
+    /**
+     * An asserter for results produced when exercising of stream or terminal
+     * tests.
+     *
+     * @param <R> the type of result to assert on
+     */
+    public interface ResultAsserter<R> {
+        /**
+         * Assert a result produced when exercising of stream or terminal
+         * test.
+         *
+         * @param actual the actual result
+         * @param expected the expected result
+         * @param isOrdered true if the pipeline is ordered
+         * @param isParallel true if the pipeline is parallel
+         */
+        void assertResult(R actual, R expected, boolean isOrdered, boolean isParallel);
+    }
+
+    // Exercise stream operations
+
+    public interface BaseStreamTestScenario {
+        StreamShape getShape();
+
+        boolean isParallel();
+
+        boolean isOrdered();
+
+        default <T, S_IN extends BaseStream<T, S_IN>>
+        S_IN getStream(TestData<T, S_IN> data) {
+            return isParallel()
+                   ? data.parallelStream()
+                   : data.stream();
+        }
+
+        <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+        void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m);
+    }
+
+    protected <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    Collection<U> exerciseOps(TestData<T, S_IN> data, Function<S_IN, S_OUT> m) {
+        return withData(data).stream(m).exercise();
+    }
+
+    // Run multiple versions of exercise(), returning the result of the first, and asserting that others return the same result
+    // If the first version is s -> s.foo(), can be used with s -> s.mapToInt(i -> i).foo().mapToObj(i -> i) to test all shape variants
+    @SafeVarargs
+    protected final<T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    Collection<U> exerciseOpsMulti(TestData<T, S_IN> data,
+                                   Function<S_IN, S_OUT>... ms) {
+        Collection<U> result = null;
+        for (Function<S_IN, S_OUT> m : ms) {
+            if (result == null)
+                result = withData(data).stream(m).exercise();
+            else {
+                Collection<U> r2 = withData(data).stream(m).exercise();
+                assertEquals(result, r2);
+            }
+        }
+        return result;
+    }
+
+    // Run multiple versions of exercise() for an Integer stream, returning the result of the first, and asserting that others return the same result
+    // Automates the conversion between Stream<Integer> and {Int,Long,Double}Stream and back, so client sites look like you are passing the same
+    // lambda four times, but in fact they are four different lambdas since they are transforming four different kinds of streams
+    protected final
+    Collection<Integer> exerciseOpsInt(TestData.OfRef<Integer> data,
+                                       Function<Stream<Integer>, Stream<Integer>> mRef,
+                                       Function<IntStream, IntStream> mInt,
+                                       Function<LongStream, LongStream> mLong,
+                                       Function<DoubleStream, DoubleStream> mDouble) {
+        @SuppressWarnings({ "rawtypes", "unchecked" })
+        Function<Stream<Integer>, Stream<Integer>>[] ms = new Function[4];
+        ms[0] = mRef;
+        ms[1] = s -> mInt.apply(s.mapToInt(e -> e)).mapToObj(e -> e);
+        ms[2] = s -> mLong.apply(s.mapToLong(e -> e)).mapToObj(e -> (int) e);
+        ms[3] = s -> mDouble.apply(s.mapToDouble(e -> e)).mapToObj(e -> (int) e);
+        return exerciseOpsMulti(data, ms);
+    }
+
+    // Run multiple versions of exercise() with multiple terminal operations for all kinds of stream, , and asserting against the expected result
+    // If the first version is s -> s.foo(), can be used with s -> s.mapToInt(i -> i).foo().mapToObj(i -> i) to test all shape variants
+    protected final<T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    void exerciseTerminalOpsMulti(TestData<T, S_IN> data,
+                                  R expected,
+                                  Map<String, Function<S_IN, S_OUT>> streams,
+                                  Map<String, Function<S_OUT, R>> terminals) {
+        for (Map.Entry<String, Function<S_IN, S_OUT>> se : streams.entrySet()) {
+            setContext("Intermediate stream", se.getKey());
+            for (Map.Entry<String, Function<S_OUT, R>> te : terminals.entrySet()) {
+                setContext("Terminal stream", te.getKey());
+                withData(data)
+                        .terminal(se.getValue(), te.getValue())
+                        .expectedResult(expected)
+                        .exercise();
+
+            }
+        }
+    }
+
+    // Run multiple versions of exercise() with multiple terminal operation for all kinds of stream, and asserting against the expected result
+    // Automates the conversion between Stream<Integer> and {Int,Long,Double}Stream and back, so client sites look like you are passing the same
+    // lambda four times, but in fact they are four different lambdas since they are transforming four different kinds of streams
+    protected final
+    void exerciseTerminalOpsInt(TestData<Integer, Stream<Integer>> data,
+                                Collection<Integer> expected,
+                                String desc,
+                                Function<Stream<Integer>, Stream<Integer>> mRef,
+                                Function<IntStream, IntStream> mInt,
+                                Function<LongStream, LongStream> mLong,
+                                Function<DoubleStream, DoubleStream> mDouble,
+                                Map<String, Function<Stream<Integer>, Collection<Integer>>> terminals) {
+
+        Map<String, Function<Stream<Integer>, Stream<Integer>>> m = new HashMap<>();
+        m.put("Ref " + desc, mRef);
+        m.put("Int " + desc, s -> mInt.apply(s.mapToInt(e -> e)).mapToObj(e -> e));
+        m.put("Long " + desc, s -> mLong.apply(s.mapToLong(e -> e)).mapToObj(e -> (int) e));
+        m.put("Double " + desc, s -> mDouble.apply(s.mapToDouble(e -> e)).mapToObj(e -> (int) e));
+
+        exerciseTerminalOpsMulti(data, expected, m, terminals);
+    }
+
+
+    protected <T, U, S_OUT extends BaseStream<U, S_OUT>>
+    Collection<U> exerciseOps(Collection<T> data, Function<Stream<T>, S_OUT> m) {
+        TestData.OfRef<T> data1 = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
+        return withData(data1).stream(m).exercise();
+    }
+
+    protected <T, U, S_OUT extends BaseStream<U, S_OUT>, I extends Iterable<U>>
+    Collection<U> exerciseOps(Collection<T> data, Function<Stream<T>, S_OUT> m, I expected) {
+        TestData.OfRef<T> data1 = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
+        return withData(data1).stream(m).expectedResult(expected).exercise();
+    }
+
+    @SuppressWarnings("unchecked")
+    protected <U, S_OUT extends BaseStream<U, S_OUT>>
+    Collection<U> exerciseOps(int[] data, Function<IntStream, S_OUT> m) {
+        return withData(TestData.Factory.ofArray("int array", data)).stream(m).exercise();
+    }
+
+    protected Collection<Integer> exerciseOps(int[] data, Function<IntStream, IntStream> m, int[] expected) {
+        TestData.OfInt data1 = TestData.Factory.ofArray("int array", data);
+        return withData(data1).stream(m).expectedResult(expected).exercise();
+    }
+
+    protected <T, S_IN extends BaseStream<T, S_IN>> DataStreamBuilder<T, S_IN> withData(TestData<T, S_IN> data) {
+        Objects.requireNonNull(data);
+        return new DataStreamBuilder<>(data);
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public class DataStreamBuilder<T, S_IN extends BaseStream<T, S_IN>> {
+        final TestData<T, S_IN> data;
+
+        private DataStreamBuilder(TestData<T, S_IN> data) {
+            this.data = Objects.requireNonNull(data);
+        }
+
+        public <U, S_OUT extends BaseStream<U, S_OUT>>
+        ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> ops(IntermediateTestOp... ops) {
+            return new ExerciseDataStreamBuilder<>(data, (S_IN s) -> (S_OUT) chain(s, ops));
+        }
+
+        public <U, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT>
+        stream(Function<S_IN, S_OUT> m) {
+            return new ExerciseDataStreamBuilder<>(data, m);
+        }
+
+        public <U, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT>
+        stream(Function<S_IN, S_OUT> m, IntermediateTestOp<U, U> additionalOp) {
+            return new ExerciseDataStreamBuilder<>(data, s -> (S_OUT) chain(m.apply(s), additionalOp));
+        }
+
+        public <R> ExerciseDataTerminalBuilder<T, T, R, S_IN, S_IN>
+        terminal(Function<S_IN, R> terminalF) {
+            return new ExerciseDataTerminalBuilder<>(data, s -> s, terminalF);
+        }
+
+        public <U, R, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT>
+        terminal(Function<S_IN, S_OUT> streamF, Function<S_OUT, R> terminalF) {
+            return new ExerciseDataTerminalBuilder<>(data, streamF, terminalF);
+        }
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public class ExerciseDataStreamBuilder<T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> {
+        final TestData<T, S_IN> data;
+        final Function<S_IN, S_OUT> m;
+        final StreamShape shape;
+
+        Set<BaseStreamTestScenario> testSet = new HashSet<>();
+
+        Collection<U> refResult;
+
+        Consumer<TestData<T, S_IN>> before = LambdaTestHelpers.bEmpty;
+
+        Consumer<TestData<T, S_IN>> after = LambdaTestHelpers.bEmpty;
+
+        ResultAsserter<Iterable<U>> resultAsserter = (act, exp, ord, par) -> {
+            if (par & !ord) {
+                LambdaTestHelpers.assertContentsUnordered(act, exp);
+            }
+            else {
+                LambdaTestHelpers.assertContentsEqual(act, exp);
+            }
+        };
+
+        private ExerciseDataStreamBuilder(TestData<T, S_IN> data, Function<S_IN, S_OUT> m) {
+            this.data = data;
+
+            this.m = Objects.requireNonNull(m);
+
+            this.shape = ((AbstractPipeline<?, U, ?>) m.apply(data.stream())).getOutputShape();
+
+            // Have to initiate from the output shape of the last stream
+            // This means the stream mapper is required first rather than last
+            testSet.addAll(testScenarios.get(shape));
+        }
+
+        //
+
+        public <I extends Iterable<U>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(I expectedResult) {
+            List<U> l = new ArrayList<>();
+            expectedResult.forEach(l::add);
+            refResult = l;
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(int[] expectedResult) {
+            List l = new ArrayList();
+            for (int anExpectedResult : expectedResult) {
+                l.add(anExpectedResult);
+            }
+            refResult = l;
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(long[] expectedResult) {
+            List l = new ArrayList();
+            for (long anExpectedResult : expectedResult) {
+                l.add(anExpectedResult);
+            }
+            refResult = l;
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(double[] expectedResult) {
+            List l = new ArrayList();
+            for (double anExpectedResult : expectedResult) {
+                l.add(anExpectedResult);
+            }
+            refResult = l;
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> before(Consumer<TestData<T, S_IN>> before) {
+            this.before = Objects.requireNonNull(before);
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> after(Consumer<TestData<T, S_IN>> after) {
+            this.after = Objects.requireNonNull(after);
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> without(BaseStreamTestScenario... tests) {
+            return without(Arrays.asList(tests));
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> without(Collection<? extends BaseStreamTestScenario> tests) {
+            for (BaseStreamTestScenario ts : tests) {
+                if (ts.getShape() == shape) {
+                    testSet.remove(ts);
+                }
+            }
+
+            if (testSet.isEmpty()) {
+                throw new IllegalStateException("Test scenario set is empty");
+            }
+
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> with(BaseStreamTestScenario... tests) {
+            return with(Arrays.asList(tests));
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> with(Collection<? extends BaseStreamTestScenario> tests) {
+            testSet = new HashSet<>();
+
+            for (BaseStreamTestScenario ts : tests) {
+                if (ts.getShape() == shape) {
+                    testSet.add(ts);
+                }
+            }
+
+            if (testSet.isEmpty()) {
+                throw new IllegalStateException("Test scenario set is empty");
+            }
+
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> resultAsserter(ResultAsserter<Iterable<U>> resultAsserter) {
+            this.resultAsserter = resultAsserter;
+            return this;
+        }
+
+        // Build method
+
+        public Collection<U> exercise() {
+            final boolean isStreamOrdered;
+            if (refResult == null) {
+                // Induce the reference result
+                before.accept(data);
+                try (S_OUT sOut = m.apply(data.stream())) {
+                    isStreamOrdered = StreamOpFlag.ORDERED.isKnown(((AbstractPipeline) sOut).getStreamFlags());
+                    Node<U> refNodeResult = ((AbstractPipeline<?, U, ?>) sOut).evaluateToArrayNode(size -> (U[]) new Object[size]);
+                    refResult = LambdaTestHelpers.toBoxedList(refNodeResult.spliterator());
+                }
+                after.accept(data);
+            }
+            else {
+                try (S_OUT sOut = m.apply(data.stream())) {
+                    isStreamOrdered = StreamOpFlag.ORDERED.isKnown(((AbstractPipeline) sOut).getStreamFlags());
+                }
+            }
+
+            List<Error> errors = new ArrayList<>();
+            for (BaseStreamTestScenario test : testSet) {
+                try {
+                    before.accept(data);
+
+                    List<U> result = new ArrayList<>();
+                    test.run(data, LambdaTestHelpers.<U>toBoxingConsumer(result::add), m);
+
+                    Runnable asserter = () -> resultAsserter.assertResult(result, refResult, isStreamOrdered && test.isOrdered(), test.isParallel());
+
+                    if (refResult.size() > 1000) {
+                        LambdaTestHelpers.launderAssertion(
+                                asserter,
+                                () -> String.format("%n%s: [actual size=%d] != [expected size=%d]", test, result.size(), refResult.size()));
+                    }
+                    else {
+                        LambdaTestHelpers.launderAssertion(
+                                asserter,
+                                () -> String.format("%n%s: [actual] %s != [expected] %s", test, result, refResult));
+                    }
+
+                    after.accept(data);
+                } catch (Throwable t) {
+                    errors.add(new Error(String.format("%s: %s", test, t), t));
+                }
+            }
+
+            if (!errors.isEmpty()) {
+                StringBuilder sb = new StringBuilder();
+                int i = 1;
+                for (Error t : errors) {
+                    sb.append(i++).append(": ");
+                    if (t instanceof AssertionError) {
+                        sb.append(t).append("\n");
+                    }
+                    else {
+                        StringWriter sw = new StringWriter();
+                        PrintWriter pw = new PrintWriter(sw);
+
+                        t.getCause().printStackTrace(pw);
+                        pw.flush();
+                        sb.append(t).append("\n").append(sw);
+                    }
+                }
+                sb.append("--");
+
+                fail(String.format("%d failure(s) for test data: %s\n%s", i - 1, data.toString(), sb));
+            }
+
+            return refResult;
+        }
+    }
+
+    // Exercise terminal operations
+
+    interface BaseTerminalTestScenario<U, R, S_OUT extends BaseStream<U, S_OUT>> {
+        boolean requiresSingleStageSource();
+
+        boolean requiresParallelSource();
+
+        default R run(Function<S_OUT, R> terminalF, S_OUT source, StreamShape shape) {
+            return terminalF.apply(source);
+        }
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    enum TerminalTestScenario implements BaseTerminalTestScenario {
+        SINGLE_SEQUENTIAL(true, false),
+
+        SINGLE_SEQUENTIAL_SHORT_CIRCUIT(true, false) {
+            @Override
+            public Object run(Function terminalF, BaseStream source, StreamShape shape) {
+                source = (BaseStream) chain(source, new ShortCircuitOp(shape));
+                return terminalF.apply(source);
+            }
+        },
+
+        SINGLE_PARALLEL(true, true),
+
+        ALL_SEQUENTIAL(false, false),
+
+        ALL_SEQUENTIAL_SHORT_CIRCUIT(false, false) {
+            @Override
+            public Object run(Function terminalF, BaseStream source, StreamShape shape) {
+                source = (BaseStream) chain(source, new ShortCircuitOp(shape));
+                return terminalF.apply(source);
+            }
+        },
+
+        ALL_PARALLEL(false, true),
+
+        ALL_PARALLEL_SEQUENTIAL(false, false) {
+            @Override
+            public Object run(Function terminalF, BaseStream source, StreamShape shape) {
+                return terminalF.apply(source.sequential());
+            }
+        },
+        ;
+
+        private final boolean requiresSingleStageSource;
+        private final boolean isParallel;
+
+        TerminalTestScenario(boolean requiresSingleStageSource, boolean isParallel) {
+            this.requiresSingleStageSource = requiresSingleStageSource;
+            this.isParallel = isParallel;
+        }
+
+        @Override
+        public boolean requiresSingleStageSource() {
+            return requiresSingleStageSource;
+        }
+
+        @Override
+        public boolean requiresParallelSource() {
+            return isParallel;
+        }
+
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public class ExerciseDataTerminalBuilder<T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> {
+        final TestData<T, S_IN> data;
+        final Function<S_IN, S_OUT> streamF;
+        final Function<S_OUT, R> terminalF;
+
+        R refResult;
+
+        ResultAsserter<R> resultAsserter = (act, exp, ord, par) -> LambdaTestHelpers.assertContentsEqual(act, exp);
+
+        private ExerciseDataTerminalBuilder(TestData<T, S_IN> data, Function<S_IN, S_OUT> streamF, Function<S_OUT, R> terminalF) {
+            this.data = data;
+            this.streamF = Objects.requireNonNull(streamF);
+            this.terminalF = Objects.requireNonNull(terminalF);
+        }
+
+        //
+
+        public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> expectedResult(R expectedResult) {
+            this.refResult = expectedResult;
+            return this;
+        }
+
+        public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> equalator(BiConsumer<R, R> equalityAsserter) {
+            resultAsserter = (act, exp, ord, par) -> equalityAsserter.accept(act, exp);
+            return this;
+        }
+
+        public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> resultAsserter(ResultAsserter<R> resultAsserter) {
+            this.resultAsserter = resultAsserter;
+            return this;
+        }
+
+        // Build method
+
+        public R exercise() {
+            boolean isOrdered;
+            StreamShape shape;
+            Node<U> node;
+            try (S_OUT out = streamF.apply(data.stream()).sequential()) {
+                AbstractPipeline ap = (AbstractPipeline) out;
+                isOrdered = StreamOpFlag.ORDERED.isKnown(ap.getStreamFlags());
+                shape = ap.getOutputShape();
+                // Sequentially collect the output that will be input to the terminal op
+                node = ap.evaluateToArrayNode(size -> (U[]) new Object[size]);
+            }
+
+            EnumSet<TerminalTestScenario> tests = EnumSet.allOf(TerminalTestScenario.class);
+            if (refResult == null) {
+                // Induce the reference result
+                S_OUT source = (S_OUT) createPipeline(shape, node.spliterator(),
+                                                      StreamOpFlag.IS_ORDERED | StreamOpFlag.IS_SIZED,
+                                                      false);
+
+                refResult = (R) TerminalTestScenario.SINGLE_SEQUENTIAL.run(terminalF, source, shape);
+                tests.remove(TerminalTestScenario.SINGLE_SEQUENTIAL);
+            }
+
+            for (BaseTerminalTestScenario test : tests) {
+                S_OUT source;
+                if (test.requiresSingleStageSource()) {
+                    source = (S_OUT) createPipeline(shape, node.spliterator(),
+                                                    StreamOpFlag.IS_ORDERED | StreamOpFlag.IS_SIZED,
+                                                    test.requiresParallelSource());
+                }
+                else {
+                    source = streamF.apply(test.requiresParallelSource()
+                                           ? data.parallelStream() : data.stream());
+                }
+
+                R result;
+                try (source) {
+                    result = (R) test.run(terminalF, source, shape);
+                }
+                LambdaTestHelpers.launderAssertion(
+                        () -> resultAsserter.assertResult(result, refResult, isOrdered, test.requiresParallelSource()),
+                        () -> String.format("%s: %s != %s", test, refResult, result));
+            }
+
+            return refResult;
+        }
+
+        AbstractPipeline createPipeline(StreamShape shape, Spliterator s, int flags, boolean parallel) {
+            switch (shape) {
+                case REFERENCE:    return new ReferencePipeline.Head<>(s, flags, parallel);
+                case INT_VALUE:    return new IntPipeline.Head(s, flags, parallel);
+                case LONG_VALUE:   return new LongPipeline.Head(s, flags, parallel);
+                case DOUBLE_VALUE: return new DoublePipeline.Head(s, flags, parallel);
+                default: throw new IllegalStateException("Unknown shape: " + shape);
+            }
+        }
+    }
+
+    protected <T, R> R exerciseTerminalOps(Collection<T> data, Function<Stream<T>, R> m, R expected) {
+        TestData.OfRef<T> data1
+                = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
+        return withData(data1).terminal(m).expectedResult(expected).exercise();
+    }
+
+    protected <T, R, S_IN extends BaseStream<T, S_IN>> R
+    exerciseTerminalOps(TestData<T, S_IN> data,
+                        Function<S_IN, R> terminalF) {
+        return withData(data).terminal(terminalF).exercise();
+    }
+
+    protected <T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> R
+    exerciseTerminalOps(TestData<T, S_IN> data,
+                        Function<S_IN, S_OUT> streamF,
+                        Function<S_OUT, R> terminalF) {
+        return withData(data).terminal(streamF, terminalF).exercise();
+    }
+
+    //
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    private static <T> AbstractPipeline<?, T, ?> chain(AbstractPipeline upstream, IntermediateTestOp<?, T> op) {
+        return (AbstractPipeline<?, T, ?>) IntermediateTestOp.chain(upstream, op);
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    private static AbstractPipeline<?, ?, ?> chain(AbstractPipeline pipe, IntermediateTestOp... ops) {
+        for (IntermediateTestOp op : ops)
+            pipe = chain(pipe, op);
+        return pipe;
+    }
+
+    @SuppressWarnings("rawtypes")
+    private static <T> AbstractPipeline<?, T, ?> chain(BaseStream pipe, IntermediateTestOp<?, T> op) {
+        return chain((AbstractPipeline) pipe, op);
+    }
+
+    @SuppressWarnings("rawtypes")
+    public static AbstractPipeline<?, ?, ?> chain(BaseStream pipe, IntermediateTestOp... ops) {
+        return chain((AbstractPipeline) pipe, ops);
+    }
+
+    // Test data
+
+    static class ShortCircuitOp<T> implements StatelessTestOp<T,T> {
+        private final StreamShape shape;
+
+        ShortCircuitOp(StreamShape shape) {
+            this.shape = shape;
+        }
+
+        @Override
+        public Sink<T> opWrapSink(int flags, boolean parallel, Sink<T> sink) {
+            return sink;
+        }
+
+        @Override
+        public int opGetFlags() {
+            return StreamOpFlag.IS_SHORT_CIRCUIT;
+        }
+
+        @Override
+        public StreamShape outputShape() {
+            return shape;
+        }
+
+        @Override
+        public StreamShape inputShape() {
+            return shape;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StatefulTestOp.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+package java.util.stream;
+
+import java.util.Spliterator;
+import java.util.function.IntFunction;
+
+/**
+ * The base type for a stateful test operation.
+ */
+interface StatefulTestOp<E> extends IntermediateTestOp<E, E> {
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static<T> AbstractPipeline chain(AbstractPipeline upstream,
+                                            StatefulTestOp op) {
+        switch (op.outputShape()) {
+            case REFERENCE:
+                return new ReferencePipeline.StatefulOp<Object, T>(upstream, op.inputShape(), op.opGetFlags()) {
+                    @Override
+                    Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+
+                    @Override
+                    <P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper,
+                                                                 Spliterator<P_IN> spliterator) {
+                        return op.opEvaluateParallelLazy(helper, spliterator);
+                    }
+
+                    @Override
+                    <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
+                                                      Spliterator<P_IN> spliterator,
+                                                      IntFunction<T[]> generator) {
+                        return op.opEvaluateParallel(helper, spliterator, generator);
+                    }
+                };
+            case INT_VALUE:
+                return new IntPipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
+                    @Override
+                    Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+
+                    @Override
+                    <P_IN> Spliterator<Integer> opEvaluateParallelLazy(PipelineHelper<Integer> helper,
+                                                                 Spliterator<P_IN> spliterator) {
+                        return op.opEvaluateParallelLazy(helper, spliterator);
+                    }
+
+                    @Override
+                    <P_IN> Node<Integer> opEvaluateParallel(PipelineHelper<Integer> helper,
+                                                            Spliterator<P_IN> spliterator,
+                                                            IntFunction<Integer[]> generator) {
+                        return (Node<Integer>) op.opEvaluateParallel(helper, spliterator, generator);
+                    }
+                };
+            case LONG_VALUE:
+                return new LongPipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
+                    @Override
+                    Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+
+                    @Override
+                    <P_IN> Spliterator<Long> opEvaluateParallelLazy(PipelineHelper<Long> helper,
+                                                                 Spliterator<P_IN> spliterator) {
+                        return op.opEvaluateParallelLazy(helper, spliterator);
+                    }
+
+                    @Override
+                    <P_IN> Node<Long> opEvaluateParallel(PipelineHelper<Long> helper,
+                                                         Spliterator<P_IN> spliterator,
+                                                         IntFunction<Long[]> generator) {
+                        return (Node<Long>) op.opEvaluateParallel(helper, spliterator, generator);
+                    }
+                };
+            case DOUBLE_VALUE:
+                return new DoublePipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
+                    @Override
+                    Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+
+                    @Override
+                    <P_IN> Spliterator<Double> opEvaluateParallelLazy(PipelineHelper<Double> helper,
+                                                                    Spliterator<P_IN> spliterator) {
+                        return op.opEvaluateParallelLazy(helper, spliterator);
+                    }
+
+                    @Override
+                    <P_IN> Node<Double> opEvaluateParallel(PipelineHelper<Double> helper,
+                                                           Spliterator<P_IN> spliterator,
+                                                           IntFunction<Double[]> generator) {
+                        return (Node<Double>) op.opEvaluateParallel(helper, spliterator, generator);
+                    }
+                };
+            default: throw new IllegalStateException(op.outputShape().toString());
+        }
+    }
+
+    default StreamShape inputShape() { return StreamShape.REFERENCE; }
+
+    default StreamShape outputShape() { return StreamShape.REFERENCE; }
+
+    default int opGetFlags() { return 0; }
+
+    Sink<E> opWrapSink(int flags, boolean parallel, Sink<E> sink);
+
+    @SuppressWarnings("unchecked")
+    default <P_IN> Spliterator<E> opEvaluateParallelLazy(PipelineHelper<E> helper,
+                                                         Spliterator<P_IN> spliterator) {
+        return opEvaluateParallel(helper, spliterator, i -> (E[]) new Object[i]).spliterator();
+    }
+
+    <P_IN> Node<E> opEvaluateParallel(PipelineHelper<E> helper,
+                                      Spliterator<P_IN> spliterator,
+                                      IntFunction<E[]> generator);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StatelessTestOp.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+package java.util.stream;
+
+/**
+ * The base type of a stateless test operation
+ */
+interface StatelessTestOp<E_IN, E_OUT> extends IntermediateTestOp<E_IN, E_OUT> {
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static<T> AbstractPipeline chain(AbstractPipeline upstream,
+                                            StatelessTestOp<?, T> op) {
+        int flags = op.opGetFlags();
+        switch (op.outputShape()) {
+            case REFERENCE:
+                return new ReferencePipeline.StatelessOp<Object, T>(upstream, op.inputShape(), flags) {
+                    public Sink opWrapSink(int flags, Sink<T> sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+                };
+            case INT_VALUE:
+                return new IntPipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
+                    public Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+                };
+            case LONG_VALUE:
+                return new LongPipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
+                    @Override
+                    Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+                };
+            case DOUBLE_VALUE:
+                return new DoublePipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
+                    @Override
+                    Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+                };
+            default: throw new IllegalStateException(op.outputShape().toString());
+        }
+    }
+
+    default StreamShape inputShape() { return StreamShape.REFERENCE; }
+
+    default StreamShape outputShape() { return StreamShape.REFERENCE; }
+
+    default int opGetFlags() { return 0; }
+
+    Sink<E_IN> opWrapSink(int flags, boolean parallel, Sink<E_OUT> sink);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StreamOpFlagTestHelper.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+package java.util.stream;
+
+import java.util.EnumSet;
+
+public class StreamOpFlagTestHelper {
+
+    /** EnumSet containing stream flags */
+    private static final EnumSet<StreamOpFlag> allStreamFlags;
+
+    static {
+        allStreamFlags = EnumSet.allOf(StreamOpFlag.class);
+        for (StreamOpFlag f : EnumSet.allOf(StreamOpFlag.class))
+            if (!f.isStreamFlag())
+                allStreamFlags.remove(f);
+    }
+
+
+    static EnumSet<StreamOpFlag> allStreamFlags() {
+        // EnumSet is mutable
+        return allStreamFlags.clone();
+    }
+
+    public static boolean isStreamOrdered(Stream<?> s) {
+        return StreamOpFlag.ORDERED.isKnown(OpTestCase.getStreamFlags(s));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StreamTestDataProvider.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+
+/**
+ * StreamTestDataProvider
+ *
+ * @author Brian Goetz
+ */
+/** TestNG DataProvider for ref-valued streams */
+public class StreamTestDataProvider {
+    private static final Integer[] to0 = new Integer[0];
+    private static final Integer[] to1 = new Integer[1];
+    private static final Integer[] to10 = new Integer[10];
+    private static final Integer[] to100 = new Integer[100];
+    private static final Integer[] to1000 = new Integer[1000];
+    private static final Integer[] reversed = new Integer[100];
+    private static final Integer[] ones = new Integer[100];
+    private static final Integer[] twice = new Integer[200];
+    private static final Integer[] pseudoRandom;
+
+    private static final Object[][] testData;
+    private static final Object[][] testSmallData;
+    private static final Object[][] testMiniData;
+    private static final Object[][] withNullTestData;
+    private static final Object[][] spliteratorTestData;
+
+    static {
+        Integer[][] arrays = {to0, to1, to10, to100, to1000};
+        for (Integer[] arr : arrays) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = i;
+            }
+        }
+        for (int i = 0; i < reversed.length; i++) {
+            reversed[i] = reversed.length - i;
+        }
+        for (int i = 0; i < ones.length; i++) {
+            ones[i] = 1;
+        }
+        System.arraycopy(to100, 0, twice, 0, to100.length);
+        System.arraycopy(to100, 0, twice, to100.length, to100.length);
+        pseudoRandom = new Integer[LambdaTestHelpers.LONG_STRING.length()];
+        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+            pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
+        }
+    }
+
+    static final Object[][] arrays = {
+            {"empty", to0},
+            {"0..1", to1},
+            {"0..10", to10},
+            {"0..100", to100},
+            {"0..1000", to1000},
+            {"100x[1]", ones},
+            {"2x[0..100]", twice},
+            {"reverse 0..100", reversed},
+            {"pseudorandom", pseudoRandom}
+    };
+
+    static {
+        {
+            List<Object[]> listMini = new ArrayList<>();
+            List<Object[]> listSmall = new ArrayList<>();
+            List<Object[]> list1000 = new ArrayList<>();
+            List<Object[]> list = null;
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final Integer[] ints = (Integer[])data[1];
+                final List<Integer> intsAsList = Arrays.asList(ints);
+
+                list = ints.length >= 1000 ? list1000 : (ints.length >= 100 ? listSmall : listMini);
+
+                list.add(arrayDataDescr("array:" + name, ints));
+                list.add(collectionDataDescr("ArrayList.asList:" + name, intsAsList));
+                list.add(collectionDataDescr("ArrayList:" + name, new ArrayList<>(intsAsList)));
+                list.add(streamDataDescr("DelegatingStream(ArrayList):" + name,
+                                         () -> new ArrayList<>(intsAsList).stream()));
+                List<Integer> aList = new ArrayList<>(intsAsList);
+                if (LambdaTestMode.isNormalMode()) {
+                    // Only include sub-lists for normal test execution mode
+                    // This data is serialization-hostile since the state of the
+                    // deserialized sub-list will be out of sync with the
+                    // enclosing list.
+                    list.add(collectionDataDescr("ArrayList.Sublist:" + name,
+                                                 (ints.length) <= 1 ? aList.subList(0, 0) : aList.subList(1, ints.length / 2)));
+                }
+                list.add(collectionDataDescr("LinkedList:" + name, new LinkedList<>(intsAsList)));
+                list.add(collectionDataDescr("HashSet:" + name, new HashSet<>(intsAsList)));
+                list.add(collectionDataDescr("LinkedHashSet:" + name, new LinkedHashSet<>(intsAsList)));
+                list.add(collectionDataDescr("TreeSet:" + name, new TreeSet<>(intsAsList)));
+                SpinedBuffer<Integer> spinedBuffer = new SpinedBuffer<>();
+                intsAsList.forEach(spinedBuffer);
+                list.add(sbDataDescr("SpinedBuffer:" + name, spinedBuffer));
+
+                // @@@ Add more
+            }
+            testMiniData = listMini.toArray(new Object[0][]);
+            listSmall.addAll(listMini);
+            testSmallData = listSmall.toArray(new Object[0][]);
+            list1000.addAll(listSmall);
+            testData = list1000.toArray(new Object[0][]);
+        }
+
+        // Simple combination of numbers and null values, probably excessive but may catch
+        // errors for initialization/termination/sequence
+        // @@@ This is separate from the other data for now until nulls are consistently supported by
+        // all operations
+        {
+            List<Object[]> list = new ArrayList<>();
+            int size = 5;
+            for (int i = 0; i < (1 << size) - 2; i++) {
+                Integer[] content = new Integer[size];
+                for (int e = 0; e < size; e++) {
+                    content[e] = (i & (1 << e)) > 0 ? e + 1 : null;
+                }
+
+                // ORDERED
+                list.add(arrayDataDescr("array:" + i, content));
+                // not ORDERED, DISTINCT
+                list.add(collectionDataDescr("HashSet:" + i, new HashSet<>(Arrays.asList(content))));
+            }
+
+            withNullTestData = list.toArray(new Object[0][]);
+        }
+
+        {
+            List<Object[]> spliterators = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final Integer[] ints = (Integer[])data[1];
+
+                spliterators.add(splitDescr("Arrays.s(array):" + name,
+                                            () -> Arrays.spliterator(ints)));
+                spliterators.add(splitDescr("arrays.s(array,o,l):" + name,
+                                            () -> Arrays.spliterator(ints, 0, ints.length/2)));
+                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+                                            () -> {
+                                                SpinedBuffer<Integer> sb = new SpinedBuffer<>();
+                                                for (Integer i : ints)
+                                                    sb.accept(i);
+                                                return sb.spliterator();
+                                            }));
+                spliterators.add(splitDescr("Iterators.s(Arrays.s(array).iterator(), size):" + name,
+                                            () -> Spliterators.spliterator(Arrays.asList(ints).iterator(), ints.length, 0)));
+                spliterators.add(splitDescr("Iterators.s(Arrays.s(array).iterator()):" + name,
+                                            () -> Spliterators.spliteratorUnknownSize(Arrays.asList(ints).iterator(), 0)));
+                spliterators.add(splitDescr("Stream.iterate(0,x->x<l,x->x+1): " + name,
+                                            () -> Stream.iterate(0, x -> x < ints.length, x -> x + 1).spliterator()));
+                // @@@ Add map and collection spliterators when spliterator() is exposed on Collection or Iterable
+            }
+            spliteratorTestData = spliterators.toArray(new Object[0][]);
+        }
+    }
+
+    static <T> Object[] arrayDataDescr(String description, T[] data) {
+        return new Object[] { description, TestData.Factory.ofArray(description, data)};
+    }
+
+    static <T> Object[] streamDataDescr(String description, Supplier<Stream<T>> supplier) {
+        return new Object[] { description, TestData.Factory.ofSupplier(description, supplier)};
+    }
+
+    static <T> Object[] collectionDataDescr(String description, Collection<T> data) {
+        return new Object[] { description, TestData.Factory.ofCollection(description, data)};
+    }
+
+    static <T> Object[] sbDataDescr(String description, SpinedBuffer<T> data) {
+        return new Object[] { description, TestData.Factory.ofSpinedBuffer(description, data)};
+    }
+
+    static <T> Object[] splitDescr(String description, Supplier<Spliterator<T>> ss) {
+        return new Object[] { description, ss };
+    }
+
+    // Return an array of ( String name, StreamTestData<Integer> )
+    @DataProvider(name = "StreamTestData<Integer>")
+    public static Object[][] makeStreamTestData() {
+        return testData;
+    }
+
+    @DataProvider(name = "StreamTestData<Integer>.small")
+    public static Object[][] makeSmallStreamTestData() {
+        return testSmallData;
+    }
+
+    @DataProvider(name = "StreamTestData<Integer>.mini")
+    public static Object[][] makeMiniStreamTestData() {
+        return testMiniData;
+    }
+
+    @DataProvider(name = "withNull:StreamTestData<Integer>")
+    public static Object[][] makeStreamWithNullTestData() {
+        return withNullTestData;
+    }
+
+    // returns an array of (String name, Supplier<Spliterator<Integer>>)
+    @DataProvider(name = "Spliterator<Integer>")
+    public static Object[][] spliteratorProvider() {
+        return spliteratorTestData;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StreamTestScenario.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.SpliteratorTestHelper;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+/**
+ * Test scenarios for reference streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results.  Each scenario describes a different way of computing the
+ * stream contents.  The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum StreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+    STREAM_FOR_EACH(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            Stream<U> s = m.apply(source);
+            if (s.isParallel()) {
+                s = s.sequential();
+            }
+            s.forEach(b);
+        }
+    },
+
+    // Collec to list
+    STREAM_COLLECT(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (U t : m.apply(source).collect(Collectors.toList())) {
+                b.accept(t);
+            }
+        }
+    },
+
+    // To array
+    STREAM_TO_ARRAY(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (Object t : m.apply(source).toArray()) {
+                b.accept((U) t);
+            }
+        }
+    },
+
+    // Wrap as stream, and iterate in pull mode
+    STREAM_ITERATOR(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (Iterator<U> seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
+                b.accept(seqIter.next());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (Spliterator<U> spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR_FOREACH(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    // Wrap as parallel stream + sequential
+    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            m.apply(source).sequential().forEach(b);
+        }
+    },
+
+    // Wrap as parallel stream + forEachOrdered
+    PAR_STREAM_FOR_EACH_ORDERED(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            // @@@ Want to explicitly select ordered equalator
+            m.apply(source).forEachOrdered(b);
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (Spliterator<U> spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR_FOREACH(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    // Wrap as parallel stream + toArray
+    PAR_STREAM_TO_ARRAY(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (Object t : m.apply(source).toArray())
+                b.accept((U) t);
+        }
+    },
+
+    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            Stream<U> s = m.apply(source);
+            Spliterator<U> sp = s.spliterator();
+            Stream<U> ss = StreamSupport.stream(() -> sp,
+                                                StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+                                                | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
+            for (Object t : ss.toArray())
+                b.accept((U) t);
+        }
+    },
+
+    // Wrap as parallel stream + toArray and clear SIZED flag
+    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            Stream<U> pipe2 = m.apply(pipe1);
+
+            for (Object t : pipe2.toArray())
+                b.accept((U) t);
+        }
+    },
+
+    // Wrap as parallel + collect to list
+    PAR_STREAM_COLLECT_TO_LIST(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (U u : m.apply(source).collect(Collectors.toList()))
+                b.accept(u);
+        }
+    },
+
+    // Wrap sequential as parallel, + collect to list
+    STREAM_TO_PAR_STREAM_COLLECT_TO_LIST(true) {
+        public <T, S_IN extends BaseStream<T, S_IN>>
+        S_IN getStream(TestData<T, S_IN> data) {
+            return data.stream().parallel();
+        }
+
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (U u : m.apply(source).collect(Collectors.toList()))
+                b.accept(u);
+        }
+    },
+
+    // Wrap parallel as sequential,, + collect
+    PAR_STREAM_TO_STREAM_COLLECT_TO_LIST(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (U u : m.apply(source).collect(Collectors.toList()))
+                b.accept(u);
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing
+    PAR_STREAM_FOR_EACH(true, false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            m.apply(source).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
+    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            m.apply(pipe1).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+    ;
+
+    // The set of scenarios that clean the SIZED flag
+    public static final Set<StreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
+            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
+
+    private final boolean isParallel;
+
+    private final boolean isOrdered;
+
+    StreamTestScenario(boolean isParallel) {
+        this(isParallel, true);
+    }
+
+    StreamTestScenario(boolean isParallel, boolean isOrdered) {
+        this.isParallel = isParallel;
+        this.isOrdered = isOrdered;
+    }
+
+    public StreamShape getShape() {
+        return StreamShape.REFERENCE;
+    }
+
+    public boolean isParallel() {
+        return isParallel;
+    }
+
+    public boolean isOrdered() {
+        return isOrdered;
+    }
+
+    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+        try (S_IN source = getStream(data)) {
+            run(data, source, b, (Function<S_IN, Stream<U>>) m);
+        }
+    }
+
+    abstract <T, U, S_IN extends BaseStream<T, S_IN>>
+    void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/TestData.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,355 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+package java.util.stream;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.PrimitiveIterator;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.function.DoubleConsumer;
+import java.util.function.Function;
+import java.util.function.IntConsumer;
+import java.util.function.LongConsumer;
+import java.util.function.Supplier;
+import java.util.function.ToIntFunction;
+
+/** Describes a test data set for use in stream tests */
+public interface TestData<T, S extends BaseStream<T, S>>
+        extends Iterable<T> {
+
+    default int size() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    default Iterator<T> iterator() {
+        return Spliterators.iterator(spliterator());
+    }
+
+    Spliterator<T> spliterator();
+
+    default boolean isOrdered() {
+        return spliterator().hasCharacteristics(Spliterator.ORDERED);
+    }
+
+    StreamShape getShape();
+
+    default <A extends Collection<? super T>> A into(A target) {
+        spliterator().forEachRemaining(target::add);
+        return target;
+    }
+
+    S stream();
+
+    S parallelStream();
+
+    public interface OfRef<T> extends TestData<T, Stream<T>> { }
+
+    public interface OfInt extends TestData<Integer, IntStream> { }
+
+    public interface OfLong extends TestData<Long, LongStream> { }
+
+    public interface OfDouble extends TestData<Double, DoubleStream> { }
+
+    // @@@ Temporary garbage class to avoid triggering bugs with lambdas in static methods in interfaces
+    public static class Factory {
+        public static <T> OfRef<T> ofArray(String name, T[] array) {
+            return new AbstractTestData.RefTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
+                                                      Arrays::spliterator, a -> a.length);
+        }
+
+        public static <T> OfRef<T> ofCollection(String name, Collection<T> collection) {
+            return new AbstractTestData.RefTestData<>(name, collection, Collection::stream, Collection::parallelStream,
+                                                      Collection::spliterator, Collection::size);
+        }
+
+        public static <T> OfRef<T> ofSpinedBuffer(String name, SpinedBuffer<T> buffer) {
+            return new AbstractTestData.RefTestData<>(name, buffer,
+                                                      b -> StreamSupport.stream(b.spliterator(), false),
+                                                      b -> StreamSupport.stream(b.spliterator(), true),
+                                                      SpinedBuffer::spliterator,
+                                                      b -> (int) b.count());
+        }
+
+        public static <T> OfRef<T> ofSupplier(String name, Supplier<Stream<T>> supplier) {
+            return new AbstractTestData.RefTestData<>(name, supplier,
+                                                      Supplier::get,
+                                                      s -> s.get().parallel(),
+                                                      s -> s.get().spliterator(),
+                                                      s -> (int) s.get().spliterator().getExactSizeIfKnown());
+        }
+
+        public static <T> OfRef<T> ofRefNode(String name, Node<T> node) {
+            return new AbstractTestData.RefTestData<>(name, node,
+                                                      n -> StreamSupport.stream(n::spliterator, Spliterator.SIZED | Spliterator.ORDERED, false),
+                                                      n -> StreamSupport.stream(n::spliterator, Spliterator.SIZED | Spliterator.ORDERED, true),
+                                                      Node::spliterator,
+                                                      n -> (int) n.count());
+        }
+
+        // int factories
+        public static <T> OfInt ofArray(String name, int[] array) {
+            return new AbstractTestData.IntTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
+                                                      Arrays::spliterator, a -> a.length);
+        }
+
+        public static OfInt ofSpinedBuffer(String name, SpinedBuffer.OfInt buffer) {
+            return new AbstractTestData.IntTestData<>(name, buffer,
+                                                      b -> StreamSupport.intStream(b.spliterator(), false),
+                                                      b -> StreamSupport.intStream(b.spliterator(), true),
+                                                      SpinedBuffer.OfInt::spliterator,
+                                                      b -> (int) b.count());
+        }
+
+        public static OfInt ofIntSupplier(String name, Supplier<IntStream> supplier) {
+            return new AbstractTestData.IntTestData<>(name, supplier,
+                                                      Supplier::get,
+                                                      s -> s.get().parallel(),
+                                                      s -> s.get().spliterator(),
+                                                      s -> (int) s.get().spliterator().getExactSizeIfKnown());
+        }
+
+        public static OfInt ofNode(String name, Node.OfInt node) {
+            int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
+            return new AbstractTestData.IntTestData<>(name, node,
+                                                      n -> StreamSupport.intStream(n::spliterator, characteristics, false),
+                                                      n -> StreamSupport.intStream(n::spliterator, characteristics, true),
+                                                      Node.OfInt::spliterator,
+                                                      n -> (int) n.count());
+        }
+
+        // long factories
+        public static <T> OfLong ofArray(String name, long[] array) {
+            return new AbstractTestData.LongTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
+                                                       Arrays::spliterator, a -> a.length);
+        }
+
+        public static OfLong ofSpinedBuffer(String name, SpinedBuffer.OfLong buffer) {
+            return new AbstractTestData.LongTestData<>(name, buffer,
+                                                      b -> StreamSupport.longStream(b.spliterator(), false),
+                                                      b -> StreamSupport.longStream(b.spliterator(), true),
+                                                      SpinedBuffer.OfLong::spliterator,
+                                                      b -> (int) b.count());
+        }
+
+        public static OfLong ofLongSupplier(String name, Supplier<LongStream> supplier) {
+            return new AbstractTestData.LongTestData<>(name, supplier,
+                                                      Supplier::get,
+                                                      s -> s.get().parallel(),
+                                                      s -> s.get().spliterator(),
+                                                      s -> (int) s.get().spliterator().getExactSizeIfKnown());
+        }
+
+        public static OfLong ofNode(String name, Node.OfLong node) {
+            int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
+            return new AbstractTestData.LongTestData<>(name, node,
+                                                      n -> StreamSupport.longStream(n::spliterator, characteristics, false),
+                                                      n -> StreamSupport.longStream(n::spliterator, characteristics, true),
+                                                      Node.OfLong::spliterator,
+                                                      n -> (int) n.count());
+        }
+
+        // double factories
+        public static <T> OfDouble ofArray(String name, double[] array) {
+            return new AbstractTestData.DoubleTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
+                                                         Arrays::spliterator, a -> a.length);
+        }
+
+        public static OfDouble ofSpinedBuffer(String name, SpinedBuffer.OfDouble buffer) {
+            return new AbstractTestData.DoubleTestData<>(name, buffer,
+                                                         b -> StreamSupport.doubleStream(b.spliterator(), false),
+                                                         b -> StreamSupport.doubleStream(b.spliterator(), true),
+                                                         SpinedBuffer.OfDouble::spliterator,
+                                                         b -> (int) b.count());
+        }
+
+        public static OfDouble ofDoubleSupplier(String name, Supplier<DoubleStream> supplier) {
+            return new AbstractTestData.DoubleTestData<>(name, supplier,
+                                                         Supplier::get,
+                                                         s -> s.get().parallel(),
+                                                         s -> s.get().spliterator(),
+                                                         s -> (int) s.get().spliterator().getExactSizeIfKnown());
+        }
+
+        public static OfDouble ofNode(String name, Node.OfDouble node) {
+            int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
+            return new AbstractTestData.DoubleTestData<>(name, node,
+                                                         n -> StreamSupport.doubleStream(n::spliterator, characteristics, false),
+                                                         n -> StreamSupport.doubleStream(n::spliterator, characteristics, true),
+                                                         Node.OfDouble::spliterator,
+                                                         n -> (int) n.count());
+        }
+    }
+
+
+    abstract class AbstractTestData<T, S extends BaseStream<T, S>,
+            T_STATE,
+                                    T_SPLITR extends Spliterator<T>>
+            implements TestData<T, S> {
+        private final String name;
+        private final StreamShape shape;
+        protected final T_STATE state;
+        private final ToIntFunction<T_STATE> sizeFn;
+        private final Function<T_STATE, S> streamFn;
+        private final Function<T_STATE, S> parStreamFn;
+        private final Function<T_STATE, T_SPLITR> splitrFn;
+
+        AbstractTestData(String name,
+                         StreamShape shape,
+                         T_STATE state,
+                         Function<T_STATE, S> streamFn,
+                         Function<T_STATE, S> parStreamFn,
+                         Function<T_STATE, T_SPLITR> splitrFn,
+                         ToIntFunction<T_STATE> sizeFn) {
+            this.name = name;
+            this.shape = shape;
+            this.state = state;
+            this.streamFn = streamFn;
+            this.parStreamFn = parStreamFn;
+            this.splitrFn = splitrFn;
+            this.sizeFn = sizeFn;
+        }
+
+        @Override
+        public StreamShape getShape() {
+            return shape;
+        }
+
+        @Override
+        public String toString() {
+            return getClass().getSimpleName() + "[" + name + "]";
+        }
+
+        @Override
+        public int size() {
+            return sizeFn.applyAsInt(state);
+        }
+
+        @Override
+        public T_SPLITR spliterator() {
+            return splitrFn.apply(state);
+        }
+
+        @Override
+        public S stream() {
+            return streamFn.apply(state);
+        }
+
+        @Override
+        public S parallelStream() {
+            return parStreamFn.apply(state);
+        }
+
+        public static class RefTestData<T, I>
+                extends AbstractTestData<T, Stream<T>, I, Spliterator<T>>
+                implements TestData.OfRef<T> {
+
+            protected RefTestData(String name,
+                                  I state,
+                                  Function<I, Stream<T>> streamFn,
+                                  Function<I, Stream<T>> parStreamFn,
+                                  Function<I, Spliterator<T>> splitrFn,
+                                  ToIntFunction<I> sizeFn) {
+                super(name, StreamShape.REFERENCE, state, streamFn, parStreamFn, splitrFn, sizeFn);
+            }
+
+        }
+
+        static class IntTestData<I>
+                extends AbstractTestData<Integer, IntStream, I, Spliterator.OfInt>
+                implements TestData.OfInt {
+
+            protected IntTestData(String name,
+                                  I state,
+                                  Function<I, IntStream> streamFn,
+                                  Function<I, IntStream> parStreamFn,
+                                  Function<I, Spliterator.OfInt> splitrFn,
+                                  ToIntFunction<I> sizeFn) {
+                super(name, StreamShape.INT_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
+            }
+
+            @Override
+            public PrimitiveIterator.OfInt iterator() {
+                return Spliterators.iterator(spliterator());
+            }
+
+            @Override
+            public <A extends Collection<? super Integer>> A into(A target) {
+                spliterator().forEachRemaining((IntConsumer) target::add);
+                return target;
+            }
+        }
+
+        static class LongTestData<I>
+                extends AbstractTestData<Long, LongStream, I, Spliterator.OfLong>
+                implements TestData.OfLong {
+
+            protected LongTestData(String name,
+                                   I state,
+                                   Function<I, LongStream> streamFn,
+                                   Function<I, LongStream> parStreamFn,
+                                   Function<I, Spliterator.OfLong> splitrFn,
+                                   ToIntFunction<I> sizeFn) {
+                super(name, StreamShape.LONG_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
+            }
+
+            @Override
+            public PrimitiveIterator.OfLong iterator() {
+                return Spliterators.iterator(spliterator());
+            }
+
+            @Override
+            public <A extends Collection<? super Long>> A into(A target) {
+                spliterator().forEachRemaining((LongConsumer) target::add);
+                return target;
+            }
+        }
+
+        static class DoubleTestData<I>
+                extends AbstractTestData<Double, DoubleStream, I, Spliterator.OfDouble>
+                implements OfDouble {
+
+            protected DoubleTestData(String name,
+                                     I state,
+                                     Function<I, DoubleStream> streamFn,
+                                     Function<I, DoubleStream> parStreamFn,
+                                     Function<I, Spliterator.OfDouble> splitrFn,
+                                     ToIntFunction<I> sizeFn) {
+                super(name, StreamShape.DOUBLE_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
+            }
+
+            @Override
+            public PrimitiveIterator.OfDouble iterator() {
+                return Spliterators.iterator(spliterator());
+            }
+
+            @Override
+            public <A extends Collection<? super Double>> A into(A target) {
+                spliterator().forEachRemaining((DoubleConsumer) target::add);
+                return target;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/TestFlagExpectedOp.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2012, 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.
+ */
+package java.util.stream;
+
+import org.testng.Assert;
+
+import java.util.EnumSet;
+
+class TestFlagExpectedOp<T> extends FlagDeclaringOp<T> {
+
+    static class Builder<T> {
+        final int flags;
+        StreamShape shape = StreamShape.REFERENCE;
+
+        EnumSet<StreamOpFlag> known = EnumSet.noneOf(StreamOpFlag.class);
+        EnumSet<StreamOpFlag> preserve = EnumSet.noneOf(StreamOpFlag.class);
+        EnumSet<StreamOpFlag> notKnown = EnumSet.noneOf(StreamOpFlag.class);
+
+        Builder(int flags) {
+            this.flags = flags;
+        }
+
+        Builder<T> known(EnumSet<StreamOpFlag> known) {
+            this.known = known;
+            return this;
+        }
+
+        Builder<T> preserve(EnumSet<StreamOpFlag> preserve) {
+            this.preserve = preserve;
+            return this;
+        }
+
+        Builder<T> notKnown(EnumSet<StreamOpFlag> notKnown) {
+            this.notKnown = notKnown;
+            return this;
+        }
+
+        Builder<T> shape(StreamShape shape) {
+            this.shape = shape;
+            return this;
+        }
+
+        TestFlagExpectedOp<T> build() {
+            return new TestFlagExpectedOp<>(flags, known, preserve, notKnown, shape);
+        }
+    }
+
+    final EnumSet<StreamOpFlag> known;
+    final EnumSet<StreamOpFlag> preserve;
+    final EnumSet<StreamOpFlag> notKnown;
+    final StreamShape shape;
+
+    TestFlagExpectedOp(int flags,
+                       EnumSet<StreamOpFlag> known,
+                       EnumSet<StreamOpFlag> preserve,
+                       EnumSet<StreamOpFlag> notKnown) {
+        this(flags, known, preserve, notKnown, StreamShape.REFERENCE);
+    }
+
+    TestFlagExpectedOp(int flags,
+                       EnumSet<StreamOpFlag> known,
+                       EnumSet<StreamOpFlag> preserve,
+                       EnumSet<StreamOpFlag> notKnown,
+                       StreamShape shape) {
+        super(flags);
+        this.known = known;
+        this.preserve = preserve;
+        this.notKnown = notKnown;
+        this.shape = shape;
+    }
+
+    @Override
+    public StreamShape outputShape() {
+        return shape;
+    }
+
+    @Override
+    public StreamShape inputShape() {
+        return shape;
+    }
+
+    @Override
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public Sink<T> opWrapSink(int flags, boolean parallel, Sink upstream) {
+        assertFlags(flags);
+        return upstream;
+    }
+
+    private void assertFlags(int flags) {
+        for (StreamOpFlag f : known) {
+            Assert.assertTrue(f.isKnown(flags),
+                              String.format("Flag %s is not known, but should be known.", f.toString()));
+        }
+
+        for (StreamOpFlag f : preserve) {
+            Assert.assertTrue(f.isPreserved(flags),
+                              String.format("Flag %s is not preserved, but should be preserved.", f.toString()));
+        }
+
+        for (StreamOpFlag f : notKnown) {
+            Assert.assertFalse(f.isKnown(flags),
+                               String.format("Flag %s is known, but should be not known.", f.toString()));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/ThrowableHelper.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+public final class ThrowableHelper {
+
+    public static void checkException(Class<? extends Exception> ce, Runnable r) {
+        Exception caught = null;
+        try {
+            r.run();
+        } catch (Exception e) {
+            caught = e;
+        }
+
+        assertNotNull(caught);
+        assertTrue(ce.isInstance(caught));
+    }
+
+    public static void checkNPE(Runnable r) {
+        checkException(NullPointerException.class, r);
+    }
+
+    public static void checkISE(Runnable r) {
+        checkException(IllegalStateException.class, r);
+    }
+}
--- a/jdk/test/sample/TEST.properties	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-external.lib.roots = ../../
--- a/jdk/test/sample/chatserver/ChatTest.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,402 +0,0 @@
-/*
- * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* @test
- * @summary Test chat server chatserver test
- *
- * @library /src/sample/share/nio/chatserver
- * @build ChatTest ChatServer Client ClientReader DataReader MessageReader NameReader
- * @run testng ChatTest
- */
-
-import java.io.*;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.CyclicBarrier;
-
-import org.testng.annotations.Test;
-
-public class ChatTest {
-    public static int listeningPort = 0;
-
-    @Test
-    public static void doTest() throws Throwable {
-        testStartStop();
-        testPortOpen();
-        testAsksForName();
-        testUseName();
-        testConnectDisconnectConnect();
-        testUsernameAndMessage();
-        testDontReceiveMessageInNameState();
-    }
-
-    private static ChatServer startServer() throws IOException {
-        ChatServer server = new ChatServer(0);
-        InetSocketAddress address = (InetSocketAddress) server.getSocketAddress();
-        listeningPort = address.getPort();
-        server.run();
-        return server;
-    }
-
-    public static void testStartStop() throws Exception {
-        ChatServer server = startServer();
-        server.shutdown();
-    }
-
-    public static void testPortOpen() throws Exception {
-        ChatServer server = startServer();
-        try {
-            Socket socket = new Socket("localhost", listeningPort);
-            if (!socket.isConnected()) {
-                throw new RuntimeException("Failed to connect to server: port not open");
-            }
-        } finally {
-            server.shutdown();
-        }
-    }
-
-    public static void testAsksForName() throws Exception {
-        ChatServer server = startServer();
-        try {
-            Socket socket = new Socket("localhost", listeningPort);
-
-            Reader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
-            String string = readAvailableString(reader);
-            if (!string.equals("Name: ")) {
-                throw new RuntimeException("Server doesn't send Name: ");
-            }
-        } finally {
-            server.shutdown();
-        }
-    }
-
-    public static void testUseName() throws Throwable {
-        ChatServer server = startServer();
-        try {
-            performTestUseName();
-        } finally {
-            server.shutdown();
-        }
-    }
-
-    public static void testConnectDisconnectConnect() throws Exception {
-        ChatServer server = startServer();
-        try {
-            performTestConnectDisconnectConnect();
-        } finally {
-            server.shutdown();
-        }
-    }
-
-    public static void testUsernameAndMessage() throws Exception {
-        ChatServer server = startServer();
-        try {
-            performTestUsernameAndMessage();
-        } finally {
-            server.shutdown();
-        }
-    }
-
-    public static void testDontReceiveMessageInNameState() throws Exception {
-        ChatServer server = startServer();
-        try {
-            performDontReceiveMessageInNameState();
-        } finally {
-            server.shutdown();
-        }
-    }
-
-    private static void assertEqual(List<Exception> exception, Object value, Object expected) {
-        if (expected == value) {
-            return;
-        }
-        if (expected == null) {
-            exception.add(new RuntimeException("Expected null, but was: " + value));
-            return;
-        }
-        if (!expected.equals(value)) {
-            exception.add(new RuntimeException("Expected: " + expected + " but was: " + value));
-            return;
-        }
-    }
-
-    private static void performDontReceiveMessageInNameState() throws Exception {
-        final CyclicBarrier barrier1 = new CyclicBarrier(2);
-        final CyclicBarrier barrier2 = new CyclicBarrier(2);
-        final CyclicBarrier barrier3 = new CyclicBarrier(2);
-        final List<Exception> exceptions = Collections.synchronizedList(new ArrayList<Exception>());
-
-        ChatConnection chatConnection = new ChatConnection() {
-            @Override
-            public void run(Socket socket, BufferedReader reader, Writer writer) throws Exception {
-                String string = readAvailableString(reader);
-                assertEqual(exceptions, string, "Name: ");
-                writer.write("testClient1\n");
-                waitForJoin(reader, "testClient1");
-                barrier1.await();
-                writer.write("Ignore this!\n");
-                barrier2.await();
-                barrier3.await();
-            }
-        };
-
-        Thread client2 = new Thread(new ChatConnection() {
-            @Override
-            public void run(Socket socket, BufferedReader reader, Writer writer) throws Exception {
-                barrier1.await();
-                barrier2.await();
-                String string = readAvailableString(reader);
-                assertEqual(exceptions, string, "Name: ");
-                string = readAvailableString(reader, true);
-                assertEqual(exceptions, string, null);
-                writer.write("testClient2\n");
-                barrier3.await();
-            }
-        });
-
-        client2.start();
-        chatConnection.run();
-        if (!exceptions.isEmpty()) {
-            throw exceptions.get(0);
-        }
-
-    }
-
-    private static void waitForJoin(BufferedReader reader, String s) throws IOException {
-        String joined;
-        do {
-            joined = readAvailableString(reader);
-        } while (!(joined != null && joined.contains("Welcome " + s)));
-    }
-
-    private static void performTestUsernameAndMessage() throws Exception {
-        final CyclicBarrier barrier1 = new CyclicBarrier(2);
-        final CyclicBarrier barrier2 = new CyclicBarrier(2);
-        final CyclicBarrier barrier3 = new CyclicBarrier(2);
-        final List<Exception> exceptions = Collections.synchronizedList(new ArrayList<Exception>());
-
-        ChatConnection chatConnection = new ChatConnection() {
-            @Override
-            public void run(Socket socket, BufferedReader reader, Writer writer) throws Exception {
-                String string = readAvailableString(reader);
-                assertEqual(exceptions, string, "Name: ");
-                writer.write("testClient1\n");
-                waitForJoin(reader, "testClient1");
-                barrier1.await();
-                barrier2.await();
-                string = readAvailableString(reader);
-                assertEqual(exceptions, string, "testClient2: Hello world!\n");
-                barrier3.await();
-            }
-        };
-
-        Thread client2 = new Thread(new ChatConnection() {
-            @Override
-            public void run(Socket socket, BufferedReader reader, Writer writer) throws Exception {
-                String string = readAvailableString(reader);
-                assertEqual(exceptions, string, "Name: ");
-                barrier1.await();
-                writer.write("testClient2\nHello world!\n");
-                barrier2.await();
-                barrier3.await();
-            }
-        });
-
-        client2.start();
-        chatConnection.run();
-        if (!exceptions.isEmpty()) {
-            throw exceptions.get(0);
-        }
-    }
-
-    private static void performTestConnectDisconnectConnect() throws Exception {
-        final CyclicBarrier barrier1 = new CyclicBarrier(2);
-        final CyclicBarrier barrier2 = new CyclicBarrier(2);
-        final CyclicBarrier barrier3 = new CyclicBarrier(2);
-        final List<Exception> exceptions = new ArrayList<Exception>();
-
-        ChatConnection chatConnection = new ChatConnection() {
-            @Override
-            public void run(Socket socket, BufferedReader reader, Writer writer) throws Exception {
-                String string = readAvailableString(reader);
-                assertEqual(exceptions, string, "Name: ");
-                writer.write("testClient1\n");
-            }
-        };
-
-        ChatConnection chatConnection2 = new ChatConnection() {
-            @Override
-            public void run(Socket socket, BufferedReader reader, Writer writer) throws Exception {
-                readAvailableString(reader);
-                writer.write("testClient1\n");
-                waitForJoin(reader, "testClient1");
-                barrier1.await();
-                writer.write("Good morning!\n");
-                barrier2.await();
-                String string = readAvailableString(reader);
-                assertEqual(exceptions, string, "testClient2: Hello world!\n");
-                barrier3.await();
-            }
-        };
-
-        Thread client2 = new Thread(new ChatConnection() {
-            @Override
-            public void run(Socket socket, BufferedReader reader, Writer writer) throws Exception {
-                readAvailableString(reader);
-                writer.write("testClient2\n");
-                waitForJoin(reader, "testClient2");
-                barrier1.await();
-                writer.write("Hello world!\n");
-                barrier2.await();
-                String string = readAvailableString(reader);
-                assertEqual(exceptions, string, "testClient1: Good morning!\n");
-                barrier3.await();
-            }
-        });
-
-        client2.start();
-        chatConnection.run();
-        chatConnection2.run();
-        if (!exceptions.isEmpty()) {
-            throw exceptions.get(0);
-        }
-    }
-
-    private static void performTestUseName() throws Exception {
-        final CyclicBarrier barrier1 = new CyclicBarrier(2);
-        final CyclicBarrier barrier2 = new CyclicBarrier(2);
-        final CyclicBarrier barrier3 = new CyclicBarrier(2);
-        final List<Exception> exceptions = new ArrayList<Exception>();
-
-        ChatConnection chatConnection = new ChatConnection() {
-            @Override
-            public void run(Socket socket, BufferedReader reader, Writer writer) throws Exception {
-                String string = readAvailableString(reader);
-                if (!"Name: ".equals(string)) {
-                    exceptions.add(new RuntimeException("Expected Name: "));
-                }
-                writer.write("testClient1\n");
-                waitForJoin(reader, "testClient1");
-                barrier1.await();
-                barrier2.await();
-                string = readAvailableString(reader);
-                if (!"testClient2: Hello world!\n".equals(string)) {
-                    exceptions.add(new RuntimeException("testClient2: Hello world!\n"));
-                }
-                barrier3.await();
-            }
-        };
-
-        Thread client2 = new Thread(new ChatConnection() {
-            @Override
-            public void run(Socket socket, BufferedReader reader, Writer writer) throws Exception {
-                String string = readAvailableString(reader);
-                if (!"Name: ".equals(string)) {
-                    exceptions.add(new RuntimeException("Expected Name: "));
-                }
-                writer.write("testClient2\n");
-                waitForJoin(reader, "testClient2");
-                barrier1.await();
-                writer.write("Hello world!\n");
-                barrier2.await();
-                barrier3.await();
-            }
-        });
-
-        client2.start();
-        chatConnection.run();
-        if (!exceptions.isEmpty()) {
-            throw exceptions.get(0);
-        }
-    }
-
-    private static String readAvailableString(Reader reader) throws IOException {
-        return readAvailableString(reader, false);
-    }
-
-    private static String readAvailableString(Reader reader, boolean now) throws IOException {
-        StringBuilder builder = new StringBuilder();
-        int bytes;
-        if (now && !reader.ready()) {
-            return null;
-        }
-        do {
-            char[] buf = new char[256];
-            bytes = reader.read(buf);
-            builder.append(buf, 0, bytes);
-        } while (bytes == 256);
-        return builder.toString();
-    }
-
-    private abstract static class ChatConnection implements Runnable {
-        public Exception exception;
-
-        @Override
-        public void run() {
-            try (Socket socket = new Socket("localhost", listeningPort);
-            BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
-            Writer writer = new FlushingWriter(new OutputStreamWriter(socket.getOutputStream()))) {
-                socket.setTcpNoDelay(true);
-
-                run(socket, reader, writer);
-            } catch (Exception e) {
-                exception = e;
-            }
-        }
-
-        public abstract void run(Socket socket, BufferedReader reader, Writer writer) throws Exception;
-    }
-
-    private static class FlushingWriter extends Writer {
-        public final Writer delegate;
-
-        private FlushingWriter(Writer delegate) {
-            this.delegate = delegate;
-        }
-
-        @Override
-        public void write(char[] cbuf, int off, int len) throws IOException {
-            delegate.write(cbuf, off, len);
-        }
-
-        @Override
-        public void flush() throws IOException {
-            delegate.flush();
-        }
-
-        @Override
-        public void close() throws IOException {
-            delegate.close();
-        }
-
-        @Override
-        public void write(String str) throws IOException {
-            super.write(str);
-            flush();
-        }
-    }
-}
--- a/jdk/test/sample/mergesort/MergeSortTest.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/* @test
- * @summary Test MergeSort
- *
- * @library /src/sample/share/forkjoin/mergesort
- * @build MergeSortTest MergeDemo MergeSort
- * @run testng MergeSortTest
- */
-
-import java.util.Arrays;
-import java.util.Random;
-
-import org.testng.annotations.Test;
-
-public class MergeSortTest {
-    private Random random;
-    private MergeSort target;
-
-    public MergeSortTest(Random random, MergeSort target) {
-        this.random = random;
-        this.target = target;
-    }
-
-    @Test
-    public static void doTest() {
-        MergeSortTest test = new MergeSortTest(new Random(), new MergeSort(Runtime.getRuntime().availableProcessors() * 4));
-        test.run();
-    }
-
-    private int[] generateArray(int elements) {
-        int[] array = new int[elements];
-        for (int i = 0; i < array.length; ++i) {
-            array[i] = random.nextInt(10);
-        }
-        return array;
-    }
-
-    private void run() {
-        testSort();
-        testSortSingle();
-        testSortEmpty();
-        testLong();
-    }
-
-    public void testLong() {
-        for (int i = 0; i < 1000; ++i) {
-            int elements = 1 + i * 100;
-
-            int[] array = generateArray(elements);
-            int[] copy = Arrays.copyOf(array, array.length);
-            Arrays.sort(copy);
-            target.sort(array);
-            assertEqual(copy, array);
-        }
-   }
-
-    private void testSortEmpty() {
-        int[] array = { };
-        target.sort(array);
-        assertEqual(new int[] { }, array);
-    }
-
-    private void testSortSingle() {
-        int[] array = { 1 };
-        target.sort(array);
-        assertEqual(new int[] { 1 }, array);
-    }
-
-    private void testSort() {
-        int[] array = { 7, 3, 9, 0, -6, 12, 54, 3, -6, 88, 1412};
-        target.sort(array);
-        assertEqual(new int[] { -6, -6, 0, 3, 3, 7, 9, 12, 54, 88, 1412 }, array);
-    }
-
-    private void assertEqual(int[] expected, int[] array) {
-        if (!Arrays.equals(expected, array)) {
-            throw new RuntimeException("Invalid sorted array!");
-        }
-    }
-
-
-}
--- a/jdk/test/sun/awt/dnd/8024061/bug8024061.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/awt/dnd/8024061/bug8024061.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -37,7 +37,7 @@
  * @run main/othervm/timeout=600 -XX:+UsePerfData JvmstatCountersTest 1
  * @run main/othervm/timeout=600 -XX:+UsePerfData -Dcom.sun.management.jmxremote JvmstatCountersTest 2
  * @run main/othervm/timeout=600 -XX:+UsePerfData -Dcom.sun.management.jmxremote.port=0 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false JvmstatCountersTest 3
- * @run main/othervm/timeout=600 -XX:+UsePerfData JvmstatCountersTest 4
+ * @run main/othervm/timeout=600 -XX:+UsePerfData -Djdk.attach.allowAttachSelf JvmstatCountersTest 4
  */
 
 import java.io.*;
--- a/jdk/test/sun/net/idn/NFS4StringPrep.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/net/idn/NFS4StringPrep.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
--- a/jdk/test/sun/security/krb5/auto/BogusKDC.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/krb5/auto/BogusKDC.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/sun/security/krb5/auto/NoAddresses.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/krb5/auto/NoAddresses.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/sun/security/krb5/auto/Renew.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/krb5/auto/Renew.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/sun/security/krb5/auto/Renewal.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/krb5/auto/Renewal.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/sun/security/krb5/auto/SSLwithPerms.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/krb5/auto/SSLwithPerms.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/sun/security/krb5/canonicalize/Test.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/krb5/canonicalize/Test.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2016 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/sun/security/mscapi/CastError.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/mscapi/CastError.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/sun/security/mscapi/PrngSlow.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/mscapi/PrngSlow.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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
--- a/jdk/test/sun/security/mscapi/PublicKeyInterop.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/mscapi/PublicKeyInterop.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2011, 2015 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
--- a/jdk/test/sun/security/pkcs12/StoreSecretKeyTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/pkcs12/StoreSecretKeyTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
--- a/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, 2016, Oracle and/or its affiliates. All rights
- * reserved.
+ * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/sun/security/ssl/CertPathRestrictions/JSSEClient.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/JSSEClient.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,6 +1,24 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ * 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.InputStream;
--- a/jdk/test/sun/security/ssl/CertPathRestrictions/JSSEServer.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/JSSEServer.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,6 +1,24 @@
 /*
  * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
+ * 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.InputStream;
--- a/jdk/test/sun/security/ssl/CertPathRestrictions/TLSRestrictions.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/ssl/CertPathRestrictions/TLSRestrictions.java	Wed Jul 05 23:25:53 2017 +0200
@@ -4,9 +4,7 @@
  *
  * 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.
+ * 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
--- a/jdk/test/sun/security/ssl/DHKeyExchange/DHEKeySizing.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/ssl/DHKeyExchange/DHEKeySizing.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,33 +31,44 @@
  * @bug 6956398
  * @summary make ephemeral DH key match the length of the certificate key
  * @run main/othervm
+ *      DHEKeySizing TLS_DHE_RSA_WITH_AES_128_CBC_SHA  false 1639 267
+ * @run main/othervm -Djsse.enableFFDHE=false
  *      DHEKeySizing SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA true 1255 75
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=matched
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=matched
  *      DHEKeySizing SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA true 1255 75
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=legacy
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=legacy
  *      DHEKeySizing SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA true 1255 75
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=1024
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=1024
  *      DHEKeySizing SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA true 1255 75
  *
- * @run main/othervm
+ * @run main/othervm -Djsse.enableFFDHE=false
  *      DHEKeySizing SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA true 229 75
  *
- * @run main/othervm
+ * @run main/othervm -Djsse.enableFFDHE=false
  *      DHEKeySizing TLS_DHE_RSA_WITH_AES_128_CBC_SHA  false 1383 139
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=legacy
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=legacy
  *      DHEKeySizing TLS_DHE_RSA_WITH_AES_128_CBC_SHA  false 1319 107
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=matched
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=matched
  *      DHEKeySizing TLS_DHE_RSA_WITH_AES_128_CBC_SHA  false 1639 267
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=1024
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=1024
  *      DHEKeySizing TLS_DHE_RSA_WITH_AES_128_CBC_SHA  false 1383 139
  *
- * @run main/othervm
+ * @run main/othervm -Djsse.enableFFDHE=false
  *      DHEKeySizing SSL_DH_anon_WITH_RC4_128_MD5  false 357 139
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=legacy
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=legacy
  *      DHEKeySizing SSL_DH_anon_WITH_RC4_128_MD5  false 293 107
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=matched
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=matched
  *      DHEKeySizing SSL_DH_anon_WITH_RC4_128_MD5  false 357 139
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=1024
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=1024
  *      DHEKeySizing SSL_DH_anon_WITH_RC4_128_MD5  false 357 139
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/DHKeyExchange/UseStrongDHSizes.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+//
+
+/*
+ * @test
+ * @bug 8140436
+ * @modules jdk.crypto.ec
+ * @library /javax/net/ssl/templates
+ * @summary Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
+ * @run main/othervm UseStrongDHSizes 2048
+ */
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.Security;
+import javax.net.ssl.SSLSocket;
+
+public class UseStrongDHSizes extends SSLSocketTemplate {
+    /*
+     * Run the test case.
+     */
+    public static void main(String[] args) throws Exception {
+        // reset the security property to make sure that the algorithms
+        // and keys used in this test are not disabled unexpectedly.
+        String constraint = "DH keySize < " + Integer.valueOf(args[0]);
+        Security.setProperty("jdk.tls.disabledAlgorithms", constraint);
+        Security.setProperty("jdk.certpath.disabledAlgorithms", "");
+
+        (new UseStrongDHSizes()).run();
+    }
+
+    @Override
+    protected void runServerApplication(SSLSocket socket) throws Exception {
+        String ciphers[] = {
+                "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
+                "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
+                "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
+                "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA"};
+
+        socket.setEnabledCipherSuites(ciphers);
+        socket.setWantClientAuth(true);
+
+        InputStream sslIS = socket.getInputStream();
+        OutputStream sslOS = socket.getOutputStream();
+
+        sslIS.read();
+        sslOS.write(85);
+        sslOS.flush();
+    }
+
+    @Override
+    protected void runClientApplication(SSLSocket socket) throws Exception {
+        String ciphers[] = {
+                "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
+                "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
+                "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
+                "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA"};
+        socket.setEnabledCipherSuites(ciphers);
+        socket.setUseClientMode(true);
+
+        InputStream sslIS = socket.getInputStream();
+        OutputStream sslOS = socket.getOutputStream();
+
+        sslOS.write(280);
+        sslOS.flush();
+        sslIS.read();
+    }
+}
--- a/jdk/test/sun/security/tools/jarsigner/nameclash.sh	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/tools/jarsigner/nameclash.sh	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2009, 2014 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -63,4 +63,3 @@
 $JARSIGNER -verify -debug -strict $JFILE || exit 3
 
 exit 0
-
--- a/jdk/test/sun/security/x509/URICertStore/SocksProxy.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/sun/security/x509/URICertStore/SocksProxy.java	Wed Jul 05 23:25:53 2017 +0200
@@ -8,7 +8,7 @@
  *
  * 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
+ * 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).
  *
--- a/jdk/test/tools/jar/mmrjar/Basic.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/jar/mmrjar/Basic.java	Wed Jul 05 23:25:53 2017 +0200
@@ -221,7 +221,8 @@
         Assert.assertEquals(actual, expected);
     }
 
-    // jar tool does two updates, no exported packages, all concealed
+    // jar tool does two updates, no exported packages, all concealed.
+    // Along with various --describe-module variants
     @Test
     public void test5() throws IOException {
         // compile the mr10 directory
@@ -266,10 +267,13 @@
 
         jar("-d --file mr.jar");
 
+        String uri = (Paths.get("mr.jar")).toUri().toString();
+        uri = "jar:" + uri + "/!module-info.class";
+
         actual = lines(outbytes);
         expected = Set.of(
-                "module hi (module-info.class)",
-                "requires mandated java.base",
+                "hi " + uri,
+                "requires java.base mandated",
                 "contains p",
                 "contains p.internal"
         );
@@ -304,13 +308,19 @@
 
         actual = lines(outbytes);
         expected = Set.of(
-                "module hi (module-info.class)",
-                "requires mandated java.base",
+                "hi " + uri,
+                "requires java.base mandated",
                 "contains p",
                 "contains p.internal",
                 "contains p.internal.bar"
         );
         Assert.assertEquals(actual, expected);
+
+        for (String release : new String[] {"9" , "10", "100", "1000"}) {
+            jar("-d --file mr.jar --release " + release);
+            actual = lines(outbytes);
+            Assert.assertEquals(actual, expected);
+        }
     }
 
     // root and versioned module-info entries have different main-class, version
@@ -399,15 +409,42 @@
         Assert.assertEquals(rc, 0);
 
         jar("-d --file=mmr.jar");
-        System.out.println("-----------------------");
-        System.out.println( new String(outbytes.toByteArray()));
-        Assert.assertEquals(lines(outbytes),
-                            Set.of(
-                           "module m1 (META-INF/versions/9/module-info.class)",
-                           "module m1 (META-INF/versions/10/module-info.class)",
-                           "requires mandated java.base",
-                           "exports p",
-                           "main-class p.Main"));
+        Set<String> actual = lines(outbytes);
+        Set<String> expected = Set.of(
+                "releases: 9 10",
+                "No root module descriptor, specify --release"
+        );
+        Assert.assertEquals(actual, expected);
+
+        String uriPrefix = "jar:" + (Paths.get("mmr.jar")).toUri().toString();
+
+        jar("-d --file=mmr.jar --release 9");
+        actual = lines(outbytes);
+        expected = Set.of(
+                "releases: 9 10",
+                "m1 " + uriPrefix + "/!META-INF/versions/9/module-info.class",
+                "requires java.base mandated",
+                "exports p",
+                "main-class p.Main"
+        );
+        Assert.assertEquals(actual, expected);
+
+        jar("-d --file=mmr.jar --release 10");
+        actual = lines(outbytes);
+        expected = Set.of(
+                "releases: 9 10",
+                "m1 " + uriPrefix + "/!META-INF/versions/10/module-info.class",
+                "requires java.base mandated",
+                "exports p",
+                "main-class p.Main"
+        );
+        Assert.assertEquals(actual, expected);
+
+        for (String release : new String[] {"11", "12", "15", "100"}) {
+            jar("-d --file mmr.jar --release " + release);
+            actual = lines(outbytes);
+            Assert.assertEquals(actual, expected);
+        }
 
         Optional<String> exp = Optional.of("p.Main");
         try (ZipFile zf = new ZipFile("mmr.jar")) {
--- a/jdk/test/tools/jar/modularJar/Basic.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/jar/modularJar/Basic.java	Wed Jul 05 23:25:53 2017 +0200
@@ -478,13 +478,13 @@
             "--file=" + modularJar.toString())
             .assertSuccess()
             .resultChecker(r -> {
-                // Expect similar output: "bar, requires mandated foo, ...
+                // Expect "bar jar:file:/.../!module-info.class"
                 // conceals jdk.test.foo, conceals jdk.test.foo.internal"
-                Pattern p = Pattern.compile("module bar \\(module-info.class\\)\\s+requires\\s++foo");
-                assertTrue(p.matcher(r.output).find(),
-                           "Expecting to find \"bar, requires foo,...\"",
+                String uri = "jar:" + modularJar.toUri().toString() + "/!module-info.class";
+                assertTrue(r.output.contains("bar " + uri),
+                           "Expecting to find \"bar " + uri + "\"",
                            "in output, but did not: [" + r.output + "]");
-                p = Pattern.compile(
+                Pattern p = Pattern.compile(
                         "contains\\s+jdk.test.foo\\s+contains\\s+jdk.test.foo.internal");
                 assertTrue(p.matcher(r.output).find(),
                            "Expecting to find \"contains jdk.test.foo,...\"",
@@ -758,14 +758,15 @@
         for (String option : new String[]  {"--describe-module", "-d" }) {
 
             jar(option,
-                "--file=" + modularJar.toString())
+                "--file=" + modularJar.toString(),
+                "--release", "9")
                 .assertSuccess()
                 .resultChecker(r ->
                     assertTrue(r.output.contains("main-class jdk.test.baz.Baz"),
                               "Expected to find ", "main-class jdk.test.baz.Baz",
                                " in [", r.output, "]"));
 
-            jarWithStdin(modularJar.toFile(),  option)
+            jarWithStdin(modularJar.toFile(), option, "--release", "9")
                 .assertSuccess()
                 .resultChecker(r ->
                     assertTrue(r.output.contains("main-class jdk.test.baz.Baz"),
@@ -773,7 +774,7 @@
                                " in [", r.output, "]"));
 
         }
-        // run module maain class
+        // run module main class
         java(mp, "baz/jdk.test.baz.Baz")
             .assertSuccess()
             .resultChecker(r ->
@@ -900,7 +901,7 @@
                 .resultChecker(r -> {
                     assertTrue(r.output.contains("No module descriptor found"));
                     assertTrue(r.output.contains("Derived automatic module"));
-                    assertTrue(r.output.contains("module " + mid),
+                    assertTrue(r.output.contains(mid + " automatic"),
                                "Expected [", "module " + mid,"] in [", r.output, "]");
                     }
                 );
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jar/multiRelease/whitebox/Driver.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @modules jdk.jartool/sun.tools.jar
+ * @run testng/othervm jdk.jartool/sun.tools.jar.ValidatorComparatorTest
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jar/multiRelease/whitebox/jdk.jartool/sun/tools/jar/ValidatorComparatorTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @summary White-box test for Validator.ENTRYNAME_COMPARATOR ( currently just
+ *          checks module descriptors ).
+ */
+package sun.tools.jar;
+
+import java.util.List;
+import static java.util.stream.Collectors.toList;
+import static sun.tools.jar.Validator.ENTRYNAME_COMPARATOR;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class ValidatorComparatorTest {
+
+    @Test
+    public void testModuleInfo() throws Throwable {
+        List<String> list =
+                List.of("module-info.class",
+                        "META-INF/versions/9/module-info.class",
+                        "META-INF/versions/10/module-info.class");
+        List<String> sorted = list.stream()
+                .sorted(ENTRYNAME_COMPARATOR)
+                .collect(toList());
+        List<String> expected = list;
+        Assert.assertEquals(sorted, expected);
+
+
+        list =  List.of("META-INF/versions/10/module-info.class",
+                        "META-INF/versions/9/module-info.class",
+                        "module-info.class");
+        sorted = list.stream().sorted(ENTRYNAME_COMPARATOR).collect(toList());
+        expected =
+                List.of("module-info.class",
+                        "META-INF/versions/9/module-info.class",
+                        "META-INF/versions/10/module-info.class");
+        Assert.assertEquals(sorted, expected);
+
+
+        list =  List.of("META-INF/versions/1001/module-info.class",
+                        "META-INF/versions/1000/module-info.class",
+                        "META-INF/versions/999/module-info.class",
+                        "META-INF/versions/101/module-info.class",
+                        "META-INF/versions/100/module-info.class",
+                        "META-INF/versions/99/module-info.class",
+                        "META-INF/versions/31/module-info.class",
+                        "META-INF/versions/30/module-info.class",
+                        "META-INF/versions/29/module-info.class",
+                        "META-INF/versions/21/module-info.class",
+                        "META-INF/versions/20/module-info.class",
+                        "META-INF/versions/13/module-info.class",
+                        "META-INF/versions/12/module-info.class",
+                        "META-INF/versions/11/module-info.class",
+                        "META-INF/versions/10/module-info.class",
+                        "META-INF/versions/9/module-info.class",
+                        "module-info.class");
+        sorted = list.stream().sorted(ENTRYNAME_COMPARATOR).collect(toList());
+        expected =
+                List.of("module-info.class",
+                        "META-INF/versions/9/module-info.class",
+                        "META-INF/versions/10/module-info.class",
+                        "META-INF/versions/11/module-info.class",
+                        "META-INF/versions/12/module-info.class",
+                        "META-INF/versions/13/module-info.class",
+                        "META-INF/versions/20/module-info.class",
+                        "META-INF/versions/21/module-info.class",
+                        "META-INF/versions/29/module-info.class",
+                        "META-INF/versions/30/module-info.class",
+                        "META-INF/versions/31/module-info.class",
+                        "META-INF/versions/99/module-info.class",
+                        "META-INF/versions/100/module-info.class",
+                        "META-INF/versions/101/module-info.class",
+                        "META-INF/versions/999/module-info.class",
+                        "META-INF/versions/1000/module-info.class",
+                        "META-INF/versions/1001/module-info.class");
+        Assert.assertEquals(sorted, expected);
+    }
+}
--- a/jdk/test/tools/jlink/IntegrationTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/jlink/IntegrationTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -207,11 +207,6 @@
         }
 
         checkReleaseProperty(props, "JAVA_VERSION");
-        checkReleaseProperty(props, "JAVA_FULL_VERSION");
-        checkReleaseProperty(props, "OS_NAME");
-        checkReleaseProperty(props, "OS_ARCH");
-        // OS_VERSION is added from makefile. We're testing API-way to create image here!
-        // checkReleaseProperty(props, "OS_VERSION");
 
         if (!Files.exists(output.resolve("toto.txt"))) {
             throw new AssertionError("Post processing not called");
--- a/jdk/test/tools/jlink/JLinkNegativeTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/jlink/JLinkNegativeTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -178,7 +178,7 @@
                     .output(imageFile)
                     .addMods("not_zip")
                     .modulePath(helper.defaultModulePath())
-                    .call().assertFailure("Error: java.util.zip.ZipException: zip file is empty");
+                    .call().assertFailure("Error: Error reading");
         } finally {
             deleteDirectory(jar);
         }
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/SystemModulesTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -113,12 +113,13 @@
         try {
             if (modRef.descriptor().name().equals("java.base")) {
                 ModuleTargetHelper.ModuleTarget mt = ModuleTargetHelper.read(modRef);
-                assertTrue(checkOSName(mt.osName()));
-                assertTrue(checkOSArch(mt.osArch()));
+                String[] values = mt.targetPlatform().split("-");
+                assertTrue(checkOSName(values[0]));
+                assertTrue(checkOSArch(values[1]));
             } else {
                 // target platform attribute is dropped by jlink plugin for other modules
                 ModuleTargetHelper.ModuleTarget mt = ModuleTargetHelper.read(modRef);
-                assertTrue(mt == null || (mt.osName() == null && mt.osArch() == null));
+                assertTrue(mt == null || mt.targetPlatform() == null);
             }
         } catch (IOException exp) {
             throw new UncheckedIOException(exp);
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -220,16 +220,16 @@
             throw new RuntimeException("ModuleTarget is missing for java.base");
         }
 
-        String osName = mt.osName();
-        String osArch = mt.osArch();
+        String[] values = mt.targetPlatform().split("-");
+        String osName = values[0];
+        String osArch = values[1];
 
         // create JMOD files
         Files.createDirectories(JMODS_DIR);
         Stream.of(modules).forEach(mn ->
             assertTrue(jmod("create",
                 "--class-path", MODS_DIR.resolve(mn).toString(),
-                "--os-name", osName,
-                "--os-arch", osArch,
+                "--target-platform", mt.targetPlatform(),
                 "--main-class", mn.replace('m', 'p') + ".Main",
                 JMODS_DIR.resolve(mn + ".jmod").toString()) == 0)
         );
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m1/p1/Main.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m1/p1/Main.java	Wed Jul 05 23:25:53 2017 +0200
@@ -62,8 +62,7 @@
         // parse module-info.class
         ClassReader cr = new ClassReader(in);
         cr.accept(cv, attrs, 0);
-        return modTargets[0] != null &&
-            (modTargets[0].osName() != null || modTargets[0].osArch() != null);
+        return modTargets[0] != null && modTargets[0].targetPlatform() != null;
     }
 
     public static void main(String... args) throws Exception {
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m4/p4/Main.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/src/m4/p4/Main.java	Wed Jul 05 23:25:53 2017 +0200
@@ -63,8 +63,7 @@
         // parse module-info.class
         ClassReader cr = new ClassReader(in);
         cr.accept(cv, attrs, 0);
-        return modTargets[0] != null &&
-            (modTargets[0].osName() != null || modTargets[0].osArch() != null);
+        return modTargets[0] != null && modTargets[0].targetPlatform() != null;
     }
 
     private static boolean hasModuleTarget(String modName) throws IOException {
--- a/jdk/test/tools/jmod/JmodTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/jmod/JmodTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -393,16 +393,17 @@
              MODS_DIR.resolve("describeFoo.jmod").toString())
              .assertSuccess()
              .resultChecker(r -> {
-                 // Expect similar output: "foo,  requires mandated java.base
-                 // exports jdk.test.foo,  contains jdk.test.foo.internal"
-                 Pattern p = Pattern.compile("\\s+foo\\s+requires\\s+mandated\\s+java.base");
+                 // Expect similar output: "foo... exports jdk.test.foo ...
+                 //   ... requires java.base mandated... contains jdk.test.foo.internal"
+                 Pattern p = Pattern.compile("foo\\s+exports\\s+jdk.test.foo");
                  assertTrue(p.matcher(r.output).find(),
-                           "Expecting to find \"foo, requires java.base\"" +
+                           "Expecting to find \"foo... exports jdk.test.foo\"" +
                                 "in output, but did not: [" + r.output + "]");
                  p = Pattern.compile(
-                        "exports\\s+jdk.test.foo\\s+contains\\s+jdk.test.foo.internal");
+                        "requires\\s+java.base\\s+mandated\\s+contains\\s+jdk.test.foo.internal");
                  assertTrue(p.matcher(r.output).find(),
-                           "Expecting to find \"exports ..., contains ...\"" +
+                           "Expecting to find \"requires java.base mandated..., " +
+                                "contains jdk.test.foo.internal ...\"" +
                                 "in output, but did not: [" + r.output + "]");
              });
     }
--- a/jdk/test/tools/launcher/ChangeDataModel.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/launcher/ChangeDataModel.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,104 +23,57 @@
 
 /**
  * @test
- * @bug 4894330 4810347 6277269 8029388
+ * @bug 4894330 4810347 6277269 8029388 8169646
  * @compile -XDignore.symbol.file ChangeDataModel.java
  * @run main ChangeDataModel
- * @summary Verify -d32 and -d64 options are accepted(rejected) on all platforms
+ * @summary Verify -d32, -d64 and -J prefixed data-model options are rejected on all platforms
  * @author Joseph D. Darcy, ksrini
  */
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
+
+import java.util.Arrays;
 
 public class ChangeDataModel extends TestHelper {
-    private static final File TestJar      = new File("test" + JAR_FILE_EXT);
-    private static final String OptionName = "Args";
-    private static final File TestOptionJar  = new File(OptionName + JAR_FILE_EXT);
-    private static final String OPT_PREFIX = "ARCH_OPT:";
 
-    static void createTestJar() throws Exception {
-        String[] code = {
-            "   public static void main(String argv[]) {",
-            "      System.out.println(\"" + OPT_PREFIX + "-d\" + System.getProperty(\"sun.arch.data.model\", \"none\"));",
-            "   }",};
-        createJar(TestJar, code);
-    }
     public static void main(String... args) throws Exception {
-        createTestJar();
-        createOptionsJar();
+        new ChangeDataModel().run(args);
+    }
 
-        // verify if data model flag for default data model is accepted, also
-        // verify if the complimentary data model is rejected.
-        if (is32Bit) {
-            checkAcceptance(javaCmd, "-d32");
-            checkRejection(javaCmd, "-d64");
-            checkOption(javaCmd, "-d64");
-        } else if (is64Bit) {
-            checkAcceptance(javaCmd, "-d64");
-            checkRejection(javaCmd, "-d32");
-            checkOption(javaCmd, "-d32");
-        } else {
-            throw new Error("unsupported data model");
-        }
+    @Test
+    public void check32bitRejection() throws Exception {
+        checkRejection("-d32");
+    }
+
+    @Test
+    public void check64bitRejection() throws Exception {
+        checkRejection("-d64");
     }
 
-    static void checkAcceptance(String cmd, String dmodel) {
-        TestResult tr = doExec(cmd, dmodel, "-jar", TestJar.getAbsolutePath());
-        if (!tr.contains(OPT_PREFIX + dmodel)) {
+    void checkRejection(String dmodel) throws Exception {
+        String expect = "Unrecognized option: " + dmodel;
+        String[] cmds1 = {
+            javaCmd,
+            dmodel,
+            "-version"
+        };
+        checkRejection(expect, cmds1);
+
+        String[] cmds2 = {
+            javacCmd,
+            "-J" + dmodel,
+            "-version"
+        };
+        checkRejection(expect, cmds2);
+    }
+
+
+    void checkRejection(String expect, String... cmds) throws Exception {
+        TestResult tr = doExec(cmds);
+        tr.checkNegative();
+        if (!tr.contains(expect)) {
             System.out.println(tr);
-            String message = "Data model flag " + dmodel +
-                    " not accepted or had improper effect.";
-            throw new RuntimeException(message);
+            String error = "did not get " + "\'" + expect + "\'" +
+                           "with options " + Arrays.asList(cmds);
+            throw new Exception(error);
         }
     }
-
-    static void checkRejection(String cmd, String dmodel) {
-        TestResult tr = doExec(cmd, dmodel, "-jar", TestJar.getAbsolutePath());
-        if (tr.contains(OPT_PREFIX + dmodel)) {
-            System.out.println(tr);
-            String message = "Data model flag " + dmodel + " was accepted.";
-            throw new RuntimeException(message);
-        }
-    }
-
-    static void checkOption(String cmd, String dmodel) throws Exception {
-        TestResult tr = doExec(cmd, "-jar", TestOptionJar.getAbsolutePath(), dmodel);
-        verifyOption(tr, dmodel);
-
-        tr = doExec(cmd, "-cp", ".", OptionName, dmodel);
-        verifyOption(tr, dmodel);
-    }
-
-    static void verifyOption(TestResult tr, String dmodel) {
-        if (!tr.contains(OPT_PREFIX + dmodel)) {
-            System.out.println(tr);
-            String message = "app argument: " + dmodel + " not found.";
-            throw new RuntimeException(message);
-        }
-        if (!tr.isOK()) {
-            System.out.println(tr);
-            String message = "app argument: " + dmodel + " interpreted ?";
-            throw new RuntimeException(message);
-        }
-    }
-
-    static void createOptionsJar() throws Exception {
-        List<String> code = new ArrayList<>();
-        code.add("public class Args {");
-        code.add("   public static void main(String argv[]) {");
-        code.add("       for (String x : argv)");
-        code.add("           System.out.println(\"" + OPT_PREFIX + "\" + x);");
-        code.add("   }");
-        code.add("}");
-        File optionsJava  = new File(OptionName + JAVA_FILE_EXT);
-        createFile(optionsJava, code);
-        File optionsClass = new File(OptionName + CLASS_FILE_EXT);
-
-        compile(optionsJava.getName());
-        createJar("cvfe",
-                  TestOptionJar.getName(),
-                  OptionName,
-                  optionsClass.getName());
-    }
 }
--- a/jdk/test/tools/launcher/Test7029048.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/launcher/Test7029048.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -193,7 +193,7 @@
             if (isSolaris) {
                 /*
                  * Case 3: set the appropriate LLP_XX flag,
-                 * java64 -d64, LLP_64 is relevant, LLP_32 is ignored
+                 * java64 LLP_64 is relevant, LLP_32 is ignored
                  */
                 env.clear();
                 env.put(LD_LIBRARY_PATH_64, dstServerDir.getAbsolutePath());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/describe/DescribeModuleTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @modules java.xml
+ * @library /lib/testlibrary
+ * @build DescribeModuleTest jdk.testlibrary.*
+ * @run testng DescribeModuleTest
+ * @summary Basic test for java --describe-module
+ */
+
+import jdk.testlibrary.ProcessTools;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+@Test
+public class DescribeModuleTest {
+
+    /**
+     * Test that the output describes java.base
+     */
+    private void expectJavaBase(String... args) throws Exception {
+        int exitValue = ProcessTools.executeTestJava(args)
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .stdoutShouldContain("java.base")
+                .stdoutShouldContain("exports java.lang")
+                .stdoutShouldContain("uses java.nio.file.spi.FileSystemProvider")
+                .stdoutShouldContain("contains sun.launcher")
+                .stdoutShouldNotContain("requires ")
+                .getExitValue();
+        assertTrue(exitValue == 0);
+    }
+
+    /**
+     * Test that the output describes java.xml
+     */
+    private void expectJavaXml(String... args) throws Exception {
+        int exitValue = ProcessTools.executeTestJava(args)
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .stdoutShouldContain("java.xml")
+                .stdoutShouldContain("exports javax.xml")
+                .stdoutShouldContain("requires java.base")
+                .stdoutShouldContain("uses javax.xml.stream.XMLInputFactory")
+                .getExitValue();
+        assertTrue(exitValue == 0);
+    }
+
+    /**
+     * Test output/exitValue when describing an unknown module
+     */
+    private void expectUnknownModule(String... args) throws Exception {
+        int exitValue = ProcessTools.executeTestJava(args)
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .stdoutShouldNotContain("requires java.base")
+                .getExitValue();
+        assertTrue(exitValue != 0);
+    }
+
+
+    public void testDescribeJavaBase() throws Exception {
+        expectJavaBase("--describe-module", "java.base");
+        expectJavaBase("--describe-module=java.base");
+        expectJavaBase("-d", "java.base");
+    }
+
+    public void testDescribeJavaXml() throws Exception {
+        expectJavaXml("--describe-module", "java.xml");
+        expectJavaXml("--describe-module=java.xml");
+        expectJavaXml("-d", "java.xml");
+    }
+
+    public void testDescribeUnknownModule() throws Exception {
+        expectUnknownModule("--describe-module", "jdk.rhubarb");
+        expectUnknownModule("--describe-module=jdk.rhubarb");
+        expectUnknownModule("-d", "jdk.rhubarb");
+    }
+
+}
--- a/jdk/test/tools/launcher/modules/listmods/ListModsTest.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/launcher/modules/listmods/ListModsTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
-import static jdk.testlibrary.ProcessTools.*;
+import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.OutputAnalyzer;
 
 import org.testng.annotations.BeforeTest;
@@ -66,138 +66,80 @@
                 SRC_DIR.resolve("java.transaction"),
                 UPGRADEMODS_DIR.resolve("java.transaction"));
         assertTrue(compiled);
-
     }
 
-
     @Test
     public void testListAll() throws Exception {
-        OutputAnalyzer output
-            = executeTestJava("--list-modules")
-                .outputTo(System.out)
-                .errorTo(System.out);
-        output.shouldContain("java.base");
-        output.shouldContain("java.xml");
-        assertTrue(output.getExitValue() == 0);
-    }
-
-
-    @Test
-    public void testListOneModule() throws Exception {
-        OutputAnalyzer output
-            = executeTestJava("--list-modules=java.base")
-                .outputTo(System.out)
-                .errorTo(System.out);
-        output.shouldContain("java.base");
-        output.shouldContain("exports java.lang");
-        assertTrue(output.getExitValue() == 0);
+        exec("--list-modules")
+                .shouldContain("java.base")
+                .shouldContain("java.xml")
+                .shouldHaveExitValue(0);
     }
 
-
-    @Test
-    public void testListTwoModules() throws Exception {
-        OutputAnalyzer output
-            = executeTestJava("--list-modules", "java.base,java.xml")
-                .outputTo(System.out)
-                .errorTo(System.out);
-        output.shouldContain("java.base");
-        output.shouldContain("exports java.lang");
-        output.shouldContain("java.xml");
-        output.shouldContain("exports javax.xml");
-        assertTrue(output.getExitValue() == 0);
-    }
-
-
-    @Test
-    public void testListUnknownModule() throws Exception {
-        OutputAnalyzer output
-            = executeTestJava("--list-modules", "java.rhubarb")
-                .outputTo(System.out)
-                .errorTo(System.out);
-        output.shouldNotContain("java.base");
-        output.shouldContain("java.rhubarb not found");
-        assertTrue(output.getExitValue() == 0);
-    }
-
-
     @Test
     public void testListWithModulePath() throws Exception {
-        OutputAnalyzer output
-            = executeTestJava("--module-path", MODS_DIR.toString(), "--list-modules")
-                .outputTo(System.out)
-                .errorTo(System.out);
-        output.shouldContain("java.base");
-        output.shouldContain("m1");
-        assertTrue(output.getExitValue() == 0);
+        exec("--list-modules", "--module-path", MODS_DIR.toString())
+                .shouldContain("java.base")
+                .shouldContain("m1")
+                .shouldHaveExitValue(0);
     }
 
-
     @Test
     public void testListWithUpgradeModulePath() throws Exception {
-        OutputAnalyzer output
-            = executeTestJava("--upgrade-module-path", UPGRADEMODS_DIR.toString(),
-                              "--list-modules", "java.transaction")
-                .outputTo(System.out)
-                .errorTo(System.out);
-        output.shouldContain("exports javax.transaction.atomic");
-        assertTrue(output.getExitValue() == 0);
+        String dir = UPGRADEMODS_DIR.toString();
+        exec("--list-modules", "--upgrade-module-path", dir)
+                .shouldContain(UPGRADEMODS_DIR.toString())
+                .shouldHaveExitValue(0);
     }
 
-
     @Test
     public void testListWithLimitMods1() throws Exception {
-        OutputAnalyzer output
-            = executeTestJava("--limit-modules", "java.management.rmi", "--list-modules")
-                .outputTo(System.out)
-                .errorTo(System.out);
-        output.shouldContain("java.rmi");
-        output.shouldContain("java.base");
-        output.shouldNotContain("java.scripting");
-        assertTrue(output.getExitValue() == 0);
+        exec("--limit-modules", "java.management.rmi", "--list-modules")
+                .shouldContain("java.rmi")
+                .shouldContain("java.base")
+                .shouldNotContain("java.scripting")
+                .shouldHaveExitValue(0);
     }
 
-
     @Test
     public void testListWithLimitMods2() throws Exception {
-        OutputAnalyzer output
-            = executeTestJava("--module-path", MODS_DIR.toString(),
-                              "--limit-modules", "java.management",
-                              "--list-modules")
-                .outputTo(System.out)
-                .errorTo(System.out);
-        output.shouldContain("java.base");
-        output.shouldNotContain("m1");
-        assertTrue(output.getExitValue() == 0);
+        exec("--list-modules",
+                    "--module-path", MODS_DIR.toString(),
+                    "--limit-modules", "java.management")
+                .shouldContain("java.base")
+                .shouldNotContain("m1")
+                .shouldHaveExitValue(0);
     }
 
-
     /**
      * java -version --list-modules => should print version and exit
      */
     @Test
     public void testListWithPrintVersion1() throws Exception {
-        OutputAnalyzer output
-            = executeTestJava("-version", "--list-modules")
-                .outputTo(System.out)
-                .errorTo(System.out);
-        output.shouldNotContain("java.base");
-        output.shouldContain("Runtime Environment");
-        assertTrue(output.getExitValue() == 0);
+        exec("-version", "--list-modules")
+                .shouldNotContain("java.base")
+                .shouldContain("Runtime Environment")
+                .shouldHaveExitValue(0);
     }
 
-
     /**
      * java --list-modules -version => should list modules and exit
      */
     @Test
     public void testListWithPrintVersion2() throws Exception {
-        OutputAnalyzer output
-            = executeTestJava("--list-modules", "-version")
+        exec("--list-modules", "-version")
+                .shouldContain("java.base")
+                .shouldNotContain("Runtime Environment")
+                .shouldHaveExitValue(0);
+    }
+
+    /**
+     * java args... returning the OutputAnalyzer to analyzer the output
+     */
+    private OutputAnalyzer exec(String... args) throws Exception {
+        return ProcessTools.executeTestJava(args)
                 .outputTo(System.out)
                 .errorTo(System.out);
-        output.shouldContain("java.base");
-        output.shouldNotContain("Runtime Environment");
-        assertTrue(output.getExitValue() == 0);
     }
 
 }
--- a/jdk/test/tools/launcher/modules/listmods/src/java.transaction/javax/transaction/atomic/Atomic.java	Thu May 11 20:23:41 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * 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.transaction.atomic;
-
-public interface Atomic {
-
-}
--- a/jdk/test/tools/launcher/modules/listmods/src/java.transaction/module-info.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/launcher/modules/listmods/src/java.transaction/module-info.java	Wed Jul 05 23:25:53 2017 +0200
@@ -23,5 +23,4 @@
 
 module java.transaction {
     exports javax.transaction;
-    exports javax.transaction.atomic;
 }
--- a/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,8 @@
 
 /*
  * @test
- * @bug 8157068
- * @summary Patch java.base and user module with Hashes attribute tied with
- *          other module.
+ * @bug 8157068 8177844
+ * @summary Patch java.base and user module with ModuleHashes attribute
  * @library /lib/testlibrary
  * @modules jdk.compiler
  * @build CompilerUtils
@@ -59,6 +58,7 @@
     private static final Path JARS_DIR = Paths.get("jars");
     private static final Path PATCH_DIR = Paths.get("patches");
     private static final Path IMAGE = Paths.get("image");
+    private static final Path NEW_M1_JAR = JARS_DIR.resolve("new_m1.jar");
 
     private static final String JAVA_BASE = "java.base";
     private final String[] modules = new String[] { "m1", "m2" };
@@ -80,13 +80,23 @@
         assertTrue(CompilerUtils.compile(PATCH_SRC_DIR.resolve("m2"),
                                          PATCH_DIR.resolve("m2")));
 
+        createJars();
+
         // create an image with only m1 and m2
         if (Files.exists(JMODS)) {
             // create an image with m1,m2
             createImage();
         }
+
+        // create new copy of m1.jar
+        jar("--create",
+            "--file=" + NEW_M1_JAR.toString(),
+            "-C", MODS_DIR.resolve("m1").toString(), ".");
     }
 
+    /*
+     * Test patching system module and user module on module path
+     */
     @Test
     public void test() throws Throwable {
         Path patchedJavaBase = PATCH_DIR.resolve(JAVA_BASE);
@@ -107,6 +117,9 @@
                 "-m", "m1/p1.Main", "2");
     }
 
+    /*
+     * Test --patch-module on a custom image
+     */
     @Test
     public void testImage() throws Throwable {
         if (Files.notExists(JMODS))
@@ -125,27 +138,49 @@
                 "-m", "m1/p1.Main", "2");
     }
 
+    /*
+     * Test a module linked in a system hashed in ModuleHashes attribute
+     * cannot be upgraded
+     */
     @Test
-    public void upgradeTiedModule() throws Throwable {
+    public void upgradeHashedModule() throws Throwable {
         if (Files.notExists(JMODS))
             return;
 
-        Path m1 = MODS_DIR.resolve("m1.jar");
-
-        // create another m1.jar
-        jar("--create",
-            "--file=" + m1.toString(),
-            "-C", MODS_DIR.resolve("m1").toString(), ".");
-
         // Fail to upgrade m1.jar with mismatched hash
         runTestWithExitCode(getJava(IMAGE),
-                "--upgrade-module-path", m1.toString(),
-                "-m", "m1/p1.Main");
+                "--upgrade-module-path", NEW_M1_JAR.toString(),
+                "-m", "m1/p1.Main", "ShouldNeverRun");
 
+        // test when SystemModules fast path is not enabled, i.e. exploded image
         runTestWithExitCode(getJava(IMAGE),
                 "--patch-module", "java.base=" + PATCH_DIR.resolve(JAVA_BASE),
-                "--upgrade-module-path", m1.toString(),
-                "-m", "m1/p1.Main", "1");
+                "--upgrade-module-path", NEW_M1_JAR.toString(),
+                "-m", "m1/p1.Main", "ShouldNeverRun");
+    }
+
+    /*
+     * Test a module linked in a system hashed in ModuleHashes attribute
+     * cannot be upgraded combining with --patch-module and --upgrade-module-path
+     */
+    @Test
+    public void patchHashedModule() throws Throwable {
+        if (Files.notExists(JMODS))
+            return;
+
+        // --patch-module does not disable hash check.
+        // Test that a hashed module cannot be upgraded.
+        runTestWithExitCode(getJava(IMAGE),
+                "--patch-module", "m1=.jar",
+                "--upgrade-module-path", NEW_M1_JAR.toString(),
+                "-m", "m1/p1.Main", "ShouldNeverRun");
+
+        // test when SystemModules fast path is not enabled, i.e. exploded image
+        runTestWithExitCode(getJava(IMAGE),
+                "--patch-module", "java.base=" + PATCH_DIR.resolve(JAVA_BASE),
+                "--patch-module", "m1=.jar",
+                "--upgrade-module-path", NEW_M1_JAR.toString(),
+                "-m", "m1/p1.Main", "ShouldNeverRun");
     }
 
     private void runTestWithExitCode(String... options) throws Throwable {
@@ -171,9 +206,8 @@
         assertTrue(exitValue == 0);
     }
 
-    static void createImage() throws Throwable {
+    static void createJars() throws Throwable {
         FileUtils.deleteFileTreeUnchecked(JARS_DIR);
-        FileUtils.deleteFileTreeUnchecked(IMAGE);
 
         Files.createDirectories(JARS_DIR);
         Path m1 = JARS_DIR.resolve("m1.jar");
@@ -189,7 +223,10 @@
             "--module-path", JARS_DIR.toString(),
             "--hash-modules", "m1",
             "-C", MODS_DIR.resolve("m2").toString(), ".");
+    }
 
+    static void createImage() throws Throwable {
+        FileUtils.deleteFileTreeUnchecked(IMAGE);
 
         String mpath = JARS_DIR.toString() + File.pathSeparator + JMODS.toString();
         execTool("jlink", "--module-path", mpath,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/showmoduleresolution/ShowModuleResolutionTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @modules jdk.jdeps jdk.zipfs
+ * @library /lib/testlibrary
+ * @build ShowModuleResolutionTest jdk.testlibrary.*
+ * @run testng ShowModuleResolutionTest
+ * @summary Basic test for java --show-module-resolution
+ */
+
+import jdk.testlibrary.ProcessTools;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+@Test
+public class ShowModuleResolutionTest {
+
+    /**
+     * Test that the resolution does not bind any services
+     */
+    private void expectJavaBase(String... args) throws Exception {
+        int exitValue = ProcessTools.executeTestJava(args)
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .stdoutShouldContain("root java.base")
+                .stdoutShouldNotContain("java.base binds")
+                .getExitValue();
+        assertTrue(exitValue == 0);
+    }
+
+    /**
+     * Test that the resolution binds services that resolves additional
+     * modules
+     */
+    private void expectProviders(String... args) throws Exception {
+        int exitValue = ProcessTools.executeTestJava(args)
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .stdoutShouldContain("root java.base")
+                .stdoutShouldContain("root java.compiler")
+                .stdoutShouldContain("root jdk.compiler")
+                .stdoutShouldContain("root java.compiler")
+                .stdoutShouldContain("jdk.compiler requires java.compiler")
+                .stdoutShouldContain("java.base binds jdk.compiler")
+                .stdoutShouldContain("java.base binds jdk.jdeps")
+                .stdoutShouldContain("java.base binds jdk.zipfs")
+                .stdoutShouldContain("java.compiler binds jdk.compiler")
+                .stdoutShouldContain("jdk.jdeps requires jdk.compiler")
+                .getExitValue();
+        assertTrue(exitValue == 0);
+    }
+
+    public void test() throws Exception {
+        expectJavaBase("--show-module-resolution",
+                       "--limit-modules", "java.base",
+                       "-version");
+        expectProviders("--show-module-resolution",
+                        "--limit-modules", "java.base,jdk.jdeps,jdk.zipfs",
+                        "-version");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/launcher/modules/validate/ValidateModulesTest.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @modules java.xml
+ * @library /lib/testlibrary
+ * @build ValidateModulesTest JarUtils jdk.testlibrary.*
+ * @run testng ValidateModulesTest
+ * @summary Basic test for java --validate-modules
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import jdk.testlibrary.ProcessTools;
+import jdk.testlibrary.OutputAnalyzer;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+@Test
+public class ValidateModulesTest {
+
+    /**
+     * Test that the system modules validate.
+     */
+    public void testSystemModules() throws Exception {
+        run("--validate-modules")
+                .stdoutShouldContain("java.base")
+                .stdoutShouldContain("java.xml")
+                .shouldHaveExitValue(0);
+    }
+
+    /**
+     * Test an automatic module on the module path with classes in the same
+     * package as a system module.
+     */
+    public void testPackageConflict() throws Exception {
+        Path tmpdir = Files.createTempDirectory("tmp");
+
+        Path classes = Files.createDirectory(tmpdir.resolve("classes"));
+        touch(classes, "javax/xml/XMLConstants.class");
+        touch(classes, "javax/xml/parsers/SAXParser.class");
+
+        Path lib = Files.createDirectory(tmpdir.resolve("lib"));
+        JarUtils.createJarFile(lib.resolve("xml.jar"), classes);
+
+        int exitValue = run("-p", lib.toString(), "--validate-modules")
+                .shouldContain("xml automatic")
+                .shouldContain("conflicts with module java.xml")
+                .getExitValue();
+        assertTrue(exitValue != 0);
+
+    }
+
+    /**
+     * Test two modules with the same name in a directory.
+     */
+    public void testDuplicateModule() throws Exception {
+        Path tmpdir = Files.createTempDirectory("tmp");
+
+        Path classes = Files.createDirectory(tmpdir.resolve("classes"));
+        touch(classes, "org/foo/Bar.class");
+
+        Path lib = Files.createDirectory(tmpdir.resolve("lib"));
+        JarUtils.createJarFile(lib.resolve("foo-1.0.jar"), classes);
+        JarUtils.createJarFile(lib.resolve("foo-2.0.jar"), classes);
+
+        int exitValue = run("-p", lib.toString(), "--validate-modules")
+                .shouldContain("contains same module")
+                .getExitValue();
+        assertTrue(exitValue != 0);
+    }
+
+    /**
+     * Test two modules with the same name in different directories.
+     */
+    public void testShadowed() throws Exception {
+        Path tmpdir = Files.createTempDirectory("tmp");
+
+        Path classes = Files.createDirectory(tmpdir.resolve("classes"));
+        touch(classes, "org/foo/Bar.class");
+
+        Path lib1 = Files.createDirectory(tmpdir.resolve("lib1"));
+        JarUtils.createJarFile(lib1.resolve("foo-1.0.jar"), classes);
+
+        Path lib2 = Files.createDirectory(tmpdir.resolve("lib2"));
+        JarUtils.createJarFile(lib2.resolve("foo-2.0.jar"), classes);
+
+        run("-p", lib1 + File.pathSeparator + lib2, "--validate-modules")
+                .shouldContain("shadowed by")
+                .shouldHaveExitValue(0);
+    }
+
+    /**
+     * Runs the java launcher with the given arguments.
+     */
+    private OutputAnalyzer run(String... args) throws Exception {
+        return ProcessTools.executeTestJava(args)
+                .outputTo(System.out)
+                .errorTo(System.out);
+    }
+
+    /**
+     * Creates a file relative the given directory.
+     */
+    private void touch(Path dir, String relPath) throws IOException {
+        Path file = dir.resolve(relPath.replace('/', File.separatorChar));
+        Files.createDirectories(file.getParent());
+        Files.createFile(file);
+    }
+}
--- a/jdk/test/tools/pack200/MultiRelease.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/pack200/MultiRelease.java	Wed Jul 05 23:25:53 2017 +0200
@@ -12,7 +12,7 @@
  * version 2 for more details (a copy is included in the LICENSE file that
  * accompanied this code).
  *
- r You should have received a copy of the GNU General Public License version
+ * 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.
  *
--- a/jdk/test/tools/pack200/pack200-verifier/src/xmlkit/ClassReader.java	Thu May 11 20:23:41 2017 +0000
+++ b/jdk/test/tools/pack200/pack200-verifier/src/xmlkit/ClassReader.java	Wed Jul 05 23:25:53 2017 +0200
@@ -1542,8 +1542,7 @@
     @Override
     public Element visitModuleTarget(ModuleTarget_attribute attr, Element p) {
         Element e = new Element(x.getCpString(attr.attribute_name_index));
-        e.add(x.getCpString(attr.os_name_index));
-        e.add(x.getCpString(attr.os_arch_index));
+        e.add(x.getCpString(attr.target_platform_index));
         e.trimToSize();
         p.add(e);
         return null;
--- a/make/CreateJmods.gmk	Thu May 11 20:23:41 2017 +0000
+++ b/make/CreateJmods.gmk	Wed Jul 05 23:25:53 2017 +0200
@@ -135,8 +135,7 @@
 	$(RM) $@ $(JMODS_TEMPDIR)/$(notdir $@)
 	$(JMOD) create \
             --module-version $(VERSION_SHORT) \
-            --os-name '$(OPENJDK_MODULE_TARGET_OS_NAME)' \
-            --os-arch '$(OPENJDK_MODULE_TARGET_OS_ARCH)' \
+            --target-platform '$(OPENJDK_MODULE_TARGET_PLATFORM)' \
             --module-path $(JMODS_DIR) \
 	    --exclude '**{_the.*,_*.marker,*.diz,*.debuginfo,*.dSYM/**,*.dSYM,*.pdb,*.map}' \
 	    $(JMOD_FLAGS) $(JMODS_TEMPDIR)/$(notdir $@)
--- a/make/Javadoc.gmk	Thu May 11 20:23:41 2017 +0000
+++ b/make/Javadoc.gmk	Wed Jul 05 23:25:53 2017 +0200
@@ -27,6 +27,7 @@
 include $(SPEC)
 include MakeBase.gmk
 include Modules.gmk
+include ProcessMarkdown.gmk
 include ZipArchive.gmk
 include $(JDK_TOPDIR)/make/Tools.gmk
 include $(JDK_TOPDIR)/make/ModuleTools.gmk
@@ -51,9 +52,12 @@
 DOCROOTPARENT_FLAG ?= TRUE
 
 # URLs
-JAVADOC_BASE_URL := http://docs.oracle.com/javase/$(VERSION_SPECIFICATION)/docs
+JAVADOC_BASE_URL := http://www.oracle.com/pls/topic/lookup?ctx=javase9&id=homepage
 BUG_SUBMIT_URL := http://bugreport.java.com/bugreport/
 COPYRIGHT_URL := {@docroot}/../legal/cpyr.html
+LICENSE_URL := http://www.oracle.com/technetwork/java/javase/terms/license/java9speclicense.html
+REDISTRIBUTION_URL := http://www.oracle.com/technetwork/java/redist-137594.html
+
 
 # In order to get a specific ordering it's necessary to specify the total
 # ordering of tags as the tags are otherwise ordered in order of definition.
@@ -134,7 +138,10 @@
     the US and other countries.<br> \
     <a href="$(COPYRIGHT_URL)">Copyright</a> \
     &copy; 1993, $(COPYRIGHT_YEAR), $(FULL_COMPANY_NAME). \
-    $(COMPANY_ADDRESS). All rights reserved.$(DRAFT_MARKER_STR)</span>
+    $(COMPANY_ADDRESS). All rights reserved. \
+    Use is subject to <a href="$(LICENSE_URL)">license terms</a>. Also see the \
+    <a href="$(REDISTRIBUTION_URL)">documentation redistribution policy</a>. \
+    $(DRAFT_MARKER_STR)</span>
 
 JAVADOC_TOP := \
     <div style="background-color: $(HASH)EEEEEE"><div style="padding: 6px; \
@@ -356,7 +363,7 @@
 # unmodified
 
 ALL_MODULES := $(call FindAllModules)
-COPY_SPEC_FILTER := %.html %.gif %.jpg %.mib
+COPY_SPEC_FILTER := %.html %.gif %.jpg %.mib %.css
 
 $(foreach m, $(ALL_MODULES), \
   $(eval SPECS_$m := $(call FindModuleSpecsDirs, $m)) \
@@ -370,36 +377,35 @@
   ) \
 )
 
+# Copy the global resources
+GLOBAL_SPECS_RESOURCES_DIR := $(JDK_TOPDIR)/make/data/docs-resources/specs
+$(eval $(call SetupCopyFiles, COPY_GLOBAL_RESOURCES, \
+    SRC := $(GLOBAL_SPECS_RESOURCES_DIR), \
+    FILES := $(call CacheFind, $(GLOBAL_SPECS_RESOURCES_DIR)), \
+    DEST := $(JAVADOC_OUTPUTDIR)/specs/, \
+))
+JDK_SPECS_TARGETS += $(COPY_GLOBAL_RESOURCES)
+
 ifeq ($(ENABLE_FULL_DOCS), true)
   # For all markdown files in $module/share/specs directories, convert them to
   # html.
-  MARKDOWN_SPEC_FILTER := %.md
 
-  # Macro for SetupCopyFiles that converts from markdown to html using pandoc.
-  define markdown-to-html
-	$(call MakeDir, $(@D))
-	$(RM) $@
-	$(PANDOC) -t html -s -o $@ $<
-  endef
-
-  rename-md-to-html = \
-      $(patsubst %.md,%.html,$1)
+  GLOBAL_SPECS_DEFAULT_CSS_FILE := $(JAVADOC_OUTPUTDIR)/specs/resources/jdk-default.css
 
   $(foreach m, $(ALL_MODULES), \
     $(eval SPECS_$m := $(call FindModuleSpecsDirs, $m)) \
-    $(if $(SPECS_$m), \
-      $(eval $(call SetupCopyFiles, CONVERT_MARKDOWN_$m, \
-          SRC := $(SPECS_$m), \
-          FILES := $(filter $(MARKDOWN_SPEC_FILTER), $(call CacheFind, $(SPECS_$m))), \
-          DEST := $(JAVADOC_OUTPUTDIR)/specs/, \
-          MACRO := markdown-to-html, \
-          NAME_MACRO := rename-md-to-html, \
-          LOG_ACTION := Converting from markdown, \
-      )) \
-      $(eval JDK_SPECS_TARGETS += $(CONVERT_MARKDOWN_$m)) \
+    $(foreach d, $(SPECS_$m), \
+      $(if $(filter %.md, $(call CacheFind, $d)), \
+        $(eval $(call SetupProcessMarkdown, CONVERT_MARKDOWN_$m_$(patsubst $(TOPDIR)/%,%,$d), \
+            SRC := $d, \
+            FILES := $(filter %.md, $(call CacheFind, $d)), \
+            DEST := $(JAVADOC_OUTPUTDIR)/specs/, \
+            CSS := $(GLOBAL_SPECS_DEFAULT_CSS_FILE), \
+        )) \
+      ) \
+      $(eval JDK_SPECS_TARGETS += $(CONVERT_MARKDOWN_$m_$(patsubst $(TOPDIR)/%,%,$d))) \
     ) \
   )
-
 endif
 
 # Special treatment for generated documentation
--- a/make/ReleaseFile.gmk	Thu May 11 20:23:41 2017 +0000
+++ b/make/ReleaseFile.gmk	Wed Jul 05 23:25:53 2017 +0200
@@ -48,6 +48,8 @@
     $(call info-file-item, "SUN_ARCH_ABI", "$(JDK_ARCH_ABI_PROP_NAME)"))
   $(call info-file-item, "SOURCE", "$(strip $(SOURCE_REVISION))")
   $(call info-file-item, "IMPLEMENTOR", "$(COMPANY_NAME)")
+  $(call info-file-item, "OS_NAME", "$(RELEASE_FILE_OS_NAME)")
+  $(call info-file-item, "OS_ARCH", "$(RELEASE_FILE_OS_ARCH)")
 endef
 
 # Param 1 - The file containing the MODULES list
--- a/make/UpdateBuildDocs.gmk	Thu May 11 20:23:41 2017 +0000
+++ b/make/UpdateBuildDocs.gmk	Wed Jul 05 23:25:53 2017 +0200
@@ -27,6 +27,7 @@
 
 include $(SPEC)
 include MakeBase.gmk
+include ProcessMarkdown.gmk
 
 ################################################################################
 # This makefile updates the generated build html documentation.
@@ -38,62 +39,26 @@
   $(error Cannot continue)
 endif
 
-################################################################################
-# Setup make rules for converting a markdown file to html.
-#
-# Parameter 1 is the name of the rule. This name is used as variable prefix,
-# and the targets generated are listed in a variable by that name.
-#
-# Remaining parameters are named arguments. These include:
-#   SOURCE_FILE  The markdown source file
-#   TARGET_DIR   The directory where to store the generated html file
-#   OPTIONS      Additional options to pandoc
-#
-SetupMarkdownToHtml = $(NamedParamsMacroTemplate)
-define SetupMarkdownToHtmlBody
-  ifeq ($$($1_SOURCE_FILE), )
-    $$(error SOURCE_FILE is missing in SetupMarkdownToHtml $1)
-  endif
-
-  ifeq ($$($1_TARGET_DIR), )
-    $$(error TARGET_DIR is missing in SetupMarkdownToHtml $1)
-  endif
-
-  $1_BASENAME := $$(notdir $$(basename $$($1_SOURCE_FILE)))
-  $1_OUTPUT_FILE := $$($1_TARGET_DIR)/$$($1_BASENAME).html
-
-$$($1_OUTPUT_FILE): $$($1_SOURCE_FILE)
-	$$(call LogInfo, Converting $$(notdir $1) to html)
-	$$(call MakeDir, $$($1_TARGET_DIR) $$(MAKESUPPORT_OUTPUTDIR)/markdown)
-	$$(call ExecuteWithLog, $$(MAKESUPPORT_OUTPUTDIR)/markdown/$1, \
-	    $$(PANDOC) $$($1_OPTIONS) -f markdown -t html --standalone \
-	    --css 'http://openjdk.java.net/page.css' '$$<' -o '$$@')
-	TOO_LONG_LINES=`$$(GREP) -E -e '^.{80}.+$$$$' $$<` || true ; \
-	if [ "x$$$$TOO_LONG_LINES" != x ]; then \
-	  $$(ECHO) "Warning: Unsuitable markdown in $$<:" ; \
-	  $$(ECHO) "The following lines are longer than 80 characters:" ; \
-	  $$(GREP) -E -n -e '^.{80}.+$$$$' $$< || true ; \
-	fi
-
-  $1 := $$($1_OUTPUT_FILE)
-
-  TARGETS += $$($1)
-endef
+GLOBAL_SPECS_DEFAULT_CSS_FILE := $(JDK_TOPDIR)/make/data/docs-resources/specs/resources/jdk-default.css
 
 ################################################################################
 
 DOCS_DIR := $(TOPDIR)/common/doc
 
-$(eval $(call SetupMarkdownToHtml, building, \
-  SOURCE_FILE := $(DOCS_DIR)/building.md, \
-  TARGET_DIR := $(DOCS_DIR), \
+$(eval $(call SetupProcessMarkdown, building, \
+  FILES := $(DOCS_DIR)/building.md, \
+  DEST := $(DOCS_DIR), \
+  CSS := $(GLOBAL_SPECS_DEFAULT_CSS_FILE), \
 ))
+TARGETS += $(building)
 
-$(eval $(call SetupMarkdownToHtml, testing, \
-  SOURCE_FILE := $(DOCS_DIR)/testing.md, \
-  TARGET_DIR := $(DOCS_DIR), \
+$(eval $(call SetupProcessMarkdown, testing, \
+  FILES := $(DOCS_DIR)/testing.md, \
+  DEST := $(DOCS_DIR), \
+  CSS := $(GLOBAL_SPECS_DEFAULT_CSS_FILE), \
   OPTIONS := --toc, \
 ))
+TARGETS += $(testing)
 
 ################################################################################
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/make/common/ProcessMarkdown.gmk	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,103 @@
+# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+ifeq (,$(_MAKEBASE_GMK))
+  $(error You must include MakeBase.gmk prior to including ProcessMarkdown.gmk)
+endif
+
+# Helper function for SetupProcessMarkdown
+# $1: The $1 from SetupProcessMarkdown
+# $2: The name of the current source file, relative to $1_SRC
+define ProcessMarkdown
+  $1_$2_OUTPUT_FILE := $$($1_DEST)/$$(basename $2).html
+  $1_$2_TARGET_DIR := $$(dir $$($1_$2_OUTPUT_FILE))
+  ifneq ($$($1_CSS), )
+    ifneq ($$(findstring http:/, $$($1_CSS)), )
+      $1_$2_CSS_OPTION := --css '$$($1_CSS)'
+    else
+      $1_$2_CSS := $$(call RelativePath, $$($1_CSS), $$($1_$2_TARGET_DIR))
+      $1_$2_CSS_OPTION := --css '$$($1_$2_CSS)'
+    endif
+  endif
+  $1_$2_OPTIONS = $$(shell $$(GREP) _pandoc-options_: $$($1_SRC)/$2 | $$(CUT) -d : -f 2-)
+  $1_$2_MARKER := $$(subst /,_,$1_$2)
+
+  $1_$2_VARDEPS := $$($1_OPTIONS) $$($1_CSS)
+  $1_$2_VARDEPS_FILE := $$(call DependOnVariable, $1_$2_VARDEPS, \
+      $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER).vardeps)
+
+$$($1_$2_OUTPUT_FILE): $$($1_SRC)/$2 $$($1_$2_VARDEPS_FILE)
+	$$(call LogInfo, Converting $2 to html)
+	$$(call MakeDir, $$($1_$2_TARGET_DIR) $$(SUPPORT_OUTPUTDIR)/markdown)
+	$$(call ExecuteWithLog, $$(SUPPORT_OUTPUTDIR)/markdown/$$($1_$2_MARKER), \
+	    $$(PANDOC) $$($1_OPTIONS) -f markdown -t html --standalone \
+	    $$($1_$2_CSS_OPTION) $$($1_$2_OPTIONS) '$$<' -o '$$@')
+        ifneq ($$(findstring $$(LOG_LEVEL), debug trace),)
+	TOO_LONG_LINES=`$$(GREP) -E -e '^.{80}.+$$$$' $$<` || true ; \
+	if [ "x$$$$TOO_LONG_LINES" != x ]; then \
+	  $$(ECHO) "Warning: Unsuitable markdown in $$<:" ; \
+	  $$(ECHO) "The following lines are longer than 80 characters:" ; \
+	  $$(GREP) -E -n -e '^.{80}.+$$$$' $$< || true ; \
+	fi
+        endif
+
+  $1 += $$($1_$2_OUTPUT_FILE)
+endef
+
+################################################################################
+# Setup make rules for converting a markdown file to html.
+#
+# Parameter 1 is the name of the rule. This name is used as variable prefix,
+# and the targets generated are listed in a variable by that name.
+#
+# Remaining parameters are named arguments. These include:
+#   SRC     : Source root dir (defaults to dir of first file)
+#   DEST    : Dest root dir
+#   FILES   : List of files to copy with absolute paths, or path relative to SRC.
+#             Must be in SRC.
+#   OPTIONS : Additional options to pandoc
+#
+SetupProcessMarkdown = $(NamedParamsMacroTemplate)
+define SetupProcessMarkdownBody
+  ifeq ($$($1_FILES), )
+    $$(error FILES is missing in SetupProcessMarkdown $1)
+  endif
+
+  ifeq ($$($1_DEST), )
+    $$(error DEST is missing in SetupProcessMarkdown $1)
+  endif
+
+  # Default SRC to the dir of the first file.
+  ifeq ($$($1_SRC), )
+    $1_SRC := $$(dir $$(firstword $$($1_FILES)))
+  endif
+
+  # Remove any trailing slash from SRC and DEST
+  $1_SRC := $$(patsubst %/,%,$$($1_SRC))
+  $1_DEST := $$(patsubst %/,%,$$($1_DEST))
+
+  $$(foreach f, $$(patsubst $$($1_SRC)/%,%,$$($1_FILES)), \
+    $$(eval $$(call ProcessMarkdown,$1,$$f)) \
+  )
+endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/compiler/CompilerUtils.java	Wed Jul 05 23:25:53 2017 +0200
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.lib.compiler;
+
+import javax.tools.JavaCompiler;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * This class consists exclusively of static utility methods for invoking the
+ * java compiler.
+ */
+
+public final class CompilerUtils {
+    private CompilerUtils() { }
+
+    /**
+     * Compile all the java sources in {@code <source>/**} to
+     * {@code <destination>/**}. The destination directory will be created if
+     * it doesn't exist.
+     *
+     * All warnings/errors emitted by the compiler are output to System.out/err.
+     *
+     * @return true if the compilation is successful
+     *
+     * @throws IOException if there is an I/O error scanning the source tree or
+     *                     creating the destination directory
+     */
+    public static boolean compile(Path source, Path destination, String ... options)
+        throws IOException
+    {
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
+
+        List<Path> sources
+            = Files.find(source, Integer.MAX_VALUE,
+                (file, attrs) -> (file.toString().endsWith(".java")))
+                .collect(Collectors.toList());
+
+        Files.createDirectories(destination);
+        jfm.setLocation(StandardLocation.CLASS_PATH, Collections.emptyList());
+        jfm.setLocationFromPaths(StandardLocation.CLASS_OUTPUT,
+                Collections.singletonList(destination));
+
+        List<String> opts = Arrays.asList(options);
+        JavaCompiler.CompilationTask task
+            = compiler.getTask(null, jfm, null, opts, null,
+                jfm.getJavaFileObjectsFromPaths(sources));
+
+        return task.call();
+    }
+}
--- a/test/lib/jdk/test/lib/process/OutputAnalyzer.java	Thu May 11 20:23:41 2017 +0000
+++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.java	Wed Jul 05 23:25:53 2017 +0200
@@ -24,6 +24,7 @@
 package jdk.test.lib.process;
 
 import java.io.IOException;
+import java.io.PrintStream;
 import java.util.Arrays;
 import java.util.List;
 import java.util.regex.Matcher;
@@ -415,6 +416,25 @@
       System.err.println(msg);
   }
 
+  /**
+   * Print the stdout buffer to the given {@code PrintStream}.
+   *
+   * @return this OutputAnalyzer
+   */
+  public OutputAnalyzer outputTo(PrintStream out) {
+      out.println(getStdout());
+      return this;
+  }
+
+  /**
+   * Print the stderr buffer to the given {@code PrintStream}.
+   *
+   * @return this OutputAnalyzer
+   */
+  public OutputAnalyzer errorTo(PrintStream out) {
+      out.println(getStderr());
+      return this;
+  }
 
   /**
    * Get the contents of the output buffer (stdout and stderr)
--- a/test/lib/jdk/test/lib/process/ProcessTools.java	Thu May 11 20:23:41 2017 +0000
+++ b/test/lib/jdk/test/lib/process/ProcessTools.java	Wed Jul 05 23:25:53 2017 +0200
@@ -365,7 +365,7 @@
      *
      * The jvm process will have exited before this method returns.
      *
-     * @param cmds User specifed arguments.
+     * @param cmds User specified arguments.
      * @return The output from the process.
      */
     public static OutputAnalyzer executeTestJvm(String... cmds) throws Exception {
@@ -374,6 +374,15 @@
     }
 
     /**
+     * @see #executeTestJvm(String...)
+     * @param cmds User specified arguments.
+     * @return The output from the process.
+     */
+    public static OutputAnalyzer executeTestJava(String... cmds) throws Exception {
+        return executeTestJvm(cmds);
+    }
+
+    /**
      * Executes a process, waits for it to finish and returns the process output.
      * The process will have exited before this method returns.
      * @param pb The ProcessBuilder to execute.