Merge
diff --git a/.hgtags b/.hgtags
index a6cb07b..1be5b58 100644
--- a/.hgtags
+++ b/.hgtags
@@ -1,3 +1,12 @@
+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,12 +409,7 @@
 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
+74116beae88a8f17a80301aa6c83865c82f10ece jdk-10+1
+4a79ad46e578112fce68f1af9dd931025cc235cb jdk-10+2
+d1cab6c7e608479be4ebfad48a25b0ed48600f62 jdk-10+3
+02253db2ace1422f576f58502fc7831ead77424b jdk-10+4
diff --git a/.hgtags-top-repo b/.hgtags-top-repo
index 2ceddcc..b667a1e 100644
--- a/.hgtags-top-repo
+++ b/.hgtags-top-repo
@@ -396,6 +396,7 @@
 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
@@ -407,3 +408,4 @@
 21b063d75b3edbffb9bebc8872d990920c4ae1e5 jdk-9+162
 c38c6b270ccc8e2b86d1631bcf42248241b54d2c jdk-9+163
 7810f75d016a52e32295c4233009de5ca90e31af jdk-9+164
+aff4f339acd40942d3dab499846b52acd87b3af1 jdk-9+165
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 20180c4..1337cde 100644
--- a/common/autoconf/basics.m4
+++ b/common/autoconf/basics.m4
@@ -1098,6 +1098,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/generated-configure.sh b/common/autoconf/generated-configure.sh
index f7ee60e..8bd0cf8 100644
--- a/common/autoconf/generated-configure.sh
+++ b/common/autoconf/generated-configure.sh
@@ -932,6 +932,7 @@
 IS_GNU_TIME
 PATCH
 DTRACE
+FLOCK
 TIME
 STAT
 HG
@@ -1293,6 +1294,7 @@
 HG
 STAT
 TIME
+FLOCK
 DTRACE
 PATCH
 DSYMUTIL
@@ -2257,6 +2259,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
@@ -5174,7 +5177,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1490856742
+DATE_WHEN_GENERATED=1490900744
 
 ###############################################################################
 #
@@ -23059,6 +23062,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.
 
diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in
index ffb3168..f59b6a5 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@
@@ -637,6 +637,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/common/conf/jib-profiles.js b/common/conf/jib-profiles.js
index 871068d..7405f41 100644
--- a/common/conf/jib-profiles.js
+++ b/common/conf/jib-profiles.js
@@ -1079,7 +1079,7 @@
         + "." + (minor != null ? minor : version_numbers.get("DEFAULT_VERSION_MINOR"))
         + "." + (security != null ? security :  version_numbers.get("DEFAULT_VERSION_SECURITY"))
         + "." + (patch != null ? patch : version_numbers.get("DEFAULT_VERSION_PATCH"));
