Merge
diff --git a/.hgtags b/.hgtags
index cc30bed..c2e4892 100644
--- a/.hgtags
+++ b/.hgtags
@@ -1,3 +1,17 @@
+898cbe31fbdae2d25d141384fac746cc244a730c jdk-9+170
+c7efde2b60fc1ec04630be769d9ad60efb39c39c jdk-9+169
+8fd0a4569191f33c98ee90c2709174a342fefb0d jdk-9+167
+fcabc74bd44e56c7419d111d59b95669ecb33c55 jdk-9+168
+d3e973f1809606c67412361041ad197e50fe8cec jdk-9+166
+3965b747cfe1e6cbd66b8739da5a1ea6ec6985e9 jdk-9+165
+d16aebbb56d37f12e0c0b0a4fb427db65e1fb1a8 jdk-9+162
+18c41483a082e097ac2f5f983c1226ed94aa4215 jdk-9+163
+32db52c675e7d5bc413605d2e89b68b608b19be0 jdk-9+164
+fd1497902bbe3aa24b21f270ecdcb8de5f7aa9ac jdk-9+159
+6aa8be0c4e054fe8b3ab016ae00d16d680f92145 jdk-9+160
+f6883b1a5a6478437cd4181c4bd45328ab24feaf jdk-9+161
+fa3e76b477829afc4476f0b725cfaa440a6fd917 jdk-9+157
+b5015f742ba648184bb7fc547197bd33ebfde30d jdk-9+158
 1cc8dd79fd1cd13d36b385196271a29632c67c3b jdk7-b24
 bf2517e15f0c0f950e5b3143c4ca11e2df73dcc1 jdk7-b25
 5ae7db536e3fcf6be78e45b240a9058095e0ed38 jdk7-b26
@@ -400,17 +414,11 @@
 45b751afd11e6c05991cf4913c5a0ac3304fcc4e jdk-9+154
 f4aff695ffe05cfdb69d8af25a4ddc6a029754ea jdk-9+155
 06bce0388880b5ff8e040e4a9d72a3ea11dac321 jdk-9+156
-fa3e76b477829afc4476f0b725cfaa440a6fd917 jdk-9+157
-b5015f742ba648184bb7fc547197bd33ebfde30d jdk-9+158
-fd1497902bbe3aa24b21f270ecdcb8de5f7aa9ac jdk-9+159
-6aa8be0c4e054fe8b3ab016ae00d16d680f92145 jdk-9+160
-f6883b1a5a6478437cd4181c4bd45328ab24feaf jdk-9+161
-d16aebbb56d37f12e0c0b0a4fb427db65e1fb1a8 jdk-9+162
-18c41483a082e097ac2f5f983c1226ed94aa4215 jdk-9+163
-32db52c675e7d5bc413605d2e89b68b608b19be0 jdk-9+164
-3965b747cfe1e6cbd66b8739da5a1ea6ec6985e9 jdk-9+165
-d3e973f1809606c67412361041ad197e50fe8cec jdk-9+166
-8fd0a4569191f33c98ee90c2709174a342fefb0d jdk-9+167
-fcabc74bd44e56c7419d111d59b95669ecb33c55 jdk-9+168
-c7efde2b60fc1ec04630be769d9ad60efb39c39c jdk-9+169
-898cbe31fbdae2d25d141384fac746cc244a730c jdk-9+170
+74116beae88a8f17a80301aa6c83865c82f10ece jdk-10+1
+4a79ad46e578112fce68f1af9dd931025cc235cb jdk-10+2
+d1cab6c7e608479be4ebfad48a25b0ed48600f62 jdk-10+3
+02253db2ace1422f576f58502fc7831ead77424b jdk-10+4
+f113ce12fe24fbd24acf02711372d9f1e1c12426 jdk-10+5
+1407b19a2ddf6baae162f5a1a5b96af473f4d7d1 jdk-10+6
+30e75693ae99fd8e47fd2f5116527aff1b59aff9 jdk-10+7
+c42dc7b58b4d4301ea676a76326fd9bbd403d595 jdk-10+8
diff --git a/.hgtags-top-repo b/.hgtags-top-repo
index 88b31a1..bf64ef1 100644
--- a/.hgtags-top-repo
+++ b/.hgtags-top-repo
@@ -396,9 +396,11 @@
 71a766d4c18041a7f833ee22823125b02e1a7f1e jdk-9+151
 ef056360ddf3977d7d2ddbeb456a4d612d19ea05 jdk-9+152
 816a6d03a7c44edfbd8780110529f1bdc3964fb9 jdk-9+153
+8d22611ffb6540bc1ace64a00c048c8b82d8c69a jdk-10+0
 8d26916eaa21b689835ffc1c0dbf12470aa9be61 jdk-9+154
 688a3863c00ebc089ab17ee1fc46272cbbd96815 jdk-9+155
 783ec7542cf7154e5d2b87f55bb97d28f81e9ada jdk-9+156
+4df5f619c9ead4604d2f97ed231b3a35ec688c41 jdk-10+1
 4eb77fb98952dc477a4229575c81d2263a9ce711 jdk-9+157
 a4087bc10a88a43ea3ad0919b5b4af1c86977221 jdk-9+158
 fe8466adaef8178dba94be53c789a0aaa87d13bb jdk-9+159
@@ -411,4 +413,13 @@
 ba5b16c9c6d80632b61959a33d424b1c3398ce62 jdk-9+166
 35017c286513ddcbcc6b63b99679c604993fc639 jdk-9+167
 143d4c87bc1ef1ed6dadd613cd9dd4488fdefc29 jdk-9+168
+9c7248b787c39b034d4f48d4aa48df903836cca7 jdk-10+2
+06373236a30801f72e2a31ee5c691c2a1e500f57 jdk-10+3
+8ec175c61fc3f58328a3324f07d7ded00e060be3 jdk-10+4
+111e2e7d00f45c983cdbc9c59ae40552152fcc23 jdk-10+5
+03fe61bb7670644cf6e46b5cfafb6b27c0e0157e jdk-10+6
 b25838a28195f4b6dab34668411eedd2d366a16c jdk-9+169
+4d163ec59d989a9261ed7f848bc6303f90869af5 jdk-9+170
+
+aa3c97810d7c484c93a2fd75d3c76ff574deb6d8 jdk-10+7
+df33ef1dc163f994177fd97d4d0e73a1e3cb5d85 jdk-10+8
diff --git a/.jcheck/conf b/.jcheck/conf
index 5c6f62d..b258135 100644
--- a/.jcheck/conf
+++ b/.jcheck/conf
@@ -1 +1 @@
-project=jdk9
+project=jdk10
diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4
index 187ad8a..0bce558 100644
--- a/common/autoconf/basics.m4
+++ b/common/autoconf/basics.m4
@@ -1099,6 +1099,7 @@
   BASIC_PATH_PROGS(HG, hg)
   BASIC_PATH_PROGS(STAT, stat)
   BASIC_PATH_PROGS(TIME, time)
+  BASIC_PATH_PROGS(FLOCK, flock)
   # Dtrace is usually found in /usr/sbin on Solaris, but that directory may not
   # be in the user path.
   BASIC_PATH_PROGS(DTRACE, dtrace, $PATH:/usr/sbin)
diff --git a/common/autoconf/boot-jdk.m4 b/common/autoconf/boot-jdk.m4
index b7ae105..e286603 100644
--- a/common/autoconf/boot-jdk.m4
+++ b/common/autoconf/boot-jdk.m4
@@ -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"
diff --git a/common/autoconf/build-performance.m4 b/common/autoconf/build-performance.m4
index 13578cf..7279914 100644
--- a/common/autoconf/build-performance.m4
+++ b/common/autoconf/build-performance.m4
@@ -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
 
diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh
index cf23d7e..8a8760f 100644
--- a/common/autoconf/generated-configure.sh
+++ b/common/autoconf/generated-configure.sh
@@ -933,6 +933,7 @@
 IS_GNU_TIME
 PATCH
 DTRACE
+FLOCK
 TIME
 STAT
 HG
@@ -1297,6 +1298,7 @@
 HG
 STAT
 TIME
+FLOCK
 DTRACE
 PATCH
 DSYMUTIL
@@ -2264,6 +2266,7 @@
   HG          Override default value for HG
   STAT        Override default value for STAT
   TIME        Override default value for TIME
+  FLOCK       Override default value for FLOCK
   DTRACE      Override default value for DTRACE
   PATCH       Override default value for PATCH
   DSYMUTIL    Override default value for DSYMUTIL
@@ -23271,6 +23274,203 @@
   fi
 
 
+
+
+  # Publish this variable in the help.
+
+
+  if [ -z "${FLOCK+x}" ]; then
+    # The variable is not set by user, try to locate tool using the code snippet
+    for ac_prog in flock
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_FLOCK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $FLOCK in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FLOCK="$FLOCK" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_FLOCK="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+FLOCK=$ac_cv_path_FLOCK
+if test -n "$FLOCK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLOCK" >&5
+$as_echo "$FLOCK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$FLOCK" && break
+done
+
+  else
+    # The variable is set, but is it from the command line or the environment?
+
+    # Try to remove the string !FLOCK! from our list.
+    try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!FLOCK!/}
+    if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
+      # If it failed, the variable was not from the command line. Ignore it,
+      # but warn the user (except for BASH, which is always set by the calling BASH).
+      if test "xFLOCK" != xBASH; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of FLOCK from the environment. Use command line variables instead." >&5
+$as_echo "$as_me: WARNING: Ignoring value of FLOCK from the environment. Use command line variables instead." >&2;}
+      fi
+      # Try to locate tool using the code snippet
+      for ac_prog in flock
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_FLOCK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $FLOCK in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FLOCK="$FLOCK" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_FLOCK="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+FLOCK=$ac_cv_path_FLOCK
+if test -n "$FLOCK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLOCK" >&5
+$as_echo "$FLOCK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$FLOCK" && break
+done
+
+    else
+      # If it succeeded, then it was overridden by the user. We will use it
+      # for the tool.
+
+      # First remove it from the list of overridden variables, so we can test
+      # for unknown variables in the end.
+      CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
+
+      # Check if we try to supply an empty value
+      if test "x$FLOCK" = x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool FLOCK= (no value)" >&5
+$as_echo "$as_me: Setting user supplied tool FLOCK= (no value)" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FLOCK" >&5
+$as_echo_n "checking for FLOCK... " >&6; }
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
+$as_echo "disabled" >&6; }
+      else
+        # Check if the provided tool contains a complete path.
+        tool_specified="$FLOCK"
+        tool_basename="${tool_specified##*/}"
+        if test "x$tool_basename" = "x$tool_specified"; then
+          # A command without a complete path is provided, search $PATH.
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool FLOCK=$tool_basename" >&5
+$as_echo "$as_me: Will search for user supplied tool FLOCK=$tool_basename" >&6;}
+          # Extract the first word of "$tool_basename", so it can be a program name with args.
+set dummy $tool_basename; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_FLOCK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $FLOCK in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FLOCK="$FLOCK" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_FLOCK="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+FLOCK=$ac_cv_path_FLOCK
+if test -n "$FLOCK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLOCK" >&5
+$as_echo "$FLOCK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+          if test "x$FLOCK" = x; then
+            as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5
+          fi
+        else
+          # Otherwise we believe it is a complete path. Use it as it is.
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool FLOCK=$tool_specified" >&5
+$as_echo "$as_me: Will use user supplied tool FLOCK=$tool_specified" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FLOCK" >&5
+$as_echo_n "checking for FLOCK... " >&6; }
+          if test ! -x "$tool_specified"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+            as_fn_error $? "User supplied tool FLOCK=$tool_specified does not exist or is not executable" "$LINENO" 5
+          fi
+          { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5
+$as_echo "$tool_specified" >&6; }
+        fi
+      fi
+    fi
+
+  fi
+
+
   # Dtrace is usually found in /usr/sbin on Solaris, but that directory may not
   # be in the user path.
 
@@ -31216,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"
@@ -66062,24 +66262,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
 
diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in
index 247b150..175084e 100644
--- a/common/autoconf/spec.gmk.in
+++ b/common/autoconf/spec.gmk.in
@@ -48,7 +48,7 @@
 
 # The default make arguments
 MAKE_ARGS = $(MAKE_LOG_FLAGS) -r -R -I $(TOPDIR)/make/common SPEC=$(SPEC) \
-    MAKE_LOG_FLAGS="$(MAKE_LOG_FLAGS)" LOG_LEVEL=$(LOG_LEVEL)
+    MAKE_LOG_FLAGS="$(MAKE_LOG_FLAGS)" $(MAKE_LOG_VARS)
 
 OUTPUT_SYNC_SUPPORTED:=@OUTPUT_SYNC_SUPPORTED@
 OUTPUT_SYNC:=@OUTPUT_SYNC@
@@ -638,6 +638,7 @@
 DSYMUTIL:=@DSYMUTIL@
 FIND:=@FIND@
 FIND_DELETE:=@FIND_DELETE@
+FLOCK:=@FLOCK@
 ECHO:=@ECHO@
 EGREP:=@EGREP@
 FGREP:=@FGREP@
diff --git a/common/autoconf/version-numbers b/common/autoconf/version-numbers
index 4cb5467..dc6e062 100644
--- a/common/autoconf/version-numbers
+++ b/common/autoconf/version-numbers
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 # Default version numbers to use unless overridden by configure
 
-DEFAULT_VERSION_MAJOR=9
+DEFAULT_VERSION_MAJOR=10
 DEFAULT_VERSION_MINOR=0
 DEFAULT_VERSION_SECURITY=0
 DEFAULT_VERSION_PATCH=0
diff --git a/common/bin/shell-profiler.sh b/common/bin/shell-profiler.sh
new file mode 100644
index 0000000..d4a39dd
--- /dev/null
+++ b/common/bin/shell-profiler.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+#
+# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+# 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.
+#
+
+# Usage: sh shell-tracer.sh <TIME_CMD_TYPE> <TIME_CMD> <OUTPUT_FILE> <shell command line>
+#
+# This shell script is supposed to be set as a replacement for SHELL in make,
+# causing it to be called whenever make wants to execute shell commands.
+# The <shell command line> is suitable for passing on to the old shell,
+# typically beginning with -c.
+#
+# This script will run the shell command line and it will also store a simple
+# log of the the time it takes to execute the command in the OUTPUT_FILE, using
+# utility for time measure specified with TIME_CMD option.
+#
+# Type of time measure utility is specified with TIME_CMD_TYPE option.
+# Recognized options values of TIME_CMD_TYPE option: "gnutime", "flock".
+
+TIME_CMD_TYPE="$1"
+TIME_CMD="$2"
+OUTPUT_FILE="$3"
+shift
+shift
+shift
+if [ "$TIME_CMD_TYPE" = "gnutime" ]; then
+  # Escape backslashes (\) and percent chars (%). See man for GNU 'time'.
+  msg=${@//\\/\\\\}
+  msg=${msg//%/%%}
+  "$TIME_CMD" -f "[TIME:%E] $msg" -a -o "$OUTPUT_FILE" "$@"
+elif [ "$TIME_CMD_TYPE" = "flock" ]; then
+  # Emulated GNU 'time' with 'flock' and 'date'.
+  ts=`date +%s%3N`
+  "$@"
+  status=$?
+  ts2=`date +%s%3N`
+  millis=$((ts2 - ts))
+  ms=$(($millis % 1000))
+  seconds=$((millis / 1000))
+  ss=$(($seconds % 60))
+  minutes=$(($seconds / 60))
+  mm=$(($minutes % 60))
+  hh=$(($minutes / 60)):
+  [ $hh != "0:" ] || hh=
+  # Synchronize on this script.
+  flock -w 10 "$0" printf "[TIME:${hh}${mm}:${ss}.%.2s] %s\n" $ms "$*" >> "$OUTPUT_FILE" || true
+  exit $status
+else
+  "$@"
+fi
diff --git a/common/bin/shell-tracer.sh b/common/bin/shell-tracer.sh
deleted file mode 100644
index 5c7cc44..0000000
--- a/common/bin/shell-tracer.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/bash
-#
-# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-
-# Usage: sh shell-tracer.sh <TIME_CMD> <OUTPUT_FILE> <OLD_SHELL> <shell command line>
-#
-# This shell script is supposed to be set as a replacement for SHELL in make,
-# causing it to be called whenever make wants to execute shell commands.
-# The <shell command line> is suitable for passing on to the old shell,
-# typically beginning with -c.
-#
-# This script will make sure the shell command line is executed with
-# OLD_SHELL -x, and it will also store a simple log of the the time it takes to
-# execute the command in the OUTPUT_FILE, using the "time" utility as pointed
-# to by TIME_CMD. If TIME_CMD is "-", no timestamp will be stored.
-
-TIME_CMD="$1"
-OUTPUT_FILE="$2"
-OLD_SHELL="$3"
-shift
-shift
-shift
-if [ "$TIME_CMD" != "-" ]; then
-"$TIME_CMD" -f "[TIME:%E] $*" -a -o "$OUTPUT_FILE" "$OLD_SHELL" -x "$@"
-else
-"$OLD_SHELL" -x "$@"
-fi
diff --git a/corba/.hgtags b/corba/.hgtags
index 6dde9ab..0fe545a 100644
--- a/corba/.hgtags
+++ b/corba/.hgtags
@@ -396,9 +396,11 @@
 77f827f5bbad3ef795664bc675f72d98d156b9f8 jdk-9+151
 ff8cb43c07c069b1debdee44cb88ca22db1ec757 jdk-9+152
 68a8e8658511093b322a46ed04b2a321e1da2a43 jdk-9+153
+d66f97a610a6beac987740edc2bf6a70f46ba574 jdk-10+0
 078ebe23b584466dc8346e620d7821d91751e5a9 jdk-9+154
 a545f54babfa31aa7eb611f36031609acd617cbc jdk-9+155
 907c26240cd481579e919bfd23740797ff8ce1c8 jdk-9+156
+37c9962586a4d3498fa673d93eab1a336acd7652 jdk-10+1
 9383da04b385cca46b7ca67f3a39ac1b673e09fe jdk-9+157
 de6bdf38935fa753183ca288bed5c06a23c0bb12 jdk-9+158
 6feea77d2083c99e44aa3e272d07b7fb3b801683 jdk-9+159
@@ -409,6 +411,14 @@
 965bbae3072702f7c0d95c240523b65e6bb19261 jdk-9+164
 a510b2201154abdd12ede42788086b5283bfb9a6 jdk-9+165
 934c18145915b06d3fcc0de1a30f91f5aab8a192 jdk-9+166
+56a8bf5322684e9a31cda64c336c32bcdb592211 jdk-10+2
+3813c94c8585dd7507887916c6943f45051f1b55 jdk-10+3
+5d6d891bb36dbeeacaffa06b5a3e3b4e44b35fbd jdk-10+4
+7c5328012799923d45d1cf87e8725e725b3d298b jdk-10+5
+c7358d703e1282af3dcd8af6c037dc4342de9054 jdk-10+6
 43de67f51801b9e16507865fcb7e8344f4ca4aa9 jdk-9+167
 03a2cc9c8a1e8f87924c9863e917bc8b91770d5f jdk-9+168
 b2218d41edef02ee8f94bb438f885b2ba79bfa08 jdk-9+169
+8a4ab3b0ab9a86df73d9a1e337134f2dbe006725 jdk-9+170
+aed5a4edc8275c1c50195503756ff92bfe0197f5 jdk-10+7
+648b0a00824eb29e71936bc3258d309a25e3b8c0 jdk-10+8
diff --git a/corba/.jcheck/conf b/corba/.jcheck/conf
index 5c6f62d..b258135 100644
--- a/corba/.jcheck/conf
+++ b/corba/.jcheck/conf
@@ -1 +1 @@
-project=jdk9
+project=jdk10
diff --git a/hotspot/.hgtags b/hotspot/.hgtags
index 1ce36c1..368f851 100644
--- a/hotspot/.hgtags
+++ b/hotspot/.hgtags
@@ -556,9 +556,11 @@
 2a2ac7d9f52c8cb2b80077e515b5840b947e640c jdk-9+151
 31f1d26c60df7b2e516a4f84160d76ba017d4e09 jdk-9+152
 217ba81b9a4ce8698200370175aa2db86a39f66c jdk-9+153
+fc7e94cb748507366b839e859f865f724467446a jdk-10+0
 a9fdfd55835ef9dccb7f317b07249bd66653b874 jdk-9+154
 f3b3d77a1751897413aae43ac340a130b6fa2ae1 jdk-9+155
 43139c588ea48b6504e52b6c3dec530b17b1fdb4 jdk-9+156
+1ea217626ba0995dd03127f8322ba3687926a085 jdk-10+1
 b2d0a906afd73dcf27f572217eb1be0f196ec16c jdk-9+157
 4e78f30935229f13ce7c43089621cf7169f5abac jdk-9+158
 9211c2e89c1cd11ec2d5752b0f97131a7d7525c7 jdk-9+159
@@ -569,6 +571,14 @@
 0af429be8bbaeaaf0cb838e9af28c953dda6a9c8 jdk-9+164
 c92c6416ca03b1464d5ed99cf6201e52b5ba0a70 jdk-9+165
 560d7aa083a24b6a56443feb8de0f40435d33aa9 jdk-9+166
+48809c513ed5ebb4d4dbf2f454afcce2780db6db jdk-10+2
+6c3b6b3438c4a63e619f00bd5732d1260ffd5600 jdk-10+3
+8295ca08f5cb09c090eb048bbdd338d7e270c8bf jdk-10+4
+7b5ca2ff1f78873ca3ee99b6589d3cb4dde2e454 jdk-10+5
+762465099d938fd96cd1efda193bc1fa23d070d3 jdk-10+6
 1ca7ed1b17b5776930d641d1379834f3140a74e4 jdk-9+167
 fbb9c802649585d19f6d7e81b4a519d44806225a jdk-9+168
 16d692be099c5c38eb48cc9aca78b0c900910d5b jdk-9+169
+38a240fd58a287acb1963920b92ed4d9c2fd39e3 jdk-9+170
+9d4746eca95aec3e5a344bf2520745dcc1d17eed jdk-10+7
+f5ded0cf954c770deeecb80f2ba1ba6a05cd979b jdk-10+8
diff --git a/hotspot/.jcheck/conf b/hotspot/.jcheck/conf
index 5c6f62d..b258135 100644
--- a/hotspot/.jcheck/conf
+++ b/hotspot/.jcheck/conf
@@ -1 +1 @@
-project=jdk9
+project=jdk10
diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad
index 4360e8c..cf3fd21 100644
--- a/hotspot/src/cpu/aarch64/vm/aarch64.ad
+++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad
@@ -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" %}
diff --git a/hotspot/src/cpu/aarch64/vm/c1_globals_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/c1_globals_aarch64.hpp
index 71d7819..3177a89 100644
--- a/hotspot/src/cpu/aarch64/vm/c1_globals_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/c1_globals_aarch64.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -45,10 +45,8 @@
 // We compile very aggressively with the builtin simulator because
 // doing so greatly reduces run times and tests more code.
 define_pd_global(intx, CompileThreshold,             150 );
-define_pd_global(intx, BackEdgeThreshold,            500);
 #else
 define_pd_global(intx, CompileThreshold,             1500 );
-define_pd_global(intx, BackEdgeThreshold,            100000);
 #endif
 
 define_pd_global(intx, OnStackReplacePercentage,     933  );
@@ -76,6 +74,4 @@
 define_pd_global(bool, CSEArrayLength,               false);
 define_pd_global(bool, TwoOperandLIRForm,            false );
 
-define_pd_global(intx, SafepointPollOffset,          0  );
-
 #endif // CPU_AARCH64_VM_C1_GLOBALS_AARCH64_HPP
diff --git a/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp
index 9a16dd7..5a5d8ac 100644
--- a/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp
@@ -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.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -43,7 +43,6 @@
 define_pd_global(bool, ProfileInterpreter,           true);
 define_pd_global(bool, TieredCompilation,            trueInTiered);
 define_pd_global(intx, CompileThreshold,             10000);
-define_pd_global(intx, BackEdgeThreshold,            100000);
 
 define_pd_global(intx, OnStackReplacePercentage,     140);
 define_pd_global(intx, ConditionalMoveLimit,         3);
diff --git a/hotspot/src/cpu/aarch64/vm/globalDefinitions_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/globalDefinitions_aarch64.hpp
index 0d78e2da..ad6b12d 100644
--- a/hotspot/src/cpu/aarch64/vm/globalDefinitions_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/globalDefinitions_aarch64.hpp
@@ -34,10 +34,6 @@
 
 #define SUPPORTS_NATIVE_CX8
 
-// The maximum B/BL offset range on AArch64 is 128MB.
-#undef CODE_CACHE_DEFAULT_LIMIT
-#define CODE_CACHE_DEFAULT_LIMIT (128*M)
-
 // According to the ARMv8 ARM, "Concurrent modification and execution
 // of instructions can lead to the resulting instruction performing
 // any behavior that can be achieved by executing any sequence of
diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
index 1c955d5..303c2f5 100644
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp
@@ -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,
diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp
index 2f17699..59171e5 100644
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp
@@ -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,
diff --git a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
index 3143fe9..650c374 100644
--- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp
@@ -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);
+    if (UseBlockZeroing) {
+      int zva_length = VM_Version::zva_length();
 
-    // 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);
+      // Ensure ZVA length can be divided by 16. This is required by
+      // the subsequent operations.
+      assert (zva_length % 16 == 0, "Unexpected ZVA Length");
 
-    for (int i = -zva_length + 16; i < 0; i += 16)
-      __ stp(zr, zr, Address(base, i));
-    __ bind(initial_table_end);
+      __ tbz(base, 3, base_aligned);
+      __ str(zr, Address(__ post(base, 8)));
+      __ sub(cnt, cnt, 1);
+      __ bind(base_aligned);
 
-    __ 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);
+      // 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:
diff --git a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp
index f5727ee..9bcbe1e 100644
--- a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp
+++ b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp
@@ -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
diff --git a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp
index 1355a68..fc86d04 100644
--- a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp
+++ b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp
@@ -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[];
 
 };
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/AltHashing.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/AltHashing.java
new file mode 100644
index 0000000..e3ff237
--- /dev/null
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/AltHashing.java
@@ -0,0 +1,94 @@
+/*
+ * 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 sun.jvm.hotspot.memory;
+
+public class AltHashing {
+    public static long murmur3_32(long seed, byte[] data) {
+      long h1 = seed;
+      int len = data.length;
+      int count = len;
+
+      int offset = 0;
+
+      // body
+      while (count >= 4) {
+          long k1 = (data[offset] & 0x0FF)
+              | (data[offset + 1] & 0x0FF) << 8
+              | (data[offset + 2] & 0x0FF) << 16
+              | data[offset + 3] << 24;
+
+          count -= 4;
+          offset += 4;
+
+          k1 *= 0xcc9e2d51;
+          k1 = Integer.rotateLeft((int)k1, 15);
+          k1 *= 0x1b873593;
+          k1 &= 0xFFFFFFFFL;
+
+          h1 ^= k1;
+          h1 = Integer.rotateLeft((int)h1, 13);
+          h1 = h1 * 5 + 0xe6546b64;
+          h1 &= 0xFFFFFFFFL;
+      }
+
+      //tail
+      if (count > 0) {
+          long k1 = 0;
+
+          switch (count) {
+              case 3:
+                  k1 ^= (data[offset + 2] & 0xff) << 16;
+                  // fall through
+              case 2:
+                  k1 ^= (data[offset + 1] & 0xff) << 8;
+                  // fall through
+              case 1:
+                  k1 ^= (data[offset] & 0xff);
+                  // fall through
+              default:
+                  k1 *= 0xcc9e2d51;
+                  k1 = Integer.rotateLeft((int)k1, 15);
+                  k1 *= 0x1b873593;
+                  k1 &= 0xFFFFFFFFL;
+                  h1 ^= k1;
+                  h1 &= 0xFFFFFFFFL;
+          }
+      }
+
+      // finalization
+      h1 ^= len;
+
+      // finalization mix force all bits of a hash block to avalanche
+      h1 ^= h1 >> 16;
+      h1 *= 0x85ebca6b;
+      h1 &= 0xFFFFFFFFL;
+      h1 ^= h1 >> 13;
+      h1 *= 0xc2b2ae35;
+      h1 &= 0xFFFFFFFFL;
+      h1 ^= h1 >> 16;
+
+      return h1 & 0xFFFFFFFFL;
+  }
+}
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java
index 46d0873..e2231b5 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,11 +45,14 @@
     Type type = db.lookupType("SymbolTable");
     theTableField  = type.getAddressField("_the_table");
     sharedTableField = type.getAddressField("_shared_table");
+    type = db.lookupType("RehashableSymbolHashtable");
+    seedField = type.getCIntegerField("_seed");
   }
 
   // Fields
   private static AddressField theTableField;
   private static AddressField sharedTableField;
+  private static CIntegerField seedField;
 
   private CompactHashTable sharedTable;
 
@@ -62,6 +65,17 @@
     return table;
   }
 
+  public static long getSeed() {
+      return (long) seedField.getValue();
+  }
+
+  public static boolean useAlternateHashcode() {
+      if (getSeed() != 0) {
+          return true;
+      }
+      return false;
+  }
+
   public SymbolTable(Address addr) {
     super(addr);
   }
@@ -86,11 +100,17 @@
   public Symbol probe(byte[] name) {
     long hashValue = hashSymbol(name);
 
+    // shared table does not use alternate hashing algorithm,
+    // it always uses the same original hash code.
     Symbol s = sharedTable.probe(name, hashValue);
     if (s != null) {
       return s;
     }
 
+    if (useAlternateHashcode()) {
+        hashValue = AltHashing.murmur3_32(getSeed(), name);
+    }
+
     for (HashtableEntry e = (HashtableEntry) bucket(hashToIndex(hashValue)); e != null; e = (HashtableEntry) e.next()) {
       if (e.hash() == hashValue) {
          Symbol sym = Symbol.create(e.literalValue());
diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java
index 643109b..09a382f 100644
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -150,13 +150,7 @@
    // Helper methods
 
    private void printGCAlgorithm(Map flagMap) {
-       // print about new generation
-       long l = getFlagValue("UseParNewGC", flagMap);
-       if (l == 1L) {
-          System.out.println("using parallel threads in the new generation.");
-       }
-
-       l = getFlagValue("UseTLAB", flagMap);
+       long l = getFlagValue("UseTLAB", flagMap);
        if (l == 1L) {
           System.out.println("using thread-local object allocation.");
        }
diff --git a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java
index d070eb0..9a73893 100644
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java
@@ -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;",
diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp
index 527246d..adbec4e 100644
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp
@@ -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
@@ -3050,15 +3050,12 @@
   thr_yield();
 }
 
-// Interface for setting lwp priorities.  If we are using T2 libthread,
-// which forces the use of BoundThreads or we manually set UseBoundThreads,
-// all of our threads will be assigned to real lwp's.  Using the thr_setprio
-// function is meaningless in this mode so we must adjust the real lwp's priority
+// Interface for setting lwp priorities.  We are using T2 libthread,
+// which forces the use of bound threads, so all of our threads will
+// be assigned to real lwp's.  Using the thr_setprio function is
+// meaningless in this mode so we must adjust the real lwp's priority.
 // The routines below implement the getting and setting of lwp priorities.
 //
-// Note: T2 is now the only supported libthread. UseBoundThreads flag is
-//       being deprecated and all threads are now BoundThreads
-//
 // Note: There are three priority scales used on Solaris.  Java priotities
 //       which range from 1 to 10, libthread "thr_setprio" scale which range
 //       from 0 to 127, and the current scheduling class of the process we
diff --git a/hotspot/src/share/vm/c1/c1_Compiler.cpp b/hotspot/src/share/vm/c1/c1_Compiler.cpp
index 731b9ef..416f0f3 100644
--- a/hotspot/src/share/vm/c1/c1_Compiler.cpp
+++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp
@@ -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
diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
index 200a3fc..d440048 100644
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp
@@ -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       :
diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
index 8143eef..68c9592 100644
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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;
 
diff --git a/hotspot/src/share/vm/classfile/vmSymbols.cpp b/hotspot/src/share/vm/classfile/vmSymbols.cpp
index ad17837..e56b4e9 100644
--- a/hotspot/src/share/vm/classfile/vmSymbols.cpp
+++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp
@@ -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;
diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp
index 1340560..15aa361 100644
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp
@@ -1244,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")                                       \
diff --git a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp
index 1cc6a5e..4effbf4 100644
--- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp
+++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp
@@ -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
@@ -488,9 +488,6 @@
   _gc_timer_cm(new (ResourceObj::C_HEAP, mtGC) ConcurrentGCTimer()),
   _cms_start_registered(false)
 {
-  if (ExplicitGCInvokesConcurrentAndUnloadsClasses) {
-    ExplicitGCInvokesConcurrent = true;
-  }
   // Now expand the span and allocate the collection support structures
   // (MUT, marking bit map etc.) to cover both generations subject to
   // collection.
@@ -2559,10 +2556,8 @@
 // Decide if we want to enable class unloading as part of the
 // ensuing concurrent GC cycle. We will collect and
 // unload classes if it's the case that:
-// (1) an explicit gc request has been made and the flag
-//     ExplicitGCInvokesConcurrentAndUnloadsClasses is set, OR
-// (2) (a) class unloading is enabled at the command line, and
-//     (b) old gen is getting really full
+//  (a) class unloading is enabled at the command line, and
+//  (b) old gen is getting really full
 // NOTE: Provided there is no change in the state of the heap between
 // calls to this method, it should have idempotent results. Moreover,
 // its results should be monotonically increasing (i.e. going from 0 to 1,
@@ -2575,11 +2570,7 @@
 // below.
 void CMSCollector::update_should_unload_classes() {
   _should_unload_classes = false;
-  // Condition 1 above
-  if (_full_gc_requested && ExplicitGCInvokesConcurrentAndUnloadsClasses) {
-    _should_unload_classes = true;
-  } else if (CMSClassUnloadingEnabled) { // Condition 2.a above
-    // Disjuncts 2.b.(i,ii,iii) above
+  if (CMSClassUnloadingEnabled) {
     _should_unload_classes = (concurrent_cycles_since_last_unload() >=
                               CMSClassUnloadingMaxInterval)
                            || _cmsGen->is_too_full();
diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp
index f37278e..beed68b 100644
--- a/hotspot/src/share/vm/oops/method.cpp
+++ b/hotspot/src/share/vm/oops/method.cpp
@@ -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
@@ -2199,7 +2199,6 @@
   ResourceMark rm;
   assert(is_method(), "must be method");
   st->print_cr("%s", internal_name());
-  // get the effect of PrintOopAddress, always, for methods:
   st->print_cr(" - this oop:          " INTPTR_FORMAT, p2i(this));
   st->print   (" - method holder:     "); method_holder()->print_value_on(st); st->cr();
   st->print   (" - constants:         " INTPTR_FORMAT " ", p2i(constants()));
diff --git a/hotspot/src/share/vm/opto/c2compiler.cpp b/hotspot/src/share/vm/opto/c2compiler.cpp
index ec7e03c..69106bb 100644
--- a/hotspot/src/share/vm/opto/c2compiler.cpp
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp
@@ -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;
diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp
index e1e1c9f..4e5051e 100644
--- a/hotspot/src/share/vm/opto/library_call.cpp
+++ b/hotspot/src/share/vm/opto/library_call.cpp
@@ -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::_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::_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::_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::_compareAndExchangeObjectVolatile: return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  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
diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp
index 71b0ea3..59704b2 100644
--- a/hotspot/src/share/vm/prims/jvm.cpp
+++ b/hotspot/src/share/vm/prims/jvm.cpp
@@ -2967,14 +2967,7 @@
   JVMWrapper("JVM_Yield");
   if (os::dont_yield()) return;
   HOTSPOT_THREAD_YIELD();
-
-  // When ConvertYieldToSleep is off (default), this matches the classic VM use of yield.
-  // Critical for similar threading behaviour
-  if (ConvertYieldToSleep) {
-    os::sleep(thread, MinSleepInterval, false);
-  } else {
-    os::naked_yield();
-  }
+  os::naked_yield();
 JVM_END
 
 
@@ -2998,18 +2991,7 @@
   EventThreadSleep event;
 
   if (millis == 0) {
-    // When ConvertSleepToYield is on, this matches the classic VM implementation of
-    // JVM_Sleep. Critical for similar threading behaviour (Win32)
-    // It appears that in certain GUI contexts, it may be beneficial to do a short sleep
-    // for SOLARIS
-    if (ConvertSleepToYield) {
-      os::naked_yield();
-    } else {
-      ThreadState old_state = thread->osthread()->get_state();
-      thread->osthread()->set_state(SLEEPING);
-      os::sleep(thread, MinSleepInterval, false);
-      thread->osthread()->set_state(old_state);
-    }
+    os::naked_yield();
   } else {
     ThreadState old_state = thread->osthread()->get_state();
     thread->osthread()->set_state(SLEEPING);
diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp
index 1c98add..2f09637 100644
--- a/hotspot/src/share/vm/prims/unsafe.cpp
+++ b/hotspot/src/share/vm/prims/unsafe.cpp
@@ -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)},
diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp
index dbbe554..7149c1a 100644
--- a/hotspot/src/share/vm/runtime/arguments.cpp
+++ b/hotspot/src/share/vm/runtime/arguments.cpp
@@ -376,53 +376,17 @@
   // --- Non-alias flags - sorted by obsolete_in then expired_in:
   { "MaxGCMinorPauseMillis",        JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
   { "UseConcMarkSweepGC",           JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
-  { "AutoGCSelectPauseMillis",      JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "UseAutoGCSelectPolicy",        JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "UseParNewGC",                  JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "ExplicitGCInvokesConcurrentAndUnloadsClasses", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "ConvertSleepToYield",          JDK_Version::jdk(9), JDK_Version::jdk(10),     JDK_Version::jdk(11) },
-  { "ConvertYieldToSleep",          JDK_Version::jdk(9), JDK_Version::jdk(10),     JDK_Version::jdk(11) },
 
   // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in:
   { "DefaultMaxRAMFraction",        JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
   { "CreateMinidumpOnCrash",        JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
-  { "CMSMarkStackSizeMax",          JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "CMSMarkStackSize",             JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "G1MarkStackSize",              JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "ParallelMarkingThreads",       JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "ParallelCMSThreads",           JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
 
   // -------------- Obsolete Flags - sorted by expired_in --------------
-  { "UseOldInlining",                JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "SafepointPollOffset",           JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "UseBoundThreads",               JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "DefaultThreadPriority",         JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "NoYieldsInMicrolock",           JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "BackEdgeThreshold",             JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "UseNewReflection",              JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "ReflectionWrapResolutionErrors",JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "VerifyReflectionBytecodes",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "AutoShutdownNMT",               JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "NmethodSweepFraction",          JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "NmethodSweepCheckInterval",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "CodeCacheMinimumFreeSpace",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-#ifndef ZERO
-  { "UseFastAccessorMethods",        JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "UseFastEmptyMethods",           JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-#endif // ZERO
-  { "UseCompilerSafepoints",         JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "AdaptiveSizePausePolicy",       JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "ParallelGCRetainPLAB",          JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "ThreadSafetyMargin",            JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "LazyBootClassLoader",           JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "StarvationMonitorInterval",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "PreInflateSpin",                JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "JNIDetachReleasesMonitors",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "UseAltSigs",                    JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "SegmentedHeapDumpThreshold",    JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "PrintOopAddress",               JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "PermSize",                      JDK_Version::undefined(), JDK_Version::jdk(8), JDK_Version::jdk(10) },
-  { "MaxPermSize",                   JDK_Version::undefined(), JDK_Version::jdk(8), JDK_Version::jdk(10) },
+  { "ConvertSleepToYield",           JDK_Version::jdk(9),      JDK_Version::jdk(10), JDK_Version::jdk(11) },
+  { "ConvertYieldToSleep",           JDK_Version::jdk(9),      JDK_Version::jdk(10), JDK_Version::jdk(11) },
+  { "MinSleepInterval",              JDK_Version::jdk(9),      JDK_Version::jdk(10), JDK_Version::jdk(11) },
+  { "PermSize",                      JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
+  { "MaxPermSize",                   JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
 
 #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS
   { "dep > obs",                    JDK_Version::jdk(9), JDK_Version::jdk(8), JDK_Version::undefined() },
@@ -445,11 +409,6 @@
 
 static AliasedFlag const aliased_jvm_flags[] = {
   { "DefaultMaxRAMFraction",    "MaxRAMFraction"    },
-  { "CMSMarkStackSizeMax",      "MarkStackSizeMax"  },
-  { "CMSMarkStackSize",         "MarkStackSize"     },
-  { "G1MarkStackSize",          "MarkStackSize"     },
-  { "ParallelMarkingThreads",   "ConcGCThreads"     },
-  { "ParallelCMSThreads",       "ConcGCThreads"     },
   { "CreateMinidumpOnCrash",    "CreateCoredumpOnCrash" },
   { NULL, NULL}
 };
@@ -1548,7 +1507,6 @@
   assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC,
          "control point invariant");
   assert(UseConcMarkSweepGC, "CMS is expected to be on here");
-  assert(UseParNewGC, "ParNew should always be used with CMS");
 
   if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
     FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
@@ -1589,7 +1547,6 @@
 void Arguments::set_cms_and_parnew_gc_flags() {
   assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC, "Error");
   assert(UseConcMarkSweepGC, "CMS is expected to be on here");
-  assert(UseParNewGC, "ParNew should always be used with CMS");
 
   // Turn off AdaptiveSizePolicy by default for cms until it is complete.
   disable_adaptive_size_policy("UseConcMarkSweepGC");
@@ -1729,16 +1686,6 @@
   NOT_LP64(ShouldNotReachHere(); return 0);
 }
 
-bool Arguments::should_auto_select_low_pause_collector() {
-  if (UseAutoGCSelectPolicy &&
-      !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
-      (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
-    log_trace(gc)("Automatic selection of the low pause collector based on pause goal of %d (ms)", (int) MaxGCPauseMillis);
-    return true;
-  }
-  return false;
-}
-
 void Arguments::set_use_compressed_oops() {
 #ifndef ZERO
 #ifdef _LP64
@@ -1842,16 +1789,7 @@
 void Arguments::select_gc_ergonomically() {
 #if INCLUDE_ALL_GCS
   if (os::is_server_class_machine()) {
-    if (!UseAutoGCSelectPolicy) {
-       FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
-    } else {
-      if (should_auto_select_low_pause_collector()) {
-        FLAG_SET_ERGO_IF_DEFAULT(bool, UseConcMarkSweepGC, true);
-        FLAG_SET_ERGO_IF_DEFAULT(bool, UseParNewGC, true);
-      } else {
-        FLAG_SET_ERGO_IF_DEFAULT(bool, UseParallelGC, true);
-      }
-    }
+    FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
   } else {
     FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
   }
@@ -1860,7 +1798,6 @@
   UNSUPPORTED_OPTION(UseParallelGC);
   UNSUPPORTED_OPTION(UseParallelOldGC);
   UNSUPPORTED_OPTION(UseConcMarkSweepGC);
-  UNSUPPORTED_OPTION(UseParNewGC);
   FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
 #endif // INCLUDE_ALL_GCS
 }
@@ -2079,7 +2016,6 @@
   if (!ClassUnloading) {
     FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
     FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false);
-    FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false);
   }
 #endif // INCLUDE_ALL_GCS
 }
@@ -2432,18 +2368,6 @@
     return false;
   }
 
-  if (UseConcMarkSweepGC && !UseParNewGC) {
-    jio_fprintf(defaultStream::error_stream(),
-        "It is not possible to combine the DefNew young collector with the CMS collector.\n");
-    return false;
-  }
-
-  if (UseParNewGC && !UseConcMarkSweepGC) {
-    jio_fprintf(defaultStream::error_stream(),
-        "It is not possible to combine the ParNew young collector with any collector other than CMS.\n");
-    return false;
-  }
-
   return true;
 }
 
@@ -3741,11 +3665,6 @@
     }
   }
 
-  if (UseConcMarkSweepGC && FLAG_IS_DEFAULT(UseParNewGC) && !UseParNewGC) {
-    // CMS can only be used with ParNew
-    FLAG_SET_ERGO(bool, UseParNewGC, true);
-  }
-
   if (!check_vm_args_consistency()) {
     return JNI_ERR;
   }
diff --git a/hotspot/src/share/vm/runtime/arguments.hpp b/hotspot/src/share/vm/runtime/arguments.hpp
index daa91c2..ad2178d 100644
--- a/hotspot/src/share/vm/runtime/arguments.hpp
+++ b/hotspot/src/share/vm/runtime/arguments.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -480,9 +480,6 @@
   static julong limit_by_allocatable_memory(julong size);
   // Setup heap size
   static void set_heap_size();
-  // Based on automatic selection criteria, should the
-  // low pause collector be used.
-  static bool should_auto_select_low_pause_collector();
 
   // Bytecode rewriting
   static void set_bytecode_flags();
diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp
index 16ce96b..5cfe971 100644
--- a/hotspot/src/share/vm/runtime/globals.hpp
+++ b/hotspot/src/share/vm/runtime/globals.hpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1158,13 +1158,6 @@
   product_pd(bool, DontYieldALot,                                           \
           "Throw away obvious excess yield calls")                          \
                                                                             \
-  product(bool, ConvertSleepToYield, true,                                  \
-          "Convert sleep(0) to thread yield ")                              \
-                                                                            \
-  product(bool, ConvertYieldToSleep, false,                                 \
-          "Convert yield to a sleep of MinSleepInterval to simulate Win32 " \
-          "behavior")                                                       \
-                                                                            \
   develop(bool, UseDetachedThreads, true,                                   \
           "Use detached threads that are recycled upon termination "        \
           "(for Solaris only)")                                             \
@@ -1478,11 +1471,6 @@
           "A System.gc() request invokes a concurrent collection; "         \
           "(effective only when using concurrent collectors)")              \
                                                                             \
-  product(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false,        \
-          "A System.gc() request invokes a concurrent collection and "      \
-          "also unloads classes during such a concurrent gc cycle "         \
-          "(effective only when UseConcMarkSweepGC)")                       \
-                                                                            \
   product(bool, GCLockerInvokesConcurrent, false,                           \
           "The exit of a JNI critical section necessitating a scavenge, "   \
           "also kicks off a background concurrent collection")              \
@@ -1500,9 +1488,6 @@
   product(bool, UseCMSBestFit, true,                                        \
           "Use CMS best fit allocation strategy")                           \
                                                                             \
-  product(bool, UseParNewGC, false,                                         \
-          "Use parallel threads in the new generation")                     \
-                                                                            \
   product(uintx, ParallelGCBufferWastePct, 10,                              \
           "Wasted fraction of parallel allocation buffer")                  \
           range(0, 100)                                                     \
@@ -2058,13 +2043,6 @@
           "Maximum fraction (1/n) of virtual memory used for ergonomically "\
           "determining maximum heap size")                                  \
                                                                             \
-  product(bool, UseAutoGCSelectPolicy, false,                               \
-          "Use automatic collection selection policy")                      \
-                                                                            \
-  product(uintx, AutoGCSelectPauseMillis, 5000,                             \
-          "Automatic GC selection pause threshold in milliseconds")         \
-          range(0, max_uintx)                                               \
-                                                                            \
   product(bool, UseAdaptiveSizePolicy, true,                                \
           "Use adaptive generation sizing policies")                        \
                                                                             \
@@ -3002,10 +2980,6 @@
   develop(intx, DontYieldALotInterval,    10,                               \
           "Interval between which yields will be dropped (milliseconds)")   \
                                                                             \
-  develop(intx, MinSleepInterval,     1,                                    \
-          "Minimum sleep() interval (milliseconds) when "                   \
-          "ConvertSleepToYield is off (used for Solaris)")                  \
-                                                                            \
   develop(intx, ProfilerPCTickThreshold,    15,                             \
           "Number of ticks in a PC buckets to be a hotspot")                \
                                                                             \
diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp
index 0d973ca..6d86a7c 100644
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp
@@ -199,6 +199,7 @@
 typedef HashtableEntry<Klass*, mtClass>       KlassHashtableEntry;
 typedef TwoOopHashtable<Symbol*, mtClass>     SymbolTwoOopHashtable;
 typedef CompactHashtable<Symbol*, char>       SymbolCompactHashTable;
+typedef RehashableHashtable<Symbol*, mtSymbol>   RehashableSymbolHashtable;
 
 //--------------------------------------------------------------------------------
 // VM_STRUCTS
@@ -584,6 +585,7 @@
                                                                                                                                      \
      static_field(SymbolTable,                 _the_table,                                    SymbolTable*)                          \
      static_field(SymbolTable,                 _shared_table,                                 SymbolCompactHashTable)                \
+     static_field(RehashableSymbolHashtable,   _seed,                                         juint)                                 \
                                                                                                                                      \
   /***************/                                                                                                                  \
   /* StringTable */                                                                                                                  \
@@ -1602,6 +1604,8 @@
                                                                           \
   declare_toplevel_type(BasicHashtable<mtInternal>)                       \
     declare_type(IntptrHashtable, BasicHashtable<mtInternal>)             \
+  declare_toplevel_type(BasicHashtable<mtSymbol>)                         \
+    declare_type(RehashableSymbolHashtable, BasicHashtable<mtSymbol>)     \
   declare_type(SymbolTable, SymbolHashtable)                              \
   declare_type(StringTable, StringHashtable)                              \
     declare_type(LoaderConstraintTable, KlassHashtable)                   \
diff --git a/hotspot/src/share/vm/shark/sharkIntrinsics.cpp b/hotspot/src/share/vm/shark/sharkIntrinsics.cpp
index 51b813f..15b6679 100644
--- a/hotspot/src/share/vm/shark/sharkIntrinsics.cpp
+++ b/hotspot/src/share/vm/shark/sharkIntrinsics.cpp
@@ -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();
diff --git a/hotspot/src/share/vm/shark/sharkIntrinsics.hpp b/hotspot/src/share/vm/shark/sharkIntrinsics.hpp
index f0699f8..8a5d60f 100644
--- a/hotspot/src/share/vm/shark/sharkIntrinsics.hpp
+++ b/hotspot/src/share/vm/shark/sharkIntrinsics.hpp
@@ -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
diff --git a/hotspot/src/share/vm/utilities/hashtable.hpp b/hotspot/src/share/vm/utilities/hashtable.hpp
index 76e8005..54e0b87 100644
--- a/hotspot/src/share/vm/utilities/hashtable.hpp
+++ b/hotspot/src/share/vm/utilities/hashtable.hpp
@@ -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
@@ -312,6 +312,7 @@
 };
 
 template <class T, MEMFLAGS F> class RehashableHashtable : public Hashtable<T, F> {
+ friend class VMStructs;
  protected:
 
   enum {
diff --git a/hotspot/test/TEST.groups b/hotspot/test/TEST.groups
index c50c741..8953467a 100644
--- a/hotspot/test/TEST.groups
+++ b/hotspot/test/TEST.groups
@@ -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
@@ -209,11 +209,8 @@
   gc/g1/TestShrinkToOneRegion.java \
   gc/metaspace/G1AddMetaspaceDependency.java \
   gc/startup_warnings/TestCMS.java \
-  gc/startup_warnings/TestDefNewCMS.java \
   gc/startup_warnings/TestParallelGC.java \
   gc/startup_warnings/TestParallelScavengeSerialOld.java \
-  gc/startup_warnings/TestParNewCMS.java \
-  gc/startup_warnings/TestParNewSerialOld.java \
   runtime/SharedArchiveFile/SharedArchiveFile.java
 
 # Minimal VM on Compact 2 adds in some compact2 tests
diff --git a/hotspot/test/compiler/c2/cr7200264/TestDriver.java b/hotspot/test/compiler/c2/cr7200264/TestDriver.java
index 558592b..bc8a987 100644
--- a/hotspot/test/compiler/c2/cr7200264/TestDriver.java
+++ b/hotspot/test/compiler/c2/cr7200264/TestDriver.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.regex.Pattern;
 
 import jdk.test.lib.Asserts;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -45,7 +44,7 @@
     }
 
     private List<String> executeApplication() throws Throwable {
-        OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvmAllArgs(
+        OutputAnalyzer outputAnalyzer = ProcessTools.executeTestJvm(
             "-Xbatch",
             "-XX:-TieredCompilation",
             "-XX:+PrintCompilation",
diff --git a/hotspot/test/compiler/compilercontrol/share/scenario/Executor.java b/hotspot/test/compiler/compilercontrol/share/scenario/Executor.java
index fbd3f13..19ebd61 100644
--- a/hotspot/test/compiler/compilercontrol/share/scenario/Executor.java
+++ b/hotspot/test/compiler/compilercontrol/share/scenario/Executor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 
 import compiler.compilercontrol.share.actions.BaseAction;
 import jdk.test.lib.Asserts;
+import jdk.test.lib.management.InputArguments;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.dcmd.CommandExecutor;
@@ -38,6 +39,7 @@
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -97,9 +99,13 @@
                 // Start separate thread to connect with test VM
                 new Thread(() -> connectTestVM(serverSocket)).start();
             }
-            // Start test VM
-            output = ProcessTools.executeTestJvmAllArgs(
-                    vmOptions.toArray(new String[vmOptions.size()]));
+            // Start a test VM using vm flags from @run and from vm options
+            String[] vmInputArgs = InputArguments.getVmInputArgs();
+            String[] cmds = Arrays.copyOf(vmInputArgs,
+                    vmInputArgs.length + vmOptions.size());
+            System.arraycopy(vmOptions.toArray(), 0, cmds, vmInputArgs.length,
+                    vmOptions.size());
+            output = ProcessTools.executeTestJvm(cmds);
         } catch (Throwable thr) {
             throw new Error("Execution failed: " + thr.getMessage(), thr);
         }
diff --git a/hotspot/test/compiler/intrinsics/unsafe/TestCAEAntiDep.java b/hotspot/test/compiler/intrinsics/unsafe/TestCAEAntiDep.java
index 5bec829..353c73e 100644
--- a/hotspot/test/compiler/intrinsics/unsafe/TestCAEAntiDep.java
+++ b/hotspot/test/compiler/intrinsics/unsafe/TestCAEAntiDep.java
@@ -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;
diff --git a/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java b/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java
index 8f65f1d..772b44b 100644
--- a/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java
+++ b/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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);
     }
 
 }
-
diff --git a/hotspot/test/compiler/jsr292/patches/java.base/java/lang/invoke/MethodHandleHelper.java b/hotspot/test/compiler/jsr292/patches/java.base/java/lang/invoke/MethodHandleHelper.java
index f19244b..c740628 100644
--- a/hotspot/test/compiler/jsr292/patches/java.base/java/lang/invoke/MethodHandleHelper.java
+++ b/hotspot/test/compiler/jsr292/patches/java.base/java/lang/invoke/MethodHandleHelper.java
@@ -99,7 +99,7 @@
 
         public static MethodHandle make(MethodHandle target) {
             LambdaForm lform = DelegatingMethodHandle.makeReinvokerForm(
-                    target, -1, DelegatingMethodHandle.class, "reinvoker.dontInline",
+                    target, -1, DelegatingMethodHandle.class,
                 /*forceInline=*/false, DelegatingMethodHandle.NF_getTarget, null);
             return new NonInlinedReinvoker(target, lform);
         }
diff --git a/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java b/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java
index a66a448..f07c570 100644
--- a/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,11 +30,9 @@
  * @modules java.base/jdk.internal.misc
  * @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot
  * @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
- * @run main/othervm compiler.jvmci.compilerToVM.DebugOutputTest
+ * @run driver compiler.jvmci.compilerToVM.DebugOutputTest
  */
 
- // as soon as CODETOOLS-7901589 fixed, '@run main/othervm' should be replaced w/ '@run driver'
-
 package compiler.jvmci.compilerToVM;
 
 import jdk.test.lib.process.OutputAnalyzer;
@@ -42,8 +40,11 @@
 import jdk.vm.ci.hotspot.CompilerToVMHelper;
 
 import java.util.Arrays;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 
 public class DebugOutputTest {
+    private static final String VM_CI_MODULE = "jdk.internal.vm.ci";
     public static void main(String[] args) {
         new DebugOutputTest().test();
     }
@@ -53,10 +54,18 @@
             System.out.println(testCase);
             OutputAnalyzer oa;
             try {
-                oa = ProcessTools.executeTestJvmAllArgs(
+                Path patch = Paths.get(System.getProperty("test.patch.path"));
+                Path jvmciPath = patch.resolve(VM_CI_MODULE).toAbsolutePath();
+                if (!jvmciPath.toFile().exists()) {
+                    throw new Error("TESTBUG: patch for " + VM_CI_MODULE + " : "
+                            + jvmciPath.toString() + " does not exist");
+                }
+                oa = ProcessTools.executeTestJvm(
                         "-XX:+UnlockExperimentalVMOptions",
                         "-XX:+EnableJVMCI",
-                        "-Xbootclasspath/a:.",
+                        "--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED",
+                        "--add-exports", "jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED",
+                        "--patch-module", VM_CI_MODULE + "=" + jvmciPath.toString(),
                         DebugOutputTest.Worker.class.getName(),
                         testCase.name());
                } catch (Throwable e) {
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java
index 50e505b..75c33c9 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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 @@
     }
 
 }
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java
index e35e590..30ffae3 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java
index 0bb36c8..817af4b 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java
index 48a98c6..37c15e5 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java
index 2a91a7c..0ac9fa1 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java
index b55e367..0f0f1f1 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java
index fc78b37..69a51bb 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java
index 039b472..b2e5fc5 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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 @@
     }
 
 }
-
diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java
index f854979..a6b845e 100644
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java
index 7200bf7..a1b68c7 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -138,4 +138,3 @@
     }
 
 }
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java
index a30c01f..c086315 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java
index 12dbb25..3a55939 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java
index 5fedde7..52bde3f 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java
index 621e4ae..478efa4 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java
index 1e49aac..0bf8b64 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -216,4 +216,3 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java
index e484bce..64014df 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -216,4 +216,3 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java
index 1241f0f..0145124 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -170,4 +170,3 @@
     }
 
 }
-
diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java
index d1d7b63..9a81567 100644
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
diff --git a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template
index 55ed81f..f287917 100644
--- a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template
+++ b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template
@@ -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]
 }
-
diff --git a/hotspot/test/gc/arguments/TestExplicitGCInvokesConcurrentAndUnloadsClasses.java b/hotspot/test/gc/arguments/TestExplicitGCInvokesConcurrentAndUnloadsClasses.java
deleted file mode 100644
index 83f0757..0000000
--- a/hotspot/test/gc/arguments/TestExplicitGCInvokesConcurrentAndUnloadsClasses.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test TestExplicitGCInvokesConcurrentAndUnloadsClasses
- * @summary Test that the flag ExplicitGCInvokesConcurrentAndUnloadsClasses is deprecated
- * @bug 8170388
- * @key gc
- * @library /test/lib
- * @modules java.base/jdk.internal.misc
- *          java.management
- * @run driver TestExplicitGCInvokesConcurrentAndUnloadsClasses
- */
-
-import jdk.test.lib.process.OutputAnalyzer;
-import jdk.test.lib.process.ProcessTools;
-
-public class TestExplicitGCInvokesConcurrentAndUnloadsClasses {
-    public static void main(String[] args) throws Exception {
-        ProcessBuilder pb =
-            ProcessTools.createJavaProcessBuilder("-XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses",
-                                                  "-Xlog:gc",
-                                                  "-version");
-        OutputAnalyzer output = new OutputAnalyzer(pb.start());
-        output.shouldContain("ExplicitGCInvokesConcurrentAndUnloadsClasses was deprecated");
-        output.shouldHaveExitValue(0);
-    }
-}
diff --git a/hotspot/test/gc/arguments/TestSelectDefaultGC.java b/hotspot/test/gc/arguments/TestSelectDefaultGC.java
index de770b2..084ee04 100644
--- a/hotspot/test/gc/arguments/TestSelectDefaultGC.java
+++ b/hotspot/test/gc/arguments/TestSelectDefaultGC.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,7 +66,6 @@
         assertVMOption(output, "UseSerialGC",        !isServer);
         // CMS is never default
         assertVMOption(output, "UseConcMarkSweepGC", false);
-        assertVMOption(output, "UseParNewGC",        false);
     }
 
     public static void main(String[] args) throws Exception {
diff --git a/hotspot/test/gc/startup_warnings/TestDefNewCMS.java b/hotspot/test/gc/startup_warnings/TestDefNewCMS.java
deleted file mode 100644
index f878067..0000000
--- a/hotspot/test/gc/startup_warnings/TestDefNewCMS.java
+++ /dev/null
@@ -1,47 +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.
- */
-
-/*
-* @test TestDefNewCMS
-* @key gc
-* @bug 8065972
-* @summary Test that the unsupported DefNew+CMS combination does not start
-* @library /test/lib
-* @modules java.base/jdk.internal.misc
-*          java.management
-*/
-
-import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.process.OutputAnalyzer;
-
-public class TestDefNewCMS {
-
-  public static void main(String args[]) throws Exception {
-    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:-UseParNewGC", "-XX:+UseConcMarkSweepGC", "-version");
-    OutputAnalyzer output = new OutputAnalyzer(pb.start());
-    output.shouldContain("It is not possible to combine the DefNew young collector with the CMS collector.");
-    output.shouldContain("Error");
-    output.shouldHaveExitValue(1);
-  }
-
-}
diff --git a/hotspot/test/gc/startup_warnings/TestParNewCMS.java b/hotspot/test/gc/startup_warnings/TestParNewCMS.java
deleted file mode 100644
index 75dbe4b..0000000
--- a/hotspot/test/gc/startup_warnings/TestParNewCMS.java
+++ /dev/null
@@ -1,48 +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.
- */
-
-/*
-* @test TestParNewCMS
-* @key gc
-* @bug 8065972
-* @summary Test that specifying -XX:+UseParNewGC on the command line logs a warning message
-* @library /test/lib
-* @modules java.base/jdk.internal.misc
-*          java.management
-*/
-
-import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.process.OutputAnalyzer;
-
-
-public class TestParNewCMS {
-
-  public static void main(String args[]) throws Exception {
-    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseParNewGC", "-XX:+UseConcMarkSweepGC", "-version");
-    OutputAnalyzer output = new OutputAnalyzer(pb.start());
-    output.shouldContain("warning: Option UseParNewGC was deprecated in version");
-    output.shouldNotContain("error");
-    output.shouldHaveExitValue(0);
-  }
-
-}
diff --git a/hotspot/test/gc/startup_warnings/TestParNewSerialOld.java b/hotspot/test/gc/startup_warnings/TestParNewSerialOld.java
deleted file mode 100644
index a4c8d5c..0000000
--- a/hotspot/test/gc/startup_warnings/TestParNewSerialOld.java
+++ /dev/null
@@ -1,48 +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.
- */
-
-/*
-* @test TestParNewSerialOld
-* @key gc
-* @bug 8065972
-* @summary Test that the unsupported ParNew+SerialOld combination does not start
-* @library /test/lib
-* @modules java.base/jdk.internal.misc
-*          java.management
-*/
-
-import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.process.OutputAnalyzer;
-
-
-public class TestParNewSerialOld {
-
-  public static void main(String args[]) throws Exception {
-    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseParNewGC", "-version");
-    OutputAnalyzer output = new OutputAnalyzer(pb.start());
-    output.shouldContain("It is not possible to combine the ParNew young collector with any collector other than CMS.");
-    output.shouldContain("Error");
-    output.shouldHaveExitValue(1);
-  }
-
-}
diff --git a/hotspot/test/gc/startup_warnings/TestUseAutoGCSelectPolicy.java b/hotspot/test/gc/startup_warnings/TestUseAutoGCSelectPolicy.java
deleted file mode 100644
index 360e5e0..0000000
--- a/hotspot/test/gc/startup_warnings/TestUseAutoGCSelectPolicy.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test TestUseAutoGCSelectPolicy
- * @key gc
- * @bug 8166461 8167494
- * @summary Test that UseAutoGCSelectPolicy and AutoGCSelectPauseMillis do print a warning message
- * @library /test/lib
- * @modules java.base/jdk.internal.misc
- *          java.management
- */
-
-import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.process.OutputAnalyzer;
-
-public class TestUseAutoGCSelectPolicy {
-
-  public static void main(String args[]) throws Exception {
-    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseAutoGCSelectPolicy", "-XX:AutoGCSelectPauseMillis=3000", "-version");
-    OutputAnalyzer output = new OutputAnalyzer(pb.start());
-    output.shouldContain("UseAutoGCSelectPolicy was deprecated in version 9.0");
-    output.shouldContain("AutoGCSelectPauseMillis was deprecated in version 9.0");
-    output.shouldNotContain("error");
-    output.shouldHaveExitValue(0);
-  }
-}
diff --git a/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java b/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java
index 31d8b47..59d2455 100644
--- a/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java
+++ b/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2015, 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
@@ -37,18 +37,18 @@
 
     // Case 1: Newly obsolete flags with extra junk appended should not be treated as newly obsolete (8060449)
     ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-        "-XX:UseOldInliningPlusJunk", "-version");
+        "-XX:ConvertSleepToYieldPlusJunk", "-version");
 
     OutputAnalyzer output = new OutputAnalyzer(pb.start());
-    output.shouldContain("Unrecognized VM option 'UseOldInliningPlusJunk'"); // Must identify bad option.
+    output.shouldContain("Unrecognized VM option 'ConvertSleepToYieldPlusJunk'"); // Must identify bad option.
     output.shouldHaveExitValue(1);
 
-    // Case 2: Newly obsolete integer-valued flags should be recognized as newly obsolete (8073989)
+    // Case 2: Newly obsolete flags should be recognized as newly obsolete (8073989)
     ProcessBuilder pb2 = ProcessTools.createJavaProcessBuilder(
-        "-XX:NmethodSweepFraction=10", "-version");
+        "-XX:+ConvertSleepToYield", "-version");
 
     OutputAnalyzer output2 = new OutputAnalyzer(pb2.start());
     output2.shouldContain("Ignoring option").shouldContain("support was removed");
-    output2.shouldContain("NmethodSweepFraction");
+    output2.shouldContain("ConvertSleepToYield");
   }
 }
diff --git a/hotspot/test/runtime/CommandLine/VMAliasOptions.java b/hotspot/test/runtime/CommandLine/VMAliasOptions.java
index eae3747..d82b4ae 100644
--- a/hotspot/test/runtime/CommandLine/VMAliasOptions.java
+++ b/hotspot/test/runtime/CommandLine/VMAliasOptions.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,11 +40,6 @@
      */
     public static final String[][] ALIAS_OPTIONS = {
         {"DefaultMaxRAMFraction",   "MaxRAMFraction", "1032"},
-        {"CMSMarkStackSizeMax",     "MarkStackSizeMax", "1032"},
-        {"CMSMarkStackSize",        "MarkStackSize", "1032"},
-        {"G1MarkStackSize",         "MarkStackSize", "1032"},
-        {"ParallelMarkingThreads",  "ConcGCThreads", "2"},
-        {"ParallelCMSThreads",      "ConcGCThreads", "2"},
         {"CreateMinidumpOnCrash",   "CreateCoredumpOnCrash", "false" },
     };
 
diff --git a/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java b/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java
index 06f7356..bbd2ea5 100644
--- a/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java
+++ b/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -41,17 +41,9 @@
     public static final String[][] DEPRECATED_OPTIONS = {
         // deprecated non-alias flags:
         {"MaxGCMinorPauseMillis", "1032"},
-        {"UseParNewGC", "false"},
-        {"ConvertSleepToYield", "false" },
-        {"ConvertYieldToSleep", "false" },
 
         // deprecated alias flags (see also aliased_jvm_flags):
         {"DefaultMaxRAMFraction", "4"},
-        {"CMSMarkStackSizeMax", "1032"},
-        {"CMSMarkStackSize", "1032"},
-        {"G1MarkStackSize", "1032"},
-        {"ParallelMarkingThreads", "2"},
-        {"ParallelCMSThreads", "2"},
         {"CreateMinidumpOnCrash", "false"}
     };
 
diff --git a/hotspot/test/runtime/NMT/AutoshutdownNMT.java b/hotspot/test/runtime/NMT/AutoshutdownNMT.java
deleted file mode 100644
index d07103e..0000000
--- a/hotspot/test/runtime/NMT/AutoshutdownNMT.java
+++ /dev/null
@@ -1,47 +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.
- */
-
-/*
- * @test
- * @key nmt
- * @summary Test for deprecated message if -XX:-AutoShutdownNMT is specified
- * @library /test/lib
- * @modules java.base/jdk.internal.misc
- *          java.management
- */
-
-import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.process.OutputAnalyzer;
-
-public class AutoshutdownNMT {
-
-    public static void main(String args[]) throws Exception {
-
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-                "-XX:NativeMemoryTracking=detail",
-                "-XX:-AutoShutdownNMT",
-                "-version");
-        OutputAnalyzer output = new OutputAnalyzer(pb.start());
-        output.shouldContain("Ignoring option AutoShutdownNMT");
-    }
-}
diff --git a/jaxp/.hgtags b/jaxp/.hgtags
index bc1c0c2..45875ae 100644
--- a/jaxp/.hgtags
+++ b/jaxp/.hgtags
@@ -396,9 +396,11 @@
 13c6906bfc861d99dc35a19c80b7a99f0b0ac58d jdk-9+151
 7e3da313b1746578da648155e37dd8526e83153d jdk-9+152
 1384504d2cd0e55c5e0becaeaf40ab05cae959d6 jdk-9+153
+0908877116d17c6e59092ec7d53ef687a96d3278 jdk-10+0
 7fa738305436d14c0926df0f04892890cacc766b jdk-9+154
 48fa77af153288b08ba794e1616a7b0685f3b67e jdk-9+155
 e930c373aaa4e0e712c9a25ba4b03d473b48c294 jdk-9+156
+b4257a40e55d5dea9fe27f7cc11c430531b7ad66 jdk-10+1
 412df235a8a229469a2cb9e7bb274d43277077d2 jdk-9+157
 60e670a65e07cc309951bd838b484401e6dd7847 jdk-9+158
 5695854e8831d0c088ab0ecf83b367ec16c9760a jdk-9+159
@@ -409,6 +411,14 @@
 6dc790a4e8310c86712cfdf7561a9820818546e6 jdk-9+164
 55419603989707ec50c84bb379bbdc1adeec3ab2 jdk-9+165
 8d3febd5c9d82e49f3e6e5f8eb10f959e7b50f83 jdk-9+166
+fb8f87183981ae0ea7afdafec64763e2f1a88227 jdk-10+2
+97423b4995a216d3fb566dcc5825f3d54dcfe17f jdk-10+3
+1f64e853c72b269a3e45878515c07dad9c533592 jdk-10+4
+ac697b2bdf486ef18caad2092bd24036e14946ac jdk-10+5
+26ed5e84fa13b8dca066b01ece5bc029323611be jdk-10+6
 646567dcfa64b9a39b33d71330427737d1c1a0d5 jdk-9+167
 23a87f409371fb8ce7b764cccb3a74c3f6b29900 jdk-9+168
 5d9d2a65fb26aa183019346c11d9314819621665 jdk-9+169
+6e78f902f477a093afca85a1042f97410d01eb69 jdk-9+170
+09cae4c36242734f5450de739b8264523a030809 jdk-10+7
+856998840907b67b7e1fc49259f785ac085a189b jdk-10+8
diff --git a/jaxp/.jcheck/conf b/jaxp/.jcheck/conf
index 5c6f62d..b258135 100644
--- a/jaxp/.jcheck/conf
+++ b/jaxp/.jcheck/conf
@@ -1 +1 @@
-project=jdk9
+project=jdk10
diff --git a/jaxp/test/TEST.ROOT b/jaxp/test/TEST.ROOT
index 8414a38..8ad82b2 100644
--- a/jaxp/test/TEST.ROOT
+++ b/jaxp/test/TEST.ROOT
@@ -25,6 +25,10 @@
 # Minimum jtreg version
 requiredVersion=4.2 b07
 
+# Path to libraries in the topmost test directory. This is needed so @library
+# does not need ../../ notation to reach them
+external.lib.roots = ../../
+
 # Use new module options
 useNewOptions=true
 
diff --git a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/Asserts.java b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/Asserts.java
deleted file mode 100644
index 594b12e..0000000
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/Asserts.java
+++ /dev/null
@@ -1,566 +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 jdk.testlibrary;
-
-import java.util.Objects;
-
-/**
- * Asserts that can be used for verifying assumptions in tests.
- *
- * An assertion will throw a {@link RuntimeException} if the assertion isn't true.
- * All the asserts can be imported into a test by using a static import:
- *
- * <pre>
- * {@code
- * import static jdk.testlibrary.Asserts.*;
- * }
- *
- * Always provide a message describing the assumption if the line number of the
- * failing assertion isn't enough to understand why the assumption failed. For
- * example, if the assertion is in a loop or in a method that is called
- * multiple times, then the line number won't provide enough context to
- * understand the failure.
- * </pre>
- *
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib}
- */
-@Deprecated
-public class Asserts {
-
-    /**
-     * Shorthand for {@link #assertLessThan(Comparable, Comparable)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertLessThan(Comparable, Comparable)
-     */
-    public static <T extends Comparable<T>> void assertLT(T lhs, T rhs) {
-        assertLessThan(lhs, rhs);
-    }
-
-    /**
-     * Shorthand for {@link #assertLessThan(Comparable, Comparable, String)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @see #assertLessThan(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertLT(T lhs, T rhs, String msg) {
-        assertLessThan(lhs, rhs, msg);
-    }
-
-    /**
-     * Calls {@link #assertLessThan(Comparable, Comparable, String)} with a default message.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertLessThan(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertLessThan(T lhs, T rhs) {
-        assertLessThan(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is less than {@code rhs}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static <T extends Comparable<T>>void assertLessThan(T lhs, T rhs, String msg) {
-        if (!(compare(lhs, rhs, msg) < 0)) {
-            msg = Objects.toString(msg, "assertLessThan")
-                    + ": expected that " + Objects.toString(lhs)
-                    + " < " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Shorthand for {@link #assertLessThanOrEqual(Comparable, Comparable)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertLessThanOrEqual(Comparable, Comparable)
-     */
-    public static <T extends Comparable<T>> void assertLTE(T lhs, T rhs) {
-        assertLessThanOrEqual(lhs, rhs);
-    }
-
-    /**
-     * Shorthand for {@link #assertLessThanOrEqual(Comparable, Comparable, String)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @see #assertLessThanOrEqual(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertLTE(T lhs, T rhs, String msg) {
-        assertLessThanOrEqual(lhs, rhs, msg);
-    }
-
-    /**
-     * Calls {@link #assertLessThanOrEqual(Comparable, Comparable, String)} with a default message.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertLessThanOrEqual(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertLessThanOrEqual(T lhs, T rhs) {
-        assertLessThanOrEqual(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is less than or equal to {@code rhs}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static <T extends Comparable<T>> void assertLessThanOrEqual(T lhs, T rhs, String msg) {
-        if (!(compare(lhs, rhs, msg) <= 0)) {
-            msg = Objects.toString(msg, "assertLessThanOrEqual")
-                    + ": expected that " + Objects.toString(lhs)
-                    + " <= " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Shorthand for {@link #assertEquals(Object, Object)}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertEquals(Object, Object)
-     */
-    public static void assertEQ(Object lhs, Object rhs) {
-        assertEquals(lhs, rhs);
-    }
-
-    /**
-     * Shorthand for {@link #assertEquals(Object, Object, String)}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @see #assertEquals(Object, Object, String)
-     */
-    public static void assertEQ(Object lhs, Object rhs, String msg) {
-        assertEquals(lhs, rhs, msg);
-    }
-
-    /**
-     * Calls {@link #assertEquals(java.lang.Object, java.lang.Object, java.lang.String)} with a default message.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertEquals(Object, Object, String)
-     */
-    public static void assertEquals(Object lhs, Object rhs) {
-        assertEquals(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is equal to {@code rhs}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertEquals(Object lhs, Object rhs, String msg) {
-        if ((lhs != rhs) && ((lhs == null) || !(lhs.equals(rhs)))) {
-            msg = Objects.toString(msg, "assertEquals")
-                    + ": expected " + Objects.toString(lhs)
-                    + " to equal " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Calls {@link #assertSame(java.lang.Object, java.lang.Object, java.lang.String)} with a default message.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertSame(Object, Object, String)
-     */
-    public static void assertSame(Object lhs, Object rhs) {
-        assertSame(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is the same as {@code rhs}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertSame(Object lhs, Object rhs, String msg) {
-        if (lhs != rhs) {
-            msg = Objects.toString(msg, "assertSame")
-                    + ": expected " + Objects.toString(lhs)
-                    + " to equal " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Shorthand for {@link #assertGreaterThanOrEqual(Comparable, Comparable)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertGreaterThanOrEqual(Comparable, Comparable)
-     */
-    public static <T extends Comparable<T>> void assertGTE(T lhs, T rhs) {
-        assertGreaterThanOrEqual(lhs, rhs);
-    }
-
-    /**
-     * Shorthand for {@link #assertGreaterThanOrEqual(Comparable, Comparable, String)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @see #assertGreaterThanOrEqual(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertGTE(T lhs, T rhs, String msg) {
-        assertGreaterThanOrEqual(lhs, rhs, msg);
-    }
-
-    /**
-     * Calls {@link #assertGreaterThanOrEqual(Comparable, Comparable, String)} with a default message.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertGreaterThanOrEqual(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertGreaterThanOrEqual(T lhs, T rhs) {
-        assertGreaterThanOrEqual(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is greater than or equal to {@code rhs}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static <T extends Comparable<T>> void assertGreaterThanOrEqual(T lhs, T rhs, String msg) {
-        if (!(compare(lhs, rhs, msg) >= 0)) {
-            msg = Objects.toString(msg, "assertGreaterThanOrEqual")
-                    + ": expected " + Objects.toString(lhs)
-                    + " >= " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Shorthand for {@link #assertGreaterThan(Comparable, Comparable)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertGreaterThan(Comparable, Comparable)
-     */
-    public static <T extends Comparable<T>> void assertGT(T lhs, T rhs) {
-        assertGreaterThan(lhs, rhs);
-    }
-
-    /**
-     * Shorthand for {@link #assertGreaterThan(Comparable, Comparable, String)}.
-     *
-     * @param <T> a type
-     * @param lhs the left hand value
-     * @param rhs the right hand value
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @see #assertGreaterThan(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertGT(T lhs, T rhs, String msg) {
-        assertGreaterThan(lhs, rhs, msg);
-    }
-
-    /**
-     * Calls {@link #assertGreaterThan(Comparable, Comparable, String)} with a default message.
-     *
-     * @param <T> a type
-     * @param lhs the left hand value
-     * @param rhs the right hand value
-     * @see #assertGreaterThan(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertGreaterThan(T lhs, T rhs) {
-        assertGreaterThan(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is greater than {@code rhs}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static <T extends Comparable<T>> void assertGreaterThan(T lhs, T rhs, String msg) {
-        if (!(compare(lhs, rhs, msg) > 0)) {
-            msg = Objects.toString(msg, "assertGreaterThan")
-                    + ": expected " + Objects.toString(lhs)
-                    + " > " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Shorthand for {@link #assertNotEquals(Object, Object)}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertNotEquals(Object, Object)
-     */
-    public static void assertNE(Object lhs, Object rhs) {
-        assertNotEquals(lhs, rhs);
-    }
-
-    /**
-     * Shorthand for {@link #assertNotEquals(Object, Object, String)}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @see #assertNotEquals(Object, Object, String)
-     */
-    public static void assertNE(Object lhs, Object rhs, String msg) {
-        assertNotEquals(lhs, rhs, msg);
-    }
-
-    /**
-     * Calls {@link #assertNotEquals(Object, Object, String)} with a default message.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertNotEquals(Object, Object, String)
-     */
-    public static void assertNotEquals(Object lhs, Object rhs) {
-        assertNotEquals(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is not equal to {@code rhs}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertNotEquals(Object lhs, Object rhs, String msg) {
-        if ((lhs == rhs) || (lhs != null && lhs.equals(rhs))) {
-            msg = Objects.toString(msg, "assertNotEquals")
-                    + ": expected " + Objects.toString(lhs)
-                    + " to not equal " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Calls {@link #assertNull(Object, String)} with a default message.
-     *
-     * @param o The reference assumed to be null.
-     * @see #assertNull(Object, String)
-     */
-    public static void assertNull(Object o) {
-        assertNull(o, null);
-    }
-
-    /**
-     * Asserts that {@code o} is null.
-     *
-     * @param o The reference assumed to be null.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertNull(Object o, String msg) {
-        assertEquals(o, null, msg);
-    }
-
-    /**
-     * Calls {@link #assertNotNull(Object, String)} with a default message.
-     *
-     * @param o The reference assumed <i>not</i> to be null,
-     * @see #assertNotNull(Object, String)
-     */
-    public static void assertNotNull(Object o) {
-        assertNotNull(o, null);
-    }
-
-    /**
-     * Asserts that {@code o} is <i>not</i> null.
-     *
-     * @param o The reference assumed <i>not</i> to be null,
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertNotNull(Object o, String msg) {
-        assertNotEquals(o, null, msg);
-    }
-
-    /**
-     * Calls {@link #assertFalse(boolean, String)} with a default message.
-     *
-     * @param value The value assumed to be false.
-     * @see #assertFalse(boolean, String)
-     */
-    public static void assertFalse(boolean value) {
-        assertFalse(value, null);
-    }
-
-    /**
-     * Asserts that {@code value} is {@code false}.
-     *
-     * @param value The value assumed to be false.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertFalse(boolean value, String msg) {
-        if (value) {
-            msg = Objects.toString(msg, "assertFalse")
-                    + ": expected false, was true";
-            fail(msg);
-        }
-    }
-
-    /**
-     * Calls {@link #assertTrue(boolean, String)} with a default message.
-     *
-     * @param value The value assumed to be true.
-     * @see #assertTrue(boolean, String)
-     */
-    public static void assertTrue(boolean value) {
-        assertTrue(value, null);
-    }
-
-    /**
-     * Asserts that {@code value} is {@code true}.
-     *
-     * @param value The value assumed to be true.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertTrue(boolean value, String msg) {
-        if (!value) {
-            msg = Objects.toString(msg, "assertTrue")
-                    + ": expected true, was false";
-            fail(msg);
-        }
-    }
-
-    private static <T extends Comparable<T>> int compare(T lhs, T rhs, String msg) {
-        if (lhs == null || rhs == null) {
-            fail(lhs, rhs, msg + ": values must be non-null:", ",");
-        }
-        return lhs.compareTo(rhs);
-    }
-
-    /**
-     * Returns a string formatted with a message and expected and actual values.
-     * @param lhs the actual value
-     * @param rhs  the expected value
-     * @param message the actual value
-     * @param relation the asserted relationship between lhs and rhs
-     * @return a formatted string
-     */
-    public static String format(Object lhs, Object rhs, String message, String relation) {
-        StringBuilder sb = new StringBuilder(80);
-        if (message != null) {
-            sb.append(message);
-            sb.append(' ');
-        }
-        sb.append("<");
-        sb.append(Objects.toString(lhs));
-        sb.append("> ");
-        sb.append(Objects.toString(relation, ","));
-        sb.append(" <");
-        sb.append(Objects.toString(rhs));
-        sb.append(">");
-        return sb.toString();
-    }
-
-    /**
-     * Fail reports a failure with message fail.
-     *
-     * @throws RuntimeException always
-     */
-    public static void fail() {
-        fail("fail");
-    }
-
-    /**
-     * Fail reports a failure with a message.
-     * @param message for the failure
-     * @throws RuntimeException always
-     */
-    public static void fail(String message) {
-        throw new RuntimeException(message);
-    }
-
-    /**
-     * Fail reports a failure with a formatted message.
-     *
-     * @param lhs the actual value
-     * @param rhs the expected value
-     * @param message to be format before the expected and actual values
-     * @param relation the asserted relationship between lhs and rhs
-     * @throws RuntimeException always
-     */
-    public static void fail(Object lhs, Object rhs, String message, String relation) {
-        throw new RuntimeException(format(lhs, rhs, message, relation));
-    }
-
-    /**
-     * Fail reports a failure with a message and a cause.
-     * @param message to be format before the expected and actual values
-     * @param cause the exception that caused this failure
-     * @throws RuntimeException always
-     */
-    public static void fail(String message, Throwable cause) {
-        throw new RuntimeException(message, cause);
-    }
-
-}
diff --git a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/JDKToolFinder.java b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/JDKToolFinder.java
deleted file mode 100644
index c481522..0000000
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/JDKToolFinder.java
+++ /dev/null
@@ -1,111 +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 jdk.testlibrary;
-
-import java.io.FileNotFoundException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib}
- */
-@Deprecated
-public final class JDKToolFinder {
-
-    private JDKToolFinder() {
-    }
-
-    /**
-     * Returns the full path to an executable in jdk/bin based on System
-     * property {@code test.jdk} or {@code compile.jdk} (both are set by the jtreg test suite)
-     *
-     * @return Full path to an executable in jdk/bin
-     */
-    public static String getJDKTool(String tool) {
-
-        // First try to find the executable in test.jdk
-        try {
-            return getTool(tool, "test.jdk");
-        } catch (FileNotFoundException e) {
-
-        }
-
-        // Now see if it's available in compile.jdk
-        try {
-            return getTool(tool, "compile.jdk");
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException("Failed to find " + tool +
-                    ", looked in test.jdk (" + System.getProperty("test.jdk") +
-                    ") and compile.jdk (" + System.getProperty("compile.jdk") + ")");
-        }
-    }
-
-    /**
-     * Returns the full path to an executable in jdk/bin based on System
-     * property {@code compile.jdk}
-     *
-     * @return Full path to an executable in jdk/bin
-     */
-    public static String getCompileJDKTool(String tool) {
-        try {
-            return getTool(tool, "compile.jdk");
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Returns the full path to an executable in jdk/bin based on System
-     * property {@code test.jdk}
-     *
-     * @return Full path to an executable in jdk/bin
-     */
-    public static String getTestJDKTool(String tool) {
-        try {
-            return getTool(tool, "test.jdk");
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    private static String getTool(String tool, String property) throws FileNotFoundException {
-        String jdkPath = System.getProperty(property);
-
-        if (jdkPath == null) {
-            throw new RuntimeException(
-                    "System property '" + property + "' not set. This property is normally set by jtreg. "
-                    + "When running test separately, set this property using '-D" + property + "=/path/to/jdk'.");
-        }
-
-        Path toolName = Paths.get("bin", tool + (Platform.isWindows() ? ".exe" : ""));
-
-        Path jdkTool = Paths.get(jdkPath, toolName.toString());
-        if (!jdkTool.toFile().exists()) {
-            throw new FileNotFoundException("Could not find file " + jdkTool.toAbsolutePath());
-        }
-
-        return jdkTool.toAbsolutePath().toString();
-    }
-}
diff --git a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/JDKToolLauncher.java b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/JDKToolLauncher.java
deleted file mode 100644
index 777e8cf..0000000
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/JDKToolLauncher.java
+++ /dev/null
@@ -1,136 +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 jdk.testlibrary;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * A utility for constructing command lines for starting JDK tool processes.
- *
- * The JDKToolLauncher can in particular be combined with a
- * java.lang.ProcessBuilder to easily run a JDK tool. For example, the following
- * code run {@code jmap -heap} against a process with GC logging turned on for
- * the {@code jmap} process:
- *
- * <pre>
- * {@code
- * JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
- *                                       .addVMArg("-Xlog:gc*=debug")
- *                                       .addToolArg("-heap")
- *                                       .addToolArg(pid);
- * ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
- * Process p = pb.start();
- * }
- * </pre>
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib}
- */
-@Deprecated
-public class JDKToolLauncher {
-    private final String executable;
-    private final List<String> vmArgs = new ArrayList<String>();
-    private final List<String> toolArgs = new ArrayList<String>();
-
-    private JDKToolLauncher(String tool, boolean useCompilerJDK) {
-        if (useCompilerJDK) {
-            executable = JDKToolFinder.getJDKTool(tool);
-        } else {
-            executable = JDKToolFinder.getTestJDKTool(tool);
-        }
-        vmArgs.addAll(Arrays.asList(ProcessTools.getPlatformSpecificVMArgs()));
-    }
-
-    /**
-     * Creates a new JDKToolLauncher for the specified tool. Using tools path
-     * from the compiler JDK.
-     *
-     * @param tool
-     *            The name of the tool
-     * @return A new JDKToolLauncher
-     */
-    public static JDKToolLauncher create(String tool) {
-        return new JDKToolLauncher(tool, true);
-    }
-
-    /**
-     * Creates a new JDKToolLauncher for the specified tool in the Tested JDK.
-     *
-     * @param tool
-     *            The name of the tool
-     *
-     * @return A new JDKToolLauncher
-     */
-    public static JDKToolLauncher createUsingTestJDK(String tool) {
-        return new JDKToolLauncher(tool, false);
-    }
-
-    /**
-     * Adds an argument to the JVM running the tool.
-     *
-     * The JVM arguments are passed to the underlying JVM running the tool.
-     * Arguments will automatically be prepended with "-J".
-     *
-     * Any platform specific arguments required for running the tool are
-     * automatically added.
-     *
-     *
-     * @param arg
-     *            The argument to VM running the tool
-     * @return The JDKToolLauncher instance
-     */
-    public JDKToolLauncher addVMArg(String arg) {
-        vmArgs.add(arg);
-        return this;
-    }
-
-    /**
-     * Adds an argument to the tool.
-     *
-     * @param arg
-     *            The argument to the tool
-     * @return The JDKToolLauncher instance
-     */
-    public JDKToolLauncher addToolArg(String arg) {
-        toolArgs.add(arg);
-        return this;
-    }
-
-    /**
-     * Returns the command that can be used for running the tool.
-     *
-     * @return An array whose elements are the arguments of the command.
-     */
-    public String[] getCommand() {
-        List<String> command = new ArrayList<String>();
-        command.add(executable);
-        // Add -J in front of all vmArgs
-        for (String arg : vmArgs) {
-            command.add("-J" + arg);
-        }
-        command.addAll(toolArgs);
-        return command.toArray(new String[command.size()]);
-    }
-}
diff --git a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/OutputAnalyzer.java b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/OutputAnalyzer.java
deleted file mode 100644
index 839c322..0000000
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/OutputAnalyzer.java
+++ /dev/null
@@ -1,576 +0,0 @@
-/*
- * 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
- * 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.testlibrary;
-
-import static jdk.testlibrary.Asserts.*;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Utility class for verifying output and exit value from a {@code Process}.
- *
- * @deprecated  This class is deprecated. Use the one from
- *              {@code <root>/test/lib/share/classes/jdk/test/lib/process}
- *
- */
-@Deprecated
-public final class OutputAnalyzer {
-    private final OutputBuffer output;
-    private final String stdout;
-    private final String stderr;
-    private final int exitValue;    // useless now. output contains exit value.
-
-    /**
-     * Create an OutputAnalyzer, a utility class for verifying output and exit
-     * value from a Process.
-     * <p>
-     * OutputAnalyzer should never be instantiated directly -
-     * use {@linkplain ProcessTools#executeProcess(ProcessBuilder)} instead
-     *
-     * @param process
-     *            Process to analyze
-     * @throws IOException
-     *             If an I/O error occurs.
-     */
-    OutputAnalyzer(Process process) throws IOException {
-        output = new OutputBuffer(process);
-        exitValue = -1;
-        this.stdout = null;
-        this.stderr = null;
-    }
-
-    /**
-     * Create an OutputAnalyzer, a utility class for verifying output.
-     *
-     * @param buf
-     *            String buffer to analyze
-     */
-    OutputAnalyzer(String buf) {
-        this(buf, buf);
-    }
-
-    /**
-     * Create an OutputAnalyzer, a utility class for verifying output
-     *
-     * @param stdout
-     *            stdout buffer to analyze
-     * @param stderr
-     *            stderr buffer to analyze
-     */
-    OutputAnalyzer(String stdout, String stderr) {
-        this.output = null;
-        this.stdout = stdout;
-        this.stderr = stderr;
-        exitValue = -1;
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer contains the
-     * string
-     *
-     * @param expectedString
-     *            String that buffer should contain
-     * @throws RuntimeException
-     *             If the string was not found
-     */
-    public OutputAnalyzer shouldContain(String expectedString) {
-        if (!getStdout().contains(expectedString)
-                && !getStderr().contains(expectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + expectedString
-                    + "' missing from stdout/stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer contains the string
-     *
-     * @param expectedString
-     *            String that buffer should contain
-     * @throws RuntimeException
-     *             If the string was not found
-     */
-    public OutputAnalyzer stdoutShouldContain(String expectedString) {
-        if (!getStdout().contains(expectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + expectedString
-                    + "' missing from stdout \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stderr contents of output buffer contains the string
-     *
-     * @param expectedString
-     *            String that buffer should contain
-     * @throws RuntimeException
-     *             If the string was not found
-     */
-    public OutputAnalyzer stderrShouldContain(String expectedString) {
-        if (!getStderr().contains(expectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + expectedString
-                    + "' missing from stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer does not
-     * contain the string
-     *
-     * @param notExpectedString
-     *            String that the buffer should not contain
-     * @throws RuntimeException
-     *             If the string was found
-     */
-    public OutputAnalyzer shouldNotContain(String notExpectedString) {
-        if (getStdout().contains(notExpectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + notExpectedString
-                    + "' found in stdout \n");
-        }
-        if (getStderr().contains(notExpectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + notExpectedString
-                    + "' found in stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer does not contain the
-     * string
-     *
-     * @param notExpectedString
-     *            String that the buffer should not contain
-     * @throws RuntimeException
-     *             If the string was found
-     */
-    public OutputAnalyzer stdoutShouldNotContain(String notExpectedString) {
-        if (getStdout().contains(notExpectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + notExpectedString
-                    + "' found in stdout \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stderr contents of output buffer does not contain the
-     * string
-     *
-     * @param notExpectedString
-     *            String that the buffer should not contain
-     * @throws RuntimeException
-     *             If the string was found
-     */
-    public OutputAnalyzer stderrShouldNotContain(String notExpectedString) {
-        if (getStderr().contains(notExpectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + notExpectedString
-                    + "' found in stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer matches the
-     * pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was not found
-     */
-    public OutputAnalyzer shouldMatch(String pattern) {
-        Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE)
-                .matcher(getStdout());
-        Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE)
-                .matcher(getStderr());
-        if (!stdoutMatcher.find() && !stderrMatcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
-                    + "' missing from stdout/stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer matches the pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was not found
-     */
-    public OutputAnalyzer stdoutShouldMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStdout());
-        if (!matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
-                    + "' missing from stdout \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stderr contents of output buffer matches the pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was not found
-     */
-    public OutputAnalyzer stderrShouldMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStderr());
-        if (!matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
-                    + "' missing from stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer does not
-     * match the pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was found
-     */
-    public OutputAnalyzer shouldNotMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStdout());
-        if (matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern + "' found in stdout: '"
-                    + matcher.group() + "' \n");
-        }
-        matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(getStderr());
-        if (matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern + "' found in stderr: '"
-                    + matcher.group() + "' \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer does not match the
-     * pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was found
-     */
-    public OutputAnalyzer stdoutShouldNotMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStdout());
-        if (matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern + "' found in stdout \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stderr contents of output buffer does not match the
-     * pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was found
-     */
-    public OutputAnalyzer stderrShouldNotMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStderr());
-        if (matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern + "' found in stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Get the captured group of the first string matching the pattern. stderr
-     * is searched before stdout.
-     *
-     * @param pattern
-     *            The multi-line pattern to match
-     * @param group
-     *            The group to capture
-     * @return The matched string or null if no match was found
-     */
-    public String firstMatch(String pattern, int group) {
-        Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE)
-                .matcher(getStderr());
-        Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE)
-                .matcher(getStdout());
-        if (stderrMatcher.find()) {
-            return stderrMatcher.group(group);
-        }
-        if (stdoutMatcher.find()) {
-            return stdoutMatcher.group(group);
-        }
-        return null;
-    }
-
-    /**
-     * Get the first string matching the pattern. stderr is searched before
-     * stdout.
-     *
-     * @param pattern
-     *            The multi-line pattern to match
-     * @return The matched string or null if no match was found
-     */
-    public String firstMatch(String pattern) {
-        return firstMatch(pattern, 0);
-    }
-
-    /**
-     * Verify the exit value of the process
-     *
-     * @param expectedExitValue
-     *            Expected exit value from process
-     * @throws RuntimeException
-     *             If the exit value from the process did not match the expected
-     *             value
-     */
-    public OutputAnalyzer shouldHaveExitValue(int expectedExitValue) {
-        if (getExitValue() != expectedExitValue) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("Expected to get exit value of ["
-                    + expectedExitValue + "]\n");
-        }
-        return this;
-    }
-
-    /**
-     * Report summary that will help to diagnose the problem Currently includes:
-     * - standard input produced by the process under test - standard output -
-     * exit code Note: the command line is printed by the ProcessTools
-     */
-    private OutputAnalyzer reportDiagnosticSummary() {
-        String msg = " stdout: [" + getStdout() + "];\n" + " stderr: [" + getStderr()
-                + "]\n" + " exitValue = " + getExitValue() + "\n";
-
-        System.err.println(msg);
-        return this;
-    }
-
-    /**
-     * Get the contents of the output buffer (stdout and stderr)
-     *
-     * @return Content of the output buffer
-     */
-    public String getOutput() {
-        return getStdout() + getStderr();
-    }
-
-    /**
-     * Get the contents of the stdout buffer
-     *
-     * @return Content of the stdout buffer
-     */
-    public String getStdout() {
-        return output == null ? stdout : output.getStdout();
-    }
-
-    /**
-     * Get the contents of the stderr buffer
-     *
-     * @return Content of the stderr buffer
-     */
-    public String getStderr() {
-        return output == null ? stderr : output.getStderr();
-    }
-
-    /**
-     * Get the process exit value
-     *
-     * @return Process exit value
-     */
-    public int getExitValue() {
-        return output == null ? exitValue : output.getExitValue();
-    }
-
-
-    /**
-     * 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) as list of strings.
-     * Output will be split by system property 'line.separator'.
-     *
-     * @return Contents of the output buffer as list of strings
-     */
-    public List<String> asLines() {
-        return asLines(getOutput());
-    }
-
-    private List<String> asLines(String buffer) {
-        List<String> l = new ArrayList<>();
-        String[] a = buffer.split(Utils.NEW_LINE);
-        for (String string : a) {
-            l.add(string);
-        }
-        return l;
-    }
-
-    /**
-     * Check if there is a line matching {@code pattern} and return its index
-     *
-     * @param pattern Matching pattern
-     * @return Index of first matching line
-     */
-    private int indexOf(List<String> lines, String pattern) {
-        for (int i = 0; i < lines.size(); i++) {
-            if (lines.get(i).matches(pattern)) {
-                return i;
-            }
-        }
-        return -1;
-    }
-
-    /**
-     * @see #shouldMatchByLine(String, String, String)
-     */
-    public int shouldMatchByLine(String pattern) {
-        return shouldMatchByLine(null, null, pattern);
-    }
-
-    /**
-     * @see #stdoutShouldMatchByLine(String, String, String)
-     */
-    public int stdoutShouldMatchByLine(String pattern) {
-        return stdoutShouldMatchByLine(null, null, pattern);
-    }
-
-    /**
-     * @see #shouldMatchByLine(String, String, String)
-     */
-    public int shouldMatchByLineFrom(String from, String pattern) {
-        return shouldMatchByLine(from, null, pattern);
-    }
-
-    /**
-     * @see #shouldMatchByLine(String, String, String)
-     */
-    public int shouldMatchByLineTo(String to, String pattern) {
-        return shouldMatchByLine(null, to, pattern);
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer match the
-     * {@code pattern} line by line. The whole output could be matched or
-     * just a subset of it.
-     *
-     * @param from
-     *            The line from where output will be matched.
-     *            Set {@code from} to null for matching from the first line.
-     * @param to
-     *            The line until where output will be matched.
-     *            Set {@code to} to null for matching until the last line.
-     * @param pattern
-     *            Matching pattern
-     * @return Count of lines which match the {@code pattern}
-     */
-    public int shouldMatchByLine(String from, String to, String pattern) {
-        return shouldMatchByLine(getOutput(), from, to, pattern);
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer matches the
-     * {@code pattern} line by line. The whole stdout could be matched or
-     * just a subset of it.
-     *
-     * @param from
-     *            The line from where stdout will be matched.
-     *            Set {@code from} to null for matching from the first line.
-     * @param to
-     *            The line until where stdout will be matched.
-     *            Set {@code to} to null for matching until the last line.
-     * @param pattern
-     *            Matching pattern
-     * @return Count of lines which match the {@code pattern}
-     */
-    public int stdoutShouldMatchByLine(String from, String to, String pattern) {
-        return shouldMatchByLine(getStdout(), from, to, pattern);
-    }
-
-    private int shouldMatchByLine(String buffer, String from, String to, String pattern) {
-        List<String> lines = asLines(buffer);
-
-        int fromIndex = 0;
-        if (from != null) {
-            fromIndex = indexOf(lines, from);
-            assertGreaterThan(fromIndex, -1,
-                    "The line/pattern '" + from + "' from where the output should match can not be found");
-        }
-
-        int toIndex = lines.size();
-        if (to != null) {
-            toIndex = indexOf(lines, to);
-            assertGreaterThan(toIndex, -1,
-                    "The line/pattern '" + to + "' until where the output should match can not be found");
-        }
-
-        List<String> subList = lines.subList(fromIndex, toIndex);
-        int matchedCount = 0;
-        for (String line : subList) {
-            assertTrue(line.matches(pattern),
-                    "The line '" + line + "' does not match pattern '" + pattern + "'");
-            matchedCount++;
-        }
-
-        return matchedCount;
-    }
-
-}
diff --git a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/OutputBuffer.java b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/OutputBuffer.java
deleted file mode 100644
index c8a5d7a..0000000
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/OutputBuffer.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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
- * 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.testlibrary;
-
-import java.io.ByteArrayOutputStream;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib/process}
- */
-@Deprecated
-class OutputBuffer {
-    private static class OutputBufferException extends RuntimeException {
-        private static final long serialVersionUID = 8528687792643129571L;
-
-        public OutputBufferException(Throwable cause) {
-            super(cause);
-        }
-    }
-
-    private final Process p;
-    private final Future<Void> outTask;
-    private final Future<Void> errTask;
-    private final ByteArrayOutputStream stderrBuffer = new ByteArrayOutputStream();
-    private final ByteArrayOutputStream stdoutBuffer = new ByteArrayOutputStream();
-
-    /**
-     * Create an OutputBuffer, a class for storing and managing stdout and
-     * stderr results separately
-     *
-     * @param stdout
-     *            stdout result
-     * @param stderr
-     *            stderr result
-     */
-    OutputBuffer(Process p) {
-        this.p = p;
-        StreamPumper outPumper = new StreamPumper(p.getInputStream(),
-                stdoutBuffer);
-        StreamPumper errPumper = new StreamPumper(p.getErrorStream(),
-                stderrBuffer);
-
-        outTask = outPumper.process();
-        errTask = errPumper.process();
-    }
-
-    /**
-     * Returns the stdout result
-     *
-     * @return stdout result
-     */
-    public String getStdout() {
-        try {
-            outTask.get();
-            return stdoutBuffer.toString();
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-            throw new OutputBufferException(e);
-        } catch (ExecutionException | CancellationException e) {
-            throw new OutputBufferException(e);
-        }
-    }
-
-    /**
-     * Returns the stderr result
-     *
-     * @return stderr result
-     */
-    public String getStderr() {
-        try {
-            errTask.get();
-            return stderrBuffer.toString();
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-            throw new OutputBufferException(e);
-        } catch (ExecutionException | CancellationException e) {
-            throw new OutputBufferException(e);
-        }
-    }
-
-    public int getExitValue() {
-        try {
-            return p.waitFor();
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-            throw new OutputBufferException(e);
-        }
-    }
-}
diff --git a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/Platform.java b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/Platform.java
deleted file mode 100644
index 523e6e6..0000000
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/Platform.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * 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
- * 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.testlibrary;
-import java.util.regex.Pattern;
-import java.io.RandomAccessFile;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib}
- */
-@Deprecated
-public class Platform {
-    private static final String osName      = System.getProperty("os.name");
-    private static final String dataModel   = System.getProperty("sun.arch.data.model");
-    private static final String vmVersion   = System.getProperty("java.vm.version");
-    private static final String jdkDebug    = System.getProperty("jdk.debug");
-    private static final String osArch      = System.getProperty("os.arch");
-    private static final String vmName      = System.getProperty("java.vm.name");
-    private static final String userName    = System.getProperty("user.name");
-    private static final String compiler    = System.getProperty("sun.management.compiler");
-
-    public static boolean isClient() {
-        return vmName.endsWith(" Client VM");
-    }
-
-    public static boolean isServer() {
-        return vmName.endsWith(" Server VM");
-    }
-
-    public static boolean isGraal() {
-        return vmName.endsWith(" Graal VM");
-    }
-
-    public static boolean isMinimal() {
-        return vmName.endsWith(" Minimal VM");
-    }
-
-    public static boolean isEmbedded() {
-        return vmName.contains("Embedded");
-    }
-
-    public static boolean isTieredSupported() {
-        return compiler.contains("Tiered Compilers");
-    }
-
-
-    public static boolean is32bit() {
-        return dataModel.equals("32");
-    }
-
-    public static boolean is64bit() {
-        return dataModel.equals("64");
-    }
-
-    public static boolean isAix() {
-        return isOs("aix");
-    }
-
-    public static boolean isLinux() {
-        return isOs("linux");
-    }
-
-    public static boolean isOSX() {
-        return isOs("mac");
-    }
-
-    public static boolean isSolaris() {
-        return isOs("sunos");
-    }
-
-    public static boolean isWindows() {
-        return isOs("win");
-    }
-
-    private static boolean isOs(String osname) {
-        return osName.toLowerCase().startsWith(osname.toLowerCase());
-    }
-
-    public static String getOsName() {
-        return osName;
-    }
-
-    public static boolean isDebugBuild() {
-        return (jdkDebug.toLowerCase().contains("debug"));
-    }
-
-    public static String getVMVersion() {
-        return vmVersion;
-    }
-
-    // Returns true for sparc and sparcv9.
-    public static boolean isSparc() {
-        return isArch("sparc.*");
-    }
-
-    public static boolean isARM() {
-        return isArch("arm.*");
-    }
-
-    public static boolean isPPC() {
-        return isArch("ppc.*");
-    }
-
-    public static boolean isX86() {
-        // On Linux it's 'i386', Windows 'x86' without '_64' suffix.
-        return isArch("(i386)|(x86(?!_64))");
-    }
-
-    public static boolean isX64() {
-        // On OSX it's 'x86_64' and on other (Linux, Windows and Solaris) platforms it's 'amd64'
-        return isArch("(amd64)|(x86_64)");
-    }
-
-    private static boolean isArch(String archnameRE) {
-        return Pattern.compile(archnameRE, Pattern.CASE_INSENSITIVE)
-                .matcher(osArch)
-                .matches();
-    }
-
-    public static String getOsArch() {
-        return osArch;
-    }
-
-    /**
-     * Return a boolean for whether we expect to be able to attach
-     * the SA to our own processes on this system.
-     */
-    public static boolean shouldSAAttach()
-                               throws IOException {
-
-        if (isAix()) {
-            return false;   // SA not implemented.
-        } else if (isLinux()) {
-            return canPtraceAttachLinux();
-        } else if (isOSX()) {
-            return canAttachOSX();
-        } else {
-            // Other platforms expected to work:
-            return true;
-        }
-    }
-
-    /**
-     * On Linux, first check the SELinux boolean "deny_ptrace" and return false
-     * as we expect to be denied if that is "1".
-     */
-    public static boolean canPtraceAttachLinux()
-                               throws IOException {
-
-        // SELinux deny_ptrace:
-        try(RandomAccessFile file = new RandomAccessFile("/sys/fs/selinux/booleans/deny_ptrace", "r")) {
-            if (file.readByte() != '0') {
-                return false;
-            }
-        }
-        catch(FileNotFoundException ex) {
-            // Ignored
-        }
-
-        // YAMA enhanced security ptrace_scope:
-        // 0 - a process can PTRACE_ATTACH to any other process running under the same uid
-        // 1 - restricted ptrace: a process must be a children of the inferior or user is root
-        // 2 - only processes with CAP_SYS_PTRACE may use ptrace or user is root
-        // 3 - no attach: no processes may use ptrace with PTRACE_ATTACH
-
-        try(RandomAccessFile file = new RandomAccessFile("/proc/sys/kernel/yama/ptrace_scope", "r")) {
-            byte yama_scope = file.readByte();
-            if (yama_scope == '3') {
-                return false;
-            }
-
-            if (!userName.equals("root") && yama_scope != '0') {
-                return false;
-            }
-        }
-        catch(FileNotFoundException ex) {
-            // Ignored
-        }
-
-        // Otherwise expect to be permitted:
-        return true;
-    }
-
-    /**
-     * On OSX, expect permission to attach only if we are root.
-     */
-    public static boolean canAttachOSX() {
-        return userName.equals("root");
-    }
-}
diff --git a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/ProcessTools.java b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/ProcessTools.java
deleted file mode 100644
index c3abe59..0000000
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/ProcessTools.java
+++ /dev/null
@@ -1,579 +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 jdk.testlibrary;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.concurrent.CountDownLatch;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.function.Predicate;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib/process}
- */
-@Deprecated
-public final class ProcessTools {
-    private static final class LineForwarder extends StreamPumper.LinePump {
-        private final PrintStream ps;
-        private final String prefix;
-        LineForwarder(String prefix, PrintStream os) {
-            this.ps = os;
-            this.prefix = prefix;
-        }
-        @Override
-        protected void processLine(String line) {
-            ps.println("[" + prefix + "] " + line);
-        }
-    }
-
-    private ProcessTools() {
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * @param name The process name
-     * @param processBuilder The process builder
-     * @return Returns the initialized process
-     * @throws IOException
-     */
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder)
-    throws IOException {
-        return startProcess(name, processBuilder, (Consumer<String>)null);
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * <p>It is possible to monitor the in-streams via the provided {@code consumer}
-     * @param name The process name
-     * @param consumer {@linkplain Consumer} instance to process the in-streams
-     * @param processBuilder The process builder
-     * @return Returns the initialized process
-     * @throws IOException
-     */
-    @SuppressWarnings("overloads")
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder,
-                                       Consumer<String> consumer)
-    throws IOException {
-        try {
-            return startProcess(name, processBuilder, consumer, null, -1, TimeUnit.NANOSECONDS);
-        } catch (InterruptedException | TimeoutException e) {
-            // will never happen
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * <p>
-     * It is possible to wait for the process to get to a warmed-up state
-     * via {@linkplain Predicate} condition on the STDOUT
-     * </p>
-     * @param name The process name
-     * @param processBuilder The process builder
-     * @param linePredicate The {@linkplain Predicate} to use on the STDOUT
-     *                      Used to determine the moment the target app is
-     *                      properly warmed-up.
-     *                      It can be null - in that case the warmup is skipped.
-     * @param timeout The timeout for the warmup waiting; -1 = no wait; 0 = wait forever
-     * @param unit The timeout {@linkplain TimeUnit}
-     * @return Returns the initialized {@linkplain Process}
-     * @throws IOException
-     * @throws InterruptedException
-     * @throws TimeoutException
-     */
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder,
-                                       final Predicate<String> linePredicate,
-                                       long timeout,
-                                       TimeUnit unit)
-    throws IOException, InterruptedException, TimeoutException {
-        return startProcess(name, processBuilder, null, linePredicate, timeout, unit);
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * <p>
-     * It is possible to wait for the process to get to a warmed-up state
-     * via {@linkplain Predicate} condition on the STDOUT and monitor the
-     * in-streams via the provided {@linkplain Consumer}
-     * </p>
-     * @param name The process name
-     * @param processBuilder The process builder
-     * @param lineConsumer  The {@linkplain Consumer} the lines will be forwarded to
-     * @param linePredicate The {@linkplain Predicate} to use on the STDOUT
-     *                      Used to determine the moment the target app is
-     *                      properly warmed-up.
-     *                      It can be null - in that case the warmup is skipped.
-     * @param timeout The timeout for the warmup waiting; -1 = no wait; 0 = wait forever
-     * @param unit The timeout {@linkplain TimeUnit}
-     * @return Returns the initialized {@linkplain Process}
-     * @throws IOException
-     * @throws InterruptedException
-     * @throws TimeoutException
-     */
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder,
-                                       final Consumer<String> lineConsumer,
-                                       final Predicate<String> linePredicate,
-                                       long timeout,
-                                       TimeUnit unit)
-    throws IOException, InterruptedException, TimeoutException {
-        System.out.println("["+name+"]:" + processBuilder.command().stream().collect(Collectors.joining(" ")));
-        Process p = processBuilder.start();
-        StreamPumper stdout = new StreamPumper(p.getInputStream());
-        StreamPumper stderr = new StreamPumper(p.getErrorStream());
-
-        stdout.addPump(new LineForwarder(name, System.out));
-        stderr.addPump(new LineForwarder(name, System.err));
-        if (lineConsumer != null) {
-            StreamPumper.LinePump pump = new StreamPumper.LinePump() {
-                @Override
-                protected void processLine(String line) {
-                    lineConsumer.accept(line);
-                }
-            };
-            stdout.addPump(pump);
-            stderr.addPump(pump);
-        }
-
-
-        CountDownLatch latch = new CountDownLatch(1);
-        if (linePredicate != null) {
-            StreamPumper.LinePump pump = new StreamPumper.LinePump() {
-                @Override
-                protected void processLine(String line) {
-                    if (latch.getCount() > 0 && linePredicate.test(line)) {
-                        latch.countDown();
-                    }
-                }
-            };
-            stdout.addPump(pump);
-            stderr.addPump(pump);
-        } else {
-            latch.countDown();
-        }
-        final Future<Void> stdoutTask = stdout.process();
-        final Future<Void> stderrTask = stderr.process();
-
-        try {
-            if (timeout > -1) {
-                if (timeout == 0) {
-                    latch.await();
-                } else {
-                    if (!latch.await(Utils.adjustTimeout(timeout), unit)) {
-                        throw new TimeoutException();
-                    }
-                }
-            }
-        } catch (TimeoutException | InterruptedException e) {
-            System.err.println("Failed to start a process (thread dump follows)");
-            for(Map.Entry<Thread, StackTraceElement[]> s : Thread.getAllStackTraces().entrySet()) {
-                printStack(s.getKey(), s.getValue());
-            }
-
-            if (p.isAlive()) {
-                p.destroyForcibly();
-            }
-
-            stdoutTask.cancel(true);
-            stderrTask.cancel(true);
-            throw e;
-        }
-
-        return new ProcessImpl(p, stdoutTask, stderrTask);
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * <p>
-     * It is possible to wait for the process to get to a warmed-up state
-     * via {@linkplain Predicate} condition on the STDOUT. The warm-up will
-     * wait indefinitely.
-     * </p>
-     * @param name The process name
-     * @param processBuilder The process builder
-     * @param linePredicate The {@linkplain Predicate} to use on the STDOUT
-     *                      Used to determine the moment the target app is
-     *                      properly warmed-up.
-     *                      It can be null - in that case the warmup is skipped.
-     * @return Returns the initialized {@linkplain Process}
-     * @throws IOException
-     * @throws InterruptedException
-     * @throws TimeoutException
-     */
-    @SuppressWarnings("overloads")
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder,
-                                       final Predicate<String> linePredicate)
-    throws IOException, InterruptedException, TimeoutException {
-        return startProcess(name, processBuilder, linePredicate, 0, TimeUnit.SECONDS);
-    }
-
-    /**
-     * Get the process id of the current running Java process
-     *
-     * @return Process id
-     */
-    public static long getProcessId() {
-        return ProcessHandle.current().pid();
-    }
-
-    /**
-     * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris)
-     *
-     * @return String[] with platform specific arguments, empty if there are
-     *         none
-     */
-    public static String[] getPlatformSpecificVMArgs() {
-        String osName = System.getProperty("os.name");
-        String dataModel = System.getProperty("sun.arch.data.model");
-
-        if (osName.equals("SunOS") && dataModel.equals("64")) {
-            return new String[] { "-d64" };
-        }
-
-        return new String[] {};
-    }
-
-    /**
-     * Create ProcessBuilder using the java launcher from the jdk to be tested,
-     * and with any platform specific arguments prepended.
-     *
-     * @param command Arguments to pass to the java command.
-     * @return The ProcessBuilder instance representing the java command.
-     */
-    public static ProcessBuilder createJavaProcessBuilder(String... command)
-            throws Exception {
-        return createJavaProcessBuilder(false, command);
-    }
-
-    /**
-     * Create ProcessBuilder using the java launcher from the jdk to be tested,
-     * and with any platform specific arguments prepended.
-     *
-     * @param addTestVmAndJavaOptions If true, adds test.vm.opts and test.java.opts
-     *        to the java arguments.
-     * @param command Arguments to pass to the java command.
-     * @return The ProcessBuilder instance representing the java command.
-     */
-    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) throws Exception {
-        String javapath = JDKToolFinder.getJDKTool("java");
-
-        ArrayList<String> args = new ArrayList<>();
-        args.add(javapath);
-        Collections.addAll(args, getPlatformSpecificVMArgs());
-
-        if (addTestVmAndJavaOptions) {
-            // -cp is needed to make sure the same classpath is used whether the test is
-            // run in AgentVM mode or OtherVM mode. It was added to the hotspot version
-            // of this API as part of 8077608. However, for the jdk version it is only
-            // added when addTestVmAndJavaOptions is true in order to minimize
-            // disruption to existing JDK tests, which have yet to be tested with -cp
-            // being added. At some point -cp should always be added to be consistent
-            // with what the hotspot version does.
-            args.add("-cp");
-            args.add(System.getProperty("java.class.path"));
-            Collections.addAll(args, Utils.getTestJavaOpts());
-        }
-
-        Collections.addAll(args, command);
-
-        // Reporting
-        StringBuilder cmdLine = new StringBuilder();
-        for (String cmd : args)
-            cmdLine.append(cmd).append(' ');
-        System.out.println("Command line: [" + cmdLine.toString() + "]");
-
-        return new ProcessBuilder(args.toArray(new String[args.size()]));
-    }
-
-    private static void printStack(Thread t, StackTraceElement[] stack) {
-        System.out.println("\t" +  t +
-                           " stack: (length = " + stack.length + ")");
-        if (t != null) {
-            for (StackTraceElement stack1 : stack) {
-                System.out.println("\t" + stack1);
-            }
-            System.out.println();
-        }
-    }
-
-    /**
-     * Executes a test java process, waits for it to finish and returns the process output.
-     * The default options from jtreg, test.vm.opts and test.java.opts, are added.
-     * The java from the test.jdk is used to execute the command.
-     *
-     * The command line will be like:
-     * {test.jdk}/bin/java {test.vm.opts} {test.java.opts} cmds
-     *
-     * The java process will have exited before this method returns.
-     *
-     * @param cmds User specifed arguments.
-     * @return The output from the process.
-     */
-    public static OutputAnalyzer executeTestJava(String... options) throws Exception {
-        ProcessBuilder pb = createJavaProcessBuilder(Utils.addTestJavaOpts(options));
-        return executeProcess(pb);
-    }
-
-    /**
-     * @deprecated Use executeTestJava instead
-     */
-    public static OutputAnalyzer executeTestJvm(String... options) throws Exception {
-        return executeTestJava(options);
-    }
-
-    /**
-     * 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.
-     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
-     */
-    public static OutputAnalyzer executeProcess(ProcessBuilder pb) throws Exception {
-        return executeProcess(pb, null);
-    }
-
-    /**
-     * Executes a process, pipe some text into its STDIN, 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.
-     * @param input The text to pipe into STDIN. Can be null.
-     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
-     */
-    public static OutputAnalyzer executeProcess(ProcessBuilder pb, String input)
-            throws Exception {
-        OutputAnalyzer output = null;
-        Process p = null;
-        boolean failed = false;
-        try {
-            p = pb.start();
-            if (input != null) {
-                try (OutputStream os = p.getOutputStream();
-                        PrintStream ps = new PrintStream(os)) {
-                    ps.print(input);
-                    ps.flush();
-                }
-            }
-            output = new OutputAnalyzer(p);
-            p.waitFor();
-
-            return output;
-        } catch (Throwable t) {
-            if (p != null) {
-                p.destroyForcibly().waitFor();
-            }
-
-            failed = true;
-            System.out.println("executeProcess() failed: " + t);
-            throw t;
-        } finally {
-            if (failed) {
-                System.err.println(getProcessLog(pb, output));
-            }
-        }
-    }
-
-    /**
-     * Executes a process, waits for it to finish and returns the process output.
-     *
-     * The process will have exited before this method returns.
-     *
-     * @param cmds The command line to execute.
-     * @return The output from the process.
-     */
-    public static OutputAnalyzer executeProcess(String... cmds) throws Throwable {
-        return executeProcess(new ProcessBuilder(cmds));
-    }
-
-    /**
-     * Used to log command line, stdout, stderr and exit code from an executed process.
-     * @param pb The executed process.
-     * @param output The output from the process.
-     */
-    public static String getProcessLog(ProcessBuilder pb, OutputAnalyzer output) {
-        String stderr = output == null ? "null" : output.getStderr();
-        String stdout = output == null ? "null" : output.getStdout();
-        String exitValue = output == null ? "null": Integer.toString(output.getExitValue());
-        StringBuilder logMsg = new StringBuilder();
-        final String nl = System.getProperty("line.separator");
-        logMsg.append("--- ProcessLog ---" + nl);
-        logMsg.append("cmd: " + getCommandLine(pb) + nl);
-        logMsg.append("exitvalue: " + exitValue + nl);
-        logMsg.append("stderr: " + stderr + nl);
-        logMsg.append("stdout: " + stdout + nl);
-
-        return logMsg.toString();
-    }
-
-    /**
-     * @return The full command line for the ProcessBuilder.
-     */
-    public static String getCommandLine(ProcessBuilder pb) {
-        if (pb == null) {
-            return "null";
-        }
-        StringBuilder cmd = new StringBuilder();
-        for (String s : pb.command()) {
-            cmd.append(s).append(" ");
-        }
-        return cmd.toString().trim();
-    }
-
-    /**
-     * Executes a process, waits for it to finish, prints the process output
-     * to stdout, and returns the process output.
-     *
-     * The process will have exited before this method returns.
-     *
-     * @param cmds The command line to execute.
-     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
-     */
-    public static OutputAnalyzer executeCommand(String... cmds)
-            throws Throwable {
-        String cmdLine = Arrays.stream(cmds).collect(Collectors.joining(" "));
-        System.out.println("Command line: [" + cmdLine + "]");
-        OutputAnalyzer analyzer = ProcessTools.executeProcess(cmds);
-        System.out.println(analyzer.getOutput());
-        return analyzer;
-    }
-
-    /**
-     * Executes a process, waits for it to finish, prints the process output
-     * to stdout and returns the process output.
-     *
-     * The process will have exited before this method returns.
-     *
-     * @param pb The ProcessBuilder to execute.
-     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
-     */
-    public static OutputAnalyzer executeCommand(ProcessBuilder pb)
-            throws Throwable {
-        String cmdLine = pb.command().stream().collect(Collectors.joining(" "));
-        System.out.println("Command line: [" + cmdLine + "]");
-        OutputAnalyzer analyzer = ProcessTools.executeProcess(pb);
-        System.out.println(analyzer.getOutput());
-        return analyzer;
-    }
-
-    private static class ProcessImpl extends Process {
-
-        private final Process p;
-        private final Future<Void> stdoutTask;
-        private final Future<Void> stderrTask;
-
-        public ProcessImpl(Process p, Future<Void> stdoutTask, Future<Void> stderrTask) {
-            this.p = p;
-            this.stdoutTask = stdoutTask;
-            this.stderrTask = stderrTask;
-        }
-
-        @Override
-        public OutputStream getOutputStream() {
-            return p.getOutputStream();
-        }
-
-        @Override
-        public InputStream getInputStream() {
-            return p.getInputStream();
-        }
-
-        @Override
-        public InputStream getErrorStream() {
-            return p.getErrorStream();
-        }
-
-        @Override
-        public int waitFor() throws InterruptedException {
-            int rslt = p.waitFor();
-            waitForStreams();
-            return rslt;
-        }
-
-        @Override
-        public int exitValue() {
-            return p.exitValue();
-        }
-
-        @Override
-        public void destroy() {
-            p.destroy();
-        }
-
-        @Override
-        public long pid() {
-            return p.pid();
-        }
-
-        @Override
-        public boolean isAlive() {
-            return p.isAlive();
-        }
-
-        @Override
-        public Process destroyForcibly() {
-            return p.destroyForcibly();
-        }
-
-        @Override
-        public boolean waitFor(long timeout, TimeUnit unit) throws InterruptedException {
-            boolean rslt = p.waitFor(timeout, unit);
-            if (rslt) {
-                waitForStreams();
-            }
-            return rslt;
-        }
-
-        private void waitForStreams() throws InterruptedException {
-            try {
-                stdoutTask.get();
-            } catch (ExecutionException e) {
-            }
-            try {
-                stderrTask.get();
-            } catch (ExecutionException e) {
-            }
-        }
-    }
-}
diff --git a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/README.txt b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/README.txt
deleted file mode 100644
index c4fd572..0000000
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/README.txt
+++ /dev/null
@@ -1 +0,0 @@
-These files are copies of the corresponding files in test/lib/testlibrary/ from jdk repo.
diff --git a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/StreamPumper.java b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/StreamPumper.java
deleted file mode 100644
index 2f3c205..0000000
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/StreamPumper.java
+++ /dev/null
@@ -1,204 +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 jdk.testlibrary;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.Future;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib/process}
- */
-@Deprecated
-public final class StreamPumper implements Runnable {
-
-    private static final int BUF_SIZE = 256;
-
-    /**
-     * Pump will be called by the StreamPumper to process the incoming data
-     */
-    abstract public static class Pump {
-        abstract void register(StreamPumper d);
-    }
-
-    /**
-     * OutputStream -> Pump adapter
-     */
-    final public static class StreamPump extends Pump {
-        private final OutputStream out;
-        public StreamPump(OutputStream out) {
-            this.out = out;
-        }
-
-        @Override
-        void register(StreamPumper sp) {
-            sp.addOutputStream(out);
-        }
-    }
-
-    /**
-     * Used to process the incoming data line-by-line
-     */
-    abstract public static class LinePump extends Pump {
-        @Override
-        final void register(StreamPumper sp) {
-            sp.addLineProcessor(this);
-        }
-
-        abstract protected void processLine(String line);
-    }
-
-    private final InputStream in;
-    private final Set<OutputStream> outStreams = new HashSet<>();
-    private final Set<LinePump> linePumps = new HashSet<>();
-
-    private final AtomicBoolean processing = new AtomicBoolean(false);
-    private final FutureTask<Void> processingTask = new FutureTask<>(this, null);
-
-    public StreamPumper(InputStream in) {
-        this.in = in;
-    }
-
-    /**
-     * Create a StreamPumper that reads from in and writes to out.
-     *
-     * @param in
-     *            The stream to read from.
-     * @param out
-     *            The stream to write to.
-     */
-    public StreamPumper(InputStream in, OutputStream out) {
-        this(in);
-        this.addOutputStream(out);
-    }
-
-    /**
-     * Implements Thread.run(). Continuously read from {@code in} and write to
-     * {@code out} until {@code in} has reached end of stream. Abort on
-     * interruption. Abort on IOExceptions.
-     */
-    @Override
-    public void run() {
-        try (BufferedInputStream is = new BufferedInputStream(in)) {
-            ByteArrayOutputStream lineBos = new ByteArrayOutputStream();
-            byte[] buf = new byte[BUF_SIZE];
-            int len = 0;
-            int linelen = 0;
-
-            while ((len = is.read(buf)) > 0 && !Thread.interrupted()) {
-                for(OutputStream out : outStreams) {
-                    out.write(buf, 0, len);
-                }
-                if (!linePumps.isEmpty()) {
-                    int i = 0;
-                    int lastcrlf = -1;
-                    while (i < len) {
-                        if (buf[i] == '\n' || buf[i] == '\r') {
-                            int bufLinelen = i - lastcrlf - 1;
-                            if (bufLinelen > 0) {
-                                lineBos.write(buf, lastcrlf + 1, bufLinelen);
-                            }
-                            linelen += bufLinelen;
-
-                            if (linelen > 0) {
-                                lineBos.flush();
-                                final String line = lineBos.toString();
-                                linePumps.stream().forEach((lp) -> {
-                                    lp.processLine(line);
-                                });
-                                lineBos.reset();
-                                linelen = 0;
-                            }
-                            lastcrlf = i;
-                        }
-
-                        i++;
-                    }
-                    if (lastcrlf == -1) {
-                        lineBos.write(buf, 0, len);
-                        linelen += len;
-                    } else if (lastcrlf < len - 1) {
-                        lineBos.write(buf, lastcrlf + 1, len - lastcrlf - 1);
-                        linelen += len - lastcrlf - 1;
-                    }
-                }
-            }
-
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            for(OutputStream out : outStreams) {
-                try {
-                    out.flush();
-                } catch (IOException e) {}
-            }
-            try {
-                in.close();
-            } catch (IOException e) {}
-        }
-    }
-
-    final void addOutputStream(OutputStream out) {
-        outStreams.add(out);
-    }
-
-    final void addLineProcessor(LinePump lp) {
-        linePumps.add(lp);
-    }
-
-    final public StreamPumper addPump(Pump ... pump) {
-        if (processing.get()) {
-            throw new IllegalStateException("Can not modify pumper while " +
-                                            "processing is in progress");
-        }
-        for(Pump p : pump) {
-            p.register(this);
-        }
-        return this;
-    }
-
-    final public Future<Void> process() {
-        if (!processing.compareAndSet(false, true)) {
-            throw new IllegalStateException("Can not re-run the processing");
-        }
-        Thread t = new Thread(new Runnable() {
-            @Override
-            public void run() {
-                processingTask.run();
-            }
-        });
-        t.setDaemon(true);
-        t.start();
-
-        return processingTask;
-    }
-}
diff --git a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/Utils.java b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/Utils.java
deleted file mode 100644
index c763391..0000000
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/Utils.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * 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
- * 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.testlibrary;
-
-import static jdk.testlibrary.Asserts.assertTrue;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import java.util.concurrent.TimeUnit;
-import java.util.function.BooleanSupplier;
-import java.util.function.Function;
-
-/**
- * Common library for various test helper functions.
- *
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib}
- */
-@Deprecated
-public final class Utils {
-
-    /**
-     * Returns the sequence used by operating system to separate lines.
-     */
-    public static final String NEW_LINE = System.getProperty("line.separator");
-
-    /**
-     * Returns the value of 'test.vm.opts'system property.
-     */
-    public static final String VM_OPTIONS = System.getProperty("test.vm.opts", "").trim();
-
-    /**
-     * Returns the value of 'test.java.opts'system property.
-     */
-    public static final String JAVA_OPTIONS = System.getProperty("test.java.opts", "").trim();
-
-    /**
-    * Returns the value of 'test.timeout.factor' system property
-    * converted to {@code double}.
-    */
-    public static final double TIMEOUT_FACTOR;
-    static {
-        String toFactor = System.getProperty("test.timeout.factor", "1.0");
-        TIMEOUT_FACTOR = Double.parseDouble(toFactor);
-    }
-
-    /**
-    * Returns the value of JTREG default test timeout in milliseconds
-    * converted to {@code long}.
-    */
-    public static final long DEFAULT_TEST_TIMEOUT = TimeUnit.SECONDS.toMillis(120);
-
-    private Utils() {
-        // Private constructor to prevent class instantiation
-    }
-
-    /**
-     * Returns the list of VM options.
-     *
-     * @return List of VM options
-     */
-    public static List<String> getVmOptions() {
-        return Arrays.asList(safeSplitString(VM_OPTIONS));
-    }
-
-    /**
-     * Returns the list of VM options with -J prefix.
-     *
-     * @return The list of VM options with -J prefix
-     */
-    public static List<String> getForwardVmOptions() {
-        String[] opts = safeSplitString(VM_OPTIONS);
-        for (int i = 0; i < opts.length; i++) {
-            opts[i] = "-J" + opts[i];
-        }
-        return Arrays.asList(opts);
-    }
-
-    /**
-     * Returns the default JTReg arguments for a jvm running a test.
-     * This is the combination of JTReg arguments test.vm.opts and test.java.opts.
-     * @return An array of options, or an empty array if no opptions.
-     */
-    public static String[] getTestJavaOpts() {
-        List<String> opts = new ArrayList<String>();
-        Collections.addAll(opts, safeSplitString(VM_OPTIONS));
-        Collections.addAll(opts, safeSplitString(JAVA_OPTIONS));
-        return opts.toArray(new String[0]);
-    }
-
-    /**
-     * Combines given arguments with default JTReg arguments for a jvm running a test.
-     * This is the combination of JTReg arguments test.vm.opts and test.java.opts
-     * @return The combination of JTReg test java options and user args.
-     */
-    public static String[] addTestJavaOpts(String... userArgs) {
-        List<String> opts = new ArrayList<String>();
-        Collections.addAll(opts, getTestJavaOpts());
-        Collections.addAll(opts, userArgs);
-        return opts.toArray(new String[0]);
-    }
-
-    /**
-     * Removes any options specifying which GC to use, for example "-XX:+UseG1GC".
-     * Removes any options matching: -XX:(+/-)Use*GC
-     * Used when a test need to set its own GC version. Then any
-     * GC specified by the framework must first be removed.
-     * @return A copy of given opts with all GC options removed.
-     */
-    private static final Pattern useGcPattern = Pattern.compile(
-            "(?:\\-XX\\:[\\+\\-]Use.+GC)"
-            + "|(?:\\-Xconcgc)");
-    public static List<String> removeGcOpts(List<String> opts) {
-        List<String> optsWithoutGC = new ArrayList<String>();
-        for (String opt : opts) {
-            if (useGcPattern.matcher(opt).matches()) {
-                System.out.println("removeGcOpts: removed " + opt);
-            } else {
-                optsWithoutGC.add(opt);
-            }
-        }
-        return optsWithoutGC;
-    }
-
-    /**
-     * Splits a string by white space.
-     * Works like String.split(), but returns an empty array
-     * if the string is null or empty.
-     */
-    private static String[] safeSplitString(String s) {
-        if (s == null || s.trim().isEmpty()) {
-            return new String[] {};
-        }
-        return s.trim().split("\\s+");
-    }
-
-    /**
-     * @return The full command line for the ProcessBuilder.
-     */
-    public static String getCommandLine(ProcessBuilder pb) {
-        StringBuilder cmd = new StringBuilder();
-        for (String s : pb.command()) {
-            cmd.append(s).append(" ");
-        }
-        return cmd.toString();
-    }
-
-    /**
-     * Returns the free port on the local host.
-     * The function will spin until a valid port number is found.
-     *
-     * @return The port number
-     * @throws InterruptedException if any thread has interrupted the current thread
-     * @throws IOException if an I/O error occurs when opening the socket
-     */
-    public static int getFreePort() throws InterruptedException, IOException {
-        int port = -1;
-
-        while (port <= 0) {
-            Thread.sleep(100);
-
-            ServerSocket serverSocket = null;
-            try {
-                serverSocket = new ServerSocket(0);
-                port = serverSocket.getLocalPort();
-            } finally {
-                serverSocket.close();
-            }
-        }
-
-        return port;
-    }
-
-    /**
-     * Returns the name of the local host.
-     *
-     * @return The host name
-     * @throws UnknownHostException if IP address of a host could not be determined
-     */
-    public static String getHostname() throws UnknownHostException {
-        InetAddress inetAddress = InetAddress.getLocalHost();
-        String hostName = inetAddress.getHostName();
-
-        assertTrue((hostName != null && !hostName.isEmpty()),
-                "Cannot get hostname");
-
-        return hostName;
-    }
-
-    /**
-     * Uses "jcmd -l" to search for a jvm pid. This function will wait
-     * forever (until jtreg timeout) for the pid to be found.
-     * @param key Regular expression to search for
-     * @return The found pid.
-     */
-    public static int waitForJvmPid(String key) throws Throwable {
-        final long iterationSleepMillis = 250;
-        System.out.println("waitForJvmPid: Waiting for key '" + key + "'");
-        System.out.flush();
-        while (true) {
-            int pid = tryFindJvmPid(key);
-            if (pid >= 0) {
-                return pid;
-            }
-            Thread.sleep(iterationSleepMillis);
-        }
-    }
-
-    /**
-     * Searches for a jvm pid in the output from "jcmd -l".
-     *
-     * Example output from jcmd is:
-     * 12498 sun.tools.jcmd.JCmd -l
-     * 12254 /tmp/jdk8/tl/jdk/JTwork/classes/com/sun/tools/attach/Application.jar
-     *
-     * @param key A regular expression to search for.
-     * @return The found pid, or -1 if Enot found.
-     * @throws Exception If multiple matching jvms are found.
-     */
-    public static int tryFindJvmPid(String key) throws Throwable {
-        OutputAnalyzer output = null;
-        try {
-            JDKToolLauncher jcmdLauncher = JDKToolLauncher.create("jcmd");
-            jcmdLauncher.addToolArg("-l");
-            output = ProcessTools.executeProcess(jcmdLauncher.getCommand());
-            output.shouldHaveExitValue(0);
-
-            // Search for a line starting with numbers (pid), follwed by the key.
-            Pattern pattern = Pattern.compile("([0-9]+)\\s.*(" + key + ").*\\r?\\n");
-            Matcher matcher = pattern.matcher(output.getStdout());
-
-            int pid = -1;
-            if (matcher.find()) {
-                pid = Integer.parseInt(matcher.group(1));
-                System.out.println("findJvmPid.pid: " + pid);
-                if (matcher.find()) {
-                    throw new Exception("Found multiple JVM pids for key: " + key);
-                }
-            }
-            return pid;
-        } catch (Throwable t) {
-            System.out.println(String.format("Utils.findJvmPid(%s) failed: %s", key, t));
-            throw t;
-        }
-    }
-
-    /**
-     * Adjusts the provided timeout value for the TIMEOUT_FACTOR
-     * @param tOut the timeout value to be adjusted
-     * @return The timeout value adjusted for the value of "test.timeout.factor"
-     *         system property
-     */
-    public static long adjustTimeout(long tOut) {
-        return Math.round(tOut * Utils.TIMEOUT_FACTOR);
-    }
-
-    /**
-     * Wait for condition to be true
-     *
-     * @param condition, a condition to wait for
-     */
-    public static final void waitForCondition(BooleanSupplier condition) {
-        waitForCondition(condition, -1L, 100L);
-    }
-
-    /**
-     * Wait until timeout for condition to be true
-     *
-     * @param condition, a condition to wait for
-     * @param timeout a time in milliseconds to wait for condition to be true
-     * specifying -1 will wait forever
-     * @return condition value, to determine if wait was successfull
-     */
-    public static final boolean waitForCondition(BooleanSupplier condition,
-            long timeout) {
-        return waitForCondition(condition, timeout, 100L);
-    }
-
-    /**
-     * Wait until timeout for condition to be true for specified time
-     *
-     * @param condition, a condition to wait for
-     * @param timeout a time in milliseconds to wait for condition to be true,
-     * specifying -1 will wait forever
-     * @param sleepTime a time to sleep value in milliseconds
-     * @return condition value, to determine if wait was successfull
-     */
-    public static final boolean waitForCondition(BooleanSupplier condition,
-            long timeout, long sleepTime) {
-        long startTime = System.currentTimeMillis();
-        while (!(condition.getAsBoolean() || (timeout != -1L
-                && ((System.currentTimeMillis() - startTime) > timeout)))) {
-            try {
-                Thread.sleep(sleepTime);
-            } catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
-                throw new Error(e);
-            }
-        }
-        return condition.getAsBoolean();
-    }
-
-    /**
-     * Interface same as java.lang.Runnable but with
-     * method {@code run()} able to throw any Throwable.
-     */
-    public static interface ThrowingRunnable {
-        void run() throws Throwable;
-    }
-
-    /**
-     * Filters out an exception that may be thrown by the given
-     * test according to the given filter.
-     *
-     * @param test - method that is invoked and checked for exception.
-     * @param filter - function that checks if the thrown exception matches
-     *                 criteria given in the filter's implementation.
-     * @return - exception that matches the filter if it has been thrown or
-     *           {@code null} otherwise.
-     * @throws Throwable - if test has thrown an exception that does not
-     *                     match the filter.
-     */
-    public static Throwable filterException(ThrowingRunnable test,
-            Function<Throwable, Boolean> filter) throws Throwable {
-        try {
-            test.run();
-        } catch (Throwable t) {
-            if (filter.apply(t)) {
-                return t;
-            } else {
-                throw t;
-            }
-        }
-        return null;
-    }
-}
diff --git a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java
index 72fd20c..9b6faaa 100644
--- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java
+++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java
@@ -27,16 +27,15 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
-import static jdk.testlibrary.ProcessTools.executeTestJava;
-import jdk.testlibrary.CompilerUtils;
+import static jdk.test.lib.process.ProcessTools.executeTestJava;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
 /*
  * @test
- * @library /javax/xml/jaxp/libs
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run testng BasicModularXMLParserTest
  * @bug 8078820 8156119
  * @summary Tests JAXP lib can instantiate the following interfaces
diff --git a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java
index 306b9ee..291ccc7 100644
--- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java
+++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java
@@ -40,12 +40,11 @@
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
-import jdk.testlibrary.CompilerUtils;
+import jdk.test.lib.compiler.CompilerUtils;
 
 /*
  * @test
- * @library /javax/xml/jaxp/libs
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run testng LayerModularXMLParserTest
  * @bug 8078820 8156119
  * @summary Tests JAXP lib works with layer and TCCL
diff --git a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/XMLReaderFactoryTest.java b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/XMLReaderFactoryTest.java
index ef3507f..6771d44 100644
--- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/XMLReaderFactoryTest.java
+++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/XMLReaderFactoryTest.java
@@ -31,7 +31,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
-import jdk.testlibrary.CompilerUtils;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.Assert;
 import org.testng.annotations.BeforeTest;
@@ -41,8 +41,7 @@
 
 /*
  * @test
- * @library /javax/xml/jaxp/libs
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run testng XMLReaderFactoryTest
  * @bug 8152912 8015099 8156119
  * @summary Tests XMLReaderFactory can work as ServiceLoader compliant, as well as backward compatible
diff --git a/jaxws/.hgtags b/jaxws/.hgtags
index dc36ed4..1e510f6 100644
--- a/jaxws/.hgtags
+++ b/jaxws/.hgtags
@@ -399,9 +399,11 @@
 c48b4d4768b1c2b8fe5d1a844ca13732e5dfbe2a jdk-9+151
 6f8fb1cf7e5f61c40dcc3654f9a623c505f6de1f jdk-9+152
 7a532a9a227137155b905341d4b99939db51220e jdk-9+153
+34af95c7dbff74f3448fcdb7d745524e8a1cc88a jdk-10+0
 34af95c7dbff74f3448fcdb7d745524e8a1cc88a jdk-9+154
 9b9918656c97724fd89c04a8547043bbd37f5935 jdk-9+155
 7c829eba781409b4fe15392639289af1553dcf63 jdk-9+156
+6afc1d9b8c41457cc8ebe2e1a27b8fd6d887c1fb jdk-10+1
 b7e70e1e0154e1d2c69f814e03a8800ef8634fe0 jdk-9+157
 e53b322357382209fb553b9a1541ccfd12cbcb6c jdk-9+158
 0ea34706c7fa5cd71accd493eb4f54262e4a5f4e jdk-9+159
@@ -412,5 +414,14 @@
 1a52de2da827459e866fd736f9e9c62eb2ecd6bb jdk-9+164
 a987401bac0d528475e57732c9d5d93f4405804c jdk-9+165
 b1f30c27367bd286fa4eb8a767335e917a5b5b82 jdk-9+166
+06b9f0de66d3a17a10af380c950619c63b62d4cd jdk-10+2
+2e2c78f1713b2c6b760b870946d2b4341a1522e3 jdk-10+3
+ac7e572a6a6ba5bbd7e6aa94a289f88cc86256a4 jdk-10+4
+879aad463c21065254918629e6dfd7d7bf98adb2 jdk-10+5
+85e15cdc75aaaea8a1bb00563af7889869d3e602 jdk-10+6
 1c610f1b4097c64cdd722a7fb59f5a4d9cc15ca9 jdk-9+167
 2746716dcc5a8c28ccf41df0c8fb620b1a1e7098 jdk-9+168
+912cf69806d518c5af7fba30b340c4cb5458dd22 jdk-9+169
+e75d3abe579a7b39b762fc0a1a337c49eb072d82 jdk-9+170
+b0efae7df1dfa14926058baebaf999e4268c955c jdk-10+7
+e705867d9989d00e4357f66f18b302c95e13b5e7 jdk-10+8
diff --git a/jaxws/.jcheck/conf b/jaxws/.jcheck/conf
index 5c6f62d..b258135 100644
--- a/jaxws/.jcheck/conf
+++ b/jaxws/.jcheck/conf
@@ -1 +1 @@
-project=jdk9
+project=jdk10
diff --git a/jdk/.hgtags b/jdk/.hgtags
index f4217d6..3a58536 100644
--- a/jdk/.hgtags
+++ b/jdk/.hgtags
@@ -396,9 +396,11 @@
 d27bab22ff62823902d93d1d35ca397cfd50d059 jdk-9+151
 a20f2cf90762673e1bc4980fd6597e70a2578045 jdk-9+152
 1c4411322327aea3f91011ec3977a12a05b09629 jdk-9+153
+f2325d80b37c2817e15039bf64189a08e29c6d39 jdk-10+0
 c97e7a8b8da062b9070df442f9cf308e10845fb7 jdk-9+154
 e170c858888e83d5c0994504599b6ed7a1fb0cfc jdk-9+155
 7d64e541a6c04c714bcad4c8b553db912f827cd5 jdk-9+156
+e209a98d40a1c353199285f31ca0ff6f0d68264a jdk-10+1
 fdfa7b2fe9a7db06792eae20f97748f3e85bb83a jdk-9+157
 c476ca73750698fa5654e101af699ee45db38e2a jdk-9+158
 49b54a4d9e84b7ba956b8c27fced5035465146ae jdk-9+159
@@ -409,6 +411,14 @@
 6dea581453d7c0e767e3169cfec8b423a381e71d jdk-9+164
 a7942c3b1e59495dbf51dc7c41aab355fcd253d7 jdk-9+165
 5d2b48f1f0a322aca719b49ff02ab421705bffc7 jdk-9+166
+5adecda6cf9a5623f983ea29e5511755ccfd1273 jdk-10+2
+4723e1d233195e253f018e8a46732c7ffbe6ce90 jdk-10+3
+37f8b938b680cf8fb551e9a48bffc5536b061fa8 jdk-10+4
+d1436b2945383cef15edbdba9bb41ef1656c987b jdk-10+5
+329609d00aef2443cf1e44ded94637c5ed55a143 jdk-10+6
 7828aedcb525df40b7c8122bcc3f997c75ebaf7f jdk-9+167
 e78da9db6299b3fcba49300d52e2359e82fdd218 jdk-9+168
 177436a54ca13730ffc725a6e5dbfcd9486f3da3 jdk-9+169
+ef9954f6896bb0b95ac62bf769f68b59a7a56ccd jdk-9+170
+cbd65760a005766610583949b3b5c9ace92e74b3 jdk-10+7
+f0adc10ed8316e6cf316e3208c5ecf6835d22bc4 jdk-10+8
diff --git a/jdk/.jcheck/conf b/jdk/.jcheck/conf
index 5c6f62d..b258135 100644
--- a/jdk/.jcheck/conf
+++ b/jdk/.jcheck/conf
@@ -1 +1 @@
-project=jdk9
+project=jdk10
diff --git a/jdk/make/launcher/Launcher-java.base.gmk b/jdk/make/launcher/Launcher-java.base.gmk
index f70d900..06ccec7 100644
--- a/jdk/make/launcher/Launcher-java.base.gmk
+++ b/jdk/make/launcher/Launcher-java.base.gmk
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -71,102 +71,37 @@
 
 ################################################################################
 
-BUILD_JEXEC :=
-BUILD_JEXEC_SRC :=
-BUILD_JEXEC_INC :=
-BUILD_JEXEC_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base
-
-#
-# UNHANDLED:
-# - COMPILE_APPROACH = normal
-#
-
-#
-# jdk/make/java/Makefile
-#
-ifeq ($(OPENJDK_TARGET_OS), solaris)
-  ifeq ($(OPENJDK_TARGET_CPU_BITS), 32)
-    BUILD_JEXEC := 1
-  endif
-endif
-
 ifeq ($(OPENJDK_TARGET_OS), linux)
-  BUILD_JEXEC := 1
-endif # OPENJDK_TARGET_OS
-
-#
-# jdk/make/java/jexec/Makefile
-#
-ifeq ($(BUILD_JEXEC), 1)
-
-  ifeq ($(OPENJDK_TARGET_OS), windows)
-  else ifeq ($(OPENJDK_TARGET_OS), macosx)
-    BUILD_JEXEC_SRC := $(JDK_TOPDIR)/src/java.base/macosx/native/launcher
-  else
-    BUILD_JEXEC_SRC := $(JDK_TOPDIR)/src/java.base/unix/native/launcher
-  endif
-
-  ifeq ($(OPENJDK_TARGET_OS), linux)
-    BUILD_JEXEC_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base
-    BUILD_JEXEC_INC += -I$(JDK_TOPDIR)/src/java.base/share/native/libjli
-  endif
-endif
-
-#
-# Note that the two Makefile's seems to contradict each other,
-# and that src/macosx/bin/jexec.c seems unused
-#
-ifneq ($(BUILD_JEXEC_SRC), )
-  $(eval $(call SetupNativeCompilation,BUILD_JEXEC, \
-      SRC := $(BUILD_JEXEC_SRC), \
+  $(eval $(call SetupNativeCompilation, BUILD_JEXEC, \
+      SRC := $(JDK_TOPDIR)/src/$(MODULE)/unix/native/launcher, \
       INCLUDE_FILES := jexec.c, \
       OPTIMIZATION := LOW, \
       CFLAGS := $(CFLAGS_JDKEXE) \
-          $(BUILD_JEXEC_INC), \
+          -I$(JDK_TOPDIR)/src/$(MODULE)/share/native/libjli, \
       CFLAGS_linux := -fPIC, \
       CFLAGS_solaris := -KPIC, \
       LDFLAGS := $(LDFLAGS_JDKEXE), \
       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/jexec_obj, \
-      OUTPUT_DIR := $(BUILD_JEXEC_DST_DIR), \
-      PROGRAM := jexec))
+      OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
+      PROGRAM := jexec, \
+  ))
 
   TARGETS += $(BUILD_JEXEC)
 endif
 
 ################################################################################
 
-BUILD_JSPAWNHELPER :=
-BUILD_JSPAWNHELPER_SRC := $(JDK_TOPDIR)/src/java.base/unix/native/jspawnhelper
-JSPAWNHELPER_CFLAGS := -I$(JDK_TOPDIR)/src/java.base/unix/native/libjava
-BUILD_JSPAWNHELPER_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base
-LINK_JSPAWNHELPER_OBJECTS := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjava/childproc.o
-BUILD_JSPAWNHELPER_LDFLAGS :=
-
 ifneq ($(findstring $(OPENJDK_TARGET_OS), macosx solaris aix), )
-  BUILD_JSPAWNHELPER := 1
-endif
-
-ifeq ($(OPENJDK_TARGET_OS), macosx)
-  BUILD_JSPAWNHELPER_DST_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base
-endif
-
-ifeq ($(OPENJDK_TARGET_CPU_BITS), 64)
-  BUILD_JSPAWNHELPER_LDFLAGS += $(COMPILER_TARGET_BITS_FLAG)64
-endif
-
-ifeq ($(BUILD_JSPAWNHELPER), 1)
-  $(eval $(call SetupNativeCompilation,BUILD_JSPAWNHELPER, \
-      SRC := $(BUILD_JSPAWNHELPER_SRC), \
-      INCLUDE_FILES := jspawnhelper.c, \
+  $(eval $(call SetupNativeCompilation, BUILD_JSPAWNHELPER, \
+      SRC := $(JDK_TOPDIR)/src/$(MODULE)/unix/native/jspawnhelper, \
       OPTIMIZATION := LOW, \
-      CFLAGS := $(CFLAGS_JDKEXE) $(JSPAWNHELPER_CFLAGS), \
-      LDFLAGS := $(LDFLAGS_JDKEXE) $(BUILD_JSPAWNHELPER_LDFLAGS), \
-      LIBS := $(LINK_JSPAWNHELPER_OBJECTS), \
+      CFLAGS := $(CFLAGS_JDKEXE) -I$(JDK_TOPDIR)/src/$(MODULE)/unix/native/libjava, \
+      EXTRA_OBJECT_FILES := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjava/childproc.o, \
+      LDFLAGS := $(LDFLAGS_JDKEXE), \
       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/jspawnhelper, \
-      OUTPUT_DIR := $(BUILD_JSPAWNHELPER_DST_DIR), \
-      PROGRAM := jspawnhelper))
-
-  $(BUILD_JSPAWNHELPER): $(LINK_JSPAWNHELPER_OBJECTS)
+      OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE), \
+      PROGRAM := jspawnhelper, \
+  ))
 
   TARGETS += $(BUILD_JSPAWNHELPER)
 endif
diff --git a/jdk/src/java.base/aix/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java b/jdk/src/java.base/aix/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
new file mode 100644
index 0000000..1ba654e
--- /dev/null
+++ b/jdk/src/java.base/aix/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
@@ -0,0 +1,47 @@
+/*
+ * 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.nio.ch;
+
+import java.nio.channels.spi.AsynchronousChannelProvider;
+
+/**
+ * Creates this platform's default AsynchronousChannelProvider
+ */
+
+public class DefaultAsynchronousChannelProvider {
+
+    /**
+     * Prevent instantiation.
+     */
+    private DefaultAsynchronousChannelProvider() { }
+
+    /**
+     * Returns the default AsynchronousChannelProvider.
+     */
+    public static AsynchronousChannelProvider create() {
+        return new AixAsynchronousChannelProvider();
+    }
+}
diff --git a/jdk/src/java.base/aix/classes/sun/nio/ch/DefaultSelectorProvider.java b/jdk/src/java.base/aix/classes/sun/nio/ch/DefaultSelectorProvider.java
index 3f23cc4..dbc3ab6 100644
--- a/jdk/src/java.base/aix/classes/sun/nio/ch/DefaultSelectorProvider.java
+++ b/jdk/src/java.base/aix/classes/sun/nio/ch/DefaultSelectorProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,6 @@
      * Returns the default SelectorProvider.
      */
     public static SelectorProvider create() {
-        return new sun.nio.ch.PollSelectorProvider();
+        return new PollSelectorProvider();
     }
-
 }
diff --git a/jdk/src/java.base/aix/native/libnet/aix_close.c b/jdk/src/java.base/aix/native/libnet/aix_close.c
index 1588d48..a038af3 100644
--- a/jdk/src/java.base/aix/native/libnet/aix_close.c
+++ b/jdk/src/java.base/aix/native/libnet/aix_close.c
@@ -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;
         }
-
     }
 }
diff --git a/jdk/src/java.base/linux/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java b/jdk/src/java.base/linux/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
new file mode 100644
index 0000000..f235410
--- /dev/null
+++ b/jdk/src/java.base/linux/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
@@ -0,0 +1,47 @@
+/*
+ * 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.nio.ch;
+
+import java.nio.channels.spi.AsynchronousChannelProvider;
+
+/**
+ * Creates this platform's default AsynchronousChannelProvider
+ */
+
+public class DefaultAsynchronousChannelProvider {
+
+    /**
+     * Prevent instantiation.
+     */
+    private DefaultAsynchronousChannelProvider() { }
+
+    /**
+     * Returns the default AsynchronousChannelProvider.
+     */
+    public static AsynchronousChannelProvider create() {
+        return new LinuxAsynchronousChannelProvider();
+    }
+}
diff --git a/jdk/src/java.base/linux/classes/sun/nio/ch/DefaultSelectorProvider.java b/jdk/src/java.base/linux/classes/sun/nio/ch/DefaultSelectorProvider.java
index 1278f15..77531b2 100644
--- a/jdk/src/java.base/linux/classes/sun/nio/ch/DefaultSelectorProvider.java
+++ b/jdk/src/java.base/linux/classes/sun/nio/ch/DefaultSelectorProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,6 @@
      * Returns the default SelectorProvider.
      */
     public static SelectorProvider create() {
-        return new sun.nio.ch.EPollSelectorProvider();
+        return new EPollSelectorProvider();
     }
-
 }
diff --git a/jdk/src/java.base/linux/native/libnet/linux_close.c b/jdk/src/java.base/linux/native/libnet/linux_close.c
index 2bf7cc7..d2b60a9 100644
--- a/jdk/src/java.base/linux/native/libnet/linux_close.c
+++ b/jdk/src/java.base/linux/native/libnet/linux_close.c
@@ -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;
         }
-
     }
 }
diff --git a/jdk/src/java.base/macosx/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java b/jdk/src/java.base/macosx/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
new file mode 100644
index 0000000..8bb3682
--- /dev/null
+++ b/jdk/src/java.base/macosx/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
@@ -0,0 +1,47 @@
+/*
+ * 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.nio.ch;
+
+import java.nio.channels.spi.AsynchronousChannelProvider;
+
+/**
+ * Creates this platform's default AsynchronousChannelProvider
+ */
+
+public class DefaultAsynchronousChannelProvider {
+
+    /**
+     * Prevent instantiation.
+     */
+    private DefaultAsynchronousChannelProvider() { }
+
+    /**
+     * Returns the default AsynchronousChannelProvider.
+     */
+    public static AsynchronousChannelProvider create() {
+        return new BsdAsynchronousChannelProvider();
+    }
+}
diff --git a/jdk/src/java.base/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java b/jdk/src/java.base/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java
index e55f8e6..c7d67b2 100644
--- a/jdk/src/java.base/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java
+++ b/jdk/src/java.base/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2012, 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
@@ -42,7 +42,6 @@
      * Returns the default SelectorProvider.
      */
     public static SelectorProvider create() {
-        return new sun.nio.ch.KQueueSelectorProvider();
+        return new KQueueSelectorProvider();
     }
-
 }
diff --git a/jdk/src/java.base/macosx/native/launcher/jexec.c b/jdk/src/java.base/macosx/native/launcher/jexec.c
deleted file mode 100644
index 24df31f..0000000
--- a/jdk/src/java.base/macosx/native/launcher/jexec.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
- * 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.
- */
-
-/*
- * jexec for J2SE
- *
- * jexec is used by the system to allow execution of JAR files.
- *    Essentially jexec needs to run java and
- *    needs to be a native ISA executable (not a shell script), although
- *    this native ISA executable requirement was a mistake that will be fixed.
- *    (<ISA> is sparc or i386 or amd64).
- *
- *    When you execute a jar file, jexec is executed by the system as follows:
- *      /usr/java/jre/lib/<ISA>/jexec -jar JARFILENAME
- *    so this just needs to be turned into:
- *      /usr/java/jre/bin/java -jar JARFILENAME
- *
- * Solaris systems (new 7's and all 8's) will be looking for jexec at:
- *      /usr/java/jre/lib/<ISA>/jexec
- * Older systems may need to add this to their /etc/system file:
- *      set javaexec:jexec="/usr/java/jre/lib/<ISA>/jexec"
- *     and reboot the machine for this to work.
- *
- * This source should be compiled as:
- *      cc -o jexec jexec.c
- *
- * And jexec should be placed at the following location of the installation:
- *      <INSTALLATIONDIR>/jre/lib/<ISA>/jexec  (for Solaris)
- *      <INSTALLATIONDIR>/lib/jexec            (for Linux)
- *
- * NOTE: Unless <INSTALLATIONDIR> is the "default" JDK on the system
- *       (i.e. /usr/java -> <INSTALLATIONDIR>), this jexec will not be
- *       found.  The 1.2 java is only the default on Solaris 8 and
- *       on systems where the 1.2 packages were installed and no 1.1
- *       java was found.
- *
- * NOTE: You must use 1.2 jar to build your jar files. The system
- *       doesn't seem to pick up 1.1 jar files.
- *
- * NOTE: We don't need to set LD_LIBRARY_PATH here, even though we
- *       are running the actual java binary because the java binary will
- *       look for it's libraries through it's own runpath, which uses
- *       $ORIGIN.
- *
- * NOTE: This jexec should NOT have any special .so library needs because
- *       it appears that this executable will NOT get the $ORIGIN of jexec
- *       but the $ORIGIN of the jar file being executed. Be careful to keep
- *       this program simple and with no .so dependencies.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <limits.h>
-#include <errno.h>
-
-static const int CRAZY_EXEC = ENOEXEC;
-static const int BAD_MAGIC  = ENOEXEC;
-
-static const char * BAD_EXEC_MSG     = "jexec failed";
-static const char * CRAZY_EXEC_MSG   = "missing args";
-static const char * MISSING_JAVA_MSG = "can't locate java";
-static const char * UNKNOWN_ERROR    = "unknown error";
-
-/* Define a constant that represents the number of directories to pop off the
- * current location to find the java binary */
-static const int RELATIVE_DEPTH = 3;
-
-/* path to java after popping */
-static const char * BIN_PATH = "/bin/java";
-
-/* flag used when running JAR files */
-static const char * JAR_FLAG = "-jar";
-
-int main(int argc, const char * argv[]);
-void errorExit(int error, const char * message);
-int getJavaPath(const char * path, char * buf, int depth);
-
-/*
- * This is the main entry point.  This program (jexec) will attempt to execute
- * a JAR file by finding the Java program (java), relative to its own location.
- * The exact location of the Java program depends on the platform, i.e.
- *
- *      <INSTALLATIONDIR>/jre/lib/<ISA>/jexec  (for Solaris)
- *      <INSTALLATIONDIR>/lib/jexec            (for Linux JDK)
- *
- * Once the Java program is found, this program copies any remaining arguments
- * into another array, which is then used to exec the Java program.
- *
- * On Linux this program does some additional steps.  When copying the array of
- * args, it is necessary to insert the "-jar" flag between arg[0], the program
- * name, and the original arg[1], which is presumed to be a path to a JAR file.
- * It is also necessary to verify that the original arg[1] really is a JAR file.
- * (These steps are unnecessary on Solaris because they are taken care of by
- * the kernel.)
- */
-int main(int argc, const char * argv[]) {
-    /* We need to exec the original arguments using java, instead of jexec.
-     * Also, for Linux, it is necessary to add the "-jar" argument between
-     * the new arg[0], and the old arg[1].  To do this we will create a new
-     * args array. */
-    char          java[PATH_MAX + 1];    /* path to java binary  */
-    const char ** nargv = NULL;          /* new args array       */
-    int           nargc = 0;             /* new args array count */
-    int           argi  = 0;             /* index into old array */
-
-    /* Make sure we have something to work with */
-    if ((argc < 1) || (argv == NULL)) {
-        /* Shouldn't happen... */
-        errorExit(CRAZY_EXEC, CRAZY_EXEC_MSG);
-    }
-
-    /* Get the path to the java binary, which is in a known position relative
-     * to our current position, which is in argv[0]. */
-    if (getJavaPath(argv[argi++], java, RELATIVE_DEPTH) != 0) {
-        errorExit(errno, MISSING_JAVA_MSG);
-    }
-
-    nargv = (const char **) malloc((argc + 2) * (sizeof (const char *)));
-    nargv[nargc++] = java;
-
-    if (argc >= 2) {
-        const char * jarfile = argv[argi++];
-        const char * message = NULL;
-
-        /* the next argument is the path to the JAR file */
-        nargv[nargc++] = jarfile;
-    }
-
-    /* finally copy any remaining arguments */
-    while (argi < argc) {
-        nargv[nargc++] = argv[argi++];
-    }
-
-    /* finally add one last terminating null */
-    nargv[nargc++] = NULL;
-
-    /* It's time to exec the java binary with the new arguments.  It
-     * is possible that we've reached this point without actually
-     * having a JAR file argument (i.e. if argc < 2), but we still
-     * want to exec the java binary, since that will take care of
-     * displaying the correct usage. */
-    execv(java, (char * const *) nargv);
-
-    /* If the exec worked, this process would have been replaced
-     * by the new process.  So any code reached beyond this point
-     * implies an error in the exec. */
-    free(nargv);
-    errorExit(errno, BAD_EXEC_MSG);
-    return 0; // keep the compiler happy
-}
-
-
-/*
- * Exit the application by setting errno, and writing a message.
- *
- * Parameters:
- *     error   - errno is set to this value, and it is used to exit.
- *     message - the message to write.
- */
-void errorExit(int error, const char * message) {
-    if (error != 0) {
-        errno = error;
-        perror((message != NULL) ? message : UNKNOWN_ERROR);
-    }
-
-    exit((error == 0) ? 0 : 1);
-}
-
-
-/*
- * Get the path to the java binary that should be relative to the current path.
- *
- * Parameters:
- *     path  - the input path that the java binary that should be relative to.
- *     buf   - a buffer of size PATH_MAX or greater that the java path is
- *             copied to.
- *     depth - the number of names to trim off the current path, including the
- *             name of this program.
- *
- * Returns:
- *     This function returns 0 on success; otherwise it returns the value of
- *     errno.
- */
-int getJavaPath(const char * path, char * buf, int depth) {
-    int result = 0;
-
-    /* Get the full path to this program.  Depending on whether this is Solaris
-     * or Linux, this will be something like,
-     *
-     *     <FOO>/jre/lib/<ISA>/jexec  (for Solaris)
-     *     <FOO>/lib/jexec            (for Linux)
-     */
-    if (realpath(path, buf) != NULL) {
-        int count = 0;
-
-        /* Pop off the filename, and then subdirectories for each level of
-         * depth */
-        for (count = 0; count < depth; count++) {
-            *(strrchr(buf, '/')) = '\0';
-        }
-
-        /* Append the relative location of java, creating something like,
-         *
-         *     <FOO>/jre/bin/java  (for Solaris)
-         *     <FOO>/bin/java      (for Linux)
-         */
-        strcat(buf, BIN_PATH);
-    }
-    else {
-        /* Failed to get the path */
-        result = errno;
-    }
-
-    return (result);
-}
diff --git a/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c b/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c
index f21201c..0abf273 100644
--- a/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c
+++ b/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c
@@ -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;
+    char * jvmtype    = NULL;
+    int  argc         = *pargc;
+    char **argv       = *pargv;
 
-      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);
-        }
-
-        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);
diff --git a/jdk/src/java.base/macosx/native/libnet/bsd_close.c b/jdk/src/java.base/macosx/native/libnet/bsd_close.c
index 14739b1..2d7d2fb 100644
--- a/jdk/src/java.base/macosx/native/libnet/bsd_close.c
+++ b/jdk/src/java.base/macosx/native/libnet/bsd_close.c
@@ -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;
         }
-
     }
 }
diff --git a/jdk/src/java.base/share/classes/java/lang/Class.java b/jdk/src/java.base/share/classes/java/lang/Class.java
index 4251a69..e6962ac 100644
--- a/jdk/src/java.base/share/classes/java/lang/Class.java
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java
@@ -2880,19 +2880,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);
         }
     }
 
diff --git a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java
index fb9660f..9aee833 100644
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java
@@ -2884,7 +2884,7 @@
         } catch (NoSuchFieldException e) {
             throw new InternalError(e);
         }
-        return unsafe.compareAndSwapObject(this, offset, null, obj);
+        return unsafe.compareAndSetObject(this, offset, null, obj);
     }
 }
 
diff --git a/jdk/src/java.base/share/classes/java/lang/Math.java b/jdk/src/java.base/share/classes/java/lang/Math.java
index 40e8926..1409390 100644
--- a/jdk/src/java.base/share/classes/java/lang/Math.java
+++ b/jdk/src/java.base/share/classes/java/lang/Math.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1442,8 +1442,8 @@
     }
 
     // Use raw bit-wise conversions on guaranteed non-NaN arguments.
-    private static long negativeZeroFloatBits  = Float.floatToRawIntBits(-0.0f);
-    private static long negativeZeroDoubleBits = Double.doubleToRawLongBits(-0.0d);
+    private static final long negativeZeroFloatBits  = Float.floatToRawIntBits(-0.0f);
+    private static final long negativeZeroDoubleBits = Double.doubleToRawLongBits(-0.0d);
 
     /**
      * Returns the greater of two {@code float} values.  That is,
diff --git a/jdk/src/java.base/share/classes/java/lang/StringCoding.java b/jdk/src/java.base/share/classes/java/lang/StringCoding.java
index 7340fed..065dcd7 100644
--- a/jdk/src/java.base/share/classes/java/lang/StringCoding.java
+++ b/jdk/src/java.base/share/classes/java/lang/StringCoding.java
@@ -272,8 +272,7 @@
         // (2)The defensive copy of the input byte/char[] has a big performance
         // impact, as well as the outgoing result byte/char[]. Need to do the
         // optimization check of (sm==null && classLoader0==null) for both.
-        // (3)getClass().getClassLoader0() is expensive
-        // (4)There might be a timing gap in isTrusted setting. getClassLoader0()
+        // (3)There might be a timing gap in isTrusted setting. getClassLoader0()
         // is only checked (and then isTrusted gets set) when (SM==null). It is
         // possible that the SM==null for now but then SM is NOT null later
         // when safeTrim() is invoked...the "safe" way to do is to redundant
@@ -299,8 +298,8 @@
         if (len == 0) {
             return new Result().with();
         }
-        if (System.getSecurityManager() != null &&
-            cs.getClass().getClassLoader0() != null) {
+        if (cs.getClass().getClassLoader0() != null &&
+            System.getSecurityManager() != null) {
             ba =  Arrays.copyOfRange(ba, off, off + len);
             off = 0;
         }
@@ -609,8 +608,8 @@
         if (len == 0) {
             return ba;
         }
-        boolean isTrusted = System.getSecurityManager() == null ||
-                            cs.getClass().getClassLoader0() == null;
+        boolean isTrusted = cs.getClass().getClassLoader0() == null ||
+                            System.getSecurityManager() == null;
         ce.onMalformedInput(CodingErrorAction.REPLACE)
           .onUnmappableCharacter(CodingErrorAction.REPLACE)
           .reset();
diff --git a/jdk/src/java.base/share/classes/java/lang/System.java b/jdk/src/java.base/share/classes/java/lang/System.java
index 1066481..1f569a5 100644
--- a/jdk/src/java.base/share/classes/java/lang/System.java
+++ b/jdk/src/java.base/share/classes/java/lang/System.java
@@ -534,6 +534,8 @@
      * @param x object for which the hashCode is to be calculated
      * @return  the hashCode
      * @since   1.1
+     * @see Object#hashCode
+     * @see java.util.Objects#hashCode(Object)
      */
     @HotSpotIntrinsicCandidate
     public static native int identityHashCode(Object x);
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
index cec4366..f4675e1 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java
@@ -450,32 +450,29 @@
      */
     static class Factory {
 
-        static final String JLO_SIG  = "Ljava/lang/Object;";
-        static final String JLS_SIG  = "Ljava/lang/String;";
-        static final String JLC_SIG  = "Ljava/lang/Class;";
-        static final String MH       = "java/lang/invoke/MethodHandle";
-        static final String MH_SIG   = "L"+MH+";";
-        static final String BMH      = "java/lang/invoke/BoundMethodHandle";
-        static final String BMH_SIG  = "L"+BMH+";";
-        static final String SPECIES_DATA     = "java/lang/invoke/BoundMethodHandle$SpeciesData";
-        static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";";
-        static final String STABLE_SIG       = "Ljdk/internal/vm/annotation/Stable;";
+        private static final String JLO_SIG  = "Ljava/lang/Object;";
+        private static final String MH       = "java/lang/invoke/MethodHandle";
+        private static final String MH_SIG   = "L"+MH+";";
+        private static final String BMH      = "java/lang/invoke/BoundMethodHandle";
+        private static final String BMH_NAME = "java.lang.invoke.BoundMethodHandle";
+        private static final String BMH_SIG  = "L"+BMH+";";
+        private static final String SPECIES_DATA     = "java/lang/invoke/BoundMethodHandle$SpeciesData";
+        private static final String SPECIES_DATA_SIG = "L"+SPECIES_DATA+";";
+        private static final String STABLE_SIG       = "Ljdk/internal/vm/annotation/Stable;";
 
-        static final String SPECIES_PREFIX_NAME = "Species_";
-        static final String SPECIES_PREFIX_PATH = BMH + "$" + SPECIES_PREFIX_NAME;
-        static final String SPECIES_CLASS_PREFIX = SPECIES_PREFIX_PATH.replace('/', '.');
+        private static final String SPECIES_PREFIX_NAME = "Species_";
+        private static final String SPECIES_PREFIX_PATH = BMH + "$" + SPECIES_PREFIX_NAME;
+        private static final String SPECIES_CLASS_PREFIX = BMH_NAME + "$" + SPECIES_PREFIX_NAME;
 
-        static final String BMHSPECIES_DATA_EWI_SIG = "(B)" + SPECIES_DATA_SIG;
-        static final String BMHSPECIES_DATA_GFC_SIG = "(" + JLS_SIG + JLC_SIG + ")" + SPECIES_DATA_SIG;
-        static final String MYSPECIES_DATA_SIG = "()" + SPECIES_DATA_SIG;
-        static final String VOID_SIG   = "()V";
-        static final String INT_SIG    = "()I";
+        private static final String BMHSPECIES_DATA_EWI_SIG = "(B)" + SPECIES_DATA_SIG;
+        private static final String MYSPECIES_DATA_SIG = "()" + SPECIES_DATA_SIG;
+        private static final String INT_SIG    = "()I";
 
-        static final String SIG_INCIPIT = "(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;";
+        private static final String SIG_INCIPIT = "(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;";
 
-        static final String[] E_THROWABLE = new String[] { "java/lang/Throwable" };
+        private static final String[] E_THROWABLE = new String[] { "java/lang/Throwable" };
 
-        static final ConcurrentMap<String, Class<? extends BoundMethodHandle>> CLASS_CACHE = new ConcurrentHashMap<>();
+        private static final ConcurrentMap<String, Class<? extends BoundMethodHandle>> CLASS_CACHE = new ConcurrentHashMap<>();
 
         /**
          * Get a concrete subclass of BMH for a given combination of bound types.
@@ -830,15 +827,27 @@
 
         private static String makeSignature(String types, boolean ctor) {
             StringBuilder buf = new StringBuilder(SIG_INCIPIT);
-            for (char c : types.toCharArray()) {
-                buf.append(typeSig(c));
+            int len = types.length();
+            for (int i = 0; i < len; i++) {
+                buf.append(typeSig(types.charAt(i)));
             }
             return buf.append(')').append(ctor ? "V" : BMH_SIG).toString();
         }
 
+        private static MethodType makeConstructorType(String types) {
+            int length = types.length();
+            Class<?> ptypes[] = new Class<?>[length + 2];
+            ptypes[0] = MethodType.class;
+            ptypes[1] = LambdaForm.class;
+            for (int i = 0; i < length; i++) {
+                ptypes[i + 2] = BasicType.basicType(types.charAt(i)).basicTypeClass();
+            }
+            return MethodType.makeImpl(BoundMethodHandle.class, ptypes, true);
+        }
+
         static MethodHandle makeCbmhCtor(Class<? extends BoundMethodHandle> cbmh, String types) {
             try {
-                return LOOKUP.findStatic(cbmh, "make", MethodType.fromDescriptor(makeSignature(types, false), null));
+                return LOOKUP.findStatic(cbmh, "make", makeConstructorType(types));
             } catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException | TypeNotPresentException e) {
                 throw newInternalError(e);
             }
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java
index d11012e..cecfe5e 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java
@@ -98,21 +98,17 @@
                                         Object constraint,
                                         NamedFunction getTargetFn) {
         // No pre-action needed.
-        return makeReinvokerForm(target, whichCache, constraint, null, true, getTargetFn, null);
+        return makeReinvokerForm(target, whichCache, constraint, true, getTargetFn, null);
     }
     /** Create a LF which simply reinvokes a target of the given basic type. */
     static LambdaForm makeReinvokerForm(MethodHandle target,
                                         int whichCache,
                                         Object constraint,
-                                        String debugString,
                                         boolean forceInline,
                                         NamedFunction getTargetFn,
                                         NamedFunction preActionFn) {
         MethodType mtype = target.type().basicType();
         Kind kind = whichKind(whichCache);
-        if (debugString == null) {
-            debugString = kind.defaultLambdaName;
-        }
         boolean customized = (whichCache < 0 ||
                 mtype.parameterSlotCount() > MethodType.MAX_MH_INVOKER_ARITY);
         boolean hasPreAction = (preActionFn != null);
@@ -144,7 +140,7 @@
             targetArgs[0] = names[NEXT_MH];  // overwrite this MH with next MH
             names[REINVOKE] = new LambdaForm.Name(mtype, targetArgs);
         }
-        form = new LambdaForm(debugString, ARG_LIMIT, names, forceInline, kind);
+        form = new LambdaForm(ARG_LIMIT, names, forceInline, kind);
         if (!customized) {
             form = mtype.form().setCachedLambdaForm(whichCache, form);
         }
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java
index ce1f938..bd06ffa 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java
@@ -224,12 +224,12 @@
         assert(names.length == nameCursor);
         if (doesAlloc) {
             // names = { argx,y,z,... new C, init method }
-            names[NEW_OBJ] = new Name(NF_allocateInstance, names[DMH_THIS]);
-            names[GET_MEMBER] = new Name(NF_constructorMethod, names[DMH_THIS]);
+            names[NEW_OBJ] = new Name(getFunction(NF_allocateInstance), names[DMH_THIS]);
+            names[GET_MEMBER] = new Name(getFunction(NF_constructorMethod), names[DMH_THIS]);
         } else if (needsInit) {
-            names[GET_MEMBER] = new Name(NF_internalMemberNameEnsureInit, names[DMH_THIS]);
+            names[GET_MEMBER] = new Name(getFunction(NF_internalMemberNameEnsureInit), names[DMH_THIS]);
         } else {
-            names[GET_MEMBER] = new Name(NF_internalMemberName, names[DMH_THIS]);
+            names[GET_MEMBER] = new Name(getFunction(NF_internalMemberName), names[DMH_THIS]);
         }
         assert(findDirectMethodHandle(names[GET_MEMBER]) == names[DMH_THIS]);
         Object[] outArgs = Arrays.copyOfRange(names, ARG_BASE, GET_MEMBER+1, Object[].class);
@@ -242,18 +242,17 @@
             result = NEW_OBJ;
         }
         names[LINKER_CALL] = new Name(linker, outArgs);
-        String lambdaName = kind.defaultLambdaName + "_" + shortenSignature(basicTypeSignature(mtype));
-        LambdaForm lform = new LambdaForm(lambdaName, ARG_LIMIT, names, result, kind);
+        LambdaForm lform = new LambdaForm(ARG_LIMIT, names, result, kind);
 
         // This is a tricky bit of code.  Don't send it through the LF interpreter.
         lform.compileToBytecode();
         return lform;
     }
 
-    static Object findDirectMethodHandle(Name name) {
-        if (name.function == NF_internalMemberName ||
-            name.function == NF_internalMemberNameEnsureInit ||
-            name.function == NF_constructorMethod) {
+    /* assert */ static Object findDirectMethodHandle(Name name) {
+        if (name.function.equals(getFunction(NF_internalMemberName)) ||
+            name.function.equals(getFunction(NF_internalMemberNameEnsureInit)) ||
+            name.function.equals(getFunction(NF_constructorMethod))) {
             assert(name.arguments.length == 1);
             return name.arguments[0];
         }
@@ -675,18 +674,18 @@
         final int RESULT    = nameCursor-1;  // either the call or the cast
         Name[] names = arguments(nameCursor - ARG_LIMIT, mtype.invokerType());
         if (needsInit)
-            names[INIT_BAR] = new Name(NF_ensureInitialized, names[DMH_THIS]);
+            names[INIT_BAR] = new Name(getFunction(NF_ensureInitialized), names[DMH_THIS]);
         if (needsCast && !isGetter)
-            names[PRE_CAST] = new Name(NF_checkCast, names[DMH_THIS], names[SET_VALUE]);
+            names[PRE_CAST] = new Name(getFunction(NF_checkCast), names[DMH_THIS], names[SET_VALUE]);
         Object[] outArgs = new Object[1 + linkerType.parameterCount()];
         assert(outArgs.length == (isGetter ? 3 : 4));
-        outArgs[0] = names[U_HOLDER] = new Name(NF_UNSAFE);
+        outArgs[0] = names[U_HOLDER] = new Name(getFunction(NF_UNSAFE));
         if (isStatic) {
-            outArgs[1] = names[F_HOLDER]  = new Name(NF_staticBase, names[DMH_THIS]);
-            outArgs[2] = names[F_OFFSET]  = new Name(NF_staticOffset, names[DMH_THIS]);
+            outArgs[1] = names[F_HOLDER]  = new Name(getFunction(NF_staticBase), names[DMH_THIS]);
+            outArgs[2] = names[F_OFFSET]  = new Name(getFunction(NF_staticOffset), names[DMH_THIS]);
         } else {
-            outArgs[1] = names[OBJ_CHECK] = new Name(NF_checkBase, names[OBJ_BASE]);
-            outArgs[2] = names[F_OFFSET]  = new Name(NF_fieldOffset, names[DMH_THIS]);
+            outArgs[1] = names[OBJ_CHECK] = new Name(getFunction(NF_checkBase), names[OBJ_BASE]);
+            outArgs[2] = names[F_OFFSET]  = new Name(getFunction(NF_fieldOffset), names[DMH_THIS]);
         }
         if (!isGetter) {
             outArgs[3] = (needsCast ? names[PRE_CAST] : names[SET_VALUE]);
@@ -694,70 +693,105 @@
         for (Object a : outArgs)  assert(a != null);
         names[LINKER_CALL] = new Name(linker, outArgs);
         if (needsCast && isGetter)
-            names[POST_CAST] = new Name(NF_checkCast, names[DMH_THIS], names[LINKER_CALL]);
+            names[POST_CAST] = new Name(getFunction(NF_checkCast), names[DMH_THIS], names[LINKER_CALL]);
         for (Name n : names)  assert(n != null);
-        // add some detail to the lambdaForm debugname,
-        // significant only for debugging
-        StringBuilder nameBuilder = new StringBuilder(kind.methodName);
-        if (isStatic) {
-            nameBuilder.append("Static");
-        } else {
-            nameBuilder.append("Field");
-        }
-        if (needsCast)  nameBuilder.append("Cast");
-        if (needsInit)  nameBuilder.append("Init");
+
+        LambdaForm form;
         if (needsCast || needsInit) {
             // can't use the pre-generated form when casting and/or initializing
-            return new LambdaForm(nameBuilder.toString(), ARG_LIMIT, names, RESULT);
+            form = new LambdaForm(ARG_LIMIT, names, RESULT);
         } else {
-            return new LambdaForm(nameBuilder.toString(), ARG_LIMIT, names, RESULT, kind);
+            form = new LambdaForm(ARG_LIMIT, names, RESULT, kind);
         }
+
+        if (LambdaForm.debugNames()) {
+            // add some detail to the lambdaForm debugname,
+            // significant only for debugging
+            StringBuilder nameBuilder = new StringBuilder(kind.methodName);
+            if (isStatic) {
+                nameBuilder.append("Static");
+            } else {
+                nameBuilder.append("Field");
+            }
+            if (needsCast) {
+                nameBuilder.append("Cast");
+            }
+            if (needsInit) {
+                nameBuilder.append("Init");
+            }
+            LambdaForm.associateWithDebugName(form, nameBuilder.toString());
+        }
+        return form;
     }
 
     /**
      * Pre-initialized NamedFunctions for bootstrapping purposes.
-     * Factored in an inner class to delay initialization until first usage.
      */
-    static final NamedFunction
-            NF_internalMemberName,
-            NF_internalMemberNameEnsureInit,
-            NF_ensureInitialized,
-            NF_fieldOffset,
-            NF_checkBase,
-            NF_staticBase,
-            NF_staticOffset,
-            NF_checkCast,
-            NF_allocateInstance,
-            NF_constructorMethod,
-            NF_UNSAFE;
-    static {
+    static final byte NF_internalMemberName = 0,
+            NF_internalMemberNameEnsureInit = 1,
+            NF_ensureInitialized = 2,
+            NF_fieldOffset = 3,
+            NF_checkBase = 4,
+            NF_staticBase = 5,
+            NF_staticOffset = 6,
+            NF_checkCast = 7,
+            NF_allocateInstance = 8,
+            NF_constructorMethod = 9,
+            NF_UNSAFE = 10,
+            NF_LIMIT = 11;
+
+    private static final @Stable NamedFunction[] NFS = new NamedFunction[NF_LIMIT];
+
+    private static NamedFunction getFunction(byte func) {
+        NamedFunction nf = NFS[func];
+        if (nf != null) {
+            return nf;
+        }
+        // Each nf must be statically invocable or we get tied up in our bootstraps.
+        nf = NFS[func] = createFunction(func);
+        assert(InvokerBytecodeGenerator.isStaticallyInvocable(nf));
+        return nf;
+    }
+
+    private static NamedFunction createFunction(byte func) {
         try {
-            NamedFunction nfs[] = {
-                    NF_internalMemberName = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("internalMemberName", Object.class)),
-                    NF_internalMemberNameEnsureInit = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("internalMemberNameEnsureInit", Object.class)),
-                    NF_ensureInitialized = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("ensureInitialized", Object.class)),
-                    NF_fieldOffset = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("fieldOffset", Object.class)),
-                    NF_checkBase = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("checkBase", Object.class)),
-                    NF_staticBase = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("staticBase", Object.class)),
-                    NF_staticOffset = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("staticOffset", Object.class)),
-                    NF_checkCast = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("checkCast", Object.class, Object.class)),
-                    NF_allocateInstance = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("allocateInstance", Object.class)),
-                    NF_constructorMethod = new NamedFunction(DirectMethodHandle.class
-                            .getDeclaredMethod("constructorMethod", Object.class)),
-                    NF_UNSAFE = new NamedFunction(new MemberName(MethodHandleStatics.class
-                            .getDeclaredField("UNSAFE")))
-            };
-            // Each nf must be statically invocable or we get tied up in our bootstraps.
-            assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs));
+            switch (func) {
+                case NF_internalMemberName:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("internalMemberName", Object.class));
+                case NF_internalMemberNameEnsureInit:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("internalMemberNameEnsureInit", Object.class));
+                case NF_ensureInitialized:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("ensureInitialized", Object.class));
+                case NF_fieldOffset:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("fieldOffset", Object.class));
+                case NF_checkBase:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("checkBase", Object.class));
+                case NF_staticBase:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("staticBase", Object.class));
+                case NF_staticOffset:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("staticOffset", Object.class));
+                case NF_checkCast:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("checkCast", Object.class, Object.class));
+                case NF_allocateInstance:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("allocateInstance", Object.class));
+                case NF_constructorMethod:
+                    return new NamedFunction(DirectMethodHandle.class
+                            .getDeclaredMethod("constructorMethod", Object.class));
+                case NF_UNSAFE:
+                    return new NamedFunction(new MemberName(MethodHandleStatics.class
+                            .getDeclaredField("UNSAFE")));
+                default:
+                    throw newInternalError("Unknown function: " + func);
+            }
         } catch (ReflectiveOperationException ex) {
             throw newInternalError(ex);
         }
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
index d903d48..7349ea2 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
@@ -73,6 +73,7 @@
     private static final String LL_SIG  = "(L" + OBJ + ";)L" + OBJ + ";";
     private static final String LLV_SIG = "(L" + OBJ + ";L" + OBJ + ";)V";
     private static final String CLASS_PREFIX = LF + "$";
+    private static final String SOURCE_PREFIX = "LambdaForm$";
 
     /** Name of its super class*/
     static final String INVOKER_SUPER_NAME = OBJ;
@@ -80,9 +81,6 @@
     /** Name of new class */
     private final String className;
 
-    /** Name of the source file (for stack trace printing). */
-    private final String sourceFile;
-
     private final LambdaForm lambdaForm;
     private final String     invokerName;
     private final MethodType invokerType;
@@ -109,8 +107,7 @@
         if (DUMP_CLASS_FILES) {
             className = makeDumpableClassName(className);
         }
-        this.className  = CLASS_PREFIX + className;
-        this.sourceFile = "LambdaForm$" + className;
+        this.className  = className;
         this.lambdaForm = lambdaForm;
         this.invokerName = invokerName;
         this.invokerType = invokerType;
@@ -130,7 +127,7 @@
 
     /** For generating customized code for a single LambdaForm. */
     private InvokerBytecodeGenerator(String className, LambdaForm form, MethodType invokerType) {
-        this(className, form.debugName, form, invokerType);
+        this(className, form.lambdaName(), form, invokerType);
     }
 
     /** For generating customized code for a single LambdaForm. */
@@ -173,6 +170,13 @@
         }
     }
 
+    private void maybeDump(final byte[] classFile) {
+        if (DUMP_CLASS_FILES) {
+            maybeDump(CLASS_PREFIX + className, classFile);
+        }
+    }
+
+    // Also used from BoundMethodHandle
     static void maybeDump(final String className, final byte[] classFile) {
         if (DUMP_CLASS_FILES) {
             java.security.AccessController.doPrivileged(
@@ -306,8 +310,9 @@
     private ClassWriter classFilePrologue() {
         final int NOT_ACC_PUBLIC = 0;  // not ACC_PUBLIC
         cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
-        cw.visit(Opcodes.V1_8, NOT_ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, className, null, INVOKER_SUPER_NAME, null);
-        cw.visitSource(sourceFile, null);
+        cw.visit(Opcodes.V1_8, NOT_ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER,
+                CLASS_PREFIX + className, null, INVOKER_SUPER_NAME, null);
+        cw.visitSource(SOURCE_PREFIX + className, null);
         return cw;
     }
 
@@ -617,12 +622,11 @@
         return resolvedMember;
     }
 
-    private static MemberName lookupPregenerated(LambdaForm form) {
+    private static MemberName lookupPregenerated(LambdaForm form, MethodType invokerType) {
         if (form.customized != null) {
             // No pre-generated version for customized LF
             return null;
         }
-        MethodType invokerType = form.methodType();
         String name = form.kind.methodName;
         switch (form.kind) {
             case BOUND_REINVOKER: {
@@ -670,7 +674,7 @@
      * Generate customized bytecode for a given LambdaForm.
      */
     static MemberName generateCustomizedCode(LambdaForm form, MethodType invokerType) {
-        MemberName pregenerated = lookupPregenerated(form);
+        MemberName pregenerated = lookupPregenerated(form, invokerType);
         if (pregenerated != null)  return pregenerated; // pre-generated bytecode
 
         InvokerBytecodeGenerator g = new InvokerBytecodeGenerator("MH", form, invokerType);
@@ -720,7 +724,7 @@
         bogusMethod(lambdaForm);
 
         final byte[] classFile = toByteArray();
-        maybeDump(className, classFile);
+        maybeDump(classFile);
         return classFile;
     }
 
@@ -908,7 +912,7 @@
         //MethodHandle.class already covered
     };
 
-    static boolean isStaticallyInvocable(NamedFunction[] functions) {
+    static boolean isStaticallyInvocable(NamedFunction ... functions) {
         for (NamedFunction nf : functions) {
             if (!isStaticallyInvocable(nf.member())) {
                 return false;
@@ -1761,7 +1765,7 @@
         bogusMethod(invokerType);
 
         final byte[] classFile = cw.toByteArray();
-        maybeDump(className, classFile);
+        maybeDump(classFile);
         return classFile;
     }
 
@@ -1829,7 +1833,7 @@
         bogusMethod(dstType);
 
         final byte[] classFile = cw.toByteArray();
-        maybeDump(className, classFile);
+        maybeDump(classFile);
         return classFile;
     }
 
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java
index 0a97622..8eeb4c3 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java
@@ -132,7 +132,7 @@
         MethodType mtype = targetType;
         MethodType invokerType = mtype.insertParameterTypes(0, VarHandle.class);
 
-        LambdaForm lform = varHandleMethodInvokerHandleForm(ak.methodName(), mtype, isExact);
+        LambdaForm lform = varHandleMethodInvokerHandleForm(ak, mtype, isExact);
         VarHandle.AccessDescriptor ad = new VarHandle.AccessDescriptor(mtype, ak.at.ordinal(), ak.ordinal());
         MethodHandle invoker = BoundMethodHandle.bindSingle(invokerType, lform, ad);
 
@@ -313,21 +313,21 @@
         Object[] outArgs = Arrays.copyOfRange(names, CALL_MH, OUTARG_LIMIT, Object[].class);
         Object mtypeArg = (customized ? mtype : names[MTYPE_ARG]);
         if (!isGeneric) {
-            names[CHECK_TYPE] = new Name(NF_checkExactType, names[CALL_MH], mtypeArg);
+            names[CHECK_TYPE] = new Name(getFunction(NF_checkExactType), names[CALL_MH], mtypeArg);
             // mh.invokeExact(a*):R => checkExactType(mh, TYPEOF(a*:R)); mh.invokeBasic(a*)
         } else {
-            names[CHECK_TYPE] = new Name(NF_checkGenericType, names[CALL_MH], mtypeArg);
+            names[CHECK_TYPE] = new Name(getFunction(NF_checkGenericType), names[CALL_MH], mtypeArg);
             // mh.invokeGeneric(a*):R => checkGenericType(mh, TYPEOF(a*:R)).invokeBasic(a*)
             outArgs[0] = names[CHECK_TYPE];
         }
         if (CHECK_CUSTOM != -1) {
-            names[CHECK_CUSTOM] = new Name(NF_checkCustomized, outArgs[0]);
+            names[CHECK_CUSTOM] = new Name(getFunction(NF_checkCustomized), outArgs[0]);
         }
         names[LINKER_CALL] = new Name(outCallType, outArgs);
         if (customized) {
-            lform = new LambdaForm(kind.defaultLambdaName, INARG_LIMIT, names);
+            lform = new LambdaForm(INARG_LIMIT, names);
         } else {
-            lform = new LambdaForm(kind.defaultLambdaName, INARG_LIMIT, names, kind);
+            lform = new LambdaForm(INARG_LIMIT, names, kind);
         }
         if (isLinker)
             lform.compileToBytecode();  // JVM needs a real methodOop
@@ -337,11 +337,10 @@
     }
 
 
-    static MemberName varHandleInvokeLinkerMethod(String name,
-                                                  MethodType mtype) {
+    static MemberName varHandleInvokeLinkerMethod(VarHandle.AccessMode ak, MethodType mtype) {
         LambdaForm lform;
         if (mtype.parameterSlotCount() <= MethodType.MAX_MH_ARITY - MH_LINKER_ARG_APPENDED) {
-            lform = varHandleMethodGenericLinkerHandleForm(name, mtype);
+            lform = varHandleMethodGenericLinkerHandleForm(ak, mtype);
         } else {
             // TODO
             throw newInternalError("Unsupported parameter slot count " + mtype.parameterSlotCount());
@@ -349,7 +348,8 @@
         return lform.vmentry;
     }
 
-    private static LambdaForm varHandleMethodGenericLinkerHandleForm(String name, MethodType mtype) {
+    private static LambdaForm varHandleMethodGenericLinkerHandleForm(VarHandle.AccessMode ak,
+            MethodType mtype) {
         // TODO Cache form?
 
         final int THIS_VH      = 0;
@@ -368,7 +368,7 @@
         }
         names[VAD_ARG] = new Name(ARG_LIMIT, BasicType.basicType(Object.class));
 
-        names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[THIS_VH], names[VAD_ARG]);
+        names[CHECK_TYPE] = new Name(getFunction(NF_checkVarHandleGenericType), names[THIS_VH], names[VAD_ARG]);
 
         Object[] outArgs = new Object[ARG_LIMIT + 1];
         outArgs[0] = names[CHECK_TYPE];
@@ -377,20 +377,24 @@
         }
 
         if (CHECK_CUSTOM != -1) {
-            names[CHECK_CUSTOM] = new Name(NF_checkCustomized, outArgs[0]);
+            names[CHECK_CUSTOM] = new Name(getFunction(NF_checkCustomized), outArgs[0]);
         }
 
         MethodType outCallType = mtype.insertParameterTypes(0, VarHandle.class)
                 .basicType();
         names[LINKER_CALL] = new Name(outCallType, outArgs);
-        LambdaForm lform = new LambdaForm(name + ":VarHandle_invoke_MT_" + shortenSignature(basicTypeSignature(mtype)),
-                                          ARG_LIMIT + 1, names);
-
+        LambdaForm lform = new LambdaForm(ARG_LIMIT + 1, names, VARHANDLE_LINKER);
+        if (LambdaForm.debugNames()) {
+            String name = ak.methodName() + ":VarHandle_invoke_MT_" +
+                    shortenSignature(basicTypeSignature(mtype));
+            LambdaForm.associateWithDebugName(lform, name);
+        }
         lform.compileToBytecode();
         return lform;
     }
 
-    private static LambdaForm varHandleMethodInvokerHandleForm(String name, MethodType mtype, boolean isExact) {
+    private static LambdaForm varHandleMethodInvokerHandleForm(VarHandle.AccessMode ak,
+            MethodType mtype, boolean isExact) {
         // TODO Cache form?
 
         final int THIS_MH      = 0;
@@ -416,9 +420,9 @@
         names[VAD_ARG] = new Name(getter, names[THIS_MH]);
 
         if (isExact) {
-            names[CHECK_TYPE] = new Name(NF_checkVarHandleExactType, names[CALL_VH], names[VAD_ARG]);
+            names[CHECK_TYPE] = new Name(getFunction(NF_checkVarHandleExactType), names[CALL_VH], names[VAD_ARG]);
         } else {
-            names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[CALL_VH], names[VAD_ARG]);
+            names[CHECK_TYPE] = new Name(getFunction(NF_checkVarHandleGenericType), names[CALL_VH], names[VAD_ARG]);
         }
         Object[] outArgs = new Object[ARG_LIMIT];
         outArgs[0] = names[CHECK_TYPE];
@@ -429,10 +433,14 @@
         MethodType outCallType = mtype.insertParameterTypes(0, VarHandle.class)
                 .basicType();
         names[LINKER_CALL] = new Name(outCallType, outArgs);
-        String debugName = isExact ? ":VarHandle_exactInvoker" : ":VarHandle_invoker";
-        LambdaForm lform = new LambdaForm(name + debugName + shortenSignature(basicTypeSignature(mtype)),
-                                          ARG_LIMIT, names);
-
+        Kind kind = isExact ? VARHANDLE_EXACT_INVOKER : VARHANDLE_INVOKER;
+        LambdaForm lform = new LambdaForm(ARG_LIMIT, names, kind);
+        if (LambdaForm.debugNames()) {
+            String name = ak.methodName() +
+                    (isExact ? ":VarHandle_exactInvoker_" : ":VarHandle_invoker_") +
+                    shortenSignature(basicTypeSignature(mtype));
+            LambdaForm.associateWithDebugName(lform, name);
+        }
         lform.prepare();
         return lform;
     }
@@ -535,7 +543,7 @@
         assert(names.length == nameCursor);
         assert(names[APPENDIX_ARG] != null);
         if (!skipCallSite)
-            names[CALL_MH] = new Name(NF_getCallSiteTarget, names[CSITE_ARG]);
+            names[CALL_MH] = new Name(getFunction(NF_getCallSiteTarget), names[CSITE_ARG]);
         // (site.)invokedynamic(a*):R => mh = site.getTarget(); mh.invokeBasic(a*)
         final int PREPEND_MH = 0, PREPEND_COUNT = 1;
         Object[] outArgs = Arrays.copyOfRange(names, ARG_BASE, OUTARG_LIMIT + PREPEND_COUNT, Object[].class);
@@ -543,7 +551,8 @@
         System.arraycopy(outArgs, 0, outArgs, PREPEND_COUNT, outArgs.length - PREPEND_COUNT);
         outArgs[PREPEND_MH] = names[CALL_MH];
         names[LINKER_CALL] = new Name(mtype, outArgs);
-        lform = new LambdaForm((skipCallSite ? "linkToTargetMethod" : "linkToCallSite"), INARG_LIMIT, names);
+        lform = new LambdaForm(INARG_LIMIT, names,
+                (skipCallSite ? LINK_TO_TARGET_METHOD : LINK_TO_CALL_SITE));
         lform.compileToBytecode();  // JVM needs a real methodOop
         lform = mtype.form().setCachedLambdaForm(which, lform);
         return lform;
@@ -577,31 +586,51 @@
     }
 
     // Local constant functions:
-    private static final NamedFunction
-        NF_checkExactType,
-        NF_checkGenericType,
-        NF_getCallSiteTarget,
-        NF_checkCustomized,
-        NF_checkVarHandleGenericType,
-        NF_checkVarHandleExactType;
-    static {
+    private static final byte NF_checkExactType = 0,
+        NF_checkGenericType = 1,
+        NF_getCallSiteTarget = 2,
+        NF_checkCustomized = 3,
+        NF_checkVarHandleGenericType = 4,
+        NF_checkVarHandleExactType = 5,
+        NF_LIMIT = 6;
+
+    private static final @Stable NamedFunction[] NFS = new NamedFunction[NF_LIMIT];
+
+    private static NamedFunction getFunction(byte func) {
+        NamedFunction nf = NFS[func];
+        if (nf != null) {
+            return nf;
+        }
+        NFS[func] = nf = createFunction(func);
+        // Each nf must be statically invocable or we get tied up in our bootstraps.
+        assert(InvokerBytecodeGenerator.isStaticallyInvocable(nf));
+        return nf;
+    }
+
+    private static NamedFunction createFunction(byte func) {
         try {
-            NamedFunction nfs[] = {
-                NF_checkExactType = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("checkExactType", MethodHandle.class,  MethodType.class)),
-                NF_checkGenericType = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("checkGenericType", MethodHandle.class,  MethodType.class)),
-                NF_getCallSiteTarget = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("getCallSiteTarget", CallSite.class)),
-                NF_checkCustomized = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("checkCustomized", MethodHandle.class)),
-                NF_checkVarHandleGenericType = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("checkVarHandleGenericType", VarHandle.class, VarHandle.AccessDescriptor.class)),
-                NF_checkVarHandleExactType = new NamedFunction(Invokers.class
-                        .getDeclaredMethod("checkVarHandleExactType", VarHandle.class, VarHandle.AccessDescriptor.class)),
-            };
-            // Each nf must be statically invocable or we get tied up in our bootstraps.
-            assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs));
+            switch (func) {
+                case NF_checkExactType:
+                    return new NamedFunction(Invokers.class
+                        .getDeclaredMethod("checkExactType", MethodHandle.class,  MethodType.class));
+                case NF_checkGenericType:
+                    return new NamedFunction(Invokers.class
+                        .getDeclaredMethod("checkGenericType", MethodHandle.class,  MethodType.class));
+                case NF_getCallSiteTarget:
+                    return new NamedFunction(Invokers.class
+                        .getDeclaredMethod("getCallSiteTarget", CallSite.class));
+                case NF_checkCustomized:
+                    return new NamedFunction(Invokers.class
+                        .getDeclaredMethod("checkCustomized", MethodHandle.class));
+                case NF_checkVarHandleGenericType:
+                    return new NamedFunction(Invokers.class
+                        .getDeclaredMethod("checkVarHandleGenericType", VarHandle.class, VarHandle.AccessDescriptor.class));
+                case NF_checkVarHandleExactType:
+                    return new NamedFunction(Invokers.class
+                        .getDeclaredMethod("checkVarHandleExactType", VarHandle.class, VarHandle.AccessDescriptor.class));
+                default:
+                    throw newInternalError("Unknown function: " + func);
+            }
         } catch (ReflectiveOperationException ex) {
             throw newInternalError(ex);
         }
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
index 96b0a94..bde9438 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -126,7 +126,6 @@
     final boolean forceInline;
     final MethodHandle customized;
     @Stable final Name[] names;
-    final String debugName;
     final Kind kind;
     MemberName vmentry;   // low-level behavior, or null if not yet prepared
     private boolean isCompiled;
@@ -268,22 +267,24 @@
     }
 
     enum Kind {
-        GENERIC(""),
+        GENERIC("invoke"),
         ZERO("zero"),
         IDENTITY("identity"),
-        BOUND_REINVOKER("BMH.reinvoke"),
-        REINVOKER("MH.reinvoke"),
-        DELEGATE("MH.delegate"),
-        EXACT_LINKER("MH.invokeExact_MT"),
-        EXACT_INVOKER("MH.exactInvoker"),
-        GENERIC_LINKER("MH.invoke_MT"),
-        GENERIC_INVOKER("MH.invoker"),
-        DIRECT_INVOKE_VIRTUAL("DMH.invokeVirtual"),
-        DIRECT_INVOKE_SPECIAL("DMH.invokeSpecial"),
-        DIRECT_INVOKE_STATIC("DMH.invokeStatic"),
-        DIRECT_NEW_INVOKE_SPECIAL("DMH.newInvokeSpecial"),
-        DIRECT_INVOKE_INTERFACE("DMH.invokeInterface"),
-        DIRECT_INVOKE_STATIC_INIT("DMH.invokeStaticInit"),
+        BOUND_REINVOKER("BMH.reinvoke", "reinvoke"),
+        REINVOKER("MH.reinvoke", "reinvoke"),
+        DELEGATE("MH.delegate", "delegate"),
+        EXACT_LINKER("MH.invokeExact_MT", "invokeExact_MT"),
+        EXACT_INVOKER("MH.exactInvoker", "exactInvoker"),
+        GENERIC_LINKER("MH.invoke_MT", "invoke_MT"),
+        GENERIC_INVOKER("MH.invoker", "invoker"),
+        LINK_TO_TARGET_METHOD("linkToTargetMethod"),
+        LINK_TO_CALL_SITE("linkToCallSite"),
+        DIRECT_INVOKE_VIRTUAL("DMH.invokeVirtual", "invokeVirtual"),
+        DIRECT_INVOKE_SPECIAL("DMH.invokeSpecial", "invokeSpecial"),
+        DIRECT_INVOKE_STATIC("DMH.invokeStatic", "invokeStatic"),
+        DIRECT_NEW_INVOKE_SPECIAL("DMH.newInvokeSpecial", "newInvokeSpecial"),
+        DIRECT_INVOKE_INTERFACE("DMH.invokeInterface", "invokeInterface"),
+        DIRECT_INVOKE_STATIC_INIT("DMH.invokeStaticInit", "invokeStaticInit"),
         GET_OBJECT("getObject"),
         PUT_OBJECT("putObject"),
         GET_OBJECT_VOLATILE("getObjectVolatile"),
@@ -319,41 +320,46 @@
         GET_DOUBLE("getDouble"),
         PUT_DOUBLE("putDouble"),
         GET_DOUBLE_VOLATILE("getDoubleVolatile"),
-        PUT_DOUBLE_VOLATILE("putDoubleVolatile");
+        PUT_DOUBLE_VOLATILE("putDoubleVolatile"),
+        TRY_FINALLY("tryFinally"),
+        COLLECT("collect"),
+        CONVERT("convert"),
+        SPREAD("spread"),
+        LOOP("loop"),
+        FIELD("field"),
+        GUARD("guard"),
+        GUARD_WITH_CATCH("guardWithCatch"),
+        VARHANDLE_EXACT_INVOKER("VH.exactInvoker"),
+        VARHANDLE_INVOKER("VH.invoker", "invoker"),
+        VARHANDLE_LINKER("VH.invoke_MT", "invoke_MT");
 
         final String defaultLambdaName;
         final String methodName;
 
         private Kind(String defaultLambdaName) {
+            this(defaultLambdaName, defaultLambdaName);
+        }
+
+        private Kind(String defaultLambdaName, String methodName) {
             this.defaultLambdaName = defaultLambdaName;
-            int p = defaultLambdaName.indexOf('.');
-            if (p > -1) {
-                this.methodName = defaultLambdaName.substring(p + 1);
-            } else {
-                this.methodName = defaultLambdaName;
-            }
+            this.methodName = methodName;
         }
     }
 
-    LambdaForm(String debugName,
-               int arity, Name[] names, int result) {
-        this(debugName, arity, names, result, /*forceInline=*/true, /*customized=*/null, Kind.GENERIC);
+    LambdaForm(int arity, Name[] names, int result) {
+        this(arity, names, result, /*forceInline=*/true, /*customized=*/null, Kind.GENERIC);
     }
-    LambdaForm(String debugName,
-               int arity, Name[] names, int result, Kind kind) {
-        this(debugName, arity, names, result, /*forceInline=*/true, /*customized=*/null, kind);
+    LambdaForm(int arity, Name[] names, int result, Kind kind) {
+        this(arity, names, result, /*forceInline=*/true, /*customized=*/null, kind);
     }
-    LambdaForm(String debugName,
-               int arity, Name[] names, int result, boolean forceInline, MethodHandle customized) {
-        this(debugName, arity, names, result, forceInline, customized, Kind.GENERIC);
+    LambdaForm(int arity, Name[] names, int result, boolean forceInline, MethodHandle customized) {
+        this(arity, names, result, forceInline, customized, Kind.GENERIC);
     }
-    LambdaForm(String debugName,
-               int arity, Name[] names, int result, boolean forceInline, MethodHandle customized, Kind kind) {
+    LambdaForm(int arity, Name[] names, int result, boolean forceInline, MethodHandle customized, Kind kind) {
         assert(namesOK(arity, names));
         this.arity = arity;
         this.result = fixResult(result, names);
         this.names = names.clone();
-        this.debugName = fixDebugName(debugName);
         this.forceInline = forceInline;
         this.customized = customized;
         this.kind = kind;
@@ -364,31 +370,23 @@
             compileToBytecode();
         }
     }
-    LambdaForm(String debugName,
-               int arity, Name[] names) {
-        this(debugName, arity, names, LAST_RESULT, /*forceInline=*/true, /*customized=*/null, Kind.GENERIC);
+    LambdaForm(int arity, Name[] names) {
+        this(arity, names, LAST_RESULT, /*forceInline=*/true, /*customized=*/null, Kind.GENERIC);
     }
-    LambdaForm(String debugName,
-               int arity, Name[] names, Kind kind) {
-        this(debugName, arity, names, LAST_RESULT, /*forceInline=*/true, /*customized=*/null, kind);
+    LambdaForm(int arity, Name[] names, Kind kind) {
+        this(arity, names, LAST_RESULT, /*forceInline=*/true, /*customized=*/null, kind);
     }
-    LambdaForm(String debugName,
-               int arity, Name[] names, boolean forceInline) {
-        this(debugName, arity, names, LAST_RESULT, forceInline, /*customized=*/null, Kind.GENERIC);
+    LambdaForm(int arity, Name[] names, boolean forceInline) {
+        this(arity, names, LAST_RESULT, forceInline, /*customized=*/null, Kind.GENERIC);
     }
-    LambdaForm(String debugName,
-               int arity, Name[] names, boolean forceInline, Kind kind) {
-        this(debugName, arity, names, LAST_RESULT, forceInline, /*customized=*/null, kind);
+    LambdaForm(int arity, Name[] names, boolean forceInline, Kind kind) {
+        this(arity, names, LAST_RESULT, forceInline, /*customized=*/null, kind);
     }
-    LambdaForm(String debugName,
-               Name[] formals, Name[] temps, Name result) {
-        this(debugName,
-             formals.length, buildNames(formals, temps, result), LAST_RESULT, /*forceInline=*/true, /*customized=*/null);
+    LambdaForm(Name[] formals, Name[] temps, Name result) {
+        this(formals.length, buildNames(formals, temps, result), LAST_RESULT, /*forceInline=*/true, /*customized=*/null);
     }
-    LambdaForm(String debugName,
-               Name[] formals, Name[] temps, Name result, boolean forceInline) {
-        this(debugName,
-             formals.length, buildNames(formals, temps, result), LAST_RESULT, forceInline, /*customized=*/null);
+    LambdaForm(Name[] formals, Name[] temps, Name result, boolean forceInline) {
+        this(formals.length, buildNames(formals, temps, result), LAST_RESULT, forceInline, /*customized=*/null);
     }
 
     private static Name[] buildNames(Name[] formals, Name[] temps, Name result) {
@@ -408,10 +406,9 @@
         this.arity = mt.parameterCount();
         this.result = (mt.returnType() == void.class || mt.returnType() == Void.class) ? -1 : arity;
         this.names = buildEmptyNames(arity, mt, result == -1);
-        this.debugName = "LF.zero";
         this.forceInline = true;
         this.customized = null;
-        this.kind = Kind.GENERIC;
+        this.kind = Kind.ZERO;
         assert(nameRefsAreLegal());
         assert(isEmpty());
         String sig = null;
@@ -436,36 +433,46 @@
         return result;
     }
 
-    private static String fixDebugName(String debugName) {
-        if (DEBUG_NAME_COUNTERS != null) {
-            int under = debugName.indexOf('_');
-            int length = debugName.length();
-            if (under < 0)  under = length;
-            String debugNameStem = debugName.substring(0, under);
-            Integer ctr;
-            synchronized (DEBUG_NAME_COUNTERS) {
-                ctr = DEBUG_NAME_COUNTERS.get(debugNameStem);
-                if (ctr == null)  ctr = 0;
-                DEBUG_NAME_COUNTERS.put(debugNameStem, ctr+1);
-            }
-            StringBuilder buf = new StringBuilder(debugNameStem);
-            buf.append('_');
-            int leadingZero = buf.length();
-            buf.append((int) ctr);
-            for (int i = buf.length() - leadingZero; i < 3; i++)
-                buf.insert(leadingZero, '0');
-            if (under < length) {
-                ++under;    // skip "_"
-                while (under < length && Character.isDigit(debugName.charAt(under))) {
-                    ++under;
-                }
-                if (under < length && debugName.charAt(under) == '_')  ++under;
-                if (under < length)
-                    buf.append('_').append(debugName, under, length);
-            }
-            return buf.toString();
+    static boolean debugNames() {
+        return DEBUG_NAME_COUNTERS != null;
+    }
+
+    static void associateWithDebugName(LambdaForm form, String name) {
+        assert (debugNames());
+        synchronized (DEBUG_NAMES) {
+            DEBUG_NAMES.put(form, name);
         }
-        return debugName;
+    }
+
+    String lambdaName() {
+        if (DEBUG_NAMES != null) {
+            synchronized (DEBUG_NAMES) {
+                String name = DEBUG_NAMES.get(this);
+                if (name == null) {
+                    name = generateDebugName();
+                }
+                return name;
+            }
+        }
+        return kind.defaultLambdaName;
+    }
+
+    private String generateDebugName() {
+        assert (debugNames());
+        String debugNameStem = kind.defaultLambdaName;
+        Integer ctr = DEBUG_NAME_COUNTERS.getOrDefault(debugNameStem, 0);
+        DEBUG_NAME_COUNTERS.put(debugNameStem, ctr + 1);
+        StringBuilder buf = new StringBuilder(debugNameStem);
+        int leadingZero = buf.length();
+        buf.append((int) ctr);
+        for (int i = buf.length() - leadingZero; i < 3; i++) {
+            buf.insert(leadingZero, '0');
+        }
+        buf.append('_');
+        buf.append(basicTypeSignature());
+        String name = buf.toString();
+        associateWithDebugName(this, name);
+        return name;
     }
 
     private static boolean namesOK(int arity, Name[] names) {
@@ -482,7 +489,7 @@
 
     /** Customize LambdaForm for a particular MethodHandle */
     LambdaForm customize(MethodHandle mh) {
-        LambdaForm customForm = new LambdaForm(debugName, arity, names, result, forceInline, mh, kind);
+        LambdaForm customForm = new LambdaForm(arity, names, result, forceInline, mh, kind);
         if (COMPILE_THRESHOLD >= 0 && isCompiled) {
             // If shared LambdaForm has been compiled, compile customized version as well.
             customForm.compileToBytecode();
@@ -634,7 +641,7 @@
         for (int i = 0; i < arity; ++i) {
             ptypes[i] = parameterType(i).btClass;
         }
-        return MethodType.methodType(returnType().btClass, ptypes);
+        return MethodType.makeImpl(returnType().btClass, ptypes, true);
     }
 
     /** Return ABC_Z, where the ABC are parameter type characters, and Z is the return type character. */
@@ -670,7 +677,7 @@
         for (int i = 0; i < ptypes.length; i++)
             ptypes[i] = basicType(sig.charAt(i)).btClass;
         Class<?> rtype = signatureReturn(sig).btClass;
-        return MethodType.methodType(rtype, ptypes);
+        return MethodType.makeImpl(rtype, ptypes, true);
     }
 
     /**
@@ -840,6 +847,10 @@
         if (vmentry != null && isCompiled) {
             return;  // already compiled somehow
         }
+
+        // Obtain the invoker MethodType outside of the following try block.
+        // This ensures that an IllegalArgumentException is directly thrown if the
+        // type would have 256 or more parameters
         MethodType invokerType = methodType();
         assert(vmentry == null || vmentry.getMethodType().basicType().equals(invokerType));
         try {
@@ -894,10 +905,6 @@
         }
         return true;
     }
-    private static boolean returnTypesMatch(String sig, Object[] av, Object res) {
-        MethodHandle mh = (MethodHandle) av[0];
-        return valueMatches(signatureReturn(sig), mh.type().returnType(), res);
-    }
     private static boolean checkInt(Class<?> type, Object x) {
         assert(x instanceof Integer);
         if (type == int.class)  return true;
@@ -1030,7 +1037,8 @@
     }
 
     public String toString() {
-        StringBuilder buf = new StringBuilder(debugName+"=Lambda(");
+        String lambdaName = lambdaName();
+        StringBuilder buf = new StringBuilder(lambdaName + "=Lambda(");
         for (int i = 0; i < names.length; i++) {
             if (i == arity)  buf.append(")=>{");
             Name n = names[i];
@@ -1171,7 +1179,6 @@
             // If we have a cached invoker, call it right away.
             // NOTE: The invoker always returns a reference value.
             if (TRACE_INTERPRETER)  return invokeWithArgumentsTracing(arguments);
-            assert(checkArgumentTypes(arguments, methodType()));
             return invoker().invokeBasic(resolvedHandle(), arguments);
         }
 
@@ -1189,7 +1196,6 @@
                     traceInterpreter("| resolve", this);
                     resolvedHandle();
                 }
-                assert(checkArgumentTypes(arguments, methodType()));
                 rval = invoker().invokeBasic(resolvedHandle(), arguments);
             } catch (Throwable ex) {
                 traceInterpreter("] throw =>", ex);
@@ -1205,23 +1211,6 @@
             return invoker = computeInvoker(methodType().form());
         }
 
-        private static boolean checkArgumentTypes(Object[] arguments, MethodType methodType) {
-            if (true)  return true;  // FIXME
-            MethodType dstType = methodType.form().erasedType();
-            MethodType srcType = dstType.basicType().wrap();
-            Class<?>[] ptypes = new Class<?>[arguments.length];
-            for (int i = 0; i < arguments.length; i++) {
-                Object arg = arguments[i];
-                Class<?> ptype = arg == null ? Object.class : arg.getClass();
-                // If the dest. type is a primitive we keep the
-                // argument type.
-                ptypes[i] = dstType.parameterType(i).isPrimitive() ? ptype : Object.class;
-            }
-            MethodType argType = MethodType.methodType(srcType.returnType(), ptypes).wrap();
-            assert(argType.isConvertibleTo(srcType)) : "wrong argument types: cannot convert " + argType + " to " + srcType;
-            return true;
-        }
-
         MethodType methodType() {
             if (resolvedHandle != null)
                 return resolvedHandle.type();
@@ -1717,7 +1706,7 @@
         boolean isVoid = (type == V_TYPE);
         Class<?> btClass = type.btClass;
         MethodType zeType = MethodType.methodType(btClass);
-        MethodType idType = (isVoid) ? zeType : zeType.appendParameterTypes(btClass);
+        MethodType idType = (isVoid) ? zeType : MethodType.methodType(btClass, btClass);
 
         // Look up symbolic names.  It might not be necessary to have these,
         // but if we need to emit direct references to bytecodes, it helps.
@@ -1742,7 +1731,7 @@
         // bootstrap dependency on this method in case we're interpreting LFs
         if (isVoid) {
             Name[] idNames = new Name[] { argument(0, L_TYPE) };
-            idForm = new LambdaForm(idMem.getName(), 1, idNames, VOID_RESULT, Kind.IDENTITY);
+            idForm = new LambdaForm(1, idNames, VOID_RESULT, Kind.IDENTITY);
             idForm.compileToBytecode();
             idFun = new NamedFunction(idMem, SimpleMethodHandle.make(idMem.getInvocationType(), idForm));
 
@@ -1750,14 +1739,14 @@
             zeFun = idFun;
         } else {
             Name[] idNames = new Name[] { argument(0, L_TYPE), argument(1, type) };
-            idForm = new LambdaForm(idMem.getName(), 2, idNames, 1, Kind.IDENTITY);
+            idForm = new LambdaForm(2, idNames, 1, Kind.IDENTITY);
             idForm.compileToBytecode();
             idFun = new NamedFunction(idMem, MethodHandleImpl.makeIntrinsic(
                     idMem.getInvocationType(), idForm, MethodHandleImpl.Intrinsic.IDENTITY));
 
             Object zeValue = Wrapper.forBasicType(btChar).zero();
             Name[] zeNames = new Name[] { argument(0, L_TYPE), new Name(idFun, zeValue) };
-            zeForm = new LambdaForm(zeMem.getName(), 1, zeNames, 1, Kind.ZERO);
+            zeForm = new LambdaForm(1, zeNames, 1, Kind.ZERO);
             zeForm.compileToBytecode();
             zeFun = new NamedFunction(zeMem, MethodHandleImpl.makeIntrinsic(
                     zeMem.getInvocationType(), zeForm, MethodHandleImpl.Intrinsic.ZERO));
@@ -1805,11 +1794,15 @@
     }
 
     private static final HashMap<String,Integer> DEBUG_NAME_COUNTERS;
+    private static final HashMap<LambdaForm,String> DEBUG_NAMES;
     static {
-        if (debugEnabled())
+        if (debugEnabled()) {
             DEBUG_NAME_COUNTERS = new HashMap<>();
-        else
+            DEBUG_NAMES = new HashMap<>();
+        } else {
             DEBUG_NAME_COUNTERS = null;
+            DEBUG_NAMES = null;
+        }
     }
 
     static {
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java
index cc4b97b..bcf1733 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java
@@ -40,7 +40,6 @@
     private byte flags;
     private int firstChange;
     private Name resultName;
-    private String debugName;
     private ArrayList<Name> dups;
 
     private static final int F_TRANS = 0x10, F_OWNED = 0x03;
@@ -50,15 +49,15 @@
         setNames(lf.names);
         int result = lf.result;
         if (result == LAST_RESULT)  result = length - 1;
-        if (result >= 0 && lf.names[result].type != V_TYPE)
+        if (result >= 0 && lf.names[result].type != V_TYPE) {
             resultName = lf.names[result];
-        debugName = lf.debugName;
+        }
         assert(lf.nameRefsAreLegal());
     }
 
     private LambdaForm lambdaForm() {
         assert(!inTrans());  // need endEdit call to tidy things up
-        return new LambdaForm(debugName, arity, nameArray(), resultIndex());
+        return new LambdaForm(arity, nameArray(), resultIndex());
     }
 
     Name name(int i) {
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java
index ddd60ca..e066a60 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java
@@ -532,7 +532,8 @@
         assert(pos > 0);  // cannot spread the MH arg itself
 
         Name spreadParam = new Name(L_TYPE);
-        Name checkSpread = new Name(MethodHandleImpl.NF_checkSpreadArgument, spreadParam, arrayLength);
+        Name checkSpread = new Name(MethodHandleImpl.getFunction(MethodHandleImpl.NF_checkSpreadArgument),
+                spreadParam, arrayLength);
 
         // insert the new expressions
         int exprPos = lambdaForm.arity();
@@ -915,7 +916,7 @@
             }
         }
 
-        form = new LambdaForm(lambdaForm.debugName, arity2, names2, result2);
+        form = new LambdaForm(arity2, names2, result2);
         return putInCache(key, form);
     }
 
@@ -932,14 +933,14 @@
 
         // replace the null entry in the MHImpl.loop invocation with localTypes
         Name invokeLoop = lambdaForm.names[pos + 1];
-        assert(invokeLoop.function == NF_loop);
+        assert(invokeLoop.function.equals(MethodHandleImpl.getFunction(NF_loop)));
         Object[] args = Arrays.copyOf(invokeLoop.arguments, invokeLoop.arguments.length);
         assert(args[0] == null);
         args[0] = localTypes;
 
         LambdaFormBuffer buf = buffer();
         buf.startEdit();
-        buf.changeName(pos + 1, new Name(NF_loop, args));
+        buf.changeName(pos + 1, new Name(MethodHandleImpl.getFunction(NF_loop), args));
         form = buf.endEdit();
 
         return putInCache(key, form);
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java
index 92ab77c..41a4545 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java
@@ -148,7 +148,7 @@
                 Object[] typeInfo = (Object[]) type;
                 Class<?>[] ptypes = (Class<?>[]) typeInfo[1];
                 Class<?> rtype = (Class<?>) typeInfo[0];
-                MethodType res = MethodType.methodType(rtype, ptypes);
+                MethodType res = MethodType.makeImpl(rtype, ptypes, true);
                 type = res;
             }
             // Make sure type is a MethodType for racing threads.
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
index 010b6180..a12fa13 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java
@@ -399,7 +399,7 @@
             assert(RETURN_CONV == names.length-1);
         }
 
-        LambdaForm form = new LambdaForm("convert", lambdaType.parameterCount(), names, RESULT);
+        LambdaForm form = new LambdaForm(lambdaType.parameterCount(), names, RESULT, Kind.CONVERT);
         return SimpleMethodHandle.make(srcType, form);
     }
 
@@ -589,7 +589,7 @@
                 // Spread the array.
                 MethodHandle aload = MethodHandles.arrayElementGetter(spreadArgType);
                 Name array = names[argIndex];
-                names[nameCursor++] = new Name(NF_checkSpreadArgument, array, spreadArgCount);
+                names[nameCursor++] = new Name(getFunction(NF_checkSpreadArgument), array, spreadArgCount);
                 for (int j = 0; j < spreadArgCount; i++, j++) {
                     indexes[i] = nameCursor;
                     names[nameCursor++] = new Name(aload, array, j);
@@ -608,7 +608,7 @@
         }
         names[names.length - 1] = new Name(target, (Object[]) targetArgs);
 
-        LambdaForm form = new LambdaForm("spread", lambdaType.parameterCount(), names);
+        LambdaForm form = new LambdaForm(lambdaType.parameterCount(), names, Kind.SPREAD);
         return SimpleMethodHandle.make(srcType, form);
     }
 
@@ -676,7 +676,7 @@
         assert(inputArgPos + chunk == collectNamePos);  // use of rest of input args also
         names[targetNamePos] = new Name(target, (Object[]) targetArgs);
 
-        LambdaForm form = new LambdaForm("collect", lambdaType.parameterCount(), names);
+        LambdaForm form = new LambdaForm(lambdaType.parameterCount(), names, Kind.COLLECT);
         return SimpleMethodHandle.make(srcType, form);
     }
 
@@ -774,7 +774,7 @@
             @Override
             public LambdaForm apply(MethodHandle target) {
                 return DelegatingMethodHandle.makeReinvokerForm(target,
-                                   MethodTypeForm.LF_DELEGATE_BLOCK_INLINING, CountingWrapper.class, "reinvoker.dontInline", false,
+                                   MethodTypeForm.LF_DELEGATE_BLOCK_INLINING, CountingWrapper.class, false,
                                    DelegatingMethodHandle.NF_getTarget, CountingWrapper.NF_maybeStopCounting);
             }
         };
@@ -934,7 +934,7 @@
 
         // profile branch
         if (PROFILE != -1) {
-            names[PROFILE] = new Name(NF_profileBoolean, names[CALL_TEST], names[GET_COUNTERS]);
+            names[PROFILE] = new Name(getFunction(NF_profileBoolean), names[CALL_TEST], names[GET_COUNTERS]);
         }
         // call selectAlternative
         names[SELECT_ALT] = new Name(getConstantHandle(MH_selectAlternative), names[TEST], names[GET_TARGET], names[GET_FALLBACK]);
@@ -943,7 +943,7 @@
         invokeArgs[0] = names[SELECT_ALT];
         names[CALL_TARGET] = new Name(basicType, invokeArgs);
 
-        lform = new LambdaForm("guard", lambdaType.parameterCount(), names, /*forceInline=*/true);
+        lform = new LambdaForm(lambdaType.parameterCount(), names, /*forceInline=*/true, Kind.GUARD);
 
         return basicType.form().setCachedLambdaForm(MethodTypeForm.LF_GWT, lform);
     }
@@ -1012,14 +1012,14 @@
 
         // t_{i+1}:L=MethodHandleImpl.guardWithCatch(target:L,exType:L,catcher:L,t_{i}:L);
         Object[] gwcArgs = new Object[] {names[GET_TARGET], names[GET_CLASS], names[GET_CATCHER], names[BOXED_ARGS]};
-        names[TRY_CATCH] = new Name(NF_guardWithCatch, gwcArgs);
+        names[TRY_CATCH] = new Name(getFunction(NF_guardWithCatch), gwcArgs);
 
         // t_{i+2}:I=MethodHandle.invokeBasic(unbox:L,t_{i+1}:L);
         MethodHandle invokeBasicUnbox = MethodHandles.basicInvoker(MethodType.methodType(basicType.rtype(), Object.class));
         Object[] unboxArgs  = new Object[] {names[GET_UNBOX_RESULT], names[TRY_CATCH]};
         names[UNBOX_RESULT] = new Name(invokeBasicUnbox, unboxArgs);
 
-        lform = new LambdaForm("guardWithCatch", lambdaType.parameterCount(), names);
+        lform = new LambdaForm(lambdaType.parameterCount(), names, Kind.GUARD_WITH_CATCH);
 
         return basicType.form().setCachedLambdaForm(MethodTypeForm.LF_GWC, lform);
     }
@@ -1085,7 +1085,7 @@
             mh = MethodHandles.dropArguments(mh, 1, Arrays.copyOfRange(type.parameterArray(), 1, arity));
             return mh;
         }
-        return makePairwiseConvert(NF_throwException.resolvedHandle(), type, false, true);
+        return makePairwiseConvert(getFunction(NF_throwException).resolvedHandle(), type, false, true);
     }
 
     static <T extends Throwable> Empty throwException(T t) throws T { throw t; }
@@ -1673,33 +1673,57 @@
     }
 
     // Local constant functions:
-    /*non-public*/ static final NamedFunction
-        NF_checkSpreadArgument,
-        NF_guardWithCatch,
-        NF_throwException,
-        NF_tryFinally,
-        NF_loop,
-        NF_profileBoolean;
 
-    static {
+    /* non-public */
+    static final byte NF_checkSpreadArgument = 0,
+            NF_guardWithCatch = 1,
+            NF_throwException = 2,
+            NF_tryFinally = 3,
+            NF_loop = 4,
+            NF_profileBoolean = 5,
+            NF_LIMIT = 6;
+
+    private static final @Stable NamedFunction[] NFS = new NamedFunction[NF_LIMIT];
+
+    static NamedFunction getFunction(byte func) {
+        NamedFunction nf = NFS[func];
+        if (nf != null) {
+            return nf;
+        }
+        return NFS[func] = createFunction(func);
+    }
+
+    private static NamedFunction createFunction(byte func) {
         try {
-            NF_checkSpreadArgument = new NamedFunction(MethodHandleImpl.class
-                    .getDeclaredMethod("checkSpreadArgument", Object.class, int.class));
-            NF_guardWithCatch = new NamedFunction(MethodHandleImpl.class
-                    .getDeclaredMethod("guardWithCatch", MethodHandle.class, Class.class,
-                            MethodHandle.class, Object[].class));
-            NF_tryFinally = new NamedFunction(MethodHandleImpl.class
-                    .getDeclaredMethod("tryFinally", MethodHandle.class, MethodHandle.class, Object[].class));
-            NF_loop = new NamedFunction(MethodHandleImpl.class
-                    .getDeclaredMethod("loop", BasicType[].class, LoopClauses.class, Object[].class));
-            NF_throwException = new NamedFunction(MethodHandleImpl.class
-                    .getDeclaredMethod("throwException", Throwable.class));
-            NF_profileBoolean = new NamedFunction(MethodHandleImpl.class
-                    .getDeclaredMethod("profileBoolean", boolean.class, int[].class));
+            switch (func) {
+                case NF_checkSpreadArgument:
+                    return new NamedFunction(MethodHandleImpl.class
+                            .getDeclaredMethod("checkSpreadArgument", Object.class, int.class));
+                case NF_guardWithCatch:
+                    return new NamedFunction(MethodHandleImpl.class
+                            .getDeclaredMethod("guardWithCatch", MethodHandle.class, Class.class,
+                                    MethodHandle.class, Object[].class));
+                case NF_tryFinally:
+                    return new NamedFunction(MethodHandleImpl.class
+                            .getDeclaredMethod("tryFinally", MethodHandle.class, MethodHandle.class, Object[].class));
+                case NF_loop:
+                    return new NamedFunction(MethodHandleImpl.class
+                            .getDeclaredMethod("loop", BasicType[].class, LoopClauses.class, Object[].class));
+                case NF_throwException:
+                    return new NamedFunction(MethodHandleImpl.class
+                            .getDeclaredMethod("throwException", Throwable.class));
+                case NF_profileBoolean:
+                    return new NamedFunction(MethodHandleImpl.class
+                            .getDeclaredMethod("profileBoolean", boolean.class, int[].class));
+                default:
+                    throw new InternalError("Undefined function: " + func);
+            }
         } catch (ReflectiveOperationException ex) {
             throw newInternalError(ex);
         }
+    }
 
+    static {
         SharedSecrets.setJavaLangInvokeAccess(new JavaLangInvokeAccess() {
             @Override
             public Object newMemberName() {
@@ -1878,7 +1902,7 @@
             Object[] lArgs =
                     new Object[]{null, // placeholder for BasicType[] localTypes - will be added by LambdaFormEditor
                             names[GET_CLAUSE_DATA], names[BOXED_ARGS]};
-            names[LOOP] = new Name(NF_loop, lArgs);
+            names[LOOP] = new Name(getFunction(NF_loop), lArgs);
 
             // t_{i+2}:I=MethodHandle.invokeBasic(unbox:L,t_{i+1}:L);
             MethodHandle invokeBasicUnbox = MethodHandles.basicInvoker(MethodType.methodType(basicType.rtype(), Object.class));
@@ -1886,7 +1910,7 @@
             names[UNBOX_RESULT] = new Name(invokeBasicUnbox, unboxArgs);
 
             lform = basicType.form().setCachedLambdaForm(MethodTypeForm.LF_LOOP,
-                    new LambdaForm("loop", lambdaType.parameterCount(), names));
+                    new LambdaForm(lambdaType.parameterCount(), names, Kind.LOOP));
         }
 
         // BOXED_ARGS is the index into the names array where the loop idiom starts
@@ -2113,14 +2137,14 @@
 
         // t_{i+1}:L=MethodHandleImpl.tryFinally(target:L,exType:L,catcher:L,t_{i}:L);
         Object[] tfArgs = new Object[] {names[GET_TARGET], names[GET_CLEANUP], names[BOXED_ARGS]};
-        names[TRY_FINALLY] = new Name(NF_tryFinally, tfArgs);
+        names[TRY_FINALLY] = new Name(getFunction(NF_tryFinally), tfArgs);
 
         // t_{i+2}:I=MethodHandle.invokeBasic(unbox:L,t_{i+1}:L);
         MethodHandle invokeBasicUnbox = MethodHandles.basicInvoker(MethodType.methodType(basicType.rtype(), Object.class));
         Object[] unboxArgs  = new Object[] {names[GET_UNBOX_RESULT], names[TRY_FINALLY]};
         names[UNBOX_RESULT] = new Name(invokeBasicUnbox, unboxArgs);
 
-        lform = new LambdaForm("tryFinally", lambdaType.parameterCount(), names);
+        lform = new LambdaForm(lambdaType.parameterCount(), names, Kind.TRY_FINALLY);
 
         return basicType.form().setCachedLambdaForm(MethodTypeForm.LF_TF, lform);
     }
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java
index 1065b8d..110369f 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java
@@ -420,7 +420,7 @@
                                                              MethodType mtype,
                                                              Object[] appendixResult) {
         // Get the signature method type
-        MethodType sigType = mtype.basicType();
+        final MethodType sigType = mtype.basicType();
 
         // Get the access kind from the method name
         VarHandle.AccessMode ak;
@@ -430,32 +430,37 @@
             throw MethodHandleStatics.newInternalError(e);
         }
 
-        // If not polymorphic in the return type, such as the compareAndSet
-        // methods that return boolean
-        if (ak.at.isMonomorphicInReturnType) {
-            if (ak.at.returnType != mtype.returnType()) {
-                // The caller contains a different return type than that
-                // defined by the method
-                throw newNoSuchMethodErrorOnVarHandle(name, mtype);
-            }
-            // Adjust the return type of the signature method type
-            sigType = sigType.changeReturnType(ak.at.returnType);
-        }
-
-        // Get the guard method type for linking
-        MethodType guardType = sigType
-                // VarHandle at start
-                .insertParameterTypes(0, VarHandle.class)
-                // Access descriptor at end
-                .appendParameterTypes(VarHandle.AccessDescriptor.class);
-
         // Create the appendix descriptor constant
         VarHandle.AccessDescriptor ad = new VarHandle.AccessDescriptor(mtype, ak.at.ordinal(), ak.ordinal());
         appendixResult[0] = ad;
 
         if (MethodHandleStatics.VAR_HANDLE_GUARDS) {
+            // If not polymorphic in the return type, such as the compareAndSet
+            // methods that return boolean
+            Class<?> guardReturnType = sigType.returnType();
+            if (ak.at.isMonomorphicInReturnType) {
+                if (ak.at.returnType != mtype.returnType()) {
+                    // The caller contains a different return type than that
+                    // defined by the method
+                    throw newNoSuchMethodErrorOnVarHandle(name, mtype);
+                }
+                // Adjust the return type of the signature method type
+                guardReturnType = ak.at.returnType;
+            }
+
+            // Get the guard method type for linking
+            final Class<?>[] guardParams = new Class<?>[sigType.parameterCount() + 2];
+            // VarHandle at start
+            guardParams[0] = VarHandle.class;
+            for (int i = 0; i < sigType.parameterCount(); i++) {
+                guardParams[i + 1] = sigType.parameterType(i);
+            }
+            // Access descriptor at end
+            guardParams[guardParams.length - 1] = VarHandle.AccessDescriptor.class;
+            MethodType guardType = MethodType.makeImpl(guardReturnType, guardParams, true);
+
             MemberName linker = new MemberName(
-                    VarHandleGuards.class, "guard_" + getVarHandleMethodSignature(sigType),
+                    VarHandleGuards.class, getVarHandleGuardMethodName(guardType),
                     guardType, REF_invokeStatic);
 
             linker = MemberName.getFactory().resolveOrNull(REF_invokeStatic, linker,
@@ -466,16 +471,18 @@
             // Fall back to lambda form linkage if guard method is not available
             // TODO Optionally log fallback ?
         }
-        return Invokers.varHandleInvokeLinkerMethod(name, mtype);
+        return Invokers.varHandleInvokeLinkerMethod(ak, mtype);
     }
-    static String getVarHandleMethodSignature(MethodType mt) {
-        StringBuilder sb = new StringBuilder(mt.parameterCount() + 2);
+    static String getVarHandleGuardMethodName(MethodType guardType) {
+        String prefix = "guard_";
+        StringBuilder sb = new StringBuilder(prefix.length() + guardType.parameterCount());
 
-        for (int i = 0; i < mt.parameterCount(); i++) {
-            Class<?> pt = mt.parameterType(i);
+        sb.append(prefix);
+        for (int i = 1; i < guardType.parameterCount() - 1; i++) {
+            Class<?> pt = guardType.parameterType(i);
             sb.append(getCharType(pt));
         }
-        sb.append('_').append(getCharType(mt.returnType()));
+        sb.append('_').append(getCharType(guardType.returnType()));
         return sb.toString();
     }
     static char getCharType(Class<?> pt) {
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java
index 860ef23..df7904d 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java
@@ -95,7 +95,7 @@
     private static final long serialVersionUID = 292L;  // {rtype, {ptype...}}
 
     // The rtype and ptypes fields define the structural identity of the method type:
-    private final Class<?>   rtype;
+    private final @Stable Class<?>   rtype;
     private final @Stable Class<?>[] ptypes;
 
     // The remaining fields are caches of various sorts:
@@ -117,7 +117,8 @@
 
     /**
      * Construct a temporary unchecked instance of MethodType for use only as a key to the intern table.
-     * Does not check the given parameters for validity, and must be discarded after it is used as a searching key.
+     * Does not check the given parameters for validity, and must discarded (if untrusted) or checked
+     * (if trusted) after it has been used as a searching key.
      * The parameters are reversed for this constructor, so that it is not accidentally used.
      */
     private MethodType(Class<?>[] ptypes, Class<?> rtype) {
@@ -181,6 +182,7 @@
         checkSlotCount(ptypes.length + slots);
         return slots;
     }
+
     static {
         // MAX_JVM_ARITY must be power of 2 minus 1 for following code trick to work:
         assert((MAX_JVM_ARITY & (MAX_JVM_ARITY+1)) == 0);
@@ -303,18 +305,26 @@
      */
     /*trusted*/ static
     MethodType makeImpl(Class<?> rtype, Class<?>[] ptypes, boolean trusted) {
-        MethodType mt = internTable.get(new MethodType(ptypes, rtype));
-        if (mt != null)
-            return mt;
         if (ptypes.length == 0) {
             ptypes = NO_PTYPES; trusted = true;
         }
-        mt = new MethodType(rtype, ptypes, trusted);
+        MethodType primordialMT = new MethodType(ptypes, rtype);
+        MethodType mt = internTable.get(primordialMT);
+        if (mt != null)
+            return mt;
+
         // promote the object to the Real Thing, and reprobe
+        if (trusted) {
+            MethodType.checkRtype(rtype);
+            MethodType.checkPtypes(ptypes);
+            mt = primordialMT;
+        } else {
+            mt = new MethodType(rtype, ptypes, false);
+        }
         mt.form = MethodTypeForm.findForm(mt);
         return internTable.add(mt);
     }
-    private static final MethodType[] objectOnlyTypes = new MethodType[20];
+    private static final @Stable MethodType[] objectOnlyTypes = new MethodType[20];
 
     /**
      * Finds or creates a method type whose components are {@code Object} with an optional trailing {@code Object[]} array.
@@ -398,9 +408,14 @@
         checkSlotCount(parameterSlotCount() + ptypesToInsert.length + ins);
         int ilen = ptypesToInsert.length;
         if (ilen == 0)  return this;
-        Class<?>[] nptypes = Arrays.copyOfRange(ptypes, 0, len+ilen);
-        System.arraycopy(nptypes, num, nptypes, num+ilen, len-num);
+        Class<?>[] nptypes = new Class<?>[len + ilen];
+        if (num > 0) {
+            System.arraycopy(ptypes, 0, nptypes, 0, num);
+        }
         System.arraycopy(ptypesToInsert, 0, nptypes, num, ilen);
+        if (num < len) {
+            System.arraycopy(ptypes, num, nptypes, num+ilen, len-num);
+        }
         return makeImpl(rtype, nptypes, true);
     }
 
@@ -636,11 +651,14 @@
         return form.basicType();
     }
 
+    private static final @Stable Class<?>[] METHOD_HANDLE_ARRAY
+            = new Class<?>[] { MethodHandle.class };
+
     /**
      * @return a version of the original type with MethodHandle prepended as the first argument
      */
     /*non-public*/ MethodType invokerType() {
-        return insertParameterTypes(0, MethodHandle.class);
+        return insertParameterTypes(0, METHOD_HANDLE_ARRAY);
     }
 
     /**
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
index 634d64d..71419c3 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template
@@ -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;
diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
index da57311..e85fd91 100644
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template
@@ -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;
         }
diff --git a/jdk/src/java.base/share/classes/java/net/ContentHandler.java b/jdk/src/java.base/share/classes/java/net/ContentHandler.java
index bea0391..119af89 100644
--- a/jdk/src/java.base/share/classes/java/net/ContentHandler.java
+++ b/jdk/src/java.base/share/classes/java/net/ContentHandler.java
@@ -37,10 +37,10 @@
  * application calls the {@code getContent} method in class
  * {@code URL} or in {@code URLConnection}.
  * The application's content handler factory (an instance of a class that
- * implements the interface {@code ContentHandlerFactory} set
- * up by a call to {@code setContentHandler}) is
- * called with a {@code String} giving the MIME type of the
- * object being received on the socket. The factory returns an
+ * implements the interface {@code ContentHandlerFactory} set up by a call to
+ * {@link URLConnection#setContentHandlerFactory(ContentHandlerFactory)
+ * setContentHandlerFactory} is called with a {@code String} giving the
+ * MIME type of the object being received on the socket. The factory returns an
  * instance of a subclass of {@code ContentHandler}, and its
  * {@code getContent} method is called to create the object.
  * <p>
@@ -99,7 +99,8 @@
      * representation of an object, this method reads that stream and
      * creates an object that matches one of the types specified.
      *
-     * The default implementation of this method should call getContent()
+     * The default implementation of this method should call
+     * {@link #getContent(URLConnection)}
      * and screen the return type for a match of the suggested types.
      *
      * @param      urlc   a URL connection.
diff --git a/jdk/src/java.base/share/classes/java/net/URLConnection.java b/jdk/src/java.base/share/classes/java/net/URLConnection.java
index c9331b7..e54a0b1 100644
--- a/jdk/src/java.base/share/classes/java/net/URLConnection.java
+++ b/jdk/src/java.base/share/classes/java/net/URLConnection.java
@@ -881,7 +881,7 @@
      * Sets the value of the {@code doInput} field for this
      * {@code URLConnection} to the specified value.
      * <p>
-     * A URL connection can be used for input and/or output.  Set the DoInput
+     * A URL connection can be used for input and/or output.  Set the doInput
      * flag to true if you intend to use the URL connection for input,
      * false if not.  The default is true.
      *
@@ -911,7 +911,7 @@
      * Sets the value of the {@code doOutput} field for this
      * {@code URLConnection} to the specified value.
      * <p>
-     * A URL connection can be used for input and/or output.  Set the DoOutput
+     * A URL connection can be used for input and/or output.  Set the doOutput
      * flag to true if you intend to use the URL connection for output,
      * false if not.  The default is false.
      *
@@ -977,7 +977,7 @@
      * Returns the default value of the {@code allowUserInteraction}
      * field.
      * <p>
-     * Ths default is "sticky", being a part of the static state of all
+     * This default is "sticky", being a part of the static state of all
      * URLConnections.  This flag applies to the next, and all following
      * URLConnections that are created.
      *
@@ -998,7 +998,7 @@
      * "reload" button in a browser).  If the UseCaches flag on a connection
      * is true, the connection is allowed to use whatever caches it can.
      *  If false, caches are to be ignored.
-     *  The default value comes from DefaultUseCaches, which defaults to
+     *  The default value comes from defaultUseCaches, which defaults to
      * true. A default value can also be set per-protocol using
      * {@link #setDefaultUseCaches(String,boolean)}.
      *
@@ -1257,7 +1257,7 @@
      * application. It can be called at most once by an application.
      * <p>
      * The {@code ContentHandlerFactory} instance is used to
-     * construct a content handler from a content type
+     * construct a content handler from a content type.
      * <p>
      * If there is a security manager, this method first calls
      * the security manager's {@code checkSetFactory} method
diff --git a/jdk/src/java.base/share/classes/java/security/cert/X509CRL.java b/jdk/src/java.base/share/classes/java/security/cert/X509CRL.java
index 2133290..821e3d0 100644
--- a/jdk/src/java.base/share/classes/java/security/cert/X509CRL.java
+++ b/jdk/src/java.base/share/classes/java/security/cert/X509CRL.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
 import java.security.Principal;
 import java.security.Provider;
 import java.security.PublicKey;
+import java.security.Signature;
 import javax.security.auth.x500.X500Principal;
 
 import java.math.BigInteger;
@@ -241,7 +242,17 @@
     public void verify(PublicKey key, Provider sigProvider)
         throws CRLException, NoSuchAlgorithmException,
         InvalidKeyException, SignatureException {
-        X509CRLImpl.verify(this, key, sigProvider);
+        Signature sig = (sigProvider == null)
+            ? Signature.getInstance(getSigAlgName())
+            : Signature.getInstance(getSigAlgName(), sigProvider);
+        sig.initVerify(key);
+
+        byte[] tbsCRL = getTBSCertList();
+        sig.update(tbsCRL, 0, tbsCRL.length);
+
+        if (sig.verify(getSignature()) == false) {
+            throw new SignatureException("Signature does not match.");
+        }
     }
 
     /**
diff --git a/jdk/src/java.base/share/classes/java/security/cert/X509Certificate.java b/jdk/src/java.base/share/classes/java/security/cert/X509Certificate.java
index 174d6a7..d93e66c 100644
--- a/jdk/src/java.base/share/classes/java/security/cert/X509Certificate.java
+++ b/jdk/src/java.base/share/classes/java/security/cert/X509Certificate.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -647,7 +647,7 @@
         return X509CertImpl.getIssuerAlternativeNames(this);
     }
 
-     /**
+    /**
      * Verifies that this certificate was signed using the
      * private key that corresponds to the specified public key.
      * This method uses the signature verification engine
@@ -673,6 +673,16 @@
     public void verify(PublicKey key, Provider sigProvider)
         throws CertificateException, NoSuchAlgorithmException,
         InvalidKeyException, SignatureException {
-        X509CertImpl.verify(this, key, sigProvider);
+        Signature sig = (sigProvider == null)
+            ? Signature.getInstance(getSigAlgName())
+            : Signature.getInstance(getSigAlgName(), sigProvider);
+        sig.initVerify(key);
+
+        byte[] tbsCert = getTBSCertificate();
+        sig.update(tbsCert, 0, tbsCert.length);
+
+        if (sig.verify(getSignature()) == false) {
+            throw new SignatureException("Signature does not match.");
+        }
     }
 }
diff --git a/jdk/src/java.base/share/classes/java/text/DecimalFormat.java b/jdk/src/java.base/share/classes/java/text/DecimalFormat.java
index eb5107c..999ff9a 100644
--- a/jdk/src/java.base/share/classes/java/text/DecimalFormat.java
+++ b/jdk/src/java.base/share/classes/java/text/DecimalFormat.java
@@ -3201,13 +3201,6 @@
         isCurrencyFormat = false;
         useExponentialNotation = false;
 
-        // Two variables are used to record the subrange of the pattern
-        // occupied by phase 1.  This is used during the processing of the
-        // second pattern (the one representing negative numbers) to ensure
-        // that no deviation exists in phase 1 between the two patterns.
-        int phaseOneStart = 0;
-        int phaseOneLength = 0;
-
         int start = 0;
         for (int j = 1; j >= 0 && start < pattern.length(); --j) {
             boolean inQuote = false;
@@ -3258,9 +3251,6 @@
                             ch == groupingSeparator ||
                             ch == decimalSeparator) {
                             phase = 1;
-                            if (j == 1) {
-                                phaseOneStart = pos;
-                            }
                             --pos; // Reprocess this character
                             continue;
                         } else if (ch == CURRENCY_SIGN) {
@@ -3331,17 +3321,29 @@
                     break;
 
                 case 1:
-                    // Phase one must be identical in the two sub-patterns. We
-                    // enforce this by doing a direct comparison. While
-                    // processing the first sub-pattern, we just record its
-                    // length. While processing the second, we compare
-                    // characters.
-                    if (j == 1) {
-                        ++phaseOneLength;
-                    } else {
-                        if (--phaseOneLength == 0) {
-                            phase = 2;
-                            affix = suffix;
+                    // The negative subpattern (j = 0) serves only to specify the
+                    // negative prefix and suffix, so all the phase 1 characters
+                    // e.g. digits, zeroDigit, groupingSeparator,
+                    // decimalSeparator, exponent are ignored
+                    if (j == 0) {
+                        while (pos < pattern.length()) {
+                            char negPatternChar = pattern.charAt(pos);
+                            if (negPatternChar == digit
+                                    || negPatternChar == zeroDigit
+                                    || negPatternChar == groupingSeparator
+                                    || negPatternChar == decimalSeparator) {
+                                ++pos;
+                            } else if (pattern.regionMatches(pos, exponent,
+                                    0, exponent.length())) {
+                                pos = pos + exponent.length();
+                            } else {
+                                // Not a phase 1 character, consider it as
+                                // suffix and parse it in phase 2
+                                --pos; //process it again in outer loop
+                                phase = 2;
+                                affix = suffix;
+                                break;
+                            }
                         }
                         continue;
                     }
@@ -3395,7 +3397,6 @@
                          while (pos < pattern.length() &&
                                pattern.charAt(pos) == zeroDigit) {
                             ++minExponentDigits;
-                            ++phaseOneLength;
                             ++pos;
                         }
 
@@ -3414,7 +3415,6 @@
                         phase = 2;
                         affix = suffix;
                         --pos;
-                        --phaseOneLength;
                         continue;
                     }
                     break;
diff --git a/jdk/src/java.base/share/classes/java/time/chrono/AbstractChronology.java b/jdk/src/java.base/share/classes/java/time/chrono/AbstractChronology.java
index c2e91d7..a32ecb7 100644
--- a/jdk/src/java.base/share/classes/java/time/chrono/AbstractChronology.java
+++ b/jdk/src/java.base/share/classes/java/time/chrono/AbstractChronology.java
@@ -127,36 +127,6 @@
 public abstract class AbstractChronology implements Chronology {
 
     /**
-     * ChronoLocalDate order constant.
-     */
-    static final Comparator<ChronoLocalDate> DATE_ORDER =
-        (Comparator<ChronoLocalDate> & Serializable) (date1, date2) -> {
-            return Long.compare(date1.toEpochDay(), date2.toEpochDay());
-        };
-    /**
-     * ChronoLocalDateTime order constant.
-     */
-    static final Comparator<ChronoLocalDateTime<? extends ChronoLocalDate>> DATE_TIME_ORDER =
-        (Comparator<ChronoLocalDateTime<? extends ChronoLocalDate>> & Serializable) (dateTime1, dateTime2) -> {
-            int cmp = Long.compare(dateTime1.toLocalDate().toEpochDay(), dateTime2.toLocalDate().toEpochDay());
-            if (cmp == 0) {
-                cmp = Long.compare(dateTime1.toLocalTime().toNanoOfDay(), dateTime2.toLocalTime().toNanoOfDay());
-            }
-            return cmp;
-        };
-    /**
-     * ChronoZonedDateTime order constant.
-     */
-    static final Comparator<ChronoZonedDateTime<?>> INSTANT_ORDER =
-            (Comparator<ChronoZonedDateTime<?>> & Serializable) (dateTime1, dateTime2) -> {
-                int cmp = Long.compare(dateTime1.toEpochSecond(), dateTime2.toEpochSecond());
-                if (cmp == 0) {
-                    cmp = Long.compare(dateTime1.toLocalTime().getNano(), dateTime2.toLocalTime().getNano());
-                }
-                return cmp;
-            };
-
-    /**
      * Map of available calendars by ID.
      */
     private static final ConcurrentHashMap<String, Chronology> CHRONOS_BY_ID = new ConcurrentHashMap<>();
diff --git a/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDate.java b/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDate.java
index 03a7a48..fb69386 100644
--- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDate.java
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDate.java
@@ -66,6 +66,7 @@
 import static java.time.temporal.ChronoField.YEAR;
 import static java.time.temporal.ChronoUnit.DAYS;
 
+import java.io.Serializable;
 import java.time.DateTimeException;
 import java.time.LocalDate;
 import java.time.LocalTime;
@@ -256,7 +257,9 @@
      * @see #isEqual
      */
     static Comparator<ChronoLocalDate> timeLineOrder() {
-        return AbstractChronology.DATE_ORDER;
+        return (Comparator<ChronoLocalDate> & Serializable) (date1, date2) -> {
+            return Long.compare(date1.toEpochDay(), date2.toEpochDay());
+        };
     }
 
     //-----------------------------------------------------------------------
diff --git a/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDateTime.java b/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDateTime.java
index b211a52..d841196 100644
--- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDateTime.java
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDateTime.java
@@ -66,6 +66,7 @@
 import static java.time.temporal.ChronoUnit.FOREVER;
 import static java.time.temporal.ChronoUnit.NANOS;
 
+import java.io.Serializable;
 import java.time.DateTimeException;
 import java.time.Instant;
 import java.time.LocalDateTime;
@@ -136,7 +137,13 @@
      * @see #isEqual
      */
     static Comparator<ChronoLocalDateTime<?>> timeLineOrder() {
-        return AbstractChronology.DATE_TIME_ORDER;
+        return (Comparator<ChronoLocalDateTime<? extends ChronoLocalDate>> & Serializable) (dateTime1, dateTime2) -> {
+            int cmp = Long.compare(dateTime1.toLocalDate().toEpochDay(), dateTime2.toLocalDate().toEpochDay());
+            if (cmp == 0) {
+                cmp = Long.compare(dateTime1.toLocalTime().toNanoOfDay(), dateTime2.toLocalTime().toNanoOfDay());
+            }
+            return cmp;
+        };
     }
 
     //-----------------------------------------------------------------------
diff --git a/jdk/src/java.base/share/classes/java/time/chrono/ChronoZonedDateTime.java b/jdk/src/java.base/share/classes/java/time/chrono/ChronoZonedDateTime.java
index 8227c48..eadcf9d 100644
--- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoZonedDateTime.java
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoZonedDateTime.java
@@ -66,6 +66,7 @@
 import static java.time.temporal.ChronoUnit.FOREVER;
 import static java.time.temporal.ChronoUnit.NANOS;
 
+import java.io.Serializable;
 import java.time.DateTimeException;
 import java.time.Instant;
 import java.time.LocalTime;
@@ -137,7 +138,13 @@
      * @see #isEqual
      */
     static Comparator<ChronoZonedDateTime<?>> timeLineOrder() {
-        return AbstractChronology.INSTANT_ORDER;
+        return (Comparator<ChronoZonedDateTime<?>> & Serializable) (dateTime1, dateTime2) -> {
+                int cmp = Long.compare(dateTime1.toEpochSecond(), dateTime2.toEpochSecond());
+                if (cmp == 0) {
+                    cmp = Long.compare(dateTime1.toLocalTime().getNano(), dateTime2.toLocalTime().getNano());
+                }
+                return cmp;
+            };
     }
 
     //-----------------------------------------------------------------------
diff --git a/jdk/src/java.base/share/classes/java/time/temporal/ValueRange.java b/jdk/src/java.base/share/classes/java/time/temporal/ValueRange.java
index 4e5c2fd..d31cdca 100644
--- a/jdk/src/java.base/share/classes/java/time/temporal/ValueRange.java
+++ b/jdk/src/java.base/share/classes/java/time/temporal/ValueRange.java
@@ -385,7 +385,7 @@
         }
         if (obj instanceof ValueRange) {
             ValueRange other = (ValueRange) obj;
-           return minSmallest == other.minSmallest && minLargest == other.minLargest &&
+            return minSmallest == other.minSmallest && minLargest == other.minLargest &&
                    maxSmallest == other.maxSmallest && maxLargest == other.maxLargest;
         }
         return false;
@@ -398,8 +398,9 @@
      */
     @Override
     public int hashCode() {
-        long hash = minSmallest + minLargest << 16 + minLargest >> 48 + maxSmallest << 32 +
-            maxSmallest >> 32 + maxLargest << 48 + maxLargest >> 16;
+        long hash = minSmallest + (minLargest << 16) + (minLargest >> 48) +
+                (maxSmallest << 32) + (maxSmallest >> 32) + (maxLargest << 48) +
+                (maxLargest >> 16);
         return (int) (hash ^ (hash >>> 32));
     }
 
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
index 77c42ef..b2fe964 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
@@ -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) {
@@ -1032,9 +1032,10 @@
             }
             else if ((fh = f.hash) == MOVED)
                 tab = helpTransfer(tab, f);
-            else if (onlyIfAbsent && fh == hash &&  // check first node
-                     ((fk = f.key) == key || fk != null && key.equals(fk)) &&
-                     (fv = f.val) != null)
+            else if (onlyIfAbsent // check first node without acquiring lock
+                     && fh == hash
+                     && ((fk = f.key) == key || (fk != null && key.equals(fk)))
+                     && (fv = f.val) != null)
                 return fv;
             else {
                 V oldVal = null;
@@ -1728,9 +1729,9 @@
             }
             else if ((fh = f.hash) == MOVED)
                 tab = helpTransfer(tab, f);
-            else if (fh == h &&                  // check first node
-                     ((fk = f.key) == key || fk != null && key.equals(fk)) &&
-                     (fv = f.val) != null)
+            else if (fh == h    // check first node without acquiring lock
+                     && ((fk = f.key) == key || (fk != null && key.equals(fk)))
+                     && (fv = f.val) != null)
                 return fv;
             else {
                 boolean added = false;
@@ -2299,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;
@@ -2330,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;
             }
@@ -2354,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();
@@ -2378,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;
                 }
@@ -2401,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")
@@ -2418,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);
             }
@@ -2459,7 +2460,7 @@
                     i = -1;
                     advance = false;
                 }
-                else if (U.compareAndSwapInt
+                else if (U.compareAndSetInt
                          (this, TRANSFERINDEX, nextIndex,
                           nextBound = (nextIndex > stride ?
                                        nextIndex - stride : 0))) {
@@ -2476,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;
@@ -2601,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;
@@ -2623,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];
@@ -2647,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) {
@@ -2662,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
         }
     }
@@ -2858,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
         }
 
@@ -2876,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();
                     }
@@ -2908,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 {
@@ -3468,9 +3469,9 @@
 
     static final class KeyIterator<K,V> extends BaseIterator<K,V>
         implements Iterator<K>, Enumeration<K> {
-        KeyIterator(Node<K,V>[] tab, int index, int size, int limit,
+        KeyIterator(Node<K,V>[] tab, int size, int index, int limit,
                     ConcurrentHashMap<K,V> map) {
-            super(tab, index, size, limit, map);
+            super(tab, size, index, limit, map);
         }
 
         public final K next() {
@@ -3488,9 +3489,9 @@
 
     static final class ValueIterator<K,V> extends BaseIterator<K,V>
         implements Iterator<V>, Enumeration<V> {
-        ValueIterator(Node<K,V>[] tab, int index, int size, int limit,
+        ValueIterator(Node<K,V>[] tab, int size, int index, int limit,
                       ConcurrentHashMap<K,V> map) {
-            super(tab, index, size, limit, map);
+            super(tab, size, index, limit, map);
         }
 
         public final V next() {
@@ -3508,9 +3509,9 @@
 
     static final class EntryIterator<K,V> extends BaseIterator<K,V>
         implements Iterator<Map.Entry<K,V>> {
-        EntryIterator(Node<K,V>[] tab, int index, int size, int limit,
+        EntryIterator(Node<K,V>[] tab, int size, int index, int limit,
                       ConcurrentHashMap<K,V> map) {
-            super(tab, index, size, limit, map);
+            super(tab, size, index, limit, map);
         }
 
         public final Map.Entry<K,V> next() {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
index 8be8752..8e56e9b 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java
@@ -48,7 +48,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.NavigableMap;
 import java.util.NavigableSet;
 import java.util.NoSuchElementException;
 import java.util.Set;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java
index d61fb21..aa0a2e9 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java
@@ -43,7 +43,6 @@
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.NavigableMap;
 import java.util.NavigableSet;
 import java.util.Set;
 import java.util.SortedSet;
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
index cd14b00..1e4f667 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java
@@ -2354,7 +2354,7 @@
         checkPermission();
     }
 
-    private Object newInstanceFromSystemProperty(String property)
+    private static Object newInstanceFromSystemProperty(String property)
         throws ReflectiveOperationException {
         String className = System.getProperty(property);
         return (className == null)
@@ -2524,15 +2524,13 @@
      * @throws RejectedExecutionException if the task cannot be
      *         scheduled for execution
      */
+    @SuppressWarnings("unchecked")
     public ForkJoinTask<?> submit(Runnable task) {
         if (task == null)
             throw new NullPointerException();
-        ForkJoinTask<?> job;
-        if (task instanceof ForkJoinTask<?>) // avoid re-wrap
-            job = (ForkJoinTask<?>) task;
-        else
-            job = new ForkJoinTask.AdaptedRunnableAction(task);
-        return externalSubmit(job);
+        return externalSubmit((task instanceof ForkJoinTask<?>)
+            ? (ForkJoinTask<Void>) task // avoid re-wrap
+            : new ForkJoinTask.AdaptedRunnableAction(task));
     }
 
     /**
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java
index a3054b8..b1550f9 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java
@@ -203,21 +203,19 @@
     static final class InnocuousForkJoinWorkerThread extends ForkJoinWorkerThread {
         /** The ThreadGroup for all InnocuousForkJoinWorkerThreads */
         private static final ThreadGroup innocuousThreadGroup =
-            java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction<>() {
-                    public ThreadGroup run() {
-                        ThreadGroup group = Thread.currentThread().getThreadGroup();
-                        for (ThreadGroup p; (p = group.getParent()) != null; )
-                            group = p;
-                        return new ThreadGroup(group, "InnocuousForkJoinWorkerThreadGroup");
-                    }});
+            AccessController.doPrivileged(new PrivilegedAction<>() {
+                public ThreadGroup run() {
+                    ThreadGroup group = Thread.currentThread().getThreadGroup();
+                    for (ThreadGroup p; (p = group.getParent()) != null; )
+                        group = p;
+                    return new ThreadGroup(
+                        group, "InnocuousForkJoinWorkerThreadGroup");
+                }});
 
         /** An AccessControlContext supporting no privileges */
         private static final AccessControlContext INNOCUOUS_ACC =
             new AccessControlContext(
-                new ProtectionDomain[] {
-                    new ProtectionDomain(null, null)
-                });
+                new ProtectionDomain[] { new ProtectionDomain(null, null) });
 
         InnocuousForkJoinWorkerThread(ForkJoinPool pool) {
             super(pool,
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java
index f2184aa..22850e6 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java
@@ -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);
     }
 
 }
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
index 1de994f..826a055 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java
@@ -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) {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java
index a0670ee..940f67c1b 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java
@@ -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);
     }
 
 }
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
index bd60f0b..ee0447a 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
@@ -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) {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
index 56f6751..a469abb 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java
@@ -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) {
diff --git a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
index ab43971..4f093bf 100644
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java
@@ -444,7 +444,7 @@
             }
         }
 
-        private IllegalMonitorStateException unmatchedUnlockException() {
+        private static IllegalMonitorStateException unmatchedUnlockException() {
             return new IllegalMonitorStateException(
                 "attempt to unlock read lock, not locked by current thread");
         }
diff --git a/jdk/src/java.base/share/classes/java/util/stream/FindOps.java b/jdk/src/java.base/share/classes/java/util/stream/FindOps.java
index 45e1d69..299cebe 100644
--- a/jdk/src/java.base/share/classes/java/util/stream/FindOps.java
+++ b/jdk/src/java.base/share/classes/java/util/stream/FindOps.java
@@ -54,9 +54,10 @@
      *        first element in the encounter order
      * @return a {@code TerminalOp} implementing the find operation
      */
+    @SuppressWarnings("unchecked")
     public static <T> TerminalOp<T, Optional<T>> makeRef(boolean mustFindFirst) {
-        return new FindOp<>(mustFindFirst, StreamShape.REFERENCE, Optional.empty(),
-                            Optional::isPresent, FindSink.OfRef::new);
+        return (TerminalOp<T, Optional<T>>)
+                (mustFindFirst ? FindSink.OfRef.OP_FIND_FIRST : FindSink.OfRef.OP_FIND_ANY);
     }
 
     /**
@@ -67,8 +68,7 @@
      * @return a {@code TerminalOp} implementing the find operation
      */
     public static TerminalOp<Integer, OptionalInt> makeInt(boolean mustFindFirst) {
-        return new FindOp<>(mustFindFirst, StreamShape.INT_VALUE, OptionalInt.empty(),
-                            OptionalInt::isPresent, FindSink.OfInt::new);
+        return mustFindFirst ? FindSink.OfInt.OP_FIND_FIRST : FindSink.OfInt.OP_FIND_ANY;
     }
 
     /**
@@ -79,8 +79,7 @@
      * @return a {@code TerminalOp} implementing the find operation
      */
     public static TerminalOp<Long, OptionalLong> makeLong(boolean mustFindFirst) {
-        return new FindOp<>(mustFindFirst, StreamShape.LONG_VALUE, OptionalLong.empty(),
-                            OptionalLong::isPresent, FindSink.OfLong::new);
+        return mustFindFirst ? FindSink.OfLong.OP_FIND_FIRST : FindSink.OfLong.OP_FIND_ANY;
     }
 
     /**
@@ -91,8 +90,7 @@
      * @return a {@code TerminalOp} implementing the find operation
      */
     public static TerminalOp<Double, OptionalDouble> makeDouble(boolean mustFindFirst) {
-        return new FindOp<>(mustFindFirst, StreamShape.DOUBLE_VALUE, OptionalDouble.empty(),
-                            OptionalDouble::isPresent, FindSink.OfDouble::new);
+        return mustFindFirst ? FindSink.OfDouble.OP_FIND_FIRST : FindSink.OfDouble.OP_FIND_ANY;
     }
 
     /**
@@ -195,6 +193,14 @@
             public Optional<T> get() {
                 return hasValue ? Optional.of(value) : null;
             }
+
+            static final TerminalOp<?, ?> OP_FIND_FIRST = new FindOp<>(true,
+                    StreamShape.REFERENCE, Optional.empty(),
+                    Optional::isPresent, FindSink.OfRef::new);
+
+            static final TerminalOp<?, ?> OP_FIND_ANY = new FindOp<>(false,
+                    StreamShape.REFERENCE, Optional.empty(),
+                    Optional::isPresent, FindSink.OfRef::new);
         }
 
         /** Specialization of {@code FindSink} for int streams */
@@ -210,6 +216,13 @@
             public OptionalInt get() {
                 return hasValue ? OptionalInt.of(value) : null;
             }
+
+            static final TerminalOp<Integer, OptionalInt> OP_FIND_FIRST = new FindOp<>(true,
+                    StreamShape.INT_VALUE, OptionalInt.empty(),
+                    OptionalInt::isPresent, FindSink.OfInt::new);
+            static final TerminalOp<Integer, OptionalInt> OP_FIND_ANY = new FindOp<>(false,
+                    StreamShape.INT_VALUE, OptionalInt.empty(),
+                    OptionalInt::isPresent, FindSink.OfInt::new);
         }
 
         /** Specialization of {@code FindSink} for long streams */
@@ -225,6 +238,13 @@
             public OptionalLong get() {
                 return hasValue ? OptionalLong.of(value) : null;
             }
+
+            static final TerminalOp<Long, OptionalLong> OP_FIND_FIRST = new FindOp<>(true,
+                    StreamShape.LONG_VALUE, OptionalLong.empty(),
+                    OptionalLong::isPresent, FindSink.OfLong::new);
+            static final TerminalOp<Long, OptionalLong> OP_FIND_ANY = new FindOp<>(false,
+                    StreamShape.LONG_VALUE, OptionalLong.empty(),
+                    OptionalLong::isPresent, FindSink.OfLong::new);
         }
 
         /** Specialization of {@code FindSink} for double streams */
@@ -240,6 +260,13 @@
             public OptionalDouble get() {
                 return hasValue ? OptionalDouble.of(value) : null;
             }
+
+            static final TerminalOp<Double, OptionalDouble> OP_FIND_FIRST = new FindOp<>(true,
+                    StreamShape.DOUBLE_VALUE, OptionalDouble.empty(),
+                    OptionalDouble::isPresent, FindSink.OfDouble::new);
+            static final TerminalOp<Double, OptionalDouble> OP_FIND_ANY = new FindOp<>(false,
+                    StreamShape.DOUBLE_VALUE, OptionalDouble.empty(),
+                    OptionalDouble::isPresent, FindSink.OfDouble::new);
         }
     }
 
diff --git a/jdk/src/java.base/share/classes/jdk/internal/logger/SimpleConsoleLogger.java b/jdk/src/java.base/share/classes/jdk/internal/logger/SimpleConsoleLogger.java
index fb0ffe6..b6e4246 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/SimpleConsoleLogger.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/SimpleConsoleLogger.java
@@ -33,6 +33,7 @@
 import java.security.PrivilegedAction;
 import java.time.ZonedDateTime;
 import java.util.Optional;
+import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 import java.util.function.Function;
 import java.lang.System.Logger;
@@ -106,7 +107,7 @@
     public final void log(Level level, ResourceBundle bundle, String key, Throwable thrown) {
         if (isLoggable(level)) {
             if (bundle != null) {
-                key = bundle.getString(key);
+                key = getString(bundle, key);
             }
             publish(getCallerInfo(), logLevel(level), key, thrown);
         }
@@ -116,7 +117,7 @@
     public final void log(Level level, ResourceBundle bundle, String format, Object... params) {
         if (isLoggable(level)) {
             if (bundle != null) {
-                format = bundle.getString(format);
+                format = getString(bundle, format);
             }
             publish(getCallerInfo(), logLevel(level), format, params);
         }
@@ -364,7 +365,7 @@
     public final void logrb(PlatformLogger.Level level, String sourceClass,
             String sourceMethod, ResourceBundle bundle, String key, Object... params) {
         if (isLoggable(level)) {
-            String msg = bundle == null ? key : bundle.getString(key);
+            String msg = bundle == null ? key : getString(bundle, key);
             publish(getCallerInfo(sourceClass, sourceMethod), logLevel(level), msg, params);
         }
     }
@@ -373,7 +374,7 @@
     public final void logrb(PlatformLogger.Level level, String sourceClass,
             String sourceMethod, ResourceBundle bundle, String key, Throwable thrown) {
         if (isLoggable(level)) {
-            String msg = bundle == null ? key : bundle.getString(key);
+            String msg = bundle == null ? key : getString(bundle, key);
             publish(getCallerInfo(sourceClass, sourceMethod), logLevel(level), msg, thrown);
         }
     }
@@ -382,7 +383,7 @@
     public final void logrb(PlatformLogger.Level level, ResourceBundle bundle,
             String key, Object... params) {
         if (isLoggable(level)) {
-            String msg = bundle == null ? key : bundle.getString(key);
+            String msg = bundle == null ? key : getString(bundle,key);
             publish(getCallerInfo(), logLevel(level), msg, params);
         }
     }
@@ -391,11 +392,23 @@
     public final void logrb(PlatformLogger.Level level, ResourceBundle bundle,
             String key, Throwable thrown) {
         if (isLoggable(level)) {
-            String msg = bundle == null ? key : bundle.getString(key);
+            String msg = bundle == null ? key : getString(bundle,key);
             publish(getCallerInfo(), logLevel(level), msg, thrown);
         }
     }
 
+    static String getString(ResourceBundle bundle, String key) {
+        if (bundle == null || key == null) return key;
+        try {
+            return bundle.getString(key);
+        } catch (MissingResourceException x) {
+            // Emulate what java.util.logging Formatters do
+            // We don't want unchecked exception to propagate up to
+            // the caller's code.
+            return key;
+        }
+    }
+
     static final class Formatting {
         // The default simple log format string.
         // Used both by SimpleConsoleLogger when java.logging is not present,
diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java
index f4de0ea..f9d7e3e 100644
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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,
-                                                  int expected,
-                                                  int x);
+    public final native boolean compareAndSetInt(Object o, long offset,
+                                                 int expected,
+                                                 int x);
 
     @HotSpotIntrinsicCandidate
-    public final native int compareAndExchangeIntVolatile(Object o, long offset,
-                                                          int expected,
-                                                          int x);
+    public final native int compareAndExchangeInt(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,
-                                            Float.floatToRawIntBits(expected),
-                                            Float.floatToRawIntBits(x));
-    }
-
-    @ForceInline
-    public final boolean weakCompareAndSwapFloatRelease(Object o, long offset,
-                                                      float expected,
-                                                      float x) {
-        return weakCompareAndSwapIntRelease(o, offset,
-                                            Float.floatToRawIntBits(expected),
-                                            Float.floatToRawIntBits(x));
-    }
-
-    @ForceInline
-    public final boolean weakCompareAndSwapFloatVolatile(Object o, long offset,
+    public final boolean weakCompareAndSetFloatAcquire(Object o, long offset,
                                                        float expected,
                                                        float x) {
-        return weakCompareAndSwapIntVolatile(o, offset,
+        return weakCompareAndSetIntAcquire(o, offset,
+                                            Float.floatToRawIntBits(expected),
+                                            Float.floatToRawIntBits(x));
+    }
+
+    @ForceInline
+    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 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;
     }
diff --git a/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java b/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java
index d0e2a98..758d59a 100644
--- a/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java
@@ -296,10 +296,13 @@
      * @param refc the class attempting to make the reference
      */
     public static boolean isTypeVisible(java.lang.invoke.MethodType type, Class<?> refc) {
-        for (int n = -1, max = type.parameterCount(); n < max; n++) {
-            Class<?> ptype = (n < 0 ? type.returnType() : type.parameterType(n));
-            if (!isTypeVisible(ptype, refc))
+        if (!isTypeVisible(type.returnType(), refc)) {
+            return false;
+        }
+        for (int n = 0, max = type.parameterCount(); n < max; n++) {
+            if (!isTypeVisible(type.parameterType(n), refc)) {
                 return false;
+            }
         }
         return true;
     }
diff --git a/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java b/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java
index f22eda0..9f1f312 100644
--- a/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java
@@ -26,20 +26,20 @@
 package sun.invoke.util;
 
 public enum Wrapper {
-    //        wrapperType    primitiveType  char     emptyArray          format
-    BOOLEAN(  Boolean.class, boolean.class, 'Z', new boolean[0], Format.unsigned( 1)),
+    //        wrapperType      simple     primitiveType  simple     char  emptyArray     format
+    BOOLEAN(  Boolean.class,   "Boolean", boolean.class, "boolean", 'Z', new boolean[0], Format.unsigned( 1)),
     // These must be in the order defined for widening primitive conversions in JLS 5.1.2
     // Avoid boxing integral types here to defer initialization of internal caches
-    BYTE   (     Byte.class,    byte.class, 'B', new    byte[0], Format.signed(   8)),
-    SHORT  (    Short.class,   short.class, 'S', new   short[0], Format.signed(  16)),
-    CHAR   (Character.class,    char.class, 'C', new    char[0], Format.unsigned(16)),
-    INT    (  Integer.class,     int.class, 'I', new     int[0], Format.signed(  32)),
-    LONG   (     Long.class,    long.class, 'J', new    long[0], Format.signed(  64)),
-    FLOAT  (    Float.class,   float.class, 'F', new   float[0], Format.floating(32)),
-    DOUBLE (   Double.class,  double.class, 'D', new  double[0], Format.floating(64)),
-    OBJECT (   Object.class,  Object.class, 'L', new  Object[0], Format.other(    1)),
+    BYTE   (     Byte.class,      "Byte",    byte.class,    "byte", 'B', new    byte[0], Format.signed(   8)),
+    SHORT  (    Short.class,     "Short",   short.class,   "short", 'S', new   short[0], Format.signed(  16)),
+    CHAR   (Character.class, "Character",    char.class,    "char", 'C', new    char[0], Format.unsigned(16)),
+    INT    (  Integer.class,   "Integer",     int.class,     "int", 'I', new     int[0], Format.signed(  32)),
+    LONG   (     Long.class,      "Long",    long.class,    "long", 'J', new    long[0], Format.signed(  64)),
+    FLOAT  (    Float.class,     "Float",   float.class,   "float", 'F', new   float[0], Format.floating(32)),
+    DOUBLE (   Double.class,    "Double",  double.class,  "double", 'D', new  double[0], Format.floating(64)),
+    OBJECT (   Object.class,    "Object",  Object.class,  "Object", 'L', new  Object[0], Format.other(    1)),
     // VOID must be the last type, since it is "assignable" from any other type:
-    VOID   (     Void.class,    void.class, 'V',           null, Format.other(    0)),
+    VOID   (     Void.class,      "Void",    void.class,    "void", 'V',           null, Format.other(    0)),
     ;
 
     public static final int COUNT = 10;
@@ -52,14 +52,14 @@
     private final String   wrapperSimpleName;
     private final String   primitiveSimpleName;
 
-    private Wrapper(Class<?> wtype, Class<?> ptype, char tchar, Object emptyArray, int format) {
+    private Wrapper(Class<?> wtype, String wtypeName, Class<?> ptype, String ptypeName, char tchar, Object emptyArray, int format) {
         this.wrapperType = wtype;
         this.primitiveType = ptype;
         this.basicTypeChar = tchar;
         this.emptyArray = emptyArray;
         this.format = format;
-        this.wrapperSimpleName = wtype.getSimpleName();
-        this.primitiveSimpleName = ptype.getSimpleName();
+        this.wrapperSimpleName = wtypeName;
+        this.primitiveSimpleName = ptypeName;
     }
 
     /** For debugging, give the details of this wrapper. */
@@ -518,12 +518,6 @@
      * If the target type is a primitive, change it to a wrapper.
      */
     static <T> Class<T> forceType(Class<?> type, Class<T> exampleType) {
-        boolean z = (type == exampleType ||
-               type.isPrimitive() && forPrimitiveType(type) == findWrapperType(exampleType) ||
-               exampleType.isPrimitive() && forPrimitiveType(exampleType) == findWrapperType(type) ||
-               type == Object.class && !exampleType.isPrimitive());
-        if (!z)
-            System.out.println(type+" <= "+exampleType);
         assert(type == exampleType ||
                type.isPrimitive() && forPrimitiveType(type) == findWrapperType(exampleType) ||
                exampleType.isPrimitive() && forPrimitiveType(exampleType) == findWrapperType(type) ||
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/X509Factory.java b/jdk/src/java.base/share/classes/sun/security/provider/X509Factory.java
index 1789dd6..34a3c8e 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/X509Factory.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/X509Factory.java
@@ -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);
+            }
         }
     }
 
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java
index 0ad5387..dd86415 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, 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
@@ -214,7 +214,7 @@
         try {
             byte[] extVal = xcert.getExtensionValue("2.5.29.14");
             if (extVal == null) {
-                if (debug != null) {
+                if (debug != null && Debug.isVerbose()) {
                     debug.println("AdaptableX509CertSelector.match: "
                         + "no subject key ID extension. Subject: "
                         + xcert.getSubjectX500Principal());
@@ -225,7 +225,7 @@
             byte[] certSubjectKeyID = in.getOctetString();
             if (certSubjectKeyID == null ||
                     !Arrays.equals(ski, certSubjectKeyID)) {
-                if (debug != null) {
+                if (debug != null && Debug.isVerbose()) {
                     debug.println("AdaptableX509CertSelector.match: "
                         + "subject key IDs don't match. "
                         + "Expected: " + Arrays.toString(ski) + " "
@@ -234,7 +234,7 @@
                 return false;
             }
         } catch (IOException ex) {
-            if (debug != null) {
+            if (debug != null && Debug.isVerbose()) {
                 debug.println("AdaptableX509CertSelector.match: "
                     + "exception in subject key ID check");
             }
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java
index 53ae439..c65ebf0 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java
@@ -117,7 +117,7 @@
                 // if this trust anchor is not worth trying,
                 // we move on to the next one
                 if (selector != null && !selector.match(trustedCert)) {
-                    if (debug != null) {
+                    if (debug != null && Debug.isVerbose()) {
                         debug.println("NO - don't try this trustedCert");
                     }
                     continue;
diff --git a/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java b/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java
index 9b443a7..468cad0 100644
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java
@@ -986,9 +986,7 @@
         // any way to convey them back to the application.
         // That's the default, so no need to write code.
         builderParams.setDate(params.date());
-        // CertPathCheckers need to be cloned to start from fresh state
-        builderParams.setCertPathCheckers(
-            params.getPKIXParameters().getCertPathCheckers());
+        builderParams.setCertPathCheckers(params.certPathCheckers());
         builderParams.setSigProvider(params.sigProvider());
 
         // Skip revocation during this build to detect circular
@@ -1116,15 +1114,6 @@
         }
     }
 
-    @Override
-    public RevocationChecker clone() {
-        RevocationChecker copy = (RevocationChecker)super.clone();
-        // we don't deep-copy the exceptions, but that is ok because they
-        // are never modified after they are instantiated
-        copy.softFailExceptions = new LinkedList<>(softFailExceptions);
-        return copy;
-    }
-
     /*
      * This inner class extends the X509CertSelector to add an additional
      * check to make sure the subject public key isn't on a particular list.
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuite.java b/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuite.java
index 2ffb5f3..c8080ca 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuite.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuite.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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());
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuiteList.java b/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuiteList.java
index a114f4a..025f40b 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuiteList.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuiteList.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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);
     }
 
     /**
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java b/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java
index b95de5e..1d6c74e 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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);
             }
         }
 
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/DHCrypt.java b/jdk/src/java.base/share/classes/sun/security/ssl/DHCrypt.java
index f7dadca..a9d4c2a 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/DHCrypt.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/DHCrypt.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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);
-        }
-    }
 }
+
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/ECDHCrypt.java b/jdk/src/java.base/share/classes/sun/security/ssl/ECDHCrypt.java
index 929c592..7e4f593 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ECDHCrypt.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ECDHCrypt.java
@@ -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);
         }
     }
 
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/EllipticCurvesExtension.java b/jdk/src/java.base/share/classes/sun/security/ssl/EllipticCurvesExtension.java
deleted file mode 100644
index c91b25e..0000000
--- a/jdk/src/java.base/share/classes/sun/security/ssl/EllipticCurvesExtension.java
+++ /dev/null
@@ -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;
-    }
-}
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/ExtensionType.java b/jdk/src/java.base/share/classes/sun/security/ssl/ExtensionType.java
index be64dfd..5338807 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ExtensionType.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ExtensionType.java
@@ -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
 
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java b/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java
index 4717fbb..8477456 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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) {
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/Handshaker.java b/jdk/src/java.base/share/classes/sun/security/ssl/Handshaker.java
index f830bc7..e26495b 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/Handshaker.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/Handshaker.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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.
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/HelloExtensions.java b/jdk/src/java.base/share/classes/sun/security/ssl/HelloExtensions.java
index f831db1..82975c9 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/HelloExtensions.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/HelloExtensions.java
@@ -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) {
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/NamedGroup.java b/jdk/src/java.base/share/classes/sun/security/ssl/NamedGroup.java
new file mode 100644
index 0000000..452e839
--- /dev/null
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/NamedGroup.java
@@ -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;
+    }
+}
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/NamedGroupType.java b/jdk/src/java.base/share/classes/sun/security/ssl/NamedGroupType.java
new file mode 100644
index 0000000..0e0c982
--- /dev/null
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/NamedGroupType.java
@@ -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
+}
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/PredefinedDHParameterSpecs.java b/jdk/src/java.base/share/classes/sun/security/ssl/PredefinedDHParameterSpecs.java
new file mode 100644
index 0000000..54d8c7d
--- /dev/null
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/PredefinedDHParameterSpecs.java
@@ -0,0 +1,314 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  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);
+    }
+}
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/RecordType.java b/jdk/src/java.base/share/classes/sun/security/ssl/RecordType.java
deleted file mode 100644
index 1468802..0000000
--- a/jdk/src/java.base/share/classes/sun/security/ssl/RecordType.java
+++ /dev/null
@@ -1,122 +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 sun.security.ssl;
-
-/*
- * enumation of record type
- */
-enum RecordType {
-
-    RECORD_CHANGE_CIPHER_SPEC   (Record.ct_change_cipher_spec,
-                                    HandshakeMessage.ht_not_applicable),
-    RECORD_ALERT                (Record.ct_alert,
-                                    HandshakeMessage.ht_not_applicable),
-    RECORD_HELLO_REQUEST        (Record.ct_handshake,
-                                    HandshakeMessage.ht_hello_request),
-    RECORD_CLIENT_HELLO         (Record.ct_handshake,
-                                    HandshakeMessage.ht_client_hello),
-    RECORD_SERVER_HELLO         (Record.ct_handshake,
-                                    HandshakeMessage.ht_server_hello),
-    RECORD_HELLO_VERIFY_REQUEST (Record.ct_handshake,
-                                    HandshakeMessage.ht_hello_verify_request),
-    RECORD_NEW_SESSION_TICKET   (Record.ct_handshake,
-                                    HandshakeMessage.ht_new_session_ticket),
-    RECORD_CERTIFICATE          (Record.ct_handshake,
-                                    HandshakeMessage.ht_certificate),
-    RECORD_SERVER_KEY_EXCHANGE  (Record.ct_handshake,
-                                    HandshakeMessage.ht_server_key_exchange),
-    RECORD_CERTIFICATE_REQUEST  (Record.ct_handshake,
-                                    HandshakeMessage.ht_certificate_request),
-    RECORD_SERVER_HELLO_DONE    (Record.ct_handshake,
-                                    HandshakeMessage.ht_server_hello_done),
-    RECORD_CERTIFICATE_VERIFY   (Record.ct_handshake,
-                                    HandshakeMessage.ht_certificate_verify),
-    RECORD_CLIENT_KEY_EXCHANGE  (Record.ct_handshake,
-                                    HandshakeMessage.ht_client_key_exchange),
-    RECORD_FINISHED             (Record.ct_handshake,
-                                    HandshakeMessage.ht_finished),
-    RECORD_CERTIFICATE_URL      (Record.ct_handshake,
-                                    HandshakeMessage.ht_certificate_url),
-    RECORD_CERTIFICATE_STATUS   (Record.ct_handshake,
-                                    HandshakeMessage.ht_certificate_status),
-    RECORD_SUPPLIEMENTAL_DATA   (Record.ct_handshake,
-                                    HandshakeMessage.ht_supplemental_data),
-    RECORD_APPLICATION_DATA     (Record.ct_application_data,
-                                    HandshakeMessage.ht_not_applicable);
-
-    byte            contentType;
-    byte            handshakeType;
-
-    private RecordType(byte contentType, byte handshakeType) {
-        this.contentType = contentType;
-        this.handshakeType = handshakeType;
-    }
-
-    static RecordType valueOf(byte contentType, byte handshakeType) {
-        if (contentType == Record.ct_change_cipher_spec) {
-            return RECORD_CHANGE_CIPHER_SPEC;
-        } else if (contentType == Record.ct_alert) {
-            return RECORD_ALERT;
-        } else if (contentType == Record.ct_application_data) {
-            return RECORD_APPLICATION_DATA;
-        } else if (handshakeType == HandshakeMessage.ht_hello_request) {
-            return RECORD_HELLO_REQUEST;
-        } else if (handshakeType == HandshakeMessage.ht_client_hello) {
-            return RECORD_CLIENT_HELLO;
-        } else if (handshakeType == HandshakeMessage.ht_server_hello) {
-            return RECORD_SERVER_HELLO;
-        } else if (handshakeType == HandshakeMessage.ht_hello_verify_request) {
-            return RECORD_HELLO_VERIFY_REQUEST;
-        } else if (handshakeType == HandshakeMessage.ht_new_session_ticket) {
-            return RECORD_NEW_SESSION_TICKET;
-        } else if (handshakeType == HandshakeMessage.ht_certificate) {
-            return RECORD_CERTIFICATE;
-        } else if (handshakeType == HandshakeMessage.ht_server_key_exchange) {
-            return RECORD_SERVER_KEY_EXCHANGE;
-        } else if (handshakeType == HandshakeMessage.ht_certificate_request) {
-            return RECORD_CERTIFICATE_REQUEST;
-        } else if (handshakeType == HandshakeMessage.ht_server_hello_done) {
-            return RECORD_SERVER_HELLO_DONE;
-        } else if (handshakeType == HandshakeMessage.ht_certificate_verify) {
-            return RECORD_CERTIFICATE_VERIFY;
-        } else if (handshakeType == HandshakeMessage.ht_client_key_exchange) {
-            return RECORD_CLIENT_KEY_EXCHANGE;
-        } else if (handshakeType == HandshakeMessage.ht_finished) {
-            return RECORD_FINISHED;
-        } else if (handshakeType == HandshakeMessage.ht_certificate_url) {
-            return RECORD_CERTIFICATE_URL;
-        } else if (handshakeType == HandshakeMessage.ht_certificate_status) {
-            return RECORD_CERTIFICATE_STATUS;
-        } else if (handshakeType == HandshakeMessage.ht_supplemental_data) {
-            return RECORD_SUPPLIEMENTAL_DATA;
-        }
-
-        // otherwise, invalid record type
-        throw new IllegalArgumentException(
-                "Invalid record type (ContentType:" + contentType +
-                ", HandshakeType:" + handshakeType + ")");
-    }
-}
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java
index 4ad18b1..85b96cd 100644
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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;
             }
         }
diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java b/jdk/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java
new file mode 100644
index 0000000..b33cc1e
--- /dev/null
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java
@@ -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);
+        }
+    }
+}
diff --git a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java
index 53ea970..6208565c 100644
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java
@@ -485,7 +485,9 @@
 
             if (c != null) {
                 command = c;
-            } else if (collator.compare(flags, "-help") == 0) {
+            } else if (collator.compare(flags, "-help") == 0 ||
+                    collator.compare(flags, "-h") == 0 ||
+                    collator.compare(flags, "-?") == 0) {
                 help = true;
             } else if (collator.compare(flags, "-conf") == 0) {
                 i++;
diff --git a/jdk/src/java.base/share/classes/sun/security/util/Debug.java b/jdk/src/java.base/share/classes/sun/security/util/Debug.java
index b8018c8..134be05 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/Debug.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/Debug.java
@@ -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
@@ -25,6 +25,7 @@
 
 package sun.security.util;
 
+import java.io.PrintStream;
 import java.math.BigInteger;
 import java.util.regex.Pattern;
 import java.util.regex.Matcher;
@@ -32,7 +33,7 @@
 import sun.security.action.GetPropertyAction;
 
 /**
- * A utility class for debuging.
+ * A utility class for debugging.
  *
  * @author Roland Schemers
  */
@@ -118,6 +119,7 @@
         System.err.println("The following can be used with certpath:");
         System.err.println();
         System.err.println("ocsp          dump the OCSP protocol exchanges");
+        System.err.println("verbose       verbose debugging");
         System.err.println();
         System.err.println("Note: Separate multiple options with a comma");
         System.exit(0);
@@ -166,6 +168,13 @@
     }
 
     /**
+     * Check if verbose messages is enabled for extra debugging.
+     */
+    public static boolean isVerbose() {
+        return isOn("verbose");
+    }
+
+    /**
      * print a message to stderr that is prefixed with the prefix
      * created from the call to getInstance.
      */
@@ -204,6 +213,13 @@
     }
 
     /**
+     * PrintStream for debug methods. Currently only System.err is supported.
+     */
+    public PrintStream getPrintStream() {
+        return System.err;
+    }
+
+    /**
      * return a hexadecimal printed representation of the specified
      * BigInteger object. the value is formatted to fit on lines of
      * at least 75 characters, with embedded newlines. Words are
diff --git a/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java b/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
index 9051b39..b5ffc90 100644
--- a/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
+++ b/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
@@ -674,12 +674,11 @@
                 if (debug != null) {
                     debug.println("Checking if usage constraint \"" + v +
                             "\" matches \"" + cp.getVariant() + "\"");
-                    // Because usage checking can come from many places
-                    // a stack trace is very helpful.
-                    ByteArrayOutputStream ba = new ByteArrayOutputStream();
-                    PrintStream ps = new PrintStream(ba);
-                    (new Exception()).printStackTrace(ps);
-                    debug.println(ba.toString());
+                    if (Debug.isVerbose()) {
+                        // Because usage checking can come from many places
+                        // a stack trace is very helpful.
+                        (new Exception()).printStackTrace(debug.getPrintStream());
+                    }
                 }
                 if (cp.getVariant().compareTo(v) == 0) {
                     if (next(cp)) {
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java b/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java
index 364d47b..271616e 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -443,18 +443,6 @@
     }
 
     /**
-     * This static method is the default implementation of the
-     * verify(PublicKey key, Provider sigProvider) method in X509CRL.
-     * Called from java.security.cert.X509CRL.verify(PublicKey key,
-     * Provider sigProvider)
-     */
-    public static void verify(X509CRL crl, PublicKey key,
-            Provider sigProvider) throws CRLException,
-            NoSuchAlgorithmException, InvalidKeyException, SignatureException {
-        crl.verify(key, sigProvider);
-    }
-
-    /**
      * Encodes an X.509 CRL, and signs it using the given key.
      *
      * @param key the private key used for signing.
diff --git a/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java b/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java
index 8d496ad..8d3ccff 100644
--- a/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -494,18 +494,6 @@
         }
     }
 
-     /**
-     * This static method is the default implementation of the
-     * verify(PublicKey key, Provider sigProvider) method in X509Certificate.
-     * Called from java.security.cert.X509Certificate.verify(PublicKey key,
-     * Provider sigProvider)
-     */
-    public static void verify(X509Certificate cert, PublicKey key,
-            Provider sigProvider) throws CertificateException,
-            NoSuchAlgorithmException, InvalidKeyException, SignatureException {
-        cert.verify(key, sigProvider);
-    }
-
     /**
      * Creates an X.509 certificate, and signs it using the given key
      * (associating a signature algorithm and an X.500 name).
diff --git a/jdk/src/java.base/share/native/libjli/java.c b/jdk/src/java.base/share/native/libjli/java.c
index 927c09f..8967f70 100644
--- a/jdk/src/java.base/share/native/libjli/java.c
+++ b/jdk/src/java.base/share/native/libjli/java.c
@@ -129,7 +129,6 @@
 static void SetPaths(int argc, char **argv);
 
 static void DumpState();
-static jboolean RemovableOption(char *option);
 
 enum OptionKind {
     LAUNCHER_OPTION = 0,
@@ -771,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];
         /*
@@ -840,11 +838,8 @@
                     printf("TRACER_MARKER: NativeMemoryTracking: got value %s\n",envBuf);
                     free(envName);
                 }
-
             }
-
         }
-
     }
 }
 
@@ -1411,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) {
@@ -2334,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
diff --git a/jdk/src/java.base/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java b/jdk/src/java.base/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
new file mode 100644
index 0000000..36e23bd
--- /dev/null
+++ b/jdk/src/java.base/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
@@ -0,0 +1,47 @@
+/*
+ * 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.nio.ch;
+
+import java.nio.channels.spi.AsynchronousChannelProvider;
+
+/**
+ * Creates this platform's default AsynchronousChannelProvider
+ */
+
+public class DefaultAsynchronousChannelProvider {
+
+    /**
+     * Prevent instantiation.
+     */
+    private DefaultAsynchronousChannelProvider() { }
+
+    /**
+     * Returns the default AsynchronousChannelProvider.
+     */
+    public static AsynchronousChannelProvider create() {
+        return new SolarisAsynchronousChannelProvider();
+    }
+}
diff --git a/jdk/src/java.base/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java b/jdk/src/java.base/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java
index 866d8d4..aa823e4 100644
--- a/jdk/src/java.base/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java
+++ b/jdk/src/java.base/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,6 @@
      * Returns the default SelectorProvider.
      */
     public static SelectorProvider create() {
-        return new sun.nio.ch.DevPollSelectorProvider();
+        return new DevPollSelectorProvider();
     }
-
 }
diff --git a/jdk/src/java.base/solaris/native/libnet/solaris_close.c b/jdk/src/java.base/solaris/native/libnet/solaris_close.c
index 091dc00..087c988 100644
--- a/jdk/src/java.base/solaris/native/libnet/solaris_close.c
+++ b/jdk/src/java.base/solaris/native/libnet/solaris_close.c
@@ -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;
         }
diff --git a/jdk/src/java.base/unix/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java b/jdk/src/java.base/unix/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
deleted file mode 100644
index 248c6a1..0000000
--- a/jdk/src/java.base/unix/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
- * 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.nio.ch;
-
-import java.nio.channels.spi.AsynchronousChannelProvider;
-import sun.security.action.GetPropertyAction;
-
-/**
- * Creates this platform's default asynchronous channel provider
- */
-
-public class DefaultAsynchronousChannelProvider {
-
-    /**
-     * Prevent instantiation.
-     */
-    private DefaultAsynchronousChannelProvider() { }
-
-    @SuppressWarnings("unchecked")
-    private static AsynchronousChannelProvider createProvider(String cn) {
-        Class<AsynchronousChannelProvider> c;
-        try {
-            c = (Class<AsynchronousChannelProvider>)Class.forName(cn);
-        } catch (ClassNotFoundException x) {
-            throw new AssertionError(x);
-        }
-        try {
-            @SuppressWarnings("deprecation")
-            AsynchronousChannelProvider result = c.newInstance();
-            return result;
-        } catch (IllegalAccessException | InstantiationException x) {
-            throw new AssertionError(x);
-        }
-
-    }
-
-    /**
-     * Returns the default AsynchronousChannelProvider.
-     */
-    public static AsynchronousChannelProvider create() {
-        String osname = GetPropertyAction.privilegedGetProperty("os.name");
-        if (osname.equals("SunOS"))
-            return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
-        if (osname.equals("Linux"))
-            return createProvider("sun.nio.ch.LinuxAsynchronousChannelProvider");
-        if (osname.contains("OS X"))
-            return createProvider("sun.nio.ch.BsdAsynchronousChannelProvider");
-        if (osname.equals("AIX"))
-            return createProvider("sun.nio.ch.AixAsynchronousChannelProvider");
-        throw new InternalError("platform not recognized");
-    }
-}
diff --git a/jdk/src/java.base/unix/native/libjava/UnixFileSystem_md.c b/jdk/src/java.base/unix/native/libjava/UnixFileSystem_md.c
index 77fe35d..95b5674 100644
--- a/jdk/src/java.base/unix/native/libjava/UnixFileSystem_md.c
+++ b/jdk/src/java.base/unix/native/libjava/UnixFileSystem_md.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -229,7 +229,13 @@
     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
         struct stat64 sb;
         if (stat64(path, &sb) == 0) {
-            rv = 1000 * (jlong)sb.st_mtime;
+#ifndef MACOSX
+            rv  = (jlong)sb.st_mtim.tv_sec * 1000;
+            rv += (jlong)sb.st_mtim.tv_nsec / 1000000;
+#else
+            rv  = (jlong)sb.st_mtimespec.tv_sec * 1000;
+            rv += (jlong)sb.st_mtimespec.tv_nsec / 1000000;
+#endif
         }
     } END_PLATFORM_STRING(env, path);
     return rv;
@@ -413,8 +419,13 @@
             struct timeval tv[2];
 
             /* Preserve access time */
-            tv[0].tv_sec = sb.st_atime;
-            tv[0].tv_usec = 0;
+#ifndef MACOSX
+            tv[0].tv_sec = sb.st_atim.tv_sec;
+            tv[0].tv_usec = sb.st_atim.tv_nsec / 1000;
+#else
+            tv[0].tv_sec = sb.st_atimespec.tv_sec;
+            tv[0].tv_usec = sb.st_atimespec.tv_nsec / 1000;
+#endif
 
             /* Change last-modified time */
             tv[1].tv_sec = time / 1000;
diff --git a/jdk/src/java.base/unix/native/libjli/java_md.h b/jdk/src/java.base/unix/native/libjli/java_md.h
index f0eaa30..cc3bb11 100644
--- a/jdk/src/java.base/unix/native/libjli/java_md.h
+++ b/jdk/src/java.base/unix/native/libjli/java_md.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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)
diff --git a/jdk/src/java.base/unix/native/libjli/java_md_solinux.c b/jdk/src/java.base/unix/native/libjli/java_md_solinux.c
index cb9afc0..408b537 100644
--- a/jdk/src/java.base/unix/native/libjli/java_md_solinux.c
+++ b/jdk/src/java.base/unix/native/libjli/java_md_solinux.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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 */
-
-      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%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");
-
-        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);
+    /* 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);
-      }
+    }
+
+    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);
+    }
+    /*
+     * we seem to have everything we need, so without further ado
+     * we return back, otherwise proceed to set the environment.
+     */
 #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.
-             */
+    mustsetenv = RequiresSetenv(jvmpath);
+    JLI_TraceLauncher("mustsetenv: %s\n", mustsetenv ? "TRUE" : "FALSE");
 
-#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.
-             */
+    if (mustsetenv == JNI_FALSE) {
+        return;
+    }
+#else
+    return;
+#endif /* SETENV_REQUIRED */
 
-            switch (wanted) {
-                case 0:
-                case 64:
-                    dmpath = getenv("LD_LIBRARY_PATH_64");
-                    wanted = 64;
-                    break;
+#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.
+         */
 
-                default:
-                    JLI_ReportErrorMessage(JRE_ERROR3, __LINE__);
-                    exit(1); /* unknown value in wanted */
-                    break;
-            }
+        runpath = getenv(LD_LIBRARY_PATH);
 
-            /*
-             * 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.
-             */
-            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) +
+        /* 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:") +
+                    /* 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 "=");
+                    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.
-               */
-              {
+            /*
+             * 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);
-            }
-
-            if (putenv(new_runpath) != 0) {
-                exit(1); /* problem allocating memory; LD_LIBRARY_PATH not set
-                    properly */
-            }
-
-            /*
-             * 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.
-             */
-
-#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 */
-
-            newenvp = environ;
         }
-#endif /* SETENV_REQUIRED */
-        {
-            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);
+
+        /*
+         * 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);
             }
-#else /* !SETENV_REQUIRED */
-            execv(newexec, argv);
-#endif /* SETENV_REQUIRED */
-            JLI_ReportErrorMessageSys(JRE_ERROR4, newexec);
+            JLI_StrCat(new_runpath, ":");
+            JLI_StrCat(new_runpath, runpath);
         }
-        exit(1);
+
+        if (putenv(new_runpath) != 0) {
+            /* problem allocating memory; LD_LIBRARY_PATH not set properly */
+            exit(1);
+        }
+
+        /*
+         * 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;
     }
+#endif /* SETENV_REQUIRED */
+    {
+        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);
+        }
+#else /* !SETENV_REQUIRED */
+        execv(newexec, argv);
+#endif /* SETENV_REQUIRED */
+        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;
 
diff --git a/jdk/src/java.base/unix/native/libnet/Inet4AddressImpl.c b/jdk/src/java.base/unix/native/libnet/Inet4AddressImpl.c
index 385b319..829ad20 100644
--- a/jdk/src/java.base/unix/native/libnet/Inet4AddressImpl.c
+++ b/jdk/src/java.base/unix/native/libnet/Inet4AddressImpl.c
@@ -46,7 +46,13 @@
 #define NI_MAXHOST 1025
 #endif
 
-/************************************************************************
+#define SET_NONBLOCKING(fd) {       \
+    int flags = fcntl(fd, F_GETFL); \
+    flags |= O_NONBLOCK;            \
+    fcntl(fd, F_SETFL, flags);      \
+}
+
+/*
  * Inet4AddressImpl
  */
 
@@ -57,35 +63,26 @@
  */
 JNIEXPORT jstring JNICALL
 Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
-    char hostname[NI_MAXHOST+1];
+    char hostname[NI_MAXHOST + 1];
 
     hostname[0] = '\0';
-    if (gethostname(hostname, NI_MAXHOST)) {
-        /* Something went wrong, maybe networking is not setup? */
+    if (gethostname(hostname, NI_MAXHOST) != 0) {
         strcpy(hostname, "localhost");
     } else {
+        // try to resolve hostname via nameservice
+        // if it is known but getnameinfo fails, hostname will still be the
+        // value from gethostname
         struct addrinfo hints, *res;
-        int error;
 
+        // make sure string is null-terminated
         hostname[NI_MAXHOST] = '\0';
         memset(&hints, 0, sizeof(hints));
         hints.ai_flags = AI_CANONNAME;
         hints.ai_family = AF_INET;
 
-        error = getaddrinfo(hostname, NULL, &hints, &res);
-
-        if (error == 0) {/* host is known to name service */
-            getnameinfo(res->ai_addr,
-                        res->ai_addrlen,
-                        hostname,
-                        NI_MAXHOST,
-                        NULL,
-                        0,
-                        NI_NAMEREQD);
-
-            /* if getnameinfo fails hostname is still the value
-               from gethostname */
-
+        if (getaddrinfo(hostname, NULL, &hints, &res) == 0) {
+            getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST,
+                        NULL, 0, NI_NAMEREQD);
             freeaddrinfo(res);
         }
     }
@@ -93,89 +90,70 @@
 }
 
 /*
- * Find an internet address for a given hostname.  Note that this
+ * Find an internet address for a given hostname. Note that this
  * code only works for addresses of type INET. The translation
  * of %d.%d.%d.%d to an address (int) occurs in java now, so the
- * String "host" shouldn't *ever* be a %d.%d.%d.%d string
+ * String "host" shouldn't be a %d.%d.%d.%d string. The only
+ * exception should be when any of the %d are out of range and
+ * we fallback to a lookup.
  *
  * Class:     java_net_Inet4AddressImpl
  * Method:    lookupAllHostAddr
  * Signature: (Ljava/lang/String;)[[B
  */
-
 JNIEXPORT jobjectArray JNICALL
 Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
-                                                jstring host) {
+                                                 jstring host) {
+    jobjectArray ret = NULL;
     const char *hostname;
-    jobjectArray ret = 0;
-    int retLen = 0;
     int error = 0;
-    struct addrinfo hints, *res, *resNew = NULL;
+    struct addrinfo hints, *res = NULL, *resNew = NULL, *last = NULL,
+        *iterator;
 
     initInetAddressIDs(env);
     JNU_CHECK_EXCEPTION_RETURN(env, NULL);
 
     if (IS_NULL(host)) {
-        JNU_ThrowNullPointerException(env, "host is null");
-        return 0;
+        JNU_ThrowNullPointerException(env, "host argument is null");
+        return NULL;
     }
     hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE);
     CHECK_NULL_RETURN(hostname, NULL);
 
-    /* Try once, with our static buffer. */
+    // try once, with our static buffer
     memset(&hints, 0, sizeof(hints));
     hints.ai_flags = AI_CANONNAME;
     hints.ai_family = AF_INET;
 
-#ifdef __solaris__
-    /*
-     * Workaround for Solaris bug 4160367 - if a hostname contains a
-     * white space then 0.0.0.0 is returned
-     */
-    if (isspace((unsigned char)hostname[0])) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
-                        (char *)hostname);
-        JNU_ReleaseStringPlatformChars(env, host, hostname);
-        return NULL;
-    }
-#endif
-
     error = getaddrinfo(hostname, NULL, &hints, &res);
 
-#ifdef MACOSX
     if (error) {
+#if defined(MACOSX)
         // If getaddrinfo fails try getifaddrs, see bug 8170910.
         ret = lookupIfLocalhost(env, hostname, JNI_FALSE);
         if (ret != NULL || (*env)->ExceptionCheck(env)) {
-            JNU_ReleaseStringPlatformChars(env, host, hostname);
-            return ret;
+            goto cleanupAndReturn;
         }
-    }
 #endif
-
-    if (error) {
-        /* report error */
+        // report error
         NET_ThrowUnknownHostExceptionWithGaiError(env, hostname, error);
-        JNU_ReleaseStringPlatformChars(env, host, hostname);
-        return NULL;
+        goto cleanupAndReturn;
     } else {
         int i = 0;
-        struct addrinfo *itr, *last = NULL, *iterator = res;
-
+        iterator = res;
         while (iterator != NULL) {
-            // remove the duplicate one
+            // skip duplicates
             int skip = 0;
-            itr = resNew;
-            while (itr != NULL) {
+            struct addrinfo *iteratorNew = resNew;
+            while (iteratorNew != NULL) {
                 struct sockaddr_in *addr1, *addr2;
                 addr1 = (struct sockaddr_in *)iterator->ai_addr;
-                addr2 = (struct sockaddr_in *)itr->ai_addr;
-                if (addr1->sin_addr.s_addr ==
-                    addr2->sin_addr.s_addr) {
+                addr2 = (struct sockaddr_in *)iteratorNew->ai_addr;
+                if (addr1->sin_addr.s_addr == addr2->sin_addr.s_addr) {
                     skip = 1;
                     break;
                 }
-                itr = itr->ai_next;
+                iteratorNew = iteratorNew->ai_next;
             }
 
             if (!skip) {
@@ -199,44 +177,37 @@
             iterator = iterator->ai_next;
         }
 
-        retLen = i;
-        iterator = resNew;
-
-        ret = (*env)->NewObjectArray(env, retLen, ia_class, NULL);
-
+        // allocate array - at this point i contains the number of addresses
+        ret = (*env)->NewObjectArray(env, i, ia_class, NULL);
         if (IS_NULL(ret)) {
-            /* we may have memory to free at the end of this */
             goto cleanupAndReturn;
         }
 
         i = 0;
+        iterator = resNew;
         while (iterator != NULL) {
             jobject iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
             if (IS_NULL(iaObj)) {
                 ret = NULL;
                 goto cleanupAndReturn;
             }
-            setInetAddress_addr(env, iaObj, ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
+            setInetAddress_addr(env, iaObj, ntohl(((struct sockaddr_in *)
+                                (iterator->ai_addr))->sin_addr.s_addr));
             setInetAddress_hostName(env, iaObj, host);
             (*env)->SetObjectArrayElement(env, ret, i++, iaObj);
             iterator = iterator->ai_next;
         }
     }
-
 cleanupAndReturn:
-    {
-        struct addrinfo *iterator, *tmp;
-        iterator = resNew;
-        while (iterator != NULL) {
-            tmp = iterator;
-            iterator = iterator->ai_next;
-            free(tmp);
-        }
-        JNU_ReleaseStringPlatformChars(env, host, hostname);
+    JNU_ReleaseStringPlatformChars(env, host, hostname);
+    while (resNew != NULL) {
+        last = resNew;
+        resNew = resNew->ai_next;
+        free(last);
     }
-
-    freeaddrinfo(res);
-
+    if (res != NULL) {
+        freeaddrinfo(res);
+    }
     return ret;
 }
 
@@ -244,164 +215,243 @@
  * Class:     java_net_Inet4AddressImpl
  * Method:    getHostByAddr
  * Signature: (I)Ljava/lang/String;
+ *
+ * Theoretically the UnknownHostException could be enriched with gai error
+ * information. But as it is silently ignored anyway, there's no need for this.
+ * It's only important that either a valid hostname is returned or an
+ * UnknownHostException is thrown.
  */
 JNIEXPORT jstring JNICALL
 Java_java_net_Inet4AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
-                                            jbyteArray addrArray) {
+                                             jbyteArray addrArray) {
     jstring ret = NULL;
-
-    char host[NI_MAXHOST+1];
-    int error = 0;
-    int len = 0;
+    char host[NI_MAXHOST + 1];
     jbyte caddr[4];
-
-    struct sockaddr_in him4;
-    struct sockaddr *sa;
-
     jint addr;
+    struct sockaddr_in sa;
+
+    // construct a sockaddr_in structure
+    memset((char *)&sa, 0, sizeof(struct sockaddr_in));
     (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr);
-    addr = ((caddr[0]<<24) & 0xff000000);
-    addr |= ((caddr[1] <<16) & 0xff0000);
-    addr |= ((caddr[2] <<8) & 0xff00);
+    addr = ((caddr[0] << 24) & 0xff000000);
+    addr |= ((caddr[1] << 16) & 0xff0000);
+    addr |= ((caddr[2] << 8) & 0xff00);
     addr |= (caddr[3] & 0xff);
-    memset((void *) &him4, 0, sizeof(him4));
-    him4.sin_addr.s_addr = htonl(addr);
-    him4.sin_family = AF_INET;
-    sa = (struct sockaddr *) &him4;
-    len = sizeof(him4);
+    sa.sin_addr.s_addr = htonl(addr);
+    sa.sin_family = AF_INET;
 
-    error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
-
-    if (!error) {
+    if (getnameinfo((struct sockaddr *)&sa, sizeof(struct sockaddr_in),
+                    host, NI_MAXHOST, NULL, 0, NI_NAMEREQD)) {
+        JNU_ThrowByName(env, "java/net/UnknownHostException", NULL);
+    } else {
         ret = (*env)->NewStringUTF(env, host);
-    }
-
-    if (ret == NULL) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", NULL);
+        if (ret == NULL) {
+            JNU_ThrowByName(env, "java/net/UnknownHostException", NULL);
+        }
     }
 
     return ret;
 }
 
-#define SET_NONBLOCKING(fd) {           \
-        int flags = fcntl(fd, F_GETFL); \
-        flags |= O_NONBLOCK;            \
-        fcntl(fd, F_SETFL, flags);      \
+/**
+ * ping implementation using tcp port 7 (echo)
+ */
+static jboolean
+tcp_ping4(JNIEnv *env, SOCKETADDRESS *sa, SOCKETADDRESS *netif, jint timeout,
+          jint ttl)
+{
+    jint fd;
+    int connect_rv = -1;
+
+    // open a TCP socket
+    fd = socket(AF_INET, SOCK_STREAM, 0);
+    if (fd == -1) {
+        // note: if you run out of fds, you may not be able to load
+        // the exception class, and get a NoClassDefFoundError instead.
+        NET_ThrowNew(env, errno, "Can't create socket");
+        return JNI_FALSE;
+    }
+
+    // set TTL
+    if (ttl > 0) {
+        setsockopt(fd, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl));
+    }
+
+    // A network interface was specified, so let's bind to it.
+    if (netif != NULL) {
+        if (bind(fd, &netif->sa, sizeof(struct sockaddr_in)) < 0) {
+            NET_ThrowNew(env, errno, "Can't bind socket");
+            close(fd);
+            return JNI_FALSE;
+        }
+    }
+
+    // Make the socket non blocking so we can use select/poll.
+    SET_NONBLOCKING(fd);
+
+    sa->sa4.sin_port = htons(7); // echo port
+    connect_rv = NET_Connect(fd, &sa->sa, sizeof(struct sockaddr_in));
+
+    // connection established or refused immediately, either way it means
+    // we were able to reach the host!
+    if (connect_rv == 0 || errno == ECONNREFUSED) {
+        close(fd);
+        return JNI_TRUE;
+    }
+
+    switch (errno) {
+    case ENETUNREACH:   // Network Unreachable
+    case EAFNOSUPPORT:  // Address Family not supported
+    case EADDRNOTAVAIL: // address is not available on the remote machine
+#if defined(__linux__) || defined(_AIX)
+        // On some Linux versions, when a socket is bound to the loopback
+        // interface, connect will fail and errno will be set to EINVAL
+        // or EHOSTUNREACH.  When that happens, don't throw an exception,
+        // just return false.
+    case EINVAL:
+    case EHOSTUNREACH:  // No route to host
+#endif
+        close(fd);
+        return JNI_FALSE;
+    case EINPROGRESS:   // this is expected as we'll probably have to wait
+        break;
+    default:
+        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
+                                     "connect failed");
+        close(fd);
+        return JNI_FALSE;
+    }
+
+    timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout);
+    if (timeout >= 0) {
+        // connection has been established, check for error condition
+        socklen_t optlen = (socklen_t)sizeof(connect_rv);
+        if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
+                       &optlen) <0)
+        {
+            connect_rv = errno;
+        }
+        if (connect_rv == 0 || connect_rv == ECONNREFUSED) {
+            close(fd);
+            return JNI_TRUE;
+        }
+    }
+    close(fd);
+    return JNI_FALSE;
 }
 
 /**
  * ping implementation.
- * Send a ICMP_ECHO_REQUEST packet every second until either the timeout
- * expires or a answer is received.
- * Returns true is an ECHO_REPLY is received, otherwise, false.
+ * Send an ICMP_ECHO_REQUEST packet every second until either the timeout
+ * expires or an answer is received.
+ * Returns true if an ECHO_REPLY is received, false otherwise.
  */
 static jboolean
-ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout,
-      struct sockaddr_in* netif, jint ttl) {
-    jint size;
-    jint n, hlen1, icmplen;
+ping4(JNIEnv *env, jint fd, SOCKETADDRESS *sa, SOCKETADDRESS *netif,
+      jint timeout, jint ttl)
+{
+    jint n, size = 60 * 1024, hlen, tmout2, seq = 1;
     socklen_t len;
-    char sendbuf[1500];
-    char recvbuf[1500];
+    unsigned char sendbuf[1500], recvbuf[1500];
     struct icmp *icmp;
     struct ip *ip;
     struct sockaddr_in sa_recv;
     jchar pid;
-    jint tmout2, seq = 1;
     struct timeval tv;
-    size_t plen;
+    size_t plen = ICMP_ADVLENMIN + sizeof(tv);
 
-    /* icmp_id is a 16 bit data type, therefore down cast the pid */
-    pid = (jchar)getpid();
-    size = 60*1024;
     setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
-    /*
-     * sets the ttl (max number of hops)
-     */
+
+    // sets the ttl (max number of hops)
     if (ttl > 0) {
-      setsockopt(fd, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl));
+        setsockopt(fd, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl));
     }
-    /*
-     * a specific interface was specified, so let's bind the socket
-     * to that interface to ensure the requests are sent only through it.
-     */
+
+    // a specific interface was specified, so let's bind the socket
+    // to that interface to ensure the requests are sent only through it.
     if (netif != NULL) {
-      if (bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in)) < 0) {
-        NET_ThrowNew(env, errno, "Can't bind socket");
-        close(fd);
-        return JNI_FALSE;
-      }
+        if (bind(fd, &netif->sa, sizeof(struct sockaddr_in)) < 0) {
+            NET_ThrowNew(env, errno, "Can't bind socket");
+            close(fd);
+            return JNI_FALSE;
+        }
     }
-    /*
-     * Make the socket non blocking so we can use select
-     */
+
+    // icmp_id is a 16 bit data type, therefore down cast the pid
+    pid = (jchar)getpid();
+
+    // Make the socket non blocking so we can use select
     SET_NONBLOCKING(fd);
     do {
-      /*
-       * create the ICMP request
-       */
-      icmp = (struct icmp *) sendbuf;
-      icmp->icmp_type = ICMP_ECHO;
-      icmp->icmp_code = 0;
-      icmp->icmp_id = htons(pid);
-      icmp->icmp_seq = htons(seq);
-      seq++;
-      gettimeofday(&tv, NULL);
-      memcpy(icmp->icmp_data, &tv, sizeof(tv));
-      plen = ICMP_ADVLENMIN + sizeof(tv);
-      icmp->icmp_cksum = 0;
-      icmp->icmp_cksum = in_cksum((u_short *)icmp, plen);
-      /*
-       * send it
-       */
-      n = sendto(fd, sendbuf, plen, 0, (struct sockaddr *)him,
-                 sizeof(struct sockaddr));
-      if (n < 0 && errno != EINPROGRESS ) {
-#ifdef __linux__
-        if (errno != EINVAL && errno != EHOSTUNREACH)
-          /*
-           * On some Linux versions, when a socket is bound to the loopback
-           * interface, sendto will fail and errno will be set to
-           * EINVAL or EHOSTUNREACH. When that happens, don't throw an
-           * exception, just return false.
-           */
-#endif /*__linux__ */
-          NET_ThrowNew(env, errno, "Can't send ICMP packet");
-        close(fd);
-        return JNI_FALSE;
-      }
-
-      tmout2 = timeout > 1000 ? 1000 : timeout;
-      do {
-        tmout2 = NET_Wait(env, fd, NET_WAIT_READ, tmout2);
-        if (tmout2 >= 0) {
-          len = sizeof(sa_recv);
-          n = recvfrom(fd, recvbuf, sizeof(recvbuf), 0, (struct sockaddr *)&sa_recv, &len);
-          ip = (struct ip*) recvbuf;
-          hlen1 = (ip->ip_hl) << 2;
-          icmp = (struct icmp *) (recvbuf + hlen1);
-          icmplen = n - hlen1;
-          /*
-           * We did receive something, but is it what we were expecting?
-           * I.E.: A ICMP_ECHOREPLY packet with the proper PID.
-           */
-          if (icmplen >= 8 && icmp->icmp_type == ICMP_ECHOREPLY
-               && (ntohs(icmp->icmp_id) == pid)) {
-            if ((him->sin_addr.s_addr == sa_recv.sin_addr.s_addr)) {
-              close(fd);
-              return JNI_TRUE;
+        // create the ICMP request
+        icmp = (struct icmp *)sendbuf;
+        icmp->icmp_type = ICMP_ECHO;
+        icmp->icmp_code = 0;
+        // let's tag the ECHO packet with our pid so we can identify it
+        icmp->icmp_id = htons(pid);
+        icmp->icmp_seq = htons(seq);
+        seq++;
+        gettimeofday(&tv, NULL);
+        memcpy(icmp->icmp_data, &tv, sizeof(tv));
+        icmp->icmp_cksum = 0;
+        // manually calculate checksum
+        icmp->icmp_cksum = in_cksum((u_short *)icmp, plen);
+        // send it
+        n = sendto(fd, sendbuf, plen, 0, &sa->sa, sizeof(struct sockaddr_in));
+        if (n < 0 && errno != EINPROGRESS) {
+#if defined(__linux__)
+            /*
+             * On some Linux versions, when a socket is bound to the loopback
+             * interface, sendto will fail and errno will be set to
+             * EINVAL or EHOSTUNREACH. When that happens, don't throw an
+             * exception, just return false.
+             */
+            if (errno != EINVAL && errno != EHOSTUNREACH) {
+                NET_ThrowNew(env, errno, "Can't send ICMP packet");
             }
-
-            if (him->sin_addr.s_addr == 0) {
-              close(fd);
-              return JNI_TRUE;
-            }
-         }
-
+#else
+            NET_ThrowNew(env, errno, "Can't send ICMP packet");
+#endif
+            close(fd);
+            return JNI_FALSE;
         }
-      } while (tmout2 > 0);
-      timeout -= 1000;
-    } while (timeout >0);
+
+        tmout2 = timeout > 1000 ? 1000 : timeout;
+        do {
+            tmout2 = NET_Wait(env, fd, NET_WAIT_READ, tmout2);
+            if (tmout2 >= 0) {
+                len = sizeof(sa_recv);
+                n = recvfrom(fd, recvbuf, sizeof(recvbuf), 0,
+                             (struct sockaddr *)&sa_recv, &len);
+                // check if we received enough data
+                if (n < (jint)sizeof(struct ip)) {
+                    continue;
+                }
+                ip = (struct ip *)recvbuf;
+                hlen = ((jint)(unsigned int)(ip->ip_hl)) << 2;
+                // check if we received enough data
+                if (n < (jint)(hlen + sizeof(struct icmp))) {
+                    continue;
+                }
+                icmp = (struct icmp *)(recvbuf + hlen);
+                // We did receive something, but is it what we were expecting?
+                // I.E.: An ICMP_ECHO_REPLY packet with the proper PID and
+                //       from the host that we are trying to determine is reachable.
+                if (icmp->icmp_type == ICMP_ECHOREPLY &&
+                    (ntohs(icmp->icmp_id) == pid))
+                {
+                    if (sa->sa4.sin_addr.s_addr == sa_recv.sin_addr.s_addr) {
+                        close(fd);
+                        return JNI_TRUE;
+                    } else if (sa->sa4.sin_addr.s_addr == 0) {
+                        close(fd);
+                        return JNI_TRUE;
+                    }
+                }
+            }
+        } while (tmout2 > 0);
+        timeout -= 1000;
+    } while (timeout > 0);
     close(fd);
     return JNI_FALSE;
 }
@@ -413,149 +463,51 @@
  */
 JNIEXPORT jboolean JNICALL
 Java_java_net_Inet4AddressImpl_isReachable0(JNIEnv *env, jobject this,
-                                           jbyteArray addrArray,
-                                           jint timeout,
-                                           jbyteArray ifArray,
-                                           jint ttl) {
-    jint addr;
+                                            jbyteArray addrArray, jint timeout,
+                                            jbyteArray ifArray, jint ttl)
+{
     jbyte caddr[4];
-    jint fd;
-    struct sockaddr_in him;
-    struct sockaddr_in* netif = NULL;
-    struct sockaddr_in inf;
-    int len = 0;
-    int connect_rv = -1;
-    int sz;
+    jint addr = 0, sz, fd;
+    SOCKETADDRESS sa, inf, *netif = NULL;
 
-    memset((char *) caddr, 0, sizeof(caddr));
-    memset((char *) &him, 0, sizeof(him));
-    memset((char *) &inf, 0, sizeof(inf));
+    // check if address array size is 4 (IPv4 address)
     sz = (*env)->GetArrayLength(env, addrArray);
     if (sz != 4) {
       return JNI_FALSE;
     }
+
+    // convert IP address from byte array to integer
+    memset((char *)caddr, 0, sizeof(caddr));
     (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr);
-    addr = ((caddr[0]<<24) & 0xff000000);
-    addr |= ((caddr[1] <<16) & 0xff0000);
-    addr |= ((caddr[2] <<8) & 0xff00);
+    addr = ((caddr[0] << 24) & 0xff000000);
+    addr |= ((caddr[1] << 16) & 0xff0000);
+    addr |= ((caddr[2] << 8) & 0xff00);
     addr |= (caddr[3] & 0xff);
-    addr = htonl(addr);
-    him.sin_addr.s_addr = addr;
-    him.sin_family = AF_INET;
-    len = sizeof(him);
-    /*
-     * If a network interface was specified, let's create the address
-     * for it.
-     */
+    memset((char *)&sa, 0, sizeof(SOCKETADDRESS));
+    sa.sa4.sin_addr.s_addr = htonl(addr);
+    sa.sa4.sin_family = AF_INET;
+
+    // If a network interface was specified, let's convert its address as well.
     if (!(IS_NULL(ifArray))) {
-      memset((char *) caddr, 0, sizeof(caddr));
-      (*env)->GetByteArrayRegion(env, ifArray, 0, 4, caddr);
-      addr = ((caddr[0]<<24) & 0xff000000);
-      addr |= ((caddr[1] <<16) & 0xff0000);
-      addr |= ((caddr[2] <<8) & 0xff00);
-      addr |= (caddr[3] & 0xff);
-      addr = htonl(addr);
-      inf.sin_addr.s_addr = addr;
-      inf.sin_family = AF_INET;
-      inf.sin_port = 0;
-      netif = &inf;
+        memset((char *)caddr, 0, sizeof(caddr));
+        (*env)->GetByteArrayRegion(env, ifArray, 0, 4, caddr);
+        addr = ((caddr[0] << 24) & 0xff000000);
+        addr |= ((caddr[1] << 16) & 0xff0000);
+        addr |= ((caddr[2] << 8) & 0xff00);
+        addr |= (caddr[3] & 0xff);
+        memset((char *)&inf, 0, sizeof(SOCKETADDRESS));
+        inf.sa4.sin_addr.s_addr = htonl(addr);
+        inf.sa4.sin_family = AF_INET;
+        netif = &inf;
     }
 
-    /*
-     * Let's try to create a RAW socket to send ICMP packets
-     * This usually requires "root" privileges, so it's likely to fail.
-     */
+    // Let's try to create a RAW socket to send ICMP packets.
+    // This usually requires "root" privileges, so it's likely to fail.
     fd = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
-    if (fd != -1) {
-      /*
-       * It didn't fail, so we can use ICMP_ECHO requests.
-       */
-      return ping4(env, fd, &him, timeout, netif, ttl);
-    }
-
-    /*
-     * Can't create a raw socket, so let's try a TCP socket
-     */
-    fd = socket(AF_INET, SOCK_STREAM, 0);
     if (fd == -1) {
-        /* note: if you run out of fds, you may not be able to load
-         * the exception class, and get a NoClassDefFoundError
-         * instead.
-         */
-        NET_ThrowNew(env, errno, "Can't create socket");
-        return JNI_FALSE;
-    }
-    if (ttl > 0) {
-      setsockopt(fd, IPPROTO_IP, IP_TTL, &ttl, sizeof(ttl));
-    }
-
-    /*
-     * A network interface was specified, so let's bind to it.
-     */
-    if (netif != NULL) {
-      if (bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in)) < 0) {
-        NET_ThrowNew(env, errno, "Can't bind socket");
-        close(fd);
-        return JNI_FALSE;
-      }
-    }
-
-    /*
-     * Make the socket non blocking so we can use select/poll.
-     */
-    SET_NONBLOCKING(fd);
-
-    him.sin_port = htons(7);    /* Echo */
-    connect_rv = NET_Connect(fd, (struct sockaddr *)&him, len);
-
-    /**
-     * connection established or refused immediately, either way it means
-     * we were able to reach the host!
-     */
-    if (connect_rv == 0 || errno == ECONNREFUSED) {
-        close(fd);
-        return JNI_TRUE;
+        return tcp_ping4(env, &sa, netif, timeout, ttl);
     } else {
-        socklen_t optlen = (socklen_t)sizeof(connect_rv);
-
-        switch (errno) {
-        case ENETUNREACH: /* Network Unreachable */
-        case EAFNOSUPPORT: /* Address Family not supported */
-        case EADDRNOTAVAIL: /* address is not available on  the  remote machine */
-#if defined(__linux__) || defined(_AIX)
-        case EINVAL:
-        case EHOSTUNREACH: /* No route to host */
-          /*
-           * On some Linux versions, when a socket is bound to the loopback
-           * interface, connect will fail and errno will be set to EINVAL
-           * or EHOSTUNREACH.  When that happens, don't throw an exception,
-           * just return false.
-           */
-#endif /* __linux__ */
-          close(fd);
-          return JNI_FALSE;
-        }
-
-        if (errno != EINPROGRESS) {
-          NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
-                                       "connect failed");
-          close(fd);
-          return JNI_FALSE;
-        }
-
-        timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout);
-        if (timeout >= 0) {
-          /* has connection been established? */
-          if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
-                         &optlen) <0) {
-            connect_rv = errno;
-          }
-          if (connect_rv == 0 || connect_rv == ECONNREFUSED) {
-            close(fd);
-            return JNI_TRUE;
-          }
-        }
-        close(fd);
-        return JNI_FALSE;
+        // It didn't fail, so we can use ICMP_ECHO requests.
+        return ping4(env, fd, &sa, netif, timeout, ttl);
     }
 }
diff --git a/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c b/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c
index 15f984e..2760baf 100644
--- a/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c
+++ b/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c
@@ -38,17 +38,22 @@
 
 #include "net_util.h"
 
+#include "java_net_InetAddress.h"
 #include "java_net_Inet4AddressImpl.h"
 #include "java_net_Inet6AddressImpl.h"
-#include "java_net_InetAddress.h"
 
 /* the initial size of our hostent buffers */
 #ifndef NI_MAXHOST
 #define NI_MAXHOST 1025
 #endif
 
+#define SET_NONBLOCKING(fd) {       \
+    int flags = fcntl(fd, F_GETFL); \
+    flags |= O_NONBLOCK;            \
+    fcntl(fd, F_SETFL, flags);      \
+}
 
-/************************************************************************
+/*
  * Inet6AddressImpl
  */
 
@@ -59,58 +64,40 @@
  */
 JNIEXPORT jstring JNICALL
 Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
-    int ret;
-    char hostname[NI_MAXHOST+1];
+    char hostname[NI_MAXHOST + 1];
 
     hostname[0] = '\0';
-    ret = gethostname(hostname, NI_MAXHOST);
-    if (ret == -1) {
-        /* Something went wrong, maybe networking is not setup? */
+    if (gethostname(hostname, NI_MAXHOST) != 0) {
         strcpy(hostname, "localhost");
-    } else {
-        // ensure null-terminated
-        hostname[NI_MAXHOST] = '\0';
-    }
-
 #if defined(__solaris__)
-    if (ret == 0) {
-        /* Solaris doesn't want to give us a fully qualified domain name.
-         * We do a reverse lookup to try and get one.  This works
-         * if DNS occurs before NIS in /etc/resolv.conf, but fails
-         * if NIS comes first (it still gets only a partial name).
-         * We use thread-safe system calls.
-         */
-        struct addrinfo  hints, *res;
-        int error;
+    } else {
+        // try to resolve hostname via nameservice
+        // if it is known but getnameinfo fails, hostname will still be the
+        // value from gethostname
+        struct addrinfo hints, *res;
 
+        // make sure string is null-terminated
+        hostname[NI_MAXHOST] = '\0';
         memset(&hints, 0, sizeof(hints));
         hints.ai_flags = AI_CANONNAME;
         hints.ai_family = AF_UNSPEC;
 
-        error = getaddrinfo(hostname, NULL, &hints, &res);
-
-        if (error == 0) {
-            /* host is known to name service */
-            error = getnameinfo(res->ai_addr,
-                                res->ai_addrlen,
-                                hostname,
-                                NI_MAXHOST,
-                                NULL,
-                                0,
-                                NI_NAMEREQD);
-
-            /* if getnameinfo fails hostname is still the value
-               from gethostname */
-
+        if (getaddrinfo(hostname, NULL, &hints, &res) == 0) {
+            getnameinfo(res->ai_addr, res->ai_addrlen, hostname, NI_MAXHOST,
+                        NULL, 0, NI_NAMEREQD);
             freeaddrinfo(res);
         }
     }
+#else
+    } else {
+        // make sure string is null-terminated
+        hostname[NI_MAXHOST] = '\0';
+    }
 #endif
-
     return (*env)->NewStringUTF(env, hostname);
 }
 
-#ifdef MACOSX
+#if defined(MACOSX)
 /* also called from Inet4AddressImpl.c */
 __private_extern__ jobjectArray
 lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6)
@@ -163,7 +150,7 @@
     struct ifaddrs *iter = ifa;
     while (iter) {
         int family = iter->ifa_addr->sa_family;
-        if (iter->ifa_name[0] != '\0'  &&  iter->ifa_addr)
+        if (iter->ifa_name[0] != '\0' && iter->ifa_addr)
         {
             jboolean isLoopback = iter->ifa_flags & IFF_LOOPBACK;
             if (family == AF_INET) {
@@ -172,9 +159,7 @@
             } else if (family == AF_INET6 && includeV6) {
                 addrs6++;
                 if (isLoopback) numV6Loopbacks++;
-            } else {
-                /* We don't care e.g. AF_LINK */
-            }
+            } // else we don't care, e.g. AF_LINK
         }
         iter = iter->ifa_next;
     }
@@ -205,9 +190,9 @@
         jboolean isLoopback = iter->ifa_flags & IFF_LOOPBACK;
         int family = iter->ifa_addr->sa_family;
 
-        if (iter->ifa_name[0] != '\0'  &&  iter->ifa_addr
-            && (family == AF_INET || (family == AF_INET6 && includeV6))
-            && (!isLoopback || includeLoopback))
+        if (iter->ifa_name[0] != '\0' && iter->ifa_addr &&
+            (family == AF_INET || (family == AF_INET6 && includeV6)) &&
+            (!isLoopback || includeLoopback))
         {
             int port;
             int index = (family == AF_INET) ? i++ : j++;
@@ -234,93 +219,65 @@
 #endif
 
 /*
- * Find an internet address for a given hostname.  Note that this
- * code only works for addresses of type INET. The translation
- * of %d.%d.%d.%d to an address (int) occurs in java now, so the
- * String "host" shouldn't *ever* be a %d.%d.%d.%d string
- *
  * Class:     java_net_Inet6AddressImpl
  * Method:    lookupAllHostAddr
  * Signature: (Ljava/lang/String;)[[B
  */
-
 JNIEXPORT jobjectArray JNICALL
 Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
-                                                jstring host) {
+                                                 jstring host) {
+    jobjectArray ret = NULL;
     const char *hostname;
-    jobjectArray ret = 0;
-    int retLen = 0;
-
-    int getaddrinfo_error=0;
-    struct addrinfo hints, *res, *resNew = NULL;
+    int error = 0;
+    struct addrinfo hints, *res = NULL, *resNew = NULL, *last = NULL,
+        *iterator;
 
     initInetAddressIDs(env);
     JNU_CHECK_EXCEPTION_RETURN(env, NULL);
 
     if (IS_NULL(host)) {
-        JNU_ThrowNullPointerException(env, "host is null");
-        return 0;
+        JNU_ThrowNullPointerException(env, "host argument is null");
+        return NULL;
     }
     hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE);
     CHECK_NULL_RETURN(hostname, NULL);
 
-    /* Try once, with our static buffer. */
+    // try once, with our static buffer
     memset(&hints, 0, sizeof(hints));
     hints.ai_flags = AI_CANONNAME;
     hints.ai_family = AF_UNSPEC;
 
-#ifdef __solaris__
-    /*
-     * Workaround for Solaris bug 4160367 - if a hostname contains a
-     * white space then 0.0.0.0 is returned
-     */
-    if (isspace((unsigned char)hostname[0])) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
-                        hostname);
-        JNU_ReleaseStringPlatformChars(env, host, hostname);
-        return NULL;
-    }
-#endif
+    error = getaddrinfo(hostname, NULL, &hints, &res);
 
-    getaddrinfo_error = getaddrinfo(hostname, NULL, &hints, &res);
-
-#ifdef MACOSX
-    if (getaddrinfo_error) {
-        /*
-         * If getaddrinfo fails looking up the local machine, attempt to get the
-         * address from getifaddrs. This ensures we get an IPv6 address for the
-         * local machine.
-         */
+    if (error) {
+#if defined(MACOSX)
+        // if getaddrinfo fails try getifaddrs
         ret = lookupIfLocalhost(env, hostname, JNI_TRUE);
         if (ret != NULL || (*env)->ExceptionCheck(env)) {
-            JNU_ReleaseStringPlatformChars(env, host, hostname);
-            return ret;
+            goto cleanupAndReturn;
         }
-    }
 #endif
-
-    if (getaddrinfo_error) {
-        /* report error */
-        NET_ThrowUnknownHostExceptionWithGaiError(
-            env, hostname, getaddrinfo_error);
-        JNU_ReleaseStringPlatformChars(env, host, hostname);
-        return NULL;
+        // report error
+        NET_ThrowUnknownHostExceptionWithGaiError(env, hostname, error);
+        goto cleanupAndReturn;
     } else {
-        int i = 0, addressPreference = -1;
-        int inetCount = 0, inet6Count = 0, inetIndex = 0, inet6Index = 0, originalIndex = 0;
-        struct addrinfo *itr, *last = NULL, *iterator = res;
+        int i = 0, inetCount = 0, inet6Count = 0, inetIndex = 0,
+            inet6Index = 0, originalIndex = 0;
+        int addressPreference =
+            (*env)->GetStaticIntField(env, ia_class, ia_preferIPv6AddressID);;
+        iterator = res;
         while (iterator != NULL) {
+            // skip duplicates
             int skip = 0;
-            itr = resNew;
-            while (itr != NULL) {
-                if (iterator->ai_family == itr->ai_family &&
-                    iterator->ai_addrlen == itr->ai_addrlen) {
-                    if (itr->ai_family == AF_INET) { /* AF_INET */
+            struct addrinfo *iteratorNew = resNew;
+            while (iteratorNew != NULL) {
+                if (iterator->ai_family == iteratorNew->ai_family &&
+                    iterator->ai_addrlen == iteratorNew->ai_addrlen) {
+                    if (iteratorNew->ai_family == AF_INET) { /* AF_INET */
                         struct sockaddr_in *addr1, *addr2;
                         addr1 = (struct sockaddr_in *)iterator->ai_addr;
-                        addr2 = (struct sockaddr_in *)itr->ai_addr;
-                        if (addr1->sin_addr.s_addr ==
-                            addr2->sin_addr.s_addr) {
+                        addr2 = (struct sockaddr_in *)iteratorNew->ai_addr;
+                        if (addr1->sin_addr.s_addr == addr2->sin_addr.s_addr) {
                             skip = 1;
                             break;
                         }
@@ -328,7 +285,7 @@
                         int t;
                         struct sockaddr_in6 *addr1, *addr2;
                         addr1 = (struct sockaddr_in6 *)iterator->ai_addr;
-                        addr2 = (struct sockaddr_in6 *)itr->ai_addr;
+                        addr2 = (struct sockaddr_in6 *)iteratorNew->ai_addr;
 
                         for (t = 0; t < 16; t++) {
                             if (addr1->sin6_addr.s6_addr[t] !=
@@ -337,7 +294,7 @@
                             }
                         }
                         if (t < 16) {
-                            itr = itr->ai_next;
+                            iteratorNew = iteratorNew->ai_next;
                             continue;
                         } else {
                             skip = 1;
@@ -346,16 +303,16 @@
                     }
                 } else if (iterator->ai_family != AF_INET &&
                            iterator->ai_family != AF_INET6) {
-                    /* we can't handle other family types */
+                    // we can't handle other family types
                     skip = 1;
                     break;
                 }
-                itr = itr->ai_next;
+                iteratorNew = iteratorNew->ai_next;
             }
 
             if (!skip) {
                 struct addrinfo *next
-                    = (struct addrinfo*) malloc(sizeof(struct addrinfo));
+                    = (struct addrinfo *)malloc(sizeof(struct addrinfo));
                 if (!next) {
                     JNU_ThrowOutOfMemoryError(env, "Native heap allocation failed");
                     ret = NULL;
@@ -371,39 +328,33 @@
                 last = next;
                 i++;
                 if (iterator->ai_family == AF_INET) {
-                    inetCount ++;
+                    inetCount++;
                 } else if (iterator->ai_family == AF_INET6) {
-                    inet6Count ++;
+                    inet6Count++;
                 }
             }
             iterator = iterator->ai_next;
         }
-        retLen = i;
-        iterator = resNew;
 
-        ret = (*env)->NewObjectArray(env, retLen, ia_class, NULL);
-
+        // allocate array - at this point i contains the number of addresses
+        ret = (*env)->NewObjectArray(env, i, ia_class, NULL);
         if (IS_NULL(ret)) {
             /* we may have memory to free at the end of this */
             goto cleanupAndReturn;
         }
 
-        addressPreference = (*env)->GetStaticIntField(env, ia_class, ia_preferIPv6AddressID);
-
         if (addressPreference == java_net_InetAddress_PREFER_IPV6_VALUE) {
-            /* AF_INET addresses will be offset by inet6Count */
             inetIndex = inet6Count;
             inet6Index = 0;
         } else if (addressPreference == java_net_InetAddress_PREFER_IPV4_VALUE) {
-            /* AF_INET6 addresses will be offset by inetCount */
             inetIndex = 0;
             inet6Index = inetCount;
         } else if (addressPreference == java_net_InetAddress_PREFER_SYSTEM_VALUE) {
             inetIndex = inet6Index = originalIndex = 0;
         }
 
+        iterator = resNew;
         while (iterator != NULL) {
-            jboolean ret1;
             if (iterator->ai_family == AF_INET) {
                 jobject iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
                 if (IS_NULL(iaObj)) {
@@ -416,7 +367,7 @@
                 inetIndex++;
             } else if (iterator->ai_family == AF_INET6) {
                 jint scope = 0;
-
+                jboolean ret1;
                 jobject iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
                 if (IS_NULL(iaObj)) {
                     ret = NULL;
@@ -427,9 +378,8 @@
                     ret = NULL;
                     goto cleanupAndReturn;
                 }
-
-                scope = ((struct sockaddr_in6*)iterator->ai_addr)->sin6_scope_id;
-                if (scope != 0) { /* zero is default value, no need to set */
+                scope = ((struct sockaddr_in6 *)iterator->ai_addr)->sin6_scope_id;
+                if (scope != 0) { // zero is default value, no need to set
                     setInet6Address_scopeid(env, iaObj, scope);
                 }
                 setInetAddress_hostName(env, iaObj, host);
@@ -443,21 +393,16 @@
             iterator = iterator->ai_next;
         }
     }
-
- cleanupAndReturn:
-    {
-      struct addrinfo *iterator, *tmp;
-        iterator = resNew;
-        while (iterator != NULL) {
-            tmp = iterator;
-            iterator = iterator->ai_next;
-            free(tmp);
-        }
-        JNU_ReleaseStringPlatformChars(env, host, hostname);
+cleanupAndReturn:
+    JNU_ReleaseStringPlatformChars(env, host, hostname);
+    while (resNew != NULL) {
+        last = resNew;
+        resNew = resNew->ai_next;
+        free(last);
     }
-
-    freeaddrinfo(res);
-
+    if (res != NULL) {
+        freeaddrinfo(res);
+    }
     return ret;
 }
 
@@ -465,171 +410,252 @@
  * Class:     java_net_Inet6AddressImpl
  * Method:    getHostByAddr
  * Signature: (I)Ljava/lang/String;
+ *
+ * Theoretically the UnknownHostException could be enriched with gai error
+ * information. But as it is silently ignored anyway, there's no need for this.
+ * It's only important that either a valid hostname is returned or an
+ * UnknownHostException is thrown.
  */
 JNIEXPORT jstring JNICALL
 Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
-                                            jbyteArray addrArray) {
-
+                                             jbyteArray addrArray) {
     jstring ret = NULL;
-
-    char host[NI_MAXHOST+1];
-    int error = 0;
+    char host[NI_MAXHOST + 1];
     int len = 0;
     jbyte caddr[16];
+    SOCKETADDRESS sa;
 
-    struct sockaddr_in him4;
-    struct sockaddr_in6 him6;
-    struct sockaddr *sa;
+    memset((void *)&sa, 0, sizeof(SOCKETADDRESS));
 
-    /*
-     * For IPv4 addresses construct a sockaddr_in structure.
-     */
+    // construct a sockaddr_in structure (AF_INET or AF_INET6)
     if ((*env)->GetArrayLength(env, addrArray) == 4) {
         jint addr;
         (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr);
-        addr = ((caddr[0]<<24) & 0xff000000);
-        addr |= ((caddr[1] <<16) & 0xff0000);
-        addr |= ((caddr[2] <<8) & 0xff00);
+        addr = ((caddr[0] << 24) & 0xff000000);
+        addr |= ((caddr[1] << 16) & 0xff0000);
+        addr |= ((caddr[2] << 8) & 0xff00);
         addr |= (caddr[3] & 0xff);
-        memset((void *) &him4, 0, sizeof(him4));
-        him4.sin_addr.s_addr = htonl(addr);
-        him4.sin_family = AF_INET;
-        sa = (struct sockaddr *)&him4;
-        len = sizeof(him4);
+        sa.sa4.sin_addr.s_addr = htonl(addr);
+        sa.sa4.sin_family = AF_INET;
+        len = sizeof(struct sockaddr_in);
     } else {
-        /*
-         * For IPv6 address construct a sockaddr_in6 structure.
-         */
         (*env)->GetByteArrayRegion(env, addrArray, 0, 16, caddr);
-        memset((void *)&him6, 0, sizeof(him6));
-        memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr));
-        him6.sin6_family = AF_INET6;
-        sa = (struct sockaddr *)&him6;
-        len = sizeof(him6);
+        memcpy((void *)&sa.sa6.sin6_addr, caddr, sizeof(struct in6_addr));
+        sa.sa6.sin6_family = AF_INET6;
+        len = sizeof(struct sockaddr_in6);
     }
 
-    error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
-
-    if (!error) {
+    if (getnameinfo(&sa.sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD)) {
+        JNU_ThrowByName(env, "java/net/UnknownHostException", NULL);
+    } else {
         ret = (*env)->NewStringUTF(env, host);
-        CHECK_NULL_RETURN(ret, NULL);
-    }
-
-    if (ret == NULL) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", NULL);
+        if (ret == NULL) {
+            JNU_ThrowByName(env, "java/net/UnknownHostException", NULL);
+        }
     }
 
     return ret;
 }
 
-#define SET_NONBLOCKING(fd) {           \
-        int flags = fcntl(fd, F_GETFL); \
-        flags |= O_NONBLOCK;            \
-        fcntl(fd, F_SETFL, flags);      \
+/**
+ * ping implementation using tcp port 7 (echo)
+ */
+static jboolean
+tcp_ping6(JNIEnv *env, SOCKETADDRESS *sa, SOCKETADDRESS *netif, jint timeout,
+          jint ttl)
+{
+    jint fd;
+    int connect_rv = -1;
+
+    // open a TCP socket
+    fd = socket(AF_INET6, SOCK_STREAM, 0);
+    if (fd == -1) {
+        // note: if you run out of fds, you may not be able to load
+        // the exception class, and get a NoClassDefFoundError instead.
+        NET_ThrowNew(env, errno, "Can't create socket");
+        return JNI_FALSE;
+    }
+
+    // set TTL
+    if (ttl > 0) {
+        setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl));
+    }
+
+    // A network interface was specified, so let's bind to it.
+    if (netif != NULL) {
+        if (bind(fd, &netif->sa, sizeof(struct sockaddr_in6)) <0) {
+            NET_ThrowNew(env, errno, "Can't bind socket");
+            close(fd);
+            return JNI_FALSE;
+        }
+    }
+
+    // Make the socket non blocking so we can use select/poll.
+    SET_NONBLOCKING(fd);
+
+    sa->sa6.sin6_port = htons(7); // echo port
+    connect_rv = NET_Connect(fd, &sa->sa, sizeof(struct sockaddr_in6));
+
+    // connection established or refused immediately, either way it means
+    // we were able to reach the host!
+    if (connect_rv == 0 || errno == ECONNREFUSED) {
+        close(fd);
+        return JNI_TRUE;
+    }
+
+    switch (errno) {
+    case ENETUNREACH:   // Network Unreachable
+    case EAFNOSUPPORT:  // Address Family not supported
+    case EADDRNOTAVAIL: // address is not available on the remote machine
+#if defined(__linux__) || defined(_AIX)
+        // On some Linux versions, when a socket is bound to the loopback
+        // interface, connect will fail and errno will be set to EINVAL
+        // or EHOSTUNREACH.  When that happens, don't throw an exception,
+        // just return false.
+    case EINVAL:
+    case EHOSTUNREACH:  // No route to host
+#endif
+        close(fd);
+        return JNI_FALSE;
+    case EINPROGRESS:   // this is expected as we'll probably have to wait
+        break;
+    default:
+        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
+                                     "connect failed");
+        close(fd);
+        return JNI_FALSE;
+    }
+
+    timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout);
+    if (timeout >= 0) {
+        // connection has been established, check for error condition
+        socklen_t optlen = (socklen_t)sizeof(connect_rv);
+        if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
+                       &optlen) <0)
+        {
+            connect_rv = errno;
+        }
+        if (connect_rv == 0 || connect_rv == ECONNREFUSED) {
+            close(fd);
+            return JNI_TRUE;
+        }
+    }
+    close(fd);
+    return JNI_FALSE;
 }
 
+/**
+ * ping implementation.
+ * Send an ICMP_ECHO_REQUEST packet every second until either the timeout
+ * expires or an answer is received.
+ * Returns true if an ECHO_REPLY is received, false otherwise.
+ */
 static jboolean
-ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout,
-      struct sockaddr_in6* netif, jint ttl) {
-    jint size;
-    jint n;
+ping6(JNIEnv *env, jint fd, SOCKETADDRESS *sa, SOCKETADDRESS *netif,
+      jint timeout, jint ttl)
+{
+    jint n, size = 60 * 1024, tmout2, seq = 1;
     socklen_t len;
-    char sendbuf[1500];
-    unsigned char recvbuf[1500];
+    unsigned char sendbuf[1500], recvbuf[1500];
     struct icmp6_hdr *icmp6;
     struct sockaddr_in6 sa_recv;
-    jbyte *caddr, *recv_caddr;
     jchar pid;
-    jint tmout2, seq = 1;
     struct timeval tv;
-    size_t plen;
+    size_t plen = sizeof(struct icmp6_hdr) + sizeof(tv);
 
-#ifdef __linux__
-    {
-    int csum_offset;
+#if defined(__linux__)
     /**
      * For some strange reason, the linux kernel won't calculate the
      * checksum of ICMPv6 packets unless you set this socket option
      */
-    csum_offset = 2;
+    int csum_offset = 2;
     setsockopt(fd, SOL_RAW, IPV6_CHECKSUM, &csum_offset, sizeof(int));
-    }
 #endif
 
-    caddr = (jbyte *)&(him->sin6_addr);
-
-    /* icmp_id is a 16 bit data type, therefore down cast the pid */
-    pid = (jchar)getpid();
-    size = 60*1024;
     setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
+
+    // sets the ttl (max number of hops)
     if (ttl > 0) {
-      setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl));
+        setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl));
     }
+
+    // a specific interface was specified, so let's bind the socket
+    // to that interface to ensure the requests are sent only through it.
     if (netif != NULL) {
-      if (bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in6)) <0) {
-        NET_ThrowNew(env, errno, "Can't bind socket");
-        close(fd);
-        return JNI_FALSE;
-      }
-    }
-    SET_NONBLOCKING(fd);
-
-    do {
-      icmp6 = (struct icmp6_hdr *) sendbuf;
-      icmp6->icmp6_type = ICMP6_ECHO_REQUEST;
-      icmp6->icmp6_code = 0;
-      /* let's tag the ECHO packet with our pid so we can identify it */
-      icmp6->icmp6_id = htons(pid);
-      icmp6->icmp6_seq = htons(seq);
-      seq++;
-      icmp6->icmp6_cksum = 0;
-      gettimeofday(&tv, NULL);
-      memcpy(sendbuf + sizeof(struct icmp6_hdr), &tv, sizeof(tv));
-      plen = sizeof(struct icmp6_hdr) + sizeof(tv);
-      n = sendto(fd, sendbuf, plen, 0, (struct sockaddr*) him, sizeof(struct sockaddr_in6));
-      if (n < 0 && errno != EINPROGRESS) {
-#ifdef __linux__
-        if (errno != EINVAL && errno != EHOSTUNREACH)
-          /*
-           * On some Linux versions, when a socket is  bound to the
-           * loopback interface, sendto will fail and errno will be
-           * set to EINVAL or EHOSTUNREACH.
-           * When that happens, don't throw an exception, just return false.
-           */
-#endif /*__linux__ */
-        NET_ThrowNew(env, errno, "Can't send ICMP packet");
-        close(fd);
-        return JNI_FALSE;
-      }
-
-      tmout2 = timeout > 1000 ? 1000 : timeout;
-      do {
-        tmout2 = NET_Wait(env, fd, NET_WAIT_READ, tmout2);
-
-        if (tmout2 >= 0) {
-          len = sizeof(sa_recv);
-          n = recvfrom(fd, recvbuf, sizeof(recvbuf), 0, (struct sockaddr*) &sa_recv, &len);
-          icmp6 = (struct icmp6_hdr *) (recvbuf);
-          recv_caddr = (jbyte *)&(sa_recv.sin6_addr);
-          /*
-           * We did receive something, but is it what we were expecting?
-           * I.E.: An ICMP6_ECHO_REPLY packet with the proper PID and
-           *       from the host that we are trying to determine is reachable.
-           */
-          if (n >= 8 && icmp6->icmp6_type == ICMP6_ECHO_REPLY &&
-              (ntohs(icmp6->icmp6_id) == pid)) {
-            if (NET_IsEqual(caddr, recv_caddr)) {
-              close(fd);
-              return JNI_TRUE;
-            }
-            if (NET_IsZeroAddr(caddr)) {
-              close(fd);
-              return JNI_TRUE;
-            }
-          }
+        if (bind(fd, &netif->sa, sizeof(struct sockaddr_in6)) <0) {
+            NET_ThrowNew(env, errno, "Can't bind socket");
+            close(fd);
+            return JNI_FALSE;
         }
-      } while (tmout2 > 0);
-      timeout -= 1000;
+    }
+
+    // icmp_id is a 16 bit data type, therefore down cast the pid
+    pid = (jchar)getpid();
+
+    // Make the socket non blocking so we can use select
+    SET_NONBLOCKING(fd);
+    do {
+        // create the ICMP request
+        icmp6 = (struct icmp6_hdr *)sendbuf;
+        icmp6->icmp6_type = ICMP6_ECHO_REQUEST;
+        icmp6->icmp6_code = 0;
+        // let's tag the ECHO packet with our pid so we can identify it
+        icmp6->icmp6_id = htons(pid);
+        icmp6->icmp6_seq = htons(seq);
+        seq++;
+        gettimeofday(&tv, NULL);
+        memcpy(sendbuf + sizeof(struct icmp6_hdr), &tv, sizeof(tv));
+        icmp6->icmp6_cksum = 0;
+        // send it
+        n = sendto(fd, sendbuf, plen, 0, &sa->sa, sizeof(struct sockaddr_in6));
+        if (n < 0 && errno != EINPROGRESS) {
+#if defined(__linux__)
+            /*
+             * On some Linux versions, when a socket is bound to the loopback
+             * interface, sendto will fail and errno will be set to
+             * EINVAL or EHOSTUNREACH. When that happens, don't throw an
+             * exception, just return false.
+             */
+            if (errno != EINVAL && errno != EHOSTUNREACH) {
+                NET_ThrowNew(env, errno, "Can't send ICMP packet");
+            }
+#else
+            NET_ThrowNew(env, errno, "Can't send ICMP packet");
+#endif
+            close(fd);
+            return JNI_FALSE;
+        }
+
+        tmout2 = timeout > 1000 ? 1000 : timeout;
+        do {
+            tmout2 = NET_Wait(env, fd, NET_WAIT_READ, tmout2);
+            if (tmout2 >= 0) {
+                len = sizeof(sa_recv);
+                n = recvfrom(fd, recvbuf, sizeof(recvbuf), 0,
+                             (struct sockaddr *)&sa_recv, &len);
+                // check if we received enough data
+                if (n < (jint)sizeof(struct icmp6_hdr)) {
+                    continue;
+                }
+                icmp6 = (struct icmp6_hdr *)recvbuf;
+                // We did receive something, but is it what we were expecting?
+                // I.E.: An ICMP6_ECHO_REPLY packet with the proper PID and
+                //       from the host that we are trying to determine is reachable.
+                if (icmp6->icmp6_type == ICMP6_ECHO_REPLY &&
+                    (ntohs(icmp6->icmp6_id) == pid))
+                {
+                    if (NET_IsEqual((jbyte *)&sa->sa6.sin6_addr,
+                                    (jbyte *)&sa_recv.sin6_addr)) {
+                        close(fd);
+                        return JNI_TRUE;
+                    } else if (NET_IsZeroAddr((jbyte *)&sa->sa6.sin6_addr)) {
+                        close(fd);
+                        return JNI_TRUE;
+                    }
+                }
+            }
+        } while (tmout2 > 0);
+        timeout -= 1000;
     } while (timeout > 0);
     close(fd);
     return JNI_FALSE;
@@ -642,157 +668,61 @@
  */
 JNIEXPORT jboolean JNICALL
 Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
-                                           jbyteArray addrArray,
-                                           jint scope,
-                                           jint timeout,
-                                           jbyteArray ifArray,
-                                           jint ttl, jint if_scope) {
+                                            jbyteArray addrArray, jint scope,
+                                            jint timeout, jbyteArray ifArray,
+                                            jint ttl, jint if_scope)
+{
     jbyte caddr[16];
-    jint fd, sz;
-    struct sockaddr_in6 him6;
-    struct sockaddr_in6 inf6;
-    struct sockaddr_in6* netif = NULL;
-    int len = 0;
-    int connect_rv = -1;
+    jint sz, fd;
+    SOCKETADDRESS sa, inf, *netif = NULL;
 
-    /*
-     * If IPv6 is not enable, then we can't reach an IPv6 address, can we?
-     */
+    // If IPv6 is not enabled, then we can't reach an IPv6 address, can we?
+    // Actually, we probably shouldn't even get here.
     if (!ipv6_available()) {
-      return JNI_FALSE;
+        return JNI_FALSE;
     }
-    /*
-     * If it's an IPv4 address, ICMP won't work with IPv4 mapped address,
-     * therefore, let's delegate to the Inet4Address method.
-     */
+
+    // If it's an IPv4 address, ICMP won't work with IPv4 mapped address,
+    // therefore, let's delegate to the Inet4Address method.
     sz = (*env)->GetArrayLength(env, addrArray);
     if (sz == 4) {
-      return Java_java_net_Inet4AddressImpl_isReachable0(env, this,
-                                                         addrArray,
-                                                         timeout,
-                                                         ifArray, ttl);
+        return Java_java_net_Inet4AddressImpl_isReachable0(env, this,
+                                                           addrArray, timeout,
+                                                           ifArray, ttl);
     }
 
-    memset((void *) caddr, 0, 16);
-    memset((void *) &him6, 0, sizeof(him6));
+    // load address to SOCKETADDRESS
+    memset((char *)caddr, 0, 16);
     (*env)->GetByteArrayRegion(env, addrArray, 0, 16, caddr);
-    memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr) );
-    him6.sin6_family = AF_INET6;
-#ifdef __linux__
-    if (scope > 0)
-      him6.sin6_scope_id = scope;
-    else
-      him6.sin6_scope_id = getDefaultIPv6Interface( &(him6.sin6_addr));
-    len = sizeof(struct sockaddr_in6);
-#else
-    if (scope > 0)
-      him6.sin6_scope_id = scope;
-    len = sizeof(struct sockaddr_in6);
-#endif
-    /*
-     * If a network interface was specified, let's create the address
-     * for it.
-     */
-    if (!(IS_NULL(ifArray))) {
-      memset((void *) caddr, 0, 16);
-      memset((void *) &inf6, 0, sizeof(inf6));
-      (*env)->GetByteArrayRegion(env, ifArray, 0, 16, caddr);
-      memcpy((void *)&(inf6.sin6_addr), caddr, sizeof(struct in6_addr) );
-      inf6.sin6_family = AF_INET6;
-      inf6.sin6_scope_id = if_scope;
-      netif = &inf6;
-    }
-    /*
-     * If we can create a RAW socket, then when can use the ICMP ECHO_REQUEST
-     * otherwise we'll try a tcp socket to the Echo port (7).
-     * Note that this is empiric, and not connecting could mean it's blocked
-     * or the echo service has been disabled.
-     */
-
-    fd = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
-
-    if (fd != -1) { /* Good to go, let's do a ping */
-        return ping6(env, fd, &him6, timeout, netif, ttl);
-    }
-
-    /* No good, let's fall back on TCP */
-    fd = socket(AF_INET6, SOCK_STREAM, 0);
-    if (fd == -1) {
-        /* note: if you run out of fds, you may not be able to load
-         * the exception class, and get a NoClassDefFoundError
-         * instead.
-         */
-        NET_ThrowNew(env, errno, "Can't create socket");
-        return JNI_FALSE;
-    }
-    if (ttl > 0) {
-      setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &ttl, sizeof(ttl));
-    }
-
-    /*
-     * A network interface was specified, so let's bind to it.
-     */
-    if (netif != NULL) {
-      if (bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in6)) <0) {
-        NET_ThrowNew(env, errno, "Can't bind socket");
-        close(fd);
-        return JNI_FALSE;
-      }
-    }
-    SET_NONBLOCKING(fd);
-
-    him6.sin6_port = htons((short) 7); /* Echo port */
-    connect_rv = NET_Connect(fd, (struct sockaddr *)&him6, len);
-
-    /**
-     * connection established or refused immediately, either way it means
-     * we were able to reach the host!
-     */
-    if (connect_rv == 0 || errno == ECONNREFUSED) {
-        close(fd);
-        return JNI_TRUE;
+    memset((char *)&sa, 0, sizeof(SOCKETADDRESS));
+    memcpy((void *)&sa.sa6.sin6_addr, caddr, sizeof(struct in6_addr));
+    sa.sa6.sin6_family = AF_INET6;
+    if (scope > 0) {
+        sa.sa6.sin6_scope_id = scope;
+#if defined(__linux__)
     } else {
-        socklen_t optlen = (socklen_t)sizeof(connect_rv);
+        sa.sa6.sin6_scope_id = getDefaultIPv6Interface(&sa.sa6.sin6_addr);
+#endif
+    }
 
-        switch (errno) {
-        case ENETUNREACH: /* Network Unreachable */
-        case EAFNOSUPPORT: /* Address Family not supported */
-        case EADDRNOTAVAIL: /* address is not available on  the  remote machine */
-#if defined(__linux__) || defined(_AIX)
-        case EINVAL:
-        case EHOSTUNREACH: /* No route to host */
-          /*
-           * On some Linux versions, when  a socket is bound to the
-           * loopback interface, connect will fail and errno will
-           * be set to EINVAL or EHOSTUNREACH.  When that happens,
-           * don't throw an exception, just return false.
-           */
-#endif /* __linux__ */
-          close(fd);
-          return JNI_FALSE;
-        }
+    // load network interface address to SOCKETADDRESS, if specified
+    if (!(IS_NULL(ifArray))) {
+        memset((char *)caddr, 0, 16);
+        (*env)->GetByteArrayRegion(env, ifArray, 0, 16, caddr);
+        memset((char *)&inf, 0, sizeof(SOCKETADDRESS));
+        memcpy((void *)&inf.sa6.sin6_addr, caddr, sizeof(struct in6_addr));
+        inf.sa6.sin6_family = AF_INET6;
+        inf.sa6.sin6_scope_id = if_scope;
+        netif = &inf;
+    }
 
-        if (errno != EINPROGRESS) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
-                                         "connect failed");
-            close(fd);
-            return JNI_FALSE;
-        }
-
-        timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout);
-
-        if (timeout >= 0) {
-          /* has connection been established */
-          if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
-                         &optlen) <0) {
-            connect_rv = errno;
-          }
-          if (connect_rv == 0 || connect_rv == ECONNREFUSED) {
-            close(fd);
-            return JNI_TRUE;
-          }
-        }
-        close(fd);
-        return JNI_FALSE;
+    // Let's try to create a RAW socket to send ICMP packets.
+    // This usually requires "root" privileges, so it's likely to fail.
+    fd = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
+    if (fd == -1) {
+        return tcp_ping6(env, &sa, netif, timeout, ttl);
+    } else {
+        // It didn't fail, so we can use ICMP_ECHO requests.
+        return ping6(env, fd, &sa, netif, timeout, ttl);
     }
 }
diff --git a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c
index 88c2795..96f7dfb 100644
--- a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c
+++ b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c
@@ -361,7 +361,11 @@
                         ((struct sockaddr_in6*)addrP->addr)->sin6_addr);
                     jbyte caddr[16];
                     int i;
+                    unsigned int scopeid;
                     getInet6Address_ipaddress(env, iaObj, (char *)caddr);
+                    scopeid = (unsigned int)getInet6Address_scopeid(env, iaObj);
+                    if (scopeid != 0 && scopeid != ((struct sockaddr_in6*)addrP->addr)->sin6_scope_id)
+                        break;
                     i = 0;
                     while (i < 16) {
                         if (caddr[i] != bytes[i]) {
diff --git a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c
index 1235733..a3c575f 100644
--- a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c
+++ b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c
@@ -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",
diff --git a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c
index 1985085..7d96751 100644
--- a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c
+++ b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c
@@ -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) {
diff --git a/jdk/src/java.base/unix/native/libnet/SocketInputStream.c b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c
index 961f53c..7d927bd 100644
--- a/jdk/src/java.base/unix/native/libnet/SocketInputStream.c
+++ b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c
@@ -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;
diff --git a/jdk/src/java.base/unix/native/libnet/net_util_md.c b/jdk/src/java.base/unix/native/libnet/net_util_md.c
index 744fc2f..226315f 100644
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.c
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c
@@ -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;
-}
-
-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);
+    return (nanoTimeout / NET_NSEC_PER_MSEC);
 }
diff --git a/jdk/src/java.base/unix/native/libnet/net_util_md.h b/jdk/src/java.base/unix/native/libnet/net_util_md.h
index 15e08c4..d6efd2b 100644
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.h
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h
@@ -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);
diff --git a/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c b/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c
index ef512a1..8ed0694 100644
--- a/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c
+++ b/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c
@@ -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
@@ -90,29 +90,16 @@
 #if defined(__solaris__)
     rv = connect(fd, 0, 0);
 #else
-    int len;
     SOCKETADDRESS sa;
+    socklen_t len = isIPv6 ? sizeof(struct sockaddr_in6) :
+                             sizeof(struct sockaddr_in);
 
     memset(&sa, 0, sizeof(sa));
-
-#ifdef AF_INET6
-    if (isIPv6) {
 #if defined(_ALLBSD_SOURCE)
-        sa.sa6.sin6_family = AF_INET6;
+    sa.sa.sa_family = isIPv6 ? AF_INET6 : AF_INET;
 #else
-        sa.sa6.sin6_family = AF_UNSPEC;
+    sa.sa.sa_family = AF_UNSPEC;
 #endif
-        len = sizeof(struct sockaddr_in6);
-    } else
-#endif
-    {
-#if defined(_ALLBSD_SOURCE)
-        sa.sa4.sin_family = AF_INET;
-#else
-        sa.sa4.sin_family = AF_UNSPEC;
-#endif
-        len = sizeof(struct sockaddr_in);
-    }
 
     rv = connect(fd, &sa.sa, len);
 
@@ -126,8 +113,9 @@
      */
     if (rv < 0 && errno == EAFNOSUPPORT)
         rv = errno = 0;
-#endif
-#endif
+#endif // defined(_ALLBSD_SOURCE) || defined(_AIX)
+
+#endif // defined(__solaris__)
 
     if (rv < 0)
         handleSocketError(env, errno);
diff --git a/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c b/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c
index 37ed11a..817a38d 100644
--- a/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c
+++ b/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c
@@ -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
@@ -37,14 +37,8 @@
 
 #include "sun_nio_ch_InheritedChannel.h"
 
-static int matchFamily(struct sockaddr *sa) {
-    int family = sa->sa_family;
-#ifdef AF_INET6
-    if (ipv6_available()) {
-        return (family == AF_INET6);
-    }
-#endif
-    return (family == AF_INET);
+static int matchFamily(SOCKETADDRESS *sa) {
+    return (sa->sa.sa_family == (ipv6_available() ? AF_INET6 : AF_INET));
 }
 
 JNIEXPORT void JNICALL
@@ -63,7 +57,7 @@
     jint remote_port;
 
     if (getpeername(fd, &sa.sa, &len) == 0) {
-        if (matchFamily(&sa.sa)) {
+        if (matchFamily(&sa)) {
             remote_ia = NET_SockaddrToInetAddress(env, &sa, (int *)&remote_port);
         }
     }
@@ -71,7 +65,6 @@
     return remote_ia;
 }
 
-
 JNIEXPORT jint JNICALL
 Java_sun_nio_ch_InheritedChannel_peerPort0(JNIEnv *env, jclass cla, jint fd)
 {
@@ -80,7 +73,7 @@
     jint remote_port = -1;
 
     if (getpeername(fd, &sa.sa, &len) == 0) {
-        if (matchFamily(&sa.sa)) {
+        if (matchFamily(&sa)) {
             NET_SockaddrToInetAddress(env, &sa, (int *)&remote_port);
         }
     }
@@ -92,7 +85,7 @@
 Java_sun_nio_ch_InheritedChannel_soType0(JNIEnv *env, jclass cla, jint fd)
 {
     int sotype;
-    socklen_t arglen=sizeof(sotype);
+    socklen_t arglen = sizeof(sotype);
     if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *)&sotype, &arglen) == 0) {
         if (sotype == SOCK_STREAM)
             return sun_nio_ch_InheritedChannel_SOCK_STREAM;
@@ -123,7 +116,7 @@
 JNIEXPORT jint JNICALL
 Java_sun_nio_ch_InheritedChannel_open0(JNIEnv *env, jclass cla, jstring path, jint oflag)
 {
-    const char* str;
+    const char *str;
     int oflag_actual;
 
     /* convert to OS specific value */
diff --git a/jdk/src/java.base/unix/native/libnio/ch/Net.c b/jdk/src/java.base/unix/native/libnio/ch/Net.c
index dd9aedc..1158711 100644
--- a/jdk/src/java.base/unix/native/libnio/ch/Net.c
+++ b/jdk/src/java.base/unix/native/libnio/ch/Net.c
@@ -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
@@ -101,23 +101,21 @@
  * Copy IPv6 group, interface index, and IPv6 source address
  * into group_source_req structure.
  */
-#ifdef AF_INET6
 static void initGroupSourceReq(JNIEnv* env, jbyteArray group, jint index,
-                               jbyteArray source, struct group_source_req* req)
+                               jbyteArray source, struct group_source_req *req)
 {
     struct sockaddr_in6* sin6;
 
     req->gsr_interface = (uint32_t)index;
 
-    sin6 = (struct sockaddr_in6*)&(req->gsr_group);
+    sin6 = (struct sockaddr_in6 *)&(req->gsr_group);
     sin6->sin6_family = AF_INET6;
-    COPY_INET6_ADDRESS(env, group, (jbyte*)&(sin6->sin6_addr));
+    COPY_INET6_ADDRESS(env, group, (jbyte *)&(sin6->sin6_addr));
 
-    sin6 = (struct sockaddr_in6*)&(req->gsr_source);
+    sin6 = (struct sockaddr_in6 *)&(req->gsr_source);
     sin6->sin6_family = AF_INET6;
-    COPY_INET6_ADDRESS(env, source, (jbyte*)&(sin6->sin6_addr));
+    COPY_INET6_ADDRESS(env, source, (jbyte *)&(sin6->sin6_addr));
 }
-#endif
 
 #ifdef _AIX
 
@@ -199,18 +197,13 @@
 {
     int fd;
     int type = (stream ? SOCK_STREAM : SOCK_DGRAM);
-#ifdef AF_INET6
     int domain = (ipv6_available() && preferIPv6) ? AF_INET6 : AF_INET;
-#else
-    int domain = AF_INET;
-#endif
 
     fd = socket(domain, type, 0);
     if (fd < 0) {
         return handleSocketError(env, errno);
     }
 
-#ifdef AF_INET6
     /* Disable IPV6_V6ONLY to ensure dual-socket support */
     if (domain == AF_INET6) {
         int arg = 0;
@@ -223,7 +216,6 @@
             return -1;
         }
     }
-#endif
 
     if (reuse) {
         int arg = 1;
@@ -250,9 +242,7 @@
             return -1;
         }
     }
-#endif
 
-#if defined(__linux__) && defined(AF_INET6)
     /* By default, Linux uses the route default */
     if (domain == AF_INET6 && type == SOCK_DGRAM) {
         int arg = 1;
@@ -569,7 +559,6 @@
 Java_sun_nio_ch_Net_joinOrDrop6(JNIEnv *env, jobject this, jboolean join, jobject fdo,
                                 jbyteArray group, jint index, jbyteArray source)
 {
-#ifdef AF_INET6
     struct ipv6_mreq mreq6;
     struct group_source_req req;
     int opt, n, optlen;
@@ -600,21 +589,16 @@
         handleSocketError(env, errno);
     }
     return 0;
-#else
-    JNU_ThrowInternalError(env, "Should not get here");
-    return IOS_THROWN;
-#endif  /* AF_INET6 */
 }
 
 JNIEXPORT jint JNICALL
 Java_sun_nio_ch_Net_blockOrUnblock6(JNIEnv *env, jobject this, jboolean block, jobject fdo,
                                     jbyteArray group, jint index, jbyteArray source)
 {
-#ifdef AF_INET6
-  #ifdef __APPLE__
+#ifdef __APPLE__
     /* no IPv6 exclude-mode filtering for now */
     return IOS_UNAVAILABLE;
-  #else
+#else
     struct group_source_req req;
     int n;
     int opt = (block) ? MCAST_BLOCK_SOURCE : MCAST_UNBLOCK_SOURCE;
@@ -629,10 +613,6 @@
         handleSocketError(env, errno);
     }
     return 0;
-  #endif
-#else
-    JNU_ThrowInternalError(env, "Should not get here");
-    return IOS_THROWN;
 #endif
 }
 
diff --git a/jdk/src/java.base/windows/native/libjava/WinNTFileSystem_md.c b/jdk/src/java.base/windows/native/libjava/WinNTFileSystem_md.c
index 5e1664e..3ffd441 100644
--- a/jdk/src/java.base/windows/native/libjava/WinNTFileSystem_md.c
+++ b/jdk/src/java.base/windows/native/libjava/WinNTFileSystem_md.c
@@ -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
@@ -472,7 +472,7 @@
                                                  jobject file)
 {
     jlong rv = 0;
-    LARGE_INTEGER modTime;
+    ULARGE_INTEGER modTime;
     FILETIME t;
     HANDLE h;
     WCHAR *pathbuf = fileToNTPath(env, file, ids.path);
@@ -784,7 +784,7 @@
                     FILE_FLAG_BACKUP_SEMANTICS,
                     0);
     if (h != INVALID_HANDLE_VALUE) {
-        LARGE_INTEGER modTime;
+        ULARGE_INTEGER modTime;
         FILETIME t;
         modTime.QuadPart = (time + 11644473600000L) * 10000L;
         t.dwLowDateTime = (DWORD)modTime.LowPart;
diff --git a/jdk/src/java.base/windows/native/libjli/java_md.c b/jdk/src/java.base/windows/native/libjli/java_md.c
index 385fc8c..1873945 100644
--- a/jdk/src/java.base/windows/native/libjli/java_md.c
+++ b/jdk/src/java.base/windows/native/libjli/java_md.c
@@ -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)) {
diff --git a/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c b/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c
index 8a901af..ea16f7b 100644
--- a/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c
+++ b/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c
@@ -30,60 +30,6 @@
 #include "java_net_Inet4AddressImpl.h"
 
 /*
- * Returns true if hostname is in dotted IP address format. Note that this
- * function performs a syntax check only. For each octet it just checks that
- * the octet is at most 3 digits.
- */
-jboolean isDottedIPAddress(const char *hostname, unsigned int *addrp) {
-    char *c = (char *)hostname;
-    int octets = 0;
-    unsigned int cur = 0;
-    int digit_cnt = 0;
-
-    while (*c) {
-        if (*c == '.') {
-            if (digit_cnt == 0) {
-                return JNI_FALSE;
-            } else {
-                if (octets < 4) {
-                    addrp[octets++] = cur;
-                    cur = 0;
-                    digit_cnt = 0;
-                } else {
-                    return JNI_FALSE;
-                }
-            }
-            c++;
-            continue;
-        }
-
-        if ((*c < '0') || (*c > '9')) {
-            return JNI_FALSE;
-        }
-
-        digit_cnt++;
-        if (digit_cnt > 3) {
-            return JNI_FALSE;
-        }
-
-        /* don't check if current octet > 255 */
-        cur = cur*10 + (*c - '0');
-
-        /* Move onto next character and check for EOF */
-        c++;
-        if (*c == '\0') {
-            if (octets < 4) {
-                addrp[octets++] = cur;
-            } else {
-                return JNI_FALSE;
-            }
-        }
-    }
-
-    return (jboolean)(octets == 4);
-}
-
-/*
  * Inet4AddressImpl
  */
 
@@ -93,17 +39,17 @@
  * Signature: ()Ljava/lang/String;
  */
 JNIEXPORT jstring JNICALL
-Java_java_net_Inet4AddressImpl_getLocalHostName (JNIEnv *env, jobject this) {
+Java_java_net_Inet4AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
     char hostname[256];
 
-    if (gethostname(hostname, sizeof hostname) == -1) {
+    if (gethostname(hostname, sizeof(hostname)) == -1) {
         strcpy(hostname, "localhost");
     }
     return JNU_NewStringPlatform(env, hostname);
 }
 
 /*
- * Find an internet address for a given hostname.  Not this this
+ * Find an internet address for a given hostname. Note that this
  * code only works for addresses of type INET. The translation
  * of %d.%d.%d.%d to an address (int) occurs in java now, so the
  * String "host" shouldn't be a %d.%d.%d.%d string. The only
@@ -120,7 +66,6 @@
     jobjectArray ret = NULL;
     const char *hostname;
     int error = 0;
-    unsigned int addr[4];
     struct addrinfo hints, *res = NULL, *resNew = NULL, *last = NULL,
         *iterator;
 
@@ -134,57 +79,6 @@
     hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE);
     CHECK_NULL_RETURN(hostname, NULL);
 
-    /*
-     * The NT/2000 resolver tolerates a space in front of localhost. This
-     * is not consistent with other implementations of gethostbyname.
-     * In addition we must do a white space check on Solaris to avoid a
-     * bug whereby 0.0.0.0 is returned if any host name has a white space.
-     */
-    if (isspace(hostname[0])) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", hostname);
-        goto cleanupAndReturn;
-    }
-
-    /*
-     * If the format is x.x.x.x then don't use gethostbyname as Windows
-     * is unable to handle octets which are out of range.
-     */
-    if (isDottedIPAddress(hostname, &addr[0])) {
-        unsigned int address;
-        jobject iaObj;
-
-        /*
-         * Are any of the octets out of range?
-         */
-        if (addr[0] > 255 || addr[1] > 255 || addr[2] > 255 || addr[3] > 255) {
-            JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", hostname);
-            goto cleanupAndReturn;
-        }
-
-        /*
-         * Return an byte array with the populated address.
-         */
-        address = (addr[3] << 24) & 0xff000000;
-        address |= (addr[2] << 16) & 0xff0000;
-        address |= (addr[1] << 8) & 0xff00;
-        address |= addr[0];
-
-        ret = (*env)->NewObjectArray(env, 1, ia_class, NULL);
-
-        if (IS_NULL(ret)) {
-            goto cleanupAndReturn;
-        }
-
-        iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
-        if (IS_NULL(iaObj)) {
-            ret = NULL;
-            goto cleanupAndReturn;
-        }
-        setInetAddress_addr(env, iaObj, ntohl(address));
-        (*env)->SetObjectArrayElement(env, ret, 0, iaObj);
-        goto cleanupAndReturn;
-    }
-
     // try once, with our static buffer
     memset(&hints, 0, sizeof(hints));
     hints.ai_flags = AI_CANONNAME;
@@ -193,6 +87,7 @@
     error = getaddrinfo(hostname, NULL, &hints, &res);
 
     if (error) {
+        // report error
         NET_ThrowByNameWithLastError(env, "java/net/UnknownHostException",
                                      hostname);
         goto cleanupAndReturn;
@@ -311,145 +206,86 @@
     return ret;
 }
 
+/**
+ * ping implementation using tcp port 7 (echo)
+ */
 static jboolean
-tcp_ping4(JNIEnv *env,
-          jbyteArray addrArray,
-          jint timeout,
-          jbyteArray ifArray,
+tcp_ping4(JNIEnv *env, SOCKETADDRESS *sa, SOCKETADDRESS *netif, jint timeout,
           jint ttl)
 {
-    jint addr;
-    jbyte caddr[4];
     jint fd;
-    struct sockaddr_in him;
-    struct sockaddr_in* netif = NULL;
-    struct sockaddr_in inf;
-    int len = 0;
-    WSAEVENT hEvent;
     int connect_rv = -1;
-    int sz;
+    WSAEVENT hEvent;
 
-    /**
-     * Convert IP address from byte array to integer
-     */
-    sz = (*env)->GetArrayLength(env, addrArray);
-    if (sz != 4) {
-        return JNI_FALSE;
-    }
-    memset((char *) &him, 0, sizeof(him));
-    memset((char *) caddr, 0, sizeof(caddr));
-    (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr);
-    addr = ((caddr[0]<<24) & 0xff000000);
-    addr |= ((caddr[1] <<16) & 0xff0000);
-    addr |= ((caddr[2] <<8) & 0xff00);
-    addr |= (caddr[3] & 0xff);
-    addr = htonl(addr);
-    /**
-     * Socket address
-     */
-    him.sin_addr.s_addr = addr;
-    him.sin_family = AF_INET;
-    len = sizeof(him);
-
-    /**
-     * If a network interface was specified, let's convert its address
-     * as well.
-     */
-    if (!(IS_NULL(ifArray))) {
-        memset((char *) caddr, 0, sizeof(caddr));
-        (*env)->GetByteArrayRegion(env, ifArray, 0, 4, caddr);
-        addr = ((caddr[0]<<24) & 0xff000000);
-        addr |= ((caddr[1] <<16) & 0xff0000);
-        addr |= ((caddr[2] <<8) & 0xff00);
-        addr |= (caddr[3] & 0xff);
-        addr = htonl(addr);
-        inf.sin_addr.s_addr = addr;
-        inf.sin_family = AF_INET;
-        inf.sin_port = 0;
-        netif = &inf;
-    }
-
-    /*
-     * Can't create a raw socket, so let's try a TCP socket
-     */
+    // open a TCP socket
     fd = NET_Socket(AF_INET, SOCK_STREAM, 0);
-    if (fd == -1) {
-        /* note: if you run out of fds, you may not be able to load
-         * the exception class, and get a NoClassDefFoundError
-         * instead.
-         */
+    if (fd == SOCKET_ERROR) {
+        // note: if you run out of fds, you may not be able to load
+        // the exception class, and get a NoClassDefFoundError instead.
         NET_ThrowNew(env, WSAGetLastError(), "Can't create socket");
         return JNI_FALSE;
     }
+
+    // set TTL
     if (ttl > 0) {
         setsockopt(fd, IPPROTO_IP, IP_TTL, (const char *)&ttl, sizeof(ttl));
     }
-    /*
-     * A network interface was specified, so let's bind to it.
-     */
+
+    // A network interface was specified, so let's bind to it.
     if (netif != NULL) {
-        if (bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in)) < 0) {
+        if (bind(fd, &netif->sa, sizeof(struct sockaddr_in)) < 0) {
             NET_ThrowNew(env, WSAGetLastError(), "Can't bind socket");
             closesocket(fd);
             return JNI_FALSE;
         }
     }
 
-    /*
-     * Make the socket non blocking so we can use select/poll.
-     */
+    // Make the socket non blocking so we can use select/poll.
     hEvent = WSACreateEvent();
     WSAEventSelect(fd, hEvent, FD_READ|FD_CONNECT|FD_CLOSE);
 
-    /* no need to use NET_Connect as non-blocking */
-    him.sin_port = htons(7);    /* Echo */
-    connect_rv = connect(fd, (struct sockaddr *)&him, len);
+    sa->sa4.sin_port = htons(7); // echo port
+    connect_rv = connect(fd, &sa->sa, sizeof(struct sockaddr_in));
 
-    /**
-     * connection established or refused immediately, either way it means
-     * we were able to reach the host!
-     */
+    // connection established or refused immediately, either way it means
+    // we were able to reach the host!
     if (connect_rv == 0 || WSAGetLastError() == WSAECONNREFUSED) {
         WSACloseEvent(hEvent);
         closesocket(fd);
         return JNI_TRUE;
-    } else {
-        int optlen;
+    }
 
-        switch (WSAGetLastError()) {
-        case WSAEHOSTUNREACH:   /* Host Unreachable */
-        case WSAENETUNREACH:    /* Network Unreachable */
-        case WSAENETDOWN:       /* Network is down */
-        case WSAEPFNOSUPPORT:   /* Protocol Family unsupported */
+    switch (WSAGetLastError()) {
+    case WSAEHOSTUNREACH:   // Host Unreachable
+    case WSAENETUNREACH:    // Network Unreachable
+    case WSAENETDOWN:       // Network is down
+    case WSAEPFNOSUPPORT:   // Protocol Family unsupported
+        WSACloseEvent(hEvent);
+        closesocket(fd);
+        return JNI_FALSE;
+    case WSAEWOULDBLOCK:    // this is expected as we'll probably have to wait
+        break;
+    default:
+        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
+                                     "connect failed");
+        WSACloseEvent(hEvent);
+        closesocket(fd);
+        return JNI_FALSE;
+    }
+
+    timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout);
+    if (timeout >= 0) {
+        // connection has been established, check for error condition
+        int optlen = sizeof(connect_rv);
+        if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&connect_rv,
+                       &optlen) < 0)
+        {
+            connect_rv = WSAGetLastError();
+        }
+        if (connect_rv == 0 || connect_rv == WSAECONNREFUSED) {
             WSACloseEvent(hEvent);
             closesocket(fd);
-            return JNI_FALSE;
-        }
-
-        if (WSAGetLastError() != WSAEWOULDBLOCK) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
-                                         "connect failed");
-            WSACloseEvent(hEvent);
-            closesocket(fd);
-            return JNI_FALSE;
-        }
-
-        timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout);
-
-        /* has connection been established */
-
-        if (timeout >= 0) {
-            optlen = sizeof(connect_rv);
-            if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
-                           &optlen) <0) {
-                connect_rv = WSAGetLastError();
-            }
-
-            if (connect_rv == 0 || connect_rv == WSAECONNREFUSED) {
-                WSACloseEvent(hEvent);
-                closesocket(fd);
-                return JNI_TRUE;
-            }
+            return JNI_TRUE;
         }
     }
     WSACloseEvent(hEvent);
@@ -464,21 +300,17 @@
  * Returns true is an ECHO_REPLY is received, otherwise, false.
  */
 static jboolean
-ping4(JNIEnv *env,
-      unsigned long src_addr,
-      unsigned long dest_addr,
-      jint timeout,
-      HANDLE hIcmpFile)
+ping4(JNIEnv *env, HANDLE hIcmpFile, SOCKETADDRESS *sa,
+      SOCKETADDRESS *netif, jint timeout)
 {
-    // See https://msdn.microsoft.com/en-us/library/aa366050%28VS.85%29.aspx
-
     DWORD dwRetVal = 0;
     char SendData[32] = {0};
     LPVOID ReplyBuffer = NULL;
     DWORD ReplySize = 0;
     jboolean ret = JNI_FALSE;
 
-    // https://msdn.microsoft.com/en-us/library/windows/desktop/aa366051%28v=vs.85%29.aspx
+    // See https://msdn.microsoft.com/en-us/library/aa366050%28VS.85%29.aspx
+    // or https://msdn.microsoft.com/en-us/library/windows/desktop/aa366051%28v=vs.85%29.aspx
     ReplySize = sizeof(ICMP_ECHO_REPLY)   // The buffer should be large enough
                                           // to hold at least one ICMP_ECHO_REPLY
                                           // structure
@@ -487,16 +319,16 @@
                                           // to also hold 8 more bytes of data
                                           // (the size of an ICMP error message)
 
-    ReplyBuffer = (VOID*) malloc(ReplySize);
+    ReplyBuffer = (VOID *)malloc(ReplySize);
     if (ReplyBuffer == NULL) {
         IcmpCloseHandle(hIcmpFile);
         NET_ThrowNew(env, WSAGetLastError(), "Unable to allocate memory");
         return JNI_FALSE;
     }
 
-    if (src_addr == 0) {
+    if (netif == NULL) {
         dwRetVal = IcmpSendEcho(hIcmpFile,  // HANDLE IcmpHandle,
-                                dest_addr,  // IPAddr DestinationAddress,
+                                sa->sa4.sin_addr.s_addr, // IPAddr DestinationAddress,
                                 SendData,   // LPVOID RequestData,
                                 sizeof(SendData),   // WORD RequestSize,
                                 NULL,       // PIP_OPTION_INFORMATION RequestOptions,
@@ -506,20 +338,20 @@
                                 // seem to have an undocumented minimum
                                 // timeout of 1000ms below which the
                                 // api behaves inconsistently.
-                                (timeout < 1000) ? 1000 : timeout);   // DWORD Timeout
+                                (timeout < 1000) ? 1000 : timeout); // DWORD Timeout
     } else {
         dwRetVal = IcmpSendEcho2Ex(hIcmpFile,  // HANDLE IcmpHandle,
                                    NULL,       // HANDLE Event
                                    NULL,       // PIO_APC_ROUTINE ApcRoutine
                                    NULL,       // ApcContext
-                                   src_addr,   // IPAddr SourceAddress,
-                                   dest_addr,  // IPAddr DestinationAddress,
+                                   netif->sa4.sin_addr.s_addr, // IPAddr SourceAddress,
+                                   sa->sa4.sin_addr.s_addr, // IPAddr DestinationAddress,
                                    SendData,   // LPVOID RequestData,
-                                   sizeof(SendData),   // WORD RequestSize,
+                                   sizeof(SendData), // WORD RequestSize,
                                    NULL,       // PIP_OPTION_INFORMATION RequestOptions,
                                    ReplyBuffer,// LPVOID ReplyBuffer,
                                    ReplySize,  // DWORD ReplySize,
-                                   (timeout < 1000) ? 1000 : timeout);   // DWORD Timeout
+                                   (timeout < 1000) ? 1000 : timeout); // DWORD Timeout
     }
 
     if (dwRetVal == 0) { // if the call failed
@@ -544,8 +376,8 @@
                 break;
             default:
                 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
-                        NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                        (LPTSTR)&buf, 0, NULL);
+                              NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+                              (LPTSTR)&buf, 0, NULL);
                 NET_ThrowNew(env, err, buf);
                 LocalFree(buf);
                 break;
@@ -558,8 +390,8 @@
         // We perform an extra check to make sure that our
         // roundtrip time was less than our desired timeout
         // for cases where that timeout is < 1000ms.
-        if (pEchoReply->Status == IP_SUCCESS
-                && (int)pEchoReply->RoundTripTime <= timeout)
+        if (pEchoReply->Status == IP_SUCCESS &&
+            (int)pEchoReply->RoundTripTime <= timeout)
         {
             ret = JNI_TRUE;
         }
@@ -578,57 +410,58 @@
  */
 JNIEXPORT jboolean JNICALL
 Java_java_net_Inet4AddressImpl_isReachable0(JNIEnv *env, jobject this,
-                                           jbyteArray addrArray,
-                                           jint timeout,
-                                           jbyteArray ifArray,
-                                           jint ttl) {
-    jint src_addr = 0;
-    jint dest_addr = 0;
+                                            jbyteArray addrArray, jint timeout,
+                                            jbyteArray ifArray, jint ttl)
+{
     jbyte caddr[4];
-    int sz;
+    jint addr = 0, sz;
+    SOCKETADDRESS sa, inf, *netif = NULL;
     HANDLE hIcmpFile;
 
-    /**
-     * Convert IP address from byte array to integer
-     */
+    // check if address array size is 4 (IPv4 address)
     sz = (*env)->GetArrayLength(env, addrArray);
     if (sz != 4) {
       return JNI_FALSE;
     }
-    memset((char *) caddr, 0, sizeof(caddr));
-    (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr);
-    dest_addr = ((caddr[0]<<24) & 0xff000000);
-    dest_addr |= ((caddr[1] <<16) & 0xff0000);
-    dest_addr |= ((caddr[2] <<8) & 0xff00);
-    dest_addr |= (caddr[3] & 0xff);
-    dest_addr = htonl(dest_addr);
 
-    /**
-     * If a network interface was specified, let's convert its address
-     * as well.
-     */
+    // convert IP address from byte array to integer
+    memset((char *)caddr, 0, sizeof(caddr));
+    (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr);
+    addr = ((caddr[0] << 24) & 0xff000000);
+    addr |= ((caddr[1] << 16) & 0xff0000);
+    addr |= ((caddr[2] << 8) & 0xff00);
+    addr |= (caddr[3] & 0xff);
+    memset((char *)&sa, 0, sizeof(SOCKETADDRESS));
+    sa.sa4.sin_addr.s_addr = htonl(addr);
+    sa.sa4.sin_family = AF_INET;
+
+    // If a network interface was specified, let's convert its address as well.
     if (!(IS_NULL(ifArray))) {
-        memset((char *) caddr, 0, sizeof(caddr));
+        memset((char *)caddr, 0, sizeof(caddr));
         (*env)->GetByteArrayRegion(env, ifArray, 0, 4, caddr);
-        src_addr = ((caddr[0]<<24) & 0xff000000);
-        src_addr |= ((caddr[1] <<16) & 0xff0000);
-        src_addr |= ((caddr[2] <<8) & 0xff00);
-        src_addr |= (caddr[3] & 0xff);
-        src_addr = htonl(src_addr);
+        addr = ((caddr[0] << 24) & 0xff000000);
+        addr |= ((caddr[1] << 16) & 0xff0000);
+        addr |= ((caddr[2] << 8) & 0xff00);
+        addr |= (caddr[3] & 0xff);
+        memset((char *)&inf, 0, sizeof(SOCKETADDRESS));
+        inf.sa4.sin_addr.s_addr = htonl(addr);
+        inf.sa4.sin_family = AF_INET;
+        netif = &inf;
     }
 
+    // Let's try to create an ICMP handle.
     hIcmpFile = IcmpCreateFile();
     if (hIcmpFile == INVALID_HANDLE_VALUE) {
         int err = WSAGetLastError();
         if (err == ERROR_ACCESS_DENIED) {
             // fall back to TCP echo if access is denied to ICMP
-            return tcp_ping4(env, addrArray, timeout, ifArray, ttl);
+            return tcp_ping4(env, &sa, netif, timeout, ttl);
         } else {
             NET_ThrowNew(env, err, "Unable to create ICMP file handle");
             return JNI_FALSE;
         }
     } else {
-        return ping4(env, src_addr, dest_addr, timeout, hIcmpFile);
+        // It didn't fail, so we can use ICMP.
+        return ping4(env, hIcmpFile, &sa, netif, timeout);
     }
 }
-
diff --git a/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c b/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c
index e07f8a3..0b3fdb8 100644
--- a/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c
+++ b/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c
@@ -40,41 +40,40 @@
  * Signature: ()Ljava/lang/String;
  */
 JNIEXPORT jstring JNICALL
-Java_java_net_Inet6AddressImpl_getLocalHostName (JNIEnv *env, jobject this) {
-    char hostname [256];
+Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) {
+    char hostname[256];
 
-    if (gethostname (hostname, sizeof (hostname)) == -1) {
-        strcpy (hostname, "localhost");
+    if (gethostname(hostname, sizeof(hostname)) == -1) {
+        strcpy(hostname, "localhost");
     }
-    return JNU_NewStringPlatform (env, hostname);
+    return JNU_NewStringPlatform(env, hostname);
 }
 
+/*
+ * Class:     java_net_Inet6AddressImpl
+ * Method:    lookupAllHostAddr
+ * Signature: (Ljava/lang/String;)[[B
+ */
 JNIEXPORT jobjectArray JNICALL
 Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this,
-                                                jstring host) {
+                                                 jstring host) {
+    jobjectArray ret = NULL;
     const char *hostname;
-    jobjectArray ret = 0;
-    int retLen = 0;
-    jboolean preferIPv6Address;
-
-    int error=0;
-    struct addrinfo hints, *res = NULL, *resNew = NULL;
+    int error = 0;
+    struct addrinfo hints, *res = NULL, *resNew = NULL, *last = NULL,
+        *iterator;
 
     initInetAddressIDs(env);
     JNU_CHECK_EXCEPTION_RETURN(env, NULL);
 
     if (IS_NULL(host)) {
-        JNU_ThrowNullPointerException(env, "host is null");
-        return 0;
+        JNU_ThrowNullPointerException(env, "host argument is null");
+        return NULL;
     }
     hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE);
     CHECK_NULL_RETURN(hostname, NULL);
 
-    /* get the address preference */
-    preferIPv6Address
-        = (*env)->GetStaticIntField(env, ia_class, ia_preferIPv6AddressID);
-
-    /* Try once, with our static buffer. */
+    // try once, with our static buffer
     memset(&hints, 0, sizeof(hints));
     hints.ai_flags = AI_CANONNAME;
     hints.ai_family = AF_UNSPEC;
@@ -82,35 +81,28 @@
     error = getaddrinfo(hostname, NULL, &hints, &res);
 
     if (error) {
-        if (WSAGetLastError() == WSATRY_AGAIN) {
-            NET_ThrowByNameWithLastError(env,
-                                         JNU_JAVANETPKG "UnknownHostException",
-                                         hostname);
-            JNU_ReleaseStringPlatformChars(env, host, hostname);
-            return NULL;
-        } else {
-            /* report error */
-            JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
-                            (char *)hostname);
-            JNU_ReleaseStringPlatformChars(env, host, hostname);
-            return NULL;
-        }
+        // report error
+        NET_ThrowByNameWithLastError(env, "java/net/UnknownHostException",
+                                     hostname);
+        goto cleanupAndReturn;
     } else {
-        int i = 0;
-        int inetCount = 0, inet6Count = 0, inetIndex = 0, inet6Index = 0, originalIndex = 0;
-        struct addrinfo *itr, *last, *iterator = res;
+        int i = 0, inetCount = 0, inet6Count = 0, inetIndex = 0,
+            inet6Index = 0, originalIndex = 0;
+        int addressPreference =
+            (*env)->GetStaticIntField(env, ia_class, ia_preferIPv6AddressID);
+        iterator = res;
         while (iterator != NULL) {
+            // skip duplicates
             int skip = 0;
-            itr = resNew;
-            while (itr != NULL) {
-                if (iterator->ai_family == itr->ai_family &&
-                    iterator->ai_addrlen == itr->ai_addrlen) {
-                    if (itr->ai_family == AF_INET) { /* AF_INET */
+            struct addrinfo *iteratorNew = resNew;
+            while (iteratorNew != NULL) {
+                if (iterator->ai_family == iteratorNew->ai_family &&
+                    iterator->ai_addrlen == iteratorNew->ai_addrlen) {
+                    if (iteratorNew->ai_family == AF_INET) { /* AF_INET */
                         struct sockaddr_in *addr1, *addr2;
                         addr1 = (struct sockaddr_in *)iterator->ai_addr;
-                        addr2 = (struct sockaddr_in *)itr->ai_addr;
-                        if (addr1->sin_addr.s_addr ==
-                            addr2->sin_addr.s_addr) {
+                        addr2 = (struct sockaddr_in *)iteratorNew->ai_addr;
+                        if (addr1->sin_addr.s_addr == addr2->sin_addr.s_addr) {
                             skip = 1;
                             break;
                         }
@@ -118,7 +110,7 @@
                         int t;
                         struct sockaddr_in6 *addr1, *addr2;
                         addr1 = (struct sockaddr_in6 *)iterator->ai_addr;
-                        addr2 = (struct sockaddr_in6 *)itr->ai_addr;
+                        addr2 = (struct sockaddr_in6 *)iteratorNew->ai_addr;
 
                         for (t = 0; t < 16; t++) {
                             if (addr1->sin6_addr.s6_addr[t] !=
@@ -127,7 +119,7 @@
                             }
                         }
                         if (t < 16) {
-                            itr = itr->ai_next;
+                            iteratorNew = iteratorNew->ai_next;
                             continue;
                         } else {
                             skip = 1;
@@ -136,16 +128,16 @@
                     }
                 } else if (iterator->ai_family != AF_INET &&
                            iterator->ai_family != AF_INET6) {
-                    /* we can't handle other family types */
+                    // we can't handle other family types
                     skip = 1;
                     break;
                 }
-                itr = itr->ai_next;
+                iteratorNew = iteratorNew->ai_next;
             }
 
             if (!skip) {
                 struct addrinfo *next
-                    = (struct addrinfo*) malloc(sizeof(struct addrinfo));
+                    = (struct addrinfo *)malloc(sizeof(struct addrinfo));
                 if (!next) {
                     JNU_ThrowOutOfMemoryError(env, "Native heap allocation failed");
                     ret = NULL;
@@ -161,87 +153,81 @@
                 last = next;
                 i++;
                 if (iterator->ai_family == AF_INET) {
-                    inetCount ++;
+                    inetCount++;
                 } else if (iterator->ai_family == AF_INET6) {
-                    inet6Count ++;
+                    inet6Count++;
                 }
             }
             iterator = iterator->ai_next;
         }
-        retLen = i;
-        iterator = resNew;
-        i = 0;
-        ret = (*env)->NewObjectArray(env, retLen, ia_class, NULL);
 
+        // allocate array - at this point i contains the number of addresses
+        ret = (*env)->NewObjectArray(env, i, ia_class, NULL);
         if (IS_NULL(ret)) {
             /* we may have memory to free at the end of this */
             goto cleanupAndReturn;
         }
 
-        if (preferIPv6Address == java_net_InetAddress_PREFER_IPV6_VALUE) {
+        if (addressPreference == java_net_InetAddress_PREFER_IPV6_VALUE) {
             inetIndex = inet6Count;
             inet6Index = 0;
-        } else if (preferIPv6Address == java_net_InetAddress_PREFER_IPV4_VALUE) {
+        } else if (addressPreference == java_net_InetAddress_PREFER_IPV4_VALUE) {
             inetIndex = 0;
             inet6Index = inetCount;
-        } else if (preferIPv6Address == java_net_InetAddress_PREFER_SYSTEM_VALUE) {
+        } else if (addressPreference == java_net_InetAddress_PREFER_SYSTEM_VALUE) {
             inetIndex = inet6Index = originalIndex = 0;
         }
 
+        iterator = resNew;
         while (iterator != NULL) {
             if (iterator->ai_family == AF_INET) {
-              jobject iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
-              if (IS_NULL(iaObj)) {
-                ret = NULL;
-                goto cleanupAndReturn;
-              }
-              setInetAddress_addr(env, iaObj, ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
-              setInetAddress_hostName(env, iaObj, host);
-              (*env)->SetObjectArrayElement(env, ret, (inetIndex | originalIndex), iaObj);
-              inetIndex ++;
+                jobject iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID);
+                if (IS_NULL(iaObj)) {
+                    ret = NULL;
+                    goto cleanupAndReturn;
+                }
+                setInetAddress_addr(env, iaObj, ntohl(((struct sockaddr_in*)iterator->ai_addr)->sin_addr.s_addr));
+                setInetAddress_hostName(env, iaObj, host);
+                (*env)->SetObjectArrayElement(env, ret, (inetIndex | originalIndex), iaObj);
+                inetIndex++;
             } else if (iterator->ai_family == AF_INET6) {
-              jint scope = 0;
-              jboolean ret1;
-              jobject iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
-              if (IS_NULL(iaObj)) {
-                ret = NULL;
-                goto cleanupAndReturn;
-              }
-              ret1 = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr));
-              if (ret1 == JNI_FALSE) {
-                ret = NULL;
-                goto cleanupAndReturn;
-              }
-              scope = ((struct sockaddr_in6*)iterator->ai_addr)->sin6_scope_id;
-              if (scope != 0) { /* zero is default value, no need to set */
-                setInet6Address_scopeid(env, iaObj, scope);
-              }
-              setInetAddress_hostName(env, iaObj, host);
-              (*env)->SetObjectArrayElement(env, ret, (inet6Index | originalIndex), iaObj);
-              inet6Index ++;
+                jint scope = 0;
+                jboolean ret1;
+                jobject iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID);
+                if (IS_NULL(iaObj)) {
+                    ret = NULL;
+                    goto cleanupAndReturn;
+                }
+                ret1 = setInet6Address_ipaddress(env, iaObj, (char *)&(((struct sockaddr_in6*)iterator->ai_addr)->sin6_addr));
+                if (ret1 == JNI_FALSE) {
+                    ret = NULL;
+                    goto cleanupAndReturn;
+                }
+                scope = ((struct sockaddr_in6 *)iterator->ai_addr)->sin6_scope_id;
+                if (scope != 0) { // zero is default value, no need to set
+                    setInet6Address_scopeid(env, iaObj, scope);
+                }
+                setInetAddress_hostName(env, iaObj, host);
+                (*env)->SetObjectArrayElement(env, ret, (inet6Index | originalIndex), iaObj);
+                inet6Index++;
             }
-            if (preferIPv6Address == java_net_InetAddress_PREFER_SYSTEM_VALUE) {
+            if (addressPreference == java_net_InetAddress_PREFER_SYSTEM_VALUE) {
                 originalIndex++;
                 inetIndex = inet6Index = 0;
             }
             iterator = iterator->ai_next;
         }
     }
-
 cleanupAndReturn:
-    {
-        struct addrinfo *iterator, *tmp;
-        iterator = resNew;
-        while (iterator != NULL) {
-            tmp = iterator;
-            iterator = iterator->ai_next;
-            free(tmp);
-        }
-        JNU_ReleaseStringPlatformChars(env, host, hostname);
+    JNU_ReleaseStringPlatformChars(env, host, hostname);
+    while (resNew != NULL) {
+        last = resNew;
+        resNew = resNew->ai_next;
+        free(last);
     }
-
-    freeaddrinfo(res);
-
+    if (res != NULL) {
+        freeaddrinfo(res);
+    }
     return ret;
 }
 
@@ -249,57 +235,48 @@
  * Class:     java_net_Inet6AddressImpl
  * Method:    getHostByAddr
  * Signature: (I)Ljava/lang/String;
+ *
+ * Theoretically the UnknownHostException could be enriched with gai error
+ * information. But as it is silently ignored anyway, there's no need for this.
+ * It's only important that either a valid hostname is returned or an
+ * UnknownHostException is thrown.
  */
 JNIEXPORT jstring JNICALL
 Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this,
-                                            jbyteArray addrArray) {
+                                             jbyteArray addrArray) {
     jstring ret = NULL;
-
-    char host[NI_MAXHOST+1];
-    int error = 0;
+    char host[NI_MAXHOST + 1];
     int len = 0;
     jbyte caddr[16];
+    SOCKETADDRESS sa;
 
-    struct sockaddr_in him4;
-    struct sockaddr_in6 him6;
-    struct sockaddr *sa;
+    memset((void *)&sa, 0, sizeof(SOCKETADDRESS));
 
-    /*
-     * For IPv4 addresses construct a sockaddr_in structure.
-     */
+    // construct a sockaddr_in structure (AF_INET or AF_INET6)
     if ((*env)->GetArrayLength(env, addrArray) == 4) {
         jint addr;
         (*env)->GetByteArrayRegion(env, addrArray, 0, 4, caddr);
-        addr = ((caddr[0]<<24) & 0xff000000);
-        addr |= ((caddr[1] <<16) & 0xff0000);
-        addr |= ((caddr[2] <<8) & 0xff00);
+        addr = ((caddr[0] << 24) & 0xff000000);
+        addr |= ((caddr[1] << 16) & 0xff0000);
+        addr |= ((caddr[2] << 8) & 0xff00);
         addr |= (caddr[3] & 0xff);
-        memset((char *) &him4, 0, sizeof(him4));
-        him4.sin_addr.s_addr = htonl(addr);
-        him4.sin_family = AF_INET;
-        sa = (struct sockaddr *) &him4;
-        len = sizeof(him4);
+        sa.sa4.sin_addr.s_addr = htonl(addr);
+        sa.sa4.sin_family = AF_INET;
+        len = sizeof(struct sockaddr_in);
     } else {
-        /*
-         * For IPv6 address construct a sockaddr_in6 structure.
-         */
         (*env)->GetByteArrayRegion(env, addrArray, 0, 16, caddr);
-        memset((char *) &him6, 0, sizeof(him6));
-        memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr) );
-        him6.sin6_family = AF_INET6;
-        sa = (struct sockaddr *) &him6 ;
-        len = sizeof(him6) ;
+        memcpy((void *)&sa.sa6.sin6_addr, caddr, sizeof(struct in6_addr));
+        sa.sa6.sin6_family = AF_INET6;
+        len = sizeof(struct sockaddr_in6);
     }
 
-    error = getnameinfo(sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD);
-
-    if (!error) {
+    if (getnameinfo(&sa.sa, len, host, NI_MAXHOST, NULL, 0, NI_NAMEREQD)) {
+        JNU_ThrowByName(env, "java/net/UnknownHostException", NULL);
+    } else {
         ret = (*env)->NewStringUTF(env, host);
-        CHECK_NULL_RETURN(ret, NULL);
-    }
-
-    if (ret == NULL) {
-        JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException", NULL);
+        if (ret == NULL) {
+            JNU_ThrowByName(env, "java/net/UnknownHostException", NULL);
+        }
     }
 
     return ret;
@@ -309,99 +286,82 @@
  * ping implementation using tcp port 7 (echo)
  */
 static jboolean
-tcp_ping6(JNIEnv *env,
-          jint timeout,
-          jint ttl,
-          struct sockaddr_in6 him6,
-          struct sockaddr_in6* netif,
-          int len)
+tcp_ping6(JNIEnv *env, SOCKETADDRESS *sa, SOCKETADDRESS *netif, jint timeout,
+          jint ttl)
 {
     jint fd;
-    WSAEVENT hEvent;
     int connect_rv = -1;
+    WSAEVENT hEvent;
 
+    // open a TCP socket
     fd = NET_Socket(AF_INET6, SOCK_STREAM, 0);
     if (fd == SOCKET_ERROR) {
-        /* note: if you run out of fds, you may not be able to load
-         * the exception class, and get a NoClassDefFoundError
-         * instead.
-         */
-        NET_ThrowNew(env, errno, "Can't create socket");
+        // note: if you run out of fds, you may not be able to load
+        // the exception class, and get a NoClassDefFoundError instead.
+        NET_ThrowNew(env, WSAGetLastError(), "Can't create socket");
         return JNI_FALSE;
     }
 
-    /**
-     * A TTL was specified, let's set the socket option.
-     */
+    // set TTL
     if (ttl > 0) {
-      setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, (const char *)&ttl, sizeof(ttl));
+        setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, (const char *)&ttl, sizeof(ttl));
     }
 
-    /**
-     * A network interface was specified, let's bind to it.
-     */
+    // A network interface was specified, so let's bind to it.
     if (netif != NULL) {
-      if (NET_Bind(fd, (struct sockaddr*)netif, sizeof(struct sockaddr_in6)) < 0) {
-        NET_ThrowNew(env, WSAGetLastError(), "Can't bind socket to interface");
-        closesocket(fd);
-        return JNI_FALSE;
-      }
+        if (bind(fd, &netif->sa, sizeof(struct sockaddr_in6)) < 0) {
+            NET_ThrowNew(env, WSAGetLastError(), "Can't bind socket to interface");
+            closesocket(fd);
+            return JNI_FALSE;
+        }
     }
 
-    /**
-     * Make the socket non blocking.
-     */
+    // Make the socket non blocking so we can use select/poll.
     hEvent = WSACreateEvent();
     WSAEventSelect(fd, hEvent, FD_READ|FD_CONNECT|FD_CLOSE);
 
-    /* no need to use NET_Connect as non-blocking */
-    him6.sin6_port = htons((short) 7); /* Echo port */
-    connect_rv = connect(fd, (struct sockaddr *)&him6, len);
+    sa->sa6.sin6_port = htons(7); // echo port
+    connect_rv = connect(fd, &sa->sa, sizeof(struct sockaddr_in6));
 
-    /**
-     * connection established or refused immediately, either way it means
-     * we were able to reach the host!
-     */
+    // connection established or refused immediately, either way it means
+    // we were able to reach the host!
     if (connect_rv == 0 || WSAGetLastError() == WSAECONNREFUSED) {
         WSACloseEvent(hEvent);
         closesocket(fd);
         return JNI_TRUE;
-    } else {
-        int optlen;
+    }
 
-        switch (WSAGetLastError()) {
-        case WSAEHOSTUNREACH:   /* Host Unreachable */
-        case WSAENETUNREACH:    /* Network Unreachable */
-        case WSAENETDOWN:       /* Network is down */
-        case WSAEPFNOSUPPORT:   /* Protocol Family unsupported */
-          WSACloseEvent(hEvent);
-          closesocket(fd);
-          return JNI_FALSE;
-        }
+    switch (WSAGetLastError()) {
+    case WSAEHOSTUNREACH:   // Host Unreachable
+    case WSAENETUNREACH:    // Network Unreachable
+    case WSAENETDOWN:       // Network is down
+    case WSAEPFNOSUPPORT:   // Protocol Family unsupported
+        WSACloseEvent(hEvent);
+        closesocket(fd);
+        return JNI_FALSE;
+    case WSAEWOULDBLOCK:    // this is expected as we'll probably have to wait
+        break;
+    default:
+        NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
+                                     "connect failed");
+        WSACloseEvent(hEvent);
+        closesocket(fd);
+        return JNI_FALSE;
+    }
 
-        if (WSAGetLastError() != WSAEWOULDBLOCK) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
-                                         "connect failed");
-            WSACloseEvent(hEvent);
-            closesocket(fd);
-            return JNI_FALSE;
-        }
-
-        timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout);
-
-        if (timeout >= 0) {
-          /* has connection been established? */
-          optlen = sizeof(connect_rv);
-          if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)&connect_rv,
-                         &optlen) <0) {
+    timeout = NET_Wait(env, fd, NET_WAIT_CONNECT, timeout);
+    if (timeout >= 0) {
+        // connection has been established, check for error condition
+        int optlen = sizeof(connect_rv);
+        if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&connect_rv,
+                       &optlen) < 0)
+        {
             connect_rv = WSAGetLastError();
-          }
-
-          if (connect_rv == 0 || connect_rv == WSAECONNREFUSED) {
+        }
+        if (connect_rv == 0 || connect_rv == WSAECONNREFUSED) {
             WSACloseEvent(hEvent);
             closesocket(fd);
             return JNI_TRUE;
-          }
         }
     }
     WSACloseEvent(hEvent);
@@ -416,21 +376,18 @@
  * Returns true is an ECHO_REPLY is received, otherwise, false.
  */
 static jboolean
-ping6(JNIEnv *env,
-      struct sockaddr_in6* src,
-      struct sockaddr_in6* dest,
-      jint timeout,
-      HANDLE hIcmpFile)
+ping6(JNIEnv *env, HANDLE hIcmpFile, SOCKETADDRESS *sa,
+      SOCKETADDRESS *netif, jint timeout)
 {
     DWORD dwRetVal = 0;
     char SendData[32] = {0};
     LPVOID ReplyBuffer = NULL;
     DWORD ReplySize = 0;
     IP_OPTION_INFORMATION ipInfo = {255, 0, 0, 0, NULL};
-    struct sockaddr_in6 sa6Source;
+    SOCKETADDRESS dftNetif;
 
     ReplySize = sizeof(ICMPV6_ECHO_REPLY) + sizeof(SendData);
-    ReplyBuffer = (VOID*) malloc(ReplySize);
+    ReplyBuffer = (VOID *)malloc(ReplySize);
     if (ReplyBuffer == NULL) {
         IcmpCloseHandle(hIcmpFile);
         NET_ThrowNew(env, WSAGetLastError(), "Unable to allocate memory");
@@ -438,17 +395,20 @@
     }
 
     //define local source information
-    sa6Source.sin6_addr = in6addr_any;
-    sa6Source.sin6_family = AF_INET6;
-    sa6Source.sin6_flowinfo = 0;
-    sa6Source.sin6_port = 0;
+    if (netif == NULL) {
+        dftNetif.sa6.sin6_addr = in6addr_any;
+        dftNetif.sa6.sin6_family = AF_INET6;
+        dftNetif.sa6.sin6_flowinfo = 0;
+        dftNetif.sa6.sin6_port = 0;
+        netif = &dftNetif;
+    }
 
     dwRetVal = Icmp6SendEcho2(hIcmpFile,    // HANDLE IcmpHandle,
                               NULL,         // HANDLE Event,
                               NULL,         // PIO_APC_ROUTINE ApcRoutine,
                               NULL,         // PVOID ApcContext,
-                              &sa6Source,   // struct sockaddr_in6 *SourceAddress,
-                              dest,         // struct sockaddr_in6 *DestinationAddress,
+                              &netif->sa6,  // struct sockaddr_in6 *SourceAddress,
+                              &sa->sa6,     // struct sockaddr_in6 *DestinationAddress,
                               SendData,     // LPVOID RequestData,
                               sizeof(SendData), // WORD RequestSize,
                               &ipInfo,      // PIP_OPTION_INFORMATION RequestOptions,
@@ -459,11 +419,10 @@
     free(ReplyBuffer);
     IcmpCloseHandle(hIcmpFile);
 
-
-    if (dwRetVal != 0) {
-        return JNI_TRUE;
-    } else {
+    if (dwRetVal == 0) { // if the call failed
         return JNI_FALSE;
+    } else {
+        return JNI_TRUE;
     }
 }
 
@@ -474,75 +433,64 @@
  */
 JNIEXPORT jboolean JNICALL
 Java_java_net_Inet6AddressImpl_isReachable0(JNIEnv *env, jobject this,
-                                           jbyteArray addrArray,
-                                           jint scope,
-                                           jint timeout,
-                                           jbyteArray ifArray,
-                                           jint ttl, jint if_scope) {
+                                            jbyteArray addrArray, jint scope,
+                                            jint timeout, jbyteArray ifArray,
+                                            jint ttl, jint if_scope)
+{
     jbyte caddr[16];
     jint sz;
-    struct sockaddr_in6 him6;
-    struct sockaddr_in6* netif = NULL;
-    struct sockaddr_in6 inf6;
-    int len = 0;
+    SOCKETADDRESS sa, inf, *netif = NULL;
     HANDLE hIcmpFile;
 
-    /*
-     * If IPv6 is not enable, then we can't reach an IPv6 address, can we?
-     * Actually, we probably shouldn't even get here.
-     */
+    // If IPv6 is not enabled, then we can't reach an IPv6 address, can we?
+    // Actually, we probably shouldn't even get here.
     if (!ipv6_available()) {
-      return JNI_FALSE;
+        return JNI_FALSE;
     }
-    /*
-     * If it's an IPv4 address, ICMP won't work with IPv4 mapped address,
-     * therefore, let's delegate to the Inet4Address method.
-     */
+
+    // If it's an IPv4 address, ICMP won't work with IPv4 mapped address,
+    // therefore, let's delegate to the Inet4Address method.
     sz = (*env)->GetArrayLength(env, addrArray);
     if (sz == 4) {
-      return Java_java_net_Inet4AddressImpl_isReachable0(env, this,
-                                                         addrArray,
-                                                         timeout,
-                                                         ifArray, ttl);
+        return Java_java_net_Inet4AddressImpl_isReachable0(env, this,
+                                                           addrArray, timeout,
+                                                           ifArray, ttl);
     }
 
-    memset((char *) caddr, 0, 16);
-    memset((char *) &him6, 0, sizeof(him6));
+    // load address to SOCKETADDRESS
+    memset((char *)caddr, 0, 16);
     (*env)->GetByteArrayRegion(env, addrArray, 0, 16, caddr);
-    memcpy((void *)&(him6.sin6_addr), caddr, sizeof(struct in6_addr) );
-    him6.sin6_family = AF_INET6;
+    memset((char *)&sa, 0, sizeof(SOCKETADDRESS));
+    memcpy((void *)&sa.sa6.sin6_addr, caddr, sizeof(struct in6_addr));
+    sa.sa6.sin6_family = AF_INET6;
     if (scope > 0) {
-      him6.sin6_scope_id = scope;
+        sa.sa6.sin6_scope_id = scope;
     }
-    len = sizeof(struct sockaddr_in6);
 
-    /**
-     * A network interface was specified, let's convert the address
-     */
+    // load network interface address to SOCKETADDRESS, if specified
     if (!(IS_NULL(ifArray))) {
-      memset((char *) caddr, 0, 16);
-      memset((char *) &inf6, 0, sizeof(inf6));
-      (*env)->GetByteArrayRegion(env, ifArray, 0, 16, caddr);
-      memcpy((void *)&(inf6.sin6_addr), caddr, sizeof(struct in6_addr) );
-      inf6.sin6_family = AF_INET6;
-      inf6.sin6_port = 0;
-      inf6.sin6_scope_id = if_scope;
-      netif = &inf6;
+        memset((char *)caddr, 0, 16);
+        (*env)->GetByteArrayRegion(env, ifArray, 0, 16, caddr);
+        memset((char *)&inf, 0, sizeof(SOCKETADDRESS));
+        memcpy((void *)&inf.sa6.sin6_addr, caddr, sizeof(struct in6_addr));
+        inf.sa6.sin6_family = AF_INET6;
+        inf.sa6.sin6_scope_id = if_scope;
+        netif = &inf;
     }
 
+    // Let's try to create an ICMP handle.
     hIcmpFile = Icmp6CreateFile();
     if (hIcmpFile == INVALID_HANDLE_VALUE) {
         int err = WSAGetLastError();
         if (err == ERROR_ACCESS_DENIED) {
             // fall back to TCP echo if access is denied to ICMP
-            return tcp_ping6(env, timeout, ttl, him6, netif, len);
+            return tcp_ping6(env, &sa, netif, timeout, ttl);
         } else {
             NET_ThrowNew(env, err, "Unable to create ICMP file handle");
             return JNI_FALSE;
         }
     } else {
-        return ping6(env, netif, &him6, timeout, hIcmpFile);
+        // It didn't fail, so we can use ICMP.
+        return ping6(env, hIcmpFile, &sa, netif, timeout);
     }
-
-    return JNI_FALSE;
 }
diff --git a/jdk/src/java.base/windows/native/libnio/ch/Net.c b/jdk/src/java.base/windows/native/libnio/ch/Net.c
index cae8ef0..4b586d3 100644
--- a/jdk/src/java.base/windows/native/libnio/ch/Net.c
+++ b/jdk/src/java.base/windows/native/libnio/ch/Net.c
@@ -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
@@ -50,13 +50,13 @@
 
 #endif  /* MCAST_BLOCK_SOURCE */
 
-typedef struct my_ip_mreq_source {
+struct my_ip_mreq_source {
     IN_ADDR imr_multiaddr;
     IN_ADDR imr_sourceaddr;
     IN_ADDR imr_interface;
 };
 
-typedef struct my_group_source_req {
+struct my_group_source_req {
     ULONG gsr_interface;
     SOCKADDR_STORAGE gsr_group;
     SOCKADDR_STORAGE gsr_source;
diff --git a/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java b/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java
index 16eeff4..2003401 100644
--- a/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java
+++ b/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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);
         }
     }
 
diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java b/jdk/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java
index d835171..97ac9e4 100644
--- a/jdk/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java
@@ -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 liId = getListenerId(name, listener,
+                filter, handback);
+        infoList.remove(liId);
 
-        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();
-
-                infoList.remove(id);
-
-                break;
-            }
-        }
-
-        if (id == null)
-            throw new ListenerNotFoundException("Listener not found");
-
-        return id;
+        return liId;
     }
 
     public synchronized Integer[] removeNotificationListener(ObjectName name) {
diff --git a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/Config.java b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/Config.java
index c43c373..561f77f 100644
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/Config.java
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/Config.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -577,7 +577,8 @@
                         for (Path p: files) {
                             if (Files.isDirectory(p)) continue;
                             String name = p.getFileName().toString();
-                            if (name.matches("[a-zA-Z0-9_-]+")) {
+                            if (name.matches("[a-zA-Z0-9_-]+") ||
+                                    name.endsWith(".conf")) {
                                 // if dir is absolute, so is p
                                 readConfigFileLines(p, content, dups);
                             }
diff --git a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java
index c4888bf..16e99bb 100644
--- a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java
+++ b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java
@@ -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
@@ -513,7 +513,7 @@
         if (entry != null) {
             // Get end-entity certificate and remove from system cert store
             X509Certificate[] certChain = entry.getCertificateChain();
-            if (certChain != null) {
+            if (certChain != null && certChain.length > 0) {
 
                 try {
 
@@ -629,7 +629,9 @@
 
         for (Map.Entry<String,KeyEntry> mapEntry : entries.entrySet()) {
             KeyEntry entry = mapEntry.getValue();
-            if (entry.certChain != null && entry.certChain[0].equals(cert)) {
+            if (entry.certChain != null &&
+                entry.certChain.length > 0 &&
+                entry.certChain[0].equals(cert)) {
                 return entry.getAlias();
             }
         }
diff --git a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/LeftOverInputStream.java b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/LeftOverInputStream.java
index c715d72..d3a6e1b 100644
--- a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/LeftOverInputStream.java
+++ b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/LeftOverInputStream.java
@@ -41,8 +41,8 @@
  * isEOF() returns true, when all expected bytes have been read
  */
 abstract class LeftOverInputStream extends FilterInputStream {
-    ExchangeImpl t;
-    ServerImpl server;
+    final ExchangeImpl t;
+    final ServerImpl server;
     protected boolean closed = false;
     protected boolean eof = false;
     byte[] one = new byte [1];
@@ -109,6 +109,9 @@
         int bufSize = 2048;
         byte[] db = new byte [bufSize];
         while (l > 0) {
+            if (server.isFinishing()) {
+                break;
+            }
             long len = readImpl (db, 0, bufSize);
             if (len == -1) {
                 eof = true;
diff --git a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java
index e384a84..10c3539 100644
--- a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java
+++ b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java
@@ -179,6 +179,10 @@
         return httpsConfig;
     }
 
+    public final boolean isFinishing() {
+        return finished;
+    }
+
     public void stop (int delay) {
         if (delay < 0) {
             throw new IllegalArgumentException ("negative delay parameter");
diff --git a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java
index fcccd9d..b79d8c2 100644
--- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java
+++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java
@@ -264,9 +264,8 @@
     }
 
     public boolean previousSnippet() {
-        for (int i = index() - 1; i >= 0; i--) {
-            if (get(i) instanceof NarrowingHistoryLine) {
-                moveTo(i);
+        while (previous()) {
+            if (current() instanceof NarrowingHistoryLine) {
                 return true;
             }
         }
@@ -275,19 +274,17 @@
     }
 
     public boolean nextSnippet() {
-        for (int i = index() + 1; i < size(); i++) {
-            if (get(i) instanceof NarrowingHistoryLine) {
-                moveTo(i);
+        boolean success = false;
+
+        while (next()) {
+            success = true;
+
+            if (current() instanceof NarrowingHistoryLine) {
                 return true;
             }
         }
 
-        if (index() < size()) {
-            moveToEnd();
-            return true;
-        }
-
-        return false;
+        return success;
     }
 
     public final void load(Iterable<? extends String> originalHistory) {
diff --git a/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java b/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java
index a42dfe2..cb86682 100644
--- a/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java
+++ b/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java
@@ -444,6 +444,7 @@
             } else if (collator.compare(flags, "-strict") ==0) {
                 strict = true;
             } else if (collator.compare(flags, "-h") == 0 ||
+                        collator.compare(flags, "-?") == 0 ||
                         collator.compare(flags, "-help") == 0) {
                 fullusage();
             } else {
diff --git a/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java b/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java
index a77109c..c4fe1d9 100644
--- a/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java
+++ b/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java
@@ -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);
     }
 
     /**
diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt
index 16987c2..e880549 100644
--- a/jdk/test/ProblemList.txt
+++ b/jdk/test/ProblemList.txt
@@ -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
 
 ############################################################################
@@ -255,6 +258,11 @@
 tools/jimage/JImageListTest.java                                8170120 generic-all
 tools/jimage/JImageVerifyTest.java                              8170120 generic-all
 
+tools/jar/multiRelease/RuntimeTest.java                         8173905 generic-all
+
+tools/schemagen/MultiReleaseJarTest.java                        8174692 generic-all
+tools/wsgen/MultiReleaseJarTest.java                            8174692 generic-all
+
 ############################################################################
 
 # jdk_jdi
diff --git a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java
index 4a0f1d8..f2b03d7 100644
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java
+++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java
@@ -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
@@ -62,7 +62,7 @@
             ProcessBuilder pb = ProcessTools.
                 createJavaProcessBuilder(
                     "--add-exports", "jdk.attach/sun.tools.attach=ALL-UNNAMED",
-                    "-XX:+UseConcMarkSweepGC",  // this will cause UseParNewGC to be FLAG_SET_ERGO
+                    "-XX:+UseConcMarkSweepGC",  // this will cause MaxNewSize to be FLAG_SET_ERGO
                     "-XX:+UseCodeAging",
                     "-XX:+UseCerealGC",         // Should be ignored.
                     "-XX:Flags=" + flagsFile.getAbsolutePath(),
@@ -110,7 +110,7 @@
             // Set through j.l.m
             checkOrigin("HeapDumpOnOutOfMemoryError", Origin.MANAGEMENT);
             // Should be set by the VM, when we set UseConcMarkSweepGC
-            checkOrigin("UseParNewGC", Origin.ERGONOMIC);
+            checkOrigin("MaxNewSize", Origin.ERGONOMIC);
             // Set using attach
             checkOrigin("HeapDumpPath", Origin.ATTACH_ON_DEMAND);
         }
diff --git a/jdk/test/java/awt/JAWT/JAWT.sh b/jdk/test/java/awt/JAWT/JAWT.sh
index d01ff02..8432a71 100644
--- a/jdk/test/java/awt/JAWT/JAWT.sh
+++ b/jdk/test/java/awt/JAWT/JAWT.sh
@@ -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"
diff --git a/jdk/test/java/io/File/SetLastModified.java b/jdk/test/java/io/File/SetLastModified.java
index 249b7cc..1f45dd9 100644
--- a/jdk/test/java/io/File/SetLastModified.java
+++ b/jdk/test/java/io/File/SetLastModified.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, 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
@@ -22,7 +22,7 @@
  */
 
 /* @test
-   @bug 4091757 6652379
+   @bug 4091757 6652379 8177809
    @summary Basic test for setLastModified method
  */
 
diff --git a/jdk/test/java/lang/String/CompactString/SerializationTest.java b/jdk/test/java/lang/String/CompactString/SerializationTest.java
index e4c94c5..94fa9aa 100644
--- a/jdk/test/java/lang/String/CompactString/SerializationTest.java
+++ b/jdk/test/java/lang/String/CompactString/SerializationTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,13 @@
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import static jdk.testlibrary.SerializationUtils.*;
+import static jdk.test.lib.util.SerializationUtils.*;
 import static org.testng.Assert.assertEquals;
 
 /*
  * @test
  * @bug 8077559
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SerializationUtils
+ * @library /test/lib
  * @summary Tests Compact String. This one is testing String serialization
  *          among -XX:+CompactStrings/-XX:-CompactStrings/LegacyString
  * @run testng/othervm -XX:+CompactStrings SerializationTest
diff --git a/jdk/test/java/lang/StringBuffer/CompactStringBufferSerialization.java b/jdk/test/java/lang/StringBuffer/CompactStringBufferSerialization.java
index 346c824..3f721d5 100644
--- a/jdk/test/java/lang/StringBuffer/CompactStringBufferSerialization.java
+++ b/jdk/test/java/lang/StringBuffer/CompactStringBufferSerialization.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,14 +26,13 @@
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import static jdk.testlibrary.SerializationUtils.*;
+import static jdk.test.lib.util.SerializationUtils.*;
 import static org.testng.Assert.*;
 
 /*
  * @test
  * @bug 8077559
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SerializationUtils
+ * @library /test/lib
  * @summary Tests Compact String. This one is testing StringBuffer serialization
  *          among -XX:+CompactStrings/-XX:-CompactStrings/LegacyStringBuffer
  * @run testng/othervm -XX:+CompactStrings CompactStringBufferSerialization
diff --git a/jdk/test/java/lang/StringBuilder/CompactStringBuilderSerialization.java b/jdk/test/java/lang/StringBuilder/CompactStringBuilderSerialization.java
index 0c622d7..6a66e2b 100644
--- a/jdk/test/java/lang/StringBuilder/CompactStringBuilderSerialization.java
+++ b/jdk/test/java/lang/StringBuilder/CompactStringBuilderSerialization.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,14 +26,13 @@
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import static jdk.testlibrary.SerializationUtils.*;
+import static jdk.test.lib.util.SerializationUtils.*;
 import static org.testng.Assert.*;
 
 /*
  * @test
  * @bug 8077559
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SerializationUtils
+ * @library /test/lib
  * @summary Tests Compact String. This one is testing StringBuilder serialization
  *          among -XX:+CompactStrings/-XX:-CompactStrings/LegacyStringBuilder
  * @run testng/othervm -XX:+CompactStrings CompactStringBuilderSerialization
diff --git a/jdk/test/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java b/jdk/test/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java
index 3c8944e..998b1fc 100644
--- a/jdk/test/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java
+++ b/jdk/test/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java
@@ -28,17 +28,18 @@
 import java.lang.System.Logger;
 import java.lang.System.Logger.Level;
 import java.lang.System.LoggerFinder;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Locale;
+import java.util.Map;
 import java.util.Objects;
 import java.util.ResourceBundle;
-import java.util.concurrent.ConcurrentHashMap;
 // Can't use testng because testng requires java.logging
 //import org.testng.annotations.Test;
 
 /**
  * @test
- * @bug 8177835
+ * @bug 8177835 8179222
  * @summary Checks that the DefaultLoggerFinder and LoggingProviderImpl
  *          implementations of the System.LoggerFinder conform to the
  *          LoggerFinder specification, in particular with respect to
@@ -60,6 +61,8 @@
     static final String JDK_FORMAT_PROP_KEY = "jdk.system.logger.format";
     static final String JUL_FORMAT_PROP_KEY =
         "java.util.logging.SimpleFormatter.format";
+    static final String MESSAGE = "{0} with {1}: PASSED";
+    static final String LOCALIZED = "[localized] ";
 
     static class RecordStream extends OutputStream {
         static final Object LOCK = new Object[0];
@@ -106,15 +109,28 @@
     }
 
     public static class MyResourceBundle extends ResourceBundle {
-        final ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
+        final Map<String, String> map = Map.of(MESSAGE, LOCALIZED + MESSAGE);
         @Override
         protected Object handleGetObject(String string) {
-            return map.computeIfAbsent(string, s -> "[localized] " + s);
+            return map.get(string);
         }
 
         @Override
         public Enumeration<String> getKeys() {
-            return map.keys();
+            return Collections.enumeration(map.keySet());
+        }
+
+    }
+
+    public static class EmptyResourceBundle extends ResourceBundle {
+        @Override
+        protected Object handleGetObject(String string) {
+            return null;
+        }
+
+        @Override
+        public Enumeration<String> getKeys() {
+            return Collections.emptyEnumeration();
         }
 
     }
@@ -129,17 +145,23 @@
 
         LoggerFinderAPI apiTest = new LoggerFinderAPI();
         for (Object[] params : getLoggerDataProvider()) {
+            @SuppressWarnings("unchecked")
+            Class<? extends Throwable> throwableClass  =
+                    Throwable.class.getClass().cast(params[3]);
             apiTest.testGetLogger((String)params[0],
                                   (String)params[1],
                                   (Module)params[2],
-                                  Throwable.class.getClass().cast(params[3]));
+                                  throwableClass);
         }
         for (Object[] params : getLocalizedLoggerDataProvider()) {
+            @SuppressWarnings("unchecked")
+            Class<? extends Throwable> throwableClass =
+                    Throwable.class.getClass().cast(params[4]);
             apiTest.testGetLocalizedLogger((String)params[0],
                                   (String)params[1],
                                   (ResourceBundle)params[2],
                                   (Module)params[3],
-                                  Throwable.class.getClass().cast(params[4]));
+                                  throwableClass);
         }
     }
 
@@ -158,15 +180,16 @@
             // Make sure we don't fail if tests are run in parallel
             synchronized(RecordStream.LOCK) {
                 LOG_STREAM.startRecording();
+                byte[] logged = null;
                 try {
                     logger.log(Level.INFO, "{0} with {1}: PASSED",
                                "LoggerFinder.getLogger",
                                desc);
                 } finally {
-                    byte[] logged = LOG_STREAM.stopRecording();
-                    check(logged, "testGetLogger", desc, null,
-                          "LoggerFinder.getLogger");
+                    logged = LOG_STREAM.stopRecording();
                 }
+                check(logged, "testGetLogger", desc, null,
+                      "LoggerFinder.getLogger");
             }
         } catch (Throwable x) {
             if (thrown != null && thrown.isInstance(x)) {
@@ -192,15 +215,16 @@
             // Make sure we don't fail if tests are run in parallel
             synchronized(RecordStream.LOCK) {
                 LOG_STREAM.startRecording();
+                byte[] logged = null;
                 try {
-                    logger.log(Level.INFO, "{0} with {1}: PASSED",
+                    logger.log(Level.INFO, MESSAGE,
                               "LoggerFinder.getLocalizedLogger",
                               desc);
                 } finally {
-                    byte[] logged = LOG_STREAM.stopRecording();
-                    check(logged, "testGetLocalizedLogger", desc, bundle,
-                          "LoggerFinder.getLocalizedLogger");
+                   logged = LOG_STREAM.stopRecording();
                 }
+                check(logged, "testGetLocalizedLogger", desc, bundle,
+                      "LoggerFinder.getLocalizedLogger");
             }
         } catch (Throwable x) {
             if (thrown != null && thrown.isInstance(x)) {
@@ -213,9 +237,11 @@
     private void check(byte[] logged, String test, String desc,
                        ResourceBundle bundle, String meth) {
         String msg = new String(logged);
+        String localizedPrefix =
+                ((bundle==null || bundle==EMPTY_BUNDLE)?"":LOCALIZED);
         String expected = String.format(TEST_FORMAT, null,
                 "LoggerFinderAPI " + test, null, Level.INFO.name(),
-                (bundle==null?"":"[localized] ") + meth + " with " + desc + ": PASSED",
+                localizedPrefix + meth + " with " + desc + ": PASSED",
                 "");
         if (!Objects.equals(msg, expected)) {
             throw new AssertionError("Expected log message not found: "
@@ -227,6 +253,7 @@
 
     static final Module MODULE = LoggerFinderAPI.class.getModule();
     static final ResourceBundle BUNDLE = new MyResourceBundle();
+    static final ResourceBundle EMPTY_BUNDLE = new EmptyResourceBundle();
     static final Object[][] GET_LOGGER = {
         {"null name", null, MODULE , NullPointerException.class},
         {"null module", "foo", null, NullPointerException.class},
@@ -236,12 +263,15 @@
     static final Object[][] GET_LOCALIZED_LOGGER = {
         {"null name", null, BUNDLE, MODULE , NullPointerException.class},
         {"null module", "foo", BUNDLE, null, NullPointerException.class},
-        {"null name and module", null, BUNDLE, null, NullPointerException.class},
-        {"non null name and module", "foo", BUNDLE, MODULE, null},
+        {"null name and module, non null bundle", null, BUNDLE, null, NullPointerException.class},
+        {"non null name, module, and bundle", "foo", BUNDLE, MODULE, null},
         {"null name and bundle", null, null, MODULE , NullPointerException.class},
         {"null module and bundle", "foo", null, null, NullPointerException.class},
         {"null name and module and bundle", null, null, null, NullPointerException.class},
         {"non null name and module, null bundle", "foo", null, MODULE, null},
+        // tests that MissingResourceBundle is not propagated to the caller of
+        // logger.log() if the key is not found in the resource bundle
+        {"non null name, module, and empty bundle", "foo", EMPTY_BUNDLE, MODULE, null},
     };
     public static Object[][] getLoggerDataProvider() {
         return GET_LOGGER;
diff --git a/jdk/test/java/lang/Thread/ThreadStateController.java b/jdk/test/java/lang/Thread/ThreadStateController.java
index c426d1b..d644a1a 100644
--- a/jdk/test/java/lang/Thread/ThreadStateController.java
+++ b/jdk/test/java/lang/Thread/ThreadStateController.java
@@ -27,7 +27,7 @@
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.LockSupport;
 
-import jdk.testlibrary.LockFreeLogManager;
+import jdk.test.lib.LockFreeLogger;
 import jdk.testlibrary.Utils;
 
 /**
@@ -100,7 +100,7 @@
     private final AtomicInteger iterations = new AtomicInteger();
     private final AtomicInteger interrupted = new AtomicInteger();
 
-    private final LockFreeLogManager logManager = new LockFreeLogManager();
+    private final LockFreeLogger logger = new LockFreeLogger();
 
     @Override
     public void run() {
@@ -349,7 +349,7 @@
     }
 
     private void log(String msg, Object ... params) {
-        logManager.log(msg, params);
+        logger.log(msg, params);
     }
 
     /**
@@ -361,6 +361,6 @@
     public String getLog() throws InterruptedException {
         this.join();
 
-        return logManager.toString();
+        return logger.toString();
     }
 }
diff --git a/jdk/test/java/lang/Thread/ThreadStateTest.java b/jdk/test/java/lang/Thread/ThreadStateTest.java
index 843cfd7..6509e39 100644
--- a/jdk/test/java/lang/Thread/ThreadStateTest.java
+++ b/jdk/test/java/lang/Thread/ThreadStateTest.java
@@ -31,6 +31,7 @@
  *
  * @author  Mandy Chung
  * @library /lib/testlibrary
+ * @library /test/lib
  * @build jdk.testlibrary.*
  * @build ThreadStateTest ThreadStateController
  * @run main/othervm -Xmixed ThreadStateTest
diff --git a/jdk/test/java/lang/annotation/AnnotationType/AnnotationTypeRuntimeAssumptionTest.java b/jdk/test/java/lang/annotation/AnnotationType/AnnotationTypeRuntimeAssumptionTest.java
index 3258925..fc45bef 100644
--- a/jdk/test/java/lang/annotation/AnnotationType/AnnotationTypeRuntimeAssumptionTest.java
+++ b/jdk/test/java/lang/annotation/AnnotationType/AnnotationTypeRuntimeAssumptionTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, 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,8 +25,6 @@
  * @test
  * @summary Test consistent parsing of ex-RUNTIME annotations that
  *          were changed and separately compiled to have CLASS retention
- * @library /lib/testlibrary
- * @build jdk.testlibrary.IOUtils
  * @run main AnnotationTypeRuntimeAssumptionTest
  */
 
@@ -35,8 +33,6 @@
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 
-import jdk.testlibrary.IOUtils;
-
 import static java.lang.annotation.RetentionPolicy.CLASS;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
@@ -140,7 +136,7 @@
                 String altPath = altName.replace('.', '/').concat(".class");
                 try (InputStream is = getResourceAsStream(altPath)) {
                     if (is != null) {
-                        byte[] bytes = IOUtils.readFully(is);
+                        byte[] bytes = is.readAllBytes();
                         // patch class bytes to contain original name
                         for (int i = 0; i < bytes.length - 2; i++) {
                             if (bytes[i] == '_' &&
@@ -163,7 +159,7 @@
                 String path = name.replace('.', '/').concat(".class");
                 try (InputStream is = getResourceAsStream(path)) {
                     if (is != null) {
-                        byte[] bytes = IOUtils.readFully(is);
+                        byte[] bytes = is.readAllBytes();
                         return defineClass(name, bytes, 0, bytes.length);
                     }
                     else {
diff --git a/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java b/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java
index b6964c3..92036f0 100644
--- a/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java
+++ b/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java
@@ -82,9 +82,9 @@
                 throw new Error("Unexpected error: Lambda form of the method handle is null");
             }
 
-            String debugName = (String)DEBUG_NAME.get(lambdaForm);
-            if (debugName != null && debugName.startsWith("identity_")) {
-                // Ignore identity_* LambdaForms.
+            String kind = KIND_FIELD.get(lambdaForm).toString();
+            if (kind.equals("IDENTITY")) {
+                // Ignore identity LambdaForms.
                 return;
             }
 
diff --git a/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java b/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java
index 42f6aef..0bb9c49 100644
--- a/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java
+++ b/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java
@@ -51,7 +51,7 @@
      * used to get a lambda form from a method handle.
      */
     protected static final Method INTERNAL_FORM;
-    protected static final Field DEBUG_NAME;
+    protected static final Field KIND_FIELD;
     protected static final Field REF_FIELD;
     private static final List<GarbageCollectorMXBean> gcInfo;
 
@@ -64,8 +64,8 @@
             INTERNAL_FORM = MethodHandle.class.getDeclaredMethod("internalForm");
             INTERNAL_FORM.setAccessible(true);
 
-            DEBUG_NAME = Class.forName("java.lang.invoke.LambdaForm").getDeclaredField("debugName");
-            DEBUG_NAME.setAccessible(true);
+            KIND_FIELD = Class.forName("java.lang.invoke.LambdaForm").getDeclaredField("kind");
+            KIND_FIELD.setAccessible(true);
 
             REF_FIELD = Reference.class.getDeclaredField("referent");
             REF_FIELD.setAccessible(true);
diff --git a/jdk/test/java/lang/invoke/lambda/LambdaClassLoaderSerialization.java b/jdk/test/java/lang/invoke/lambda/LambdaClassLoaderSerialization.java
index 6c97e34..822fc45 100644
--- a/jdk/test/java/lang/invoke/lambda/LambdaClassLoaderSerialization.java
+++ b/jdk/test/java/lang/invoke/lambda/LambdaClassLoaderSerialization.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, 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,8 +25,6 @@
  * @test
  * @bug 8004970
  * @summary Lambda serialization in the presence of class loaders
- * @library /lib/testlibrary
- * @build jdk.testlibrary.IOUtils
  * @run main LambdaClassLoaderSerialization
  * @author Peter Levart
  */
@@ -38,9 +36,6 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
-import java.util.Arrays;
-
-import jdk.testlibrary.IOUtils;
 
 public class LambdaClassLoaderSerialization {
 
@@ -130,7 +125,7 @@
             String path = name.replace('.', '/').concat(".class");
             try (InputStream is = getResourceAsStream(path)) {
                 if (is != null) {
-                    byte[] bytes = IOUtils.readFully(is);
+                    byte[] bytes = is.readAllBytes();
                     return defineClass(name, bytes, 0, bytes.length);
                 } else {
                     throw new ClassNotFoundException(name);
diff --git a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java
index d029c8f..da30cf3 100644
--- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java
+++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,6 @@
  *
  * @requires vm.gc == "null"
  * @requires vm.opt.ExplicitGCInvokesConcurrent != "true"
- * @requires vm.opt.ExplicitGCInvokesConcurrentAndUnloadsClasses != "true"
  * @requires vm.opt.DisableExplicitGC != "true"
  * @library /lib/testlibrary/
  *
diff --git a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh
index 515cb8f..35ad4d6 100644
--- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh
+++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2004, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -54,12 +54,12 @@
 # Run test with each GC configuration
 #
 # Notes: To ensure that metaspace fills up we disable class unloading.
-# Also we set the max metaspace to 8MB - otherwise the test takes too
+# Also we set the max metaspace to 16MB - otherwise the test takes too
 # long to run.
 
 go -noclassgc -XX:MaxMetaspaceSize=16m -XX:+UseSerialGC LowMemoryTest2
 go -noclassgc -XX:MaxMetaspaceSize=16m -XX:+UseParallelGC LowMemoryTest2
-go -noclassgc -XX:MaxMetaspaceSize=16m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC LowMemoryTest2
+go -noclassgc -XX:MaxMetaspaceSize=16m -XX:+UseConcMarkSweepGC LowMemoryTest2
 
 # Test class metaspace - might hit MaxMetaspaceSize instead if
 # UseCompressedClassPointers is off or if 32 bit.
diff --git a/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java b/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
index a3d69a9..8e86042 100644
--- a/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
+++ b/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,6 @@
  * @author  Mandy Chung
  *
  * @requires vm.opt.ExplicitGCInvokesConcurrent != "true"
- * @requires vm.opt.ExplicitGCInvokesConcurrentAndUnloadsClasses != "true"
  * @requires vm.opt.DisableExplicitGC != "true"
  * @library /lib/testlibrary/
  * @modules jdk.management
diff --git a/jdk/test/java/lang/management/ThreadMXBean/Locks.java b/jdk/test/java/lang/management/ThreadMXBean/Locks.java
index fa7a5b6..85761d2 100644
--- a/jdk/test/java/lang/management/ThreadMXBean/Locks.java
+++ b/jdk/test/java/lang/management/ThreadMXBean/Locks.java
@@ -29,17 +29,17 @@
  * @author  Mandy Chung
  * @author  Jaroslav Bachorik
  *
- * @library /lib/testlibrary
+ * @library /test/lib
  *
- * @build jdk.testlibrary.*
  * @run main/othervm Locks
  */
 import java.lang.management.*;
 import java.util.Arrays;
+import java.util.Objects;
 import java.util.Optional;
 import java.util.concurrent.Phaser;
 import java.util.function.Predicate;
-import jdk.testlibrary.LockFreeLogManager;
+import jdk.test.lib.LockFreeLogger;
 
 public class Locks {
 
@@ -47,7 +47,7 @@
     private static final Object OBJB = new Object();
     private static final EnhancedWaiter OBJC = new EnhancedWaiter();
     private static final ThreadMXBean TM = ManagementFactory.getThreadMXBean();
-    private static final LockFreeLogManager LOGGER = new LockFreeLogManager();
+    private static final LockFreeLogger LOGGER = new LockFreeLogger();
 
     private static String getLockName(Object lock) {
         if (lock == null) return null;
@@ -60,12 +60,12 @@
         if (t == null) {
             return;
         }
-        Optional<ThreadInfo> result = Arrays.asList(
-                TM.getThreadInfo(TM.getAllThreadIds(), true, true)).
-                stream().
-                filter(tInfo -> (tInfo != null && tInfo.getLockOwnerName() != null)
-                        ? tInfo.getLockOwnerName().equals(t.getName()) : false).
-                findAny();
+        String name = t.getName();
+        Optional<ThreadInfo> result = Arrays.stream(
+                TM.getThreadInfo(TM.getAllThreadIds(), true, true))
+                                            .filter(Objects::nonNull)
+                                            .filter(i -> name.equals(i.getLockOwnerName()))
+                                            .findAny();
         if (result.isPresent()) {
             throw new RuntimeException("Thread " + t.getName() + " is not "
                     + "supposed to be hold any lock. Currently owning lock : "
diff --git a/jdk/test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java b/jdk/test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java
index 6a9c9ca..fc94d4a 100644
--- a/jdk/test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java
@@ -31,6 +31,7 @@
  *
  * @library ../../Thread
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @build jdk.testlibrary.*
  * @build ThreadMXBeanStateTest ThreadStateController
diff --git a/jdk/test/java/lang/module/MultiReleaseJarTest.java b/jdk/test/java/lang/module/MultiReleaseJarTest.java
index 4c58e93..84bb2ce 100644
--- a/jdk/test/java/lang/module/MultiReleaseJarTest.java
+++ b/jdk/test/java/lang/module/MultiReleaseJarTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
diff --git a/jdk/test/java/lang/reflect/Method/InterfaceStatic/StaticInterfaceMethodInWayOfDefault.java b/jdk/test/java/lang/reflect/Method/InterfaceStatic/StaticInterfaceMethodInWayOfDefault.java
index 4ad93eb..ebd99e4 100644
--- a/jdk/test/java/lang/reflect/Method/InterfaceStatic/StaticInterfaceMethodInWayOfDefault.java
+++ b/jdk/test/java/lang/reflect/Method/InterfaceStatic/StaticInterfaceMethodInWayOfDefault.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, 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
@@ -27,19 +27,14 @@
  * @summary Test that a static method on an interface doesn't hide a default
  *          method with the same name and signature in a separate compilation
  *          scenario.
- * @library /lib/testlibrary
- * @build jdk.testlibrary.IOUtils
  * @run main StaticInterfaceMethodInWayOfDefault
  */
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.concurrent.Callable;
 
-import jdk.testlibrary.IOUtils;
-
 public class StaticInterfaceMethodInWayOfDefault {
     public interface A_v1 {
     }
@@ -147,7 +142,7 @@
                 String altPath = altName.replace('.', '/').concat(".class");
                 try (InputStream is = getResourceAsStream(altPath)) {
                     if (is != null) {
-                        byte[] bytes = IOUtils.readFully(is);
+                        byte[] bytes = is.readAllBytes();
                         // patch class bytes to contain original name
                         for (int i = 0; i < bytes.length - 2; i++) {
                             if (bytes[i] == '_' &&
@@ -170,7 +165,7 @@
                 String path = name.replace('.', '/').concat(".class");
                 try (InputStream is = getResourceAsStream(path)) {
                     if (is != null) {
-                        byte[] bytes = IOUtils.readFully(is);
+                        byte[] bytes = is.readAllBytes();
                         return defineClass(name, bytes, 0, bytes.length);
                     }
                     else {
diff --git a/jdk/test/java/net/Inet6Address/B6206527.java b/jdk/test/java/net/Inet6Address/B6206527.java
index 4fc90e1..9ce617b 100644
--- a/jdk/test/java/net/Inet6Address/B6206527.java
+++ b/jdk/test/java/net/Inet6Address/B6206527.java
@@ -25,14 +25,13 @@
  * @test 1.1 05/01/05
  * @bug 6206527
  * @summary "cannot assign address" when binding ServerSocket on Suse 9
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run main B6206527
  */
 
 import java.net.*;
 import java.util.*;
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 
 public class B6206527 {
 
diff --git a/jdk/test/java/net/Inet6Address/B6558853.java b/jdk/test/java/net/Inet6Address/B6558853.java
index 3c546c2..408c30d 100644
--- a/jdk/test/java/net/Inet6Address/B6558853.java
+++ b/jdk/test/java/net/Inet6Address/B6558853.java
@@ -25,8 +25,7 @@
  * @test
  * @bug 6558853
  * @summary  getHostAddress() on connections using IPv6 link-local addrs should have zone id
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run main B6558853
  */
 
@@ -35,7 +34,7 @@
 import java.io.OutputStream;
 import java.net.*;
 import java.util.Optional;
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 
 public class B6558853 implements Runnable {
     private InetAddress addr = null;
diff --git a/jdk/test/java/net/InetAddress/CheckJNI.java b/jdk/test/java/net/InetAddress/CheckJNI.java
index 89f00a9..76ac633 100644
--- a/jdk/test/java/net/InetAddress/CheckJNI.java
+++ b/jdk/test/java/net/InetAddress/CheckJNI.java
@@ -22,17 +22,16 @@
  */
 
 /* @test
-   @bug 4889870 4890033
-   @summary java -Xcheck:jni failing in net code on Solaris / [Datagram]Socket.getLocalAddress() failure
-   @library /lib/testlibrary
-   @build jdk.testlibrary.NetworkConfiguration
-   @run main/othervm -Xcheck:jni CheckJNI
-*/
+ * @bug 4889870 4890033
+ * @summary java -Xcheck:jni failing in net code on Solaris / [Datagram]Socket.getLocalAddress() failure
+ * @library /test/lib
+ * @run main/othervm -Xcheck:jni CheckJNI
+ */
 
 import java.net.*;
 import java.util.*;
 import java.util.stream.Collectors;
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 
 public class CheckJNI {
     static Socket s;
diff --git a/jdk/test/java/net/MulticastSocket/JoinLeave.java b/jdk/test/java/net/MulticastSocket/JoinLeave.java
index 93dd939..2e59a08 100644
--- a/jdk/test/java/net/MulticastSocket/JoinLeave.java
+++ b/jdk/test/java/net/MulticastSocket/JoinLeave.java
@@ -25,8 +25,7 @@
  * @test
  * @bug 4091811 4148753 4102731
  * @summary Test java.net.MulticastSocket joinGroup and leaveGroup
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run main JoinLeave
  */
 
@@ -35,7 +34,7 @@
 import java.net.InetAddress;
 import java.net.MulticastSocket;
 import java.net.NetworkInterface;
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 
 public class JoinLeave {
 
diff --git a/jdk/test/java/net/MulticastSocket/SetLoopbackMode.java b/jdk/test/java/net/MulticastSocket/SetLoopbackMode.java
index 0a6108c..03bb39b 100644
--- a/jdk/test/java/net/MulticastSocket/SetLoopbackMode.java
+++ b/jdk/test/java/net/MulticastSocket/SetLoopbackMode.java
@@ -25,9 +25,14 @@
  * @test
  * @bug 4686717
  * @summary Test MulticastSocket.setLoopbackMode
+ * @library /test/lib
+ * @run main/othervm SetLoopbackMode
  */
+
 import java.net.*;
 import java.io.IOException;
+import java.util.Enumeration;
+import jdk.test.lib.NetworkConfiguration;
 
 public class SetLoopbackMode {
 
@@ -85,8 +90,13 @@
         return PASSED;
     }
 
+    private static boolean canUseIPv6(NetworkConfiguration nc) {
+        return nc.ip6MulticastInterfaces().toArray().length > 0;
+    }
+
     public static void main (String args[]) throws Exception {
         int failures = 0;
+        NetworkConfiguration nc = NetworkConfiguration.probe();
 
         MulticastSocket mc = new MulticastSocket();
         InetAddress grp = InetAddress.getByName("224.80.80.80");
@@ -97,11 +107,12 @@
          * to workaround Linux IPv6 bug whereby !IPV6_MULTICAST_LOOP
          * doesn't prevent loopback of IPv4 multicast packets.
          */
-        InetAddress lb = InetAddress.getByName("::1");
-        if (NetworkInterface.getByInetAddress(lb) != null) {
+
+        if (canUseIPv6(nc)) {
             grp = InetAddress.getByName("ff01::1");
         }
 
+        //mc.setNetworkInterface(NetworkInterface.getByInetAddress(lb));
         System.out.println("\nTest will use multicast group: " + grp);
         mc.joinGroup(grp);
 
diff --git a/jdk/test/java/net/MulticastSocket/Test.java b/jdk/test/java/net/MulticastSocket/Test.java
index 53fa961..853f04d 100644
--- a/jdk/test/java/net/MulticastSocket/Test.java
+++ b/jdk/test/java/net/MulticastSocket/Test.java
@@ -35,6 +35,10 @@
     static int count = 0;
     static int failures = 0;
 
+    static boolean isSolaris = System.getProperty("os.name")
+        .toLowerCase()
+        .startsWith("sunos");
+
     void doTest(String address) throws Exception {
         boolean failed = false;
 
@@ -123,6 +127,14 @@
         }
     }
 
+    static boolean isValidIpv6Address(InetAddress addr) {
+        if (! (addr instanceof Inet6Address))
+            return false;
+        if (!isSolaris)
+            return true;
+        return !(addr.isAnyLocalAddress() || addr.isLoopbackAddress());
+    }
+
     void allTests() throws Exception {
 
         /*
@@ -146,7 +158,7 @@
             while (addrs.hasMoreElements()) {
                 InetAddress ia = (InetAddress)addrs.nextElement();
 
-                if (ia instanceof Inet6Address) {
+                if (isValidIpv6Address(ia)) {
                     has_ipv6 = true;
                     if (ia.isLinkLocalAddress()) has_linklocaladdress = true;
                     if (ia.isSiteLocalAddress()) has_siteaddress = true;
diff --git a/jdk/test/java/net/NetworkConfigurationProbe.java b/jdk/test/java/net/NetworkConfigurationProbe.java
index 8b8127a..607671b 100644
--- a/jdk/test/java/net/NetworkConfigurationProbe.java
+++ b/jdk/test/java/net/NetworkConfigurationProbe.java
@@ -24,15 +24,14 @@
 /**
  * @test
  * @summary NOT A TEST. Captures the network interface configuration.
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run main NetworkConfigurationProbe
  */
 
 import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.NetworkInterface;
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 import static java.util.stream.Collectors.joining;
 import static java.lang.System.out;
 
diff --git a/jdk/test/java/net/NetworkInterface/NetworkInterfaceRetrievalTests.java b/jdk/test/java/net/NetworkInterface/NetworkInterfaceRetrievalTests.java
new file mode 100644
index 0000000..276cf42
--- /dev/null
+++ b/jdk/test/java/net/NetworkInterface/NetworkInterfaceRetrievalTests.java
@@ -0,0 +1,73 @@
+/*
+ * 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 8179559
+ */
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.Enumeration;
+
+public class NetworkInterfaceRetrievalTests {
+    public static void main(String[] args) throws Exception {
+        int checkFailureCount = 0;
+
+        try {
+            Enumeration<NetworkInterface> en = NetworkInterface
+                    .getNetworkInterfaces();
+            while (en.hasMoreElements()) {
+                NetworkInterface ni = en.nextElement();
+                Enumeration<InetAddress> addrs = ni.getInetAddresses();
+                System.out.println("############ Checking network interface + "
+                        + ni + " #############");
+                while (addrs.hasMoreElements()) {
+                    InetAddress addr = addrs.nextElement();
+                    System.out.println("************ Checking address  + "
+                            + addr + " *************");
+                    NetworkInterface addrNetIf = NetworkInterface
+                            .getByInetAddress(addr);
+                    if (addrNetIf.equals(ni)) {
+                        System.out.println("Retreived net if " + addrNetIf
+                                + " equal to owning net if " + ni);
+                    } else {
+                        System.out.println("Retreived net if " + addrNetIf
+                                + "NOT  equal to owning net if " + ni
+                                + "***********");
+                        checkFailureCount++;
+                    }
+
+                }
+            }
+
+        } catch (Exception ex) {
+
+        }
+
+        if (checkFailureCount > 0) {
+            throw new RuntimeException(
+                    "NetworkInterface lookup by address didn't match owner network interface");
+        }
+    }
+}
diff --git a/jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java b/jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java
index 1fa3a55..74a5c01 100644
--- a/jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java
+++ b/jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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
diff --git a/jdk/test/java/net/Socket/LinkLocal.java b/jdk/test/java/net/Socket/LinkLocal.java
index e62522c..9957c5c 100644
--- a/jdk/test/java/net/Socket/LinkLocal.java
+++ b/jdk/test/java/net/Socket/LinkLocal.java
@@ -26,11 +26,11 @@
  * @bug 4469866
  * @summary Connecting to a link-local IPv6 address should not
  *          causes a SocketException to be thrown.
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run main LinkLocal
  */
-import jdk.testlibrary.NetworkConfiguration;
+
+import jdk.test.lib.NetworkConfiguration;
 
 import java.net.*;
 import java.util.List;
diff --git a/jdk/test/java/net/SocketPermission/SocketPermissionTest.java b/jdk/test/java/net/SocketPermission/SocketPermissionTest.java
index e67802a..360fd2c 100644
--- a/jdk/test/java/net/SocketPermission/SocketPermissionTest.java
+++ b/jdk/test/java/net/SocketPermission/SocketPermissionTest.java
@@ -25,8 +25,7 @@
  * @test
  * @bug 8047031
  * @summary SocketPermission tests for legacy socket types
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run testng/othervm SocketPermissionTest
  */
 
@@ -55,7 +54,7 @@
 
 import static org.testng.Assert.*;
 
-import static jdk.testlibrary.NetworkConfiguration.probe;
+import static jdk.test.lib.NetworkConfiguration.probe;
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 public class SocketPermissionTest {
diff --git a/jdk/test/java/net/ipv6tests/B6521014.java b/jdk/test/java/net/ipv6tests/B6521014.java
index 5efa77d..a622bb1 100644
--- a/jdk/test/java/net/ipv6tests/B6521014.java
+++ b/jdk/test/java/net/ipv6tests/B6521014.java
@@ -25,15 +25,14 @@
  * @test
  * @bug 6521014 6543428
  * @summary IOException thrown when Socket tries to bind to an local IPv6 address on SuSE Linux
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run main B6521014
  */
 
 import java.net.*;
 import java.io.*;
 import java.util.*;
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 
 /*
  *
diff --git a/jdk/test/java/nio/channels/DatagramChannel/BasicMulticastTests.java b/jdk/test/java/nio/channels/DatagramChannel/BasicMulticastTests.java
index c60b6b7..4ce1b41 100644
--- a/jdk/test/java/nio/channels/DatagramChannel/BasicMulticastTests.java
+++ b/jdk/test/java/nio/channels/DatagramChannel/BasicMulticastTests.java
@@ -24,7 +24,8 @@
 /* @test
  * @bug 4527345
  * @summary Unit test for DatagramChannel's multicast support
- * @build BasicMulticastTests NetworkConfiguration
+ * @library /test/lib
+ * @build BasicMulticastTests
  * @run main BasicMulticastTests
  */
 
@@ -34,6 +35,8 @@
 import java.util.*;
 import java.io.IOException;
 
+import jdk.test.lib.NetworkConfiguration;
+
 public class BasicMulticastTests {
 
     /**
@@ -204,14 +207,14 @@
 
         NetworkConfiguration config = NetworkConfiguration.probe();
 
-        NetworkInterface nif = config.ip4Interfaces().iterator().next();
+        NetworkInterface nif = config.ip4MulticastInterfaces().iterator().next();
         InetAddress anySource = config.ip4Addresses(nif).iterator().next();
         membershipKeyTests(nif, ip4Group, anySource);
         exceptionTests(nif);
 
         // re-run the membership key tests with IPv6 if available
 
-        Iterator<NetworkInterface> iter = config.ip6Interfaces().iterator();
+        Iterator<NetworkInterface> iter = config.ip6MulticastInterfaces().iterator();
         if (iter.hasNext()) {
             nif = iter.next();
             anySource = config.ip6Addresses(nif).iterator().next();
diff --git a/jdk/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java b/jdk/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java
index db061a8..591e394 100644
--- a/jdk/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java
+++ b/jdk/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java
@@ -24,7 +24,8 @@
 /* @test
  * @bug 4527345 7026376 6633549
  * @summary Unit test for DatagramChannel's multicast support
- * @build MulticastSendReceiveTests NetworkConfiguration
+ * @library /test/lib
+ * @build MulticastSendReceiveTests
  * @run main MulticastSendReceiveTests
  * @run main/othervm -Djava.net.preferIPv4Stack=true MulticastSendReceiveTests
  * @key randomness
@@ -36,6 +37,9 @@
 import static java.net.StandardProtocolFamily.*;
 import java.util.*;
 import java.io.IOException;
+import java.util.stream.Collectors;
+
+import jdk.test.lib.NetworkConfiguration;
 
 public class MulticastSendReceiveTests {
 
@@ -238,14 +242,15 @@
         // multicast groups used for the test
         InetAddress ip4Group = InetAddress.getByName("225.4.5.6");
         InetAddress ip6Group = InetAddress.getByName("ff02::a");
-
-        for (NetworkInterface nif: config.ip4Interfaces()) {
+        for (NetworkInterface nif: config.ip4MulticastInterfaces()
+                                         .collect(Collectors.toList())) {
             InetAddress source = config.ip4Addresses(nif).iterator().next();
             test(INET,   nif, ip4Group, source);
             test(UNSPEC, nif, ip4Group, source);
         }
 
-        for (NetworkInterface nif: config.ip6Interfaces()) {
+        for (NetworkInterface nif: config.ip6MulticastInterfaces()
+                                         .collect(Collectors.toList())) {
             InetAddress source = config.ip6Addresses(nif).iterator().next();
             test(INET6,  nif, ip6Group, source);
             test(UNSPEC, nif, ip6Group, source);
diff --git a/jdk/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java b/jdk/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java
deleted file mode 100644
index f2d2567..0000000
--- a/jdk/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.net.*;
-import java.util.*;
-import java.io.IOException;
-
-/**
- * Helper class for multicasting tests.
- */
-
-class NetworkConfiguration {
-
-    private Map<NetworkInterface,List<InetAddress>> ip4Interfaces;
-    private Map<NetworkInterface,List<InetAddress>> ip6Interfaces;
-
-    private NetworkConfiguration(Map<NetworkInterface,List<InetAddress>> ip4Interfaces,
-                                 Map<NetworkInterface,List<InetAddress>> ip6Interfaces)
-    {
-        this.ip4Interfaces = ip4Interfaces;
-        this.ip6Interfaces = ip6Interfaces;
-    }
-
-    Iterable<NetworkInterface> ip4Interfaces() {
-        return ip4Interfaces.keySet();
-    }
-
-    Iterable<NetworkInterface> ip6Interfaces() {
-        return ip6Interfaces.keySet();
-    }
-
-    Iterable<InetAddress> ip4Addresses(NetworkInterface nif) {
-        return ip4Interfaces.get(nif);
-    }
-
-    Iterable<InetAddress> ip6Addresses(NetworkInterface nif) {
-        return ip6Interfaces.get(nif);
-    }
-
-    private static final boolean isMacOs =
-            System.getProperty("os.name").equals("Mac OS X");
-
-    static NetworkConfiguration probe() throws IOException {
-        Map<NetworkInterface,List<InetAddress>> ip4Interfaces =
-            new HashMap<NetworkInterface,List<InetAddress>>();
-        Map<NetworkInterface,List<InetAddress>> ip6Interfaces =
-            new HashMap<NetworkInterface,List<InetAddress>>();
-
-        // find the interfaces that support IPv4 and IPv6
-        List<NetworkInterface> nifs = Collections
-            .list(NetworkInterface.getNetworkInterfaces());
-        for (NetworkInterface nif: nifs) {
-            // ignore intertaces that are down or don't support multicast
-            if (!nif.isUp() || !nif.supportsMulticast() || nif.isLoopback()
-                || (isMacOs && nif.getName().contains("awdl")))
-                continue;
-
-            List<InetAddress> addrs = Collections.list(nif.getInetAddresses());
-            for (InetAddress addr: addrs) {
-                if (!addr.isAnyLocalAddress()) {
-                    if (addr instanceof Inet4Address) {
-                        List<InetAddress> list = ip4Interfaces.get(nif);
-                        if (list == null) {
-                            list = new LinkedList<InetAddress>();
-                        }
-                        list.add(addr);
-                        ip4Interfaces.put(nif, list);
-                    } else if (addr instanceof Inet6Address) {
-                        List<InetAddress> list = ip6Interfaces.get(nif);
-                        if (list == null) {
-                            list = new LinkedList<InetAddress>();
-                        }
-                        list.add(addr);
-                        ip6Interfaces.put(nif, list);
-                    }
-                }
-            }
-        }
-        return new NetworkConfiguration(ip4Interfaces, ip6Interfaces);
-    }
-}
diff --git a/jdk/test/java/nio/channels/DatagramChannel/Promiscuous.java b/jdk/test/java/nio/channels/DatagramChannel/Promiscuous.java
index 21c8c18..d79a641 100644
--- a/jdk/test/java/nio/channels/DatagramChannel/Promiscuous.java
+++ b/jdk/test/java/nio/channels/DatagramChannel/Promiscuous.java
@@ -25,7 +25,8 @@
  * @bug 8014377
  * @summary Test for interference when two sockets are bound to the same
  *   port but joined to different multicast groups
- * @build Promiscuous  NetworkConfiguration
+ * @library /test/lib
+ * @build Promiscuous
  * @run main Promiscuous
  * @run main/othervm -Djava.net.preferIPv4Stack=true Promiscuous
  * @key randomness
@@ -37,6 +38,9 @@
 import static java.net.StandardProtocolFamily.*;
 import java.util.*;
 import java.io.IOException;
+import java.util.stream.Collectors;
+
+import jdk.test.lib.NetworkConfiguration;
 
 public class Promiscuous {
 
@@ -208,7 +212,8 @@
         InetAddress ip4Group1 = InetAddress.getByName("225.4.5.6");
         InetAddress ip4Group2 = InetAddress.getByName("225.4.6.6");
 
-        for (NetworkInterface nif: config.ip4Interfaces()) {
+        for (NetworkInterface nif: config.ip4MulticastInterfaces()
+                                         .collect(Collectors.toList())) {
             InetAddress source = config.ip4Addresses(nif).iterator().next();
             test(INET, nif, ip4Group1, ip4Group2);
 
diff --git a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh
index 9b01503..cc227b0 100644
--- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh
+++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh
@@ -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
diff --git a/jdk/test/java/nio/file/Files/StreamLinesTest.java b/jdk/test/java/nio/file/Files/StreamLinesTest.java
index aa4c9ba..2cf90e7 100644
--- a/jdk/test/java/nio/file/Files/StreamLinesTest.java
+++ b/jdk/test/java/nio/file/Files/StreamLinesTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,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
diff --git a/jdk/test/java/security/PermissionCollection/PermissionCollectionStreamTest.java b/jdk/test/java/security/PermissionCollection/PermissionCollectionStreamTest.java
index 63d962e..e803f01 100644
--- a/jdk/test/java/security/PermissionCollection/PermissionCollectionStreamTest.java
+++ b/jdk/test/java/security/PermissionCollection/PermissionCollectionStreamTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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
  */
diff --git a/jdk/test/java/security/Provider/ProviderVersionCheck.java b/jdk/test/java/security/Provider/ProviderVersionCheck.java
index dab3ff8..9096b64 100644
--- a/jdk/test/java/security/Provider/ProviderVersionCheck.java
+++ b/jdk/test/java/security/Provider/ProviderVersionCheck.java
@@ -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
@@ -42,7 +42,7 @@
 
         for (Provider p: Security.getProviders()) {
             System.out.print(p.getName() + " ");
-            if (p.getVersion() != 9.0d) {
+            if (p.getVersion() != 10.0d) {
                 System.out.println("failed. " + "Version received was " +
                         p.getVersion());
                 failure = true;
diff --git a/jdk/test/java/security/cert/PKIXRevocationChecker/OcspUnauthorized.java b/jdk/test/java/security/cert/PKIXRevocationChecker/OcspUnauthorized.java
index 83f1924..198be22 100644
--- a/jdk/test/java/security/cert/PKIXRevocationChecker/OcspUnauthorized.java
+++ b/jdk/test/java/security/cert/PKIXRevocationChecker/OcspUnauthorized.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,11 +24,14 @@
 /**
  * @test
  * @bug 8023362
+ * @run main/othervm OcspUnauthorized
  * @summary Make sure Ocsp UNAUTHORIZED response is treated as failure when
  *          SOFT_FAIL option is set
  */
 
 import java.io.ByteArrayInputStream;
+import java.security.Security;
+import java.security.cert.CertPathValidatorException.BasicReason;
 import java.security.cert.*;
 import java.security.cert.PKIXRevocationChecker.Option;
 import java.util.Base64;
@@ -69,6 +72,8 @@
     private static Base64.Decoder base64Decoder = Base64.getDecoder();
 
     public static void main(String[] args) throws Exception {
+        // EE_CERT is signed with MD5withRSA
+        Security.setProperty("jdk.certpath.disabledAlgorithms", "");
         cf = CertificateFactory.getInstance("X.509");
         X509Certificate taCert = getX509Cert(TRUST_ANCHOR);
         X509Certificate eeCert = getX509Cert(EE_CERT);
@@ -92,6 +97,11 @@
             throw new Exception("FAILED: expected CertPathValidatorException");
         } catch (CertPathValidatorException cpve) {
             cpve.printStackTrace();
+            if (cpve.getReason() != BasicReason.UNSPECIFIED &&
+                !cpve.getMessage().contains("OCSP response error: UNAUTHORIZED")) {
+                throw new Exception("FAILED: unexpected " +
+                                    "CertPathValidatorException reason");
+            }
         }
     }
 
diff --git a/jdk/test/java/security/cert/X509CRL/VerifyDefault.java b/jdk/test/java/security/cert/X509CRL/VerifyDefault.java
new file mode 100644
index 0000000..be7c559
--- /dev/null
+++ b/jdk/test/java/security/cert/X509CRL/VerifyDefault.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8175029
+ * @library ../../testlibrary
+ * @summary check that default implementation of
+ *          X509CRL.verify(PublicKey, Provider) works on custom X509CRL impl.
+ */
+
+import java.math.BigInteger;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Principal;
+import java.security.Provider;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.cert.Certificate;
+import java.security.cert.CRLException;
+import java.security.cert.X509Certificate;
+import java.security.cert.X509CRL;
+import java.security.cert.X509CRLEntry;
+import java.util.Date;
+import java.util.Set;
+
+public class VerifyDefault {
+    private static final String TEST_CRL =
+        "-----BEGIN X509 CRL-----\n" +
+        "MIIBGzCBhQIBATANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQMA4GA1UE\n" +
+        "ChMHRXhhbXBsZRcNMDkwNDI3MDIzODA0WhcNMjgwNjI2MDIzODA0WjAiMCACAQUX\n" +
+        "DTA5MDQyNzAyMzgwMFowDDAKBgNVHRUEAwoBBKAOMAwwCgYDVR0UBAMCAQIwDQYJ\n" +
+        "KoZIhvcNAQEEBQADgYEAoarfzXEtw3ZDi4f9U8eSvRIipHSyxOrJC7HR/hM5VhmY\n" +
+        "CErChny6x9lBVg9s57tfD/P9PSzBLusCcHwHMAbMOEcTltVVKUWZnnbumpywlYyg\n" +
+        "oKLrE9+yCOkYUOpiRlz43/3vkEL5hjIKMcDSZnPKBZi1h16Yj2hPe9GMibNip54=\n" +
+        "-----END X509 CRL-----";
+
+    private static final String TEST_CERT =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICKzCCAZSgAwIBAgIBAjANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA0MjcwMjI0MzNaFw0yOTAxMTIwMjI0MzNa\n" +
+        "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB\n" +
+        "AQUAA4GNADCBiQKBgQDMJeBMBybHykI/YpwUJ4O9euqDSLb1kpWpceBS8TVqvgBC\n" +
+        "SgUJWtFZL0i6bdvF6mMdlbuBkGzhXqHiVAi96/zRLbUC9F8SMEJ6MuD+YhQ0ZFTQ\n" +
+        "atKy8zf8O9XzztelLJ26Gqb7QPV133WY3haAqHtCXOhEKkCN16NOYNC37DTaJwID\n" +
+        "AQABo3cwdTAdBgNVHQ4EFgQULXSWzXzUOIpOJpzbSCpW42IJUugwRwYDVR0jBEAw\n" +
+        "PoAUgiXdIaZeT3QA/SGUvh854OJVyxuhI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD\n" +
+        "VQQKEwdFeGFtcGxlggEAMAsGA1UdDwQEAwIBAjANBgkqhkiG9w0BAQQFAAOBgQAY\n" +
+        "eMnf5AHSNlyUlzXk8o2S0h4gCuvKX6C3kFfKuZcWvFAbx4yQOWLS2s15/nzR4+AP\n" +
+        "FGX3lgJjROyAh7fGedTQK+NFWwkM2ag1g3hXktnlnT1qHohi0w31nVBJxXEDO/Ck\n" +
+        "uJTpJGt8XxxbFaw5v7cHy7XuTAeU/sekvjEiNHW00Q==\n" +
+        "-----END CERTIFICATE-----";
+
+    private static class TestX509CRL extends X509CRL {
+        private final X509CRL crl;
+        TestX509CRL(X509CRL crl) {
+            this.crl = crl;
+        }
+        public Set<String> getCriticalExtensionOIDs() {
+           return crl.getCriticalExtensionOIDs();
+        }
+        public byte[] getExtensionValue(String oid) {
+            return crl.getExtensionValue(oid);
+        }
+        public Set<String> getNonCriticalExtensionOIDs() {
+            return crl.getNonCriticalExtensionOIDs();
+        }
+        public boolean hasUnsupportedCriticalExtension() {
+            return crl.hasUnsupportedCriticalExtension();
+        }
+        public Set<? extends X509CRLEntry> getRevokedCertificates() {
+            return crl.getRevokedCertificates();
+        }
+        public X509CRLEntry getRevokedCertificate(BigInteger serialNumber) {
+            return crl.getRevokedCertificate(serialNumber);
+        }
+        public boolean isRevoked(Certificate cert) {
+            return crl.isRevoked(cert);
+        }
+        public Date getNextUpdate() { return crl.getNextUpdate(); }
+        public Date getThisUpdate() { return crl.getThisUpdate(); }
+        public int getVersion() { return crl.getVersion(); }
+        public Principal getIssuerDN() { return crl.getIssuerDN(); }
+        public byte[] getTBSCertList() throws CRLException {
+            return crl.getTBSCertList();
+        }
+        public byte[] getSignature() { return crl.getSignature(); }
+        public String getSigAlgName() { return crl.getSigAlgName(); }
+        public String getSigAlgOID() { return crl.getSigAlgOID(); }
+        public byte[] getSigAlgParams() { return crl.getSigAlgParams(); }
+        public byte[] getEncoded() throws CRLException {
+            return crl.getEncoded();
+        }
+        public void verify(PublicKey key) throws CRLException,
+            InvalidKeyException, NoSuchAlgorithmException,
+            NoSuchProviderException, SignatureException {
+            crl.verify(key);
+        }
+        public void verify(PublicKey key, String sigProvider) throws
+            CRLException, InvalidKeyException, NoSuchAlgorithmException,
+            NoSuchProviderException, SignatureException {
+            crl.verify(key, sigProvider);
+        }
+        public String toString() { return crl.toString(); }
+    }
+
+    public static void main(String[] args) throws Exception {
+        X509Certificate cert = CertUtils.getCertFromString(TEST_CERT);
+        X509CRL crl = CertUtils.getCRLFromString(TEST_CRL);
+        new TestX509CRL(crl).verify(cert.getPublicKey(), (Provider)null);
+    }
+}
diff --git a/jdk/test/java/security/cert/X509Certificate/VerifyDefault.java b/jdk/test/java/security/cert/X509Certificate/VerifyDefault.java
new file mode 100644
index 0000000..b43ebf3
--- /dev/null
+++ b/jdk/test/java/security/cert/X509Certificate/VerifyDefault.java
@@ -0,0 +1,139 @@
+/*
+ * 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 8175029
+ * @library ../../testlibrary
+ * @summary check that default implementation of
+ *          X509Certificate.verify(PublicKey, Provider) works on custom
+ *          X509Certificate impl.
+ */
+
+import java.math.BigInteger;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Principal;
+import java.security.Provider;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateExpiredException;
+import java.security.cert.CertificateNotYetValidException;
+import java.security.cert.X509Certificate;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+public class VerifyDefault {
+    private static final String TEST_CERT =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICvTCCAaWgAwIBAgIEGYqL9TANBgkqhkiG9w0BAQsFADAPMQ0wCwYDVQQDEwRT\n" +
+        "ZWxmMB4XDTE3MDMyODE2NDcyNloXDTE3MDYyNjE2NDcyNlowDzENMAsGA1UEAxME\n" +
+        "U2VsZjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL1pfSJljFVSABOL\n" +
+        "tJbIVPEkz1+2AFgzY1hqwE0EH80lvhOEkiPPYCKwBE5VTZdyFfwFjpyx7eEeJMNT\n" +
+        "o7cixfmkQaiXHr/S1AS4BRTqLG/zgLzoJpVbzi45rnVEZc0oTm11KG3uUxkZTRr3\n" +
+        "5ORbYyZpkscKwHL2M0J/1GmnA1hmhQdwUQyIKxg4eKQwyE+/TdbFlCWVNnOlb+91\n" +
+        "eXvS11nIJ1oaBgn7u4qihuVmFmngLMxExnLYKV6AwdkwFD6pERObclRD9vAl5eUk\n" +
+        "+sM6zQYwfLdyC2i8e+ETBeOg1ijptM4KT5Uaq89zxjLR0DPH4S+aILp3gYHGrW5r\n" +
+        "eMxZAEMCAwEAAaMhMB8wHQYDVR0OBBYEFOME39JtbjzQaK3ufpKo/Pl4sZ8XMA0G\n" +
+        "CSqGSIb3DQEBCwUAA4IBAQCDcw0+Sf0yeVROVlb2/VV3oIblHkGQheXeIurW64k7\n" +
+        "tEzHtx9i8dnj5lzTZNH6hU4GRlyULbSDzjcM3P2XFRsM+0a/kEJZVqnLz5ji//7/\n" +
+        "ZXaRX0TiE2IfFOTGbO6LusO3yR4tOER/WHllz2H21C2SbW3+92Ou28glTZa42AAZ\n" +
+        "mUj9j+p6mZqD4/tUBqAEqqQoMIhw9CNjc46STNayBjt/0/+I2pfy6LagrMbjBzZ0\n" +
+        "A5kXg9WjnywGk8XFr/3RZz8DrUmCYs2qCYLCHQHsuCE6gCuf9wKhKyD51MFXXRr0\n" +
+        "cyG6LYQjrreMHYk4ZfN2NPC6lGjWxB5mIbV/DuikCnYu\n" +
+        "-----END CERTIFICATE-----";
+
+    private static class TestX509Certificate extends X509Certificate {
+        private final X509Certificate cert;
+        TestX509Certificate(X509Certificate cert) {
+            this.cert = cert;
+        }
+        public Set<String> getCriticalExtensionOIDs() {
+           return cert.getCriticalExtensionOIDs();
+        }
+        public byte[] getExtensionValue(String oid) {
+            return cert.getExtensionValue(oid);
+        }
+        public Set<String> getNonCriticalExtensionOIDs() {
+            return cert.getNonCriticalExtensionOIDs();
+        }
+        public boolean hasUnsupportedCriticalExtension() {
+            return cert.hasUnsupportedCriticalExtension();
+        }
+        public void checkValidity() throws CertificateExpiredException,
+            CertificateNotYetValidException {
+            cert.checkValidity();
+        }
+        public void checkValidity(Date date) throws CertificateExpiredException,
+            CertificateNotYetValidException {
+            cert.checkValidity(date);
+        }
+        public int getVersion() { return cert.getVersion(); }
+        public BigInteger getSerialNumber() { return cert.getSerialNumber(); }
+        public Principal getIssuerDN() { return cert.getIssuerDN(); }
+        public Principal getSubjectDN() { return cert.getSubjectDN(); }
+        public Date getNotBefore() { return cert.getNotBefore(); }
+        public Date getNotAfter() { return cert.getNotAfter(); }
+        public byte[] getTBSCertificate() throws CertificateEncodingException {
+            return cert.getTBSCertificate();
+        }
+        public byte[] getSignature() { return cert.getSignature(); }
+        public String getSigAlgName() { return cert.getSigAlgName(); }
+        public String getSigAlgOID() { return cert.getSigAlgOID(); }
+        public byte[] getSigAlgParams() { return cert.getSigAlgParams(); }
+        public boolean[] getIssuerUniqueID() {
+            return cert.getIssuerUniqueID();
+        }
+        public boolean[] getSubjectUniqueID() {
+            return cert.getSubjectUniqueID();
+        }
+        public boolean[] getKeyUsage() { return cert.getKeyUsage(); }
+        public int getBasicConstraints() { return cert.getBasicConstraints(); }
+        public byte[] getEncoded() throws CertificateEncodingException {
+            return cert.getEncoded();
+        }
+        public void verify(PublicKey key) throws CertificateException,
+            InvalidKeyException, NoSuchAlgorithmException,
+            NoSuchProviderException, SignatureException {
+            cert.verify(key);
+        }
+        public void verify(PublicKey key, String sigProvider) throws
+            CertificateException, InvalidKeyException, NoSuchAlgorithmException,
+            NoSuchProviderException, SignatureException {
+            cert.verify(key, sigProvider);
+        }
+        public PublicKey getPublicKey() { return cert.getPublicKey(); }
+        public String toString() { return cert.toString(); }
+    }
+
+    public static void main(String[] args) throws Exception {
+        X509Certificate cert = CertUtils.getCertFromString(TEST_CERT);
+        new TestX509Certificate(cert).verify(cert.getPublicKey(),
+                                             (Provider)null);
+    }
+}
diff --git a/jdk/test/java/security/testlibrary/CertUtils.java b/jdk/test/java/security/testlibrary/CertUtils.java
index e850ed1..0857a9a 100644
--- a/jdk/test/java/security/testlibrary/CertUtils.java
+++ b/jdk/test/java/security/testlibrary/CertUtils.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2007, 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
@@ -27,17 +27,20 @@
  * @author Steve Hanna
  *
  */
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 import java.io.IOException;
+import java.security.cert.CertificateException;
 import java.security.cert.CertificateFactory;
 import java.security.cert.CertPath;
 import java.security.cert.CertPathBuilder;
 import java.security.cert.CertPathValidator;
 import java.security.cert.CertStore;
 import java.security.cert.CollectionCertStoreParameters;
+import java.security.cert.CRLException;
 import java.security.cert.PKIXBuilderParameters;
 import java.security.cert.PKIXCertPathBuilderResult;
 import java.security.cert.PKIXCertPathValidatorResult;
@@ -60,59 +63,71 @@
      * Get a DER-encoded X.509 certificate from a file.
      *
      * @param certFilePath path to file containing DER-encoded certificate
-     * @return X509Certificate
-     * @throws IOException on error
+     * @return the X509Certificate
+     * @throws CertificateException if the certificate type is not supported
+     *                              or cannot be parsed
+     * @throws IOException if the file cannot be opened
      */
     public static X509Certificate getCertFromFile(String certFilePath)
-        throws IOException {
-            X509Certificate cert = null;
-            try {
-                File certFile = new File(System.getProperty("test.src", "."),
-                    certFilePath);
-                if (!certFile.canRead())
-                    throw new IOException("File " +
-                                          certFile.toString() +
-                                          " is not a readable file.");
-                FileInputStream certFileInputStream =
-                    new FileInputStream(certFile);
-                CertificateFactory cf = CertificateFactory.getInstance("X509");
-                cert = (X509Certificate)
-                    cf.generateCertificate(certFileInputStream);
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new IOException("Can't construct X509Certificate: " +
-                                      e.getMessage());
-            }
-            return cert;
+        throws CertificateException, IOException {
+        File certFile = new File(System.getProperty("test.src", "."),
+                                 certFilePath);
+        try (FileInputStream fis = new FileInputStream(certFile)) {
+            return (X509Certificate)
+                CertificateFactory.getInstance("X.509")
+                                  .generateCertificate(fis);
+        }
+    }
+
+    /**
+     * Get a PEM-encoded X.509 certificate from a string.
+     *
+     * @param cert string containing the PEM-encoded certificate
+     * @return the X509Certificate
+     * @throws CertificateException if the certificate type is not supported
+     *                              or cannot be parsed
+     */
+    public static X509Certificate getCertFromString(String cert)
+        throws CertificateException {
+        byte[] certBytes = cert.getBytes();
+        ByteArrayInputStream bais = new ByteArrayInputStream(certBytes);
+        return (X509Certificate)
+            CertificateFactory.getInstance("X.509").generateCertificate(bais);
     }
 
     /**
      * Get a DER-encoded X.509 CRL from a file.
      *
      * @param crlFilePath path to file containing DER-encoded CRL
-     * @return X509CRL
-     * @throws IOException on error
+     * @return the X509CRL
+     * @throws CertificateException if the crl type is not supported
+     * @throws CRLException if the crl cannot be parsed
+     * @throws IOException if the file cannot be opened
      */
     public static X509CRL getCRLFromFile(String crlFilePath)
-        throws IOException {
-            X509CRL crl = null;
-            try {
-                File crlFile = new File(System.getProperty("test.src", "."),
-                    crlFilePath);
-                if (!crlFile.canRead())
-                    throw new IOException("File " +
-                                          crlFile.toString() +
-                                          " is not a readable file.");
-                FileInputStream crlFileInputStream =
-                    new FileInputStream(crlFile);
-                CertificateFactory cf = CertificateFactory.getInstance("X509");
-                crl = (X509CRL) cf.generateCRL(crlFileInputStream);
-            } catch (Exception e) {
-                e.printStackTrace();
-                throw new IOException("Can't construct X509CRL: " +
-                                      e.getMessage());
-            }
-            return crl;
+        throws CertificateException, CRLException, IOException {
+        File crlFile = new File(System.getProperty("test.src", "."),
+                                crlFilePath);
+        try (FileInputStream fis = new FileInputStream(crlFile)) {
+            return (X509CRL)
+                CertificateFactory.getInstance("X.509").generateCRL(fis);
+        }
+    }
+
+    /**
+     * Get a PEM-encoded X.509 crl from a string.
+     *
+     * @param crl string containing the PEM-encoded crl
+     * @return the X509CRL
+     * @throws CertificateException if the crl type is not supported
+     * @throws CRLException if the crl cannot be parsed
+     */
+    public static X509CRL getCRLFromString(String crl)
+        throws CertificateException, CRLException {
+        byte[] crlBytes = crl.getBytes();
+        ByteArrayInputStream bais = new ByteArrayInputStream(crlBytes);
+        return (X509CRL)
+            CertificateFactory.getInstance("X.509").generateCRL(bais);
     }
 
     /**
diff --git a/jdk/test/java/text/Format/DecimalFormat/Bug6609740.java b/jdk/test/java/text/Format/DecimalFormat/Bug6609740.java
new file mode 100644
index 0000000..0dd8bd2
--- /dev/null
+++ b/jdk/test/java/text/Format/DecimalFormat/Bug6609740.java
@@ -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.
+ *
+ * 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 6609740
+ * @summary Checks the formatting and parsing of a number based
+ *          on the positive and negative sub-patterns, also
+ *          checks few invalid number patterns
+ */
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Locale;
+
+public class Bug6609740 {
+
+    public static void main(String[] args) {
+
+        double dNumber = -3456.349347;
+        String fOutput = "(3,456.35)";
+        String[] validCases = {"#,##0.0#;(#,##0.0#)", "#,##0.0#;(#)",
+            "#,##0.0#;(#,##0)"};
+
+        // formatting with the valid cases
+        NumberFormat nf = NumberFormat.getInstance(Locale.US);
+        for (String pattern : validCases) {
+            formatOnPattern(nf, pattern, dNumber, fOutput);
+        }
+
+        // parsing with the valid cases
+        String parseString = "(3,456.35)";
+        Number pOutput = -3456.35;
+        for (String pattern : validCases) {
+            parseOnPattern(nf, pattern, parseString, pOutput);
+        }
+
+        // should throw parse exception
+        String[] invalidParseCases = {"#,##0.0#;0", "#,##0.0#;()"};
+        for (String pattern : invalidParseCases) {
+            if (nf instanceof DecimalFormat) {
+                ((DecimalFormat) nf).applyPattern(pattern);
+            }
+
+            try {
+                nf.parse(parseString);
+            } catch (ParseException ex) {
+                continue;
+            }
+            throw new RuntimeException("[FAILED: Should throw"
+                    + " ParseException for pattern: "
+                    + pattern + " and input: " + parseString + "]");
+        }
+
+        // should throw exception on invalid patterns
+        // invalid patterns: no positive subpattern, zero after non-zero in
+        // the decimal part i.e. 0#0, multiple decimal separators,
+        // multiple percent, malformed pattern
+        String[] invalidPatterns = {";(#,##0.0#)", "#,##0.0#0;(#)",
+            "#,##0.0.#", "#,##0%%", ".#,##0"};
+        for (String pattern : invalidPatterns) {
+            if (nf instanceof DecimalFormat) {
+                try {
+                    ((DecimalFormat) nf).applyPattern(pattern);
+                } catch (IllegalArgumentException ex) {
+                    continue;
+                }
+                throw new RuntimeException("[FAILED: Should throw"
+                        + " IllegalArgumentException for invalid pattern: "
+                        + pattern + "]");
+            }
+        }
+    }
+
+    private static void formatOnPattern(NumberFormat nf, String pattern,
+            double number, String expected) {
+
+        if (nf instanceof DecimalFormat) {
+            ((DecimalFormat) nf).applyPattern(pattern);
+        }
+
+        String formatted = nf.format(number);
+        if (!formatted.equals(expected)) {
+            throw new RuntimeException("[FAILED: Unable to format the number"
+                    + " based on the pattern: '" + pattern + "', Expected : '"
+                    + expected + "', Found: '" + formatted + "']");
+        }
+    }
+
+    private static void parseOnPattern(NumberFormat nf, String pattern,
+            String parseString, Number expected) {
+
+        if (nf instanceof DecimalFormat) {
+            ((DecimalFormat) nf).applyPattern(pattern);
+        }
+
+        try {
+            Number output = nf.parse(parseString);
+            if (expected.doubleValue() != output.doubleValue()) {
+                throw new RuntimeException("[FAILED: Unable to parse the number"
+                        + " based on the pattern: '" + pattern + "', Expected : '"
+                        + expected + "', Found: '" + output + "']");
+            }
+        } catch (ParseException ex) {
+            throw new RuntimeException("[FAILED: Unable to parse the pattern:"
+                    + " '" + pattern + "']", ex);
+        }
+    }
+
+}
diff --git a/jdk/test/java/util/Arrays/Big.java b/jdk/test/java/util/Arrays/Big.java
index cd8f097..1d40b39 100644
--- a/jdk/test/java/util/Arrays/Big.java
+++ b/jdk/test/java/util/Arrays/Big.java
@@ -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();
diff --git a/jdk/test/java/util/BitSet/stream/BitSetStreamTest.java b/jdk/test/java/util/BitSet/stream/BitSetStreamTest.java
index e6bf027..608c535 100644
--- a/jdk/test/java/util/BitSet/stream/BitSetStreamTest.java
+++ b/jdk/test/java/util/BitSet/stream/BitSetStreamTest.java
@@ -50,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
diff --git a/jdk/test/java/util/Scanner/ScannerStreamTest.java b/jdk/test/java/util/Scanner/ScannerStreamTest.java
index 99d21dc..a27cae0 100644
--- a/jdk/test/java/util/Scanner/ScannerStreamTest.java
+++ b/jdk/test/java/util/Scanner/ScannerStreamTest.java
@@ -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
  */
diff --git a/jdk/test/java/util/Spliterator/SpliteratorCollisions.java b/jdk/test/java/util/Spliterator/SpliteratorCollisions.java
index da9de48f..0bc18ed 100644
--- a/jdk/test/java/util/Spliterator/SpliteratorCollisions.java
+++ b/jdk/test/java/util/Spliterator/SpliteratorCollisions.java
@@ -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
diff --git a/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java b/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java
index ca45ab7..ece63bf 100644
--- a/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java
+++ b/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java
@@ -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
diff --git a/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java b/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java
index 0a7f26b..c207955 100644
--- a/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java
+++ b/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java
@@ -37,7 +37,6 @@
 import java.util.Spliterator;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class ArrayDeque8Test extends JSR166TestCase {
     public static void main(String[] args) {
diff --git a/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java b/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java
index 1bbd981..344b63c 100644
--- a/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java
+++ b/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java
@@ -35,7 +35,6 @@
 import java.util.ArrayDeque;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Deque;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
@@ -44,7 +43,6 @@
 import java.util.concurrent.ThreadLocalRandom;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class ArrayDequeTest extends JSR166TestCase {
     public static void main(String[] args) {
diff --git a/jdk/test/java/util/concurrent/tck/ArrayListTest.java b/jdk/test/java/util/concurrent/tck/ArrayListTest.java
index 193b4af..535f04d 100644
--- a/jdk/test/java/util/concurrent/tck/ArrayListTest.java
+++ b/jdk/test/java/util/concurrent/tck/ArrayListTest.java
@@ -33,11 +33,9 @@
  */
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class ArrayListTest extends JSR166TestCase {
     public static void main(String[] args) {
diff --git a/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java b/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java
index fb50658..5fdf279 100644
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java
@@ -75,7 +75,7 @@
             assertTrue(a.compareAndSet(this, two, m4));
             assertSame(m4, a.get(this));
             assertFalse(a.compareAndSet(this, m5, seven));
-            assertFalse(seven == a.get(this));
+            assertNotSame(seven, a.get(this));
             assertTrue(a.compareAndSet(this, m4, seven));
             assertSame(seven, a.get(this));
         }
@@ -208,7 +208,7 @@
         assertTrue(a.compareAndSet(this, two, m4));
         assertSame(m4, a.get(this));
         assertFalse(a.compareAndSet(this, m5, seven));
-        assertFalse(seven == a.get(this));
+        assertNotSame(seven, a.get(this));
         assertTrue(a.compareAndSet(this, m4, seven));
         assertSame(seven, a.get(this));
     }
diff --git a/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java b/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java
index 6242374..eb8c0b7 100644
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java
@@ -153,7 +153,7 @@
         AtomicReference z = serialClone(x);
         assertNotSame(y, z);
         assertEquals(one, x.get());
-        assertEquals(null, y.get());
+        assertNull(y.get());
         assertEquals(one, z.get());
     }
 
diff --git a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java
index 6def2ff..6439a40 100644
--- a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java
+++ b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java
@@ -2589,28 +2589,28 @@
 
         // unspecified behavior - both source completions available
         try {
-            assertEquals(null, h0.join());
+            assertNull(h0.join());
             rs[0].assertValue(v1);
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h0, ex);
             rs[0].assertNotInvoked();
         }
         try {
-            assertEquals(null, h1.join());
+            assertNull(h1.join());
             rs[1].assertValue(v1);
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h1, ex);
             rs[1].assertNotInvoked();
         }
         try {
-            assertEquals(null, h2.join());
+            assertNull(h2.join());
             rs[2].assertValue(v1);
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h2, ex);
             rs[2].assertNotInvoked();
         }
         try {
-            assertEquals(null, h3.join());
+            assertNull(h3.join());
             rs[3].assertValue(v1);
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h3, ex);
@@ -2849,28 +2849,28 @@
 
         // unspecified behavior - both source completions available
         try {
-            assertEquals(null, h0.join());
+            assertNull(h0.join());
             rs[0].assertInvoked();
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h0, ex);
             rs[0].assertNotInvoked();
         }
         try {
-            assertEquals(null, h1.join());
+            assertNull(h1.join());
             rs[1].assertInvoked();
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h1, ex);
             rs[1].assertNotInvoked();
         }
         try {
-            assertEquals(null, h2.join());
+            assertNull(h2.join());
             rs[2].assertInvoked();
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h2, ex);
             rs[2].assertNotInvoked();
         }
         try {
-            assertEquals(null, h3.join());
+            assertNull(h3.join());
             rs[3].assertInvoked();
         } catch (CompletionException ok) {
             checkCompletedWithWrappedException(h3, ex);
diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java
index 00f8dc6..e0d9f81 100644
--- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java
@@ -237,8 +237,8 @@
         Set set1 = map.keySet();
         Set set2 = map.keySet(true);
         set2.add(six);
-        assertTrue(((ConcurrentHashMap.KeySetView)set2).getMap() == map);
-        assertTrue(((ConcurrentHashMap.KeySetView)set1).getMap() == map);
+        assertSame(map, ((ConcurrentHashMap.KeySetView)set2).getMap());
+        assertSame(map, ((ConcurrentHashMap.KeySetView)set1).getMap());
         assertEquals(set2.size(), map.size());
         assertEquals(set1.size(), map.size());
         assertTrue((Boolean)map.get(six));
@@ -332,10 +332,10 @@
         assertFalse(set.add(one));
         assertTrue(set.add(six));
         assertTrue(set.add(seven));
-        assertTrue(set.getMappedValue() == one);
-        assertTrue(map.get(one) != one);
-        assertTrue(map.get(six) == one);
-        assertTrue(map.get(seven) == one);
+        assertSame(one, set.getMappedValue());
+        assertNotSame(one, map.get(one));
+        assertSame(one, map.get(six));
+        assertSame(one, map.get(seven));
     }
 
     void checkSpliteratorCharacteristics(Spliterator<?> sp,
diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java
index 1485d2c..729a6e3 100644
--- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java
@@ -43,8 +43,6 @@
 import java.util.Random;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -148,7 +146,7 @@
         ConcurrentHashMap<BI, Boolean> m =
             new ConcurrentHashMap<BI, Boolean>();
         for (int i = 0; i < size; i++) {
-            assertTrue(m.put(new CI(i), true) == null);
+            assertNull(m.put(new CI(i), true));
         }
         for (int i = 0; i < size; i++) {
             assertTrue(m.containsKey(new CI(i)));
@@ -169,7 +167,7 @@
             BS bs = new BS(String.valueOf(i));
             LexicographicList<BI> bis = new LexicographicList<BI>(bi);
             LexicographicList<BS> bss = new LexicographicList<BS>(bs);
-            assertTrue(m.putIfAbsent(bis, true) == null);
+            assertNull(m.putIfAbsent(bis, true));
             assertTrue(m.containsKey(bis));
             if (m.putIfAbsent(bss, true) == null)
                 assertTrue(m.containsKey(bss));
diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java
index aac0bb7..8a8ffeb 100644
--- a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java
@@ -43,7 +43,6 @@
 import java.util.concurrent.ConcurrentLinkedDeque;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class ConcurrentLinkedDequeTest extends JSR166TestCase {
 
@@ -67,7 +66,7 @@
      * Returns a new deque of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private ConcurrentLinkedDeque<Integer> populatedDeque(int n) {
+    private static ConcurrentLinkedDeque<Integer> populatedDeque(int n) {
         ConcurrentLinkedDeque<Integer> q = new ConcurrentLinkedDeque<>();
         assertTrue(q.isEmpty());
         for (int i = 0; i < n; ++i)
diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java
index 57689cc..ee6827a 100644
--- a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java
@@ -41,7 +41,6 @@
 import java.util.concurrent.ConcurrentLinkedQueue;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class ConcurrentLinkedQueueTest extends JSR166TestCase {
 
@@ -65,7 +64,7 @@
      * Returns a new queue of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private ConcurrentLinkedQueue<Integer> populatedQueue(int n) {
+    private static ConcurrentLinkedQueue<Integer> populatedQueue(int n) {
         ConcurrentLinkedQueue<Integer> q = new ConcurrentLinkedQueue<>();
         assertTrue(q.isEmpty());
         for (int i = 0; i < n; ++i)
diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java
index ae91219..cb28b6a 100644
--- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java
@@ -64,7 +64,7 @@
      * Returns a new set of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private ConcurrentSkipListSet<Integer> populatedSet(int n) {
+    private static ConcurrentSkipListSet<Integer> populatedSet(int n) {
         ConcurrentSkipListSet<Integer> q =
             new ConcurrentSkipListSet<Integer>();
         assertTrue(q.isEmpty());
@@ -80,7 +80,7 @@
     /**
      * Returns a new set of first 5 ints.
      */
-    private ConcurrentSkipListSet set5() {
+    private static ConcurrentSkipListSet set5() {
         ConcurrentSkipListSet q = new ConcurrentSkipListSet();
         assertTrue(q.isEmpty());
         q.add(one);
@@ -229,7 +229,7 @@
         } catch (ClassCastException success) {
             assertTrue(q.size() < 2);
             for (int i = 0, size = q.size(); i < size; i++)
-                assertTrue(q.pollFirst().getClass() == Object.class);
+                assertSame(Object.class, q.pollFirst().getClass());
             assertNull(q.pollFirst());
             assertTrue(q.isEmpty());
             assertEquals(0, q.size());
diff --git a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java
index 4b299e7..19d34cc 100644
--- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java
@@ -59,7 +59,7 @@
      * Returns a new set of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private NavigableSet<Integer> populatedSet(int n) {
+    private static NavigableSet<Integer> populatedSet(int n) {
         ConcurrentSkipListSet<Integer> q =
             new ConcurrentSkipListSet<Integer>();
         assertTrue(q.isEmpty());
@@ -79,7 +79,7 @@
     /**
      * Returns a new set of first 5 ints.
      */
-    private NavigableSet set5() {
+    private static NavigableSet set5() {
         ConcurrentSkipListSet q = new ConcurrentSkipListSet();
         assertTrue(q.isEmpty());
         q.add(one);
@@ -97,7 +97,7 @@
     /**
      * Returns a new set of first 5 negative ints.
      */
-    private NavigableSet dset5() {
+    private static NavigableSet dset5() {
         ConcurrentSkipListSet q = new ConcurrentSkipListSet();
         assertTrue(q.isEmpty());
         q.add(m1);
diff --git a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java
index 329010b..2b13e13 100644
--- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java
+++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java
@@ -44,7 +44,6 @@
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class CopyOnWriteArrayListTest extends JSR166TestCase {
 
diff --git a/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java b/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java
index eb23564..77e800c2 100644
--- a/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java
+++ b/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java
@@ -32,9 +32,6 @@
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.SECONDS;
-
 import java.util.concurrent.CountedCompleter;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicInteger;
diff --git a/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java b/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java
index 3113b57..66e5bd6 100644
--- a/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java
+++ b/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java
@@ -40,7 +40,6 @@
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ForkJoinPool;
 import java.util.concurrent.ForkJoinTask;
-import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
diff --git a/jdk/test/java/util/concurrent/tck/ExchangerTest.java b/jdk/test/java/util/concurrent/tck/ExchangerTest.java
index ba6c544..36eacc7 100644
--- a/jdk/test/java/util/concurrent/tck/ExchangerTest.java
+++ b/jdk/test/java/util/concurrent/tck/ExchangerTest.java
@@ -160,12 +160,12 @@
             public void realRun() throws InterruptedException {
                 assertSame(one, e.exchange(two));
                 exchanged.countDown();
-                interrupted.await();
+                await(interrupted);
                 assertSame(three, e.exchange(one));
             }});
         Thread t3 = newStartedThread(new CheckedRunnable() {
             public void realRun() throws InterruptedException {
-                interrupted.await();
+                await(interrupted);
                 assertSame(one, e.exchange(three));
             }});
 
diff --git a/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java b/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java
index 4ca78a0..92e9247 100644
--- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java
+++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java
@@ -37,7 +37,6 @@
 import java.util.Comparator;
 import java.util.List;
 import java.util.Set;
-import java.util.HashSet;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CompletionService;
 import java.util.concurrent.ExecutionException;
diff --git a/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java b/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java
index 0ab6084..9b7251e 100644
--- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java
+++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java
@@ -172,7 +172,7 @@
         CompletionService cs = new ExecutorCompletionService(cachedThreadPool);
         final CountDownLatch proceed = new CountDownLatch(1);
         cs.submit(new Callable() { public String call() throws Exception {
-            proceed.await();
+            await(proceed);
             return TEST_STRING;
         }});
         assertNull(cs.poll());
diff --git a/jdk/test/java/util/concurrent/tck/ExecutorsTest.java b/jdk/test/java/util/concurrent/tck/ExecutorsTest.java
index 441a52a..9076424 100644
--- a/jdk/test/java/util/concurrent/tck/ExecutorsTest.java
+++ b/jdk/test/java/util/concurrent/tck/ExecutorsTest.java
@@ -333,16 +333,12 @@
             public void realRun() {
                 try {
                     Thread current = Thread.currentThread();
-                    assertTrue(!current.isDaemon());
+                    assertFalse(current.isDaemon());
                     assertTrue(current.getPriority() <= Thread.NORM_PRIORITY);
-                    ThreadGroup g = current.getThreadGroup();
                     SecurityManager s = System.getSecurityManager();
-                    if (s != null)
-                        assertTrue(g == s.getThreadGroup());
-                    else
-                        assertTrue(g == egroup);
-                    String name = current.getName();
-                    assertTrue(name.endsWith("thread-1"));
+                    assertSame(current.getThreadGroup(),
+                               (s == null) ? egroup : s.getThreadGroup());
+                    assertTrue(current.getName().endsWith("thread-1"));
                 } catch (SecurityException ok) {
                     // Also pass if not allowed to change setting
                 }
@@ -370,16 +366,12 @@
                 Runnable r = new CheckedRunnable() {
                     public void realRun() {
                         Thread current = Thread.currentThread();
-                        assertTrue(!current.isDaemon());
+                        assertFalse(current.isDaemon());
                         assertTrue(current.getPriority() <= Thread.NORM_PRIORITY);
-                        ThreadGroup g = current.getThreadGroup();
                         SecurityManager s = System.getSecurityManager();
-                        if (s != null)
-                            assertTrue(g == s.getThreadGroup());
-                        else
-                            assertTrue(g == egroup);
-                        String name = current.getName();
-                        assertTrue(name.endsWith("thread-1"));
+                        assertSame(current.getThreadGroup(),
+                                   (s == null) ? egroup : s.getThreadGroup());
+                        assertTrue(current.getName().endsWith("thread-1"));
                         assertSame(thisccl, current.getContextClassLoader());
                         assertEquals(thisacc, AccessController.getContext());
                         done.countDown();
diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java b/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java
index b0fea9a..f24de88 100644
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java
@@ -206,7 +206,7 @@
         public FJException(Throwable cause) { super(cause); }
     }
 
-    // A simple recursive action for testing
+    /** A simple recursive action for testing. */
     final class FibAction extends CheckedRecursiveAction {
         final int number;
         int result;
@@ -224,7 +224,7 @@
         }
     }
 
-    // A recursive action failing in base case
+    /** A recursive action failing in base case. */
     static final class FailingFibAction extends RecursiveAction {
         final int number;
         int result;
@@ -932,7 +932,7 @@
         }
     }
 
-    // Version of CCF with forced failure in left completions
+    /** Version of CCF with forced failure in left completions. */
     abstract static class FailingCCF extends CountedCompleter {
         int number;
         int rnumber;
diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java b/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java
index 8a87e47..b415348 100644
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java
@@ -32,8 +32,6 @@
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.VarHandle;
 import java.util.concurrent.CountDownLatch;
@@ -93,7 +91,7 @@
         Future<?> f = ForkJoinPool.commonPool().submit(runInCommonPool);
         // Ensure runInCommonPool is truly running in the common pool,
         // by giving this thread no opportunity to "help" on get().
-        assertTrue(taskStarted.await(LONG_DELAY_MS, MILLISECONDS));
+        await(taskStarted);
         assertNull(f.get());
     }
 
diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java b/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java
index bf5a365..766e350 100644
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java
@@ -244,7 +244,7 @@
                     taskStarted.countDown();
                     assertEquals(1, p.getPoolSize());
                     assertEquals(1, p.getActiveThreadCount());
-                    done.await();
+                    await(done);
                 }};
             Future<?> future = p.submit(task);
             await(taskStarted);
diff --git a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java
index c1063da..6415111 100644
--- a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java
@@ -127,7 +127,8 @@
         assertNull(a.getException());
         assertNull(a.getRawResult());
         if (a instanceof BinaryAsyncAction)
-            assertTrue(((BinaryAsyncAction)a).getForkJoinTaskTag() == INITIAL_STATE);
+            assertEquals(INITIAL_STATE,
+                         ((BinaryAsyncAction)a).getForkJoinTaskTag());
 
         try {
             a.get(0L, SECONDS);
@@ -148,7 +149,8 @@
         assertNull(a.getException());
         assertSame(expected, a.getRawResult());
         if (a instanceof BinaryAsyncAction)
-            assertTrue(((BinaryAsyncAction)a).getForkJoinTaskTag() == COMPLETE_STATE);
+            assertEquals(COMPLETE_STATE,
+                         ((BinaryAsyncAction)a).getForkJoinTaskTag());
 
         {
             Thread.currentThread().interrupt();
diff --git a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java
index 1037eb8..9625be2 100644
--- a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java
+++ b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java
@@ -26,8 +26,9 @@
  * However, the following notice accompanied the original version of this
  * file:
  *
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
+ * Written by Doug Lea and Martin Buchholz with assistance from
+ * members of JCP JSR-166 Expert Group and released to the public
+ * domain, as explained at
  * http://creativecommons.org/publicdomain/zero/1.0/
  * Other contributors include Andrew Wright, Jeffrey Hayes,
  * Pat Fisher, Mike Judd.
@@ -35,32 +36,33 @@
 
 /*
  * @test
- * @summary JSR-166 tck tests (conformance testing mode)
+ * @summary JSR-166 tck tests, in a number of variations.
+ *          The first is the conformance testing variant,
+ *          while others also test implementation details.
  * @build *
  * @modules java.management
  * @run junit/othervm/timeout=1000 JSR166TestCase
- */
-
-/*
- * @test
- * @summary JSR-166 tck tests (whitebox tests allowed)
- * @build *
- * @modules java.base/java.util.concurrent:open
- *          java.base/java.lang:open
- *          java.management
  * @run junit/othervm/timeout=1000
+ *      --add-opens java.base/java.util.concurrent=ALL-UNNAMED
+ *      --add-opens java.base/java.lang=ALL-UNNAMED
  *      -Djsr166.testImplementationDetails=true
  *      JSR166TestCase
  * @run junit/othervm/timeout=1000
+ *      --add-opens java.base/java.util.concurrent=ALL-UNNAMED
+ *      --add-opens java.base/java.lang=ALL-UNNAMED
  *      -Djsr166.testImplementationDetails=true
  *      -Djava.util.concurrent.ForkJoinPool.common.parallelism=0
  *      JSR166TestCase
  * @run junit/othervm/timeout=1000
+ *      --add-opens java.base/java.util.concurrent=ALL-UNNAMED
+ *      --add-opens java.base/java.lang=ALL-UNNAMED
  *      -Djsr166.testImplementationDetails=true
  *      -Djava.util.concurrent.ForkJoinPool.common.parallelism=1
  *      -Djava.util.secureRandomSeed=true
  *      JSR166TestCase
  * @run junit/othervm/timeout=1000/policy=tck.policy
+ *      --add-opens java.base/java.util.concurrent=ALL-UNNAMED
+ *      --add-opens java.base/java.lang=ALL-UNNAMED
  *      -Djsr166.testImplementationDetails=true
  *      JSR166TestCase
  */
@@ -79,8 +81,6 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.nio.file.Files;
-import java.nio.file.Paths;
 import java.security.CodeSource;
 import java.security.Permission;
 import java.security.PermissionCollection;
@@ -118,7 +118,6 @@
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
-import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import junit.framework.AssertionFailedError;
@@ -328,9 +327,11 @@
 
 //     public static String cpuModel() {
 //         try {
-//             Matcher matcher = Pattern.compile("model name\\s*: (.*)")
+//             java.util.regex.Matcher matcher
+//               = Pattern.compile("model name\\s*: (.*)")
 //                 .matcher(new String(
-//                      Files.readAllBytes(Paths.get("/proc/cpuinfo")), "UTF-8"));
+//                     java.nio.file.Files.readAllBytes(
+//                         java.nio.file.Paths.get("/proc/cpuinfo")), "UTF-8"));
 //             matcher.find();
 //             return matcher.group(1);
 //         } catch (Exception ex) { return null; }
diff --git a/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java b/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java
index 44dcedc..cdcc7a2 100644
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java
@@ -36,7 +36,6 @@
 import java.util.Spliterator;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class LinkedBlockingDeque8Test extends JSR166TestCase {
     public static void main(String[] args) {
diff --git a/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java b/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java
index 2559fdf..00fbcc9 100644
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java
@@ -85,7 +85,7 @@
      * Returns a new deque of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private LinkedBlockingDeque<Integer> populatedDeque(int n) {
+    private static LinkedBlockingDeque<Integer> populatedDeque(int n) {
         LinkedBlockingDeque<Integer> q =
             new LinkedBlockingDeque<Integer>(n);
         assertTrue(q.isEmpty());
@@ -801,7 +801,7 @@
                 }
             }});
 
-        aboutToWait.await();
+        await(aboutToWait);
         waitForThreadToEnterWaitState(t);
         t.interrupt();
         awaitTermination(t);
diff --git a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java
index 9900c33..2c3e498 100644
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java
@@ -36,7 +36,6 @@
 import java.util.Spliterator;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class LinkedBlockingQueue8Test extends JSR166TestCase {
     public static void main(String[] args) {
diff --git a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java
index 153cbce..cdccb75 100644
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java
@@ -85,7 +85,7 @@
      * Returns a new queue of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private LinkedBlockingQueue<Integer> populatedQueue(int n) {
+    private static LinkedBlockingQueue<Integer> populatedQueue(int n) {
         LinkedBlockingQueue<Integer> q =
             new LinkedBlockingQueue<Integer>(n);
         assertTrue(q.isEmpty());
diff --git a/jdk/test/java/util/concurrent/tck/LinkedListTest.java b/jdk/test/java/util/concurrent/tck/LinkedListTest.java
index 08a2ddd..66dd8c0 100644
--- a/jdk/test/java/util/concurrent/tck/LinkedListTest.java
+++ b/jdk/test/java/util/concurrent/tck/LinkedListTest.java
@@ -40,7 +40,6 @@
 import java.util.NoSuchElementException;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class LinkedListTest extends JSR166TestCase {
     public static void main(String[] args) {
@@ -70,7 +69,7 @@
      * Returns a new queue of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private LinkedList<Integer> populatedQueue(int n) {
+    private static LinkedList<Integer> populatedQueue(int n) {
         LinkedList<Integer> q = new LinkedList<>();
         assertTrue(q.isEmpty());
         for (int i = 0; i < n; ++i)
diff --git a/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java b/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java
index 6a22b0e..7f38351 100644
--- a/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java
+++ b/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java
@@ -321,7 +321,7 @@
                 assertTrue(millisElapsedSince(startTime) < LONG_DELAY_MS);
             }});
 
-        aboutToWait.await();
+        await(aboutToWait);
         waitForThreadToEnterWaitState(t);
         t.interrupt();
         awaitTermination(t);
@@ -826,7 +826,7 @@
         Thread first = newStartedThread(new CheckedRunnable() {
             public void realRun() throws InterruptedException {
                 q.transfer(four);
-                assertTrue(!q.contains(four));
+                assertFalse(q.contains(four));
                 assertEquals(1, q.size());
             }});
 
diff --git a/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java b/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java
index 088c389..aa826b8 100644
--- a/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java
+++ b/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java
@@ -93,7 +93,7 @@
      * Returns a new queue of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private PriorityBlockingQueue<Integer> populatedQueue(int n) {
+    private static PriorityBlockingQueue<Integer> populatedQueue(int n) {
         PriorityBlockingQueue<Integer> q =
             new PriorityBlockingQueue<Integer>(n);
         assertTrue(q.isEmpty());
@@ -445,7 +445,7 @@
                 }
             }});
 
-        aboutToWait.await();
+        await(aboutToWait);
         waitForThreadToEnterWaitState(t);
         t.interrupt();
         awaitTermination(t);
diff --git a/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java b/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java
index c156473..1c3984d 100644
--- a/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java
+++ b/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java
@@ -42,7 +42,6 @@
 import java.util.Queue;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class PriorityQueueTest extends JSR166TestCase {
     public static void main(String[] args) {
@@ -70,7 +69,7 @@
      * Returns a new queue of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private PriorityQueue<Integer> populatedQueue(int n) {
+    private static PriorityQueue<Integer> populatedQueue(int n) {
         PriorityQueue<Integer> q = new PriorityQueue<>(n);
         assertTrue(q.isEmpty());
         for (int i = n - 1; i >= 0; i -= 2)
diff --git a/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java b/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java
index 01bd927..132b8da 100644
--- a/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java
+++ b/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java
@@ -195,7 +195,7 @@
         public FJException(Throwable cause) { super(cause); }
     }
 
-    // A simple recursive action for testing
+    /** A simple recursive action for testing. */
     final class FibAction extends CheckedRecursiveAction {
         final int number;
         int result;
@@ -213,7 +213,7 @@
         }
     }
 
-    // A recursive action failing in base case
+    /** A recursive action failing in base case. */
     static final class FailingFibAction extends RecursiveAction {
         final int number;
         int result;
diff --git a/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java b/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java
index ce13daa..49723ad 100644
--- a/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java
+++ b/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java
@@ -210,10 +210,10 @@
         public FJException() { super(); }
     }
 
-    // An invalid return value for Fib
+    /** An invalid return value for Fib. */
     static final Integer NoResult = Integer.valueOf(-17);
 
-    // A simple recursive task for testing
+    /** A simple recursive task for testing. */
     final class FibTask extends CheckedRecursiveTask<Integer> {
         final int number;
         FibTask(int n) { number = n; }
@@ -231,7 +231,7 @@
         }
     }
 
-    // A recursive action failing in base case
+    /** A recursive action failing in base case. */
     final class FailingFibTask extends RecursiveTask<Integer> {
         final int number;
         int result;
diff --git a/jdk/test/java/util/concurrent/tck/StampedLockTest.java b/jdk/test/java/util/concurrent/tck/StampedLockTest.java
index 65ef48d..5f44312 100644
--- a/jdk/test/java/util/concurrent/tck/StampedLockTest.java
+++ b/jdk/test/java/util/concurrent/tck/StampedLockTest.java
@@ -518,7 +518,7 @@
                 lock.unlockWrite(s);
             }});
 
-        aboutToLock.await();
+        await(aboutToLock);
         waitForThreadToEnterWaitState(t);
         assertFalse(lock.isWriteLocked());
         assertTrue(lock.isReadLocked());
@@ -777,7 +777,7 @@
                 lock.writeLockInterruptibly();
             }});
 
-        locked.await();
+        await(locked);
         assertFalse(lock.validate(p));
         assertEquals(0L, lock.tryOptimisticRead());
         waitForThreadToEnterWaitState(t);
diff --git a/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java b/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java
index 102d1b5..ecd472f 100644
--- a/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java
+++ b/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java
@@ -519,7 +519,7 @@
         s1.request = false;
         p.subscribe(s1);
         s1.awaitSubscribe();
-        assertTrue(p.estimateMinimumDemand() == 0);
+        assertEquals(0, p.estimateMinimumDemand());
         TestSubscriber s2 = new TestSubscriber();
         p.subscribe(s2);
         p.submit(1);
diff --git a/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java b/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java
index 345ac9c..afa4f5c 100644
--- a/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java
+++ b/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java
@@ -596,7 +596,7 @@
                 fail("timed out");
             Thread.yield();
         }
-        assertTrue(l.size() == 1);
+        assertEquals(1, l.size());
         assertSame(one, l.get(0));
         awaitTermination(t);
     }
diff --git a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java
index 38862ce..90065c6 100644
--- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java
+++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java
@@ -265,7 +265,7 @@
             final Runnable task = new CheckedRunnable() {
                 public void realRun() { done.countDown(); }};
             p.execute(task);
-            assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
+            await(done);
         }
     }
 
@@ -359,13 +359,13 @@
                 public void realRun() throws InterruptedException {
                     threadStarted.countDown();
                     assertEquals(0, p.getCompletedTaskCount());
-                    threadProceed.await();
+                    await(threadProceed);
                     threadDone.countDown();
                 }});
             await(threadStarted);
             assertEquals(0, p.getCompletedTaskCount());
             threadProceed.countDown();
-            threadDone.await();
+            await(threadDone);
             long startTime = System.nanoTime();
             while (p.getCompletedTaskCount() != 1) {
                 if (millisElapsedSince(startTime) > LONG_DELAY_MS)
@@ -1953,7 +1953,7 @@
                     public void realRun() {
                         done.countDown();
                     }});
-            assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
+            await(done);
         }
     }
 
diff --git a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java
index cf0b097..9cbb985 100644
--- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java
+++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java
@@ -45,7 +45,6 @@
 import java.util.concurrent.CancellationException;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 import java.util.concurrent.FutureTask;
@@ -118,7 +117,7 @@
             final Runnable task = new CheckedRunnable() {
                 public void realRun() { done.countDown(); }};
             p.execute(task);
-            assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
+            await(done);
         }
     }
 
@@ -212,13 +211,13 @@
                 public void realRun() throws InterruptedException {
                     threadStarted.countDown();
                     assertEquals(0, p.getCompletedTaskCount());
-                    threadProceed.await();
+                    await(threadProceed);
                     threadDone.countDown();
                 }});
             await(threadStarted);
             assertEquals(0, p.getCompletedTaskCount());
             threadProceed.countDown();
-            threadDone.await();
+            await(threadDone);
             long startTime = System.nanoTime();
             while (p.getCompletedTaskCount() != 1) {
                 if (millisElapsedSince(startTime) > LONG_DELAY_MS)
@@ -302,6 +301,20 @@
     }
 
     /**
+     * The default rejected execution handler is AbortPolicy.
+     */
+    public void testDefaultRejectedExecutionHandler() {
+        final ThreadPoolExecutor p =
+            new ThreadPoolExecutor(1, 2,
+                                   LONG_DELAY_MS, MILLISECONDS,
+                                   new ArrayBlockingQueue<Runnable>(10));
+        try (PoolCleaner cleaner = cleaner(p)) {
+            assertTrue(p.getRejectedExecutionHandler()
+                       instanceof ThreadPoolExecutor.AbortPolicy);
+        }
+    }
+
+    /**
      * getRejectedExecutionHandler returns handler in constructor if not set
      */
     public void testGetRejectedExecutionHandler() {
@@ -1139,7 +1152,7 @@
                     await(done);
                 }};
             for (int i = 0; i < 2; ++i)
-                p.submit(Executors.callable(task));
+                p.execute(task);
             for (int i = 0; i < 2; ++i) {
                 try {
                     p.execute(task);
@@ -1955,7 +1968,7 @@
                     public void realRun() {
                         done.countDown();
                     }});
-            assertTrue(done.await(LONG_DELAY_MS, MILLISECONDS));
+            await(done);
         }
     }
 
@@ -2048,7 +2061,7 @@
                 }
             }
             // enough time to run all tasks
-            assertTrue(done.await(nTasks * SHORT_DELAY_MS, MILLISECONDS));
+            await(done, nTasks * SHORT_DELAY_MS);
         }
     }
 
diff --git a/jdk/test/java/util/concurrent/tck/ThreadTest.java b/jdk/test/java/util/concurrent/tck/ThreadTest.java
index 92b2aca..1cd9f0f 100644
--- a/jdk/test/java/util/concurrent/tck/ThreadTest.java
+++ b/jdk/test/java/util/concurrent/tck/ThreadTest.java
@@ -76,7 +76,7 @@
      * setDefaultUncaughtExceptionHandler.
      */
     public void testGetAndSetDefaultUncaughtExceptionHandler() {
-        assertEquals(null, Thread.getDefaultUncaughtExceptionHandler());
+        assertNull(Thread.getDefaultUncaughtExceptionHandler());
         // failure due to SecurityException is OK.
         // Would be nice to explicitly test both ways, but cannot yet.
         Thread.UncaughtExceptionHandler defaultHandler
diff --git a/jdk/test/java/util/concurrent/tck/TreeSetTest.java b/jdk/test/java/util/concurrent/tck/TreeSetTest.java
index a37922e..55b28d6 100644
--- a/jdk/test/java/util/concurrent/tck/TreeSetTest.java
+++ b/jdk/test/java/util/concurrent/tck/TreeSetTest.java
@@ -69,7 +69,7 @@
      * Returns a new set of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private TreeSet<Integer> populatedSet(int n) {
+    private static TreeSet<Integer> populatedSet(int n) {
         TreeSet<Integer> q = new TreeSet<>();
         assertTrue(q.isEmpty());
         for (int i = n - 1; i >= 0; i -= 2)
@@ -84,7 +84,7 @@
     /**
      * Returns a new set of first 5 ints.
      */
-    private TreeSet set5() {
+    private static TreeSet set5() {
         TreeSet q = new TreeSet();
         assertTrue(q.isEmpty());
         q.add(one);
diff --git a/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java b/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java
index 37edc1f..a0f2b96 100644
--- a/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java
+++ b/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java
@@ -60,7 +60,7 @@
      * Returns a new set of given size containing consecutive
      * Integers 0 ... n - 1.
      */
-    private NavigableSet<Integer> populatedSet(int n) {
+    private static NavigableSet<Integer> populatedSet(int n) {
         TreeSet<Integer> q = new TreeSet<>();
         assertTrue(q.isEmpty());
 
@@ -79,7 +79,7 @@
     /**
      * Returns a new set of first 5 ints.
      */
-    private NavigableSet set5() {
+    private static NavigableSet set5() {
         TreeSet q = new TreeSet();
         assertTrue(q.isEmpty());
         q.add(one);
@@ -94,7 +94,7 @@
         return s;
     }
 
-    private NavigableSet dset5() {
+    private static NavigableSet dset5() {
         TreeSet q = new TreeSet();
         assertTrue(q.isEmpty());
         q.add(m1);
diff --git a/jdk/test/java/util/concurrent/tck/VectorTest.java b/jdk/test/java/util/concurrent/tck/VectorTest.java
index 78c2364..1878a78 100644
--- a/jdk/test/java/util/concurrent/tck/VectorTest.java
+++ b/jdk/test/java/util/concurrent/tck/VectorTest.java
@@ -33,11 +33,9 @@
  */
 
 import java.util.Vector;
-import java.util.Collection;
 import java.util.List;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class VectorTest extends JSR166TestCase {
     public static void main(String[] args) {
diff --git a/jdk/test/java/util/regex/PatternStreamTest.java b/jdk/test/java/util/regex/PatternStreamTest.java
index 9809ea2..28d0eb0 100644
--- a/jdk/test/java/util/regex/PatternStreamTest.java
+++ b/jdk/test/java/util/regex/PatternStreamTest.java
@@ -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
  */
diff --git a/jdk/test/java/util/stream/boottest/TEST.properties b/jdk/test/java/util/stream/boottest/TEST.properties
index 3c930e3..565242e 100644
--- a/jdk/test/java/util/stream/boottest/TEST.properties
+++ b/jdk/test/java/util/stream/boottest/TEST.properties
@@ -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
diff --git a/jdk/test/java/util/stream/test/TEST.properties b/jdk/test/java/util/stream/test/TEST.properties
index 4128f6a..2eb6c19 100644
--- a/jdk/test/java/util/stream/test/TEST.properties
+++ b/jdk/test/java/util/stream/test/TEST.properties
@@ -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
diff --git a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/NullArgsTestCase.java b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/NullArgsTestCase.java
deleted file mode 100644
index 5cae1ba..0000000
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/NullArgsTestCase.java
+++ /dev/null
@@ -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
-            }
-        }
-    }
-}
diff --git a/jdk/test/javax/crypto/Cipher/ExampleVectors/CheckExampleVectors.java b/jdk/test/javax/crypto/Cipher/ExampleVectors/CheckExampleVectors.java
new file mode 100644
index 0000000..08cddef
--- /dev/null
+++ b/jdk/test/javax/crypto/Cipher/ExampleVectors/CheckExampleVectors.java
@@ -0,0 +1,248 @@
+/*
+ * 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 8006259
+ * @summary Test several modes of operation using vectors from SP 800-38A
+ * @modules java.xml.bind
+ * @run main CheckExampleVectors
+ */
+
+import java.io.*;
+import java.security.*;
+import java.util.*;
+import java.util.function.*;
+import javax.xml.bind.DatatypeConverter;
+import javax.crypto.*;
+import javax.crypto.spec.*;
+
+public class CheckExampleVectors {
+
+    private enum Mode {
+        ECB,
+        CBC,
+        CFB1,
+        CFB8,
+        CFB128,
+        OFB,
+        CTR
+    }
+
+    private enum Operation {
+        Encrypt,
+        Decrypt
+    }
+
+    private static class Block {
+        private byte[] input;
+        private byte[] output;
+
+        public Block() {
+
+        }
+        public Block(String settings) {
+            String[] settingsParts = settings.split(",");
+            input = stringToBytes(settingsParts[0]);
+            output = stringToBytes(settingsParts[1]);
+        }
+        public byte[] getInput() {
+            return input;
+        }
+        public byte[] getOutput() {
+            return output;
+        }
+    }
+
+    private static class TestVector {
+        private Mode mode;
+        private Operation operation;
+        private byte[] key;
+        private byte[] iv;
+        private List<Block> blocks = new ArrayList<Block>();
+
+        public TestVector(String settings) {
+            String[] settingsParts = settings.split(",");
+            mode = Mode.valueOf(settingsParts[0]);
+            operation = Operation.valueOf(settingsParts[1]);
+            key = stringToBytes(settingsParts[2]);
+            if (settingsParts.length > 3) {
+                iv = stringToBytes(settingsParts[3]);
+            }
+        }
+
+        public Mode getMode() {
+            return mode;
+        }
+        public Operation getOperation() {
+            return operation;
+        }
+        public byte[] getKey() {
+            return key;
+        }
+        public byte[] getIv() {
+            return iv;
+        }
+        public void addBlock (Block b) {
+            blocks.add(b);
+        }
+        public Iterable<Block> getBlocks() {
+            return blocks;
+        }
+    }
+
+    private static final String VECTOR_FILE_NAME = "NIST_800_38A_vectors.txt";
+    private static final Mode[] REQUIRED_MODES = {Mode.ECB, Mode.CBC, Mode.CTR};
+    private static Set<Mode> supportedModes = new HashSet<Mode>();
+
+    public static void main(String[] args) throws Exception {
+        checkAllProviders();
+        checkSupportedModes();
+    }
+
+    private static byte[] stringToBytes(String v) {
+        if (v.equals("")) {
+            return null;
+        }
+        return DatatypeConverter.parseBase64Binary(v);
+    }
+
+    private static String toModeString(Mode mode) {
+        return mode.toString();
+    }
+
+    private static int toCipherOperation(Operation op) {
+        switch (op) {
+            case Encrypt:
+                return Cipher.ENCRYPT_MODE;
+            case Decrypt:
+                return Cipher.DECRYPT_MODE;
+        }
+
+        throw new RuntimeException("Unknown operation: " + op);
+    }
+
+    private static void log(String str) {
+        System.out.println(str);
+    }
+
+    private static void checkVector(String providerName, TestVector test) {
+
+        String modeString = toModeString(test.getMode());
+        String cipherString = "AES" + "/" + modeString + "/" + "NoPadding";
+        log("checking: " + cipherString + " on " + providerName);
+        try {
+            Cipher cipher = Cipher.getInstance(cipherString, providerName);
+            SecretKeySpec key = new SecretKeySpec(test.getKey(), "AES");
+            if (test.getIv() != null) {
+                IvParameterSpec iv = new IvParameterSpec(test.getIv());
+                cipher.init(toCipherOperation(test.getOperation()), key, iv);
+            }
+            else {
+                cipher.init(toCipherOperation(test.getOperation()), key);
+            }
+            int blockIndex = 0;
+            for (Block curBlock : test.getBlocks()) {
+                byte[] blockOutput = cipher.update(curBlock.getInput());
+                byte[] expectedBlockOutput = curBlock.getOutput();
+                if (!Arrays.equals(blockOutput, expectedBlockOutput)) {
+                    throw new RuntimeException("Blocks do not match at index "
+                        + blockIndex);
+                }
+                blockIndex++;
+            }
+            log("success");
+            supportedModes.add(test.getMode());
+        } catch (NoSuchAlgorithmException ex) {
+            log("algorithm not supported");
+        } catch (NoSuchProviderException | NoSuchPaddingException
+            | InvalidKeyException | InvalidAlgorithmParameterException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
+    private static boolean isComment(String line) {
+        return (line != null) && line.startsWith("//");
+    }
+
+    private static TestVector readVector(BufferedReader in) throws IOException {
+        String line;
+        while (isComment(line = in.readLine())) {
+            // skip comment lines
+        }
+        if (line == null || line.isEmpty()) {
+            return null;
+        }
+
+        TestVector newVector = new TestVector(line);
+        String numBlocksStr = in.readLine();
+        int numBlocks = Integer.parseInt(numBlocksStr);
+        for (int i = 0; i < numBlocks; i++) {
+            Block newBlock = new Block(in.readLine());
+            newVector.addBlock(newBlock);
+        }
+
+        return newVector;
+    }
+
+    private static void checkAllProviders() throws IOException {
+        File dataFile = new File(System.getProperty("test.src", "."),
+                                 VECTOR_FILE_NAME);
+        BufferedReader in = new BufferedReader(new FileReader(dataFile));
+        List<TestVector> allTests = new ArrayList<>();
+        TestVector newTest;
+        while ((newTest = readVector(in)) != null) {
+            allTests.add(newTest);
+        }
+
+        for (Provider provider : Security.getProviders()) {
+            checkProvider(provider.getName(), allTests);
+        }
+    }
+
+    private static void checkProvider(String providerName,
+                                      List<TestVector> allVectors)
+        throws IOException {
+
+        for (TestVector curVector : allVectors) {
+            checkVector(providerName, curVector);
+        }
+    }
+
+    /*
+     *  This method helps ensure that the test is working properly by
+     *  verifying that the test was able to check the test vectors for
+     *  some of the modes of operation.
+     */
+    private static void checkSupportedModes() {
+        for (Mode curMode : REQUIRED_MODES) {
+            if (!supportedModes.contains(curMode)) {
+                throw new RuntimeException(
+                    "Mode not supported by any provider: " + curMode);
+            }
+        }
+
+    }
+
+}
+
diff --git a/jdk/test/javax/crypto/Cipher/ExampleVectors/NIST_800_38A_vectors.txt b/jdk/test/javax/crypto/Cipher/ExampleVectors/NIST_800_38A_vectors.txt
new file mode 100644
index 0000000..aca903e
--- /dev/null
+++ b/jdk/test/javax/crypto/Cipher/ExampleVectors/NIST_800_38A_vectors.txt
@@ -0,0 +1,418 @@
+// Example vectors from NIST Special Publication 800-38A
+// Recommentation for Block Cipher Modes of Operation
+//
+// format for each vector entry is as follows:
+// mode,encrypt/decrypt,key,initialization vector
+// number of blocks
+// (for each block) input,output
+// All key, IV, input, and output values are encoded in Base64
+//
+ECB,Encrypt,K34VFiiu0qar9xWICc9PPA==,
+4
+a8G+4i5An5bpPX4Rc5MXKg==,Otd7tA16NmConsrzJGbvlw==
+ri2KVx4DrJyet2+sRa+OUQ==,9dPVhQO5aZ3nhYlalv26rw==
+MMgcRqNc5BHl+8EZGgpS7w==,Q7HNf1mOziOIGwDj7QMGiA==
+9p8kRd9PmxetK0F75mw3EA==,ewx4XiforT+CIyBxBHJd1A==
+ECB,Decrypt,K34VFiiu0qar9xWICc9PPA==,
+4
+Otd7tA16NmConsrzJGbvlw==,a8G+4i5An5bpPX4Rc5MXKg==
+9dPVhQO5aZ3nhYlalv26rw==,ri2KVx4DrJyet2+sRa+OUQ==
+Q7HNf1mOziOIGwDj7QMGiA==,MMgcRqNc5BHl+8EZGgpS7w==
+ewx4XiforT+CIyBxBHJd1A==,9p8kRd9PmxetK0F75mw3EA==
+ECB,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,
+4
+a8G+4i5An5bpPX4Rc5MXKg==,vTNPHW5F8l/3EqIUVx+lzA==
+ri2KVx4DrJyet2+sRa+OUQ==,l0EEhG0K0613NOyz7O5O7w==
+MMgcRqNc5BHl+8EZGgpS7w==,73r9InDi5grc4LovrOZETg==
+9p8kRd9PmxetK0F75mw3EA==,mktBunONbHL7FmkWA8GODg==
+ECB,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,
+4
+vTNPHW5F8l/3EqIUVx+lzA==,a8G+4i5An5bpPX4Rc5MXKg==
+l0EEhG0K0613NOyz7O5O7w==,ri2KVx4DrJyet2+sRa+OUQ==
+73r9InDi5grc4LovrOZETg==,MMgcRqNc5BHl+8EZGgpS7w==
+mktBunONbHL7FmkWA8GODg==,9p8kRd9PmxetK0F75mw3EA==
+ECB,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,
+4
+a8G+4i5An5bpPX4Rc5MXKg==,8+7RvbXSoDwGS1p+PbGB+A==
+ri2KVx4DrJyet2+sRa+OUQ==,WRzLENQQ7SbcW6dKMTYocA==
+MMgcRqNc5BHl+8EZGgpS7w==,tu0huZym9PnxU+exvq/tHQ==
+9p8kRd9PmxetK0F75mw3EA==,IzBLejn58/8GfY2PniTsxw==
+ECB,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,
+4
+8+7RvbXSoDwGS1p+PbGB+A==,a8G+4i5An5bpPX4Rc5MXKg==
+WRzLENQQ7SbcW6dKMTYocA==,ri2KVx4DrJyet2+sRa+OUQ==
+tu0huZym9PnxU+exvq/tHQ==,MMgcRqNc5BHl+8EZGgpS7w==
+IzBLejn58/8GfY2PniTsxw==,9p8kRd9PmxetK0F75mw3EA==
+CBC,Encrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
+4
+a8G+4i5An5bpPX4Rc5MXKg==,dkmrrIEZskbO6Y6bEukZfQ==
+ri2KVx4DrJyet2+sRa+OUQ==,UIbLm1ByGe6V2xE6kXZ4sg==
+MMgcRqNc5BHl+8EZGgpS7w==,c77WuOPBdDtxFuaeIiKVFg==
+9p8kRd9PmxetK0F75mw3EA==,P/HKoWgfrAkSDsowdYbhpw==
+CBC,Decrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
+4
+dkmrrIEZskbO6Y6bEukZfQ==,a8G+4i5An5bpPX4Rc5MXKg==
+UIbLm1ByGe6V2xE6kXZ4sg==,ri2KVx4DrJyet2+sRa+OUQ==
+c77WuOPBdDtxFuaeIiKVFg==,MMgcRqNc5BHl+8EZGgpS7w==
+P/HKoWgfrAkSDsowdYbhpw==,9p8kRd9PmxetK0F75mw3EA==
+CBC,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
+4
+a8G+4i5An5bpPX4Rc5MXKg==,TwIdskO8Yz1xeBg6n6Bx6A==
+ri2KVx4DrJyet2+sRa+OUQ==,tNmtqa197fTl5zh2P2kUWg==
+MMgcRqNc5BHl+8EZGgpS7w==,VxskIBL7euB/qbqsPfEC4A==
+9p8kRd9PmxetK0F75mw3EA==,CLDieYhZiIHZIKnmT1YVzQ==
+CBC,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
+4
+TwIdskO8Yz1xeBg6n6Bx6A==,a8G+4i5An5bpPX4Rc5MXKg==
+tNmtqa197fTl5zh2P2kUWg==,ri2KVx4DrJyet2+sRa+OUQ==
+VxskIBL7euB/qbqsPfEC4A==,MMgcRqNc5BHl+8EZGgpS7w==
+CLDieYhZiIHZIKnmT1YVzQ==,9p8kRd9PmxetK0F75mw3EA==
+CBC,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
+4
+a8G+4i5An5bpPX4Rc5MXKg==,9YxMBNbl8bp3nqv7X3v71g==
+ri2KVx4DrJyet2+sRa+OUQ==,nPxOln7bgI1nn3d7xnAsfQ==
+MMgcRqNc5BHl+8EZGgpS7w==,OfIzaanZus+lMOJjBCMUYQ==
+9p8kRd9PmxetK0F75mw3EA==,susF4sOb6fzabBkHjGqdGw==
+CBC,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
+4
+9YxMBNbl8bp3nqv7X3v71g==,a8G+4i5An5bpPX4Rc5MXKg==
+nPxOln7bgI1nn3d7xnAsfQ==,ri2KVx4DrJyet2+sRa+OUQ==
+OfIzaanZus+lMOJjBCMUYQ==,MMgcRqNc5BHl+8EZGgpS7w==
+susF4sOb6fzabBkHjGqdGw==,9p8kRd9PmxetK0F75mw3EA==
+CFB1,Encrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
+16
+AA==,AA==
+AQ==,AQ==
+AQ==,AQ==
+AA==,AA==
+AQ==,AQ==
+AA==,AA==
+AQ==,AQ==
+AQ==,AA==
+AQ==,AQ==
+AQ==,AA==
+AA==,AQ==
+AA==,AQ==
+AA==,AA==
+AA==,AA==
+AA==,AQ==
+AQ==,AQ==
+CFB1,Decrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
+16
+AA==,AA==
+AQ==,AQ==
+AQ==,AQ==
+AA==,AA==
+AQ==,AQ==
+AA==,AA==
+AA==,AQ==
+AA==,AQ==
+AQ==,AQ==
+AA==,AQ==
+AQ==,AA==
+AQ==,AA==
+AA==,AA==
+AA==,AA==
+AQ==,AA==
+AQ==,AQ==
+CFB1,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
+16
+AA==,AQ==
+AQ==,AA==
+AQ==,AA==
+AA==,AQ==
+AQ==,AA==
+AA==,AA==
+AQ==,AQ==
+AQ==,AQ==
+AQ==,AA==
+AQ==,AQ==
+AA==,AA==
+AA==,AQ==
+AA==,AQ==
+AA==,AA==
+AA==,AA==
+AQ==,AQ==
+CFB1,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
+16
+AQ==,AA==
+AA==,AQ==
+AA==,AQ==
+AQ==,AA==
+AA==,AQ==
+AA==,AA==
+AQ==,AQ==
+AQ==,AQ==
+AA==,AQ==
+AQ==,AQ==
+AA==,AA==
+AQ==,AA==
+AQ==,AA==
+AA==,AA==
+AA==,AA==
+AQ==,AQ==
+CFB1,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
+16
+AA==,AQ==
+AQ==,AA==
+AQ==,AA==
+AA==,AQ==
+AQ==,AA==
+AA==,AA==
+AQ==,AA==
+AQ==,AA==
+AQ==,AA==
+AQ==,AA==
+AA==,AQ==
+AA==,AA==
+AA==,AQ==
+AA==,AA==
+AA==,AA==
+AQ==,AQ==
+CFB1,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
+16
+AQ==,AA==
+AA==,AQ==
+AA==,AQ==
+AQ==,AA==
+AA==,AQ==
+AA==,AA==
+AA==,AQ==
+AA==,AQ==
+AA==,AQ==
+AA==,AQ==
+AQ==,AA==
+AA==,AA==
+AQ==,AA==
+AA==,AA==
+AA==,AA==
+AQ==,AQ==
+CFB8,Encrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
+18
+aw==,Ow==
+wQ==,eQ==
+vg==,Qg==
+4g==,TA==
+Lg==,nA==
+QA==,DQ==
+nw==,1A==
+lg==,Ng==
+6Q==,ug==
+PQ==,zg==
+fg==,ng==
+EQ==,Dg==
+cw==,1A==
+kw==,WA==
+Fw==,ag==
+Kg==,Tw==
+rg==,Mg==
+LQ==,uQ==
+CFB8,Decrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
+18
+Ow==,aw==
+eQ==,wQ==
+Qg==,vg==
+TA==,4g==
+nA==,Lg==
+DQ==,QA==
+1A==,nw==
+Ng==,lg==
+ug==,6Q==
+zg==,PQ==
+ng==,fg==
+Dg==,EQ==
+1A==,cw==
+WA==,kw==
+ag==,Fw==
+Tw==,Kg==
+Mg==,rg==
+uQ==,LQ==
+CFB8,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
+18
+aw==,zQ==
+wQ==,og==
+vg==,Ug==
+4g==,Hg==
+Lg==,8A==
+QA==,qQ==
+nw==,BQ==
+lg==,yg==
+6Q==,RA==
+PQ==,zQ==
+fg==,BQ==
+EQ==,fA==
+cw==,vw==
+kw==,DQ==
+Fw==,Rw==
+Kg==,oA==
+rg==,Zw==
+LQ==,ig==
+CFB8,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
+18
+zQ==,aw==
+og==,wQ==
+Ug==,vg==
+Hg==,4g==
+8A==,Lg==
+qQ==,QA==
+BQ==,nw==
+yg==,lg==
+RA==,6Q==
+zQ==,PQ==
+BQ==,fg==
+fA==,EQ==
+vw==,cw==
+DQ==,kw==
+Rw==,Fw==
+oA==,Kg==
+Zw==,rg==
+ig==,LQ==
+CFB8,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
+18
+aw==,3A==
+wQ==,Hw==
+vg==,Gg==
+4g==,hQ==
+Lg==,IA==
+QA==,pg==
+nw==,TQ==
+lg==,tQ==
+6Q==,Xw==
+PQ==,zA==
+fg==,ig==
+EQ==,xQ==
+cw==,VA==
+kw==,hA==
+Fw==,Tg==
+Kg==,iA==
+rg==,lw==
+LQ==,AA==
+CFB8,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
+18
+3A==,aw==
+Hw==,wQ==
+Gg==,vg==
+hQ==,4g==
+IA==,Lg==
+pg==,QA==
+TQ==,nw==
+tQ==,lg==
+Xw==,6Q==
+zA==,PQ==
+ig==,fg==
+xQ==,EQ==
+VA==,cw==
+hA==,kw==
+Tg==,Fw==
+iA==,Kg==
+lw==,rg==
+AA==,LQ==
+CFB128,Encrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
+4
+a8G+4i5An5bpPX4Rc5MXKg==,Oz/ZLrctrSAzNEn46Dz7Sg==
+ri2KVx4DrJyet2+sRa+OUQ==,yKZFN6CzqT/N482tnxzliw==
+MMgcRqNc5BHl+8EZGgpS7w==,JnUfZ6PLsUCxgIzxh6T03w==
+9p8kRd9PmxetK0F75mw3EA==,wEsFNXxdHA7qxMZvn/fy5g==
+CFB128,Decrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
+4
+Oz/ZLrctrSAzNEn46Dz7Sg==,a8G+4i5An5bpPX4Rc5MXKg==
+yKZFN6CzqT/N482tnxzliw==,ri2KVx4DrJyet2+sRa+OUQ==
+JnUfZ6PLsUCxgIzxh6T03w==,MMgcRqNc5BHl+8EZGgpS7w==
+wEsFNXxdHA7qxMZvn/fy5g==,9p8kRd9PmxetK0F75mw3EA==
+CFB128,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
+4
+a8G+4i5An5bpPX4Rc5MXKg==,zcgNb93xjKs0wlkJyZpBdA==
+ri2KVx4DrJyet2+sRa+OUQ==,Z85/f4EXNiGWGitwFx09eg==
+MMgcRqNc5BHl+8EZGgpS7w==,Lh6KHdWbiLHI5g/tHvrEyQ==
+9p8kRd9PmxetK0F75mw3EA==,wF+fnKmDT6BCro+6WEsJ/w==
+CFB128,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
+4
+zcgNb93xjKs0wlkJyZpBdA==,a8G+4i5An5bpPX4Rc5MXKg==
+Z85/f4EXNiGWGitwFx09eg==,ri2KVx4DrJyet2+sRa+OUQ==
+Lh6KHdWbiLHI5g/tHvrEyQ==,MMgcRqNc5BHl+8EZGgpS7w==
+wF+fnKmDT6BCro+6WEsJ/w==,9p8kRd9PmxetK0F75mw3EA==
+CFB128,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
+4
+a8G+4i5An5bpPX4Rc5MXKg==,3H6Ev9p5Fkt+zYSGmF04YA==
+ri2KVx4DrJyet2+sRa+OUQ==,Of/tFDsoscgyETxjMeVAew==
+MMgcRqNc5BHl+8EZGgpS7w==,3xATJBXlS5KhPtCoJnri+Q==
+9p8kRd9PmxetK0F75mw3EA==,daOFdBq5zvggMWI9VbHkcQ==
+CFB128,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
+4
+3H6Ev9p5Fkt+zYSGmF04YA==,a8G+4i5An5bpPX4Rc5MXKg==
+Of/tFDsoscgyETxjMeVAew==,ri2KVx4DrJyet2+sRa+OUQ==
+3xATJBXlS5KhPtCoJnri+Q==,MMgcRqNc5BHl+8EZGgpS7w==
+daOFdBq5zvggMWI9VbHkcQ==,9p8kRd9PmxetK0F75mw3EA==
+OFB,Encrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
+4
+a8G+4i5An5bpPX4Rc5MXKg==,Oz/ZLrctrSAzNEn46Dz7Sg==
+ri2KVx4DrJyet2+sRa+OUQ==,d4lQjRaRjwP1PFLaxU7YJQ==
+MMgcRqNc5BHl+8EZGgpS7w==,l0AFHpxf7PZDRPeoImDtzA==
+9p8kRd9PmxetK0F75mw3EA==,MExlKPZZx3hmpRDZwdauXg==
+OFB,Decrypt,K34VFiiu0qar9xWICc9PPA==,AAECAwQFBgcICQoLDA0ODw==
+4
+Oz/ZLrctrSAzNEn46Dz7Sg==,a8G+4i5An5bpPX4Rc5MXKg==
+d4lQjRaRjwP1PFLaxU7YJQ==,ri2KVx4DrJyet2+sRa+OUQ==
+l0AFHpxf7PZDRPeoImDtzA==,MMgcRqNc5BHl+8EZGgpS7w==
+MExlKPZZx3hmpRDZwdauXg==,9p8kRd9PmxetK0F75mw3EA==
+OFB,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
+4
+a8G+4i5An5bpPX4Rc5MXKg==,zcgNb93xjKs0wlkJyZpBdA==
+ri2KVx4DrJyet2+sRa+OUQ==,/MKLjUxjg3wJ6BcAwRAEAQ==
+MMgcRqNc5BHl+8EZGgpS7w==,jZqa6sD2WW9VnG1Nr1ml8g==
+9p8kRd9PmxetK0F75mw3EA==,bZ8gCFfKbD6crFJL2azJKg==
+OFB,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,AAECAwQFBgcICQoLDA0ODw==
+4
+zcgNb93xjKs0wlkJyZpBdA==,a8G+4i5An5bpPX4Rc5MXKg==
+/MKLjUxjg3wJ6BcAwRAEAQ==,ri2KVx4DrJyet2+sRa+OUQ==
+jZqa6sD2WW9VnG1Nr1ml8g==,MMgcRqNc5BHl+8EZGgpS7w==
+bZ8gCFfKbD6crFJL2azJKg==,9p8kRd9PmxetK0F75mw3EA==
+OFB,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
+4
+a8G+4i5An5bpPX4Rc5MXKg==,3H6Ev9p5Fkt+zYSGmF04YA==
+ri2KVx4DrJyet2+sRa+OUQ==,T+vcZ0DSCzrIj2rYKk+wjQ==
+MMgcRqNc5BHl+8EZGgpS7w==,catHoIbobu3znRxbupfECA==
+9p8kRd9PmxetK0F75mw3EA==,ASYUHWfze+hTj1qL50DkhA==
+OFB,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,AAECAwQFBgcICQoLDA0ODw==
+4
+3H6Ev9p5Fkt+zYSGmF04YA==,a8G+4i5An5bpPX4Rc5MXKg==
+T+vcZ0DSCzrIj2rYKk+wjQ==,ri2KVx4DrJyet2+sRa+OUQ==
+catHoIbobu3znRxbupfECA==,MMgcRqNc5BHl+8EZGgpS7w==
+ASYUHWfze+hTj1qL50DkhA==,9p8kRd9PmxetK0F75mw3EA==
+CTR,Encrypt,K34VFiiu0qar9xWICc9PPA==,8PHy8/T19vf4+fr7/P3+/w==
+4
+a8G+4i5An5bpPX4Rc5MXKg==,h01hkbYg4yYb72hkmQ22zg==
+ri2KVx4DrJyet2+sRa+OUQ==,mAb2a3lw/f+GFxh7uf/9/w==
+MMgcRqNc5BHl+8EZGgpS7w==,WuTfPtvV015bTwkCDbA+qw==
+9p8kRd9PmxetK0F75mw3EA==,HgMd2i++A9F5IXCg8wCc7g==
+CTR,Decrypt,K34VFiiu0qar9xWICc9PPA==,8PHy8/T19vf4+fr7/P3+/w==
+4
+h01hkbYg4yYb72hkmQ22zg==,a8G+4i5An5bpPX4Rc5MXKg==
+mAb2a3lw/f+GFxh7uf/9/w==,ri2KVx4DrJyet2+sRa+OUQ==
+WuTfPtvV015bTwkCDbA+qw==,MMgcRqNc5BHl+8EZGgpS7w==
+HgMd2i++A9F5IXCg8wCc7g==,9p8kRd9PmxetK0F75mw3EA==
+CTR,Encrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,8PHy8/T19vf4+fr7/P3+/w==
+4
+a8G+4i5An5bpPX4Rc5MXKg==,GryTJBdSHKJPKwRZ/n5uCw==
+ri2KVx4DrJyet2+sRa+OUQ==,CQM57Aqm+u/VzMLG9M6OlA==
+MMgcRqNc5BHl+8EZGgpS7w==,Hjaya9HrxnDRvR1mViCr9w==
+9p8kRd9PmxetK0F75mw3EA==,T3in9tKYCVhal9rsWMawUA==
+CTR,Decrypt,jnOw99oOZFLIEPMrgJB55WL46tJSLGt7,8PHy8/T19vf4+fr7/P3+/w==
+4
+GryTJBdSHKJPKwRZ/n5uCw==,a8G+4i5An5bpPX4Rc5MXKg==
+CQM57Aqm+u/VzMLG9M6OlA==,ri2KVx4DrJyet2+sRa+OUQ==
+Hjaya9HrxnDRvR1mViCr9w==,MMgcRqNc5BHl+8EZGgpS7w==
+T3in9tKYCVhal9rsWMawUA==,9p8kRd9PmxetK0F75mw3EA==
+CTR,Encrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,8PHy8/T19vf4+fr7/P3+/w==
+4
+a8G+4i5An5bpPX4Rc5MXKg==,YB7DE3dXiaW3p/UEu/PSKA==
+ri2KVx4DrJyet2+sRa+OUQ==,9EPjyk1itZrKhOmQysr1xQ==
+MMgcRqNc5BHl+8EZGgpS7w==,Kwkw2qI96UzocBe6LYSYjQ==
+9p8kRd9PmxetK0F75mw3EA==,38nFjbZ6raYTwt0IRXlBpg==
+CTR,Decrypt,YD3rEBXKcb4rc67whX13gR81LAc7YQjXLZgQowkU3/Q=,8PHy8/T19vf4+fr7/P3+/w==
+4
+YB7DE3dXiaW3p/UEu/PSKA==,a8G+4i5An5bpPX4Rc5MXKg==
+9EPjyk1itZrKhOmQysr1xQ==,ri2KVx4DrJyet2+sRa+OUQ==
+Kwkw2qI96UzocBe6LYSYjQ==,MMgcRqNc5BHl+8EZGgpS7w==
+38nFjbZ6raYTwt0IRXlBpg==,9p8kRd9PmxetK0F75mw3EA==
+
diff --git a/jdk/test/javax/management/MBeanServer/NotifDeadlockTest.java b/jdk/test/javax/management/MBeanServer/NotifDeadlockTest.java
index 4020add..1b7e0e8 100644
--- a/jdk/test/javax/management/MBeanServer/NotifDeadlockTest.java
+++ b/jdk/test/javax/management/MBeanServer/NotifDeadlockTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,7 +77,6 @@
         }
     }
     static MBeanServer mbs;
-    static boolean timedOut;
 
     /* This listener registers or unregisters the MBean called on2
        when triggered.  */
@@ -110,83 +109,48 @@
                 };
                 t.start();
                 try {
-                    t.join(2000);
+                    t.join();
                 } catch (InterruptedException e) {
                     e.printStackTrace(); // should not happen
                 }
-                if (t.isAlive()) {
-                    System.out.println("FAILURE: Wait timed out: " +
-                                       "probable deadlock");
-                    timedOut = true;
-                }
             }
         }
     }
 
     public static void main(String[] args) throws Exception {
-        boolean success = true;
 
         System.out.println("Test 1: in register notif, unregister an MBean");
-        timedOut = false;
         mbs = MBeanServerFactory.createMBeanServer();
         mbs.createMBean("javax.management.timer.Timer", on2);
         mbs.addNotificationListener(delName, new XListener(false), null, null);
         mbs.createMBean("javax.management.timer.Timer", on1);
         MBeanServerFactory.releaseMBeanServer(mbs);
-        if (timedOut) {
-            success = false;
-            Thread.sleep(500);
-            // wait for the spawned thread to complete its work, probably
-        }
         System.out.println("Test 1 completed");
 
         System.out.println("Test 2: in unregister notif, unregister an MBean");
-        timedOut = false;
         mbs = MBeanServerFactory.createMBeanServer();
         mbs.createMBean("javax.management.timer.Timer", on1);
         mbs.createMBean("javax.management.timer.Timer", on2);
         mbs.addNotificationListener(delName, new XListener(false), null, null);
         mbs.unregisterMBean(on1);
         MBeanServerFactory.releaseMBeanServer(mbs);
-        if (timedOut) {
-            success = false;
-            Thread.sleep(500);
-            // wait for the spawned thread to complete its work, probably
-        }
         System.out.println("Test 2 completed");
 
         System.out.println("Test 3: in register notif, register an MBean");
-        timedOut = false;
         mbs = MBeanServerFactory.createMBeanServer();
         mbs.addNotificationListener(delName, new XListener(true), null, null);
         mbs.createMBean("javax.management.timer.Timer", on1);
         MBeanServerFactory.releaseMBeanServer(mbs);
-        if (timedOut) {
-            success = false;
-            Thread.sleep(500);
-            // wait for the spawned thread to complete its work, probably
-        }
         System.out.println("Test 3 completed");
 
         System.out.println("Test 4: in unregister notif, register an MBean");
-        timedOut = false;
         mbs = MBeanServerFactory.createMBeanServer();
         mbs.createMBean("javax.management.timer.Timer", on1);
         mbs.addNotificationListener(delName, new XListener(true), null, null);
         mbs.unregisterMBean(on1);
         MBeanServerFactory.releaseMBeanServer(mbs);
-        if (timedOut) {
-            success = false;
-            Thread.sleep(500);
-            // wait for the spawned thread to complete its work, probably
-        }
         System.out.println("Test 4 completed");
 
-        if (success)
-            System.out.println("Test passed");
-        else {
-            System.out.println("TEST FAILED: at least one subcase failed");
-            System.exit(1);
-        }
+        System.out.println("Test passed");
     }
 }
diff --git a/jdk/test/javax/management/remote/mandatory/notif/NoPermToRemoveTest.java b/jdk/test/javax/management/remote/mandatory/notif/NoPermToRemoveTest.java
new file mode 100644
index 0000000..1af316f
--- /dev/null
+++ b/jdk/test/javax/management/remote/mandatory/notif/NoPermToRemoveTest.java
@@ -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();
+        }
+    }
+}
diff --git a/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java b/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java
index aaa8ce3..c721868 100644
--- a/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java
+++ b/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -367,9 +367,15 @@
             throw tr.serverExc;
         }
 
+        // make sure getSoftFailExceptions is not empty
+        if (cliParams.revChecker.getSoftFailExceptions().isEmpty()) {
+            throw new Exception("No soft fail exceptions");
+        }
+
         System.out.println("                 PASS");
         System.out.println("=======================================\n");
 
+
         // Make OCSP responders accept connections
         intOcsp.acceptConnections();
         rootOcsp.acceptConnections();
diff --git a/jdk/test/jdk/internal/jline/extra/HistoryTest.java b/jdk/test/jdk/internal/jline/extra/HistoryTest.java
index f8d3084..65f721d 100644
--- a/jdk/test/jdk/internal/jline/extra/HistoryTest.java
+++ b/jdk/test/jdk/internal/jline/extra/HistoryTest.java
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8178821
  * @summary Test Completion
  * @modules jdk.internal.le/jdk.internal.jline
  *          jdk.internal.le/jdk.internal.jline.console
@@ -152,6 +153,15 @@
         complete.set(true);  history.add("}");
 
         previousSnippetAndAssert(history, "void test() { /*after full*/");
+        nextSnippetAndAssert(history, "");
+
+        assertFalse(history.nextSnippet());
+
+        while (history.previousSnippet())
+            ;
+
+        while (history.nextSnippet())
+            ;
     }
 
     private void previousAndAssert(EditingHistory history, String expected) {
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/SpliteratorOfIntDataBuilder.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/SpliteratorOfIntDataBuilder.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/SpliteratorOfIntDataBuilder.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/SpliteratorOfIntDataBuilder.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/SpliteratorTestHelper.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/SpliteratorTestHelper.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/SpliteratorTestHelper.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/SpliteratorTestHelper.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/CollectorOps.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/CollectorOps.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/CollectorOps.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/CollectorOps.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DefaultMethodStreams.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/DefaultMethodStreams.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DefaultMethodStreams.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/DefaultMethodStreams.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DoubleStreamTestDataProvider.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/DoubleStreamTestDataProvider.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DoubleStreamTestDataProvider.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/DoubleStreamTestDataProvider.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DoubleStreamTestScenario.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/DoubleStreamTestScenario.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DoubleStreamTestScenario.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/DoubleStreamTestScenario.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/FlagDeclaringOp.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/FlagDeclaringOp.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/FlagDeclaringOp.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/FlagDeclaringOp.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntStreamTestDataProvider.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/IntStreamTestDataProvider.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntStreamTestDataProvider.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/IntStreamTestDataProvider.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntStreamTestScenario.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/IntStreamTestScenario.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntStreamTestScenario.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/IntStreamTestScenario.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntermediateTestOp.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/IntermediateTestOp.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntermediateTestOp.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/IntermediateTestOp.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LambdaTestHelpers.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LambdaTestHelpers.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LambdaTestHelpers.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LambdaTestHelpers.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LambdaTestMode.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LambdaTestMode.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LambdaTestMode.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LambdaTestMode.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LoggingTestCase.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LoggingTestCase.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LoggingTestCase.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LoggingTestCase.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LongStreamTestDataProvider.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LongStreamTestDataProvider.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LongStreamTestDataProvider.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LongStreamTestDataProvider.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LongStreamTestScenario.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LongStreamTestScenario.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LongStreamTestScenario.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LongStreamTestScenario.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/OpTestCase.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/OpTestCase.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/OpTestCase.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/OpTestCase.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StatefulTestOp.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StatefulTestOp.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StatefulTestOp.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StatefulTestOp.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StatelessTestOp.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StatelessTestOp.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StatelessTestOp.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StatelessTestOp.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamOpFlagTestHelper.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StreamOpFlagTestHelper.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamOpFlagTestHelper.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StreamOpFlagTestHelper.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamTestDataProvider.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StreamTestDataProvider.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamTestDataProvider.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StreamTestDataProvider.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamTestScenario.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StreamTestScenario.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamTestScenario.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StreamTestScenario.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/TestData.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/TestData.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/TestData.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/TestData.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/TestFlagExpectedOp.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/TestFlagExpectedOp.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/TestFlagExpectedOp.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/TestFlagExpectedOp.java
diff --git a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/ThrowableHelper.java b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/ThrowableHelper.java
similarity index 100%
rename from jdk/test/java/util/stream/bootlib/java.base/java/util/stream/ThrowableHelper.java
rename to jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/ThrowableHelper.java
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/IOUtils.java b/jdk/test/lib/testlibrary/jdk/testlibrary/IOUtils.java
deleted file mode 100644
index 4bfddd0..0000000
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/IOUtils.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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
- * 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.testlibrary;
-
-/**
- * Defines useful I/O methods.
- */
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-
-public final class IOUtils {
-
-    /*
-     * Prevent instantiation.
-     */
-    private IOUtils() {}
-
-    /**
-     * Read all bytes from <code>in</code>
-     * until EOF is detected.
-     * @param in input stream, must not be null
-     * @return bytes read
-     * @throws IOException Any IO error.
-     */
-    public static byte[] readFully(InputStream is) throws IOException {
-        byte[] output = {};
-        int pos = 0;
-        while (true) {
-            int bytesToRead;
-            if (pos >= output.length) { // Only expand when there's no room
-                bytesToRead = output.length + 1024;
-                if (output.length < pos + bytesToRead) {
-                    output = Arrays.copyOf(output, pos + bytesToRead);
-                }
-            } else {
-                bytesToRead = output.length - pos;
-            }
-            int cc = is.read(output, pos, bytesToRead);
-            if (cc < 0) {
-                if (output.length != pos) {
-                    output = Arrays.copyOf(output, pos);
-                }
-                break;
-            }
-            pos += cc;
-        }
-        return output;
-    }
-}
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java
index cd3b7ce..c19cb5d 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java
@@ -24,7 +24,6 @@
 package jdk.testlibrary;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -60,7 +59,6 @@
         } else {
             executable = JDKToolFinder.getTestJDKTool(tool);
         }
-        vmArgs.addAll(Arrays.asList(ProcessTools.getPlatformSpecificVMArgs()));
     }
 
     /**
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java
index d4626fa..4619773 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java
@@ -260,31 +260,13 @@
     }
 
     /**
-     * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris)
-     *
-     * @return String[] with platform specific arguments, empty if there are
-     *         none
-     */
-    public static String[] getPlatformSpecificVMArgs() {
-        String osName = System.getProperty("os.name");
-        String dataModel = System.getProperty("sun.arch.data.model");
-
-        if (osName.equals("SunOS") && dataModel.equals("64")) {
-            return new String[] { "-d64" };
-        }
-
-        return new String[] {};
-    }
-
-    /**
      * Create ProcessBuilder using the java launcher from the jdk to be tested,
      * and with any platform specific arguments prepended.
      *
      * @param command Arguments to pass to the java command.
      * @return The ProcessBuilder instance representing the java command.
      */
-    public static ProcessBuilder createJavaProcessBuilder(String... command)
-            throws Exception {
+    public static ProcessBuilder createJavaProcessBuilder(String... command) {
         return createJavaProcessBuilder(false, command);
     }
 
@@ -297,12 +279,11 @@
      * @param command Arguments to pass to the java command.
      * @return The ProcessBuilder instance representing the java command.
      */
-    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) throws Exception {
+    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) {
         String javapath = JDKToolFinder.getJDKTool("java");
 
         ArrayList<String> args = new ArrayList<>();
         args.add(javapath);
-        Collections.addAll(args, getPlatformSpecificVMArgs());
 
         if (addTestVmAndJavaOptions) {
             // -cp is needed to make sure the same classpath is used whether the test is
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/management/InputArguments.java b/jdk/test/lib/testlibrary/jdk/testlibrary/management/InputArguments.java
deleted file mode 100644
index 7fc2f67..0000000
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/management/InputArguments.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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
- * 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.testlibrary.management;
-
-import java.lang.management.RuntimeMXBean;
-import java.lang.management.ManagementFactory;
-import java.util.List;
-
-/**
- * This class provides access to the input arguments to the VM.
- */
-public class InputArguments {
-    private static final List<String> args;
-
-    static {
-        RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
-        args = runtimeMxBean.getInputArguments();
-    }
-
-    /**
-     * Returns true if {@code arg} is an input argument to the VM.
-     *
-     * This is useful for checking boolean flags such as -XX:+UseSerialGC or
-     * -XX:-UsePerfData.
-     *
-     * @param arg The name of the argument.
-     * @return {@code true} if the given argument is an input argument,
-     *         otherwise {@code false}.
-     */
-    public static boolean contains(String arg) {
-        return args.contains(arg);
-    }
-
-    /**
-     * Returns true if {@code prefix} is the start of an input argument to the
-     * VM.
-     *
-     * This is useful for checking if flags describing a quantity, such as
-     * -XX:+MaxMetaspaceSize=100m, is set without having to know the quantity.
-     * To check if the flag -XX:MaxMetaspaceSize is set, use
-     * {@code InputArguments.containsPrefix("-XX:MaxMetaspaceSize")}.
-     *
-     * @param prefix The start of the argument.
-     * @return {@code true} if the given argument is the start of an input
-     *         argument, otherwise {@code false}.
-     */
-    public static boolean hasArgStartingWith(String prefix) {
-        for (String arg : args) {
-            if (arg.startsWith(prefix)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Get the string containing input arguments passed to the VM
-     */
-    public static String getInputArguments() {
-        StringBuilder result = new StringBuilder();
-        for (String arg : args)
-            result.append(arg).append(' ');
-
-        return result.toString();
-    }
-
-}
diff --git a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java
index fbdad8c..be761a7 100644
--- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java
+++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java
@@ -31,9 +31,9 @@
  * @bug 6216082
  * @summary  Redirect problem with HttpsURLConnection using a proxy
  * @modules java.base/sun.net.www
- * @library .. /lib/testlibrary
+ * @library .. /test/lib
  * @build HttpCallback TestHttpsServer ClosedChannelList
- *        HttpTransaction TunnelProxy jdk.testlibrary.NetworkConfiguration
+ *        HttpTransaction TunnelProxy
  * @key intermittent
  * @run main/othervm B6216082
  */
@@ -43,7 +43,7 @@
 import javax.net.ssl.*;
 import java.util.*;
 
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 
 public class B6216082 {
     static SimpleHttpTransaction httpTrans;
diff --git a/jdk/test/sun/security/krb5/config/Include.java b/jdk/test/sun/security/krb5/config/Include.java
index b253b81..ee741c5 100644
--- a/jdk/test/sun/security/krb5/config/Include.java
+++ b/jdk/test/sun/security/krb5/config/Include.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8029994
+ * @bug 8029994 8177085
  * @summary Support "include" and "includedir" in krb5.conf
  * @modules java.security.jgss/sun.security.krb5
  * @compile -XDignore.symbol.file Include.java
@@ -35,6 +35,7 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
+import java.util.Arrays;
 
 public class Include {
     public static void main(String[] args) throws Exception {
@@ -43,13 +44,15 @@
 
         Path conf = Paths.get("krb5.conf");         // base krb5.conf
 
-        Path ifile = Paths.get("f");                // include f
-        Path idir = Paths.get("x");                 // includedir fx
-        Path idirdir = Paths.get("x/xx");           // sub dir, will be ignored
-        Path idirdirfile = Paths.get("x/xx/ff");    // sub dir, will be ignored
-        Path idirfile1 = Paths.get("x/f1");         // one file
-        Path idirfile2 = Paths.get("x/f2");         // another file
-        Path idirfile3 = Paths.get("x/f.3");        // third file bad name
+        Path f = Paths.get("f");            // include
+        Path f2 = Paths.get("f2");          // f include f2
+        Path d = Paths.get("d");            // includedir
+        Path dd = Paths.get("d/dd");        // sub dir, ignore
+        Path ddf = Paths.get("d/dd/ddf");   // file in sub dir, ignore
+        Path df1 = Paths.get("d/f1");       // one file in dir
+        Path df2 = Paths.get("d/f2");       // another file
+        Path df3 = Paths.get("d/f.3");      // third file bad name
+        Path df4 = Paths.get("d/f4.conf");  // fourth file
 
         // OK: The base file can be missing
         System.setProperty("java.security.krb5.conf", "no-such-file");
@@ -59,8 +62,8 @@
 
         // Write base file
         Files.write(conf,
-                ("include " + ifile.toAbsolutePath() + "\n" +
-                        "includedir " + idir.toAbsolutePath() + "\n" +
+                ("include " + f.toAbsolutePath() + "\n" +
+                        "includedir " + d.toAbsolutePath() + "\n" +
                         krb5Conf + "base").getBytes()
         );
 
@@ -68,54 +71,63 @@
         tryReload(false);
 
         // Error: Only includedir exists
-        Files.createDirectory(idir);
+        Files.createDirectory(d);
         tryReload(false);
 
         // Error: Both exists, but include is a cycle
-        Files.write(ifile,
+        Files.write(f,
                 ("include " + conf.toAbsolutePath() + "\n" +
-                    krb5Conf + "incfile").getBytes());
+                    krb5Conf + "f").getBytes());
         tryReload(false);
 
-        // Error: A good include exists, but no includedir
-        Files.delete(idir);
-        Files.write(ifile, (krb5Conf + "incfile").getBytes());
+        // Error: A good include exists, but no includedir yet
+        Files.delete(d);
+        Files.write(f, (krb5Conf + "f").getBytes());
         tryReload(false);
 
         // OK: Everything is set
-        Files.createDirectory(idir);
+        Files.createDirectory(d);
         tryReload(true);   // Now OK
 
+        // make f include f2
+        Files.write(f,
+                ("include " + f2.toAbsolutePath() + "\n" +
+                        krb5Conf + "f").getBytes());
+        Files.write(f2, (krb5Conf + "f2").getBytes());
         // fx1 and fx2 will be loaded
-        Files.write(idirfile1, (krb5Conf + "incdir1").getBytes());
-        Files.write(idirfile2, (krb5Conf + "incdir2").getBytes());
+        Files.write(df1, (krb5Conf + "df1").getBytes());
+        Files.write(df2, (krb5Conf + "df2").getBytes());
         // fx3 and fxs (and file inside it) will be ignored
-        Files.write(idirfile3, (krb5Conf + "incdir3").getBytes());
-        Files.createDirectory(idirdir);
-        Files.write(idirdirfile, (krb5Conf + "incdirdir").getBytes());
+        Files.write(df3, (krb5Conf + "df3").getBytes());
+        Files.createDirectory(dd);
+        Files.write(ddf, (krb5Conf + "ddf").getBytes());
+        // fx4 will be loaded
+        Files.write(df4, (krb5Conf + "df4").getBytes());
 
         // OK: All good files read
         tryReload(true);
 
-        String v = Config.getInstance().getAll("section", "key");
-        // The order of files in includedir could be either
-        if (!v.equals("incfile incdir1 incdir2 base") &&
-                !v.equals("incfile incdir2 incdir1 base")) {
-            throw new Exception(v);
+        String[] v = Config.getInstance().getAll("section", "key") .split(" ");
+        // v will contain f2, f, df[124], and base.
+        // Order of df[124] is not determined. Sort them first.
+        Arrays.sort(v, 2, 5);
+        String longv = Arrays.toString(v);
+        if (!longv.equals("[f2, f, df1, df2, df4, base]")) {
+            throw new Exception(longv);
         }
 
         // Error: include file not absolute
         Files.write(conf,
-                ("include " + ifile + "\n" +
-                        "includedir " + idir.toAbsolutePath() + "\n" +
+                ("include " + f + "\n" +
+                        "includedir " + d.toAbsolutePath() + "\n" +
                         krb5Conf + "base").getBytes()
         );
         tryReload(false);
 
         // Error: includedir not absolute
         Files.write(conf,
-                ("include " + ifile.toAbsolutePath() + "\n" +
-                        "includedir " + idir + "\n" +
+                ("include " + f.toAbsolutePath() + "\n" +
+                        "includedir " + d + "\n" +
                         krb5Conf + "base").getBytes()
         );
         tryReload(false);
diff --git a/jdk/test/sun/security/mscapi/KeyStoreEmptyCertChain.java b/jdk/test/sun/security/mscapi/KeyStoreEmptyCertChain.java
new file mode 100644
index 0000000..d603df9
--- /dev/null
+++ b/jdk/test/sun/security/mscapi/KeyStoreEmptyCertChain.java
@@ -0,0 +1,81 @@
+/*
+ * 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 8172244
+ * @summary Verify that no exception is thrown with empty cert chain
+ *    in MSCAPI.
+ * @requires os.family == "windows"
+ * @modules java.base/sun.security.tools.keytool java.base/sun.security.x509
+ * @run main/othervm --add-opens java.base/java.security=ALL-UNNAMED
+ *      KeyStoreEmptyCertChain
+ */
+
+import java.security.KeyStore;
+import java.security.cert.Certificate;
+import sun.security.x509.X500Name;
+import sun.security.tools.keytool.CertAndKeyGen;
+import java.security.KeyPairGenerator;
+import java.security.KeyPair;
+import java.security.PrivateKey;
+import java.security.KeyStoreSpi;
+import java.lang.reflect.*;
+
+public class KeyStoreEmptyCertChain {
+
+    public static void main(String[] args) {
+
+        try {
+
+            KeyStore keyStore = KeyStore.getInstance("Windows-MY", "SunMSCAPI");
+            keyStore.load(null, null);
+
+            // Generate a certificate to use for testing
+            CertAndKeyGen gen = new CertAndKeyGen("RSA", "SHA256withRSA");
+            gen.generate(2048);
+            Certificate cert =
+                gen.getSelfCertificate(new X500Name("CN=test"), 3600);
+            String alias = "JDK-8172244";
+            char[] password = "password".toCharArray();
+            KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
+
+            // generate a private key for the certificate
+            kpg.initialize(2048);
+            KeyPair keyPair = kpg.generateKeyPair();
+            PrivateKey privKey = keyPair.getPrivate();
+            // need to bypass checks to store the private key without the cert
+            Field spiField = KeyStore.class.getDeclaredField("keyStoreSpi");
+            spiField.setAccessible(true);
+            KeyStoreSpi spi = (KeyStoreSpi) spiField.get(keyStore);
+            spi.engineSetKeyEntry(alias, privKey, password, new Certificate[0]);
+            keyStore.store(null, null);
+
+            keyStore.getCertificateAlias(cert);
+            keyStore.deleteEntry(alias);
+            // test passes if no exception is thrown
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+}
diff --git a/jdk/test/sun/security/ssl/DHKeyExchange/DHEKeySizing.java b/jdk/test/sun/security/ssl/DHKeyExchange/DHEKeySizing.java
index 3b44931..c003377 100644
--- a/jdk/test/sun/security/ssl/DHKeyExchange/DHEKeySizing.java
+++ b/jdk/test/sun/security/ssl/DHKeyExchange/DHEKeySizing.java
@@ -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
  */
 
diff --git a/jdk/test/sun/security/ssl/DHKeyExchange/UseStrongDHSizes.java b/jdk/test/sun/security/ssl/DHKeyExchange/UseStrongDHSizes.java
new file mode 100644
index 0000000..5706f5c
--- /dev/null
+++ b/jdk/test/sun/security/ssl/DHKeyExchange/UseStrongDHSizes.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//
+// 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();
+    }
+}
diff --git a/jdk/test/sun/security/tools/jarsigner/EntriesOrder.java b/jdk/test/sun/security/tools/jarsigner/EntriesOrder.java
index 1b804bb..91eada8 100644
--- a/jdk/test/sun/security/tools/jarsigner/EntriesOrder.java
+++ b/jdk/test/sun/security/tools/jarsigner/EntriesOrder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,9 @@
  * @test
  * @bug 8031572
  * @summary jarsigner -verify exits with 0 when a jar file is not properly signed
- * @library /lib/testlibrary
  * @modules java.base/sun.security.tools.keytool
  *          jdk.jartool/sun.security.tools.jarsigner
  *          jdk.jartool/sun.tools.jar
- * @build jdk.testlibrary.IOUtils
  * @run main EntriesOrder
  */
 
@@ -45,8 +43,6 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
-import jdk.testlibrary.IOUtils;
-
 public class EntriesOrder {
 
     public static void main(String[] args) throws Exception {
@@ -114,7 +110,7 @@
                 Enumeration<JarEntry> jes = jf.entries();
                 while (jes.hasMoreElements()) {
                     JarEntry je = jes.nextElement();
-                    IOUtils.readFully(jf.getInputStream(je));
+                    jf.getInputStream(je).readAllBytes();
                     Certificate[] certs = je.getCertificates();
                     if (certs != null && certs.length > 0) {
                         cc++;
@@ -146,7 +142,7 @@
                 while (true) {
                     JarEntry je = jis.getNextJarEntry();
                     if (je == null) break;
-                    IOUtils.readFully(jis);
+                    jis.readAllBytes();
                     Certificate[] certs = je.getCertificates();
                     if (certs != null && certs.length > 0) {
                         cc++;
diff --git a/jdk/test/sun/security/tools/jarsigner/multiRelease/MVJarSigningTest.java b/jdk/test/sun/security/tools/jarsigner/multiRelease/MVJarSigningTest.java
index 6afeb27..57b2623 100644
--- a/jdk/test/sun/security/tools/jarsigner/multiRelease/MVJarSigningTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/multiRelease/MVJarSigningTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,7 +74,8 @@
     private static final String KEYPASS = "changeit";
     private static final String SIGNED_JAR = "Signed.jar";
     private static final String POLICY_FILE = "SignedJar.policy";
-    private static final String VERSION_MESSAGE = "I am running on version 9";
+    private static final String VERSION = "" + Runtime.version().major();
+    private static final String VERSION_MESSAGE = "I am running on version " + VERSION;
 
     public static void main(String[] args) throws Throwable {
         // compile java files in jarContent directory
diff --git a/jdk/test/sun/tools/jhsdb/AlternateHashingTest.java b/jdk/test/sun/tools/jhsdb/AlternateHashingTest.java
new file mode 100644
index 0000000..8333c66
--- /dev/null
+++ b/jdk/test/sun/tools/jhsdb/AlternateHashingTest.java
@@ -0,0 +1,128 @@
+/*
+ * 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 8030750
+ * @summary Test alternate hashing of strings in Serviceability Agent.
+ * @library /test/lib
+ * @library /lib/testlibrary
+ * @compile AlternateHashingTest.java
+ * @run main/timeout=240 AlternateHashingTest
+ */
+
+import java.io.BufferedReader;
+import java.io.OutputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.Arrays;
+import jdk.testlibrary.JDKToolLauncher;
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.Platform;
+
+public class AlternateHashingTest {
+
+    private static LingeredAppWithAltHashing theApp = null;
+
+    /**
+     *
+     * @param vmArgs  - tool arguments to launch jhsdb
+     * @return exit code of tool
+     */
+    public static void launch(String expectedMessage, String cmd) throws IOException {
+
+        System.out.println("Starting LingeredApp");
+        try {
+            theApp = new LingeredAppWithAltHashing();
+            LingeredApp.startApp(Arrays.asList("-Xmx256m"), theApp);
+
+            System.out.println("Starting clhsdb against " + theApp.getPid());
+            JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
+            launcher.addToolArg("clhsdb");
+            launcher.addToolArg("--pid=" + Long.toString(theApp.getPid()));
+
+            ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
+            processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
+            Process toolProcess = processBuilder.start();
+
+            try (OutputStream out = toolProcess.getOutputStream()) {
+                out.write(cmd.getBytes());
+                out.write("quit\n".getBytes());
+            }
+
+            boolean result = false;
+            try (BufferedReader reader =
+                 new BufferedReader(new InputStreamReader(toolProcess.getInputStream()))) {
+                String line;
+
+                while ((line = reader.readLine()) != null) {
+                    line = line.trim();
+                    System.out.println(line);
+
+                    if (line.contains(expectedMessage)) {
+                        result = true;
+                        break;
+                    }
+                }
+            }
+
+            toolProcess.waitFor();
+
+            if (toolProcess.exitValue() != 0) {
+                throw new RuntimeException("FAILED CLHSDB terminated with non-zero exit code " + toolProcess.exitValue());
+            }
+
+            if (!result) {
+                throw new RuntimeException(cmd + " command output is missing the message " + expectedMessage);
+            }
+
+        } catch (Exception ex) {
+            throw new RuntimeException("Test ERROR " + ex, ex);
+        } finally {
+            LingeredApp.stopApp(theApp);
+        }
+    }
+
+
+    public static void testAltHashing() throws IOException {
+
+        launch("Stack in use by Java", "threads\n");
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        if (!Platform.shouldSAAttach()) {
+            // Silently skip the test if we don't have enough permissions to attach
+            System.err.println("Error! Insufficient permissions to attach - test skipped.");
+            return;
+        }
+
+
+        testAltHashing();
+
+        // The test throws RuntimeException on error.
+        // IOException is thrown if LingeredApp can't start because of some bad
+        // environment condition
+        System.out.println("Test PASSED");
+    }
+}
diff --git a/jdk/test/sun/tools/jhsdb/LingeredAppWithAltHashing.java b/jdk/test/sun/tools/jhsdb/LingeredAppWithAltHashing.java
new file mode 100644
index 0000000..492cb84
--- /dev/null
+++ b/jdk/test/sun/tools/jhsdb/LingeredAppWithAltHashing.java
@@ -0,0 +1,161 @@
+/*
+ * 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 jdk.test.lib.apps.LingeredApp;
+
+public class LingeredAppWithAltHashing extends LingeredApp {
+
+    public static void main(String args[]) {
+        LingeredApp.main(args);
+    }
+
+    // Following strings generate the same hashcode
+
+    static final String str1 = "AaAaAaAaAaAaAa";
+    static final String str2 = "AaAaAaAaAaAaBB";
+    static final String str3 = "AaAaAaAaAaBBAa";
+    static final String str4 = "AaAaAaAaAaBBBB";
+    static final String str5 = "AaAaAaAaBBAaAa";
+    static final String str6 = "AaAaAaAaBBAaBB";
+    static final String str7 = "AaAaAaAaBBBBAa";
+    static final String str8 = "AaAaAaAaBBBBBB";
+    static final String str9 = "AaAaAaBBAaAaAa";
+    static final String str10 = "AaAaAaBBAaAaBB";
+    static final String str11 = "AaAaAaBBAaBBAa";
+    static final String str12 = "AaAaAaBBAaBBBB";
+    static final String str13 = "AaAaAaBBBBAaAa";
+    static final String str14 = "AaAaAaBBBBAaBB";
+    static final String str15 = "AaAaAaBBBBBBAa";
+    static final String str16 = "AaAaAaBBBBBBBB";
+    static final String str17 = "AaAaBBAaAaAaAa";
+    static final String str18 = "AaAaBBAaAaAaBB";
+    static final String str19 = "AaAaBBAaAaBBAa";
+    static final String str20 = "AaAaBBAaAaBBBB";
+    static final String str21 = "AaAaBBAaBBAaAa";
+    static final String str22 = "AaAaBBAaBBAaBB";
+    static final String str23 = "AaAaBBAaBBBBAa";
+    static final String str24 = "AaAaBBAaBBBBBB";
+    static final String str25 = "AaAaBBBBAaAaAa";
+    static final String str26 = "AaAaBBBBAaAaBB";
+    static final String str27 = "AaAaBBBBAaBBAa";
+    static final String str28 = "AaAaBBBBAaBBBB";
+    static final String str29 = "AaAaBBBBBBAaAa";
+    static final String str30 = "AaAaBBBBBBAaBB";
+    static final String str31 = "AaAaBBBBBBBBAa";
+    static final String str32 = "AaAaBBBBBBBBBB";
+    static final String str33 = "AaBBAaAaAaAaAa";
+    static final String str34 = "AaBBAaAaAaAaBB";
+    static final String str35 = "AaBBAaAaAaBBAa";
+    static final String str36 = "AaBBAaAaAaBBBB";
+    static final String str37 = "AaBBAaAaBBAaAa";
+    static final String str38 = "AaBBAaAaBBAaBB";
+    static final String str39 = "AaBBAaAaBBBBAa";
+    static final String str40 = "AaBBAaAaBBBBBB";
+    static final String str41 = "AaBBAaBBAaAaAa";
+    static final String str42 = "AaBBAaBBAaAaBB";
+    static final String str43 = "AaBBAaBBAaBBAa";
+    static final String str44 = "AaBBAaBBAaBBBB";
+    static final String str45 = "AaBBAaBBBBAaAa";
+    static final String str46 = "AaBBAaBBBBAaBB";
+    static final String str47 = "AaBBAaBBBBBBAa";
+    static final String str48 = "AaBBAaBBBBBBBB";
+    static final String str49 = "AaBBBBAaAaAaAa";
+    static final String str50 = "AaBBBBAaAaAaBB";
+    static final String str51 = "AaBBBBAaAaBBAa";
+    static final String str52 = "AaBBBBAaAaBBBB";
+    static final String str53 = "AaBBBBAaBBAaAa";
+    static final String str54 = "AaBBBBAaBBAaBB";
+    static final String str55 = "AaBBBBAaBBBBAa";
+    static final String str56 = "AaBBBBAaBBBBBB";
+    static final String str57 = "AaBBBBBBAaAaAa";
+    static final String str58 = "AaBBBBBBAaAaBB";
+    static final String str59 = "AaBBBBBBAaBBAa";
+    static final String str60 = "AaBBBBBBAaBBBB";
+    static final String str61 = "AaBBBBBBBBAaAa";
+    static final String str62 = "AaBBBBBBBBAaBB";
+    static final String str63 = "AaBBBBBBBBBBAa";
+    static final String str64 = "AaBBBBBBBBBBBB";
+    static final String str65 = "BBAaAaAaAaAaAa";
+    static final String str66 = "BBAaAaAaAaAaBB";
+    static final String str67 = "BBAaAaAaAaBBAa";
+    static final String str68 = "BBAaAaAaAaBBBB";
+    static final String str69 = "BBAaAaAaBBAaAa";
+    static final String str70 = "BBAaAaAaBBAaBB";
+    static final String str71 = "BBAaAaAaBBBBAa";
+    static final String str72 = "BBAaAaAaBBBBBB";
+    static final String str73 = "BBAaAaBBAaAaAa";
+    static final String str74 = "BBAaAaBBAaAaBB";
+    static final String str75 = "BBAaAaBBAaBBAa";
+    static final String str76 = "BBAaAaBBAaBBBB";
+    static final String str77 = "BBAaAaBBBBAaAa";
+    static final String str78 = "BBAaAaBBBBAaBB";
+    static final String str79 = "BBAaAaBBBBBBAa";
+    static final String str80 = "BBAaAaBBBBBBBB";
+    static final String str81 = "BBAaBBAaAaAaAa";
+    static final String str82 = "BBAaBBAaAaAaBB";
+    static final String str83 = "BBAaBBAaAaBBAa";
+    static final String str84 = "BBAaBBAaAaBBBB";
+    static final String str85 = "BBAaBBAaBBAaAa";
+    static final String str86 = "BBAaBBAaBBAaBB";
+    static final String str87 = "BBAaBBAaBBBBAa";
+    static final String str88 = "BBAaBBAaBBBBBB";
+    static final String str89 = "BBAaBBBBAaAaAa";
+    static final String str90 = "BBAaBBBBAaAaBB";
+    static final String str91 = "BBAaBBBBAaBBAa";
+    static final String str92 = "BBAaBBBBAaBBBB";
+    static final String str93 = "BBAaBBBBBBAaAa";
+    static final String str94 = "BBAaBBBBBBAaBB";
+    static final String str95 = "BBAaBBBBBBBBAa";
+    static final String str96 = "BBAaBBBBBBBBBB";
+    static final String str97 = "BBBBAaAaAaAaAa";
+    static final String str98 = "BBBBAaAaAaAaBB";
+    static final String str99 = "BBBBAaAaAaBBAa";
+    static final String str100 = "BBBBAaAaAaBBBB";
+    static final String str101 = "BBBBAaAaBBAaAa";
+    static final String str102 = "BBBBAaAaBBAaBB";
+    static final String str103 = "BBBBAaAaBBBBAa";
+    static final String str104 = "BBBBAaAaBBBBBB";
+    static final String str105 = "BBBBAaBBAaAaAa";
+    static final String str106 = "BBBBAaBBAaAaBB";
+    static final String str107 = "BBBBAaBBAaBBAa";
+    static final String str108 = "BBBBAaBBAaBBBB";
+    static final String str109 = "BBBBAaBBBBAaAa";
+    static final String str110 = "BBBBAaBBBBAaBB";
+    static final String str111 = "BBBBAaBBBBBBAa";
+    static final String str112 = "BBBBAaBBBBBBBB";
+    static final String str113 = "BBBBBBAaAaAaAa";
+    static final String str114 = "BBBBBBAaAaAaBB";
+    static final String str115 = "BBBBBBAaAaBBAa";
+    static final String str116 = "BBBBBBAaAaBBBB";
+    static final String str117 = "BBBBBBAaBBAaAa";
+    static final String str118 = "BBBBBBAaBBAaBB";
+    static final String str119 = "BBBBBBAaBBBBAa";
+    static final String str120 = "BBBBBBAaBBBBBB";
+    static final String str121 = "BBBBBBBBAaAaAa";
+    static final String str122 = "BBBBBBBBAaAaBB";
+    static final String str123 = "BBBBBBBBAaBBAa";
+    static final String str124 = "BBBBBBBBAaBBBB";
+    static final String str125 = "BBBBBBBBBBAaAa";
+    static final String str126 = "BBBBBBBBBBAaBB";
+    static final String str127 = "BBBBBBBBBBBBAa";
+    static final String str128 = "BBBBBBBBBBBBBB";
+ }
diff --git a/jdk/test/tools/jmod/hashes/HashesTest.java b/jdk/test/tools/jmod/hashes/HashesTest.java
index 1068092..e71efe9 100644
--- a/jdk/test/tools/jmod/hashes/HashesTest.java
+++ b/jdk/test/tools/jmod/hashes/HashesTest.java
@@ -25,13 +25,12 @@
  * @test
  * @bug 8160286
  * @summary Test the recording and checking of module hashes
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          java.base/jdk.internal.module
  *          jdk.compiler
  *          jdk.jartool
  *          jdk.jlink
- * @build CompilerUtils ModuleInfoMaker
  * @run testng HashesTest
  */
 
@@ -62,6 +61,8 @@
 import jdk.internal.module.ModuleHashes;
 import jdk.internal.module.ModulePath;
 
+import jdk.test.lib.compiler.ModuleInfoMaker;
+
 import org.testng.annotations.Test;
 
 import static org.testng.Assert.*;
@@ -382,7 +383,7 @@
         makeModule(mn, null, deps);
     }
 
-    private void makeModule(String mn, ModuleDescriptor.Requires.Modifier mod,  String... deps)
+    private void makeModule(String mn, ModuleDescriptor.Requires.Modifier mod, String... deps)
         throws IOException
     {
         if (mod != null && mod != TRANSITIVE && mod != STATIC) {
@@ -390,23 +391,23 @@
         }
 
         StringBuilder sb = new StringBuilder();
-        sb.append("module " + mn + " {").append("\n");
-        Arrays.stream(deps).forEach(req -> {
-            sb.append("    requires ");
-            if (mod != null) {
-                sb.append(mod.toString().toLowerCase()).append(" ");
-            }
-            sb.append(req + ";\n");
-        });
+        sb.append("module ")
+          .append(mn)
+          .append(" {")
+          .append("\n");
+        Arrays.stream(deps)
+              .forEach(req -> {
+                  sb.append("    requires ");
+                  if (mod != null) {
+                      sb.append(mod.toString().toLowerCase())
+                        .append(" ");
+                  }
+                  sb.append(req)
+                    .append(";\n");
+              });
         sb.append("}\n");
         builder.writeJavaFiles(mn, sb.toString());
-
-        compileModule(mn, srcDir);
-    }
-
-    private void compileModule(String moduleName, Path src) throws IOException {
-        Path msrc = src.resolve(moduleName);
-        assertTrue(CompilerUtils.compile(msrc, mods, "--module-source-path", src.toString()));
+        builder.compile(mn, mods);
     }
 
     private void jmodHashModules(String moduleName, String hashModulesPattern) {
diff --git a/jdk/test/tools/launcher/ChangeDataModel.java b/jdk/test/tools/launcher/ChangeDataModel.java
index 31ee6f8..e6bc281 100644
--- a/jdk/test/tools/launcher/ChangeDataModel.java
+++ b/jdk/test/tools/launcher/ChangeDataModel.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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();
-
-        // 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");
-        }
+        new ChangeDataModel().run(args);
     }
 
-    static void checkAcceptance(String cmd, String dmodel) {
-        TestResult tr = doExec(cmd, dmodel, "-jar", TestJar.getAbsolutePath());
-        if (!tr.contains(OPT_PREFIX + dmodel)) {
+    @Test
+    public void check32bitRejection() throws Exception {
+        checkRejection("-d32");
+    }
+
+    @Test
+    public void check64bitRejection() throws Exception {
+        checkRejection("-d64");
+    }
+
+    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());
-    }
 }
diff --git a/jdk/test/tools/launcher/Test7029048.java b/jdk/test/tools/launcher/Test7029048.java
index 1a32322..b9d70ae 100644
--- a/jdk/test/tools/launcher/Test7029048.java
+++ b/jdk/test/tools/launcher/Test7029048.java
@@ -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());
diff --git a/jdk/test/tools/launcher/modules/addexports/AddExportsTestWarningError.java b/jdk/test/tools/launcher/modules/addexports/AddExportsTestWarningError.java
index 0a20fec..66c4930 100644
--- a/jdk/test/tools/launcher/modules/addexports/AddExportsTestWarningError.java
+++ b/jdk/test/tools/launcher/modules/addexports/AddExportsTestWarningError.java
@@ -25,9 +25,8 @@
  * @test
  * @bug 8168836
  * @summary Basic argument validation for --add-exports
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build AddExportsTestWarningError CompilerUtils ModuleInfoMaker
  * @build jdk.testlibrary.*
  * @run testng AddExportsTestWarningError
  */
@@ -40,6 +39,7 @@
 import java.util.Arrays;
 import java.util.stream.Stream;
 
+import jdk.test.lib.compiler.ModuleInfoMaker;
 import jdk.testlibrary.OutputAnalyzer;
 import static jdk.testlibrary.ProcessTools.*;
 
@@ -48,7 +48,6 @@
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
-
 @Test
 public class AddExportsTestWarningError {
 
diff --git a/jdk/test/tools/launcher/modules/addreads/AddReadsTestWarningError.java b/jdk/test/tools/launcher/modules/addreads/AddReadsTestWarningError.java
index 6c9ee56..079accc 100644
--- a/jdk/test/tools/launcher/modules/addreads/AddReadsTestWarningError.java
+++ b/jdk/test/tools/launcher/modules/addreads/AddReadsTestWarningError.java
@@ -25,9 +25,9 @@
  * @test
  * @bug 8168836
  * @summary  Basic argument validation for --add-reads
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build AddReadsTestWarningError CompilerUtils ModuleInfoMaker
+ * @build AddReadsTestWarningError
  * @build jdk.testlibrary.*
  * @run testng AddReadsTestWarningError
  */
@@ -40,6 +40,7 @@
 import java.util.Arrays;
 import java.util.stream.Stream;
 
+import jdk.test.lib.compiler.ModuleInfoMaker;
 import jdk.testlibrary.OutputAnalyzer;
 import static jdk.testlibrary.ProcessTools.*;
 
@@ -48,7 +49,6 @@
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
-
 @Test
 public class AddReadsTestWarningError {
 
diff --git a/langtools/.hgtags b/langtools/.hgtags
index f6415c8..3e74be3 100644
--- a/langtools/.hgtags
+++ b/langtools/.hgtags
@@ -396,9 +396,11 @@
 4f348bd05341581df84ff1510d5b3a9b5b488367 jdk-9+151
 5b6f12de6f9167a582fa2c6ac54e69c591b09e68 jdk-9+152
 03f48cd283f5dd6b7153fd7e0cf2df8582b14391 jdk-9+153
+b670e95106f5327a29e2e2c4f18ee48a8d36e481 jdk-10+0
 6a9dd3d893b0a493a3e5d8d392815b5ee76a02d9 jdk-9+154
 dfcfdb2db85f1bb434209f56ca557ea6f9830aa8 jdk-9+155
 6f91e41163bc09e9b3ec72e8d1185f39296ee5d4 jdk-9+156
+ce999290d1c31bf8b28c51b1890268cc73cd4722 jdk-10+1
 162b521af7bb097019a8afaa44e1f8069ce274eb jdk-9+157
 4eb737a8d439f49a197e8000de26c6580cb4d57b jdk-9+158
 39449d2a6398fee779630f041c55c0466f5fd2c0 jdk-9+159
@@ -409,6 +411,14 @@
 c7f3df19667b093538c6eecb73dcb3fb531706b4 jdk-9+164
 98108b7d4cb6078773e2d27ad8471dc25d4d6124 jdk-9+165
 2a8b403a623320479705aad04ed8d78396661eb7 jdk-9+166
+657b68876fe39c6104c8a6350b746203edfd9da2 jdk-10+2
+e5689e13301ec65d8fba8ae7e581b1cb3bf5a391 jdk-10+3
+ef9180164e0847387519152d08bbcbcf9da0606d jdk-10+4
+6190dbeac954c5efd64201a8ab04d393330ff192 jdk-10+5
+2b33ceb2cee7ba561657ed69fcb14d6cf0543f3d jdk-10+6
 f260f1a2acf616509a4ee5a29bc7f2acca3853e3 jdk-9+167
 bc21e5ba6bf1538551093f57fa0f1a6571be05cc jdk-9+168
 0e522ff8b9f52a9d4929af9a6aa84110f4dcd81d jdk-9+169
+18355c879c69a33167f1862896738a7b9a4da729 jdk-9+170
+85581ae8a97f20fd2f817a71eb3cd7b04e492722 jdk-10+7
+6d9a33d72d0647f3981c9d9c636a6f1290689895 jdk-10+8
diff --git a/langtools/.jcheck/conf b/langtools/.jcheck/conf
index 5c6f62d..b258135 100644
--- a/langtools/.jcheck/conf
+++ b/langtools/.jcheck/conf
@@ -1 +1 @@
-project=jdk9
+project=jdk10
diff --git a/langtools/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java b/langtools/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
index 768c7ba..46538f1 100644
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java
@@ -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
@@ -56,6 +56,7 @@
      * 1.7: diamond syntax, try-with-resources, etc.
      * 1.8: lambda expressions and default methods
      *   9: modules, small cleanups to 1.7 and 1.8 changes
+     *  10: to-be-determined changes
      */
 
     /**
@@ -150,7 +151,15 @@
      *
      * @since 9
      */
-     RELEASE_9;
+     RELEASE_9,
+
+    /**
+     * The version recognized by the Java Platform, Standard Edition
+     * 10.
+     *
+     * @since 10
+     */
+     RELEASE_10;
 
     // Note that when adding constants for newer releases, the
     // behavior of latest() and latestSupported() must be updated too.
@@ -161,7 +170,7 @@
      * @return the latest source version that can be modeled
      */
     public static SourceVersion latest() {
-        return RELEASE_9;
+        return RELEASE_10;
     }
 
     private static final SourceVersion latestSupported = getLatestSupported();
@@ -171,6 +180,8 @@
             String specVersion = System.getProperty("java.specification.version");
 
             switch (specVersion) {
+                case "10":
+                    return RELEASE_10;
                 case "9":
                 case "1.9":
                     return RELEASE_9;
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
index 91a4bda..9be0a08 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -70,8 +70,11 @@
     /** 1.8 lambda expressions and default methods. */
     JDK1_8("1.8"),
 
-    /** 1.9 covers the to be determined language features that will be added in JDK 9. */
-    JDK1_9("1.9");
+    /** 1.9 modularity. */
+    JDK1_9("1.9"),
+
+    /** 1.10 covers the to be determined language features that will be added in JDK 10. */
+    JDK1_10("1.10");
 
     private static final Context.Key<Source> sourceKey = new Context.Key<>();
 
@@ -99,6 +102,7 @@
         tab.put("7", JDK1_7); // Make 7 an alias for 1.7
         tab.put("8", JDK1_8); // Make 8 an alias for 1.8
         tab.put("9", JDK1_9); // Make 9 an alias for 1.9
+        tab.put("10", JDK1_10); // Make 10 an alias for 1.10
     }
 
     private Source(String name) {
@@ -116,6 +120,7 @@
     }
 
     public Target requiredTarget() {
+        if (this.compareTo(JDK1_10) >= 0) return Target.JDK1_10;
         if (this.compareTo(JDK1_9) >= 0) return Target.JDK1_9;
         if (this.compareTo(JDK1_8) >= 0) return Target.JDK1_8;
         if (this.compareTo(JDK1_7) >= 0) return Target.JDK1_7;
@@ -240,6 +245,8 @@
             return RELEASE_8;
         case JDK1_9:
             return RELEASE_9;
+        case JDK1_10:
+            return RELEASE_10;
         default:
             return null;
         }
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstFold.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstFold.java
index 3436c18..e85a75e 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstFold.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstFold.java
@@ -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
@@ -73,24 +73,6 @@
     private static float floatValue(Object x) { return ((Number)x).floatValue(); }
     private static double doubleValue(Object x) { return ((Number)x).doubleValue(); }
 
-    /** Fold binary or unary operation, returning constant type reflecting the
-     *  operations result. Return null if fold failed due to an
-     *  arithmetic exception.
-     *  @param opcode    The operation's opcode instruction (usually a byte code),
-     *                   as entered by class Symtab.
-     *  @param argtypes  The operation's argument types (a list of length 1 or 2).
-     *                   Argument types are assumed to have non-null constValue's.
-     */
-    Type fold(int opcode, List<Type> argtypes) {
-        int argCount = argtypes.length();
-        if (argCount == 1)
-            return fold1(opcode, argtypes.head);
-        else if (argCount == 2)
-            return fold2(opcode, argtypes.head, argtypes.tail.head);
-        else
-            throw new AssertionError();
-    }
-
     /** Fold unary operation.
      *  @param opcode    The operation's opcode instruction (usually a byte code),
      *                   as entered by class Symtab.
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Env.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Env.java
index e189d99..d2848dc 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Env.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Env.java
@@ -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
@@ -126,10 +126,6 @@
     public String toString() {
         StringBuilder sb = new StringBuilder();
         sb.append("Env[").append(info);
-//        if (enclMethod != null)
-//            sb.append(",enclMethod=").append(Pretty.toSimpleString(enclMethod));
-//        if (enclClass != null)
-//            sb.append(",enclClass=").append(Pretty.toSimpleString(enclClass));
         if (outer != null)
             sb.append(",outer=").append(outer);
         sb.append("]");
@@ -149,7 +145,6 @@
                     return current;
                 }
                 throw new NoSuchElementException();
-
             }
             public void remove() {
                 throw new UnsupportedOperationException();
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java
index e369c04..641283a 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1755,23 +1755,6 @@
                 }
 
                 /**
-                 * Compute closure of a give node, by recursively walking
-                 * through all its dependencies (of given kinds)
-                 */
-                protected Set<Node> closure() {
-                    boolean progress = true;
-                    Set<Node> closure = new HashSet<>();
-                    closure.add(this);
-                    while (progress) {
-                        progress = false;
-                        for (Node n1 : new HashSet<>(closure)) {
-                            progress = closure.addAll(n1.deps);
-                        }
-                    }
-                    return closure;
-                }
-
-                /**
                  * Is this node a leaf? This means either the node has no dependencies,
                  * or it just has self-dependencies.
                  */
@@ -1906,10 +1889,13 @@
                     Type i = n_i.data.first();
                     for (Node n_j : nodes) {
                         Type j = n_j.data.first();
-                        UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
-                        if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
-                            //update i's bound dependencies
-                            n_i.addDependency(n_j);
+                        // don't compare a variable to itself
+                        if (i != j) {
+                            UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
+                            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
+                                //update i's bound dependencies
+                                n_i.addDependency(n_j);
+                            }
                         }
                     }
                 }
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
index 7868d9e..2f3448a 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -772,13 +772,6 @@
     /**
      * Create new synthetic variable with given flags, name, type, owner
      */
-    private VarSymbol makeSyntheticVar(long flags, String name, Type type, Symbol owner) {
-        return makeSyntheticVar(flags, names.fromString(name), type, owner);
-    }
-
-    /**
-     * Create new synthetic variable with given flags, name, type, owner
-     */
     private VarSymbol makeSyntheticVar(long flags, Name name, Type type, Symbol owner) {
         return new VarSymbol(flags | SYNTHETIC, name, type, owner);
     }
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java
index 180423d..1fd4343 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -760,18 +760,6 @@
         return rs.resolveInternalMethod(pos, attrEnv, qual, name, args, List.nil());
     }
 
-    /** Look up a constructor.
-     */
-    private MethodSymbol lookupConstructor(DiagnosticPosition pos, Type qual, List<Type> args) {
-        return rs.resolveInternalConstructor(pos, attrEnv, qual, args, null);
-    }
-
-    /** Look up a field.
-     */
-    private VarSymbol lookupField(DiagnosticPosition pos, Type qual, Name name) {
-        return rs.resolveInternalField(pos, attrEnv, qual, name);
-    }
-
     /** Anon inner classes are used as access constructor tags.
      * accessConstructorTag will use an existing anon class if one is available,
      * and synthethise a class (with makeEmptyClass) if one is not available.
@@ -1908,181 +1896,12 @@
         return makeEmptyClass(STATIC | SYNTHETIC, clazz).sym;
     }
 
-    /** Return symbol for "class$" method. If there is no method definition
-     *  for class$, construct one as follows:
-     *
-     *    class class$(String x0) {
-     *      try {
-     *        return Class.forName(x0);
-     *      } catch (ClassNotFoundException x1) {
-     *        throw new NoClassDefFoundError(x1.getMessage());
-     *      }
-     *    }
-     */
-    private MethodSymbol classDollarSym(DiagnosticPosition pos) {
-        ClassSymbol outerCacheClass = outerCacheClass();
-        MethodSymbol classDollarSym =
-            (MethodSymbol)lookupSynthetic(classDollar,
-                                          outerCacheClass.members());
-        if (classDollarSym == null) {
-            classDollarSym = new MethodSymbol(
-                STATIC | SYNTHETIC,
-                classDollar,
-                new MethodType(
-                    List.of(syms.stringType),
-                    types.erasure(syms.classType),
-                    List.nil(),
-                    syms.methodClass),
-                outerCacheClass);
-            enterSynthetic(pos, classDollarSym, outerCacheClass.members());
-
-            JCMethodDecl md = make.MethodDef(classDollarSym, null);
-            try {
-                md.body = classDollarSymBody(pos, md);
-            } catch (CompletionFailure ex) {
-                md.body = make.Block(0, List.nil());
-                chk.completionError(pos, ex);
-            }
-            JCClassDecl outerCacheClassDef = classDef(outerCacheClass);
-            outerCacheClassDef.defs = outerCacheClassDef.defs.prepend(md);
-        }
-        return classDollarSym;
-    }
-
-    /** Generate code for class$(String name). */
-    JCBlock classDollarSymBody(DiagnosticPosition pos, JCMethodDecl md) {
-        MethodSymbol classDollarSym = md.sym;
-        ClassSymbol outerCacheClass = (ClassSymbol)classDollarSym.owner;
-
-        JCBlock returnResult;
-
-        // cache the current loader in cl$
-        // clsym = "private static ClassLoader cl$"
-        VarSymbol clsym = new VarSymbol(STATIC | SYNTHETIC,
-                                        names.fromString("cl" + target.syntheticNameChar()),
-                                        syms.classLoaderType,
-                                        outerCacheClass);
-        enterSynthetic(pos, clsym, outerCacheClass.members());
-
-        // emit "private static ClassLoader cl$;"
-        JCVariableDecl cldef = make.VarDef(clsym, null);
-        JCClassDecl outerCacheClassDef = classDef(outerCacheClass);
-        outerCacheClassDef.defs = outerCacheClassDef.defs.prepend(cldef);
-
-        // newcache := "new cache$1[0]"
-        JCNewArray newcache = make.NewArray(make.Type(outerCacheClass.type),
-                                            List.of(make.Literal(INT, 0).setType(syms.intType)),
-                                            null);
-        newcache.type = new ArrayType(types.erasure(outerCacheClass.type),
-                                      syms.arrayClass);
-
-        // forNameSym := java.lang.Class.forName(
-        //     String s,boolean init,ClassLoader loader)
-        Symbol forNameSym = lookupMethod(make_pos, names.forName,
-                                         types.erasure(syms.classType),
-                                         List.of(syms.stringType,
-                                                 syms.booleanType,
-                                                 syms.classLoaderType));
-        // clvalue := "(cl$ == null) ?
-        // $newcache.getClass().getComponentType().getClassLoader() : cl$"
-        JCExpression clvalue =
-                make.Conditional(
-                        makeBinary(EQ, make.Ident(clsym), makeNull()),
-                        make.Assign(make.Ident(clsym),
-                                    makeCall(
-                                            makeCall(makeCall(newcache,
-                                                              names.getClass,
-                                                              List.nil()),
-                                                     names.getComponentType,
-                                                     List.nil()),
-                                            names.getClassLoader,
-                                            List.nil())).setType(syms.classLoaderType),
-                        make.Ident(clsym)).setType(syms.classLoaderType);
-
-        // returnResult := "{ return Class.forName(param1, false, cl$); }"
-        List<JCExpression> args = List.of(make.Ident(md.params.head.sym),
-                                          makeLit(syms.booleanType, 0),
-                                          clvalue);
-        returnResult = make.Block(0, List.of(make.Call(make.App(make.Ident(forNameSym), args))));
-
-        // catchParam := ClassNotFoundException e1
-        VarSymbol catchParam =
-            new VarSymbol(SYNTHETIC, make.paramName(1),
-                          syms.classNotFoundExceptionType,
-                          classDollarSym);
-
-        JCStatement rethrow;
-        // rethrow = "throw new NoClassDefFoundError().initCause(e);
-        JCExpression throwExpr =
-            makeCall(makeNewClass(syms.noClassDefFoundErrorType,
-                                  List.nil()),
-                     names.initCause,
-                     List.of(make.Ident(catchParam)));
-        rethrow = make.Throw(throwExpr);
-
-        // rethrowStmt := "( $rethrow )"
-        JCBlock rethrowStmt = make.Block(0, List.of(rethrow));
-
-        // catchBlock := "catch ($catchParam) $rethrowStmt"
-        JCCatch catchBlock = make.Catch(make.VarDef(catchParam, null),
-                                      rethrowStmt);
-
-        // tryCatch := "try $returnResult $catchBlock"
-        JCStatement tryCatch = make.Try(returnResult,
-                                        List.of(catchBlock), null);
-
-        return make.Block(0, List.of(tryCatch));
-    }
-    // where
-        /** Create an attributed tree of the form left.name(). */
-        private JCMethodInvocation makeCall(JCExpression left, Name name, List<JCExpression> args) {
-            Assert.checkNonNull(left.type);
-            Symbol funcsym = lookupMethod(make_pos, name, left.type,
-                                          TreeInfo.types(args));
-            return make.App(make.Select(left, funcsym), args);
-        }
-
-    /** The Name Of The variable to cache T.class values.
-     *  @param sig      The signature of type T.
-     */
-    private Name cacheName(String sig) {
-        StringBuilder buf = new StringBuilder();
-        if (sig.startsWith("[")) {
-            buf = buf.append("array");
-            while (sig.startsWith("[")) {
-                buf = buf.append(target.syntheticNameChar());
-                sig = sig.substring(1);
-            }
-            if (sig.startsWith("L")) {
-                sig = sig.substring(0, sig.length() - 1);
-            }
-        } else {
-            buf = buf.append("class" + target.syntheticNameChar());
-        }
-        buf = buf.append(sig.replace('.', target.syntheticNameChar()));
-        return names.fromString(buf.toString());
-    }
-
-    /** The variable symbol that caches T.class values.
-     *  If none exists yet, create a definition.
-     *  @param sig      The signature of type T.
-     *  @param pos      The position to report diagnostics, if any.
-     */
-    private VarSymbol cacheSym(DiagnosticPosition pos, String sig) {
-        ClassSymbol outerCacheClass = outerCacheClass();
-        Name cname = cacheName(sig);
-        VarSymbol cacheSym =
-            (VarSymbol)lookupSynthetic(cname, outerCacheClass.members());
-        if (cacheSym == null) {
-            cacheSym = new VarSymbol(
-                STATIC | SYNTHETIC, cname, types.erasure(syms.classType), outerCacheClass);
-            enterSynthetic(pos, cacheSym, outerCacheClass.members());
-
-            JCVariableDecl cacheDef = make.VarDef(cacheSym, null);
-            JCClassDecl outerCacheClassDef = classDef(outerCacheClass);
-            outerCacheClassDef.defs = outerCacheClassDef.defs.prepend(cacheDef);
-        }
-        return cacheSym;
+    /** Create an attributed tree of the form left.name(). */
+    private JCMethodInvocation makeCall(JCExpression left, Name name, List<JCExpression> args) {
+        Assert.checkNonNull(left.type);
+        Symbol funcsym = lookupMethod(make_pos, name, left.type,
+                                      TreeInfo.types(args));
+        return make.App(make.Select(left, funcsym), args);
     }
 
     /** The tree simulating a T.class expression.
@@ -2319,16 +2138,6 @@
 
     /** Visitor method: Translate list of trees.
      */
-    public <T extends JCTree> List<T> translate(List<T> trees, JCExpression enclOp) {
-        JCExpression prevEnclOp = this.enclOp;
-        this.enclOp = enclOp;
-        List<T> res = translate(trees);
-        this.enclOp = prevEnclOp;
-        return res;
-    }
-
-    /** Visitor method: Translate list of trees.
-     */
     public <T extends JCExpression> List<T> translate(List<T> trees, Type type) {
         if (trees == null) return null;
         for (List<T> l = trees; l.nonEmpty(); l = l.tail)
@@ -2949,7 +2758,6 @@
     /** Visitor method for assert statements. Translate them away.
      */
     public void visitAssert(JCAssert tree) {
-        DiagnosticPosition detailPos = (tree.detail == null) ? tree.pos() : tree.detail.pos();
         tree.cond = translate(tree.cond, syms.booleanType);
         if (!tree.cond.type.isTrue()) {
             JCExpression cond = assertFlagTest(tree.pos());
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java
index 9b5da2b..fb0d09d 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java
@@ -223,20 +223,11 @@
         private static final String XMODULES_PREFIX = "-Xmodule:";
 
     int depth = -1;
-    private void dprintln(String msg) {
-        for (int i = 0; i < depth; i++)
-            System.err.print("  ");
-        System.err.println(msg);
-    }
 
     public void addExtraAddModules(String... extras) {
         extraAddMods.addAll(Arrays.asList(extras));
     }
 
-    public void addExtraLimitModules(String... extras) {
-        extraLimitMods.addAll(Arrays.asList(extras));
-    }
-
     boolean inInitModules;
     public void initModules(List<JCCompilationUnit> trees) {
         Assert.check(!inInitModules);
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
index 5f1de99..1452275 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
@@ -840,14 +840,6 @@
         }
     };
 
-    List<Type> dummyArgs(int length) {
-        ListBuffer<Type> buf = new ListBuffer<>();
-        for (int i = 0 ; i < length ; i++) {
-            buf.append(Type.noType);
-        }
-        return buf.toList();
-    }
-
     /**
      * Main method applicability routine. Given a list of actual types A,
      * a list of formal types F, determines whether the types in A are
@@ -4705,20 +4697,6 @@
                 this.mtype = mtype;
             }
 
-            @Override
-            public boolean equals(Object o) {
-                if (o instanceof Candidate) {
-                    Symbol s1 = this.sym;
-                    Symbol s2 = ((Candidate)o).sym;
-                    if  ((s1 != s2 &&
-                            (s1.overrides(s2, s1.owner.type.tsym, types, false) ||
-                            (s2.overrides(s1, s2.owner.type.tsym, types, false)))) ||
-                            ((s1.isConstructor() || s2.isConstructor()) && s1.owner != s2.owner))
-                        return true;
-                }
-                return false;
-            }
-
             boolean isApplicable() {
                 return mtype != null;
             }
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java
index 2230fc7..c8a63a2 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java
@@ -25,6 +25,7 @@
 
 package com.sun.tools.javac.jvm;
 
+import com.sun.tools.javac.tree.TreeInfo.PosKind;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.List;
@@ -1399,12 +1400,16 @@
                                   catchallpc, 0);
                     startseg = env.info.gaps.next().intValue();
                 }
-                code.statBegin(TreeInfo.finalizerPos(env.tree));
+                code.statBegin(TreeInfo.finalizerPos(env.tree, PosKind.FIRST_STAT_POS));
                 code.markStatBegin();
 
                 Item excVar = makeTemp(syms.throwableType);
                 excVar.store();
                 genFinalizer(env);
+                code.resolvePending();
+                code.statBegin(TreeInfo.finalizerPos(env.tree, PosKind.END_POS));
+                code.markStatBegin();
+
                 excVar.load();
                 registerCatch(body.pos(), startseg,
                               env.info.gaps.next().intValue(),
@@ -1418,7 +1423,7 @@
                     code.resolve(env.info.cont);
 
                     // Mark statement line number
-                    code.statBegin(TreeInfo.finalizerPos(env.tree));
+                    code.statBegin(TreeInfo.finalizerPos(env.tree, PosKind.FIRST_STAT_POS));
                     code.markStatBegin();
 
                     // Save return address.
@@ -1577,14 +1582,18 @@
     }
 
     public void visitBreak(JCBreak tree) {
+        int tmpPos = code.pendingStatPos;
         Env<GenContext> targetEnv = unwind(tree.target, env);
+        code.pendingStatPos = tmpPos;
         Assert.check(code.state.stacksize == 0);
         targetEnv.info.addExit(code.branch(goto_));
         endFinalizerGaps(env, targetEnv);
     }
 
     public void visitContinue(JCContinue tree) {
+        int tmpPos = code.pendingStatPos;
         Env<GenContext> targetEnv = unwind(tree.target, env);
+        code.pendingStatPos = tmpPos;
         Assert.check(code.state.stacksize == 0);
         targetEnv.info.addCont(code.branch(goto_));
         endFinalizerGaps(env, targetEnv);
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java
index cb7c714..1dceec9 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, 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
@@ -40,9 +40,9 @@
  *  deletion without notice.</b>
  */
 public enum Profile {
-    COMPACT1("compact1", 1, Target.JDK1_8, Target.JDK1_9),
-    COMPACT2("compact2", 2, Target.JDK1_8, Target.JDK1_9),
-    COMPACT3("compact3", 3, Target.JDK1_8, Target.JDK1_9),
+    COMPACT1("compact1", 1, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10),
+    COMPACT2("compact2", 2, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10),
+    COMPACT3("compact3", 3, Target.JDK1_8, Target.JDK1_9, Target.JDK1_10),
 
     DEFAULT {
         @Override
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java
index b073755..1d1fdf1 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,10 @@
     JDK1_8("1.8", 52, 0),
 
     /** JDK 9. */
-    JDK1_9("1.9", 53, 0);
+    JDK1_9("1.9", 53, 0),
+
+    /** JDK 10, initially an alias for 9 */
+    JDK1_10("1.10", 53, 0);
 
     private static final Context.Key<Target> targetKey = new Context.Key<>();
 
@@ -91,6 +94,7 @@
         tab.put("7", JDK1_7);
         tab.put("8", JDK1_8);
         tab.put("9", JDK1_9);
+        tab.put("10", JDK1_10);
     }
 
     public final String name;
@@ -102,7 +106,7 @@
         this.minorVersion = minorVersion;
     }
 
-    public static final Target DEFAULT = JDK1_9;
+    public static final Target DEFAULT = values()[values().length - 1];
 
     public static Target lookup(String name) {
         return tab.get(name);
@@ -146,5 +150,4 @@
     public String multiReleaseValue() {
         return Integer.toString(this.ordinal() - Target.JDK1_1.ordinal() + 1);
     }
-
 }
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java
index d356f4a..5fe785e 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java
@@ -31,10 +31,13 @@
 import java.io.PrintWriter;
 import java.net.URL;
 import java.nio.file.NoSuchFileException;
+import java.security.CodeSource;
 import java.security.DigestInputStream;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.tools.JavaFileManager;
 
@@ -325,6 +328,11 @@
         } catch (PropagatedException ex) {
             // TODO: what about errors from plugins?   should not simply rethrow the error here
             throw ex.getCause();
+        } catch (IllegalAccessError iae) {
+            if (twoClassLoadersInUse(iae)) {
+                bugMessage(iae);
+            }
+            return Result.ABNORMAL;
         } catch (Throwable ex) {
             // Nasty.  If we've already reported an error, compensate
             // for buggy compiler error recovery by swallowing thrown
@@ -343,6 +351,35 @@
         }
     }
 
+    private boolean twoClassLoadersInUse(IllegalAccessError iae) {
+        String msg = iae.getMessage();
+        Pattern pattern = Pattern.compile("(?i)(?<=tried to access class )([a-z_$][a-z\\d_$]*\\.)*[a-z_$][a-z\\d_$]*");
+        Matcher matcher = pattern.matcher(msg);
+        if (matcher.find()) {
+            try {
+                String otherClassName = matcher.group(0);
+                Class<?> otherClass = Class.forName(otherClassName);
+                ClassLoader otherClassLoader = otherClass.getClassLoader();
+                ClassLoader javacClassLoader = this.getClass().getClassLoader();
+                if (javacClassLoader != otherClassLoader) {
+                    CodeSource otherClassCodeSource = otherClass.getProtectionDomain().getCodeSource();
+                    CodeSource javacCodeSource = this.getClass().getProtectionDomain().getCodeSource();
+                    if (otherClassCodeSource != null && javacCodeSource != null) {
+                        log.printLines(PrefixKind.JAVAC, "err.two.class.loaders.2",
+                                otherClassCodeSource.getLocation(),
+                                javacCodeSource.getLocation());
+                    } else {
+                        log.printLines(PrefixKind.JAVAC, "err.two.class.loaders.1");
+                    }
+                    return true;
+                }
+            } catch (Throwable t) {
+                return false;
+            }
+        }
+        return false;
+    }
+
     /** Print a message reporting an internal error.
      */
     void bugMessage(Throwable ex) {
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java
index 4d836eb..3ece0dd 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,7 +66,7 @@
 
     @Override
     public PlatformDescription getPlatform(String platformName, String options) {
-        return new PlatformDescriptionImpl(platformName);
+        return new PlatformDescriptionImpl(platformName.equals("10") ? "9" : platformName);
     }
 
     private static final String[] symbolFileLocation = { "lib", "ct.sym" };
@@ -93,6 +93,10 @@
             } catch (IOException | ProviderNotFoundException ex) {
             }
         }
+
+        if (SUPPORTED_JAVA_PLATFORM_VERSIONS.contains("9")) {
+            SUPPORTED_JAVA_PLATFORM_VERSIONS.add("10");
+        }
     }
 
     private static String targetNumericVersion(Target target) {
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java
index afedf3e..ecfc372 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java
@@ -55,7 +55,7 @@
  * deletion without notice.</b>
  */
 @SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_9)
+@SupportedSourceVersion(SourceVersion.RELEASE_10)
 public class PrintingProcessor extends AbstractProcessor {
     PrintWriter writer;
 
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties
index fd8dfcb..3069bc3 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties
@@ -376,6 +376,12 @@
     not a file: {0}
 javac.err.cannot.access.runtime.env=\
     cannot access runtime environment
+javac.err.two.class.loaders.1=\
+    javac is split between multiple class loaders: check your configuration
+javac.err.two.class.loaders.2=\
+    javac is split between multiple class loaders:\n\
+    one class comes from file: {0}\n\
+    while javac comes from {1}
 javac.err.bad.value.for.option=\
     bad value for {0} option: ''{1}''
 javac.err.no.value.for.option=\
diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java
index b0f430b..1796c4d 100644
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,6 +46,8 @@
 
 import javax.tools.JavaFileObject;
 
+import java.util.function.ToIntFunction;
+
 import static com.sun.tools.javac.tree.JCTree.JCOperatorExpression.OperandPos.LEFT;
 import static com.sun.tools.javac.tree.JCTree.JCOperatorExpression.OperandPos.RIGHT;
 
@@ -580,13 +582,29 @@
         };
     }
 
+    public enum PosKind {
+        START_POS(TreeInfo::getStartPos),
+        FIRST_STAT_POS(TreeInfo::firstStatPos),
+        END_POS(TreeInfo::endPos);
+
+        final ToIntFunction<JCTree> posFunc;
+
+        PosKind(ToIntFunction<JCTree> posFunc) {
+            this.posFunc = posFunc;
+        }
+
+        int toPos(JCTree tree) {
+            return posFunc.applyAsInt(tree);
+        }
+    }
+
     /** The position of the finalizer of given try/synchronized statement.
      */
-    public static int finalizerPos(JCTree tree) {
+    public static int finalizerPos(JCTree tree, PosKind posKind) {
         if (tree.hasTag(TRY)) {
             JCTry t = (JCTry) tree;
             Assert.checkNonNull(t.finalizer);
-            return firstStatPos(t.finalizer);
+            return posKind.toPos(t.finalizer);
         } else if (tree.hasTag(SYNCHRONIZED)) {
             return endPos(((JCSynchronized) tree).body);
         } else {
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java
index 11978a2..8f0c761 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,7 +50,7 @@
 
 import javax.tools.Diagnostic;
 
-import static javax.lang.model.SourceVersion.RELEASE_9;
+import static javax.lang.model.SourceVersion.RELEASE_10;
 
 /**
  * Annotation processor for the Deprecation Scanner tool.
@@ -58,7 +58,7 @@
  *
  */
 @SupportedAnnotationTypes("java.lang.Deprecated")
-@SupportedSourceVersion(RELEASE_9)
+@SupportedSourceVersion(RELEASE_10)
 public class LoadProc extends AbstractProcessor {
     Elements elements;
     Messager messager;
diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java
index 175ac3f..155f1be 100644
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -101,7 +101,7 @@
     // Keep these updated manually until there's a compiler API
     // that allows querying of supported releases.
     final Set<String> releasesWithoutForRemoval = Set.of("6", "7", "8");
-    final Set<String> releasesWithForRemoval = Set.of("9");
+    final Set<String> releasesWithForRemoval = Set.of("9", "10");
 
     final Set<String> validReleases;
     {
@@ -353,14 +353,14 @@
      * Process classes from a particular JDK release, using only information
      * in this JDK.
      *
-     * @param release "6", "7", "8", or "9"
+     * @param release "6", "7", "8", "9", or "10"
      * @param classes collection of classes to process, may be empty
      * @return success value
      */
     boolean processRelease(String release, Collection<String> classes) throws IOException {
         options.addAll(List.of("--release", release));
 
-        if (release.equals("9")) {
+        if (release.equals("9") || release.equals("10")) {
             List<String> rootMods = List.of("java.se", "java.se.ee");
             TraverseProc proc = new TraverseProc(rootMods);
             JavaCompiler.CompilationTask task =
@@ -484,7 +484,7 @@
         String dir = null;
         String jar = null;
         String jdkHome = null;
-        String release = "9";
+        String release = "10";
         List<String> loadClasses = new ArrayList<>();
         String csvFile = null;
 
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java
index ad66b67..1fb0661 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java
@@ -121,6 +121,17 @@
     }
 
     /**
+     * Is the specified option allowed.
+     *
+     * @param opt the option to check
+     * @return true if the option is allowed
+     */
+    boolean isAllowedOption(String opt) {
+        Boolean has = options.get(opt);
+        return has != null;
+    }
+
+    /**
      * Has the specified option been encountered.
      *
      * @param opt the option to check
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
index 0a54674..c58ba51 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
@@ -90,7 +90,6 @@
 import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
 import static java.nio.file.StandardOpenOption.WRITE;
 import java.util.MissingResourceException;
-import java.util.Optional;
 import java.util.ResourceBundle;
 import java.util.ServiceLoader;
 import java.util.Spliterators;
@@ -126,6 +125,7 @@
 public class JShellTool implements MessageHandler {
 
     private static final Pattern LINEBREAK = Pattern.compile("\\R");
+    private static final Pattern ID = Pattern.compile("[se]?\\d+([-\\s].*)?");
             static final String RECORD_SEPARATOR = "\u241E";
     private static final String RB_NAME_PREFIX  = "jdk.internal.jshell.tool.resources";
     private static final String VERSION_RB_NAME = RB_NAME_PREFIX + ".version";
@@ -1189,36 +1189,54 @@
         }
     }
 
-    private void processCommand(String cmd) {
-        if (cmd.startsWith("/-")) {
+    /**
+     * Process a command (as opposed to a snippet) -- things that start with
+     * slash.
+     *
+     * @param input
+     */
+    private void processCommand(String input) {
+        if (input.startsWith("/-")) {
             try {
                 //handle "/-[number]"
-                cmdUseHistoryEntry(Integer.parseInt(cmd.substring(1)));
+                cmdUseHistoryEntry(Integer.parseInt(input.substring(1)));
                 return ;
             } catch (NumberFormatException ex) {
                 //ignore
             }
         }
-        String arg = "";
-        int idx = cmd.indexOf(' ');
+        String cmd;
+        String arg;
+        int idx = input.indexOf(' ');
         if (idx > 0) {
-            arg = cmd.substring(idx + 1).trim();
-            cmd = cmd.substring(0, idx);
+            arg = input.substring(idx + 1).trim();
+            cmd = input.substring(0, idx);
+        } else {
+            cmd = input;
+            arg = "";
         }
+        // find the command as a "real command", not a pseudo-command or doc subject
         Command[] candidates = findCommand(cmd, c -> c.kind.isRealCommand);
         switch (candidates.length) {
             case 0:
-                if (!rerunHistoryEntryById(cmd.substring(1))) {
-                    errormsg("jshell.err.no.such.command.or.snippet.id", cmd);
+                // not found, it is either a snippet command or an error
+                if (ID.matcher(cmd.substring(1)).matches()) {
+                    // it is in the form of a snipppet id, see if it is a valid history reference
+                    rerunHistoryEntriesById(input);
+                } else {
+                    errormsg("jshell.err.invalid.command", cmd);
                     fluffmsg("jshell.msg.help.for.help");
-                }   break;
+                }
+                break;
             case 1:
                 Command command = candidates[0];
                 // If comand was successful and is of a replayable kind, add it the replayable history
                 if (command.run.apply(arg) && command.kind == CommandKind.REPLAY) {
                     addToReplayHistory((command.command + " " + arg).trim());
-                }   break;
+                }
+                break;
             default:
+                // command if too short (ambigous), show the possibly matches
                 errormsg("jshell.err.command.ambiguous", cmd,
                         Arrays.stream(candidates).map(c -> c.command).collect(Collectors.joining(", ")));
                 fluffmsg("jshell.msg.help.for.help");
@@ -1701,6 +1719,9 @@
         registerCommand(new Command("context",
                 "help.context",
                 CommandKind.HELP_SUBJECT));
+        registerCommand(new Command("rerun",
+                "help.rerun",
+                CommandKind.HELP_SUBJECT));
 
         commandCompletions = new ContinuousCompletionProvider(
                 commands.values().stream()
@@ -2247,6 +2268,20 @@
             Predicate<Snippet> defFilter, String rawargs, String cmd) {
         ArgTokenizer at = new ArgTokenizer(cmd, rawargs.trim());
         at.allowedOptions("-all", "-start");
+        return argsOptionsToSnippets(snippetSupplier, defFilter, at);
+    }
+
+    /**
+     * Convert user arguments to a Stream of snippets referenced by those
+     * arguments (or lack of arguments).
+     *
+     * @param snippets the base list of possible snippets
+     * @param defFilter the filter to apply to the arguments if no argument
+     * @param at the ArgTokenizer, with allowed options set
+     * @return
+     */
+    private <T extends Snippet> Stream<T> argsOptionsToSnippets(Supplier<Stream<T>> snippetSupplier,
+            Predicate<Snippet> defFilter, ArgTokenizer at) {
         List<String> args = new ArrayList<>();
         String s;
         while ((s = at.next()) != null) {
@@ -2263,11 +2298,11 @@
             errormsg("jshell.err.conflicting.options", at.whole());
             return null;
         }
-        if (at.hasOption("-all")) {
+        if (at.isAllowedOption("-all") && at.hasOption("-all")) {
             // all snippets including start-up, failed, and overwritten
             return snippetSupplier.get();
         }
-        if (at.hasOption("-start")) {
+        if (at.isAllowedOption("-start") && at.hasOption("-start")) {
             // start-up snippets
             return snippetSupplier.get()
                     .filter(this::inStartUp);
@@ -2277,54 +2312,227 @@
             return snippetSupplier.get()
                     .filter(defFilter);
         }
-        return argsToSnippets(snippetSupplier, args);
+        return new ArgToSnippets<>(snippetSupplier).argsToSnippets(args);
     }
 
     /**
-     * Convert user arguments to a Stream of snippets referenced by those
-     * arguments.
+     * Support for converting arguments that are definition names, snippet ids,
+     * or snippet id ranges into a stream of snippets,
      *
-     * @param snippetSupplier the base list of possible snippets
-     * @param args the user's argument to the command, maybe be the empty list
-     * @return a Stream of referenced snippets or null if no matches to specific
-     * arg
+     * @param <T> the snipper subtype
      */
-    private <T extends Snippet> Stream<T> argsToSnippets(Supplier<Stream<T>> snippetSupplier,
-            List<String> args) {
-        Stream<T> result = null;
-        for (String arg : args) {
+    private class ArgToSnippets<T extends Snippet> {
+
+        // the supplier of snippet streams
+        final Supplier<Stream<T>> snippetSupplier;
+        // these two are parallel, and lazily filled if a range is encountered
+        List<T> allSnippets;
+        String[] allIds = null;
+
+        /**
+         *
+         * @param snippetSupplier the base list of possible snippets
+        */
+        ArgToSnippets(Supplier<Stream<T>> snippetSupplier) {
+            this.snippetSupplier = snippetSupplier;
+        }
+
+        /**
+         * Convert user arguments to a Stream of snippets referenced by those
+         * arguments.
+         *
+         * @param args the user's argument to the command, maybe be the empty
+         * list
+         * @return a Stream of referenced snippets or null if no matches to
+         * specific arg
+         */
+        Stream<T> argsToSnippets(List<String> args) {
+            Stream<T> result = null;
+            for (String arg : args) {
+                // Find the best match
+                Stream<T> st = argToSnippets(arg);
+                if (st == null) {
+                    return null;
+                } else {
+                    result = (result == null)
+                            ? st
+                            : Stream.concat(result, st);
+                }
+            }
+            return result;
+        }
+
+        /**
+         * Convert a user argument to a Stream of snippets referenced by the
+         * argument.
+         *
+         * @param snippetSupplier the base list of possible snippets
+         * @param arg the user's argument to the command
+         * @return a Stream of referenced snippets or null if no matches to
+         * specific arg
+         */
+        Stream<T> argToSnippets(String arg) {
+            if (arg.contains("-")) {
+                return range(arg);
+            }
             // Find the best match
             Stream<T> st = layeredSnippetSearch(snippetSupplier, arg);
             if (st == null) {
-                Stream<Snippet> est = layeredSnippetSearch(state::snippets, arg);
-                if (est == null) {
-                    errormsg("jshell.err.no.such.snippets", arg);
-                } else {
-                    errormsg("jshell.err.the.snippet.cannot.be.used.with.this.command",
-                            arg, est.findFirst().get().source());
-                }
+                badSnippetErrormsg(arg);
                 return null;
-            }
-            if (result == null) {
-                result = st;
             } else {
-                result = Stream.concat(result, st);
+                return st;
             }
         }
-        return result;
-    }
 
-    private <T extends Snippet> Stream<T> layeredSnippetSearch(Supplier<Stream<T>> snippetSupplier, String arg) {
-        return nonEmptyStream(
-                // the stream supplier
-                snippetSupplier,
-                // look for active user declarations matching the name
-                sn -> isActive(sn) && matchingDeclaration(sn, arg),
-                // else, look for any declarations matching the name
-                sn -> matchingDeclaration(sn, arg),
-                // else, look for an id of this name
-                sn -> sn.id().equals(arg)
-        );
+        /**
+         * Look for inappropriate snippets to give best error message
+         *
+         * @param arg the bad snippet arg
+         * @param errKey the not found error key
+         */
+        void badSnippetErrormsg(String arg) {
+            Stream<Snippet> est = layeredSnippetSearch(state::snippets, arg);
+            if (est == null) {
+                if (ID.matcher(arg).matches()) {
+                    errormsg("jshell.err.no.snippet.with.id", arg);
+                } else {
+                    errormsg("jshell.err.no.such.snippets", arg);
+                }
+            } else {
+                errormsg("jshell.err.the.snippet.cannot.be.used.with.this.command",
+                        arg, est.findFirst().get().source());
+            }
+        }
+
+        /**
+         * Search through the snippets for the best match to the id/name.
+         *
+         * @param <R> the snippet type
+         * @param aSnippetSupplier the supplier of snippet streams
+         * @param arg the arg to match
+         * @return a Stream of referenced snippets or null if no matches to
+         * specific arg
+         */
+        <R extends Snippet> Stream<R> layeredSnippetSearch(Supplier<Stream<R>> aSnippetSupplier, String arg) {
+            return nonEmptyStream(
+                    // the stream supplier
+                    aSnippetSupplier,
+                    // look for active user declarations matching the name
+                    sn -> isActive(sn) && matchingDeclaration(sn, arg),
+                    // else, look for any declarations matching the name
+                    sn -> matchingDeclaration(sn, arg),
+                    // else, look for an id of this name
+                    sn -> sn.id().equals(arg)
+            );
+        }
+
+        /**
+         * Given an id1-id2 range specifier, return a stream of snippets within
+         * our context
+         *
+         * @param arg the range arg
+         * @return a Stream of referenced snippets or null if no matches to
+         * specific arg
+         */
+        Stream<T> range(String arg) {
+            int dash = arg.indexOf('-');
+            String iid = arg.substring(0, dash);
+            String tid = arg.substring(dash + 1);
+            int iidx = snippetIndex(iid);
+            if (iidx < 0) {
+                return null;
+            }
+            int tidx = snippetIndex(tid);
+            if (tidx < 0) {
+                return null;
+            }
+            if (tidx < iidx) {
+                errormsg("jshell.err.end.snippet.range.less.than.start", iid, tid);
+                return null;
+            }
+            return allSnippets.subList(iidx, tidx+1).stream();
+        }
+
+        /**
+         * Lazily initialize the id mapping -- needed only for id ranges.
+         */
+        void initIdMapping() {
+            if (allIds == null) {
+                allSnippets = snippetSupplier.get()
+                        .sorted((a, b) -> order(a) - order(b))
+                        .collect(toList());
+                allIds = allSnippets.stream()
+                        .map(sn -> sn.id())
+                        .toArray(n -> new String[n]);
+            }
+        }
+
+        /**
+         * Return all the snippet ids -- within the context, and in order.
+         *
+         * @return the snippet ids
+         */
+        String[] allIds() {
+            initIdMapping();
+            return allIds;
+        }
+
+        /**
+         * Establish an order on snippet ids.  All startup snippets are first,
+         * all error snippets are last -- within that is by snippet number.
+         *
+         * @param id the id string
+         * @return an ordering int
+         */
+        int order(String id) {
+            try {
+                switch (id.charAt(0)) {
+                    case 's':
+                        return Integer.parseInt(id.substring(1));
+                    case 'e':
+                        return 0x40000000 + Integer.parseInt(id.substring(1));
+                    default:
+                        return 0x20000000 + Integer.parseInt(id);
+                }
+            } catch (Exception ex) {
+                return 0x60000000;
+            }
+        }
+
+        /**
+         * Establish an order on snippets, based on its snippet id. All startup
+         * snippets are first, all error snippets are last -- within that is by
+         * snippet number.
+         *
+         * @param sn the id string
+         * @return an ordering int
+         */
+        int order(Snippet sn) {
+            return order(sn.id());
+        }
+
+        /**
+         * Find the index into the parallel allSnippets and allIds structures.
+         *
+         * @param s the snippet id name
+         * @return the index, or, if not found, report the error and return a
+         * negative number
+         */
+        int snippetIndex(String s) {
+            int idx = Arrays.binarySearch(allIds(), 0, allIds().length, s,
+                    (a, b) -> order(a) - order(b));
+            if (idx < 0) {
+                // the id is not in the snippet domain, find the right error to report
+                if (!ID.matcher(s).matches()) {
+                    errormsg("jshell.err.range.requires.id", s);
+                } else {
+                    badSnippetErrormsg(s);
+                }
+            }
+            return idx;
+        }
+
     }
 
     private boolean cmdDrop(String rawargs) {
@@ -2342,24 +2550,13 @@
             errormsg("jshell.err.drop.arg");
             return false;
         }
-        Stream<Snippet> stream = argsToSnippets(this::dropableSnippets, args);
+        Stream<Snippet> stream = new ArgToSnippets<>(this::dropableSnippets).argsToSnippets(args);
         if (stream == null) {
             // Snippet not found. Error already printed
             fluffmsg("jshell.msg.see.classes.etc");
             return false;
         }
-        List<Snippet> snippets = stream.collect(toList());
-        if (snippets.size() > args.size()) {
-            // One of the args references more thean one snippet
-            errormsg("jshell.err.drop.ambiguous");
-            fluffmsg("jshell.msg.use.one.of", snippets.stream()
-                    .map(sn -> String.format("\n/drop %-5s :   %s", sn.id(), sn.source().replace("\n", "\n       ")))
-                    .collect(Collectors.joining(", "))
-            );
-            return false;
-        }
-        snippets.stream()
-                .forEach(sn -> state.drop(sn).forEach(this::handleEvent));
+        stream.forEach(sn -> state.drop(sn).forEach(this::handleEvent));
         return true;
     }
 
@@ -2690,37 +2887,38 @@
     }
 
     private boolean cmdSave(String rawargs) {
-        ArgTokenizer at = new ArgTokenizer("/save", rawargs.trim());
-        at.allowedOptions("-all", "-start", "-history");
-        String filename = at.next();
-        if (filename == null) {
+        // The filename to save to is the last argument, extract it
+        String[] args = rawargs.split("\\s");
+        String filename = args[args.length - 1];
+        if (filename.isEmpty()) {
             errormsg("jshell.err.file.filename", "/save");
             return false;
         }
-        if (!checkOptionsAndRemainingInput(at)) {
-            return false;
-        }
-        if (at.optionCount() > 1) {
-            errormsg("jshell.err.conflicting.options", at.whole());
+        // All the non-filename arguments are the specifier of what to save
+        String srcSpec = Arrays.stream(args, 0, args.length - 1)
+                .collect(Collectors.joining("\n"));
+        // From the what to save specifier, compute the snippets (as a stream)
+        ArgTokenizer at = new ArgTokenizer("/save", srcSpec);
+        at.allowedOptions("-all", "-start", "-history");
+        Stream<Snippet> snippetStream = argsOptionsToSnippets(state::snippets, this::mainActive, at);
+        if (snippetStream == null) {
+            // error occurred, already reported
             return false;
         }
         try (BufferedWriter writer = Files.newBufferedWriter(toPathResolvingUserHome(filename),
                 Charset.defaultCharset(),
                 CREATE, TRUNCATE_EXISTING, WRITE)) {
             if (at.hasOption("-history")) {
+                // they want history (commands and snippets), ignore the snippet stream
                 for (String s : input.currentSessionHistory()) {
                     writer.write(s);
                     writer.write("\n");
                 }
-            } else if (at.hasOption("-start")) {
-                writer.append(startup.toString());
             } else {
-                String sources = (at.hasOption("-all")
-                        ? state.snippets()
-                        : state.snippets().filter(this::mainActive))
+                // write the snippet stream to the file
+                writer.write(snippetStream
                         .map(Snippet::source)
-                        .collect(Collectors.joining("\n"));
-                writer.write(sources);
+                        .collect(Collectors.joining("\n")));
             }
         } catch (FileNotFoundException e) {
             errormsg("jshell.err.file.not.found", "/save", filename, e.getMessage());
@@ -2837,14 +3035,21 @@
         return true;
     }
 
-    private boolean rerunHistoryEntryById(String id) {
-        Optional<Snippet> snippet = state.snippets()
-            .filter(s -> s.id().equals(id))
-            .findFirst();
-        return snippet.map(s -> {
-            rerunSnippet(s);
-            return true;
-        }).orElse(false);
+    /**
+     * Handle snippet reevaluation commands: {@code /<id>}. These commands are a
+     * sequence of ids and id ranges (names are permitted, though not in the
+     * first position. Support for names is purposely not documented).
+     *
+     * @param rawargs the whole command including arguments
+     */
+    private void rerunHistoryEntriesById(String rawargs) {
+        ArgTokenizer at = new ArgTokenizer("/<id>", rawargs.trim().substring(1));
+        at.allowedOptions();
+        Stream<Snippet> stream = argsOptionsToSnippets(state::snippets, sn -> true, at);
+        if (stream != null) {
+            // successfully parsed, rerun snippets
+            stream.forEach(sn -> rerunSnippet(sn));
+        }
     }
 
     private void rerunSnippet(Snippet snippet) {
diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties
index f636404..e677781 100644
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties
@@ -50,7 +50,7 @@
 jshell.err.startup.unexpected.exception = Unexpected exception reading start-up: {0}
 jshell.err.unexpected.exception = Unexpected exception: {0}
 
-jshell.err.no.such.command.or.snippet.id = No such command or snippet id: {0}
+jshell.err.invalid.command = Invalid command: {0}
 jshell.err.command.ambiguous = Command: ''{0}'' is ambiguous: {1}
 jshell.msg.set.restore = Setting new options and restoring state.
 jshell.msg.set.editor.set = Editor set to: {0}
@@ -105,10 +105,13 @@
 Subjects:\n\
 \n
 
+jshell.err.no.snippet.with.id = No snippet with id: {0}
+jshell.err.end.snippet.range.less.than.start = End of snippet range less than start: {0} - {1}
+jshell.err.range.requires.id = Snippet ranges require snippet ids: {0}
+
 jshell.err.drop.arg =\
 In the /drop argument, please specify an import, variable, method, or class to drop.\n\
 Specify by id or name. Use /list to see ids. Use /reset to reset all state.
-jshell.err.drop.ambiguous = The argument references more than one import, variable, method, or class.
 jshell.err.failed = Failed.
 jshell.msg.native.method = Native Method
 jshell.msg.unknown.source = Unknown Source
@@ -225,7 +228,11 @@
 /list <name>\n\t\
     List snippets with the specified name (preference for active snippets)\n\n\
 /list <id>\n\t\
-    List the snippet with the specified snippet id
+    List the snippet with the specified snippet id\n\n\
+/list <id> <id>...\n\t\
+    List the snippets with the specified snippet ids\n\n\
+/list <id>-<id>\n\t\
+    List the snippets within the range of snippet ids
 
 help.edit.summary = edit a source entry referenced by name or id
 help.edit.args = <name or id>
@@ -238,6 +245,10 @@
     Edit the snippet or snippets with the specified name (preference for active snippets)\n\n\
 /edit <id>\n\t\
     Edit the snippet with the specified snippet id\n\n\
+/edit <id> <id>...\n\t\
+    Edit the snippets with the specified snippet ids\n\n\
+/edit <id>-<id>\n\t\
+    Edit the snippets within the range of snippet ids\n\n\
 /edit\n\t\
     Edit the currently active snippets of code that you typed or read with /open
 
@@ -249,7 +260,11 @@
 /drop <name>\n\t\
     Drop the snippet with the specified name\n\n\
 /drop <id>\n\t\
-    Drop the snippet with the specified snippet id
+    Drop the snippet with the specified snippet id\n\n\
+/drop <id> <id>...\n\t\
+    Drop the snippets with the specified snippet ids\n\n\
+/drop <id>-<id>\n\t\
+    Drop the snippets within the range of snippet ids
 
 help.save.summary = Save snippet source to a file.
 help.save.args = [-all|-history|-start] <file>
@@ -264,7 +279,13 @@
 /save -history <file>\n\t\
     Save the sequential history of all commands and snippets entered since jshell was launched.\n\n\
 /save -start <file>\n\t\
-    Save the current start-up definitions to the file.
+    Save the current start-up definitions to the file.\n\n\
+/save <id> <file>\n\t\
+    Save the snippet with the specified snippet id\n\n\
+/save <id> <id>... <file>\n\t\
+    Save the snippets with the specified snippet ids\n\n\
+/save <id>-<id> <file>\n\t\
+    Save the snippets within the range of snippet ids
 
 help.open.summary = open a file as source input
 help.open.args = <file>
@@ -285,6 +306,10 @@
     List jshell variables with the specified name (preference for active variables)\n\n\
 /vars <id>\n\t\
     List the jshell variable with the specified snippet id\n\n\
+/vars <id> <id>... <file>\n\t\
+    List the jshell variables with the specified snippet ids\n\n\
+/vars <id>-<id> <file>\n\t\
+    List the jshell variables within the range of snippet ids\n\n\
 /vars -start\n\t\
     List the automatically added start-up jshell variables\n\n\
 /vars -all\n\t\
@@ -301,6 +326,10 @@
     List jshell methods with the specified name (preference for active methods)\n\n\
 /methods <id>\n\t\
     List the jshell method with the specified snippet id\n\n\
+/methods <id> <id>... <file>\n\t\
+    List jshell methods with the specified snippet ids\n\n\
+/methods <id>-<id> <file>\n\t\
+    List jshell methods within the range of snippet ids\n\n\
 /methods -start\n\t\
     List the automatically added start-up jshell methods\n\n\
 /methods -all\n\t\
@@ -317,6 +346,10 @@
     List jshell types with the specified name (preference for active types)\n\n\
 /types <id>\n\t\
     List the jshell type with the specified snippet id\n\n\
+/types <id> <id>... <file>\n\t\
+    List jshell types with the specified snippet ids\n\n\
+/types <id>-<id> <file>\n\t\
+    List jshell types within the range of snippet ids\n\n\
 /types -start\n\t\
     List the automatically added start-up jshell types\n\n\
 /types -all\n\t\
@@ -461,17 +494,24 @@
 /? <subject>\n\t\
      Display information about the specified help subject. Example: /? intro
 
-help.bang.summary = re-run last snippet
+help.bang.summary = rerun last snippet -- see /help rerun
 help.bang.args =
 help.bang =\
 Reevaluate the most recently entered snippet.
 
-help.id.summary = re-run snippet by id
+help.id.summary = rerun snippets by id or id range -- see /help rerun
 help.id.args =
 help.id =\
-Reevaluate the snippet specified by the id.
+/<id> <id> <id>\n\
+\n\
+/<id>-<id>\n\
+\n\
+Reevaluate the snippets specified by the id or id range.\n\
+An id range is represented as a two ids separated by a hyphen, e.g.:  3-17\n\
+Start-up and error snippets maybe used, e.g.:  s3-s9    or   e1-e4\n\
+Any number of ids or id ranges may be used, e.g.:  /3-7 s4 14-16 e2
 
-help.previous.summary = re-run n-th previous snippet
+help.previous.summary = rerun n-th previous snippet -- see /help rerun
 help.previous.args =
 help.previous =\
 Reevaluate the n-th most recently entered snippet.
@@ -509,7 +549,7 @@
         then release and press "i", and jshell will propose possible imports\n\t\t\
         which will resolve the identifier based on the content of the specified classpath.
 
-help.context.summary = the evaluation context options for /env /reload and /reset
+help.context.summary = a description of the evaluation context options for /env /reload and /reset
 help.context =\
 These options configure the evaluation context, they can be specified when\n\
 jshell is started: on the command-line, or restarted with the commands /env,\n\
@@ -540,6 +580,38 @@
 On the command-line these options must have two dashes, e.g.: --module-path\n\
 On jshell commands they can have one or two dashes, e.g.: -module-path\n\
 
+help.rerun.summary = a description of ways to re-evaluate previously entered snippets
+help.rerun =\
+There are four ways to re-evaluate previously entered snippets.\n\
+The last snippet can be re-evaluated using: /!\n\
+The n-th previous snippet can be re-evaluated by slash-minus and the digits of n, e.g.:  /-4\n\
+For example:\n\
+\n\
+    \tjshell> 2 + 2\n\
+    \t$1 ==> 4\n\
+\n\
+    \tjshell> /!\n\
+    \t2 + 2\n\
+    \t$2 ==> 4\n\
+\n\
+    \tjshell> int z\n\
+    \tz ==> 0\n\
+\n\
+    \tjshell> /-1\n\
+    \tint z;\n\
+    \tz ==> 0\n\
+\n\
+    \tjshell> /-4\n\
+    \t2 + 2\n\
+    \t$5 ==> 4\n\
+\n\
+The snippets to re-evaluate may be specified by snippet id or id range.\n\
+An id range is represented as a two ids separated by a hyphen, e.g.:  3-17\n\
+Start-up and error snippets maybe used, e.g.:  s3-s9    or   e1-e4\n\
+Any number of ids or id ranges may be used, e.g.:  /3-7 s4 14-16 e2\n\
+\n\
+Finally, you can search backwards through history by entering ctrl-R followed by the string to search for.
+
 help.set._retain = \
 The '-retain' option saves a setting so that it is used in future sessions.\n\
 The -retain option can be used on the following forms of /set:\n\n\t\
diff --git a/langtools/test/ProblemList.txt b/langtools/test/ProblemList.txt
index f5a6f78..8e8b627 100644
--- a/langtools/test/ProblemList.txt
+++ b/langtools/test/ProblemList.txt
@@ -53,6 +53,7 @@
 tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java              8057687    generic-all    emit correct byte code an attributes for type annotations
 tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java         8057687    generic-all    emit correct byte code an attributes for type annotations
 tools/javac/warnings/suppress/TypeAnnotations.java                              8057683    generic-all    improve ordering of errors with type annotations
+tools/javac/modules/SourceInSymlinkTest.java                                    8180263    windows-all    fails when run on a subst drive
 tools/javac/modules/T8159439/NPEForModuleInfoWithNonZeroSuperClassTest.java     8160396    generic-all    current version of jtreg needs a new promotion to include lastes version of ASM
 
 ###########################################################################
diff --git a/langtools/test/jdk/jshell/CommandCompletionTest.java b/langtools/test/jdk/jshell/CommandCompletionTest.java
index 4424604..535a9eb 100644
--- a/langtools/test/jdk/jshell/CommandCompletionTest.java
+++ b/langtools/test/jdk/jshell/CommandCompletionTest.java
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8144095 8164825 8169818 8153402 8165405 8177079 8178013
+ * @bug 8144095 8164825 8169818 8153402 8165405 8177079 8178013 8167554
  * @summary Test Command Completion
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -162,13 +162,13 @@
                 "/edit ", "/env ", "/exit ",
                 "/help ", "/history ", "/imports ",
                 "/list ", "/methods ", "/open ", "/reload ", "/reset ",
-                "/save ", "/set ", "/types ", "/vars ", "context ", "intro ", "shortcuts "),
+                "/save ", "/set ", "/types ", "/vars ", "context ", "intro ", "rerun ", "shortcuts "),
                 a -> assertCompletion(a, "/? |", false,
                 "/! ", "/-<n> ", "/<id> ", "/? ", "/drop ",
                 "/edit ", "/env ", "/exit ",
                 "/help ", "/history ", "/imports ",
                 "/list ", "/methods ", "/open ", "/reload ", "/reset ",
-                "/save ", "/set ", "/types ", "/vars ", "context ", "intro ", "shortcuts "),
+                "/save ", "/set ", "/types ", "/vars ", "context ", "intro ", "rerun ", "shortcuts "),
                 a -> assertCompletion(a, "/help /s|", false,
                 "/save ", "/set "),
                 a -> assertCompletion(a, "/help /set |", false,
diff --git a/langtools/test/jdk/jshell/EditorTestBase.java b/langtools/test/jdk/jshell/EditorTestBase.java
index 074b4a5..927ebc6 100644
--- a/langtools/test/jdk/jshell/EditorTestBase.java
+++ b/langtools/test/jdk/jshell/EditorTestBase.java
@@ -73,7 +73,7 @@
         for (String edit : new String[] {"/ed", "/edit"}) {
             test(new String[]{"--no-startup"},
                     a -> assertCommandOutputStartsWith(a, edit + " 1",
-                            "|  No such snippet: 1"),
+                            "|  No snippet with id: 1"),
                     a -> assertCommandOutputStartsWith(a, edit + " unknown",
                             "|  No such snippet: unknown")
             );
diff --git a/langtools/test/jdk/jshell/MergedTabShiftTabCommandTest.java b/langtools/test/jdk/jshell/MergedTabShiftTabCommandTest.java
index 6a9dd82..da74700 100644
--- a/langtools/test/jdk/jshell/MergedTabShiftTabCommandTest.java
+++ b/langtools/test/jdk/jshell/MergedTabShiftTabCommandTest.java
@@ -66,17 +66,17 @@
                             Pattern.quote(getResource("jshell.console.see.next.command.doc")) + "\n" +
                             "\r\u0005/");
 
-            inputSink.write("lis\011");
-            waitOutput(out, "list $");
+            inputSink.write("ed\011");
+            waitOutput(out, "edit $");
 
             inputSink.write("\011");
             waitOutput(out, ".*-all.*" +
                             "\n\n" + Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n\r\u0005/");
             inputSink.write("\011");
-            waitOutput(out, Pattern.quote(getResource("help.list.summary")) + "\n\n" +
-                            Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/list ");
+            waitOutput(out, Pattern.quote(getResource("help.edit.summary")) + "\n\n" +
+                            Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/edit ");
             inputSink.write("\011");
-            waitOutput(out, Pattern.quote(getResource("help.list").replaceAll("\t", "    ")));
+            waitOutput(out, Pattern.quote(getResource("help.edit").replaceAll("\t", "    ")));
 
             inputSink.write("\u0003/env \011");
             waitOutput(out, "\u0005/env -\n" +
diff --git a/langtools/test/jdk/jshell/ToolBasicTest.java b/langtools/test/jdk/jshell/ToolBasicTest.java
index 93321fb..be5bce0 100644
--- a/langtools/test/jdk/jshell/ToolBasicTest.java
+++ b/langtools/test/jdk/jshell/ToolBasicTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 8154714 8166649 8167643 8170162 8172102 8165405 8174796 8174797 8175304
+ * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 8154714 8166649 8167643 8170162 8172102 8165405 8174796 8174797 8175304 8167554 8180508
  * @summary Tests for Basic tests for REPL tool
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -190,8 +190,8 @@
 
     public void testRerun() {
         test(false, new String[] {"--no-startup"},
-                (a) -> assertCommand(a, "/0", "|  No such command or snippet id: /0\n|  Type /help for help."),
-                (a) -> assertCommand(a, "/5", "|  No such command or snippet id: /5\n|  Type /help for help.")
+                (a) -> assertCommand(a, "/0", "|  No snippet with id: 0"),
+                (a) -> assertCommand(a, "/5", "|  No snippet with id: 5")
         );
         String[] codes = new String[] {
                 "int a = 0;", // var
@@ -252,9 +252,9 @@
         );
 
         test(false, new String[] {"--no-startup"},
-                (a) -> assertCommand(a, "/s1", "|  No such command or snippet id: /s1\n|  Type /help for help."),
-                (a) -> assertCommand(a, "/1", "|  No such command or snippet id: /1\n|  Type /help for help."),
-                (a) -> assertCommand(a, "/e1", "|  No such command or snippet id: /e1\n|  Type /help for help.")
+                (a) -> assertCommand(a, "/s1", "|  No snippet with id: s1"),
+                (a) -> assertCommand(a, "/1", "|  No snippet with id: 1"),
+                (a) -> assertCommand(a, "/e1", "|  No snippet with id: e1")
         );
     }
 
@@ -481,17 +481,19 @@
     public void testSave() throws IOException {
         Compiler compiler = new Compiler();
         Path path = compiler.getPath("testSave.repl");
-        List<String> list = Arrays.asList(
-                "int a;",
-                "class A { public String toString() { return \"A\"; } }"
-        );
-        test(
-                (a) -> assertVariable(a, "int", "a"),
-                (a) -> assertCommand(a, "()", null, null, null, "", ""),
-                (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"),
-                (a) -> assertCommand(a, "/save " + path.toString(), "")
-        );
-        assertEquals(Files.readAllLines(path), list);
+        {
+            List<String> list = Arrays.asList(
+                    "int a;",
+                    "class A { public String toString() { return \"A\"; } }"
+            );
+            test(
+                    (a) -> assertVariable(a, "int", "a"),
+                    (a) -> assertCommand(a, "()", null, null, null, "", ""),
+                    (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"),
+                    (a) -> assertCommand(a, "/save " + path.toString(), "")
+            );
+            assertEquals(Files.readAllLines(path), list);
+        }
         {
             List<String> output = new ArrayList<>();
             test(
@@ -499,28 +501,47 @@
                     (a) -> assertCommand(a, "()", null, null, null, "", ""),
                     (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"),
                     (a) -> assertCommandCheckOutput(a, "/list -all", (out) ->
-                            output.addAll(Stream.of(out.split("\n"))
-                                    .filter(str -> !str.isEmpty())
-                                    .map(str -> str.substring(str.indexOf(':') + 2))
-                                    .filter(str -> !str.startsWith("/"))
-                                    .collect(Collectors.toList()))),
+                                    output.addAll(Stream.of(out.split("\n"))
+                            .filter(str -> !str.isEmpty())
+                            .map(str -> str.substring(str.indexOf(':') + 2))
+                            .filter(str -> !str.startsWith("/"))
+                            .collect(Collectors.toList()))),
                     (a) -> assertCommand(a, "/save -all " + path.toString(), "")
             );
             assertEquals(Files.readAllLines(path), output);
         }
-        List<String> output = new ArrayList<>();
-        test(
-                (a) -> assertVariable(a, "int", "a"),
-                (a) -> assertCommand(a, "()", null, null, null, "", ""),
-                (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"),
-                (a) -> assertCommandCheckOutput(a, "/history", (out) ->
-                        output.addAll(Stream.of(out.split("\n"))
-                                .filter(str -> !str.isEmpty())
-                                .collect(Collectors.toList()))),
-                (a) -> assertCommand(a, "/save -history " + path.toString(), "")
-        );
-        output.add("/save -history " + path.toString());
-        assertEquals(Files.readAllLines(path), output);
+        {
+            List<String> output = new ArrayList<>();
+            test(
+                    (a) -> assertCommand(a, "int a;", null),
+                    (a) -> assertCommand(a, "int b;", null),
+                    (a) -> assertCommand(a, "int c;", null),
+                    (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"),
+                    (a) -> assertCommandCheckOutput(a, "/list b c a A", (out) ->
+                                    output.addAll(Stream.of(out.split("\n"))
+                            .filter(str -> !str.isEmpty())
+                            .map(str -> str.substring(str.indexOf(':') + 2))
+                            .filter(str -> !str.startsWith("/"))
+                            .collect(Collectors.toList()))),
+                    (a) -> assertCommand(a, "/save 2-3 1 4 " + path.toString(), "")
+            );
+            assertEquals(Files.readAllLines(path), output);
+        }
+        {
+            List<String> output = new ArrayList<>();
+            test(
+                    (a) -> assertVariable(a, "int", "a"),
+                    (a) -> assertCommand(a, "()", null, null, null, "", ""),
+                    (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"),
+                    (a) -> assertCommandCheckOutput(a, "/history", (out) ->
+                                output.addAll(Stream.of(out.split("\n"))
+                            .filter(str -> !str.isEmpty())
+                            .collect(Collectors.toList()))),
+                    (a) -> assertCommand(a, "/save -history " + path.toString(), "")
+            );
+            output.add("/save -history " + path.toString());
+            assertEquals(Files.readAllLines(path), output);
+        }
     }
 
     public void testStartRetain() {
@@ -652,6 +673,64 @@
         );
     }
 
+    public void testRerunIdRange() {
+        Compiler compiler = new Compiler();
+        Path startup = compiler.getPath("rangeStartup");
+        String[] startupSources = new String[] {
+            "boolean go = false",
+            "void println(String s) { if (go) System.out.println(s); }",
+            "void println(int i) { if (go) System.out.println(i); }",
+            "println(\"s4\")",
+            "println(\"s5\")",
+            "println(\"s6\")"
+        };
+        String[] sources = new String[] {
+            "frog",
+            "go = true",
+            "println(2)",
+            "println(3)",
+            "println(4)",
+            "querty"
+        };
+        compiler.writeToFile(startup, startupSources);
+        test(false, new String[]{"--startup", startup.toString()},
+                a -> assertCommandOutputStartsWith(a, sources[0], "|  Error:"),
+                a -> assertCommand(a, sources[1], "go ==> true", "", null, "", ""),
+                a -> assertCommand(a, sources[2], "", "", null, "2\n", ""),
+                a -> assertCommand(a, sources[3], "", "", null, "3\n", ""),
+                a -> assertCommand(a, sources[4], "", "", null, "4\n", ""),
+                a -> assertCommandOutputStartsWith(a, sources[5], "|  Error:"),
+                a -> assertCommand(a, "/3", "println(3)", "", null, "3\n", ""),
+                a -> assertCommand(a, "/s4", "println(\"s4\")", "", null, "s4\n", ""),
+                a -> assertCommandOutputStartsWith(a, "/e1", "frog\n|  Error:"),
+                a -> assertCommand(a, "/2-4",
+                        "println(2)\nprintln(3)\nprintln(4)",
+                        "", null, "2\n3\n4\n", ""),
+                a -> assertCommand(a, "/s4-s6",
+                        startupSources[3] + "\n" +startupSources[4] + "\n" +startupSources[5],
+                        "", null, "s4\ns5\ns6\n", ""),
+                a -> assertCommand(a, "/s4-4", null,
+                        "", null, "s4\ns5\ns6\n2\n3\n4\n", ""),
+                a -> assertCommandCheckOutput(a, "/e1-e2",
+                        s -> {
+                            assertTrue(s.trim().startsWith("frog\n|  Error:"),
+                                    "Output: \'" + s + "' does not start with: " + "|  Error:");
+                            assertTrue(s.trim().lastIndexOf("|  Error:") > 10,
+                                    "Output: \'" + s + "' does not have second: " + "|  Error:");
+                        }),
+                a -> assertCommand(a, "/4  s4 2",
+                        "println(4)\nprintln(\"s4\")\nprintln(2)",
+                        "", null, "4\ns4\n2\n", ""),
+                a -> assertCommand(a, "/s5 2-4 3",
+                        "println(\"s5\")\nprintln(2)\nprintln(3)\nprintln(4)\nprintln(3)",
+                        "", null, "s5\n2\n3\n4\n3\n", ""),
+                a -> assertCommand(a, "/2 ff", "|  No such snippet: ff"),
+                a -> assertCommand(a, "/4-2", "|  End of snippet range less than start: 4 - 2"),
+                a -> assertCommand(a, "/s5-s3", "|  End of snippet range less than start: s5 - s3"),
+                a -> assertCommand(a, "/4-s5", "|  End of snippet range less than start: 4 - s5")
+        );
+    }
+
     @Test(enabled = false) // TODO 8158197
     public void testHeadlessEditPad() {
         String prevHeadless = System.getProperty("java.awt.headless");
diff --git a/langtools/test/jdk/jshell/ToolLocaleMessageTest.java b/langtools/test/jdk/jshell/ToolLocaleMessageTest.java
index dc45091..6111320 100644
--- a/langtools/test/jdk/jshell/ToolLocaleMessageTest.java
+++ b/langtools/test/jdk/jshell/ToolLocaleMessageTest.java
@@ -117,7 +117,6 @@
                     (a) -> assertCommandFail(a, "/drop rats"),
                     (a) -> assertCommandOK(a, "void dup() {}"),
                     (a) -> assertCommandOK(a, "int dup"),
-                    (a) -> assertCommandFail(a, "/drop dup"),
                     (a) -> assertCommandFail(a, "/edit zebra", "zebra"),
                     (a) -> assertCommandFail(a, "/list zebra", "zebra", "No such snippet: zebra"),
                     (a) -> assertCommandFail(a, "/open", "/open"),
diff --git a/langtools/test/jdk/jshell/ToolSimpleTest.java b/langtools/test/jdk/jshell/ToolSimpleTest.java
index 909318a..647d0fd 100644
--- a/langtools/test/jdk/jshell/ToolSimpleTest.java
+++ b/langtools/test/jdk/jshell/ToolSimpleTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103  8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079
+ * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103  8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079 8180508
  * @summary Simple jshell tool tests
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -37,6 +37,7 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.function.Consumer;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -202,7 +203,7 @@
     @Test
     public void testUnknownCommand() {
         test((a) -> assertCommand(a, "/unknown",
-                "|  No such command or snippet id: /unknown\n" +
+                "|  Invalid command: /unknown\n" +
                 "|  Type /help for help."));
     }
 
@@ -275,9 +276,25 @@
     }
 
     @Test
+    public void testDropRange() {
+        test(false, new String[]{"--no-startup"},
+                a -> assertVariable(a, "int", "a"),
+                a -> assertMethod(a, "int b() { return 0; }", "()int", "b"),
+                a -> assertClass(a, "class A {}", "class", "A"),
+                a -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
+                a -> assertCommand(a, "for (int i = 0; i < 10; ++i) {}", ""),
+                a -> assertCommand(a, "/drop 3-5 b 1",
+                        "|  dropped class A\n" +
+                        "|  dropped method b()\n" +
+                        "|  dropped variable a\n"),
+                a -> assertCommand(a, "/list", "")
+        );
+    }
+
+    @Test
     public void testDropNegative() {
         test(false, new String[]{"--no-startup"},
-                a -> assertCommandOutputStartsWith(a, "/drop 0", "|  No such snippet: 0"),
+                a -> assertCommandOutputStartsWith(a, "/drop 0", "|  No snippet with id: 0"),
                 a -> assertCommandOutputStartsWith(a, "/drop a", "|  No such snippet: a"),
                 a -> assertCommandCheckOutput(a, "/drop",
                         assertStartsWith("|  In the /drop argument, please specify an import, variable, method, or class to drop.")),
@@ -292,27 +309,23 @@
 
     @Test
     public void testAmbiguousDrop() {
-        Consumer<String> check = s -> {
-            assertTrue(s.startsWith("|  The argument references more than one import, variable, method, or class"), s);
-            int lines = s.split("\n").length;
-            assertEquals(lines, 5, "Expected 3 ambiguous keys, but found: " + (lines - 2) + "\n" + s);
-        };
         test(
                 a -> assertVariable(a, "int", "a"),
                 a -> assertMethod(a, "int a() { return 0; }", "()int", "a"),
                 a -> assertClass(a, "class a {}", "class", "a"),
-                a -> assertCommandCheckOutput(a, "/drop a", check),
-                a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
-                a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
-                a -> assertCommandCheckOutput(a, "/types", assertClasses()),
-                a -> assertCommandCheckOutput(a, "/imports", assertImports())
+                a -> assertCommand(a, "/drop a",
+                        "|  dropped variable a\n" +
+                        "|  dropped method a()\n" +
+                        "|  dropped class a")
         );
         test(
                 a -> assertMethod(a, "int a() { return 0; }", "()int", "a"),
                 a -> assertMethod(a, "double a(int a) { return 0; }", "(int)double", "a"),
                 a -> assertMethod(a, "double a(double a) { return 0; }", "(double)double", "a"),
-                a -> assertCommandCheckOutput(a, "/drop a", check),
-                a -> assertCommandCheckOutput(a, "/methods", assertMethods())
+                a -> assertCommand(a, "/drop a",
+                        "|  dropped method a()\n" +
+                        "|  dropped method a(int)\n" +
+                        "|  dropped method a(double)\n")
         );
     }
 
@@ -402,12 +415,14 @@
         String arg = "qqqq";
         List<String> startVarList = new ArrayList<>(START_UP);
         startVarList.add("int aardvark");
+        startVarList.add("int weevil");
         test(
                 a -> assertCommandCheckOutput(a, "/list -all",
                         s -> checkLineToList(s, START_UP)),
                 a -> assertCommandOutputStartsWith(a, "/list " + arg,
                         "|  No such snippet: " + arg),
                 a -> assertVariable(a, "int", "aardvark"),
+                a -> assertVariable(a, "int", "weevil"),
                 a -> assertCommandOutputContains(a, "/list aardvark", "aardvark"),
                 a -> assertCommandCheckOutput(a, "/list -start",
                         s -> checkLineToList(s, START_UP)),
@@ -415,6 +430,11 @@
                         s -> checkLineToList(s, startVarList)),
                 a -> assertCommandOutputStartsWith(a, "/list s3",
                         "s3 : import"),
+                a -> assertCommandCheckOutput(a, "/list 1-2 s3",
+                        s -> {
+                            assertTrue(Pattern.matches(".*aardvark.*\\R.*weevil.*\\R.*s3.*import.*", s.trim()),
+                                    "No match: " + s);
+                        }),
                 a -> assertCommandOutputStartsWith(a, "/list " + arg,
                         "|  No such snippet: " + arg)
         );
@@ -439,6 +459,8 @@
                         s -> checkLineToList(s, startVarList)),
                 a -> assertCommandOutputStartsWith(a, "/vars -all",
                         "|    int aardvark = 0\n|    int a = "),
+                a -> assertCommandOutputStartsWith(a, "/vars 1-4",
+                        "|    int aardvark = 0\n|    int a = "),
                 a -> assertCommandOutputStartsWith(a, "/vars f",
                         "|  This command does not accept the snippet 'f'"),
                 a -> assertCommand(a, "/var " + arg,
diff --git a/langtools/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java b/langtools/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java
index 9edfb58..721e9f7 100644
--- a/langtools/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java
+++ b/langtools/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java
@@ -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
@@ -72,6 +72,7 @@
         {9,           21},      //System.out.println("finally");
         {10,          29},
         {9,           32},      //System.out.println("finally");
+        {10,          41},      //}
         {11,          43},
     };
 
diff --git a/langtools/test/tools/javac/T8180141/MissingLNTEntryForBreakContinueTest.java b/langtools/test/tools/javac/T8180141/MissingLNTEntryForBreakContinueTest.java
new file mode 100644
index 0000000..e032e93
--- /dev/null
+++ b/langtools/test/tools/javac/T8180141/MissingLNTEntryForBreakContinueTest.java
@@ -0,0 +1,184 @@
+/*
+ * 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 8180141
+ * @summary Missing entry in LineNumberTable for break statement that jumps out of try-finally
+ * @modules jdk.jdeps/com.sun.tools.classfile
+ *          jdk.compiler/com.sun.tools.javac.code
+ *          jdk.compiler/com.sun.tools.javac.comp
+ *          jdk.compiler/com.sun.tools.javac.file
+ *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.compiler/com.sun.tools.javac.tree
+ *          jdk.compiler/com.sun.tools.javac.util
+ * @compile -g MissingLNTEntryForBreakContinueTest.java
+ * @run main MissingLNTEntryForBreakContinueTest
+ */
+
+import java.io.File;
+import java.net.URI;
+
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+import com.sun.tools.classfile.*;
+import com.sun.tools.javac.comp.Attr;
+import com.sun.tools.javac.comp.AttrContext;
+import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.comp.Modules;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.List;
+
+import static com.sun.tools.javac.util.List.of;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
+
+public class MissingLNTEntryForBreakContinueTest {
+    protected ReusableJavaCompiler tool;
+    Context context;
+
+    MissingLNTEntryForBreakContinueTest() {
+        context = new Context();
+        JavacFileManager.preRegister(context);
+        MyAttr.preRegister(context);
+        tool = new ReusableJavaCompiler(context);
+    }
+
+    public static void main(String... args) throws Throwable {
+        new MissingLNTEntryForBreakContinueTest().test();
+    }
+
+    void test() throws Throwable {
+        testFor("1", "break");
+        testFor("2", "continue");
+    }
+
+    void testFor(String id, String statement) throws Throwable {
+        JavaSource source = new JavaSource(id, statement);
+        tool.clear();
+        List<JavaFileObject> inputs = of(source);
+        try {
+            tool.compile(inputs);
+        } catch (Throwable ex) {
+            throw new AssertionError(ex);
+        }
+        File testClasses = new File(".");
+        File file = new File(testClasses, "Test" + id + ".class");
+        ClassFile classFile = ClassFile.read(file);
+        for (Method m : classFile.methods) {
+            if (classFile.constant_pool.getUTF8Value(m.name_index).equals("foo")) {
+                Code_attribute code = (Code_attribute)m.attributes.get(Attribute.Code);
+                LineNumberTable_attribute lnt = (LineNumberTable_attribute)code.attributes.get(Attribute.LineNumberTable);
+                checkLNT(lnt, MyAttr.lineNumber);
+            }
+        }
+    }
+
+    void checkLNT(LineNumberTable_attribute lnt, int lineToCheckFor) {
+        for (LineNumberTable_attribute.Entry e: lnt.line_number_table) {
+            if (e.line_number == lineToCheckFor) {
+                return;
+            }
+        }
+        throw new AssertionError("seek line number not found in the LNT for method foo()");
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+        String statement;
+        String id;
+        String template =
+                "class Test#Id {\n" +
+                "    void foo(boolean condition) {\n" +
+                "        while (true) {\n" +
+                "            try {\n" +
+                "                if (condition) {\n" +
+                "                    #STM;\n" +
+                "                }\n" +
+                "            } finally {\n" +
+                "                System.out.println(\"finalizer\");\n" +
+                "            }\n" +
+                "        }\n" +
+                "    }" +
+                "}";
+
+        JavaSource(String id, String statement) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            this.statement = statement;
+            this.id = id;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return template.replace("#Id", id).replace("#STM", statement);
+        }
+    }
+
+    /* this class has been set up to do not depend on a fixed line number, this Attr subclass will
+     * look for 'break' or 'continue' statements in order to find the actual line number they occupy.
+     * This way the test can find if that line number appears in the LNT generated for a given class.
+     */
+    static class MyAttr extends Attr {
+        static int lineNumber;
+
+        static void preRegister(Context context) {
+            context.put(attrKey, (com.sun.tools.javac.util.Context.Factory<Attr>) c -> new MyAttr(c));
+        }
+
+        MyAttr(Context context) {
+            super(context);
+        }
+
+        @Override
+        public com.sun.tools.javac.code.Type attribStat(JCTree tree, Env<AttrContext> env) {
+            com.sun.tools.javac.code.Type result = super.attribStat(tree, env);
+            if (tree.hasTag(BREAK) || tree.hasTag(CONTINUE)) {
+                lineNumber = env.toplevel.lineMap.getLineNumber(tree.pos);
+            }
+            return result;
+        }
+    }
+
+    static class ReusableJavaCompiler extends JavaCompiler {
+        ReusableJavaCompiler(Context context) {
+            super(context);
+        }
+
+        @Override
+        protected void checkReusable() {
+            // do nothing
+        }
+
+        @Override
+        public void close() {
+            //do nothing
+        }
+
+        void clear() {
+            newRound();
+            Modules.instance(context).newRound();
+        }
+    }
+}
diff --git a/langtools/test/tools/javac/T8180660/MissingLNTEntryForFinalizerTest.java b/langtools/test/tools/javac/T8180660/MissingLNTEntryForFinalizerTest.java
new file mode 100644
index 0000000..49e4026
--- /dev/null
+++ b/langtools/test/tools/javac/T8180660/MissingLNTEntryForFinalizerTest.java
@@ -0,0 +1,180 @@
+/*
+ * 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 8180141
+ * @summary Missing entry in LineNumberTable for break statement that jumps out of try-finally
+ * @modules jdk.jdeps/com.sun.tools.classfile
+ *          jdk.compiler/com.sun.tools.javac.code
+ *          jdk.compiler/com.sun.tools.javac.comp
+ *          jdk.compiler/com.sun.tools.javac.file
+ *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.compiler/com.sun.tools.javac.tree
+ *          jdk.compiler/com.sun.tools.javac.util
+ * @compile -g MissingLNTEntryForFinalizerTest.java
+ * @run main MissingLNTEntryForFinalizerTest
+ */
+
+import java.io.File;
+import java.net.URI;
+
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+import com.sun.tools.classfile.*;
+import com.sun.tools.javac.comp.Attr;
+import com.sun.tools.javac.comp.AttrContext;
+import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.comp.Modules;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.List;
+
+import static com.sun.tools.javac.util.List.of;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
+
+public class MissingLNTEntryForFinalizerTest {
+    protected ReusableJavaCompiler tool;
+    Context context;
+
+    MissingLNTEntryForFinalizerTest() {
+        context = new Context();
+        JavacFileManager.preRegister(context);
+        MyAttr.preRegister(context);
+        tool = new ReusableJavaCompiler(context);
+    }
+
+    public static void main(String... args) throws Throwable {
+        new MissingLNTEntryForFinalizerTest().test();
+    }
+
+    void test() throws Throwable {
+        JavaSource source = new JavaSource("1");
+        tool.clear();
+        List<JavaFileObject> inputs = of(source);
+        try {
+            tool.compile(inputs);
+        } catch (Throwable ex) {
+            throw new AssertionError(ex);
+        }
+        File testClasses = new File(".");
+        File file = new File(testClasses, "Test1.class");
+        ClassFile classFile = ClassFile.read(file);
+        for (Method m : classFile.methods) {
+            if (classFile.constant_pool.getUTF8Value(m.name_index).equals("foo")) {
+                Code_attribute code = (Code_attribute)m.attributes.get(Attribute.Code);
+                LineNumberTable_attribute lnt = (LineNumberTable_attribute)code.attributes.get(Attribute.LineNumberTable);
+                checkLNT(lnt, MyAttr.lineNumber);
+            }
+        }
+    }
+
+    void checkLNT(LineNumberTable_attribute lnt, int lineToCheckFor) {
+        for (LineNumberTable_attribute.Entry e: lnt.line_number_table) {
+            if (e.line_number == lineToCheckFor) {
+                return;
+            }
+        }
+        throw new AssertionError("seek line number not found in the LNT for method foo()");
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+        String id;
+        String template =
+                "import java.util.*;\n" +
+                "class Test#Id {\n" +
+                "    void foo() {\n" +
+                "        List<String> l = null;\n" +
+                "        String first = null;\n" +
+                "        try {\n" +
+                "            first = l.get(0);\n" +
+                "        } finally {\n" +
+                "            if (first != null) {\n" +
+                "                System.out.println(\"finalizer\");\n" +
+                "            }\n" +
+                "        }\n" +
+                "    }\n" +
+                "}";
+
+        JavaSource(String id) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            this.id = id;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return template.replace("#Id", id);
+        }
+    }
+
+    /* this class has been set up to do not depend on a fixed line number, this Attr subclass will
+     * look for 'break' or 'continue' statements in order to find the actual line number they occupy.
+     * This way the test can find if that line number appears in the LNT generated for a given class.
+     */
+    static class MyAttr extends Attr {
+        static int lineNumber;
+
+        static void preRegister(Context context) {
+            context.put(attrKey, (com.sun.tools.javac.util.Context.Factory<Attr>) c -> new MyAttr(c));
+        }
+
+        MyAttr(Context context) {
+            super(context);
+        }
+
+        @Override
+        public com.sun.tools.javac.code.Type attribStat(JCTree tree, Env<AttrContext> env) {
+            com.sun.tools.javac.code.Type result = super.attribStat(tree, env);
+            if (tree.hasTag(TRY)) {
+                JCTry tryTree = (JCTry)tree;
+                lineNumber = env.toplevel.lineMap.getLineNumber(tryTree.finalizer.endpos);
+            }
+            return result;
+        }
+    }
+
+    static class ReusableJavaCompiler extends JavaCompiler {
+        ReusableJavaCompiler(Context context) {
+            super(context);
+        }
+
+        @Override
+        protected void checkReusable() {
+            // do nothing
+        }
+
+        @Override
+        public void close() {
+            //do nothing
+        }
+
+        void clear() {
+            newRound();
+            Modules.instance(context).newRound();
+        }
+    }
+}
diff --git a/langtools/test/tools/javac/api/T6265137.java b/langtools/test/tools/javac/api/T6265137.java
index d29ae4a..fd7f02d 100644
--- a/langtools/test/tools/javac/api/T6265137.java
+++ b/langtools/test/tools/javac/api/T6265137.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,7 +52,7 @@
             String srcdir = System.getProperty("test.src");
             Iterable<? extends JavaFileObject> files =
                 fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(srcdir, "T6265137a.java")));
-            javac.getTask(null, fm, dl, Arrays.asList("-target","9"), null, files).call();
+            javac.getTask(null, fm, dl, Arrays.asList("-target","10"), null, files).call();
         }
     }
 }
diff --git a/langtools/test/tools/javac/api/T6395981.java b/langtools/test/tools/javac/api/T6395981.java
index 30cd4cb..7ac2a2c 100644
--- a/langtools/test/tools/javac/api/T6395981.java
+++ b/langtools/test/tools/javac/api/T6395981.java
@@ -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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug     6395981 6458819 7025784 8028543
+ * @bug     6395981 6458819 7025784 8028543 8028544
  * @summary JavaCompilerTool and Tool must specify version of JLS and JVMS
  * @author  Peter von der Ah\u00e9
  * @modules java.compiler
@@ -31,7 +31,7 @@
  * @run main/fail T6395981
  * @run main/fail T6395981 RELEASE_3 RELEASE_5 RELEASE_6
  * @run main/fail T6395981 RELEASE_0 RELEASE_1 RELEASE_2 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6
- * @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7 RELEASE_8 RELEASE_9
+ * @run main T6395981 RELEASE_3 RELEASE_4 RELEASE_5 RELEASE_6 RELEASE_7 RELEASE_8 RELEASE_9 RELEASE_10
  */
 
 import java.util.EnumSet;
diff --git a/langtools/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java b/langtools/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java
index ce7bb16..47eb386 100644
--- a/langtools/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java
+++ b/langtools/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java
@@ -26,7 +26,6 @@
  * @bug 8002099 8010822
  * @summary Add support for intersection types in cast expression
  * @modules jdk.compiler/com.sun.tools.javac.util
- * @run main/othervm IntersectionTargetTypeTest
  */
 
 import com.sun.source.util.JavacTask;
diff --git a/langtools/test/tools/javac/linenumbers/FinallyLineNumberTest.java b/langtools/test/tools/javac/linenumbers/FinallyLineNumberTest.java
index 892d365..51946f6 100644
--- a/langtools/test/tools/javac/linenumbers/FinallyLineNumberTest.java
+++ b/langtools/test/tools/javac/linenumbers/FinallyLineNumberTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
 import com.sun.tools.classfile.LineNumberTable_attribute;
 import com.sun.tools.classfile.LineNumberTable_attribute.Entry;
 
-import java.io.File;
 import java.io.IOException;
 
 public class FinallyLineNumberTest {
@@ -46,13 +45,13 @@
         if (lines == null) {
             throw new Exception("finally line number table could not be loaded");
         }
-        if (lines.length != 4) {
+        if (lines.length != 5) {
             // Help debug
             System.err.println("LineTable error, got lines:");
             for (Entry e : lines) {
                 System.err.println(e.line_number);
             }
-            throw new Exception("finally line number table incorrect: length=" + lines.length + " expected length=4");
+            throw new Exception("finally line number table incorrect: length=" + lines.length + " expected length=5");
         }
 
         // return null line, for the load null operation
@@ -71,11 +70,17 @@
             throw new Exception("finally line number table incorrect: got=" + current + " expected=" + first);
         }
 
-        // finally line, for when exception is thrown
+        // for when exception is thrown
         current = lines[3].line_number;
         if (current != first + 2) {
             throw new Exception("finally line number table incorrect: got=" + current + " expected=" + (first + 2));
         }
+
+        // the '}' closing the finally block
+        current = lines[4].line_number;
+        if (current != first + 3) {
+            throw new Exception("finally line number table incorrect: got=" + current + " expected=" + (first + 3));
+        }
     }
 
     static Entry[] findEntries() throws IOException, ConstantPoolException {
diff --git a/langtools/test/tools/javac/processing/StopAfterError/StopAfterError.java b/langtools/test/tools/javac/processing/StopAfterError/StopAfterError.java
index 6e6876f..65127b0 100644
--- a/langtools/test/tools/javac/processing/StopAfterError/StopAfterError.java
+++ b/langtools/test/tools/javac/processing/StopAfterError/StopAfterError.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,8 @@
  * @summary If an error is produced by an annotation processor, the code should not be Attred, \
  *          unless requested
  * @modules jdk.compiler
- * @compile StopAfterError.java
+ * @library /tools/javac/lib
+ * @build StopAfterError JavacTestingAbstractProcessor
  * @compile/fail/ref=StopAfterError.out -XDrawDiagnostics -processor StopAfterError StopAfterErrorAux.java
  * @compile/fail/ref=StopAfterError.out -XDshould-stop.ifError=PROCESS -XDrawDiagnostics -processor StopAfterError StopAfterErrorAux.java
  * @compile/fail/ref=StopAfterErrorContinue.out -XDshould-stop.ifError=ATTR -XDrawDiagnostics -processor StopAfterError StopAfterErrorAux.java
@@ -42,8 +43,7 @@
 import javax.lang.model.element.TypeElement;
 import javax.tools.Diagnostic.Kind;
 
-@SupportedAnnotationTypes("*")
-public class StopAfterError extends AbstractProcessor {
+public class StopAfterError extends JavacTestingAbstractProcessor {
 
     @Override
     public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
@@ -52,10 +52,4 @@
         }
         return false;
     }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latestSupported();
-    }
-
 }
diff --git a/langtools/test/tools/javac/processing/errors/StopOnInapplicableAnnotations/Processor.java b/langtools/test/tools/javac/processing/errors/StopOnInapplicableAnnotations/Processor.java
index 0a3b525..8ce1a9c 100644
--- a/langtools/test/tools/javac/processing/errors/StopOnInapplicableAnnotations/Processor.java
+++ b/langtools/test/tools/javac/processing/errors/StopOnInapplicableAnnotations/Processor.java
@@ -63,7 +63,7 @@
         if (args.length != 1) throw new IllegalStateException("Must provide class name!");
         String testContent = null;
         List<File> sourcePath = new ArrayList<>();
-        for (String sourcePaths : System.getProperty("test.src.path").split(":")) {
+        for (String sourcePaths : System.getProperty("test.src.path").split(File.pathSeparator)) {
             sourcePath.add(new File(sourcePaths));
         }
         JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
diff --git a/langtools/test/tools/javac/processing/model/LocalClasses/LocalClassesModel.java b/langtools/test/tools/javac/processing/model/LocalClasses/LocalClassesModel.java
index a753057..d91a84d 100644
--- a/langtools/test/tools/javac/processing/model/LocalClasses/LocalClassesModel.java
+++ b/langtools/test/tools/javac/processing/model/LocalClasses/LocalClassesModel.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
  * @bug 8166700
  * @summary Check that local classes originating in static initializer can be loaded properly.
  * @modules jdk.compiler
- * @build LocalTest$1Local LocalTest$2Local LocalTest$3Local LocalTest$4Local LocalTest$5Local LocalTest
+ * @library /tools/javac/lib
+ * @build LocalTest$1Local LocalTest$2Local LocalTest$3Local LocalTest$4Local LocalTest$5Local LocalTest JavacTestingAbstractProcessor
  * @compile LocalClassesModel.java
  * @compile/process/ref=LocalClassesModel.out -processor LocalClassesModel LocalTest$1Local LocalTest$2Local LocalTest$3Local LocalTest$4Local LocalTest$5Local LocalTest
  */
@@ -42,8 +43,7 @@
 import javax.lang.model.element.VariableElement;
 import javax.lang.model.util.ElementFilter;
 
-@SupportedAnnotationTypes("*")
-public class LocalClassesModel extends AbstractProcessor {
+public class LocalClassesModel extends JavacTestingAbstractProcessor {
 
     @Override
     public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
@@ -65,9 +65,4 @@
 
         return false;
     }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latestSupported();
-    }
 }
diff --git a/langtools/test/tools/javac/processing/model/TestSourceVersion.java b/langtools/test/tools/javac/processing/model/TestSourceVersion.java
index 396fe10..27da94d 100644
--- a/langtools/test/tools/javac/processing/model/TestSourceVersion.java
+++ b/langtools/test/tools/javac/processing/model/TestSourceVersion.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7025809 8028543 6415644
+ * @bug 7025809 8028543 6415644 8028544 8029942
  * @summary Test latest, latestSupported, underscore as keyword, etc.
  * @author  Joseph D. Darcy
  * @modules java.compiler
@@ -44,8 +44,8 @@
     }
 
     private static void testLatestSupported() {
-        if (SourceVersion.latest() != RELEASE_9 ||
-            SourceVersion.latestSupported() != RELEASE_9)
+        if (SourceVersion.latest() != RELEASE_10 ||
+            SourceVersion.latestSupported() != RELEASE_10)
             throw new RuntimeException("Unexpected release value(s) found:\n" +
                                        "latest:\t" + SourceVersion.latest() + "\n" +
                                        "latestSupported:\t" + SourceVersion.latestSupported());
diff --git a/langtools/test/tools/javac/processing/model/nestedTypeVars/NestedTypeVars.java b/langtools/test/tools/javac/processing/model/nestedTypeVars/NestedTypeVars.java
index 24a6209..1332866 100644
--- a/langtools/test/tools/javac/processing/model/nestedTypeVars/NestedTypeVars.java
+++ b/langtools/test/tools/javac/processing/model/nestedTypeVars/NestedTypeVars.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,8 @@
 /**
  * @test
  * @modules jdk.compiler
- * @build NestedTypeVars
+ * @library /tools/javac/lib
+ * @build NestedTypeVars JavacTestingAbstractProcessor
  * @compile/process/ref=NestedTypeVars.out -processor NestedTypeVars Test$1L1$L2$1L3$L4$L5 Test$1L1$CCheck Test$1L1 Test$1CCheck Test$CCheck Test
  */
 
@@ -44,8 +45,7 @@
 import javax.lang.model.type.TypeVariable;
 import javax.lang.model.util.ElementFilter;
 
-@SupportedAnnotationTypes("*")
-public class NestedTypeVars extends AbstractProcessor{
+public class NestedTypeVars extends JavacTestingAbstractProcessor {
 
     @Override
     public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
@@ -102,12 +102,6 @@
                 throw new IllegalStateException("Unexpected element: " + el + "(" + el.getKind() + ")");
         }
     }
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latestSupported();
-    }
-
-
 }
 
 class Test<T1, C> {
diff --git a/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java b/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java
index 4e49da3..5b9365e 100644
--- a/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java
+++ b/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java
@@ -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
@@ -35,6 +35,7 @@
  * @compile/ref=gold_unsp_warn.out     -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_6 -source 1.6 -Xlint:-options -Aunsupported HelloWorld.java
  * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_7 -source 1.7 -Xlint:-options HelloWorld.java
  * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_8 -source 1.8 -Xlint:-options HelloWorld.java
+ * @compile/ref=gold_sv_none.out       -XDrawDiagnostics -processor TestSourceVersionWarnings -proc:only -ASourceVersion=RELEASE_9 -source 1.9 -Xlint:-options HelloWorld.java
  */
 
 import java.util.Set;
diff --git a/langtools/test/tools/javac/profiles/ProfileOptionTest.java b/langtools/test/tools/javac/profiles/ProfileOptionTest.java
index af6a118..37c98fd 100644
--- a/langtools/test/tools/javac/profiles/ProfileOptionTest.java
+++ b/langtools/test/tools/javac/profiles/ProfileOptionTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -148,6 +148,7 @@
                             error("unexpected exception from compiler: " + ise);
                         break;
                     case JDK1_9:
+                    case JDK1_10:
                         if (p == Profile.DEFAULT)
                             break;
                         if (ise == null)
diff --git a/langtools/test/tools/javac/tree/ArrayTypeToString.java b/langtools/test/tools/javac/tree/ArrayTypeToString.java
index a200f6d..9de443a 100644
--- a/langtools/test/tools/javac/tree/ArrayTypeToString.java
+++ b/langtools/test/tools/javac/tree/ArrayTypeToString.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
  * @bug 8068737
  * @summary Tests ArrayType.toString with type annotations present
  * @modules jdk.compiler/com.sun.tools.javac.code
- * @build ArrayTypeToString
+ * @library /tools/javac/lib
+ * @build ArrayTypeToString JavacTestingAbstractProcessor
  * @compile/ref=ArrayTypeToString.out -XDaccessInternalAPI -XDrawDiagnostics -processor ArrayTypeToString -proc:only ArrayTypeToString.java
  */
 
@@ -54,8 +55,7 @@
 }
 
 @SupportedAnnotationTypes("Foo")
-@SupportedSourceVersion(SourceVersion.RELEASE_9)
-public class ArrayTypeToString extends AbstractProcessor {
+public class ArrayTypeToString extends JavacTestingAbstractProcessor {
     @Foo(0) String @Foo(1)[] @Foo(2)[] @Foo(3)[] field;
 
     public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
diff --git a/langtools/test/tools/javac/tree/JavacTreeScannerTest.java b/langtools/test/tools/javac/tree/JavacTreeScannerTest.java
index 66189f1..b111d18 100644
--- a/langtools/test/tools/javac/tree/JavacTreeScannerTest.java
+++ b/langtools/test/tools/javac/tree/JavacTreeScannerTest.java
@@ -41,7 +41,7 @@
  *          jdk.compiler/com.sun.tools.javac.tree
  *          jdk.compiler/com.sun.tools.javac.util
  * @build AbstractTreeScannerTest JavacTreeScannerTest
- * @run main/othervm JavacTreeScannerTest -q -r .
+ * @run main JavacTreeScannerTest -q -r .
  */
 
 import java.io.*;
diff --git a/langtools/test/tools/javac/tree/SourceTreeScannerTest.java b/langtools/test/tools/javac/tree/SourceTreeScannerTest.java
index b08b36b..c272425 100644
--- a/langtools/test/tools/javac/tree/SourceTreeScannerTest.java
+++ b/langtools/test/tools/javac/tree/SourceTreeScannerTest.java
@@ -41,7 +41,7 @@
  *          jdk.compiler/com.sun.tools.javac.tree
  *          jdk.compiler/com.sun.tools.javac.util
  * @build AbstractTreeScannerTest SourceTreeScannerTest
- * @run main/othervm SourceTreeScannerTest -q -r .
+ * @run main SourceTreeScannerTest -q -r .
  */
 
 import java.io.*;
diff --git a/langtools/test/tools/javac/tree/TreePosTest.java b/langtools/test/tools/javac/tree/TreePosTest.java
index ffd0190..2fbed64 100644
--- a/langtools/test/tools/javac/tree/TreePosTest.java
+++ b/langtools/test/tools/javac/tree/TreePosTest.java
@@ -108,7 +108,7 @@
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.tree
  *          jdk.compiler/com.sun.tools.javac.util
- * @run main/othervm TreePosTest -q -r .
+ * @run main TreePosTest -q -r .
  */
 public class TreePosTest {
     /**
diff --git a/langtools/test/tools/javac/varargs/7043922/T7043922.java b/langtools/test/tools/javac/varargs/7043922/T7043922.java
index 5fc83af..b9624d0 100644
--- a/langtools/test/tools/javac/varargs/7043922/T7043922.java
+++ b/langtools/test/tools/javac/varargs/7043922/T7043922.java
@@ -28,7 +28,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.util
- * @run main/othervm T7043922
  */
 
 import com.sun.source.util.JavacTask;
diff --git a/langtools/test/tools/javac/versions/Versions.java b/langtools/test/tools/javac/versions/Versions.java
index f90f449..9d64400 100644
--- a/langtools/test/tools/javac/versions/Versions.java
+++ b/langtools/test/tools/javac/versions/Versions.java
@@ -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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 8000961 8030610
+ * @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 8000961 8030610 8028546
  * @summary Check interpretation of -target and -source options
  * @modules java.compiler
  *          jdk.compiler
@@ -69,6 +69,7 @@
         check("53.0", "-source 1.7");
         check("53.0", "-source 1.8");
         check("53.0", "-source 1.9");
+        check("53.0", "-source 1.10");
 
         check_source_target("50.0", "6", "6");
         check_source_target("51.0", "6", "7");
@@ -80,6 +81,7 @@
         check_source_target("53.0", "7", "9");
         check_source_target("53.0", "8", "9");
         check_source_target("53.0", "9", "9");
+        check_source_target("53.0", "10", "10");
 
         checksrc16("-source 1.6");
         checksrc16("-source 6");
@@ -93,19 +95,26 @@
         checksrc18("-source 8");
         checksrc18("-source 1.8", "-target 1.8");
         checksrc18("-source 8", "-target 8");
-        checksrc19();
         checksrc19("-source 1.9");
         checksrc19("-source 9");
         checksrc19("-source 1.9", "-target 1.9");
         checksrc19("-source 9", "-target 9");
-        checksrc19("-target 1.9");
-        checksrc19("-target 9");
+
+        checksrc110();
+        checksrc110("-source 1.10");
+        checksrc110("-source 10");
+        checksrc110("-source 1.10", "-target 1.10");
+        checksrc110("-source 10", "-target 10");
+        checksrc110("-target 1.10");
+        checksrc110("-target 10");
 
         fail("-source 7", "-target 1.6", "Base.java");
         fail("-source 8", "-target 1.6", "Base.java");
         fail("-source 8", "-target 1.7", "Base.java");
         fail("-source 9", "-target 1.7", "Base.java");
         fail("-source 9", "-target 1.8", "Base.java");
+        fail("-source 10", "-target 1.7", "Base.java");
+        fail("-source 10", "-target 1.8", "Base.java");
 
         fail("-source 1.5", "-target 1.5", "Base.java");
         fail("-source 1.4", "-target 1.4", "Base.java");
@@ -202,6 +211,11 @@
         checksrc18(args);
     }
 
+    protected void checksrc110(String... args) {
+        printargs("checksrc110", args);
+        checksrc19(args);
+    }
+
     protected void pass(String... args) {
         printargs("pass", args);
 
diff --git a/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java b/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java
index 9d198b7..6171270 100644
--- a/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java
+++ b/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java
@@ -66,7 +66,7 @@
         if (args.length != 1) throw new IllegalStateException("Must provide class name!");
         String testContent = null;
         List<File> sourcePath = new ArrayList<>();
-        for (String sourcePaths : System.getProperty("test.src.path").split(":")) {
+        for (String sourcePaths : System.getProperty("test.src.path").split(File.pathSeparator)) {
             sourcePath.add(new File(sourcePaths));
         }
         JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
diff --git a/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestRelease.java b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestRelease.java
index d1c833e..c3c2d87 100644
--- a/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestRelease.java
+++ b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestRelease.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,6 +49,7 @@
         assertTrue(invoke("7"));
         assertTrue(invoke("8"));
         assertTrue(invoke("9"));
+        assertTrue(invoke("10"));
     }
 
     @Test
diff --git a/make/Init.gmk b/make/Init.gmk
index 0adb842..79779e1 100644
--- a/make/Init.gmk
+++ b/make/Init.gmk
@@ -117,7 +117,7 @@
     # Check that CONF_CHECK is valid.
     $(eval $(call ParseConfCheckOption))
 
-    # Check that the LOG given is valid, and set LOG_LEVEL, LOG_NOFILE and MAKE_LOG_FLAGS.
+    # Check that the LOG given is valid, and set LOG_LEVEL, LOG_NOFILE, MAKE_LOG_VARS and MAKE_LOG_FLAGS.
     $(eval $(call ParseLogLevel))
 
     # After this SPECS contain 1..N spec files (otherwise ParseConfAndSpec fails).
@@ -171,7 +171,7 @@
 
     MAKE_INIT_WITH_SPEC_ARGUMENTS := ACTUAL_TOPDIR=$(topdir) \
         USER_MAKE_VARS="$(USER_MAKE_VARS)" MAKE_LOG_FLAGS=$(MAKE_LOG_FLAGS) \
-        LOG_LEVEL=$(LOG_LEVEL) LOG_NOFILE=$(LOG_NOFILE) LOG_CMDLINES=$(LOG_CMDLINES) \
+        $(MAKE_LOG_VARS) \
         INIT_TARGETS="$(INIT_TARGETS)" \
         SEQUENTIAL_TARGETS="$(SEQUENTIAL_TARGETS)" \
         PARALLEL_TARGETS="$(PARALLEL_TARGETS)"
@@ -319,6 +319,7 @@
 	    exit 1 ; \
 	  fi
 	  $(PRINTF) "Finished building $(TARGET_DESCRIPTION)\n" $(BUILD_LOG_PIPE)
+	  $(call ReportProfileTimes)
         endif
 
     on-failure:
@@ -327,6 +328,7 @@
 	$(call ReportBuildTimes)
 	$(call PrintFailureReports)
 	$(call PrintBuildLogFailures)
+	$(call ReportProfileTimes)
 	$(PRINTF) "Hint: If caused by a warning, try configure --disable-warnings-as-errors.\n\n"
         ifneq ($(COMPARE_BUILD), )
 	  $(call CleanupCompareBuild)
diff --git a/make/InitSupport.gmk b/make/InitSupport.gmk
index 9bab7e5..ecb8f8b 100644
--- a/make/InitSupport.gmk
+++ b/make/InitSupport.gmk
@@ -158,6 +158,18 @@
     # If the "cmdline" argument is given, act on it and strip it away
     $$(eval $$(call ParseLogOption, cmdlines, LOG_CMDLINES))
 
+    # If the "profile-to-log" argument is given, write shell times in build log
+    $$(eval $$(call ParseLogOption, profile-to-log, LOG_PROFILE_TIMES_LOG))
+
+    # If the "profile" argument is given, write shell times in separate log file
+    # IMPORTANT: $(ParseLogOption profile-to-log) should go first. Otherwise
+    # parsing of 'LOG=debug,profile-to-log,nofile' ends up in the following error:
+    # Error: LOG contains unknown option or log level: debug-to-log.
+    $$(eval $$(call ParseLogOption, profile, LOG_PROFILE_TIMES_FILE))
+
+    # Treat LOG=profile-to-log as if it were LOG=profile,profile-to-log
+    LOG_PROFILE_TIMES_FILE := $$(firstword $$(LOG_PROFILE_TIMES_FILE) $$(LOG_PROFILE_TIMES_LOG))
+
     LOG_LEVEL := $$(LOG)
 
     ifeq ($$(LOG_LEVEL),)
@@ -175,7 +187,7 @@
       MAKE_LOG_FLAGS :=
     else
       $$(info Error: LOG contains unknown option or log level: $$(LOG).)
-      $$(info LOG can be <level>[,<opt>[...]] where <opt> is nofile | cmdlines)
+      $$(info LOG can be <level>[,<opt>[...]] where <opt> is nofile | cmdlines | profile | profile-to-log)
       $$(info and <level> is warn | info | debug | trace)
       $$(error Cannot continue)
     endif
@@ -309,7 +321,7 @@
 	@( cd $$(topdir) && \
 	$$(MAKE) $$(MAKE_LOG_FLAGS) -r -R -f $$(topdir)/make/Main.gmk \
 	    -I $$(topdir)/make/common SPEC=$(strip $2) NO_RECIPES=true \
-	    LOG_LEVEL=$$(LOG_LEVEL) \
+	    $$(MAKE_LOG_VARS) \
 	    create-main-targets-include )
 
     # Now include main-targets.gmk. This will define ALL_MAIN_TARGETS.
@@ -334,7 +346,7 @@
 
   # Define basic logging setup
   BUILD_LOG := $(OUTPUT_ROOT)/build.log
-  BUILD_TRACE_LOG := $(OUTPUT_ROOT)/build-trace-time.log
+  BUILD_PROFILE_LOG := $(OUTPUT_ROOT)/build-profile.log
 
   BUILD_LOG_PIPE := > >($(TEE) -a $(BUILD_LOG)) 2> >($(TEE) -a $(BUILD_LOG) >&2) && wait
 
@@ -494,9 +506,9 @@
   define RotateLogFiles
 	$(RM) $(BUILD_LOG).old 2> /dev/null && \
 	$(MV) $(BUILD_LOG) $(BUILD_LOG).old 2> /dev/null || true
-	$(if $(findstring trace, $(LOG_LEVEL)), \
-	  $(RM) $(BUILD_TRACE_LOG).old 2> /dev/null && \
-	  $(MV) $(BUILD_TRACE_LOG) $(BUILD_TRACE_LOG).old 2> /dev/null || true \
+	$(if $(findstring true, $(LOG_PROFILE_TIMES_FILE)), \
+	  $(RM) $(BUILD_PROFILE_LOG).old 2> /dev/null && \
+	  $(MV) $(BUILD_PROFILE_LOG) $(BUILD_PROFILE_LOG).old 2> /dev/null || true \
 	)
   endef
 
@@ -558,6 +570,22 @@
 	    $(BUILD_LOG_PIPE)
   endef
 
+  define ReportProfileTimes
+    $(if $(findstring true, $(LOG_PROFILE_TIMES_LOG)), \
+      [ ! -f $(BUILD_PROFILE_LOG) ] || \
+      { $(ECHO) Begin $(notdir $(BUILD_PROFILE_LOG)) && \
+        $(CAT) $(BUILD_PROFILE_LOG) && \
+        $(ECHO) End $(notdir $(BUILD_PROFILE_LOG)); \
+      } \
+      $(BUILD_LOG_PIPE)
+    )
+  endef
+
 endif # HAS_SPEC
 
+MAKE_LOG_VARS = $(foreach v, \
+    LOG_LEVEL LOG_NOFILE LOG_CMDLINES LOG_PROFILE_TIMES_LOG LOG_PROFILE_TIMES_FILE, \
+    $v=$($v) \
+)
+
 endif # _INITSUPPORT_GMK
diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk
index 0a9c6b6..c94fbe0 100644
--- a/make/common/MakeBase.gmk
+++ b/make/common/MakeBase.gmk
@@ -355,17 +355,28 @@
 ################################################################################
 
 define SetupLogging
+  ifeq ($$(LOG_PROFILE_TIMES_FILE), true)
+    ifeq ($$(IS_GNU_TIME), yes)
+      SHELL :=  $$(BASH) $$(SRC_ROOT)/common/bin/shell-profiler.sh \
+                gnutime $$(TIME) \
+                $$(OUTPUT_ROOT)/build-profile.log $$(SHELL)
+    else ifneq ($$(FLOCK), )
+      SHELL :=  $$(BASH) $$(SRC_ROOT)/common/bin/shell-profiler.sh \
+                flock $$(FLOCK) \
+                $$(OUTPUT_ROOT)/build-profile.log $$(SHELL)
+    endif
+  endif
+
   ifeq ($$(LOG_LEVEL), trace)
+    SHELL_NO_RECURSE := $$(SHELL)
     # Shell redefinition trick inspired by http://www.cmcrossroads.com/ask-mr-make/6535-tracing-rule-execution-in-gnu-make
     # For each target executed, will print
     # Building <TARGET> (from <FIRST PREREQUISITE>) (<ALL NEWER PREREQUISITES> newer)
     # but with a limit of 20 on <ALL NEWER PREREQUISITES>, to avoid cluttering logs too much
     # (and causing a crash on Cygwin).
-    # Default shell seems to always be /bin/sh. Must override with bash to get this to work on Solaris.
-    # Only use time if it's GNU time which supports format and output file.
-    WRAPPER_SHELL := $$(BASH) $$(SRC_ROOT)/common/bin/shell-tracer.sh $$(if $$(findstring yes,$$(IS_GNU_TIME)),$$(TIME),-) $$(OUTPUT_ROOT)/build-trace-time.log $$(SHELL)
-    SHELL = $$(warning $$(if $$@,Building $$@,Running shell command) $$(if $$<, (from $$<))$$(if $$?, ($$(wordlist 1, 20, $$?) $$(if $$(wordlist 21, 22, $$?), ... [in total $$(words $$?) files]) newer)))$$(WRAPPER_SHELL)
+    SHELL = $$(warning $$(if $$@,Building $$@,Running shell command) $$(if $$<, (from $$<))$$(if $$?, ($$(wordlist 1, 20, $$?) $$(if $$(wordlist 21, 22, $$?), ... [in total $$(words $$?) files]) newer)))$$(SHELL_NO_RECURSE) -x
   endif
+
   # The warn level can never be turned off
   LogWarn = $$(info $$(strip $$1))
   LOG_WARN :=
diff --git a/make/common/SetupJavaCompilers.gmk b/make/common/SetupJavaCompilers.gmk
index 1a80d47..56417d9 100644
--- a/make/common/SetupJavaCompilers.gmk
+++ b/make/common/SetupJavaCompilers.gmk
@@ -69,7 +69,7 @@
 $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \
     JVM := $(JAVA_JAVAC), \
     JAVAC := $(NEW_JAVAC), \
-    FLAGS := -source 9 -target 9 \
+    FLAGS := -source 10 -target 10 \
         -encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS), \
     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
@@ -79,7 +79,7 @@
 $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \
     JVM := $(JAVA_JAVAC), \
     JAVAC := $(NEW_JAVAC), \
-    FLAGS := -source 9 -target 9 \
+    FLAGS := -source 10 -target 10 \
         -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS), \
     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
diff --git a/nashorn/.hgtags b/nashorn/.hgtags
index 309e95d..ef87722 100644
--- a/nashorn/.hgtags
+++ b/nashorn/.hgtags
@@ -387,9 +387,11 @@
 2a0437036a64853334e538044eb68d2df70075fa jdk-9+151
 ddc52e72757086a75a54371e8e7f56a3f89f1e55 jdk-9+152
 19aaaf2d02b7d6986538cd9a8c46901ecb50eebf jdk-9+153
+a84b49cfee63716975535abae2865ffef4dd6474 jdk-10+0
 a84b49cfee63716975535abae2865ffef4dd6474 jdk-9+154
 f9bb37a817b3cd3b758a60f3c68258a6554eb382 jdk-9+155
 d577398d31111be4bdaa08008247cf4242eaea94 jdk-9+156
+ac893c3a86ddeda4bed2573037175a2913ec570e jdk-10+1
 f6070efba6af0dc003e24ca736426c93e99ee96a jdk-9+157
 13ae2480a4c395026b3aa1739e0f9895dc8b25d9 jdk-9+158
 d75af059cff651c1b5cccfeb4c9ea8d054b28cfd jdk-9+159
@@ -400,6 +402,14 @@
 b473fab09baab51a06ffba02eb06c7f5ee8578f7 jdk-9+164
 e36e62d3ea53c316f295b37bcc19867fbf510235 jdk-9+165
 5b2e7b2101c0048ba9f1df722e56611f523fdfe8 jdk-9+166
+47277bbced66869e17899eee7ac197b78a5c69b8 jdk-10+2
+a76a5e1c9d0b94541826e2121f5754aaa78f0376 jdk-10+3
+e6bc0ad505e65c884a66c42cc92b24371ccf971d jdk-10+4
+59278e0c6ccd7cc6d2427c29e8c3446fc2af0e26 jdk-10+5
+0c5f25cc0d1b89664d1517a256b805e2a97116a4 jdk-10+6
 e118c818dbf84d15191414c453b77c089116fdc0 jdk-9+167
 0f81cde5a1f75786f381dbfb59b9afbab70174c7 jdk-9+168
 131e250080158e57ce45130560f5f987b92642b5 jdk-9+169
+550bfc15779f8f339610793867fdc251125811b5 jdk-9+170
+7e9cb37e6d6edbe56fdf4d510e5110f797823f09 jdk-10+7
+edb825e2dfb140c8e57a61b5d45de19edebccccf jdk-10+8
diff --git a/nashorn/.jcheck/conf b/nashorn/.jcheck/conf
index 5c6f62d..b258135 100644
--- a/nashorn/.jcheck/conf
+++ b/nashorn/.jcheck/conf
@@ -1 +1 @@
-project=jdk9
+project=jdk10
diff --git a/test/lib/jdk/test/lib/JDKToolLauncher.java b/test/lib/jdk/test/lib/JDKToolLauncher.java
index 38e7b45..6c26470 100644
--- a/test/lib/jdk/test/lib/JDKToolLauncher.java
+++ b/test/lib/jdk/test/lib/JDKToolLauncher.java
@@ -24,9 +24,7 @@
 package jdk.test.lib;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
-import jdk.test.lib.process.ProcessTools;
 
 /**
  * A utility for constructing command lines for starting JDK tool processes.
@@ -59,7 +57,6 @@
         } else {
             executable = JDKToolFinder.getTestJDKTool(tool);
         }
-        vmArgs.addAll(Arrays.asList(ProcessTools.getPlatformSpecificVMArgs()));
     }
 
     /**
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/LockFreeLogManager.java b/test/lib/jdk/test/lib/LockFreeLogger.java
similarity index 73%
rename from jdk/test/lib/testlibrary/jdk/testlibrary/LockFreeLogManager.java
rename to test/lib/jdk/test/lib/LockFreeLogger.java
index f895018..4e96b9a 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/LockFreeLogManager.java
+++ b/test/lib/jdk/test/lib/LockFreeLogger.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,10 +21,10 @@
  * questions.
  */
 
-package jdk.testlibrary;
+package jdk.test.lib;
 
 import java.util.Collection;
-import java.util.Formatter;
+import java.util.Comparator;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
@@ -32,32 +32,28 @@
 import java.util.stream.Collectors;
 
 /**
- * A log manager designed specifically to allow collecting ordered log messages
+ * A logger designed specifically to allow collecting ordered log messages
  * in a multi-threaded environment without involving any kind of locking.
  * <p>
  * It is particularly useful in situations when one needs to assert various
  * details about the tested thread state or the locks it hold while also wanting
  * to produce diagnostic log messages.
  * <p>
- * The log manager does not provide any guarantees about the completness of the
+ * The logger does not provide any guarantees about the completness of the
  * logs written from different threads - it is up to the caller to make sure
  * {@code toString()} method is called only when all the activity has ceased
  * and the per-thread logs contain all the necessary data.
  *
  * @author Jaroslav Bachorik
  **/
-public class LockFreeLogManager {
+public class LockFreeLogger {
     private final AtomicInteger logCntr = new AtomicInteger(0);
     private final Collection<Map<Integer, String>> allRecords = new ConcurrentLinkedQueue<>();
-    private final ThreadLocal<Map<Integer, String>> records = new ThreadLocal<Map<Integer, String>>() {
-        @Override
-        protected Map<Integer, String> initialValue() {
-            Map<Integer, String> m = new ConcurrentHashMap<>();
-            allRecords.add(m);
-            return m;
-        }
+    private final ThreadLocal<Map<Integer, String>> records = ThreadLocal.withInitial(ConcurrentHashMap::new);
 
-    };
+    public LockFreeLogger() {
+        allRecords.add(records.get());
+    }
 
     /**
      * Log a message
@@ -66,9 +62,7 @@
      */
     public void log(String format, Object ... params) {
         int id = logCntr.getAndIncrement();
-        try (Formatter formatter = new Formatter()) {
-            records.get().put(id, formatter.format(format, params).toString());
-        }
+        records.get().put(id, String.format(format, params));
     }
 
     /**
@@ -82,9 +76,9 @@
     @Override
     public String toString() {
         return allRecords.stream()
-            .flatMap(m->m.entrySet().stream())
-            .sorted((l, r)->l.getKey().compareTo(r.getKey()))
-            .map(e->e.getValue())
+            .flatMap(m -> m.entrySet().stream())
+            .sorted(Comparator.comparing(Map.Entry::getKey))
+            .map(Map.Entry::getValue)
             .collect(Collectors.joining());
     }
 }
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/NetworkConfiguration.java b/test/lib/jdk/test/lib/NetworkConfiguration.java
similarity index 66%
rename from jdk/test/lib/testlibrary/jdk/testlibrary/NetworkConfiguration.java
rename to test/lib/jdk/test/lib/NetworkConfiguration.java
index 77544d2..b8a4720 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/NetworkConfiguration.java
+++ b/test/lib/jdk/test/lib/NetworkConfiguration.java
@@ -21,7 +21,7 @@
  * questions.
  */
 
-package jdk.testlibrary;
+package jdk.test.lib;
 
 import java.io.PrintStream;
 import java.io.UncheckedIOException;
@@ -35,8 +35,8 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 import java.util.function.Predicate;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import static java.net.NetworkInterface.getNetworkInterfaces;
 import static java.util.Collections.list;
@@ -47,17 +47,12 @@
  */
 public class NetworkConfiguration {
 
-    static final boolean isWindows =
-            System.getProperty("os.name").startsWith("Windows");
-    static final boolean isMacOS =
-            System.getProperty("os.name").contains("OS X");
-
     private Map<NetworkInterface,List<Inet4Address>> ip4Interfaces;
     private Map<NetworkInterface,List<Inet6Address>> ip6Interfaces;
 
-    private NetworkConfiguration(Map<NetworkInterface,List<Inet4Address>> ip4Interfaces,
-                                 Map<NetworkInterface,List<Inet6Address>> ip6Interfaces)
-    {
+    private NetworkConfiguration(
+            Map<NetworkInterface,List<Inet4Address>> ip4Interfaces,
+            Map<NetworkInterface,List<Inet6Address>> ip6Interfaces) {
         this.ip4Interfaces = ip4Interfaces;
         this.ip6Interfaces = ip6Interfaces;
     }
@@ -74,44 +69,38 @@
      * Returns a stream of interfaces suitable for IPv4 functional tests.
      */
     public Stream<NetworkInterface> ip4Interfaces() {
-        return ip4Interfaces.keySet().stream()
-                .filter(NetworkConfiguration::isNotExcludedInterface)
-                .filter(hasIp4Addresses);
+        return ip4Interfaces.keySet()
+                            .stream()
+                            .filter(NetworkConfiguration::isNotExcludedInterface)
+                            .filter(hasIp4Addresses);
     }
 
     /**
      * Returns a stream of interfaces suitable for IPv6 functional tests.
      */
     public Stream<NetworkInterface> ip6Interfaces() {
-        return ip6Interfaces.keySet().stream()
-                .filter(NetworkConfiguration::isNotExcludedInterface)
-                .filter(hasIp6Addresses);
+        return ip6Interfaces.keySet()
+                            .stream()
+                            .filter(NetworkConfiguration::isNotExcludedInterface)
+                            .filter(hasIp6Addresses);
     }
 
     private static boolean isNotExcludedInterface(NetworkInterface nif) {
-        if (isMacOS && nif.getName().contains("awdl"))
+        if (Platform.isOSX() && nif.getName().contains("awdl")) {
             return false;
+        }
         String dName = nif.getDisplayName();
-        if (isWindows && dName != null && dName.contains("Teredo"))
+        if (Platform.isWindows() && dName != null && dName.contains("Teredo")) {
             return false;
+        }
         return true;
     }
 
-    private final Predicate<NetworkInterface> hasIp4Addresses = nif -> {
-        Optional<?> addr = ip4Interfaces.get(nif).stream()
-                .filter(a -> !a.isAnyLocalAddress())
-                .findAny();
+    private final Predicate<NetworkInterface> hasIp4Addresses = nif ->
+            ip4Interfaces.get(nif).stream().anyMatch(a -> !a.isAnyLocalAddress());
 
-        return addr.isPresent();
-    };
-
-    private final Predicate<NetworkInterface> hasIp6Addresses = nif -> {
-        Optional<?> addr = ip6Interfaces.get(nif).stream()
-                .filter(a -> !a.isAnyLocalAddress())
-                .findAny();
-
-        return addr.isPresent();
-    };
+    private final Predicate<NetworkInterface> hasIp6Addresses = nif ->
+            ip6Interfaces.get(nif).stream().anyMatch(a -> !a.isAnyLocalAddress());
 
 
     /**
@@ -130,14 +119,10 @@
 
     private final Predicate<NetworkInterface> supportsIp4Multicast = nif -> {
         try {
-            if (!nif.supportsMulticast() || nif.isLoopback())
+            if (!nif.supportsMulticast() || nif.isLoopback()) {
                 return false;
-
-            Optional<?> addr = ip4Interfaces.get(nif).stream()
-                    .filter(a -> !a.isAnyLocalAddress())
-                    .findAny();
-
-            return addr.isPresent();
+            }
+            return hasIp4Addresses.test(nif);
         } catch (IOException e) {
             throw new UncheckedIOException(e);
         }
@@ -145,14 +130,11 @@
 
     private final Predicate<NetworkInterface> supportsIp6Multicast = nif -> {
         try {
-            if (!nif.supportsMulticast() || nif.isLoopback())
+            if (!nif.supportsMulticast() || nif.isLoopback()) {
                 return false;
+            }
 
-            Optional<?> addr = ip6Interfaces.get(nif).stream()
-                    .filter(a -> !a.isAnyLocalAddress())
-                    .findAny();
-
-            return addr.isPresent();
+            return hasIp6Addresses.test(nif);
         } catch (IOException e) {
             throw new UncheckedIOException(e);
         }
@@ -170,14 +152,14 @@
      * Returns all IPv4 addresses on all "functional" interfaces.
      */
     public Stream<Inet4Address> ip4Addresses() {
-        return ip4Interfaces().flatMap(nif -> ip4Addresses(nif));
+        return ip4Interfaces().flatMap(this::ip4Addresses);
     }
 
     /**
      * Returns all IPv6 addresses on all "functional" interfaces.
      */
     public Stream<Inet6Address> ip6Addresses() {
-        return ip6Interfaces().flatMap(nif -> ip6Addresses(nif));
+        return ip6Interfaces().flatMap(this::ip6Addresses);
     }
 
     /**
@@ -204,18 +186,20 @@
         List<NetworkInterface> nifs = list(getNetworkInterfaces());
         for (NetworkInterface nif : nifs) {
             // ignore interfaces that are down
-            if (!nif.isUp() || nif.isPointToPoint())
+            if (!nif.isUp() || nif.isPointToPoint()) {
                 continue;
+            }
 
             List<Inet4Address> ip4Addresses = new LinkedList<>();
             List<Inet6Address> ip6Addresses = new LinkedList<>();
             ip4Interfaces.put(nif, ip4Addresses);
             ip6Interfaces.put(nif, ip6Addresses);
             for (InetAddress addr : list(nif.getInetAddresses())) {
-                if (addr instanceof Inet4Address)
-                    ip4Addresses.add((Inet4Address)addr);
-                else if (addr instanceof Inet6Address)
-                    ip6Addresses.add((Inet6Address)addr);
+                if (addr instanceof Inet4Address) {
+                    ip4Addresses.add((Inet4Address) addr);
+                } else if (addr instanceof Inet6Address) {
+                    ip6Addresses.add((Inet6Address) addr);
+                }
             }
         }
         return new NetworkConfiguration(ip4Interfaces, ip6Interfaces);
@@ -223,28 +207,49 @@
 
     @Override
     public String toString() {
-        StringBuilder sb = new StringBuilder();
-        interfaces().forEach(nif -> sb.append(interfaceInformation(nif)));
-        return sb.toString();
+        return interfaces().map(NetworkConfiguration::interfaceInformation)
+                           .collect(Collectors.joining());
     }
 
     /** Returns detailed information for the given interface. */
     public static String interfaceInformation(NetworkInterface nif) {
         StringBuilder sb = new StringBuilder();
         try {
-            sb.append("Display name: " + nif.getDisplayName() + "\n");
-            sb.append("Name: " + nif.getName() + "\n");
-            for (InetAddress inetAddress : list(nif.getInetAddresses()))
-                sb.append("InetAddress: " + inetAddress + "\n");
-            sb.append("Up? " + nif.isUp() + "\n");
-            sb.append("Loopback? " + nif.isLoopback() + "\n");
-            sb.append("PointToPoint? " + nif.isPointToPoint() + "\n");
-            sb.append("Supports multicast? " + nif.supportsMulticast() + "\n");
-            sb.append("Virtual? " + nif.isVirtual() + "\n");
-            sb.append("Hardware address: " +
-                    Arrays.toString(nif.getHardwareAddress()) + "\n");
-            sb.append("MTU: " + nif.getMTU() + "\n");
-            sb.append("Index: " + nif.getIndex() + "\n");
+            sb.append("Display name: ")
+              .append(nif.getDisplayName())
+              .append("\n");
+            sb.append("Name: ")
+              .append(nif.getName())
+              .append("\n");
+            for (InetAddress inetAddress : list(nif.getInetAddresses())) {
+                sb.append("InetAddress: ")
+                  .append(inetAddress)
+                  .append("\n");
+            }
+            sb.append("Up? ")
+              .append(nif.isUp())
+              .append("\n");
+            sb.append("Loopback? ")
+              .append(nif.isLoopback())
+              .append("\n");
+            sb.append("PointToPoint? ")
+              .append(nif.isPointToPoint())
+              .append("\n");
+            sb.append("Supports multicast? ")
+              .append(nif.supportsMulticast())
+              .append("\n");
+            sb.append("Virtual? ")
+              .append(nif.isVirtual())
+              .append("\n");
+            sb.append("Hardware address: ")
+              .append(Arrays.toString(nif.getHardwareAddress()))
+              .append("\n");
+            sb.append("MTU: ")
+              .append(nif.getMTU())
+              .append("\n");
+            sb.append("Index: ")
+              .append(nif.getIndex())
+              .append("\n");
             sb.append("\n");
             return sb.toString();
         } catch (IOException e) {
@@ -256,9 +261,9 @@
     public static void printSystemConfiguration(PrintStream out) {
         try {
             out.println("*** all system network interface configuration ***");
-            List<NetworkInterface> nifs = list(getNetworkInterfaces());
-            for (NetworkInterface nif : nifs)
+            for (NetworkInterface nif : list(getNetworkInterfaces())) {
                 out.print(interfaceInformation(nif));
+            }
             out.println("*** end ***");
         } catch (IOException e) {
             throw new UncheckedIOException(e);
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/FilterClassLoader.java b/test/lib/jdk/test/lib/classloader/FilterClassLoader.java
similarity index 93%
rename from jdk/test/lib/testlibrary/jdk/testlibrary/FilterClassLoader.java
rename to test/lib/jdk/test/lib/classloader/FilterClassLoader.java
index fc4e828..327b1d2 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/FilterClassLoader.java
+++ b/test/lib/jdk/test/lib/classloader/FilterClassLoader.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -20,7 +20,8 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package jdk.testlibrary;
+
+package jdk.test.lib.classloader;
 
 import java.util.function.Predicate;
 /**
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/ParentLastURLClassLoader.java b/test/lib/jdk/test/lib/classloader/ParentLastURLClassLoader.java
similarity index 93%
rename from jdk/test/lib/testlibrary/jdk/testlibrary/ParentLastURLClassLoader.java
rename to test/lib/jdk/test/lib/classloader/ParentLastURLClassLoader.java
index 5537ebd..71d8953 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/ParentLastURLClassLoader.java
+++ b/test/lib/jdk/test/lib/classloader/ParentLastURLClassLoader.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -20,7 +20,8 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-package jdk.testlibrary;
+
+package jdk.test.lib.classloader;
 
 import java.net.URL;
 import java.net.URLClassLoader;
diff --git a/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java
index 8c57487..7136915 100644
--- a/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java
+++ b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java
@@ -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
@@ -28,6 +28,7 @@
 import java.util.Collections;
 import java.util.function.BooleanSupplier;
 
+import jdk.test.lib.management.InputArguments;
 import jdk.test.lib.process.ExitCode;
 import jdk.test.lib.process.ProcessTools;
 import jdk.test.lib.process.OutputAnalyzer;
@@ -105,7 +106,7 @@
                     throws Throwable {
         List<String> finalOptions = new ArrayList<>();
         if (addTestVMOptions) {
-            Collections.addAll(finalOptions, ProcessTools.getVmInputArgs());
+            Collections.addAll(finalOptions, InputArguments.getVmInputArgs());
             Collections.addAll(finalOptions, Utils.getTestJavaOpts());
         }
         Collections.addAll(finalOptions, options);
diff --git a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/CompilerUtils.java b/test/lib/jdk/test/lib/compiler/CompilerUtils.java
similarity index 93%
rename from jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/CompilerUtils.java
rename to test/lib/jdk/test/lib/compiler/CompilerUtils.java
index afabfd7..5638dba 100644
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/CompilerUtils.java
+++ b/test/lib/jdk/test/lib/compiler/CompilerUtils.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,7 +21,7 @@
  * questions.
  */
 
-package jdk.testlibrary;
+package jdk.test.lib.compiler;
 
 import javax.tools.JavaCompiler;
 import javax.tools.StandardJavaFileManager;
@@ -67,9 +67,9 @@
                 .collect(Collectors.toList());
 
         Files.createDirectories(destination);
-        jfm.setLocation(StandardLocation.CLASS_PATH, Collections.EMPTY_LIST);
+        jfm.setLocation(StandardLocation.CLASS_PATH, Collections.emptyList());
         jfm.setLocationFromPaths(StandardLocation.CLASS_OUTPUT,
-                                 Arrays.asList(destination));
+                Collections.singletonList(destination));
 
         List<String> opts = Arrays.asList(options);
         JavaCompiler.CompilationTask task
diff --git a/jdk/test/lib/testlibrary/ModuleInfoMaker.java b/test/lib/jdk/test/lib/compiler/ModuleInfoMaker.java
similarity index 89%
rename from jdk/test/lib/testlibrary/ModuleInfoMaker.java
rename to test/lib/jdk/test/lib/compiler/ModuleInfoMaker.java
index 5e4f15a..f6438a6 100644
--- a/jdk/test/lib/testlibrary/ModuleInfoMaker.java
+++ b/test/lib/jdk/test/lib/compiler/ModuleInfoMaker.java
@@ -21,6 +21,8 @@
  * questions.
  */
 
+package jdk.test.lib.compiler;
+
 import java.io.BufferedWriter;
 import java.io.IOException;
 import java.nio.file.Files;
@@ -30,21 +32,20 @@
 import java.util.regex.Pattern;
 import java.util.stream.Stream;
 
-import static org.testng.Assert.assertTrue;
-
 /**
  * Utility class for creating test modules.
  */
 public class ModuleInfoMaker {
-    private static String MODULE_INFO_JAVA = "module-info.java";
-    private static Pattern MODULE_PATTERN =
+    private static final String MODULE_INFO_JAVA = "module-info.java";
+    private static final Pattern MODULE_PATTERN =
         Pattern.compile("module\\s+((?:\\w+\\.)*)");
-    private static Pattern PACKAGE_PATTERN =
+    private static final Pattern PACKAGE_PATTERN =
                        Pattern.compile("package\\s+(((?:\\w+\\.)*)(?:\\w+))");
-    private static Pattern CLASS_PATTERN =
+    private static final Pattern CLASS_PATTERN =
           Pattern.compile("(?:public\\s+)?(?:class|enum|interface)\\s+(\\w+)");
 
     private final Path dir;
+
     public ModuleInfoMaker(Path dir) {
         this.dir = dir;
     }
@@ -69,12 +70,13 @@
         throws IOException
     {
         Path msrc = dir.resolve(module);
-        Stream<String> args =
+        String[] args =
             Stream.concat(Arrays.stream(options),
                           Stream.of("--module-source-path",
-                                    dir.toString()));
-        assertTrue(CompilerUtils.compile(msrc, dest, args.toArray(String[]::new)),
-                   "Fail to compile " + module);
+                                    dir.toString())).toArray(String[]::new);
+        if (!CompilerUtils.compile(msrc, dest, args)) {
+            throw new Error("Fail to compile " + module);
+        }
     }
 
     static class JavaSource {
diff --git a/test/lib/jdk/test/lib/management/InputArguments.java b/test/lib/jdk/test/lib/management/InputArguments.java
new file mode 100644
index 0000000..dca3a02
--- /dev/null
+++ b/test/lib/jdk/test/lib/management/InputArguments.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.lib.management;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.RuntimeMXBean;
+import java.util.List;
+
+public class InputArguments {
+    /**
+     * Gets the array of strings containing input arguments passed to the VM
+     *
+     * @return arguments
+     */
+    public static String[] getVmInputArgs() {
+        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
+        List<String> args = runtime.getInputArguments();
+        return args.toArray(new String[args.size()]);
+    }
+}
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/management/ThreadMXBeanTool.java b/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java
similarity index 91%
rename from jdk/test/lib/testlibrary/jdk/testlibrary/management/ThreadMXBeanTool.java
rename to test/lib/jdk/test/lib/management/ThreadMXBeanTool.java
index b3f4417..eeb4297 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/management/ThreadMXBeanTool.java
+++ b/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,11 @@
  * questions.
  */
 
-package jdk.testlibrary.management;
+package jdk.test.lib.management;
 
 import java.lang.management.ManagementFactory;
 import java.lang.management.ThreadInfo;
 import java.lang.management.ThreadMXBean;
-import java.util.concurrent.TimeoutException;
 
 /**
  * A few utility methods to use ThreadMXBean.
@@ -34,7 +33,7 @@
 public final class ThreadMXBeanTool {
 
     /**
-     * Waits until {@link Thread} is in the certain {@link State}
+     * Waits until {@link Thread} is in the certain {@link Thread.State}
      * and blocking on {@code object}.
      *
      * @param state The thread state
diff --git a/test/lib/jdk/test/lib/process/OutputAnalyzer.java b/test/lib/jdk/test/lib/process/OutputAnalyzer.java
index 572610d..73936b2 100644
--- a/test/lib/jdk/test/lib/process/OutputAnalyzer.java
+++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.java
@@ -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)
diff --git a/test/lib/jdk/test/lib/process/ProcessTools.java b/test/lib/jdk/test/lib/process/ProcessTools.java
index 5066efb..eff0f36 100644
--- a/test/lib/jdk/test/lib/process/ProcessTools.java
+++ b/test/lib/jdk/test/lib/process/ProcessTools.java
@@ -28,13 +28,10 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintStream;
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.concurrent.CountDownLatch;
-import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
@@ -45,7 +42,6 @@
 import java.util.stream.Collectors;
 
 import jdk.test.lib.JDKToolFinder;
-import jdk.test.lib.Platform;
 import jdk.test.lib.Utils;
 
 public final class ProcessTools {
@@ -66,23 +62,23 @@
     }
 
     /**
-    * Pumps stdout and stderr from running the process into a String.
-    *
-    * @param processHandler ProcessHandler to run.
-    * @return Output from process.
-    * @throws IOException If an I/O error occurs.
-    */
+     * Pumps stdout and stderr from running the process into a String.
+     *
+     * @param processHandler ProcessHandler to run.
+     * @return Output from process.
+     * @throws IOException If an I/O error occurs.
+     */
     public static OutputBuffer getOutput(ProcessBuilder processBuilder) throws IOException {
         return getOutput(processBuilder.start());
     }
 
     /**
-    * Pumps stdout and stderr the running process into a String.
-    *
-    * @param process Process to pump.
-    * @return Output from process.
-    * @throws IOException If an I/O error occurs.
-    */
+     * Pumps stdout and stderr the running process into a String.
+     *
+     * @param process Process to pump.
+     * @return Output from process.
+     * @throws IOException If an I/O error occurs.
+     */
     public static OutputBuffer getOutput(Process process) throws IOException {
         ByteArrayOutputStream stderrBuffer = new ByteArrayOutputStream();
         ByteArrayOutputStream stdoutBuffer = new ByteArrayOutputStream();
@@ -304,38 +300,14 @@
     public static long getProcessId() throws Exception {
         return ProcessHandle.current().pid();
     }
-    /**
-     * Gets the array of strings containing input arguments passed to the VM
-     *
-     * @return arguments
-     */
-    public static String[] getVmInputArgs() {
-        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
-        List<String> args = runtime.getInputArguments();
-        return args.toArray(new String[args.size()]);
-    }
 
-    /**
-     * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris)
-     *
-     * @return String[] with platform specific arguments, empty if there are
-     *         none
-     */
-    public static String[] getPlatformSpecificVMArgs() {
-
-    if (Platform.is64bit() && Platform.isSolaris()) {
-            return new String[] { "-d64" };
-        }
-
-        return new String[] {};
-    }
 
 
     /**
      * Create ProcessBuilder using the java launcher from the jdk to be tested and
      * with any platform specific arguments prepended
      */
-    public static ProcessBuilder createJavaProcessBuilder(String... command) throws Exception {
+    public static ProcessBuilder createJavaProcessBuilder(String... command) {
         return createJavaProcessBuilder(false, command);
     }
 
@@ -348,12 +320,11 @@
      * @param command Arguments to pass to the java command.
      * @return The ProcessBuilder instance representing the java command.
      */
-    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) throws Exception {
+    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) {
         String javapath = JDKToolFinder.getJDKTool("java");
 
         ArrayList<String> args = new ArrayList<>();
         args.add(javapath);
-        Collections.addAll(args, getPlatformSpecificVMArgs());
 
         args.add("-cp");
         args.add(System.getProperty("java.class.path"));
@@ -386,26 +357,6 @@
 
     /**
      * Executes a test jvm process, waits for it to finish and returns the process output.
-     * The default jvm options from the test's run command, jtreg, test.vm.opts and test.java.opts, are added.
-     * The java from the test.jdk is used to execute the command.
-     *
-     * The command line will be like:
-     * {test.jdk}/bin/java {test.fromRun.opts} {test.vm.opts} {test.java.opts} cmds
-     *
-     * @param cmds User specifed arguments.
-     * @return The output from the process.
-     */
-    public static OutputAnalyzer executeTestJvmAllArgs(String... cmds) throws Throwable {
-        List<String> argsList = new ArrayList<>();
-        String[] testArgs = getVmInputArgs();
-        Collections.addAll(argsList, testArgs);
-        Collections.addAll(argsList, Utils.addTestJavaOpts(cmds));
-        ProcessBuilder pb = createJavaProcessBuilder(argsList.toArray(new String[argsList.size()]));
-        return executeProcess(pb);
-    }
-
-    /**
-     * Executes a test jvm process, waits for it to finish and returns the process output.
      * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added.
      * The java from the test.jdk is used to execute the command.
      *
@@ -414,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 {
@@ -423,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.
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/SerializationUtils.java b/test/lib/jdk/test/lib/util/SerializationUtils.java
similarity index 70%
rename from jdk/test/lib/testlibrary/jdk/testlibrary/SerializationUtils.java
rename to test/lib/jdk/test/lib/util/SerializationUtils.java
index 3dbc666..3b6e65a 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/SerializationUtils.java
+++ b/test/lib/jdk/test/lib/util/SerializationUtils.java
@@ -21,31 +21,36 @@
  * questions.
  */
 
-package jdk.testlibrary;
+package jdk.test.lib.util;
 
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 
 /**
  * Common library for various test serialization utility functions.
  */
 public final class SerializationUtils {
-    /*
+    /**
      * Serialize an object into byte array.
      */
-    public static byte[] serialize(Object obj) throws Exception {
-        try (ByteArrayOutputStream bs = new ByteArrayOutputStream();
-                ObjectOutputStream out = new ObjectOutputStream(bs);) {
+    public static byte[] serialize(Object obj) throws IOException {
+        ByteArrayOutputStream bs = new ByteArrayOutputStream();
+        try (ObjectOutputStream out = new ObjectOutputStream(bs)) {
             out.writeObject(obj);
-            return bs.toByteArray();
         }
+        return bs.toByteArray();
     }
 
-    /*
+    /**
      * Deserialize an object from byte array.
      */
-    public static Object deserialize(byte[] ba) throws Exception {
-        try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(ba));) {
+    public static Object deserialize(byte[] ba) throws IOException, ClassNotFoundException {
+        try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(ba))) {
             return in.readObject();
         }
     }
+    private SerializationUtils() {}
 }