-    while (version.match(".*\.0$")) {
+    while (version.match(".*\\.0$")) {
         version = version.substring(0, version.length - 2);
     }
     return version;
diff --git a/corba/.hgtags b/corba/.hgtags
index e7ec5da..edc9640 100644
--- a/corba/.hgtags
+++ b/corba/.hgtags
@@ -396,6 +396,7 @@
 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
@@ -406,3 +407,5 @@
 18f02bc43fe96aef36791d0df7aca748485210cc jdk-9+161
 18ffcf99a3b4a10457853d94190e825bdf07e39b jdk-9+162
 493011dee80e51c2a2b064d049183c047df36d80 jdk-9+163
+965bbae3072702f7c0d95c240523b65e6bb19261 jdk-9+164
+a510b2201154abdd12ede42788086b5283bfb9a6 jdk-9+165
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 2429aab..b139e14 100644
--- a/hotspot/.hgtags
+++ b/hotspot/.hgtags
@@ -556,6 +556,7 @@
 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
@@ -567,3 +568,4 @@
 b01c519b715ef6f785d0631adee0a6537cf6c12e jdk-9+162
 983fe207555724d98f4876991e1cbafbcf2733e8 jdk-9+163
 0af429be8bbaeaaf0cb838e9af28c953dda6a9c8 jdk-9+164
+c92c6416ca03b1464d5ed99cf6201e52b5ba0a70 jdk-9+165
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/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/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/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/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/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/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp
index f45ae42..7fc10c0 100644
--- a/hotspot/src/share/vm/runtime/arguments.cpp
+++ b/hotspot/src/share/vm/runtime/arguments.cpp
@@ -375,53 +375,17 @@
   // -------------- Deprecated Flags --------------
   // --- Non-alias flags - sorted by obsolete_in then expired_in:
   { "MaxGCMinorPauseMillis",        JDK_Version::jdk(8), 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() },
@@ -444,11 +408,6 @@
 
 static AliasedFlag const aliased_jvm_flags[] = {
   { "DefaultMaxRAMFraction",    "MaxRAMFraction"    },
-  { "CMSMarkStackSizeMax",      "MarkStackSizeMax"  },
-  { "CMSMarkStackSize",         "MarkStackSize"     },
-  { "G1MarkStackSize",          "MarkStackSize"     },
-  { "ParallelMarkingThreads",   "ConcGCThreads"     },
-  { "ParallelCMSThreads",       "ConcGCThreads"     },
   { "CreateMinidumpOnCrash",    "CreateCoredumpOnCrash" },
   { NULL, NULL}
 };
@@ -1547,7 +1506,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());
@@ -1588,7 +1546,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");
@@ -1728,16 +1685,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
@@ -1841,16 +1788,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);
   }
@@ -1859,7 +1797,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
 }
@@ -2078,7 +2015,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
 }
@@ -2433,18 +2369,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;
 }
 
@@ -3736,11 +3660,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 77acae0..13c2f24 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/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/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/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 26d248e..a73a941 100644
--- a/jaxp/.hgtags
+++ b/jaxp/.hgtags
@@ -396,6 +396,7 @@
 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
@@ -407,3 +408,4 @@
 d02b6fbcab06c59a5f5a4a6736bd4ec6d2567855 jdk-9+162
 92a38c75cd277d8b11f4382511a62087044659a1 jdk-9+163
 6dc790a4e8310c86712cfdf7561a9820818546e6 jdk-9+164
+55419603989707ec50c84bb379bbdc1adeec3ab2 jdk-9+165
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/javax/xml/jaxp/libs/jdk/testlibrary/JDKToolLauncher.java b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/JDKToolLauncher.java
index 777e8cf..a535e63 100644
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/JDKToolLauncher.java
+++ b/jaxp/test/javax/xml/jaxp/libs/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/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/ProcessTools.java b/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/ProcessTools.java
index 35cffc1..bc5cb74 100644
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/ProcessTools.java
+++ b/jaxp/test/javax/xml/jaxp/libs/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/jaxws/.hgtags b/jaxws/.hgtags
index c94b3ee..5c41c8f 100644
--- a/jaxws/.hgtags
+++ b/jaxws/.hgtags
@@ -399,6 +399,7 @@
 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
@@ -410,3 +411,4 @@
 b8aebe5292f23689f97cb8e66a9f327834dd43e6 jdk-9+162
 3890f96e8995be8c84f330d1f65269b03ac36b24 jdk-9+163
 1a52de2da827459e866fd736f9e9c62eb2ecd6bb jdk-9+164
+a987401bac0d528475e57732c9d5d93f4405804c jdk-9+165
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 a0eb89d..1991f54 100644
--- a/jdk/.hgtags
+++ b/jdk/.hgtags
@@ -396,6 +396,7 @@
 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
@@ -407,3 +408,4 @@
 f6bf027e88e9a4dd19f721001a7af00157af42c4 jdk-9+162
 50171f8c47961710cbf87aead6f03fa431d8d240 jdk-9+163
 6dea581453d7c0e767e3169cfec8b423a381e71d jdk-9+164
+a7942c3b1e59495dbf51dc7c41aab355fcd253d7 jdk-9+165
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/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/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/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 d13de5b..1105865 100644
--- a/jdk/src/java.base/share/classes/java/lang/System.java
+++ b/jdk/src/java.base/share/classes/java/lang/System.java
@@ -535,6 +535,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/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 e2ed0cf..f834d12 100644
--- a/jdk/src/java.base/share/classes/java/net/URLConnection.java
+++ b/jdk/src/java.base/share/classes/java/net/URLConnection.java
@@ -876,7 +876,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.
      *
@@ -906,7 +906,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.
      *
@@ -972,7 +972,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.
      *
@@ -993,7 +993,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)}.
      *
@@ -1252,7 +1252,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/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/util/concurrent/ConcurrentHashMap.java b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java
index 1d80077..8ebdae0 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
@@ -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;
@@ -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 2ae29aa..d34c74c 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 86be622..ccd7f64 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 330f4fb..d869797 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/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/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/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/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/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/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/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/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/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/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.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.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/test/ProblemList.txt b/jdk/test/ProblemList.txt
index 8ec40b3..377595b 100644
--- a/jdk/test/ProblemList.txt
+++ b/jdk/test/ProblemList.txt
@@ -260,6 +260,11 @@
 
 tools/jlink/multireleasejar/JLinkMultiReleaseJarTest.java       8169971 windows-x64
 
+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 1f98e2b..9095e61 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(),
@@ -109,7 +109,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/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/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/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/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/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/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/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/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 224ab0e..cc3a93f 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/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/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/langtools/.hgtags b/langtools/.hgtags
index aa208af..d86b7a0 100644
--- a/langtools/.hgtags
+++ b/langtools/.hgtags
@@ -396,6 +396,7 @@
 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
@@ -407,3 +408,4 @@
 440c45c2e8cee78f6883fa6f2505a781505f323c jdk-9+162
 24582dd2649a155876de89273975ebe1adb5f18c jdk-9+163
 c7f3df19667b093538c6eecb73dcb3fb531706b4 jdk-9+164
+98108b7d4cb6078773e2d27ad8471dc25d4d6124 jdk-9+165
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..a5cab45 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.
                  */
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 3e9e184..946a99a 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
@@ -213,20 +213,11 @@
     }
 
     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/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 07d020f..42c7933 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
@@ -90,6 +90,8 @@
             } catch (IOException | ProviderNotFoundException ex) {
             }
         }
+        // Workaround until full support for --release 9 distinct from --release 10
+        SUPPORTED_JAVA_PLATFORM_VERSIONS.add(targetNumericVersion(Target.JDK1_9));
         SUPPORTED_JAVA_PLATFORM_VERSIONS.add(targetNumericVersion(Target.DEFAULT));
     }
 
@@ -108,7 +110,9 @@
 
         @Override
         public Collection<Path> getPlatformPath() {
-            if (Target.lookup(version) == Target.DEFAULT) {
+            // Comparison should be == Target.DEFAULT once --release 9
+            // is distinct from 10
+            if (Target.lookup(version).compareTo(Target.JDK1_9)  >=  0) {
                 return null;
             }
 
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 18d8c2d..b57d2cc 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
@@ -380,6 +380,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.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/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/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/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/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/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 97368dc..a38a239 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 5ac4b86..b9419bf 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 52a00dd..bb6a17a 100644
--- a/nashorn/.hgtags
+++ b/nashorn/.hgtags
@@ -387,6 +387,7 @@
 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
@@ -398,3 +399,4 @@
 2cd29b339692524de64d049b329873facaff9727 jdk-9+162
 5e5e436543daea0c174d878d5e3ff8dd791e538a jdk-9+163
 b473fab09baab51a06ffba02eb06c7f5ee8578f7 jdk-9+164
+e36e62d3ea53c316f295b37bcc19867fbf510235 jdk-9+165
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/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/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/test/lib/jdk/test/lib/process/ProcessTools.java b/test/lib/jdk/test/lib/process/ProcessTools.java
index 3f4bbb7..f2ec073 100644
--- a/test/lib/jdk/test/lib/process/ProcessTools.java
+++ b/test/lib/jdk/test/lib/process/ProcessTools.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
@@ -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().getPid();
     }
-    /**
-     * 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.
      *