Merge jdk-10+11
authorduke
Wed, 05 Jul 2017 23:37:13 +0200
changeset 45420 036dbf8b3817
parent 45419 1e5f410302d2 (diff)
parent 45365 08280c52dc42 (current diff)
child 45421 35e89399bfc0
child 45451 2d500ccfa3b5
child 45456 d825c8ee8f46
child 45460 73ef931229ca
child 45478 e6f558fe9ec4
child 45482 78b5361fba3d
child 45487 18a5c4c0b6d7
child 45492 671e407264a3
child 45496 b41095adfdfd
child 46227 0444b69aad04
child 46530 7b915076588f
Merge
.hgtags
jdk/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java
jdk/test/java/util/stream/bootlib/java.base/java/util/SpliteratorTestHelper.java
jdk/test/lib/testlibrary/bootlib/java.base/java/util/SpliteratorOfIntDataBuilder.java
jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/DoubleStreamTestScenario.java
jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/IntStreamTestScenario.java
jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LongStreamTestScenario.java
jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StreamTestScenario.java
jdk/test/lib/testlibrary/jdk/testlibrary/NetworkConfiguration.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java
langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java
--- a/.hgtags	Wed Jul 05 23:35:20 2017 +0200
+++ b/.hgtags	Wed Jul 05 23:37:13 2017 +0200
@@ -1,3 +1,19 @@
+dad6746278facbbea57dd462cb56fb743dc0a5f0 jdk-9+172
+643b5f18c2656fe91b69fea85b07b98d5fad394d jdk-9+171
+898cbe31fbdae2d25d141384fac746cc244a730c jdk-9+170
+c7efde2b60fc1ec04630be769d9ad60efb39c39c jdk-9+169
+8fd0a4569191f33c98ee90c2709174a342fefb0d jdk-9+167
+fcabc74bd44e56c7419d111d59b95669ecb33c55 jdk-9+168
+d3e973f1809606c67412361041ad197e50fe8cec jdk-9+166
+3965b747cfe1e6cbd66b8739da5a1ea6ec6985e9 jdk-9+165
+d16aebbb56d37f12e0c0b0a4fb427db65e1fb1a8 jdk-9+162
+18c41483a082e097ac2f5f983c1226ed94aa4215 jdk-9+163
+32db52c675e7d5bc413605d2e89b68b608b19be0 jdk-9+164
+fd1497902bbe3aa24b21f270ecdcb8de5f7aa9ac jdk-9+159
+6aa8be0c4e054fe8b3ab016ae00d16d680f92145 jdk-9+160
+f6883b1a5a6478437cd4181c4bd45328ab24feaf jdk-9+161
+fa3e76b477829afc4476f0b725cfaa440a6fd917 jdk-9+157
+b5015f742ba648184bb7fc547197bd33ebfde30d jdk-9+158
 1cc8dd79fd1cd13d36b385196271a29632c67c3b jdk7-b24
 bf2517e15f0c0f950e5b3143c4ca11e2df73dcc1 jdk7-b25
 5ae7db536e3fcf6be78e45b240a9058095e0ed38 jdk7-b26
@@ -400,19 +416,13 @@
 45b751afd11e6c05991cf4913c5a0ac3304fcc4e jdk-9+154
 f4aff695ffe05cfdb69d8af25a4ddc6a029754ea jdk-9+155
 06bce0388880b5ff8e040e4a9d72a3ea11dac321 jdk-9+156
-fa3e76b477829afc4476f0b725cfaa440a6fd917 jdk-9+157
-b5015f742ba648184bb7fc547197bd33ebfde30d jdk-9+158
-fd1497902bbe3aa24b21f270ecdcb8de5f7aa9ac jdk-9+159
-6aa8be0c4e054fe8b3ab016ae00d16d680f92145 jdk-9+160
-f6883b1a5a6478437cd4181c4bd45328ab24feaf jdk-9+161
-d16aebbb56d37f12e0c0b0a4fb427db65e1fb1a8 jdk-9+162
-18c41483a082e097ac2f5f983c1226ed94aa4215 jdk-9+163
-32db52c675e7d5bc413605d2e89b68b608b19be0 jdk-9+164
-3965b747cfe1e6cbd66b8739da5a1ea6ec6985e9 jdk-9+165
-d3e973f1809606c67412361041ad197e50fe8cec jdk-9+166
-8fd0a4569191f33c98ee90c2709174a342fefb0d jdk-9+167
-fcabc74bd44e56c7419d111d59b95669ecb33c55 jdk-9+168
-c7efde2b60fc1ec04630be769d9ad60efb39c39c jdk-9+169
-898cbe31fbdae2d25d141384fac746cc244a730c jdk-9+170
-643b5f18c2656fe91b69fea85b07b98d5fad394d jdk-9+171
-dad6746278facbbea57dd462cb56fb743dc0a5f0 jdk-9+172
+74116beae88a8f17a80301aa6c83865c82f10ece jdk-10+1
+4a79ad46e578112fce68f1af9dd931025cc235cb jdk-10+2
+d1cab6c7e608479be4ebfad48a25b0ed48600f62 jdk-10+3
+02253db2ace1422f576f58502fc7831ead77424b jdk-10+4
+f113ce12fe24fbd24acf02711372d9f1e1c12426 jdk-10+5
+1407b19a2ddf6baae162f5a1a5b96af473f4d7d1 jdk-10+6
+30e75693ae99fd8e47fd2f5116527aff1b59aff9 jdk-10+7
+c42dc7b58b4d4301ea676a76326fd9bbd403d595 jdk-10+8
+aa5b01f5e5620438fd39efdb2e2f6365a2c7d898 jdk-10+9
+b0f2b8ff25a2209b2c807785d75f20e5086bbfc2 jdk-10+10
--- a/.hgtags-top-repo	Wed Jul 05 23:35:20 2017 +0200
+++ b/.hgtags-top-repo	Wed Jul 05 23:37:13 2017 +0200
@@ -396,9 +396,11 @@
 71a766d4c18041a7f833ee22823125b02e1a7f1e jdk-9+151
 ef056360ddf3977d7d2ddbeb456a4d612d19ea05 jdk-9+152
 816a6d03a7c44edfbd8780110529f1bdc3964fb9 jdk-9+153
+8d22611ffb6540bc1ace64a00c048c8b82d8c69a jdk-10+0
 8d26916eaa21b689835ffc1c0dbf12470aa9be61 jdk-9+154
 688a3863c00ebc089ab17ee1fc46272cbbd96815 jdk-9+155
 783ec7542cf7154e5d2b87f55bb97d28f81e9ada jdk-9+156
+4df5f619c9ead4604d2f97ed231b3a35ec688c41 jdk-10+1
 4eb77fb98952dc477a4229575c81d2263a9ce711 jdk-9+157
 a4087bc10a88a43ea3ad0919b5b4af1c86977221 jdk-9+158
 fe8466adaef8178dba94be53c789a0aaa87d13bb jdk-9+159
@@ -411,6 +413,16 @@
 ba5b16c9c6d80632b61959a33d424b1c3398ce62 jdk-9+166
 35017c286513ddcbcc6b63b99679c604993fc639 jdk-9+167
 143d4c87bc1ef1ed6dadd613cd9dd4488fdefc29 jdk-9+168
+9c7248b787c39b034d4f48d4aa48df903836cca7 jdk-10+2
+06373236a30801f72e2a31ee5c691c2a1e500f57 jdk-10+3
+8ec175c61fc3f58328a3324f07d7ded00e060be3 jdk-10+4
+111e2e7d00f45c983cdbc9c59ae40552152fcc23 jdk-10+5
+03fe61bb7670644cf6e46b5cfafb6b27c0e0157e jdk-10+6
 b25838a28195f4b6dab34668411eedd2d366a16c jdk-9+169
 4d163ec59d989a9261ed7f848bc6303f90869af5 jdk-9+170
+aa3c97810d7c484c93a2fd75d3c76ff574deb6d8 jdk-10+7
+df33ef1dc163f994177fd97d4d0e73a1e3cb5d85 jdk-10+8
+b94be69cbb1d2943b886bf2d458745756df146e4 jdk-10+9
 4c12464a907db4656c1033f56fa49cba643ac629 jdk-9+171
+6558c37afe832582238d338578d598f30c6fdd75 jdk-10+10
+2c25fc24103251f9711a1c280c31e1e41016d90f jdk-9+172
--- a/.jcheck/conf	Wed Jul 05 23:35:20 2017 +0200
+++ b/.jcheck/conf	Wed Jul 05 23:37:13 2017 +0200
@@ -1,1 +1,1 @@
-project=jdk9
+project=jdk10
--- a/common/autoconf/basics.m4	Wed Jul 05 23:35:20 2017 +0200
+++ b/common/autoconf/basics.m4	Wed Jul 05 23:37:13 2017 +0200
@@ -1099,6 +1099,7 @@
   BASIC_PATH_PROGS(HG, hg)
   BASIC_PATH_PROGS(STAT, stat)
   BASIC_PATH_PROGS(TIME, time)
+  BASIC_PATH_PROGS(FLOCK, flock)
   # Dtrace is usually found in /usr/sbin on Solaris, but that directory may not
   # be in the user path.
   BASIC_PATH_PROGS(DTRACE, dtrace, $PATH:/usr/sbin)
--- a/common/autoconf/boot-jdk.m4	Wed Jul 05 23:35:20 2017 +0200
+++ b/common/autoconf/boot-jdk.m4	Wed Jul 05 23:37:13 2017 +0200
@@ -318,7 +318,7 @@
   AC_SUBST(JAVAC_FLAGS)
 
   # Check if the boot jdk is 32 or 64 bit
-  if "$JAVA" -d64 -version > /dev/null 2>&1; then
+  if "$JAVA" -version 2>&1 | $GREP -q "64-Bit"; then
     BOOT_JDK_BITS="64"
   else
     BOOT_JDK_BITS="32"
--- a/common/autoconf/build-performance.m4	Wed Jul 05 23:35:20 2017 +0200
+++ b/common/autoconf/build-performance.m4	Wed Jul 05 23:37:13 2017 +0200
@@ -417,10 +417,8 @@
   AC_SUBST(SJAVAC_SERVER_JAVA)
 
   if test "$MEMORY_SIZE" -gt "3000"; then
-    ADD_JVM_ARG_IF_OK([-d64],SJAVAC_SERVER_JAVA_FLAGS,[$SJAVAC_SERVER_JAVA])
-    if test "$JVM_ARG_OK" = true; then
+    if "$JAVA" -version 2>&1 | $GREP -q "64-Bit"; then
       JVM_64BIT=true
-      JVM_ARG_OK=false
     fi
   fi
 
--- a/common/autoconf/generated-configure.sh	Wed Jul 05 23:35:20 2017 +0200
+++ b/common/autoconf/generated-configure.sh	Wed Jul 05 23:37:13 2017 +0200
@@ -933,6 +933,7 @@
 IS_GNU_TIME
 PATCH
 DTRACE
+FLOCK
 TIME
 STAT
 HG
@@ -1297,6 +1298,7 @@
 HG
 STAT
 TIME
+FLOCK
 DTRACE
 PATCH
 DSYMUTIL
@@ -2264,6 +2266,7 @@
   HG          Override default value for HG
   STAT        Override default value for STAT
   TIME        Override default value for TIME
+  FLOCK       Override default value for FLOCK
   DTRACE      Override default value for DTRACE
   PATCH       Override default value for PATCH
   DSYMUTIL    Override default value for DSYMUTIL
@@ -23271,6 +23274,203 @@
   fi
 
 
+
+
+  # Publish this variable in the help.
+
+
+  if [ -z "${FLOCK+x}" ]; then
+    # The variable is not set by user, try to locate tool using the code snippet
+    for ac_prog in flock
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_FLOCK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $FLOCK in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FLOCK="$FLOCK" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_FLOCK="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+FLOCK=$ac_cv_path_FLOCK
+if test -n "$FLOCK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLOCK" >&5
+$as_echo "$FLOCK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$FLOCK" && break
+done
+
+  else
+    # The variable is set, but is it from the command line or the environment?
+
+    # Try to remove the string !FLOCK! from our list.
+    try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!FLOCK!/}
+    if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
+      # If it failed, the variable was not from the command line. Ignore it,
+      # but warn the user (except for BASH, which is always set by the calling BASH).
+      if test "xFLOCK" != xBASH; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of FLOCK from the environment. Use command line variables instead." >&5
+$as_echo "$as_me: WARNING: Ignoring value of FLOCK from the environment. Use command line variables instead." >&2;}
+      fi
+      # Try to locate tool using the code snippet
+      for ac_prog in flock
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_FLOCK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $FLOCK in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FLOCK="$FLOCK" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_FLOCK="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+FLOCK=$ac_cv_path_FLOCK
+if test -n "$FLOCK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLOCK" >&5
+$as_echo "$FLOCK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$FLOCK" && break
+done
+
+    else
+      # If it succeeded, then it was overridden by the user. We will use it
+      # for the tool.
+
+      # First remove it from the list of overridden variables, so we can test
+      # for unknown variables in the end.
+      CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
+
+      # Check if we try to supply an empty value
+      if test "x$FLOCK" = x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool FLOCK= (no value)" >&5
+$as_echo "$as_me: Setting user supplied tool FLOCK= (no value)" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FLOCK" >&5
+$as_echo_n "checking for FLOCK... " >&6; }
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
+$as_echo "disabled" >&6; }
+      else
+        # Check if the provided tool contains a complete path.
+        tool_specified="$FLOCK"
+        tool_basename="${tool_specified##*/}"
+        if test "x$tool_basename" = "x$tool_specified"; then
+          # A command without a complete path is provided, search $PATH.
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool FLOCK=$tool_basename" >&5
+$as_echo "$as_me: Will search for user supplied tool FLOCK=$tool_basename" >&6;}
+          # Extract the first word of "$tool_basename", so it can be a program name with args.
+set dummy $tool_basename; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_FLOCK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $FLOCK in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_FLOCK="$FLOCK" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_FLOCK="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+FLOCK=$ac_cv_path_FLOCK
+if test -n "$FLOCK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FLOCK" >&5
+$as_echo "$FLOCK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+          if test "x$FLOCK" = x; then
+            as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5
+          fi
+        else
+          # Otherwise we believe it is a complete path. Use it as it is.
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool FLOCK=$tool_specified" >&5
+$as_echo "$as_me: Will use user supplied tool FLOCK=$tool_specified" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FLOCK" >&5
+$as_echo_n "checking for FLOCK... " >&6; }
+          if test ! -x "$tool_specified"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+            as_fn_error $? "User supplied tool FLOCK=$tool_specified does not exist or is not executable" "$LINENO" 5
+          fi
+          { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5
+$as_echo "$tool_specified" >&6; }
+        fi
+      fi
+    fi
+
+  fi
+
+
   # Dtrace is usually found in /usr/sbin on Solaris, but that directory may not
   # be in the user path.
 
@@ -31216,7 +31416,7 @@
 
 
   # Check if the boot jdk is 32 or 64 bit
-  if "$JAVA" -d64 -version > /dev/null 2>&1; then
+  if "$JAVA" -version 2>&1 | $GREP -q "64-Bit"; then
     BOOT_JDK_BITS="64"
   else
     BOOT_JDK_BITS="32"
@@ -66062,24 +66262,8 @@
 
 
   if test "$MEMORY_SIZE" -gt "3000"; then
-
-  $ECHO "Check if jvm arg is ok: -d64" >&5
-  $ECHO "Command: $SJAVAC_SERVER_JAVA -d64 -version" >&5
-  OUTPUT=`$SJAVAC_SERVER_JAVA -d64 -version 2>&1`
-  FOUND_WARN=`$ECHO "$OUTPUT" | $GREP -i warn`
-  FOUND_VERSION=`$ECHO $OUTPUT | $GREP " version \""`
-  if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-    SJAVAC_SERVER_JAVA_FLAGS="$SJAVAC_SERVER_JAVA_FLAGS -d64"
-    JVM_ARG_OK=true
-  else
-    $ECHO "Arg failed:" >&5
-    $ECHO "$OUTPUT" >&5
-    JVM_ARG_OK=false
-  fi
-
-    if test "$JVM_ARG_OK" = true; then
+    if "$JAVA" -version 2>&1 | $GREP -q "64-Bit"; then
       JVM_64BIT=true
-      JVM_ARG_OK=false
     fi
   fi
 
--- a/common/autoconf/spec.gmk.in	Wed Jul 05 23:35:20 2017 +0200
+++ b/common/autoconf/spec.gmk.in	Wed Jul 05 23:37:13 2017 +0200
@@ -48,7 +48,7 @@
 
 # The default make arguments
 MAKE_ARGS = $(MAKE_LOG_FLAGS) -r -R -I $(TOPDIR)/make/common SPEC=$(SPEC) \
-    MAKE_LOG_FLAGS="$(MAKE_LOG_FLAGS)" LOG_LEVEL=$(LOG_LEVEL)
+    MAKE_LOG_FLAGS="$(MAKE_LOG_FLAGS)" $(MAKE_LOG_VARS)
 
 OUTPUT_SYNC_SUPPORTED:=@OUTPUT_SYNC_SUPPORTED@
 OUTPUT_SYNC:=@OUTPUT_SYNC@
@@ -638,6 +638,7 @@
 DSYMUTIL:=@DSYMUTIL@
 FIND:=@FIND@
 FIND_DELETE:=@FIND_DELETE@
+FLOCK:=@FLOCK@
 ECHO:=@ECHO@
 EGREP:=@EGREP@
 FGREP:=@FGREP@
--- a/common/autoconf/version-numbers	Wed Jul 05 23:35:20 2017 +0200
+++ b/common/autoconf/version-numbers	Wed Jul 05 23:37:13 2017 +0200
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/bin/shell-profiler.sh	Wed Jul 05 23:37:13 2017 +0200
@@ -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
--- a/common/bin/shell-tracer.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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
--- a/common/doc/testing.html	Wed Jul 05 23:35:20 2017 +0200
+++ b/common/doc/testing.html	Wed Jul 05 23:37:13 2017 +0200
@@ -32,13 +32,15 @@
 </nav>
 <h2 id="using-the-run-test-framework">Using the run-test framework</h2>
 <p>This new way of running tests is developer-centric. It assumes that you have built a jdk locally and want to test it. Running common test targets is simple, and more complex ad-hoc combination of tests is possible. The user interface is forgiving, and clearly report errors it cannot resolve.</p>
+<p>The main target &quot;run-test&quot; uses the jdk-image as the tested product. There is also an alternate target &quot;exploded-run-test&quot; that uses the exploded image instead. Not all tests will run successfully on the exploded image, but using this target can greatly improve rebuild times for certain workflows.</p>
 <p>Some example command-lines:</p>
 <pre><code>$ make run-test-tier1
 $ make run-test-jdk_lang JTREG=&quot;JOBS=8&quot;
 $ make run-test TEST=jdk_lang
 $ make run-test-only TEST=&quot;gtest:LogTagSet gtest:LogTagSetDescriptions&quot; GTEST=&quot;REPEAT=-1&quot;
 $ make run-test TEST=&quot;hotspot/test:hotspot_gc&quot; JTREG=&quot;JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug&quot;
-$ make run-test TEST=&quot;jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java&quot;</code></pre>
+$ make run-test TEST=&quot;jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java&quot;
+$ make exploded-run-test TEST=hotspot_tier1</code></pre>
 <h2 id="test-selection">Test selection</h2>
 <p>All functionality is available using the run-test make target. In this use case, the test or tests to be executed is controlled using the <code>TEST</code> variable. To speed up subsequent test runs with no source code changes, run-test-only can be used instead, which do not depend on the source and test image build.</p>
 <p>For some common top-level tests, direct make targets have been generated. This includes all JTreg test groups, the hotspot gtest, and custom tests (if present). This means that <code>make run-test-tier1</code> is equivalent to <code>make run-test TEST=&quot;tier1&quot;</code>, but the latter is more tab-completion friendly. For more complex test runs, the <code>run-test TEST=&quot;x&quot;</code> solution needs to be used.</p>
--- a/common/doc/testing.md	Wed Jul 05 23:35:20 2017 +0200
+++ b/common/doc/testing.md	Wed Jul 05 23:37:13 2017 +0200
@@ -7,6 +7,11 @@
 and more complex ad-hoc combination of tests is possible. The user interface is
 forgiving, and clearly report errors it cannot resolve.
 
+The main target "run-test" uses the jdk-image as the tested product. There is
+also an alternate target "exploded-run-test" that uses the exploded image
+instead. Not all tests will run successfully on the exploded image, but using
+this target can greatly improve rebuild times for certain workflows.
+
 Some example command-lines:
 
     $ make run-test-tier1
@@ -15,6 +20,7 @@
     $ make run-test-only TEST="gtest:LogTagSet gtest:LogTagSetDescriptions" GTEST="REPEAT=-1"
     $ make run-test TEST="hotspot/test:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"
     $ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
+    $ make exploded-run-test TEST=hotspot_tier1
 
 ## Test selection
 
--- a/corba/.hgtags	Wed Jul 05 23:35:20 2017 +0200
+++ b/corba/.hgtags	Wed Jul 05 23:37:13 2017 +0200
@@ -396,9 +396,11 @@
 77f827f5bbad3ef795664bc675f72d98d156b9f8 jdk-9+151
 ff8cb43c07c069b1debdee44cb88ca22db1ec757 jdk-9+152
 68a8e8658511093b322a46ed04b2a321e1da2a43 jdk-9+153
+d66f97a610a6beac987740edc2bf6a70f46ba574 jdk-10+0
 078ebe23b584466dc8346e620d7821d91751e5a9 jdk-9+154
 a545f54babfa31aa7eb611f36031609acd617cbc jdk-9+155
 907c26240cd481579e919bfd23740797ff8ce1c8 jdk-9+156
+37c9962586a4d3498fa673d93eab1a336acd7652 jdk-10+1
 9383da04b385cca46b7ca67f3a39ac1b673e09fe jdk-9+157
 de6bdf38935fa753183ca288bed5c06a23c0bb12 jdk-9+158
 6feea77d2083c99e44aa3e272d07b7fb3b801683 jdk-9+159
@@ -409,6 +411,18 @@
 965bbae3072702f7c0d95c240523b65e6bb19261 jdk-9+164
 a510b2201154abdd12ede42788086b5283bfb9a6 jdk-9+165
 934c18145915b06d3fcc0de1a30f91f5aab8a192 jdk-9+166
+56a8bf5322684e9a31cda64c336c32bcdb592211 jdk-10+2
+3813c94c8585dd7507887916c6943f45051f1b55 jdk-10+3
+5d6d891bb36dbeeacaffa06b5a3e3b4e44b35fbd jdk-10+4
+7c5328012799923d45d1cf87e8725e725b3d298b jdk-10+5
+c7358d703e1282af3dcd8af6c037dc4342de9054 jdk-10+6
 43de67f51801b9e16507865fcb7e8344f4ca4aa9 jdk-9+167
 03a2cc9c8a1e8f87924c9863e917bc8b91770d5f jdk-9+168
 b2218d41edef02ee8f94bb438f885b2ba79bfa08 jdk-9+169
+8a4ab3b0ab9a86df73d9a1e337134f2dbe006725 jdk-9+170
+aed5a4edc8275c1c50195503756ff92bfe0197f5 jdk-10+7
+648b0a00824eb29e71936bc3258d309a25e3b8c0 jdk-10+8
+54c6621f7b34cc6ce6c0882d047f61fe0962c257 jdk-10+9
+c62e5964cfcf144d8f72e9ba69757897785349a9 jdk-9+171
+080c37fd77e2c4629b91059298e37758afbdbc46 jdk-10+10
+95ed14547ca9246baed34f90ef3ca13217538a8c jdk-9+172
--- a/corba/.jcheck/conf	Wed Jul 05 23:35:20 2017 +0200
+++ b/corba/.jcheck/conf	Wed Jul 05 23:37:13 2017 +0200
@@ -1,1 +1,1 @@
-project=jdk9
+project=jdk10
--- a/hotspot/.hgtags	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/.hgtags	Wed Jul 05 23:37:13 2017 +0200
@@ -556,9 +556,11 @@
 2a2ac7d9f52c8cb2b80077e515b5840b947e640c jdk-9+151
 31f1d26c60df7b2e516a4f84160d76ba017d4e09 jdk-9+152
 217ba81b9a4ce8698200370175aa2db86a39f66c jdk-9+153
+fc7e94cb748507366b839e859f865f724467446a jdk-10+0
 a9fdfd55835ef9dccb7f317b07249bd66653b874 jdk-9+154
 f3b3d77a1751897413aae43ac340a130b6fa2ae1 jdk-9+155
 43139c588ea48b6504e52b6c3dec530b17b1fdb4 jdk-9+156
+1ea217626ba0995dd03127f8322ba3687926a085 jdk-10+1
 b2d0a906afd73dcf27f572217eb1be0f196ec16c jdk-9+157
 4e78f30935229f13ce7c43089621cf7169f5abac jdk-9+158
 9211c2e89c1cd11ec2d5752b0f97131a7d7525c7 jdk-9+159
@@ -569,8 +571,18 @@
 0af429be8bbaeaaf0cb838e9af28c953dda6a9c8 jdk-9+164
 c92c6416ca03b1464d5ed99cf6201e52b5ba0a70 jdk-9+165
 560d7aa083a24b6a56443feb8de0f40435d33aa9 jdk-9+166
+48809c513ed5ebb4d4dbf2f454afcce2780db6db jdk-10+2
+6c3b6b3438c4a63e619f00bd5732d1260ffd5600 jdk-10+3
+8295ca08f5cb09c090eb048bbdd338d7e270c8bf jdk-10+4
+7b5ca2ff1f78873ca3ee99b6589d3cb4dde2e454 jdk-10+5
+762465099d938fd96cd1efda193bc1fa23d070d3 jdk-10+6
 1ca7ed1b17b5776930d641d1379834f3140a74e4 jdk-9+167
 fbb9c802649585d19f6d7e81b4a519d44806225a jdk-9+168
 16d692be099c5c38eb48cc9aca78b0c900910d5b jdk-9+169
 38a240fd58a287acb1963920b92ed4d9c2fd39e3 jdk-9+170
+9d4746eca95aec3e5a344bf2520745dcc1d17eed jdk-10+7
+f5ded0cf954c770deeecb80f2ba1ba6a05cd979b jdk-10+8
+233647e3d3800e76d7612014b745b37a88098f63 jdk-10+9
 d53171650a2cc6c6f699c966c533b914ca9c0602 jdk-9+171
+c6cd3ec8d46b034e57c86399380ffcf7f25706e4 jdk-10+10
+1ae9e84f68b359420d2d153ecfe5ee2903e33a2e jdk-9+172
--- a/hotspot/.jcheck/conf	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/.jcheck/conf	Wed Jul 05 23:37:13 2017 +0200
@@ -1,1 +1,1 @@
-project=jdk9
+project=jdk10
--- a/hotspot/src/cpu/aarch64/vm/aarch64.ad	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad	Wed Jul 05 23:37:13 2017 +0200
@@ -577,7 +577,7 @@
     R26
  /* R27, */                     // heapbase
  /* R28, */                     // thread
- /* R29, */                     // fp
+    R29,                        // fp
  /* R30, */                     // lr
  /* R31 */                      // sp
 );
@@ -646,7 +646,7 @@
     R26, R26_H,
  /* R27, R27_H, */              // heapbase
  /* R28, R28_H, */              // thread
- /* R29, R29_H, */              // fp
+    R29, R29_H,                 // fp
  /* R30, R30_H, */              // lr
  /* R31, R31_H */               // sp
 );
@@ -14021,10 +14021,12 @@
   ins_pipe(pipe_class_memory);
 %}
 
-instruct clearArray_imm_reg(immL cnt, iRegP_R10 base, iRegL_R11 tmp, Universe dummy, rFlagsReg cr)
-%{
+instruct clearArray_imm_reg(immL cnt, iRegP_R10 base, Universe dummy, rFlagsReg cr)
+%{
+  predicate((u_int64_t)n->in(2)->get_long()
+            < (u_int64_t)(BlockZeroingLowLimit >> LogBytesPerWord));
   match(Set dummy (ClearArray cnt base));
-  effect(USE_KILL base, TEMP tmp);
+  effect(USE_KILL base);
 
   ins_cost(4 * INSN_COST);
   format %{ "ClearArray $cnt, $base" %}
--- a/hotspot/src/cpu/aarch64/vm/c1_globals_aarch64.hpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/cpu/aarch64/vm/c1_globals_aarch64.hpp	Wed Jul 05 23:37:13 2017 +0200
@@ -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
--- a/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * 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);
--- a/hotspot/src/cpu/aarch64/vm/globalDefinitions_aarch64.hpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/cpu/aarch64/vm/globalDefinitions_aarch64.hpp	Wed Jul 05 23:37:13 2017 +0200
@@ -34,10 +34,6 @@
 
 #define SUPPORTS_NATIVE_CX8
 
-// The maximum B/BL offset range on AArch64 is 128MB.
-#undef CODE_CACHE_DEFAULT_LIMIT
-#define CODE_CACHE_DEFAULT_LIMIT (128*M)
-
 // According to the ARMv8 ARM, "Concurrent modification and execution
 // of instructions can lead to the resulting instruction performing
 // any behavior that can be achieved by executing any sequence of
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -698,6 +698,7 @@
 // trampolines won't be emitted.
 
 address MacroAssembler::trampoline_call(Address entry, CodeBuffer *cbuf) {
+  assert(JavaThread::current()->is_Compiler_thread(), "just checking");
   assert(entry.rspec().type() == relocInfo::runtime_call_type
          || entry.rspec().type() == relocInfo::opt_virtual_call_type
          || entry.rspec().type() == relocInfo::static_call_type
@@ -4944,34 +4945,67 @@
 }
 
 
-// base:     Address of a buffer to be zeroed, 8 bytes aligned.
-// cnt:      Count in HeapWords.
-// is_large: True when 'cnt' is known to be >= BlockZeroingLowLimit.
-void MacroAssembler::zero_words(Register base, Register cnt)
+// The size of the blocks erased by the zero_blocks stub.  We must
+// handle anything smaller than this ourselves in zero_words().
+const int MacroAssembler::zero_words_block_size = 8;
+
+// zero_words() is used by C2 ClearArray patterns.  It is as small as
+// possible, handling small word counts locally and delegating
+// anything larger to the zero_blocks stub.  It is expanded many times
+// in compiled code, so it is important to keep it short.
+
+// ptr:   Address of a buffer to be zeroed.
+// cnt:   Count in HeapWords.
+//
+// ptr, cnt, rscratch1, and rscratch2 are clobbered.
+void MacroAssembler::zero_words(Register ptr, Register cnt)
 {
-  if (UseBlockZeroing) {
-    block_zero(base, cnt);
-  } else {
-    fill_words(base, cnt, zr);
+  assert(is_power_of_2(zero_words_block_size), "adjust this");
+  assert(ptr == r10 && cnt == r11, "mismatch in register usage");
+
+  BLOCK_COMMENT("zero_words {");
+  cmp(cnt, zero_words_block_size);
+  Label around, done, done16;
+  br(LO, around);
+  {
+    RuntimeAddress zero_blocks =  RuntimeAddress(StubRoutines::aarch64::zero_blocks());
+    assert(zero_blocks.target() != NULL, "zero_blocks stub has not been generated");
+    if (StubRoutines::aarch64::complete()) {
+      trampoline_call(zero_blocks);
+    } else {
+      bl(zero_blocks);
+    }
   }
+  bind(around);
+  for (int i = zero_words_block_size >> 1; i > 1; i >>= 1) {
+    Label l;
+    tbz(cnt, exact_log2(i), l);
+    for (int j = 0; j < i; j += 2) {
+      stp(zr, zr, post(ptr, 16));
+    }
+    bind(l);
+  }
+  {
+    Label l;
+    tbz(cnt, 0, l);
+    str(zr, Address(ptr));
+    bind(l);
+  }
+  BLOCK_COMMENT("} zero_words");
 }
 
-// r10 = base:   Address of a buffer to be zeroed, 8 bytes aligned.
+// base:         Address of a buffer to be zeroed, 8 bytes aligned.
 // cnt:          Immediate count in HeapWords.
-// r11 = tmp:    For use as cnt if we need to call out
-#define ShortArraySize (18 * BytesPerLong)
+#define SmallArraySize (18 * BytesPerLong)
 void MacroAssembler::zero_words(Register base, u_int64_t cnt)
 {
-  Register tmp = r11;
+  BLOCK_COMMENT("zero_words {");
   int i = cnt & 1;  // store any odd word to start
   if (i) str(zr, Address(base));
 
-  if (cnt <= ShortArraySize / BytesPerLong) {
+  if (cnt <= SmallArraySize / BytesPerLong) {
     for (; i < (int)cnt; i += 2)
       stp(zr, zr, Address(base, i * wordSize));
-  } else if (UseBlockZeroing && cnt >= (u_int64_t)(BlockZeroingLowLimit >> LogBytesPerWord)) {
-    mov(tmp, cnt);
-    block_zero(base, tmp, true);
   } else {
     const int unroll = 4; // Number of stp(zr, zr) instructions we'll unroll
     int remainder = cnt % (2 * unroll);
@@ -4992,6 +5026,51 @@
     stp(zr, zr, Address(pre(loop_base, 2 * unroll * wordSize)));
     cbnz(cnt_reg, loop);
   }
+  BLOCK_COMMENT("} zero_words");
+}
+
+// Zero blocks of memory by using DC ZVA.
+//
+// Aligns the base address first sufficently for DC ZVA, then uses
+// DC ZVA repeatedly for every full block.  cnt is the size to be
+// zeroed in HeapWords.  Returns the count of words left to be zeroed
+// in cnt.
+//
+// NOTE: This is intended to be used in the zero_blocks() stub.  If
+// you want to use it elsewhere, note that cnt must be >= 2*zva_length.
+void MacroAssembler::zero_dcache_blocks(Register base, Register cnt) {
+  Register tmp = rscratch1;
+  Register tmp2 = rscratch2;
+  int zva_length = VM_Version::zva_length();
+  Label initial_table_end, loop_zva;
+  Label fini;
+
+  // Base must be 16 byte aligned. If not just return and let caller handle it
+  tst(base, 0x0f);
+  br(Assembler::NE, fini);
+  // Align base with ZVA length.
+  neg(tmp, base);
+  andr(tmp, tmp, zva_length - 1);
+
+  // tmp: the number of bytes to be filled to align the base with ZVA length.
+  add(base, base, tmp);
+  sub(cnt, cnt, tmp, Assembler::ASR, 3);
+  adr(tmp2, initial_table_end);
+  sub(tmp2, tmp2, tmp, Assembler::LSR, 2);
+  br(tmp2);
+
+  for (int i = -zva_length + 16; i < 0; i += 16)
+    stp(zr, zr, Address(base, i));
+  bind(initial_table_end);
+
+  sub(cnt, cnt, zva_length >> 3);
+  bind(loop_zva);
+  dc(Assembler::ZVA, base);
+  subs(cnt, cnt, zva_length >> 3);
+  add(base, base, zva_length);
+  br(Assembler::GE, loop_zva);
+  add(cnt, cnt, zva_length >> 3); // count not zeroed by DC ZVA
+  bind(fini);
 }
 
 // base:   Address of a buffer to be filled, 8 bytes aligned.
@@ -5052,69 +5131,6 @@
   bind(fini);
 }
 
-// Use DC ZVA to do fast zeroing.
-// base:   Address of a buffer to be zeroed, 8 bytes aligned.
-// cnt:    Count in HeapWords.
-// is_large: True when 'cnt' is known to be >= BlockZeroingLowLimit.
-void MacroAssembler::block_zero(Register base, Register cnt, bool is_large)
-{
-  Label small;
-  Label store_pair, loop_store_pair, done;
-  Label base_aligned;
-
-  assert_different_registers(base, cnt, rscratch1);
-  guarantee(base == r10 && cnt == r11, "fix register usage");
-
-  Register tmp = rscratch1;
-  Register tmp2 = rscratch2;
-  int zva_length = VM_Version::zva_length();
-
-  // Ensure ZVA length can be divided by 16. This is required by
-  // the subsequent operations.
-  assert (zva_length % 16 == 0, "Unexpected ZVA Length");
-
-  if (!is_large) cbz(cnt, done);
-  tbz(base, 3, base_aligned);
-  str(zr, Address(post(base, 8)));
-  sub(cnt, cnt, 1);
-  bind(base_aligned);
-
-  // Ensure count >= zva_length * 2 so that it still deserves a zva after
-  // alignment.
-  if (!is_large || !(BlockZeroingLowLimit >= zva_length * 2)) {
-    int low_limit = MAX2(zva_length * 2, (int)BlockZeroingLowLimit);
-    subs(tmp, cnt, low_limit >> 3);
-    br(Assembler::LT, small);
-  }
-
-  far_call(StubRoutines::aarch64::get_zero_longs());
-
-  bind(small);
-
-  const int unroll = 8; // Number of stp instructions we'll unroll
-  Label small_loop, small_table_end;
-
-  andr(tmp, cnt, (unroll-1) * 2);
-  sub(cnt, cnt, tmp);
-  add(base, base, tmp, Assembler::LSL, 3);
-  adr(tmp2, small_table_end);
-  sub(tmp2, tmp2, tmp, Assembler::LSL, 1);
-  br(tmp2);
-
-  bind(small_loop);
-  add(base, base, unroll * 16);
-  for (int i = -unroll; i < 0; i++)
-    stp(zr, zr, Address(base, i * 16));
-  bind(small_table_end);
-  subs(cnt, cnt, unroll * 2);
-  br(Assembler::GE, small_loop);
-
-  tbz(cnt, 0, done);
-  str(zr, Address(post(base, 8)));
-
-  bind(done);
-}
-
 // Intrinsic for sun/nio/cs/ISO_8859_1$Encoder.implEncodeISOArray and
 // java/lang/StringUTF16.compress.
 void MacroAssembler::encode_iso_array(Register src, Register dst,
--- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1213,8 +1213,10 @@
 
   void fill_words(Register base, Register cnt, Register value);
   void zero_words(Register base, u_int64_t cnt);
-  void zero_words(Register base, Register cnt);
-  void block_zero(Register base, Register cnt, bool is_large = false);
+  void zero_words(Register ptr, Register cnt);
+  void zero_dcache_blocks(Register base, Register cnt);
+
+  static const int zero_words_block_size;
 
   void byte_array_inflate(Register src, Register dst, Register len,
                           FloatRegister vtmp1, FloatRegister vtmp2,
--- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -719,48 +719,74 @@
     }
   }
 
-  address generate_zero_longs(Register base, Register cnt) {
-    Register tmp = rscratch1;
-    Register tmp2 = rscratch2;
-    int zva_length = VM_Version::zva_length();
-    Label initial_table_end, loop_zva;
-    Label fini;
+  // The inner part of zero_words().  This is the bulk operation,
+  // zeroing words in blocks, possibly using DC ZVA to do it.  The
+  // caller is responsible for zeroing the last few words.
+  //
+  // Inputs:
+  // r10: the HeapWord-aligned base address of an array to zero.
+  // r11: the count in HeapWords, r11 > 0.
+  //
+  // Returns r10 and r11, adjusted for the caller to clear.
+  // r10: the base address of the tail of words left to clear.
+  // r11: the number of words in the tail.
+  //      r11 < MacroAssembler::zero_words_block_size.
+
+  address generate_zero_blocks() {
+    Label store_pair, loop_store_pair, done;
+    Label base_aligned;
+
+    Register base = r10, cnt = r11;
 
     __ align(CodeEntryAlignment);
-    StubCodeMark mark(this, "StubRoutines", "zero_longs");
+    StubCodeMark mark(this, "StubRoutines", "zero_blocks");
     address start = __ pc();
 
-    // Base must be 16 byte aligned. If not just return and let caller handle it
-    __ tst(base, 0x0f);
-    __ br(Assembler::NE, fini);
-    // Align base with ZVA length.
-    __ neg(tmp, base);
-    __ andr(tmp, tmp, zva_length - 1);
-
-    // tmp: the number of bytes to be filled to align the base with ZVA length.
-    __ add(base, base, tmp);
-    __ sub(cnt, cnt, tmp, Assembler::ASR, 3);
-    __ adr(tmp2, initial_table_end);
-    __ sub(tmp2, tmp2, tmp, Assembler::LSR, 2);
-    __ br(tmp2);
-
-    for (int i = -zva_length + 16; i < 0; i += 16)
-      __ stp(zr, zr, Address(base, i));
-    __ bind(initial_table_end);
-
-    __ sub(cnt, cnt, zva_length >> 3);
-    __ bind(loop_zva);
-    __ dc(Assembler::ZVA, base);
-    __ subs(cnt, cnt, zva_length >> 3);
-    __ add(base, base, zva_length);
-    __ br(Assembler::GE, loop_zva);
-    __ add(cnt, cnt, zva_length >> 3); // count not zeroed by DC ZVA
-    __ bind(fini);
+    if (UseBlockZeroing) {
+      int zva_length = VM_Version::zva_length();
+
+      // Ensure ZVA length can be divided by 16. This is required by
+      // the subsequent operations.
+      assert (zva_length % 16 == 0, "Unexpected ZVA Length");
+
+      __ tbz(base, 3, base_aligned);
+      __ str(zr, Address(__ post(base, 8)));
+      __ sub(cnt, cnt, 1);
+      __ bind(base_aligned);
+
+      // Ensure count >= zva_length * 2 so that it still deserves a zva after
+      // alignment.
+      Label small;
+      int low_limit = MAX2(zva_length * 2, (int)BlockZeroingLowLimit);
+      __ cmp(cnt, low_limit >> 3);
+      __ br(Assembler::LT, small);
+      __ zero_dcache_blocks(base, cnt);
+      __ bind(small);
+    }
+
+    {
+      // Number of stp instructions we'll unroll
+      const int unroll =
+        MacroAssembler::zero_words_block_size / 2;
+      // Clear the remaining blocks.
+      Label loop;
+      __ subs(cnt, cnt, unroll * 2);
+      __ br(Assembler::LT, done);
+      __ bind(loop);
+      for (int i = 0; i < unroll; i++)
+        __ stp(zr, zr, __ post(base, 16));
+      __ subs(cnt, cnt, unroll * 2);
+      __ br(Assembler::GE, loop);
+      __ bind(done);
+      __ add(cnt, cnt, unroll * 2);
+    }
+
     __ ret(lr);
 
     return start;
   }
 
+
   typedef enum {
     copy_forwards = 1,
     copy_backwards = -1
@@ -2346,20 +2372,16 @@
     __ subw(count, count, cnt_words, Assembler::LSL, 3 - shift);
     if (UseBlockZeroing) {
       Label non_block_zeroing, rest;
-      Register tmp = rscratch1;
-      // count >= BlockZeroingLowLimit && value == 0
-      __ subs(tmp, cnt_words, BlockZeroingLowLimit >> 3);
-      __ ccmp(value, 0 /* comparing value */, 0 /* NZCV */, Assembler::GE);
-      __ br(Assembler::NE, non_block_zeroing);
+      // If the fill value is zero we can use the fast zero_words().
+      __ cbnz(value, non_block_zeroing);
       __ mov(bz_base, to);
-      __ block_zero(bz_base, cnt_words, true);
-      __ mov(to, bz_base);
+      __ add(to, to, cnt_words, Assembler::LSL, LogBytesPerWord);
+      __ zero_words(bz_base, cnt_words);
       __ b(rest);
       __ bind(non_block_zeroing);
       __ fill_words(to, cnt_words, value);
       __ bind(rest);
-    }
-    else {
+    } else {
       __ fill_words(to, cnt_words, value);
     }
 
@@ -2420,7 +2442,7 @@
     generate_copy_longs(copy_f, r0, r1, rscratch2, copy_forwards);
     generate_copy_longs(copy_b, r0, r1, rscratch2, copy_backwards);
 
-    StubRoutines::aarch64::_zero_longs = generate_zero_longs(r10, r11);
+    StubRoutines::aarch64::_zero_blocks = generate_zero_blocks();
 
     //*** jbyte
     // Always need aligned and unaligned versions
@@ -4769,6 +4791,7 @@
                                                        &StubRoutines::_safefetchN_fault_pc,
                                                        &StubRoutines::_safefetchN_continuation_pc);
 #endif
+    StubRoutines::aarch64::set_completed();
   }
 
  public:
--- a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -43,7 +43,8 @@
 address StubRoutines::aarch64::_float_sign_flip = NULL;
 address StubRoutines::aarch64::_double_sign_mask = NULL;
 address StubRoutines::aarch64::_double_sign_flip = NULL;
-address StubRoutines::aarch64::_zero_longs = NULL;
+address StubRoutines::aarch64::_zero_blocks = NULL;
+bool StubRoutines::aarch64::_completed = false;
 
 /**
  *  crc_table[] from jdk/src/share/native/java/util/zip/zlib-1.2.5/crc32.h
--- a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp	Wed Jul 05 23:37:13 2017 +0200
@@ -61,7 +61,8 @@
   static address _double_sign_mask;
   static address _double_sign_flip;
 
-  static address _zero_longs;
+  static address _zero_blocks;
+  static bool _completed;
 
  public:
 
@@ -115,12 +116,19 @@
     return _double_sign_flip;
   }
 
-  static address get_zero_longs()
-  {
-    return _zero_longs;
+  static address zero_blocks() {
+    return _zero_blocks;
   }
 
- private:
+  static bool complete() {
+    return _completed;
+  }
+
+  static void set_completed() {
+    _completed = true;
+  }
+
+private:
   static juint    _crc_table[];
 
 };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/AltHashing.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.memory;
+
+public class AltHashing {
+    public static long murmur3_32(long seed, byte[] data) {
+      long h1 = seed;
+      int len = data.length;
+      int count = len;
+
+      int offset = 0;
+
+      // body
+      while (count >= 4) {
+          long k1 = (data[offset] & 0x0FF)
+              | (data[offset + 1] & 0x0FF) << 8
+              | (data[offset + 2] & 0x0FF) << 16
+              | data[offset + 3] << 24;
+
+          count -= 4;
+          offset += 4;
+
+          k1 *= 0xcc9e2d51;
+          k1 = Integer.rotateLeft((int)k1, 15);
+          k1 *= 0x1b873593;
+          k1 &= 0xFFFFFFFFL;
+
+          h1 ^= k1;
+          h1 = Integer.rotateLeft((int)h1, 13);
+          h1 = h1 * 5 + 0xe6546b64;
+          h1 &= 0xFFFFFFFFL;
+      }
+
+      //tail
+      if (count > 0) {
+          long k1 = 0;
+
+          switch (count) {
+              case 3:
+                  k1 ^= (data[offset + 2] & 0xff) << 16;
+                  // fall through
+              case 2:
+                  k1 ^= (data[offset + 1] & 0xff) << 8;
+                  // fall through
+              case 1:
+                  k1 ^= (data[offset] & 0xff);
+                  // fall through
+              default:
+                  k1 *= 0xcc9e2d51;
+                  k1 = Integer.rotateLeft((int)k1, 15);
+                  k1 *= 0x1b873593;
+                  k1 &= 0xFFFFFFFFL;
+                  h1 ^= k1;
+                  h1 &= 0xFFFFFFFFL;
+          }
+      }
+
+      // finalization
+      h1 ^= len;
+
+      // finalization mix force all bits of a hash block to avalanche
+      h1 ^= h1 >> 16;
+      h1 *= 0x85ebca6b;
+      h1 &= 0xFFFFFFFFL;
+      h1 ^= h1 >> 13;
+      h1 *= 0xc2b2ae35;
+      h1 &= 0xFFFFFFFFL;
+      h1 ^= h1 >> 16;
+
+      return h1 & 0xFFFFFFFFL;
+  }
+}
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,11 +45,14 @@
     Type type = db.lookupType("SymbolTable");
     theTableField  = type.getAddressField("_the_table");
     sharedTableField = type.getAddressField("_shared_table");
+    type = db.lookupType("RehashableSymbolHashtable");
+    seedField = type.getCIntegerField("_seed");
   }
 
   // Fields
   private static AddressField theTableField;
   private static AddressField sharedTableField;
+  private static CIntegerField seedField;
 
   private CompactHashTable sharedTable;
 
@@ -62,6 +65,17 @@
     return table;
   }
 
+  public static long getSeed() {
+      return (long) seedField.getValue();
+  }
+
+  public static boolean useAlternateHashcode() {
+      if (getSeed() != 0) {
+          return true;
+      }
+      return false;
+  }
+
   public SymbolTable(Address addr) {
     super(addr);
   }
@@ -86,11 +100,17 @@
   public Symbol probe(byte[] name) {
     long hashValue = hashSymbol(name);
 
+    // shared table does not use alternate hashing algorithm,
+    // it always uses the same original hash code.
     Symbol s = sharedTable.probe(name, hashValue);
     if (s != null) {
       return s;
     }
 
+    if (useAlternateHashcode()) {
+        hashValue = AltHashing.murmur3_32(getSeed(), name);
+    }
+
     for (HashtableEntry e = (HashtableEntry) bucket(hashToIndex(hashValue)); e != null; e = (HashtableEntry) e.next()) {
       if (e.hash() == hashValue) {
          Symbol sym = Symbol.create(e.literalValue());
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/JavaThread.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/JavaThread.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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
@@ -50,6 +50,7 @@
   private static AddressField  osThreadField;
   private static AddressField  stackBaseField;
   private static CIntegerField stackSizeField;
+  private static CIntegerField terminatedField;
 
   private static JavaThreadPDAccess access;
 
@@ -66,6 +67,9 @@
   private static int           BLOCKED;
   private static int           BLOCKED_TRANS;
 
+  private static int           NOT_TERMINATED;
+  private static int           EXITING;
+
   static {
     VM.registerVMInitializedObserver(new Observer() {
         public void update(Observable o, Object data) {
@@ -87,6 +91,7 @@
     osThreadField     = type.getAddressField("_osthread");
     stackBaseField    = type.getAddressField("_stack_base");
     stackSizeField    = type.getCIntegerField("_stack_size");
+    terminatedField   = type.getCIntegerField("_terminated");
 
     UNINITIALIZED     = db.lookupIntConstant("_thread_uninitialized").intValue();
     NEW               = db.lookupIntConstant("_thread_new").intValue();
@@ -99,6 +104,10 @@
     IN_JAVA_TRANS     = db.lookupIntConstant("_thread_in_Java_trans").intValue();
     BLOCKED           = db.lookupIntConstant("_thread_blocked").intValue();
     BLOCKED_TRANS     = db.lookupIntConstant("_thread_blocked_trans").intValue();
+
+    NOT_TERMINATED    = db.lookupIntConstant("JavaThread::_not_terminated").intValue();
+    EXITING           = db.lookupIntConstant("JavaThread::_thread_exiting").intValue();
+
   }
 
   public JavaThread(Address addr) {
@@ -128,6 +137,14 @@
       example, "SolarisSPARCCompilerThread".) */
   public boolean isJavaThread() { return true; }
 
+  public boolean isExiting () {
+      return (getTerminated() == EXITING) || isTerminated();
+  }
+
+  public boolean isTerminated() {
+      return (getTerminated() != NOT_TERMINATED) && (getTerminated() != EXITING);
+  }
+
   public static AddressField getAnchorField() { return anchorField; }
 
   /** Get the last Java stack pointer */
@@ -329,6 +346,10 @@
     return stackSizeField.getValue(addr);
   }
 
+  public int getTerminated() {
+      return (int) terminatedField.getValue(addr);
+  }
+
   /** Gets the Java-side thread object for this JavaThread */
   public Oop getThreadObj() {
     Oop obj = null;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/StackFrameInfo.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.runtime;
+
+import sun.jvm.hotspot.oops.*;
+
+public class StackFrameInfo {
+    private Method      method;
+    int                 bci;
+    Oop                 classHolder;
+
+    public StackFrameInfo(JavaVFrame vf) {
+        this.method = vf.getMethod();
+        this.bci = vf.getBCI();
+    }
+
+    public Method getMethod() {
+        return method;
+    }
+
+    public int getBCI() {
+        return bci;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ThreadStackTrace.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+
+package sun.jvm.hotspot.runtime;
+
+import java.util.*;
+
+public class ThreadStackTrace {
+    private JavaThread                        thread;
+    private int                               depth;  // number of stack frames added
+    private ArrayList<StackFrameInfo>         frames;
+
+    public ThreadStackTrace(JavaThread t) {
+        this.thread = t;
+        this.depth = 0;
+        this.frames = new ArrayList<StackFrameInfo>();
+    }
+
+    public int getStackDepth() {
+        return depth;
+    }
+
+    public StackFrameInfo stackFrameAt(int index) {
+        return frames.get(index);
+    }
+
+    public void dumpStack(int maxDepth) {
+        if (!thread.isJavaThread()) {
+            System.out.println("dumpStack: not java Thread returning");
+            return;
+        }
+        try {
+            for (JavaVFrame vf = thread.getLastJavaVFrameDbg(); vf != null; vf = vf.javaSender()) {
+                StackFrameInfo frame = new StackFrameInfo(vf);
+                frames.add(frame);
+                depth++;
+
+                if (maxDepth > 0 && depth == maxDepth) {
+                    // Skip frames if more than maxDepth
+                    break;
+                }
+            }
+        } catch (Exception e) {
+            System.out.println("Error occurred during stack walking:");
+            e.printStackTrace();
+        }
+    }
+}
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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.");
        }
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/HeapHprofBinWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -379,6 +379,10 @@
     private static final long MAX_U4_VALUE = 0xFFFFFFFFL;
     int serialNum = 1;
 
+    public HeapHprofBinWriter() {
+        this.KlassMap = new ArrayList<Klass>();
+    }
+
     public synchronized void write(String fileName) throws IOException {
         // open file stream and create buffered data output stream
         fos = new FileOutputStream(fileName);
@@ -426,6 +430,9 @@
         // HPROF_LOAD_CLASS records for all classes
         writeClasses();
 
+        // write HPROF_FRAME and HPROF_TRACE records
+        dumpStackTraces();
+
         // write CLASS_DUMP records
         writeClassDumpRecords();
 
@@ -700,6 +707,67 @@
         }
     }
 
+    private void dumpStackTraces() throws IOException {
+        // write a HPROF_TRACE record without any frames to be referenced as object alloc sites
+        writeHeader(HPROF_TRACE, 3 * (int)INT_SIZE );
+        out.writeInt(DUMMY_STACK_TRACE_ID);
+        out.writeInt(0);                    // thread number
+        out.writeInt(0);                    // frame count
+
+        int frameSerialNum = 0;
+        int numThreads = 0;
+        Threads threads = VM.getVM().getThreads();
+
+        for (JavaThread thread = threads.first(); thread != null; thread = thread.next()) {
+            Oop threadObj = thread.getThreadObj();
+            if (threadObj != null && !thread.isExiting() && !thread.isHiddenFromExternalView()) {
+
+                // dump thread stack trace
+                ThreadStackTrace st = new ThreadStackTrace(thread);
+                st.dumpStack(-1);
+                numThreads++;
+
+                // write HPROF_FRAME records for this thread's stack trace
+                int depth = st.getStackDepth();
+                int threadFrameStart = frameSerialNum;
+                for (int j=0; j < depth; j++) {
+                    StackFrameInfo frame = st.stackFrameAt(j);
+                    Method m = frame.getMethod();
+                    int classSerialNum = KlassMap.indexOf(m.getMethodHolder()) + 1;
+                    // the class serial number starts from 1
+                    assert classSerialNum > 0:"class not found";
+                    dumpStackFrame(++frameSerialNum, classSerialNum, m, frame.getBCI());
+                }
+
+                // write HPROF_TRACE record for one thread
+                writeHeader(HPROF_TRACE, 3 * (int)INT_SIZE + depth * (int)VM.getVM().getOopSize());
+                int stackSerialNum = numThreads + DUMMY_STACK_TRACE_ID;
+                out.writeInt(stackSerialNum);      // stack trace serial number
+                out.writeInt(numThreads);          // thread serial number
+                out.writeInt(depth);               // frame count
+                for (int j=1; j <= depth; j++) {
+                    writeObjectID(threadFrameStart + j);
+                }
+            }
+        }
+    }
+
+    private void dumpStackFrame(int frameSN, int classSN, Method m, int bci) throws IOException {
+        int lineNumber;
+        if (m.isNative()) {
+            lineNumber = -3; // native frame
+        } else {
+            lineNumber = m.getLineNumberFromBCI(bci);
+        }
+        writeHeader(HPROF_FRAME, 4 * (int)VM.getVM().getOopSize() + 2 * (int)INT_SIZE);
+        writeObjectID(frameSN);                                  // frame serial number
+        writeSymbolID(m.getName());                              // method's name
+        writeSymbolID(m.getSignature());                         // method's signature
+        writeSymbolID(m.getMethodHolder().getSourceFileName());  // source file name
+        out.writeInt(classSN);                                   // class serial number
+        out.writeInt(lineNumber);                                // line number
+    }
+
     protected void writeJavaThread(JavaThread jt, int index) throws IOException {
         out.writeByte((byte) HPROF_GC_ROOT_THREAD_OBJ);
         writeObjectID(jt.getThreadObj());
@@ -1030,6 +1098,7 @@
                         writeHeader(HPROF_LOAD_CLASS, 2 * (OBJ_ID_SIZE + 4));
                         out.writeInt(serialNum);
                         writeObjectID(clazz);
+                        KlassMap.add(serialNum - 1, k);
                         out.writeInt(DUMMY_STACK_TRACE_ID);
                         writeSymbolID(k.getName());
                         serialNum++;
@@ -1045,6 +1114,7 @@
                         writeHeader(HPROF_LOAD_CLASS, 2 * (OBJ_ID_SIZE + 4));
                         out.writeInt(serialNum);
                         writeObjectID(clazz);
+                        KlassMap.add(serialNum - 1, k);
                         out.writeInt(DUMMY_STACK_TRACE_ID);
                         writeSymbolID(k.getName());
                         serialNum++;
@@ -1157,6 +1227,7 @@
     private Debugger dbg;
     private ObjectHeap objectHeap;
     private SymbolTable symTbl;
+    private ArrayList<Klass> KlassMap;
 
     // oopSize of the debuggee
     private int OBJ_ID_SIZE;
--- a/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/CheckGraalIntrinsics.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -246,21 +246,21 @@
                         "jdk/internal/misc/Unsafe.allocateUninitializedArray0(Ljava/lang/Class;I)Ljava/lang/Object;",
                         "jdk/internal/misc/Unsafe.compareAndExchangeByteAcquire(Ljava/lang/Object;JBB)B",
                         "jdk/internal/misc/Unsafe.compareAndExchangeByteRelease(Ljava/lang/Object;JBB)B",
-                        "jdk/internal/misc/Unsafe.compareAndExchangeByteVolatile(Ljava/lang/Object;JBB)B",
+                        "jdk/internal/misc/Unsafe.compareAndExchangeByte(Ljava/lang/Object;JBB)B",
                         "jdk/internal/misc/Unsafe.compareAndExchangeIntAcquire(Ljava/lang/Object;JII)I",
                         "jdk/internal/misc/Unsafe.compareAndExchangeIntRelease(Ljava/lang/Object;JII)I",
-                        "jdk/internal/misc/Unsafe.compareAndExchangeIntVolatile(Ljava/lang/Object;JII)I",
+                        "jdk/internal/misc/Unsafe.compareAndExchangeInt(Ljava/lang/Object;JII)I",
                         "jdk/internal/misc/Unsafe.compareAndExchangeLongAcquire(Ljava/lang/Object;JJJ)J",
                         "jdk/internal/misc/Unsafe.compareAndExchangeLongRelease(Ljava/lang/Object;JJJ)J",
-                        "jdk/internal/misc/Unsafe.compareAndExchangeLongVolatile(Ljava/lang/Object;JJJ)J",
+                        "jdk/internal/misc/Unsafe.compareAndExchangeLong(Ljava/lang/Object;JJJ)J",
                         "jdk/internal/misc/Unsafe.compareAndExchangeObjectAcquire(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
                         "jdk/internal/misc/Unsafe.compareAndExchangeObjectRelease(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
-                        "jdk/internal/misc/Unsafe.compareAndExchangeObjectVolatile(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
+                        "jdk/internal/misc/Unsafe.compareAndExchangeObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
                         "jdk/internal/misc/Unsafe.compareAndExchangeShortAcquire(Ljava/lang/Object;JSS)S",
                         "jdk/internal/misc/Unsafe.compareAndExchangeShortRelease(Ljava/lang/Object;JSS)S",
-                        "jdk/internal/misc/Unsafe.compareAndExchangeShortVolatile(Ljava/lang/Object;JSS)S",
-                        "jdk/internal/misc/Unsafe.compareAndSwapByte(Ljava/lang/Object;JBB)Z",
-                        "jdk/internal/misc/Unsafe.compareAndSwapShort(Ljava/lang/Object;JSS)Z",
+                        "jdk/internal/misc/Unsafe.compareAndExchangeShort(Ljava/lang/Object;JSS)S",
+                        "jdk/internal/misc/Unsafe.compareAndSetByte(Ljava/lang/Object;JBB)Z",
+                        "jdk/internal/misc/Unsafe.compareAndSetShort(Ljava/lang/Object;JSS)Z",
                         "jdk/internal/misc/Unsafe.copyMemory0(Ljava/lang/Object;JLjava/lang/Object;JJ)V",
                         "jdk/internal/misc/Unsafe.getAndAddByte(Ljava/lang/Object;JB)B",
                         "jdk/internal/misc/Unsafe.getAndAddShort(Ljava/lang/Object;JS)S",
@@ -295,26 +295,26 @@
                         "jdk/internal/misc/Unsafe.putObjectOpaque(Ljava/lang/Object;JLjava/lang/Object;)V",
                         "jdk/internal/misc/Unsafe.putShortOpaque(Ljava/lang/Object;JS)V",
                         "jdk/internal/misc/Unsafe.unpark(Ljava/lang/Object;)V",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapByte(Ljava/lang/Object;JBB)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapByteAcquire(Ljava/lang/Object;JBB)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapByteRelease(Ljava/lang/Object;JBB)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapByteVolatile(Ljava/lang/Object;JBB)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapInt(Ljava/lang/Object;JII)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapIntAcquire(Ljava/lang/Object;JII)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapIntRelease(Ljava/lang/Object;JII)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapIntVolatile(Ljava/lang/Object;JII)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapLong(Ljava/lang/Object;JJJ)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapLongAcquire(Ljava/lang/Object;JJJ)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapLongRelease(Ljava/lang/Object;JJJ)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapLongVolatile(Ljava/lang/Object;JJJ)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapObjectAcquire(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapObjectRelease(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapObjectVolatile(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapShort(Ljava/lang/Object;JSS)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapShortAcquire(Ljava/lang/Object;JSS)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapShortRelease(Ljava/lang/Object;JSS)Z",
-                        "jdk/internal/misc/Unsafe.weakCompareAndSwapShortVolatile(Ljava/lang/Object;JSS)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetBytePlain(Ljava/lang/Object;JBB)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetByteAcquire(Ljava/lang/Object;JBB)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetByteRelease(Ljava/lang/Object;JBB)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetByte(Ljava/lang/Object;JBB)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetIntPlain(Ljava/lang/Object;JII)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetIntAcquire(Ljava/lang/Object;JII)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetIntRelease(Ljava/lang/Object;JII)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetInt(Ljava/lang/Object;JII)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetLongPlain(Ljava/lang/Object;JJJ)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetLongAcquire(Ljava/lang/Object;JJJ)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetLongRelease(Ljava/lang/Object;JJJ)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetLong(Ljava/lang/Object;JJJ)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetObjectPlain(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetObjectAcquire(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetObjectRelease(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetShortPlain(Ljava/lang/Object;JSS)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetShortAcquire(Ljava/lang/Object;JSS)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetShortRelease(Ljava/lang/Object;JSS)Z",
+                        "jdk/internal/misc/Unsafe.weakCompareAndSetShort(Ljava/lang/Object;JSS)Z",
                         "jdk/internal/util/Preconditions.checkIndex(IILjava/util/function/BiFunction;)I",
                         "jdk/jfr/internal/JVM.counterTime()J",
                         "jdk/jfr/internal/JVM.getBufferWriter()Ljava/lang/Object;",
--- a/hotspot/src/os/solaris/vm/os_solaris.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/os/solaris/vm/os_solaris.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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
--- a/hotspot/src/share/vm/c1/c1_Compiler.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -108,7 +108,7 @@
   }
 
   switch (id) {
-  case vmIntrinsics::_compareAndSwapLong:
+  case vmIntrinsics::_compareAndSetLong:
     if (!VM_Version::supports_cx8()) return false;
     break;
   case vmIntrinsics::_getAndAddInt:
@@ -217,8 +217,8 @@
   case vmIntrinsics::_updateDirectByteBufferCRC32C:
 #endif
   case vmIntrinsics::_vectorizedMismatch:
-  case vmIntrinsics::_compareAndSwapInt:
-  case vmIntrinsics::_compareAndSwapObject:
+  case vmIntrinsics::_compareAndSetInt:
+  case vmIntrinsics::_compareAndSetObject:
   case vmIntrinsics::_getCharStringU:
   case vmIntrinsics::_putCharStringU:
 #ifdef TRACE_HAVE_INTRINSICS
--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3500,9 +3500,9 @@
   case vmIntrinsics::_putLongVolatile    : append_unsafe_put_obj(callee, T_LONG,    true); return;
   case vmIntrinsics::_putFloatVolatile   : append_unsafe_put_obj(callee, T_FLOAT,   true); return;
   case vmIntrinsics::_putDoubleVolatile  : append_unsafe_put_obj(callee, T_DOUBLE,  true); return;
-  case vmIntrinsics::_compareAndSwapLong:
-  case vmIntrinsics::_compareAndSwapInt:
-  case vmIntrinsics::_compareAndSwapObject: append_unsafe_CAS(callee); return;
+  case vmIntrinsics::_compareAndSetLong:
+  case vmIntrinsics::_compareAndSetInt:
+  case vmIntrinsics::_compareAndSetObject: append_unsafe_CAS(callee); return;
   case vmIntrinsics::_getAndAddInt:
   case vmIntrinsics::_getAndAddLong      : append_unsafe_get_and_set_obj(callee, true); return;
   case vmIntrinsics::_getAndSetInt       :
--- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3212,13 +3212,13 @@
   // java.nio.Buffer.checkIndex
   case vmIntrinsics::_checkIndex:     do_NIOCheckIndex(x); break;
 
-  case vmIntrinsics::_compareAndSwapObject:
+  case vmIntrinsics::_compareAndSetObject:
     do_CompareAndSwap(x, objectType);
     break;
-  case vmIntrinsics::_compareAndSwapInt:
+  case vmIntrinsics::_compareAndSetInt:
     do_CompareAndSwap(x, intType);
     break;
-  case vmIntrinsics::_compareAndSwapLong:
+  case vmIntrinsics::_compareAndSetLong:
     do_CompareAndSwap(x, longType);
     break;
 
--- a/hotspot/src/share/vm/classfile/vmSymbols.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -632,25 +632,28 @@
   case vmIntrinsics::_loadFence:
   case vmIntrinsics::_storeFence:
   case vmIntrinsics::_fullFence:
-  case vmIntrinsics::_compareAndSwapLong:
-  case vmIntrinsics::_weakCompareAndSwapLong:
-  case vmIntrinsics::_weakCompareAndSwapLongAcquire:
-  case vmIntrinsics::_weakCompareAndSwapLongRelease:
-  case vmIntrinsics::_compareAndSwapInt:
-  case vmIntrinsics::_weakCompareAndSwapInt:
-  case vmIntrinsics::_weakCompareAndSwapIntAcquire:
-  case vmIntrinsics::_weakCompareAndSwapIntRelease:
-  case vmIntrinsics::_compareAndSwapObject:
-  case vmIntrinsics::_weakCompareAndSwapObject:
-  case vmIntrinsics::_weakCompareAndSwapObjectAcquire:
-  case vmIntrinsics::_weakCompareAndSwapObjectRelease:
-  case vmIntrinsics::_compareAndExchangeIntVolatile:
+  case vmIntrinsics::_compareAndSetLong:
+  case vmIntrinsics::_weakCompareAndSetLong:
+  case vmIntrinsics::_weakCompareAndSetLongPlain:
+  case vmIntrinsics::_weakCompareAndSetLongAcquire:
+  case vmIntrinsics::_weakCompareAndSetLongRelease:
+  case vmIntrinsics::_compareAndSetInt:
+  case vmIntrinsics::_weakCompareAndSetInt:
+  case vmIntrinsics::_weakCompareAndSetIntPlain:
+  case vmIntrinsics::_weakCompareAndSetIntAcquire:
+  case vmIntrinsics::_weakCompareAndSetIntRelease:
+  case vmIntrinsics::_compareAndSetObject:
+  case vmIntrinsics::_weakCompareAndSetObject:
+  case vmIntrinsics::_weakCompareAndSetObjectPlain:
+  case vmIntrinsics::_weakCompareAndSetObjectAcquire:
+  case vmIntrinsics::_weakCompareAndSetObjectRelease:
+  case vmIntrinsics::_compareAndExchangeInt:
   case vmIntrinsics::_compareAndExchangeIntAcquire:
   case vmIntrinsics::_compareAndExchangeIntRelease:
-  case vmIntrinsics::_compareAndExchangeLongVolatile:
+  case vmIntrinsics::_compareAndExchangeLong:
   case vmIntrinsics::_compareAndExchangeLongAcquire:
   case vmIntrinsics::_compareAndExchangeLongRelease:
-  case vmIntrinsics::_compareAndExchangeObjectVolatile:
+  case vmIntrinsics::_compareAndExchangeObject:
   case vmIntrinsics::_compareAndExchangeObjectAcquire:
   case vmIntrinsics::_compareAndExchangeObjectRelease:
     if (!InlineUnsafeOps) return true;
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1244,100 +1244,100 @@
   do_intrinsic(_putIntUnaligned,           jdk_internal_misc_Unsafe,    putIntUnaligned_name, putInt_signature,         F_R)  \
   do_intrinsic(_putLongUnaligned,          jdk_internal_misc_Unsafe,    putLongUnaligned_name, putLong_signature,       F_R)  \
                                                                                                                         \
-  do_signature(compareAndSwapObject_signature,     "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z")        \
+  do_signature(compareAndSetObject_signature,      "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z")        \
   do_signature(compareAndExchangeObject_signature, "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;") \
-  do_signature(compareAndSwapLong_signature,       "(Ljava/lang/Object;JJJ)Z")                                          \
+  do_signature(compareAndSetLong_signature,        "(Ljava/lang/Object;JJJ)Z")                                          \
   do_signature(compareAndExchangeLong_signature,   "(Ljava/lang/Object;JJJ)J")                                          \
-  do_signature(compareAndSwapInt_signature,        "(Ljava/lang/Object;JII)Z")                                          \
+  do_signature(compareAndSetInt_signature,         "(Ljava/lang/Object;JII)Z")                                          \
   do_signature(compareAndExchangeInt_signature,    "(Ljava/lang/Object;JII)I")                                          \
-  do_signature(compareAndSwapByte_signature,       "(Ljava/lang/Object;JBB)Z")                                          \
+  do_signature(compareAndSetByte_signature,        "(Ljava/lang/Object;JBB)Z")                                          \
   do_signature(compareAndExchangeByte_signature,   "(Ljava/lang/Object;JBB)B")                                          \
-  do_signature(compareAndSwapShort_signature,      "(Ljava/lang/Object;JSS)Z")                                          \
+  do_signature(compareAndSetShort_signature,       "(Ljava/lang/Object;JSS)Z")                                          \
   do_signature(compareAndExchangeShort_signature,  "(Ljava/lang/Object;JSS)S")                                          \
                                                                                                                         \
-  do_name(compareAndSwapObject_name,             "compareAndSwapObject")                                                \
-  do_name(compareAndExchangeObjectVolatile_name, "compareAndExchangeObjectVolatile")                                    \
+  do_name(compareAndSetObject_name,              "compareAndSetObject")                                                 \
+  do_name(compareAndExchangeObject_name,         "compareAndExchangeObject")                                            \
   do_name(compareAndExchangeObjectAcquire_name,  "compareAndExchangeObjectAcquire")                                     \
   do_name(compareAndExchangeObjectRelease_name,  "compareAndExchangeObjectRelease")                                     \
-  do_name(compareAndSwapLong_name,               "compareAndSwapLong")                                                  \
-  do_name(compareAndExchangeLongVolatile_name,   "compareAndExchangeLongVolatile")                                      \
+  do_name(compareAndSetLong_name,                "compareAndSetLong")                                                   \
+  do_name(compareAndExchangeLong_name,           "compareAndExchangeLong")                                              \
   do_name(compareAndExchangeLongAcquire_name,    "compareAndExchangeLongAcquire")                                       \
   do_name(compareAndExchangeLongRelease_name,    "compareAndExchangeLongRelease")                                       \
-  do_name(compareAndSwapInt_name,                "compareAndSwapInt")                                                   \
-  do_name(compareAndExchangeIntVolatile_name,    "compareAndExchangeIntVolatile")                                       \
+  do_name(compareAndSetInt_name,                 "compareAndSetInt")                                                    \
+  do_name(compareAndExchangeInt_name,            "compareAndExchangeInt")                                               \
   do_name(compareAndExchangeIntAcquire_name,     "compareAndExchangeIntAcquire")                                        \
   do_name(compareAndExchangeIntRelease_name,     "compareAndExchangeIntRelease")                                        \
-  do_name(compareAndSwapByte_name,               "compareAndSwapByte")                                                  \
-  do_name(compareAndExchangeByteVolatile_name,   "compareAndExchangeByteVolatile")                                      \
+  do_name(compareAndSetByte_name,                "compareAndSetByte")                                                   \
+  do_name(compareAndExchangeByte_name,           "compareAndExchangeByte")                                              \
   do_name(compareAndExchangeByteAcquire_name,    "compareAndExchangeByteAcquire")                                       \
   do_name(compareAndExchangeByteRelease_name,    "compareAndExchangeByteRelease")                                       \
-  do_name(compareAndSwapShort_name,              "compareAndSwapShort")                                                 \
-  do_name(compareAndExchangeShortVolatile_name,  "compareAndExchangeShortVolatile")                                     \
+  do_name(compareAndSetShort_name,               "compareAndSetShort")                                                  \
+  do_name(compareAndExchangeShort_name,          "compareAndExchangeShort")                                             \
   do_name(compareAndExchangeShortAcquire_name,   "compareAndExchangeShortAcquire")                                      \
   do_name(compareAndExchangeShortRelease_name,   "compareAndExchangeShortRelease")                                      \
                                                                                                                         \
-  do_name(weakCompareAndSwapObject_name,         "weakCompareAndSwapObject")                                            \
-  do_name(weakCompareAndSwapObjectAcquire_name,  "weakCompareAndSwapObjectAcquire")                                     \
-  do_name(weakCompareAndSwapObjectRelease_name,  "weakCompareAndSwapObjectRelease")                                     \
-  do_name(weakCompareAndSwapObjectVolatile_name, "weakCompareAndSwapObjectVolatile")                                    \
-  do_name(weakCompareAndSwapLong_name,           "weakCompareAndSwapLong")                                              \
-  do_name(weakCompareAndSwapLongAcquire_name,    "weakCompareAndSwapLongAcquire")                                       \
-  do_name(weakCompareAndSwapLongRelease_name,    "weakCompareAndSwapLongRelease")                                       \
-  do_name(weakCompareAndSwapLongVolatile_name,   "weakCompareAndSwapLongVolatile")                                      \
-  do_name(weakCompareAndSwapInt_name,            "weakCompareAndSwapInt")                                               \
-  do_name(weakCompareAndSwapIntAcquire_name,     "weakCompareAndSwapIntAcquire")                                        \
-  do_name(weakCompareAndSwapIntRelease_name,     "weakCompareAndSwapIntRelease")                                        \
-  do_name(weakCompareAndSwapIntVolatile_name,    "weakCompareAndSwapIntVolatile")                                       \
-  do_name(weakCompareAndSwapByte_name,           "weakCompareAndSwapByte")                                              \
-  do_name(weakCompareAndSwapByteAcquire_name,    "weakCompareAndSwapByteAcquire")                                       \
-  do_name(weakCompareAndSwapByteRelease_name,    "weakCompareAndSwapByteRelease")                                       \
-  do_name(weakCompareAndSwapByteVolatile_name,   "weakCompareAndSwapByteVolatile")                                      \
-  do_name(weakCompareAndSwapShort_name,          "weakCompareAndSwapShort")                                             \
-  do_name(weakCompareAndSwapShortAcquire_name,   "weakCompareAndSwapShortAcquire")                                      \
-  do_name(weakCompareAndSwapShortRelease_name,   "weakCompareAndSwapShortRelease")                                      \
-  do_name(weakCompareAndSwapShortVolatile_name,  "weakCompareAndSwapShortVolatile")                                     \
+  do_name(weakCompareAndSetObjectPlain_name,     "weakCompareAndSetObjectPlain")                                        \
+  do_name(weakCompareAndSetObjectAcquire_name,   "weakCompareAndSetObjectAcquire")                                      \
+  do_name(weakCompareAndSetObjectRelease_name,   "weakCompareAndSetObjectRelease")                                      \
+  do_name(weakCompareAndSetObject_name,          "weakCompareAndSetObject")                                             \
+  do_name(weakCompareAndSetLongPlain_name,       "weakCompareAndSetLongPlain")                                          \
+  do_name(weakCompareAndSetLongAcquire_name,     "weakCompareAndSetLongAcquire")                                        \
+  do_name(weakCompareAndSetLongRelease_name,     "weakCompareAndSetLongRelease")                                        \
+  do_name(weakCompareAndSetLong_name,            "weakCompareAndSetLong")                                               \
+  do_name(weakCompareAndSetIntPlain_name,        "weakCompareAndSetIntPlain")                                           \
+  do_name(weakCompareAndSetIntAcquire_name,      "weakCompareAndSetIntAcquire")                                         \
+  do_name(weakCompareAndSetIntRelease_name,      "weakCompareAndSetIntRelease")                                         \
+  do_name(weakCompareAndSetInt_name,             "weakCompareAndSetInt")                                                \
+  do_name(weakCompareAndSetBytePlain_name,       "weakCompareAndSetBytePlain")                                          \
+  do_name(weakCompareAndSetByteAcquire_name,     "weakCompareAndSetByteAcquire")                                        \
+  do_name(weakCompareAndSetByteRelease_name,     "weakCompareAndSetByteRelease")                                        \
+  do_name(weakCompareAndSetByte_name,            "weakCompareAndSetByte")                                               \
+  do_name(weakCompareAndSetShortPlain_name,      "weakCompareAndSetShortPlain")                                         \
+  do_name(weakCompareAndSetShortAcquire_name,    "weakCompareAndSetShortAcquire")                                       \
+  do_name(weakCompareAndSetShortRelease_name,    "weakCompareAndSetShortRelease")                                       \
+  do_name(weakCompareAndSetShort_name,           "weakCompareAndSetShort")                                              \
                                                                                                                         \
-  do_intrinsic(_compareAndSwapObject,             jdk_internal_misc_Unsafe,  compareAndSwapObject_name,             compareAndSwapObject_signature,     F_RN) \
-  do_intrinsic(_compareAndExchangeObjectVolatile, jdk_internal_misc_Unsafe,  compareAndExchangeObjectVolatile_name, compareAndExchangeObject_signature, F_RN) \
+  do_intrinsic(_compareAndSetObject,              jdk_internal_misc_Unsafe,  compareAndSetObject_name,              compareAndSetObject_signature,      F_RN) \
+  do_intrinsic(_compareAndExchangeObject,         jdk_internal_misc_Unsafe,  compareAndExchangeObject_name,         compareAndExchangeObject_signature, F_RN) \
   do_intrinsic(_compareAndExchangeObjectAcquire,  jdk_internal_misc_Unsafe,  compareAndExchangeObjectAcquire_name,  compareAndExchangeObject_signature, F_R)  \
   do_intrinsic(_compareAndExchangeObjectRelease,  jdk_internal_misc_Unsafe,  compareAndExchangeObjectRelease_name,  compareAndExchangeObject_signature, F_R)  \
-  do_intrinsic(_compareAndSwapLong,               jdk_internal_misc_Unsafe,  compareAndSwapLong_name,               compareAndSwapLong_signature,       F_RN) \
-  do_intrinsic(_compareAndExchangeLongVolatile,   jdk_internal_misc_Unsafe,  compareAndExchangeLongVolatile_name,   compareAndExchangeLong_signature,   F_RN) \
+  do_intrinsic(_compareAndSetLong,                jdk_internal_misc_Unsafe,  compareAndSetLong_name,                compareAndSetLong_signature,        F_RN) \
+  do_intrinsic(_compareAndExchangeLong,           jdk_internal_misc_Unsafe,  compareAndExchangeLong_name,           compareAndExchangeLong_signature,   F_RN) \
   do_intrinsic(_compareAndExchangeLongAcquire,    jdk_internal_misc_Unsafe,  compareAndExchangeLongAcquire_name,    compareAndExchangeLong_signature,   F_R)  \
   do_intrinsic(_compareAndExchangeLongRelease,    jdk_internal_misc_Unsafe,  compareAndExchangeLongRelease_name,    compareAndExchangeLong_signature,   F_R)  \
-  do_intrinsic(_compareAndSwapInt,                jdk_internal_misc_Unsafe,  compareAndSwapInt_name,                compareAndSwapInt_signature,        F_RN) \
-  do_intrinsic(_compareAndExchangeIntVolatile,    jdk_internal_misc_Unsafe,  compareAndExchangeIntVolatile_name,    compareAndExchangeInt_signature,    F_RN) \
+  do_intrinsic(_compareAndSetInt,                 jdk_internal_misc_Unsafe,  compareAndSetInt_name,                 compareAndSetInt_signature,         F_RN) \
+  do_intrinsic(_compareAndExchangeInt,            jdk_internal_misc_Unsafe,  compareAndExchangeInt_name,            compareAndExchangeInt_signature,    F_RN) \
   do_intrinsic(_compareAndExchangeIntAcquire,     jdk_internal_misc_Unsafe,  compareAndExchangeIntAcquire_name,     compareAndExchangeInt_signature,    F_R)  \
   do_intrinsic(_compareAndExchangeIntRelease,     jdk_internal_misc_Unsafe,  compareAndExchangeIntRelease_name,     compareAndExchangeInt_signature,    F_R)  \
-  do_intrinsic(_compareAndSwapByte,               jdk_internal_misc_Unsafe,  compareAndSwapByte_name,               compareAndSwapByte_signature,       F_R)  \
-  do_intrinsic(_compareAndExchangeByteVolatile,   jdk_internal_misc_Unsafe,  compareAndExchangeByteVolatile_name,   compareAndExchangeByte_signature,   F_R)  \
+  do_intrinsic(_compareAndSetByte,                jdk_internal_misc_Unsafe,  compareAndSetByte_name,                compareAndSetByte_signature,        F_R)  \
+  do_intrinsic(_compareAndExchangeByte,           jdk_internal_misc_Unsafe,  compareAndExchangeByte_name,           compareAndExchangeByte_signature,   F_R)  \
   do_intrinsic(_compareAndExchangeByteAcquire,    jdk_internal_misc_Unsafe,  compareAndExchangeByteAcquire_name,    compareAndExchangeByte_signature,   F_R)  \
   do_intrinsic(_compareAndExchangeByteRelease,    jdk_internal_misc_Unsafe,  compareAndExchangeByteRelease_name,    compareAndExchangeByte_signature,   F_R)  \
-  do_intrinsic(_compareAndSwapShort,              jdk_internal_misc_Unsafe,  compareAndSwapShort_name,              compareAndSwapShort_signature,      F_R)  \
-  do_intrinsic(_compareAndExchangeShortVolatile,  jdk_internal_misc_Unsafe,  compareAndExchangeShortVolatile_name,  compareAndExchangeShort_signature,  F_R)  \
+  do_intrinsic(_compareAndSetShort,               jdk_internal_misc_Unsafe,  compareAndSetShort_name,               compareAndSetShort_signature,       F_R)  \
+  do_intrinsic(_compareAndExchangeShort,          jdk_internal_misc_Unsafe,  compareAndExchangeShort_name,          compareAndExchangeShort_signature,  F_R)  \
   do_intrinsic(_compareAndExchangeShortAcquire,   jdk_internal_misc_Unsafe,  compareAndExchangeShortAcquire_name,   compareAndExchangeShort_signature,  F_R)  \
   do_intrinsic(_compareAndExchangeShortRelease,   jdk_internal_misc_Unsafe,  compareAndExchangeShortRelease_name,   compareAndExchangeShort_signature,  F_R)  \
                                                                                                                                                              \
-  do_intrinsic(_weakCompareAndSwapObject,         jdk_internal_misc_Unsafe,  weakCompareAndSwapObject_name,         compareAndSwapObject_signature,     F_R) \
-  do_intrinsic(_weakCompareAndSwapObjectAcquire,  jdk_internal_misc_Unsafe,  weakCompareAndSwapObjectAcquire_name,  compareAndSwapObject_signature,     F_R) \
-  do_intrinsic(_weakCompareAndSwapObjectRelease,  jdk_internal_misc_Unsafe,  weakCompareAndSwapObjectRelease_name,  compareAndSwapObject_signature,     F_R) \
-  do_intrinsic(_weakCompareAndSwapObjectVolatile, jdk_internal_misc_Unsafe,  weakCompareAndSwapObjectVolatile_name, compareAndSwapObject_signature,     F_R) \
-  do_intrinsic(_weakCompareAndSwapLong,           jdk_internal_misc_Unsafe,  weakCompareAndSwapLong_name,           compareAndSwapLong_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapLongAcquire,    jdk_internal_misc_Unsafe,  weakCompareAndSwapLongAcquire_name,    compareAndSwapLong_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapLongRelease,    jdk_internal_misc_Unsafe,  weakCompareAndSwapLongRelease_name,    compareAndSwapLong_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapLongVolatile,   jdk_internal_misc_Unsafe,  weakCompareAndSwapLongVolatile_name,   compareAndSwapLong_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapInt,            jdk_internal_misc_Unsafe,  weakCompareAndSwapInt_name,            compareAndSwapInt_signature,        F_R) \
-  do_intrinsic(_weakCompareAndSwapIntAcquire,     jdk_internal_misc_Unsafe,  weakCompareAndSwapIntAcquire_name,     compareAndSwapInt_signature,        F_R) \
-  do_intrinsic(_weakCompareAndSwapIntRelease,     jdk_internal_misc_Unsafe,  weakCompareAndSwapIntRelease_name,     compareAndSwapInt_signature,        F_R) \
-  do_intrinsic(_weakCompareAndSwapIntVolatile,    jdk_internal_misc_Unsafe,  weakCompareAndSwapIntVolatile_name,    compareAndSwapInt_signature,        F_R) \
-  do_intrinsic(_weakCompareAndSwapByte,           jdk_internal_misc_Unsafe,  weakCompareAndSwapByte_name,           compareAndSwapByte_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapByteAcquire,    jdk_internal_misc_Unsafe,  weakCompareAndSwapByteAcquire_name,    compareAndSwapByte_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapByteRelease,    jdk_internal_misc_Unsafe,  weakCompareAndSwapByteRelease_name,    compareAndSwapByte_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapByteVolatile,   jdk_internal_misc_Unsafe,  weakCompareAndSwapByteVolatile_name,   compareAndSwapByte_signature,       F_R) \
-  do_intrinsic(_weakCompareAndSwapShort,          jdk_internal_misc_Unsafe,  weakCompareAndSwapShort_name,          compareAndSwapShort_signature,      F_R) \
-  do_intrinsic(_weakCompareAndSwapShortAcquire,   jdk_internal_misc_Unsafe,  weakCompareAndSwapShortAcquire_name,   compareAndSwapShort_signature,      F_R) \
-  do_intrinsic(_weakCompareAndSwapShortRelease,   jdk_internal_misc_Unsafe,  weakCompareAndSwapShortRelease_name,   compareAndSwapShort_signature,      F_R) \
-  do_intrinsic(_weakCompareAndSwapShortVolatile,  jdk_internal_misc_Unsafe,  weakCompareAndSwapShortVolatile_name,  compareAndSwapShort_signature,      F_R) \
+  do_intrinsic(_weakCompareAndSetObjectPlain,     jdk_internal_misc_Unsafe,  weakCompareAndSetObjectPlain_name,     compareAndSetObject_signature,      F_R) \
+  do_intrinsic(_weakCompareAndSetObjectAcquire,   jdk_internal_misc_Unsafe,  weakCompareAndSetObjectAcquire_name,   compareAndSetObject_signature,      F_R) \
+  do_intrinsic(_weakCompareAndSetObjectRelease,   jdk_internal_misc_Unsafe,  weakCompareAndSetObjectRelease_name,   compareAndSetObject_signature,      F_R) \
+  do_intrinsic(_weakCompareAndSetObject,          jdk_internal_misc_Unsafe,  weakCompareAndSetObject_name,          compareAndSetObject_signature,      F_R) \
+  do_intrinsic(_weakCompareAndSetLongPlain,       jdk_internal_misc_Unsafe,  weakCompareAndSetLongPlain_name,       compareAndSetLong_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetLongAcquire,     jdk_internal_misc_Unsafe,  weakCompareAndSetLongAcquire_name,     compareAndSetLong_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetLongRelease,     jdk_internal_misc_Unsafe,  weakCompareAndSetLongRelease_name,     compareAndSetLong_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetLong,            jdk_internal_misc_Unsafe,  weakCompareAndSetLong_name,            compareAndSetLong_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetIntPlain,        jdk_internal_misc_Unsafe,  weakCompareAndSetIntPlain_name,        compareAndSetInt_signature,         F_R) \
+  do_intrinsic(_weakCompareAndSetIntAcquire,      jdk_internal_misc_Unsafe,  weakCompareAndSetIntAcquire_name,      compareAndSetInt_signature,         F_R) \
+  do_intrinsic(_weakCompareAndSetIntRelease,      jdk_internal_misc_Unsafe,  weakCompareAndSetIntRelease_name,      compareAndSetInt_signature,         F_R) \
+  do_intrinsic(_weakCompareAndSetInt,             jdk_internal_misc_Unsafe,  weakCompareAndSetInt_name,             compareAndSetInt_signature,         F_R) \
+  do_intrinsic(_weakCompareAndSetBytePlain,       jdk_internal_misc_Unsafe,  weakCompareAndSetBytePlain_name,       compareAndSetByte_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetByteAcquire,     jdk_internal_misc_Unsafe,  weakCompareAndSetByteAcquire_name,     compareAndSetByte_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetByteRelease,     jdk_internal_misc_Unsafe,  weakCompareAndSetByteRelease_name,     compareAndSetByte_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetByte,            jdk_internal_misc_Unsafe,  weakCompareAndSetByte_name,            compareAndSetByte_signature,        F_R) \
+  do_intrinsic(_weakCompareAndSetShortPlain,      jdk_internal_misc_Unsafe,  weakCompareAndSetShortPlain_name,      compareAndSetShort_signature,       F_R) \
+  do_intrinsic(_weakCompareAndSetShortAcquire,    jdk_internal_misc_Unsafe,  weakCompareAndSetShortAcquire_name,    compareAndSetShort_signature,       F_R) \
+  do_intrinsic(_weakCompareAndSetShortRelease,    jdk_internal_misc_Unsafe,  weakCompareAndSetShortRelease_name,    compareAndSetShort_signature,       F_R) \
+  do_intrinsic(_weakCompareAndSetShort,           jdk_internal_misc_Unsafe,  weakCompareAndSetShort_name,           compareAndSetShort_signature,       F_R) \
                            \
   do_intrinsic(_getAndAddInt,             jdk_internal_misc_Unsafe,     getAndAddInt_name, getAndAddInt_signature, F_R)       \
    do_name(     getAndAddInt_name,                                      "getAndAddInt")                                       \
--- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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();
--- a/hotspot/src/share/vm/oops/method.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/oops/method.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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()));
--- a/hotspot/src/share/vm/opto/c2compiler.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/opto/c2compiler.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -244,8 +244,8 @@
     if (!Matcher::match_rule_supported(Op_ReverseBytesL)) return false;
     break;
 
-  /* CompareAndSwap, Object: */
-  case vmIntrinsics::_compareAndSwapObject:
+  /* CompareAndSet, Object: */
+  case vmIntrinsics::_compareAndSetObject:
 #ifdef _LP64
     if ( UseCompressedOops && !Matcher::match_rule_supported(Op_CompareAndSwapN)) return false;
     if (!UseCompressedOops && !Matcher::match_rule_supported(Op_CompareAndSwapP)) return false;
@@ -253,10 +253,10 @@
     if (!Matcher::match_rule_supported(Op_CompareAndSwapP)) return false;
 #endif
     break;
-  case vmIntrinsics::_weakCompareAndSwapObject:
-  case vmIntrinsics::_weakCompareAndSwapObjectAcquire:
-  case vmIntrinsics::_weakCompareAndSwapObjectRelease:
-  case vmIntrinsics::_weakCompareAndSwapObjectVolatile:
+  case vmIntrinsics::_weakCompareAndSetObjectPlain:
+  case vmIntrinsics::_weakCompareAndSetObjectAcquire:
+  case vmIntrinsics::_weakCompareAndSetObjectRelease:
+  case vmIntrinsics::_weakCompareAndSetObject:
 #ifdef _LP64
     if ( UseCompressedOops && !Matcher::match_rule_supported(Op_WeakCompareAndSwapN)) return false;
     if (!UseCompressedOops && !Matcher::match_rule_supported(Op_WeakCompareAndSwapP)) return false;
@@ -264,52 +264,52 @@
     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapP)) return false;
 #endif
     break;
-  /* CompareAndSwap, Long: */
-  case vmIntrinsics::_compareAndSwapLong:
+  /* CompareAndSet, Long: */
+  case vmIntrinsics::_compareAndSetLong:
     if (!Matcher::match_rule_supported(Op_CompareAndSwapL)) return false;
     break;
-  case vmIntrinsics::_weakCompareAndSwapLong:
-  case vmIntrinsics::_weakCompareAndSwapLongAcquire:
-  case vmIntrinsics::_weakCompareAndSwapLongRelease:
-  case vmIntrinsics::_weakCompareAndSwapLongVolatile:
+  case vmIntrinsics::_weakCompareAndSetLongPlain:
+  case vmIntrinsics::_weakCompareAndSetLongAcquire:
+  case vmIntrinsics::_weakCompareAndSetLongRelease:
+  case vmIntrinsics::_weakCompareAndSetLong:
     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapL)) return false;
     break;
 
-  /* CompareAndSwap, Int: */
-  case vmIntrinsics::_compareAndSwapInt:
+  /* CompareAndSet, Int: */
+  case vmIntrinsics::_compareAndSetInt:
     if (!Matcher::match_rule_supported(Op_CompareAndSwapI)) return false;
     break;
-  case vmIntrinsics::_weakCompareAndSwapInt:
-  case vmIntrinsics::_weakCompareAndSwapIntAcquire:
-  case vmIntrinsics::_weakCompareAndSwapIntRelease:
-  case vmIntrinsics::_weakCompareAndSwapIntVolatile:
+  case vmIntrinsics::_weakCompareAndSetIntPlain:
+  case vmIntrinsics::_weakCompareAndSetIntAcquire:
+  case vmIntrinsics::_weakCompareAndSetIntRelease:
+  case vmIntrinsics::_weakCompareAndSetInt:
     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapL)) return false;
     break;
 
-  /* CompareAndSwap, Byte: */
-  case vmIntrinsics::_compareAndSwapByte:
+  /* CompareAndSet, Byte: */
+  case vmIntrinsics::_compareAndSetByte:
     if (!Matcher::match_rule_supported(Op_CompareAndSwapB)) return false;
     break;
-  case vmIntrinsics::_weakCompareAndSwapByte:
-  case vmIntrinsics::_weakCompareAndSwapByteAcquire:
-  case vmIntrinsics::_weakCompareAndSwapByteRelease:
-  case vmIntrinsics::_weakCompareAndSwapByteVolatile:
+  case vmIntrinsics::_weakCompareAndSetBytePlain:
+  case vmIntrinsics::_weakCompareAndSetByteAcquire:
+  case vmIntrinsics::_weakCompareAndSetByteRelease:
+  case vmIntrinsics::_weakCompareAndSetByte:
     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapB)) return false;
     break;
 
-  /* CompareAndSwap, Short: */
-  case vmIntrinsics::_compareAndSwapShort:
+  /* CompareAndSet, Short: */
+  case vmIntrinsics::_compareAndSetShort:
     if (!Matcher::match_rule_supported(Op_CompareAndSwapS)) return false;
     break;
-  case vmIntrinsics::_weakCompareAndSwapShort:
-  case vmIntrinsics::_weakCompareAndSwapShortAcquire:
-  case vmIntrinsics::_weakCompareAndSwapShortRelease:
-  case vmIntrinsics::_weakCompareAndSwapShortVolatile:
+  case vmIntrinsics::_weakCompareAndSetShortPlain:
+  case vmIntrinsics::_weakCompareAndSetShortAcquire:
+  case vmIntrinsics::_weakCompareAndSetShortRelease:
+  case vmIntrinsics::_weakCompareAndSetShort:
     if (!Matcher::match_rule_supported(Op_WeakCompareAndSwapS)) return false;
     break;
 
   /* CompareAndExchange, Object: */
-  case vmIntrinsics::_compareAndExchangeObjectVolatile:
+  case vmIntrinsics::_compareAndExchangeObject:
   case vmIntrinsics::_compareAndExchangeObjectAcquire:
   case vmIntrinsics::_compareAndExchangeObjectRelease:
 #ifdef _LP64
@@ -321,28 +321,28 @@
     break;
 
   /* CompareAndExchange, Long: */
-  case vmIntrinsics::_compareAndExchangeLongVolatile:
+  case vmIntrinsics::_compareAndExchangeLong:
   case vmIntrinsics::_compareAndExchangeLongAcquire:
   case vmIntrinsics::_compareAndExchangeLongRelease:
     if (!Matcher::match_rule_supported(Op_CompareAndExchangeL)) return false;
     break;
 
   /* CompareAndExchange, Int: */
-  case vmIntrinsics::_compareAndExchangeIntVolatile:
+  case vmIntrinsics::_compareAndExchangeInt:
   case vmIntrinsics::_compareAndExchangeIntAcquire:
   case vmIntrinsics::_compareAndExchangeIntRelease:
     if (!Matcher::match_rule_supported(Op_CompareAndExchangeI)) return false;
     break;
 
   /* CompareAndExchange, Byte: */
-  case vmIntrinsics::_compareAndExchangeByteVolatile:
+  case vmIntrinsics::_compareAndExchangeByte:
   case vmIntrinsics::_compareAndExchangeByteAcquire:
   case vmIntrinsics::_compareAndExchangeByteRelease:
     if (!Matcher::match_rule_supported(Op_CompareAndExchangeB)) return false;
     break;
 
   /* CompareAndExchange, Short: */
-  case vmIntrinsics::_compareAndExchangeShortVolatile:
+  case vmIntrinsics::_compareAndExchangeShort:
   case vmIntrinsics::_compareAndExchangeShortAcquire:
   case vmIntrinsics::_compareAndExchangeShortRelease:
     if (!Matcher::match_rule_supported(Op_CompareAndExchangeS)) return false;
--- a/hotspot/src/share/vm/opto/library_call.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/opto/library_call.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -649,46 +649,46 @@
   case vmIntrinsics::_putFloatOpaque:           return inline_unsafe_access( is_store, T_FLOAT,    Opaque, false);
   case vmIntrinsics::_putDoubleOpaque:          return inline_unsafe_access( is_store, T_DOUBLE,   Opaque, false);
 
-  case vmIntrinsics::_compareAndSwapObject:             return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap,      Volatile);
-  case vmIntrinsics::_compareAndSwapByte:               return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap,      Volatile);
-  case vmIntrinsics::_compareAndSwapShort:              return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap,      Volatile);
-  case vmIntrinsics::_compareAndSwapInt:                return inline_unsafe_load_store(T_INT,    LS_cmp_swap,      Volatile);
-  case vmIntrinsics::_compareAndSwapLong:               return inline_unsafe_load_store(T_LONG,   LS_cmp_swap,      Volatile);
-
-  case vmIntrinsics::_weakCompareAndSwapObject:         return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Relaxed);
-  case vmIntrinsics::_weakCompareAndSwapObjectAcquire:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Acquire);
-  case vmIntrinsics::_weakCompareAndSwapObjectRelease:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Release);
-  case vmIntrinsics::_weakCompareAndSwapObjectVolatile: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Volatile);
-  case vmIntrinsics::_weakCompareAndSwapByte:           return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Relaxed);
-  case vmIntrinsics::_weakCompareAndSwapByteAcquire:    return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Acquire);
-  case vmIntrinsics::_weakCompareAndSwapByteRelease:    return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Release);
-  case vmIntrinsics::_weakCompareAndSwapByteVolatile:   return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Volatile);
-  case vmIntrinsics::_weakCompareAndSwapShort:          return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Relaxed);
-  case vmIntrinsics::_weakCompareAndSwapShortAcquire:   return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Acquire);
-  case vmIntrinsics::_weakCompareAndSwapShortRelease:   return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Release);
-  case vmIntrinsics::_weakCompareAndSwapShortVolatile:  return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Volatile);
-  case vmIntrinsics::_weakCompareAndSwapInt:            return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Relaxed);
-  case vmIntrinsics::_weakCompareAndSwapIntAcquire:     return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Acquire);
-  case vmIntrinsics::_weakCompareAndSwapIntRelease:     return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Release);
-  case vmIntrinsics::_weakCompareAndSwapIntVolatile:    return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Volatile);
-  case vmIntrinsics::_weakCompareAndSwapLong:           return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Relaxed);
-  case vmIntrinsics::_weakCompareAndSwapLongAcquire:    return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Acquire);
-  case vmIntrinsics::_weakCompareAndSwapLongRelease:    return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Release);
-  case vmIntrinsics::_weakCompareAndSwapLongVolatile:   return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Volatile);
-
-  case vmIntrinsics::_compareAndExchangeObjectVolatile: return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  Volatile);
+  case vmIntrinsics::_compareAndSetObject:              return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap,      Volatile);
+  case vmIntrinsics::_compareAndSetByte:                return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap,      Volatile);
+  case vmIntrinsics::_compareAndSetShort:               return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap,      Volatile);
+  case vmIntrinsics::_compareAndSetInt:                 return inline_unsafe_load_store(T_INT,    LS_cmp_swap,      Volatile);
+  case vmIntrinsics::_compareAndSetLong:                return inline_unsafe_load_store(T_LONG,   LS_cmp_swap,      Volatile);
+
+  case vmIntrinsics::_weakCompareAndSetObjectPlain:     return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Relaxed);
+  case vmIntrinsics::_weakCompareAndSetObjectAcquire:   return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Acquire);
+  case vmIntrinsics::_weakCompareAndSetObjectRelease:   return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSetObject:          return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Volatile);
+  case vmIntrinsics::_weakCompareAndSetBytePlain:       return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Relaxed);
+  case vmIntrinsics::_weakCompareAndSetByteAcquire:     return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Acquire);
+  case vmIntrinsics::_weakCompareAndSetByteRelease:     return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSetByte:            return inline_unsafe_load_store(T_BYTE,   LS_cmp_swap_weak, Volatile);
+  case vmIntrinsics::_weakCompareAndSetShortPlain:      return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Relaxed);
+  case vmIntrinsics::_weakCompareAndSetShortAcquire:    return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Acquire);
+  case vmIntrinsics::_weakCompareAndSetShortRelease:    return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSetShort:           return inline_unsafe_load_store(T_SHORT,  LS_cmp_swap_weak, Volatile);
+  case vmIntrinsics::_weakCompareAndSetIntPlain:        return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Relaxed);
+  case vmIntrinsics::_weakCompareAndSetIntAcquire:      return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Acquire);
+  case vmIntrinsics::_weakCompareAndSetIntRelease:      return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSetInt:             return inline_unsafe_load_store(T_INT,    LS_cmp_swap_weak, Volatile);
+  case vmIntrinsics::_weakCompareAndSetLongPlain:       return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Relaxed);
+  case vmIntrinsics::_weakCompareAndSetLongAcquire:     return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Acquire);
+  case vmIntrinsics::_weakCompareAndSetLongRelease:     return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Release);
+  case vmIntrinsics::_weakCompareAndSetLong:            return inline_unsafe_load_store(T_LONG,   LS_cmp_swap_weak, Volatile);
+
+  case vmIntrinsics::_compareAndExchangeObject:         return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  Volatile);
   case vmIntrinsics::_compareAndExchangeObjectAcquire:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  Acquire);
   case vmIntrinsics::_compareAndExchangeObjectRelease:  return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange,  Release);
-  case vmIntrinsics::_compareAndExchangeByteVolatile:   return inline_unsafe_load_store(T_BYTE,   LS_cmp_exchange,  Volatile);
+  case vmIntrinsics::_compareAndExchangeByte:           return inline_unsafe_load_store(T_BYTE,   LS_cmp_exchange,  Volatile);
   case vmIntrinsics::_compareAndExchangeByteAcquire:    return inline_unsafe_load_store(T_BYTE,   LS_cmp_exchange,  Acquire);
   case vmIntrinsics::_compareAndExchangeByteRelease:    return inline_unsafe_load_store(T_BYTE,   LS_cmp_exchange,  Release);
-  case vmIntrinsics::_compareAndExchangeShortVolatile:  return inline_unsafe_load_store(T_SHORT,  LS_cmp_exchange,  Volatile);
+  case vmIntrinsics::_compareAndExchangeShort:          return inline_unsafe_load_store(T_SHORT,  LS_cmp_exchange,  Volatile);
   case vmIntrinsics::_compareAndExchangeShortAcquire:   return inline_unsafe_load_store(T_SHORT,  LS_cmp_exchange,  Acquire);
   case vmIntrinsics::_compareAndExchangeShortRelease:   return inline_unsafe_load_store(T_SHORT,  LS_cmp_exchange,  Release);
-  case vmIntrinsics::_compareAndExchangeIntVolatile:    return inline_unsafe_load_store(T_INT,    LS_cmp_exchange,  Volatile);
+  case vmIntrinsics::_compareAndExchangeInt:            return inline_unsafe_load_store(T_INT,    LS_cmp_exchange,  Volatile);
   case vmIntrinsics::_compareAndExchangeIntAcquire:     return inline_unsafe_load_store(T_INT,    LS_cmp_exchange,  Acquire);
   case vmIntrinsics::_compareAndExchangeIntRelease:     return inline_unsafe_load_store(T_INT,    LS_cmp_exchange,  Release);
-  case vmIntrinsics::_compareAndExchangeLongVolatile:   return inline_unsafe_load_store(T_LONG,   LS_cmp_exchange,  Volatile);
+  case vmIntrinsics::_compareAndExchangeLong:           return inline_unsafe_load_store(T_LONG,   LS_cmp_exchange,  Volatile);
   case vmIntrinsics::_compareAndExchangeLongAcquire:    return inline_unsafe_load_store(T_LONG,   LS_cmp_exchange,  Acquire);
   case vmIntrinsics::_compareAndExchangeLongRelease:    return inline_unsafe_load_store(T_LONG,   LS_cmp_exchange,  Release);
 
@@ -2587,23 +2587,26 @@
 //
 // LS_cmp_swap:
 //
-//   boolean compareAndSwapObject(Object o, long offset, Object expected, Object x);
-//   boolean compareAndSwapInt(   Object o, long offset, int    expected, int    x);
-//   boolean compareAndSwapLong(  Object o, long offset, long   expected, long   x);
+//   boolean compareAndSetObject(Object o, long offset, Object expected, Object x);
+//   boolean compareAndSetInt(   Object o, long offset, int    expected, int    x);
+//   boolean compareAndSetLong(  Object o, long offset, long   expected, long   x);
 //
 // LS_cmp_swap_weak:
 //
-//   boolean weakCompareAndSwapObject(       Object o, long offset, Object expected, Object x);
-//   boolean weakCompareAndSwapObjectAcquire(Object o, long offset, Object expected, Object x);
-//   boolean weakCompareAndSwapObjectRelease(Object o, long offset, Object expected, Object x);
+//   boolean weakCompareAndSetObject(       Object o, long offset, Object expected, Object x);
+//   boolean weakCompareAndSetObjectPlain(  Object o, long offset, Object expected, Object x);
+//   boolean weakCompareAndSetObjectAcquire(Object o, long offset, Object expected, Object x);
+//   boolean weakCompareAndSetObjectRelease(Object o, long offset, Object expected, Object x);
 //
-//   boolean weakCompareAndSwapInt(          Object o, long offset, int    expected, int    x);
-//   boolean weakCompareAndSwapIntAcquire(   Object o, long offset, int    expected, int    x);
-//   boolean weakCompareAndSwapIntRelease(   Object o, long offset, int    expected, int    x);
+//   boolean weakCompareAndSetInt(          Object o, long offset, int    expected, int    x);
+//   boolean weakCompareAndSetIntPlain(     Object o, long offset, int    expected, int    x);
+//   boolean weakCompareAndSetIntAcquire(   Object o, long offset, int    expected, int    x);
+//   boolean weakCompareAndSetIntRelease(   Object o, long offset, int    expected, int    x);
 //
-//   boolean weakCompareAndSwapLong(         Object o, long offset, long   expected, long   x);
-//   boolean weakCompareAndSwapLongAcquire(  Object o, long offset, long   expected, long   x);
-//   boolean weakCompareAndSwapLongRelease(  Object o, long offset, long   expected, long   x);
+//   boolean weakCompareAndSetLong(         Object o, long offset, long   expected, long   x);
+//   boolean weakCompareAndSetLongPlain(    Object o, long offset, long   expected, long   x);
+//   boolean weakCompareAndSetLongAcquire(  Object o, long offset, long   expected, long   x);
+//   boolean weakCompareAndSetLongRelease(  Object o, long offset, long   expected, long   x);
 //
 // LS_cmp_exchange:
 //
@@ -4965,7 +4968,7 @@
   // See arraycopy_restore_alloc_state() comment
   // if alloc == NULL we don't have to worry about a tightly coupled allocation so we can emit all needed guards
   // if saved_jvms != NULL (then alloc != NULL) then we can handle guards and a tightly coupled allocation
-  // if saved_jvms == NULL and alloc != NULL, we can’t emit any guards
+  // if saved_jvms == NULL and alloc != NULL, we can't emit any guards
   bool can_emit_guards = (alloc == NULL || saved_jvms != NULL);
 
   // The following tests must be performed
--- a/hotspot/src/share/vm/prims/jvm.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/prims/jvm.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
--- a/hotspot/src/share/vm/prims/unsafe.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/prims/unsafe.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -378,7 +378,7 @@
 // On platforms which do not support atomic compare-and-swap of jlong (8 byte)
 // values we have to use a lock-based scheme to enforce atomicity. This has to be
 // applied to all Unsafe operations that set the value of a jlong field. Even so
-// the compareAndSwapLong operation will not be atomic with respect to direct stores
+// the compareAndSetLong operation will not be atomic with respect to direct stores
 // to the field from Java code. It is important therefore that any Java code that
 // utilizes these Unsafe jlong operations does not perform direct stores. To permit
 // direct loads of the field from Java code we must also use Atomic::store within the
@@ -1013,7 +1013,7 @@
 #endif
 } UNSAFE_END
 
-UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject e_h, jobject x_h)) {
+UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject e_h, jobject x_h)) {
   oop x = JNIHandles::resolve(x_h);
   oop e = JNIHandles::resolve(e_h);
   oop p = JNIHandles::resolve(obj);
@@ -1028,14 +1028,14 @@
   return true;
 } UNSAFE_END
 
-UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint e, jint x)) {
+UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSetInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint e, jint x)) {
   oop p = JNIHandles::resolve(obj);
   jint* addr = (jint *)index_oop_from_field_offset_long(p, offset);
 
   return (jint)(Atomic::cmpxchg(x, addr, e)) == e;
 } UNSAFE_END
 
-UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong e, jlong x)) {
+UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSetLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong e, jlong x)) {
   Handle p(THREAD, JNIHandles::resolve(obj));
   jlong* addr = (jlong*)index_oop_from_field_offset_long(p(), offset);
 
@@ -1194,12 +1194,12 @@
     {CC "defineClass0",       CC "(" DC_Args ")" CLS,    FN_PTR(Unsafe_DefineClass0)},
     {CC "allocateInstance",   CC "(" CLS ")" OBJ,        FN_PTR(Unsafe_AllocateInstance)},
     {CC "throwException",     CC "(" THR ")V",           FN_PTR(Unsafe_ThrowException)},
-    {CC "compareAndSwapObject", CC "(" OBJ "J" OBJ "" OBJ ")Z", FN_PTR(Unsafe_CompareAndSwapObject)},
-    {CC "compareAndSwapInt",  CC "(" OBJ "J""I""I"")Z",  FN_PTR(Unsafe_CompareAndSwapInt)},
-    {CC "compareAndSwapLong", CC "(" OBJ "J""J""J"")Z",  FN_PTR(Unsafe_CompareAndSwapLong)},
-    {CC "compareAndExchangeObjectVolatile", CC "(" OBJ "J" OBJ "" OBJ ")" OBJ, FN_PTR(Unsafe_CompareAndExchangeObject)},
-    {CC "compareAndExchangeIntVolatile",  CC "(" OBJ "J""I""I"")I", FN_PTR(Unsafe_CompareAndExchangeInt)},
-    {CC "compareAndExchangeLongVolatile", CC "(" OBJ "J""J""J"")J", FN_PTR(Unsafe_CompareAndExchangeLong)},
+    {CC "compareAndSetObject",CC "(" OBJ "J" OBJ "" OBJ ")Z", FN_PTR(Unsafe_CompareAndSetObject)},
+    {CC "compareAndSetInt",   CC "(" OBJ "J""I""I"")Z",  FN_PTR(Unsafe_CompareAndSetInt)},
+    {CC "compareAndSetLong",  CC "(" OBJ "J""J""J"")Z",  FN_PTR(Unsafe_CompareAndSetLong)},
+    {CC "compareAndExchangeObject", CC "(" OBJ "J" OBJ "" OBJ ")" OBJ, FN_PTR(Unsafe_CompareAndExchangeObject)},
+    {CC "compareAndExchangeInt",  CC "(" OBJ "J""I""I"")I", FN_PTR(Unsafe_CompareAndExchangeInt)},
+    {CC "compareAndExchangeLong", CC "(" OBJ "J""J""J"")J", FN_PTR(Unsafe_CompareAndExchangeLong)},
 
     {CC "park",               CC "(ZJ)V",                FN_PTR(Unsafe_Park)},
     {CC "unpark",             CC "(" OBJ ")V",           FN_PTR(Unsafe_Unpark)},
--- a/hotspot/src/share/vm/runtime/arguments.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/runtime/arguments.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -376,53 +376,17 @@
   // --- Non-alias flags - sorted by obsolete_in then expired_in:
   { "MaxGCMinorPauseMillis",        JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
   { "UseConcMarkSweepGC",           JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
-  { "AutoGCSelectPauseMillis",      JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "UseAutoGCSelectPolicy",        JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "UseParNewGC",                  JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "ExplicitGCInvokesConcurrentAndUnloadsClasses", JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "ConvertSleepToYield",          JDK_Version::jdk(9), JDK_Version::jdk(10),     JDK_Version::jdk(11) },
-  { "ConvertYieldToSleep",          JDK_Version::jdk(9), JDK_Version::jdk(10),     JDK_Version::jdk(11) },
 
   // --- Deprecated alias flags (see also aliased_jvm_flags) - sorted by obsolete_in then expired_in:
   { "DefaultMaxRAMFraction",        JDK_Version::jdk(8), JDK_Version::undefined(), JDK_Version::undefined() },
   { "CreateMinidumpOnCrash",        JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::undefined() },
-  { "CMSMarkStackSizeMax",          JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "CMSMarkStackSize",             JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "G1MarkStackSize",              JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "ParallelMarkingThreads",       JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
-  { "ParallelCMSThreads",           JDK_Version::jdk(9), JDK_Version::undefined(), JDK_Version::jdk(10) },
 
   // -------------- Obsolete Flags - sorted by expired_in --------------
-  { "UseOldInlining",                JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "SafepointPollOffset",           JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "UseBoundThreads",               JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "DefaultThreadPriority",         JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "NoYieldsInMicrolock",           JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "BackEdgeThreshold",             JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "UseNewReflection",              JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "ReflectionWrapResolutionErrors",JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "VerifyReflectionBytecodes",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "AutoShutdownNMT",               JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "NmethodSweepFraction",          JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "NmethodSweepCheckInterval",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "CodeCacheMinimumFreeSpace",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-#ifndef ZERO
-  { "UseFastAccessorMethods",        JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "UseFastEmptyMethods",           JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-#endif // ZERO
-  { "UseCompilerSafepoints",         JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "AdaptiveSizePausePolicy",       JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "ParallelGCRetainPLAB",          JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "ThreadSafetyMargin",            JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "LazyBootClassLoader",           JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "StarvationMonitorInterval",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "PreInflateSpin",                JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "JNIDetachReleasesMonitors",     JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "UseAltSigs",                    JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "SegmentedHeapDumpThreshold",    JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "PrintOopAddress",               JDK_Version::undefined(), JDK_Version::jdk(9), JDK_Version::jdk(10) },
-  { "PermSize",                      JDK_Version::undefined(), JDK_Version::jdk(8), JDK_Version::jdk(10) },
-  { "MaxPermSize",                   JDK_Version::undefined(), JDK_Version::jdk(8), JDK_Version::jdk(10) },
+  { "ConvertSleepToYield",           JDK_Version::jdk(9),      JDK_Version::jdk(10), JDK_Version::jdk(11) },
+  { "ConvertYieldToSleep",           JDK_Version::jdk(9),      JDK_Version::jdk(10), JDK_Version::jdk(11) },
+  { "MinSleepInterval",              JDK_Version::jdk(9),      JDK_Version::jdk(10), JDK_Version::jdk(11) },
+  { "PermSize",                      JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
+  { "MaxPermSize",                   JDK_Version::undefined(), JDK_Version::jdk(8),  JDK_Version::undefined() },
 
 #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS
   { "dep > obs",                    JDK_Version::jdk(9), JDK_Version::jdk(8), JDK_Version::undefined() },
@@ -445,11 +409,6 @@
 
 static AliasedFlag const aliased_jvm_flags[] = {
   { "DefaultMaxRAMFraction",    "MaxRAMFraction"    },
-  { "CMSMarkStackSizeMax",      "MarkStackSizeMax"  },
-  { "CMSMarkStackSize",         "MarkStackSize"     },
-  { "G1MarkStackSize",          "MarkStackSize"     },
-  { "ParallelMarkingThreads",   "ConcGCThreads"     },
-  { "ParallelCMSThreads",       "ConcGCThreads"     },
   { "CreateMinidumpOnCrash",    "CreateCoredumpOnCrash" },
   { NULL, NULL}
 };
@@ -1548,7 +1507,6 @@
   assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC && !UseG1GC,
          "control point invariant");
   assert(UseConcMarkSweepGC, "CMS is expected to be on here");
-  assert(UseParNewGC, "ParNew should always be used with CMS");
 
   if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
     FLAG_SET_DEFAULT(ParallelGCThreads, Abstract_VM_Version::parallel_worker_threads());
@@ -1589,7 +1547,6 @@
 void Arguments::set_cms_and_parnew_gc_flags() {
   assert(!UseSerialGC && !UseParallelOldGC && !UseParallelGC, "Error");
   assert(UseConcMarkSweepGC, "CMS is expected to be on here");
-  assert(UseParNewGC, "ParNew should always be used with CMS");
 
   // Turn off AdaptiveSizePolicy by default for cms until it is complete.
   disable_adaptive_size_policy("UseConcMarkSweepGC");
@@ -1729,16 +1686,6 @@
   NOT_LP64(ShouldNotReachHere(); return 0);
 }
 
-bool Arguments::should_auto_select_low_pause_collector() {
-  if (UseAutoGCSelectPolicy &&
-      !FLAG_IS_DEFAULT(MaxGCPauseMillis) &&
-      (MaxGCPauseMillis <= AutoGCSelectPauseMillis)) {
-    log_trace(gc)("Automatic selection of the low pause collector based on pause goal of %d (ms)", (int) MaxGCPauseMillis);
-    return true;
-  }
-  return false;
-}
-
 void Arguments::set_use_compressed_oops() {
 #ifndef ZERO
 #ifdef _LP64
@@ -1842,16 +1789,7 @@
 void Arguments::select_gc_ergonomically() {
 #if INCLUDE_ALL_GCS
   if (os::is_server_class_machine()) {
-    if (!UseAutoGCSelectPolicy) {
-       FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
-    } else {
-      if (should_auto_select_low_pause_collector()) {
-        FLAG_SET_ERGO_IF_DEFAULT(bool, UseConcMarkSweepGC, true);
-        FLAG_SET_ERGO_IF_DEFAULT(bool, UseParNewGC, true);
-      } else {
-        FLAG_SET_ERGO_IF_DEFAULT(bool, UseParallelGC, true);
-      }
-    }
+    FLAG_SET_ERGO_IF_DEFAULT(bool, UseG1GC, true);
   } else {
     FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
   }
@@ -1860,7 +1798,6 @@
   UNSUPPORTED_OPTION(UseParallelGC);
   UNSUPPORTED_OPTION(UseParallelOldGC);
   UNSUPPORTED_OPTION(UseConcMarkSweepGC);
-  UNSUPPORTED_OPTION(UseParNewGC);
   FLAG_SET_ERGO_IF_DEFAULT(bool, UseSerialGC, true);
 #endif // INCLUDE_ALL_GCS
 }
@@ -2079,7 +2016,6 @@
   if (!ClassUnloading) {
     FLAG_SET_CMDLINE(bool, CMSClassUnloadingEnabled, false);
     FLAG_SET_CMDLINE(bool, ClassUnloadingWithConcurrentMark, false);
-    FLAG_SET_CMDLINE(bool, ExplicitGCInvokesConcurrentAndUnloadsClasses, false);
   }
 #endif // INCLUDE_ALL_GCS
 }
@@ -2432,18 +2368,6 @@
     return false;
   }
 
-  if (UseConcMarkSweepGC && !UseParNewGC) {
-    jio_fprintf(defaultStream::error_stream(),
-        "It is not possible to combine the DefNew young collector with the CMS collector.\n");
-    return false;
-  }
-
-  if (UseParNewGC && !UseConcMarkSweepGC) {
-    jio_fprintf(defaultStream::error_stream(),
-        "It is not possible to combine the ParNew young collector with any collector other than CMS.\n");
-    return false;
-  }
-
   return true;
 }
 
@@ -3741,11 +3665,6 @@
     }
   }
 
-  if (UseConcMarkSweepGC && FLAG_IS_DEFAULT(UseParNewGC) && !UseParNewGC) {
-    // CMS can only be used with ParNew
-    FLAG_SET_ERGO(bool, UseParNewGC, true);
-  }
-
   if (!check_vm_args_consistency()) {
     return JNI_ERR;
   }
--- a/hotspot/src/share/vm/runtime/arguments.hpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/runtime/arguments.hpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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();
--- a/hotspot/src/share/vm/runtime/globals.hpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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")                \
                                                                             \
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -199,6 +199,7 @@
 typedef HashtableEntry<Klass*, mtClass>       KlassHashtableEntry;
 typedef TwoOopHashtable<Symbol*, mtClass>     SymbolTwoOopHashtable;
 typedef CompactHashtable<Symbol*, char>       SymbolCompactHashTable;
+typedef RehashableHashtable<Symbol*, mtSymbol>   RehashableSymbolHashtable;
 
 //--------------------------------------------------------------------------------
 // VM_STRUCTS
@@ -584,6 +585,7 @@
                                                                                                                                      \
      static_field(SymbolTable,                 _the_table,                                    SymbolTable*)                          \
      static_field(SymbolTable,                 _shared_table,                                 SymbolCompactHashTable)                \
+     static_field(RehashableSymbolHashtable,   _seed,                                         juint)                                 \
                                                                                                                                      \
   /***************/                                                                                                                  \
   /* StringTable */                                                                                                                  \
@@ -969,6 +971,7 @@
   nonstatic_field(JavaThread,                  _vframe_array_last,                            vframeArray*)                          \
   nonstatic_field(JavaThread,                  _satb_mark_queue,                              SATBMarkQueue)                         \
   nonstatic_field(JavaThread,                  _dirty_card_queue,                             DirtyCardQueue)                        \
+  volatile_nonstatic_field(JavaThread,         _terminated,                                   JavaThread::TerminatedTypes)           \
   nonstatic_field(Thread,                      _resource_area,                                ResourceArea*)                         \
   nonstatic_field(CompilerThread,              _env,                                          ciEnv*)                                \
                                                                                                                                      \
@@ -1602,6 +1605,8 @@
                                                                           \
   declare_toplevel_type(BasicHashtable<mtInternal>)                       \
     declare_type(IntptrHashtable, BasicHashtable<mtInternal>)             \
+  declare_toplevel_type(BasicHashtable<mtSymbol>)                         \
+    declare_type(RehashableSymbolHashtable, BasicHashtable<mtSymbol>)     \
   declare_type(SymbolTable, SymbolHashtable)                              \
   declare_type(StringTable, StringHashtable)                              \
     declare_type(LoaderConstraintTable, KlassHashtable)                   \
@@ -2209,6 +2214,7 @@
   declare_toplevel_type(JavaThread*)                                      \
   declare_toplevel_type(java_lang_Class)                                  \
   declare_integer_type(JavaThread::AsyncRequests)                         \
+  declare_integer_type(JavaThread::TerminatedTypes)                       \
   declare_toplevel_type(jbyte*)                                           \
   declare_toplevel_type(jbyte**)                                          \
   declare_toplevel_type(jint*)                                            \
@@ -2431,6 +2437,8 @@
   declare_constant(_thread_in_Java_trans)                                 \
   declare_constant(_thread_blocked)                                       \
   declare_constant(_thread_blocked_trans)                                 \
+  declare_constant(JavaThread::_not_terminated)                           \
+  declare_constant(JavaThread::_thread_exiting)                           \
                                                                           \
   /******************************/                                        \
   /* Klass misc. enum constants */                                        \
--- a/hotspot/src/share/vm/shark/sharkIntrinsics.cpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/shark/sharkIntrinsics.cpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2009 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -66,7 +66,7 @@
     return true;
 
     // Unsafe
-  case vmIntrinsics::_compareAndSwapInt:
+  case vmIntrinsics::_compareAndSetInt:
     return true;
 
   default:
@@ -140,8 +140,8 @@
     break;
 
     // Unsafe
-  case vmIntrinsics::_compareAndSwapInt:
-    do_Unsafe_compareAndSwapInt();
+  case vmIntrinsics::_compareAndSetInt:
+    do_Unsafe_compareAndSetInt();
     break;
 
   default:
@@ -241,7 +241,7 @@
       true));
 }
 
-void SharkIntrinsics::do_Unsafe_compareAndSwapInt() {
+void SharkIntrinsics::do_Unsafe_compareAndSetInt() {
   // Pop the arguments
   Value *x      = state()->pop()->jint_value();
   Value *e      = state()->pop()->jint_value();
--- a/hotspot/src/share/vm/shark/sharkIntrinsics.hpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/shark/sharkIntrinsics.hpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2009 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -58,7 +58,7 @@
   void do_Object_getClass();
   void do_System_currentTimeMillis();
   void do_Thread_currentThread();
-  void do_Unsafe_compareAndSwapInt();
+  void do_Unsafe_compareAndSetInt();
 };
 
 #endif // SHARE_VM_SHARK_SHARKINTRINSICS_HPP
--- a/hotspot/src/share/vm/utilities/hashtable.hpp	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/src/share/vm/utilities/hashtable.hpp	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -312,6 +312,7 @@
 };
 
 template <class T, MEMFLAGS F> class RehashableHashtable : public Hashtable<T, F> {
+ friend class VMStructs;
  protected:
 
   enum {
--- a/hotspot/test/TEST.groups	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/TEST.groups	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -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
--- a/hotspot/test/compiler/c2/cr7200264/TestDriver.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/c2/cr7200264/TestDriver.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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",
--- a/hotspot/test/compiler/compilercontrol/share/scenario/Executor.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/compilercontrol/share/scenario/Executor.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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);
         }
--- a/hotspot/test/compiler/intrinsics/unsafe/TestCAEAntiDep.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/intrinsics/unsafe/TestCAEAntiDep.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,4 +1,5 @@
 /*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2016, Red Hat, Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -53,7 +54,7 @@
     }
 
     static int m(TestCAEAntiDep test, Object expected, Object x) {
-        C old = (C)UNSAFE.compareAndExchangeObjectVolatile(test, O_OFFSET, expected, x);
+        C old = (C)UNSAFE.compareAndExchangeObject(test, O_OFFSET, expected, x);
         int res = old.f1;
         old.f1 = 0x42;
         return res;
--- a/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/intrinsics/unsafe/UnsafeTwoCASLong.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,9 +72,8 @@
     }
 
     static void testAccess(Object base, long offset) {
-        UNSAFE.compareAndSwapLong(base, offset, 1L, 2L);
-        UNSAFE.compareAndSwapLong(base, offset, 2L, 1L);
+        UNSAFE.compareAndSetLong(base, offset, 1L, 2L);
+        UNSAFE.compareAndSetLong(base, offset, 2L, 1L);
     }
 
 }
-
--- a/hotspot/test/compiler/jsr292/patches/java.base/java/lang/invoke/MethodHandleHelper.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/jsr292/patches/java.base/java/lang/invoke/MethodHandleHelper.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
         }
--- a/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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) {
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -151,32 +151,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapBoolean(base, offset, true, false);
-            assertEquals(r, true, "success compareAndSwap boolean");
+            boolean r = UNSAFE.compareAndSetBoolean(base, offset, true, false);
+            assertEquals(r, true, "success compareAndSet boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, false, "success compareAndSwap boolean value");
+            assertEquals(x, false, "success compareAndSet boolean value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapBoolean(base, offset, true, false);
-            assertEquals(r, false, "failing compareAndSwap boolean");
+            boolean r = UNSAFE.compareAndSetBoolean(base, offset, true, false);
+            assertEquals(r, false, "failing compareAndSet boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, false, "failing compareAndSwap boolean value");
+            assertEquals(x, false, "failing compareAndSet boolean value");
         }
 
         // Advanced compare
         {
-            boolean r = UNSAFE.compareAndExchangeBooleanVolatile(base, offset, false, true);
-            assertEquals(r, false, "success compareAndExchangeVolatile boolean");
+            boolean r = UNSAFE.compareAndExchangeBoolean(base, offset, false, true);
+            assertEquals(r, false, "success compareAndExchange boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, true, "success compareAndExchangeVolatile boolean value");
+            assertEquals(x, true, "success compareAndExchange boolean value");
         }
 
         {
-            boolean r = UNSAFE.compareAndExchangeBooleanVolatile(base, offset, false, false);
-            assertEquals(r, true, "failing compareAndExchangeVolatile boolean");
+            boolean r = UNSAFE.compareAndExchangeBoolean(base, offset, false, false);
+            assertEquals(r, true, "failing compareAndExchange boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, true, "failing compareAndExchangeVolatile boolean value");
+            assertEquals(x, true, "failing compareAndExchange boolean value");
         }
 
         {
@@ -210,41 +210,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapBoolean(base, offset, true, false);
+                success = UNSAFE.weakCompareAndSetBooleanPlain(base, offset, true, false);
             }
-            assertEquals(success, true, "weakCompareAndSwap boolean");
+            assertEquals(success, true, "weakCompareAndSetPlain boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, false, "weakCompareAndSwap boolean value");
+            assertEquals(x, false, "weakCompareAndSetPlain boolean value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapBooleanAcquire(base, offset, false, true);
+                success = UNSAFE.weakCompareAndSetBooleanAcquire(base, offset, false, true);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire boolean");
+            assertEquals(success, true, "weakCompareAndSetAcquire boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, true, "weakCompareAndSwapAcquire boolean");
+            assertEquals(x, true, "weakCompareAndSetAcquire boolean");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapBooleanRelease(base, offset, true, false);
+                success = UNSAFE.weakCompareAndSetBooleanRelease(base, offset, true, false);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease boolean");
+            assertEquals(success, true, "weakCompareAndSetRelease boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, false, "weakCompareAndSwapRelease boolean");
+            assertEquals(x, false, "weakCompareAndSetRelease boolean");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapBooleanVolatile(base, offset, false, true);
+                success = UNSAFE.weakCompareAndSetBoolean(base, offset, false, true);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile boolean");
+            assertEquals(success, true, "weakCompareAndSet boolean");
             boolean x = UNSAFE.getBoolean(base, offset);
-            assertEquals(x, true, "weakCompareAndSwapVolatile boolean");
+            assertEquals(x, true, "weakCompareAndSet boolean");
         }
 
         UNSAFE.putBoolean(base, offset, false);
@@ -260,4 +260,3 @@
     }
 
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -180,32 +180,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapByte(base, offset, (byte)0x01, (byte)0x23);
-            assertEquals(r, true, "success compareAndSwap byte");
+            boolean r = UNSAFE.compareAndSetByte(base, offset, (byte)0x01, (byte)0x23);
+            assertEquals(r, true, "success compareAndSet byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x23, "success compareAndSwap byte value");
+            assertEquals(x, (byte)0x23, "success compareAndSet byte value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapByte(base, offset, (byte)0x01, (byte)0x45);
-            assertEquals(r, false, "failing compareAndSwap byte");
+            boolean r = UNSAFE.compareAndSetByte(base, offset, (byte)0x01, (byte)0x45);
+            assertEquals(r, false, "failing compareAndSet byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x23, "failing compareAndSwap byte value");
+            assertEquals(x, (byte)0x23, "failing compareAndSet byte value");
         }
 
         // Advanced compare
         {
-            byte r = UNSAFE.compareAndExchangeByteVolatile(base, offset, (byte)0x23, (byte)0x01);
-            assertEquals(r, (byte)0x23, "success compareAndExchangeVolatile byte");
+            byte r = UNSAFE.compareAndExchangeByte(base, offset, (byte)0x23, (byte)0x01);
+            assertEquals(r, (byte)0x23, "success compareAndExchange byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x01, "success compareAndExchangeVolatile byte value");
+            assertEquals(x, (byte)0x01, "success compareAndExchange byte value");
         }
 
         {
-            byte r = UNSAFE.compareAndExchangeByteVolatile(base, offset, (byte)0x23, (byte)0x45);
-            assertEquals(r, (byte)0x01, "failing compareAndExchangeVolatile byte");
+            byte r = UNSAFE.compareAndExchangeByte(base, offset, (byte)0x23, (byte)0x45);
+            assertEquals(r, (byte)0x01, "failing compareAndExchange byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x01, "failing compareAndExchangeVolatile byte value");
+            assertEquals(x, (byte)0x01, "failing compareAndExchange byte value");
         }
 
         {
@@ -239,41 +239,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapByte(base, offset, (byte)0x01, (byte)0x23);
+                success = UNSAFE.weakCompareAndSetBytePlain(base, offset, (byte)0x01, (byte)0x23);
             }
-            assertEquals(success, true, "weakCompareAndSwap byte");
+            assertEquals(success, true, "weakCompareAndSetPlain byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x23, "weakCompareAndSwap byte value");
+            assertEquals(x, (byte)0x23, "weakCompareAndSetPlain byte value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapByteAcquire(base, offset, (byte)0x23, (byte)0x01);
+                success = UNSAFE.weakCompareAndSetByteAcquire(base, offset, (byte)0x23, (byte)0x01);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire byte");
+            assertEquals(success, true, "weakCompareAndSetAcquire byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x01, "weakCompareAndSwapAcquire byte");
+            assertEquals(x, (byte)0x01, "weakCompareAndSetAcquire byte");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapByteRelease(base, offset, (byte)0x01, (byte)0x23);
+                success = UNSAFE.weakCompareAndSetByteRelease(base, offset, (byte)0x01, (byte)0x23);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease byte");
+            assertEquals(success, true, "weakCompareAndSetRelease byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x23, "weakCompareAndSwapRelease byte");
+            assertEquals(x, (byte)0x23, "weakCompareAndSetRelease byte");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapByteVolatile(base, offset, (byte)0x23, (byte)0x01);
+                success = UNSAFE.weakCompareAndSetByte(base, offset, (byte)0x23, (byte)0x01);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile byte");
+            assertEquals(success, true, "weakCompareAndSet byte");
             byte x = UNSAFE.getByte(base, offset);
-            assertEquals(x, (byte)0x01, "weakCompareAndSwapVolatile byte");
+            assertEquals(x, (byte)0x01, "weakCompareAndSet byte");
         }
 
         UNSAFE.putByte(base, offset, (byte)0x23);
@@ -306,4 +306,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -198,32 +198,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapChar(base, offset, '\u0123', '\u4567');
-            assertEquals(r, true, "success compareAndSwap char");
+            boolean r = UNSAFE.compareAndSetChar(base, offset, '\u0123', '\u4567');
+            assertEquals(r, true, "success compareAndSet char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u4567', "success compareAndSwap char value");
+            assertEquals(x, '\u4567', "success compareAndSet char value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapChar(base, offset, '\u0123', '\u89AB');
-            assertEquals(r, false, "failing compareAndSwap char");
+            boolean r = UNSAFE.compareAndSetChar(base, offset, '\u0123', '\u89AB');
+            assertEquals(r, false, "failing compareAndSet char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u4567', "failing compareAndSwap char value");
+            assertEquals(x, '\u4567', "failing compareAndSet char value");
         }
 
         // Advanced compare
         {
-            char r = UNSAFE.compareAndExchangeCharVolatile(base, offset, '\u4567', '\u0123');
-            assertEquals(r, '\u4567', "success compareAndExchangeVolatile char");
+            char r = UNSAFE.compareAndExchangeChar(base, offset, '\u4567', '\u0123');
+            assertEquals(r, '\u4567', "success compareAndExchange char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u0123', "success compareAndExchangeVolatile char value");
+            assertEquals(x, '\u0123', "success compareAndExchange char value");
         }
 
         {
-            char r = UNSAFE.compareAndExchangeCharVolatile(base, offset, '\u4567', '\u89AB');
-            assertEquals(r, '\u0123', "failing compareAndExchangeVolatile char");
+            char r = UNSAFE.compareAndExchangeChar(base, offset, '\u4567', '\u89AB');
+            assertEquals(r, '\u0123', "failing compareAndExchange char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u0123', "failing compareAndExchangeVolatile char value");
+            assertEquals(x, '\u0123', "failing compareAndExchange char value");
         }
 
         {
@@ -257,41 +257,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapChar(base, offset, '\u0123', '\u4567');
+                success = UNSAFE.weakCompareAndSetCharPlain(base, offset, '\u0123', '\u4567');
             }
-            assertEquals(success, true, "weakCompareAndSwap char");
+            assertEquals(success, true, "weakCompareAndSetPlain char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u4567', "weakCompareAndSwap char value");
+            assertEquals(x, '\u4567', "weakCompareAndSetPlain char value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapCharAcquire(base, offset, '\u4567', '\u0123');
+                success = UNSAFE.weakCompareAndSetCharAcquire(base, offset, '\u4567', '\u0123');
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire char");
+            assertEquals(success, true, "weakCompareAndSetAcquire char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u0123', "weakCompareAndSwapAcquire char");
+            assertEquals(x, '\u0123', "weakCompareAndSetAcquire char");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapCharRelease(base, offset, '\u0123', '\u4567');
+                success = UNSAFE.weakCompareAndSetCharRelease(base, offset, '\u0123', '\u4567');
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease char");
+            assertEquals(success, true, "weakCompareAndSetRelease char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u4567', "weakCompareAndSwapRelease char");
+            assertEquals(x, '\u4567', "weakCompareAndSetRelease char");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapCharVolatile(base, offset, '\u4567', '\u0123');
+                success = UNSAFE.weakCompareAndSetChar(base, offset, '\u4567', '\u0123');
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile char");
+            assertEquals(success, true, "weakCompareAndSet char");
             char x = UNSAFE.getChar(base, offset);
-            assertEquals(x, '\u0123', "weakCompareAndSwapVolatile char");
+            assertEquals(x, '\u0123', "weakCompareAndSet char");
         }
 
         UNSAFE.putChar(base, offset, '\u4567');
@@ -324,4 +324,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -180,32 +180,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapDouble(base, offset, 1.0d, 2.0d);
-            assertEquals(r, true, "success compareAndSwap double");
+            boolean r = UNSAFE.compareAndSetDouble(base, offset, 1.0d, 2.0d);
+            assertEquals(r, true, "success compareAndSet double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 2.0d, "success compareAndSwap double value");
+            assertEquals(x, 2.0d, "success compareAndSet double value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapDouble(base, offset, 1.0d, 3.0d);
-            assertEquals(r, false, "failing compareAndSwap double");
+            boolean r = UNSAFE.compareAndSetDouble(base, offset, 1.0d, 3.0d);
+            assertEquals(r, false, "failing compareAndSet double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 2.0d, "failing compareAndSwap double value");
+            assertEquals(x, 2.0d, "failing compareAndSet double value");
         }
 
         // Advanced compare
         {
-            double r = UNSAFE.compareAndExchangeDoubleVolatile(base, offset, 2.0d, 1.0d);
-            assertEquals(r, 2.0d, "success compareAndExchangeVolatile double");
+            double r = UNSAFE.compareAndExchangeDouble(base, offset, 2.0d, 1.0d);
+            assertEquals(r, 2.0d, "success compareAndExchange double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 1.0d, "success compareAndExchangeVolatile double value");
+            assertEquals(x, 1.0d, "success compareAndExchange double value");
         }
 
         {
-            double r = UNSAFE.compareAndExchangeDoubleVolatile(base, offset, 2.0d, 3.0d);
-            assertEquals(r, 1.0d, "failing compareAndExchangeVolatile double");
+            double r = UNSAFE.compareAndExchangeDouble(base, offset, 2.0d, 3.0d);
+            assertEquals(r, 1.0d, "failing compareAndExchange double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 1.0d, "failing compareAndExchangeVolatile double value");
+            assertEquals(x, 1.0d, "failing compareAndExchange double value");
         }
 
         {
@@ -239,41 +239,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapDouble(base, offset, 1.0d, 2.0d);
+                success = UNSAFE.weakCompareAndSetDoublePlain(base, offset, 1.0d, 2.0d);
             }
-            assertEquals(success, true, "weakCompareAndSwap double");
+            assertEquals(success, true, "weakCompareAndSetPlain double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 2.0d, "weakCompareAndSwap double value");
+            assertEquals(x, 2.0d, "weakCompareAndSetPlain double value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapDoubleAcquire(base, offset, 2.0d, 1.0d);
+                success = UNSAFE.weakCompareAndSetDoubleAcquire(base, offset, 2.0d, 1.0d);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire double");
+            assertEquals(success, true, "weakCompareAndSetAcquire double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 1.0d, "weakCompareAndSwapAcquire double");
+            assertEquals(x, 1.0d, "weakCompareAndSetAcquire double");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapDoubleRelease(base, offset, 1.0d, 2.0d);
+                success = UNSAFE.weakCompareAndSetDoubleRelease(base, offset, 1.0d, 2.0d);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease double");
+            assertEquals(success, true, "weakCompareAndSetRelease double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 2.0d, "weakCompareAndSwapRelease double");
+            assertEquals(x, 2.0d, "weakCompareAndSetRelease double");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapDoubleVolatile(base, offset, 2.0d, 1.0d);
+                success = UNSAFE.weakCompareAndSetDouble(base, offset, 2.0d, 1.0d);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile double");
+            assertEquals(success, true, "weakCompareAndSet double");
             double x = UNSAFE.getDouble(base, offset);
-            assertEquals(x, 1.0d, "weakCompareAndSwapVolatile double");
+            assertEquals(x, 1.0d, "weakCompareAndSet double");
         }
 
         UNSAFE.putDouble(base, offset, 2.0d);
@@ -306,4 +306,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -180,32 +180,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapFloat(base, offset, 1.0f, 2.0f);
-            assertEquals(r, true, "success compareAndSwap float");
+            boolean r = UNSAFE.compareAndSetFloat(base, offset, 1.0f, 2.0f);
+            assertEquals(r, true, "success compareAndSet float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 2.0f, "success compareAndSwap float value");
+            assertEquals(x, 2.0f, "success compareAndSet float value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapFloat(base, offset, 1.0f, 3.0f);
-            assertEquals(r, false, "failing compareAndSwap float");
+            boolean r = UNSAFE.compareAndSetFloat(base, offset, 1.0f, 3.0f);
+            assertEquals(r, false, "failing compareAndSet float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 2.0f, "failing compareAndSwap float value");
+            assertEquals(x, 2.0f, "failing compareAndSet float value");
         }
 
         // Advanced compare
         {
-            float r = UNSAFE.compareAndExchangeFloatVolatile(base, offset, 2.0f, 1.0f);
-            assertEquals(r, 2.0f, "success compareAndExchangeVolatile float");
+            float r = UNSAFE.compareAndExchangeFloat(base, offset, 2.0f, 1.0f);
+            assertEquals(r, 2.0f, "success compareAndExchange float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 1.0f, "success compareAndExchangeVolatile float value");
+            assertEquals(x, 1.0f, "success compareAndExchange float value");
         }
 
         {
-            float r = UNSAFE.compareAndExchangeFloatVolatile(base, offset, 2.0f, 3.0f);
-            assertEquals(r, 1.0f, "failing compareAndExchangeVolatile float");
+            float r = UNSAFE.compareAndExchangeFloat(base, offset, 2.0f, 3.0f);
+            assertEquals(r, 1.0f, "failing compareAndExchange float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 1.0f, "failing compareAndExchangeVolatile float value");
+            assertEquals(x, 1.0f, "failing compareAndExchange float value");
         }
 
         {
@@ -239,41 +239,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapFloat(base, offset, 1.0f, 2.0f);
+                success = UNSAFE.weakCompareAndSetFloatPlain(base, offset, 1.0f, 2.0f);
             }
-            assertEquals(success, true, "weakCompareAndSwap float");
+            assertEquals(success, true, "weakCompareAndSetPlain float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 2.0f, "weakCompareAndSwap float value");
+            assertEquals(x, 2.0f, "weakCompareAndSetPlain float value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapFloatAcquire(base, offset, 2.0f, 1.0f);
+                success = UNSAFE.weakCompareAndSetFloatAcquire(base, offset, 2.0f, 1.0f);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire float");
+            assertEquals(success, true, "weakCompareAndSetAcquire float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 1.0f, "weakCompareAndSwapAcquire float");
+            assertEquals(x, 1.0f, "weakCompareAndSetAcquire float");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapFloatRelease(base, offset, 1.0f, 2.0f);
+                success = UNSAFE.weakCompareAndSetFloatRelease(base, offset, 1.0f, 2.0f);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease float");
+            assertEquals(success, true, "weakCompareAndSetRelease float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 2.0f, "weakCompareAndSwapRelease float");
+            assertEquals(x, 2.0f, "weakCompareAndSetRelease float");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapFloatVolatile(base, offset, 2.0f, 1.0f);
+                success = UNSAFE.weakCompareAndSetFloat(base, offset, 2.0f, 1.0f);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile float");
+            assertEquals(success, true, "weakCompareAndSet float");
             float x = UNSAFE.getFloat(base, offset);
-            assertEquals(x, 1.0f, "weakCompareAndSwapVolatile float");
+            assertEquals(x, 1.0f, "weakCompareAndSet float");
         }
 
         UNSAFE.putFloat(base, offset, 2.0f);
@@ -306,4 +306,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -198,32 +198,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapInt(base, offset, 0x01234567, 0x89ABCDEF);
-            assertEquals(r, true, "success compareAndSwap int");
+            boolean r = UNSAFE.compareAndSetInt(base, offset, 0x01234567, 0x89ABCDEF);
+            assertEquals(r, true, "success compareAndSet int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x89ABCDEF, "success compareAndSwap int value");
+            assertEquals(x, 0x89ABCDEF, "success compareAndSet int value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapInt(base, offset, 0x01234567, 0xCAFEBABE);
-            assertEquals(r, false, "failing compareAndSwap int");
+            boolean r = UNSAFE.compareAndSetInt(base, offset, 0x01234567, 0xCAFEBABE);
+            assertEquals(r, false, "failing compareAndSet int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x89ABCDEF, "failing compareAndSwap int value");
+            assertEquals(x, 0x89ABCDEF, "failing compareAndSet int value");
         }
 
         // Advanced compare
         {
-            int r = UNSAFE.compareAndExchangeIntVolatile(base, offset, 0x89ABCDEF, 0x01234567);
-            assertEquals(r, 0x89ABCDEF, "success compareAndExchangeVolatile int");
+            int r = UNSAFE.compareAndExchangeInt(base, offset, 0x89ABCDEF, 0x01234567);
+            assertEquals(r, 0x89ABCDEF, "success compareAndExchange int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x01234567, "success compareAndExchangeVolatile int value");
+            assertEquals(x, 0x01234567, "success compareAndExchange int value");
         }
 
         {
-            int r = UNSAFE.compareAndExchangeIntVolatile(base, offset, 0x89ABCDEF, 0xCAFEBABE);
-            assertEquals(r, 0x01234567, "failing compareAndExchangeVolatile int");
+            int r = UNSAFE.compareAndExchangeInt(base, offset, 0x89ABCDEF, 0xCAFEBABE);
+            assertEquals(r, 0x01234567, "failing compareAndExchange int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x01234567, "failing compareAndExchangeVolatile int value");
+            assertEquals(x, 0x01234567, "failing compareAndExchange int value");
         }
 
         {
@@ -257,41 +257,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapInt(base, offset, 0x01234567, 0x89ABCDEF);
+                success = UNSAFE.weakCompareAndSetIntPlain(base, offset, 0x01234567, 0x89ABCDEF);
             }
-            assertEquals(success, true, "weakCompareAndSwap int");
+            assertEquals(success, true, "weakCompareAndSetPlain int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x89ABCDEF, "weakCompareAndSwap int value");
+            assertEquals(x, 0x89ABCDEF, "weakCompareAndSetPlain int value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapIntAcquire(base, offset, 0x89ABCDEF, 0x01234567);
+                success = UNSAFE.weakCompareAndSetIntAcquire(base, offset, 0x89ABCDEF, 0x01234567);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire int");
+            assertEquals(success, true, "weakCompareAndSetAcquire int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x01234567, "weakCompareAndSwapAcquire int");
+            assertEquals(x, 0x01234567, "weakCompareAndSetAcquire int");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapIntRelease(base, offset, 0x01234567, 0x89ABCDEF);
+                success = UNSAFE.weakCompareAndSetIntRelease(base, offset, 0x01234567, 0x89ABCDEF);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease int");
+            assertEquals(success, true, "weakCompareAndSetRelease int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x89ABCDEF, "weakCompareAndSwapRelease int");
+            assertEquals(x, 0x89ABCDEF, "weakCompareAndSetRelease int");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapIntVolatile(base, offset, 0x89ABCDEF, 0x01234567);
+                success = UNSAFE.weakCompareAndSetInt(base, offset, 0x89ABCDEF, 0x01234567);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile int");
+            assertEquals(success, true, "weakCompareAndSet int");
             int x = UNSAFE.getInt(base, offset);
-            assertEquals(x, 0x01234567, "weakCompareAndSwapVolatile int");
+            assertEquals(x, 0x01234567, "weakCompareAndSet int");
         }
 
         UNSAFE.putInt(base, offset, 0x89ABCDEF);
@@ -324,4 +324,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -198,32 +198,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
-            assertEquals(r, true, "success compareAndSwap long");
+            boolean r = UNSAFE.compareAndSetLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
+            assertEquals(r, true, "success compareAndSet long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSwap long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "success compareAndSet long value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
-            assertEquals(r, false, "failing compareAndSwap long");
+            boolean r = UNSAFE.compareAndSetLong(base, offset, 0x0123456789ABCDEFL, 0xDEADBEEFDEADBEEFL);
+            assertEquals(r, false, "failing compareAndSet long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSwap long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "failing compareAndSet long value");
         }
 
         // Advanced compare
         {
-            long r = UNSAFE.compareAndExchangeLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
-            assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchangeVolatile long");
+            long r = UNSAFE.compareAndExchangeLong(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+            assertEquals(r, 0xCAFEBABECAFEBABEL, "success compareAndExchange long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchangeVolatile long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "success compareAndExchange long value");
         }
 
         {
-            long r = UNSAFE.compareAndExchangeLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
-            assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long");
+            long r = UNSAFE.compareAndExchangeLong(base, offset, 0xCAFEBABECAFEBABEL, 0xDEADBEEFDEADBEEFL);
+            assertEquals(r, 0x0123456789ABCDEFL, "failing compareAndExchange long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchangeVolatile long value");
+            assertEquals(x, 0x0123456789ABCDEFL, "failing compareAndExchange long value");
         }
 
         {
@@ -257,41 +257,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapLong(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
+                success = UNSAFE.weakCompareAndSetLongPlain(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
             }
-            assertEquals(success, true, "weakCompareAndSwap long");
+            assertEquals(success, true, "weakCompareAndSetPlain long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSwap long value");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetPlain long value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapLongAcquire(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+                success = UNSAFE.weakCompareAndSetLongAcquire(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire long");
+            assertEquals(success, true, "weakCompareAndSetAcquire long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSwapAcquire long");
+            assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSetAcquire long");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapLongRelease(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
+                success = UNSAFE.weakCompareAndSetLongRelease(base, offset, 0x0123456789ABCDEFL, 0xCAFEBABECAFEBABEL);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease long");
+            assertEquals(success, true, "weakCompareAndSetRelease long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSwapRelease long");
+            assertEquals(x, 0xCAFEBABECAFEBABEL, "weakCompareAndSetRelease long");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapLongVolatile(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
+                success = UNSAFE.weakCompareAndSetLong(base, offset, 0xCAFEBABECAFEBABEL, 0x0123456789ABCDEFL);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile long");
+            assertEquals(success, true, "weakCompareAndSet long");
             long x = UNSAFE.getLong(base, offset);
-            assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSwapVolatile long");
+            assertEquals(x, 0x0123456789ABCDEFL, "weakCompareAndSet long");
         }
 
         UNSAFE.putLong(base, offset, 0xCAFEBABECAFEBABEL);
@@ -324,4 +324,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -151,32 +151,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapObject(base, offset, "foo", "bar");
-            assertEquals(r, true, "success compareAndSwap Object");
+            boolean r = UNSAFE.compareAndSetObject(base, offset, "foo", "bar");
+            assertEquals(r, true, "success compareAndSet Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "bar", "success compareAndSwap Object value");
+            assertEquals(x, "bar", "success compareAndSet Object value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapObject(base, offset, "foo", "baz");
-            assertEquals(r, false, "failing compareAndSwap Object");
+            boolean r = UNSAFE.compareAndSetObject(base, offset, "foo", "baz");
+            assertEquals(r, false, "failing compareAndSet Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "bar", "failing compareAndSwap Object value");
+            assertEquals(x, "bar", "failing compareAndSet Object value");
         }
 
         // Advanced compare
         {
-            Object r = UNSAFE.compareAndExchangeObjectVolatile(base, offset, "bar", "foo");
-            assertEquals(r, "bar", "success compareAndExchangeVolatile Object");
+            Object r = UNSAFE.compareAndExchangeObject(base, offset, "bar", "foo");
+            assertEquals(r, "bar", "success compareAndExchange Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "foo", "success compareAndExchangeVolatile Object value");
+            assertEquals(x, "foo", "success compareAndExchange Object value");
         }
 
         {
-            Object r = UNSAFE.compareAndExchangeObjectVolatile(base, offset, "bar", "baz");
-            assertEquals(r, "foo", "failing compareAndExchangeVolatile Object");
+            Object r = UNSAFE.compareAndExchangeObject(base, offset, "bar", "baz");
+            assertEquals(r, "foo", "failing compareAndExchange Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "foo", "failing compareAndExchangeVolatile Object value");
+            assertEquals(x, "foo", "failing compareAndExchange Object value");
         }
 
         {
@@ -210,41 +210,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapObject(base, offset, "foo", "bar");
+                success = UNSAFE.weakCompareAndSetObjectPlain(base, offset, "foo", "bar");
             }
-            assertEquals(success, true, "weakCompareAndSwap Object");
+            assertEquals(success, true, "weakCompareAndSetPlain Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "bar", "weakCompareAndSwap Object value");
+            assertEquals(x, "bar", "weakCompareAndSetPlain Object value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapObjectAcquire(base, offset, "bar", "foo");
+                success = UNSAFE.weakCompareAndSetObjectAcquire(base, offset, "bar", "foo");
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire Object");
+            assertEquals(success, true, "weakCompareAndSetAcquire Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "foo", "weakCompareAndSwapAcquire Object");
+            assertEquals(x, "foo", "weakCompareAndSetAcquire Object");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapObjectRelease(base, offset, "foo", "bar");
+                success = UNSAFE.weakCompareAndSetObjectRelease(base, offset, "foo", "bar");
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease Object");
+            assertEquals(success, true, "weakCompareAndSetRelease Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "bar", "weakCompareAndSwapRelease Object");
+            assertEquals(x, "bar", "weakCompareAndSetRelease Object");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapObjectVolatile(base, offset, "bar", "foo");
+                success = UNSAFE.weakCompareAndSetObject(base, offset, "bar", "foo");
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile Object");
+            assertEquals(success, true, "weakCompareAndSet Object");
             Object x = UNSAFE.getObject(base, offset);
-            assertEquals(x, "foo", "weakCompareAndSwapVolatile Object");
+            assertEquals(x, "foo", "weakCompareAndSet Object");
         }
 
         UNSAFE.putObject(base, offset, "bar");
@@ -260,4 +260,3 @@
     }
 
 }
-
--- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -198,32 +198,32 @@
 
         // Compare
         {
-            boolean r = UNSAFE.compareAndSwapShort(base, offset, (short)0x0123, (short)0x4567);
-            assertEquals(r, true, "success compareAndSwap short");
+            boolean r = UNSAFE.compareAndSetShort(base, offset, (short)0x0123, (short)0x4567);
+            assertEquals(r, true, "success compareAndSet short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x4567, "success compareAndSwap short value");
+            assertEquals(x, (short)0x4567, "success compareAndSet short value");
         }
 
         {
-            boolean r = UNSAFE.compareAndSwapShort(base, offset, (short)0x0123, (short)0x89AB);
-            assertEquals(r, false, "failing compareAndSwap short");
+            boolean r = UNSAFE.compareAndSetShort(base, offset, (short)0x0123, (short)0x89AB);
+            assertEquals(r, false, "failing compareAndSet short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x4567, "failing compareAndSwap short value");
+            assertEquals(x, (short)0x4567, "failing compareAndSet short value");
         }
 
         // Advanced compare
         {
-            short r = UNSAFE.compareAndExchangeShortVolatile(base, offset, (short)0x4567, (short)0x0123);
-            assertEquals(r, (short)0x4567, "success compareAndExchangeVolatile short");
+            short r = UNSAFE.compareAndExchangeShort(base, offset, (short)0x4567, (short)0x0123);
+            assertEquals(r, (short)0x4567, "success compareAndExchange short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x0123, "success compareAndExchangeVolatile short value");
+            assertEquals(x, (short)0x0123, "success compareAndExchange short value");
         }
 
         {
-            short r = UNSAFE.compareAndExchangeShortVolatile(base, offset, (short)0x4567, (short)0x89AB);
-            assertEquals(r, (short)0x0123, "failing compareAndExchangeVolatile short");
+            short r = UNSAFE.compareAndExchangeShort(base, offset, (short)0x4567, (short)0x89AB);
+            assertEquals(r, (short)0x0123, "failing compareAndExchange short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x0123, "failing compareAndExchangeVolatile short value");
+            assertEquals(x, (short)0x0123, "failing compareAndExchange short value");
         }
 
         {
@@ -257,41 +257,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapShort(base, offset, (short)0x0123, (short)0x4567);
+                success = UNSAFE.weakCompareAndSetShortPlain(base, offset, (short)0x0123, (short)0x4567);
             }
-            assertEquals(success, true, "weakCompareAndSwap short");
+            assertEquals(success, true, "weakCompareAndSetPlain short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x4567, "weakCompareAndSwap short value");
+            assertEquals(x, (short)0x4567, "weakCompareAndSetPlain short value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapShortAcquire(base, offset, (short)0x4567, (short)0x0123);
+                success = UNSAFE.weakCompareAndSetShortAcquire(base, offset, (short)0x4567, (short)0x0123);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire short");
+            assertEquals(success, true, "weakCompareAndSetAcquire short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x0123, "weakCompareAndSwapAcquire short");
+            assertEquals(x, (short)0x0123, "weakCompareAndSetAcquire short");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapShortRelease(base, offset, (short)0x0123, (short)0x4567);
+                success = UNSAFE.weakCompareAndSetShortRelease(base, offset, (short)0x0123, (short)0x4567);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease short");
+            assertEquals(success, true, "weakCompareAndSetRelease short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x4567, "weakCompareAndSwapRelease short");
+            assertEquals(x, (short)0x4567, "weakCompareAndSetRelease short");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwapShortVolatile(base, offset, (short)0x4567, (short)0x0123);
+                success = UNSAFE.weakCompareAndSetShort(base, offset, (short)0x4567, (short)0x0123);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile short");
+            assertEquals(success, true, "weakCompareAndSet short");
             short x = UNSAFE.getShort(base, offset);
-            assertEquals(x, (short)0x0123, "weakCompareAndSwapVolatile short");
+            assertEquals(x, (short)0x0123, "weakCompareAndSet short");
         }
 
         UNSAFE.putShort(base, offset, (short)0x4567);
@@ -324,4 +324,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -138,4 +138,3 @@
     }
 
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -216,4 +216,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -216,4 +216,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -170,4 +170,3 @@
     }
 
 }
-
--- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -175,4 +175,3 @@
         }
     }
 }
-
--- a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,11 @@
  * @bug 8143628
  * @summary Test unsafe access for $type$
  *
+#if[JdkInternalMisc]
+ * @modules $module$/$package$:+open
+#else[JdkInternalMisc]
  * @modules $module$/$package$
+#end[JdkInternalMisc]
  * @run testng/othervm -Diters=100   -Xint                   compiler.unsafe.$Qualifier$UnsafeAccessTest$Type$
  * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 compiler.unsafe.$Qualifier$UnsafeAccessTest$Type$
  * @run testng/othervm -Diters=20000 -XX:-TieredCompilation  compiler.unsafe.$Qualifier$UnsafeAccessTest$Type$
@@ -219,33 +223,51 @@
 
         // Compare
         {
+#if[JdkInternalMisc]
+            boolean r = UNSAFE.compareAndSet$Type$(base, offset, $value1$, $value2$);
+            assertEquals(r, true, "success compareAndSet $type$");
+#else[JdkInternalMisc]
             boolean r = UNSAFE.compareAndSwap$Type$(base, offset, $value1$, $value2$);
             assertEquals(r, true, "success compareAndSwap $type$");
+#end[JdkInternalMisc]
             $type$ x = UNSAFE.get$Type$(base, offset);
+#if[JdkInternalMisc]
+            assertEquals(x, $value2$, "success compareAndSet $type$ value");
+#else[JdkInternalMisc]
             assertEquals(x, $value2$, "success compareAndSwap $type$ value");
+#end[JdkInternalMisc]
         }
 
         {
+#if[JdkInternalMisc]
+            boolean r = UNSAFE.compareAndSet$Type$(base, offset, $value1$, $value3$);
+            assertEquals(r, false, "failing compareAndSet $type$");
+#else[JdkInternalMisc]
             boolean r = UNSAFE.compareAndSwap$Type$(base, offset, $value1$, $value3$);
             assertEquals(r, false, "failing compareAndSwap $type$");
+#end[JdkInternalMisc]
             $type$ x = UNSAFE.get$Type$(base, offset);
+#if[JdkInternalMisc]
+            assertEquals(x, $value2$, "failing compareAndSet $type$ value");
+#else[JdkInternalMisc]
             assertEquals(x, $value2$, "failing compareAndSwap $type$ value");
+#end[JdkInternalMisc]
         }
 
 #if[JdkInternalMisc]
         // Advanced compare
         {
-            $type$ r = UNSAFE.compareAndExchange$Type$Volatile(base, offset, $value2$, $value1$);
-            assertEquals(r, $value2$, "success compareAndExchangeVolatile $type$");
+            $type$ r = UNSAFE.compareAndExchange$Type$(base, offset, $value2$, $value1$);
+            assertEquals(r, $value2$, "success compareAndExchange $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value1$, "success compareAndExchangeVolatile $type$ value");
+            assertEquals(x, $value1$, "success compareAndExchange $type$ value");
         }
 
         {
-            $type$ r = UNSAFE.compareAndExchange$Type$Volatile(base, offset, $value2$, $value3$);
-            assertEquals(r, $value1$, "failing compareAndExchangeVolatile $type$");
+            $type$ r = UNSAFE.compareAndExchange$Type$(base, offset, $value2$, $value3$);
+            assertEquals(r, $value1$, "failing compareAndExchange $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value1$, "failing compareAndExchangeVolatile $type$ value");
+            assertEquals(x, $value1$, "failing compareAndExchange $type$ value");
         }
 
         {
@@ -279,41 +301,41 @@
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwap$Type$(base, offset, $value1$, $value2$);
+                success = UNSAFE.weakCompareAndSet$Type$Plain(base, offset, $value1$, $value2$);
             }
-            assertEquals(success, true, "weakCompareAndSwap $type$");
+            assertEquals(success, true, "weakCompareAndSetPlain $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value2$, "weakCompareAndSwap $type$ value");
+            assertEquals(x, $value2$, "weakCompareAndSetPlain $type$ value");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwap$Type$Acquire(base, offset, $value2$, $value1$);
+                success = UNSAFE.weakCompareAndSet$Type$Acquire(base, offset, $value2$, $value1$);
             }
-            assertEquals(success, true, "weakCompareAndSwapAcquire $type$");
+            assertEquals(success, true, "weakCompareAndSetAcquire $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value1$, "weakCompareAndSwapAcquire $type$");
+            assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwap$Type$Release(base, offset, $value1$, $value2$);
+                success = UNSAFE.weakCompareAndSet$Type$Release(base, offset, $value1$, $value2$);
             }
-            assertEquals(success, true, "weakCompareAndSwapRelease $type$");
+            assertEquals(success, true, "weakCompareAndSetRelease $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value2$, "weakCompareAndSwapRelease $type$");
+            assertEquals(x, $value2$, "weakCompareAndSetRelease $type$");
         }
 
         {
             boolean success = false;
             for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) {
-                success = UNSAFE.weakCompareAndSwap$Type$Volatile(base, offset, $value2$, $value1$);
+                success = UNSAFE.weakCompareAndSet$Type$(base, offset, $value2$, $value1$);
             }
-            assertEquals(success, true, "weakCompareAndSwapVolatile $type$");
+            assertEquals(success, true, "weakCompareAndSet $type$");
             $type$ x = UNSAFE.get$Type$(base, offset);
-            assertEquals(x, $value1$, "weakCompareAndSwapVolatile $type$");
+            assertEquals(x, $value1$, "weakCompareAndSet $type$");
         }
 
 #end[JdkInternalMisc]
@@ -354,4 +376,3 @@
 #end[!boolean]
 #end[!Object]
 }
-
--- a/hotspot/test/gc/arguments/TestExplicitGCInvokesConcurrentAndUnloadsClasses.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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);
-    }
-}
--- a/hotspot/test/gc/arguments/TestSelectDefaultGC.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/gc/arguments/TestSelectDefaultGC.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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 {
--- a/hotspot/test/gc/startup_warnings/TestDefNewCMS.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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);
-  }
-
-}
--- a/hotspot/test/gc/startup_warnings/TestParNewCMS.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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);
-  }
-
-}
--- a/hotspot/test/gc/startup_warnings/TestParNewSerialOld.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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);
-  }
-
-}
--- a/hotspot/test/gc/startup_warnings/TestUseAutoGCSelectPolicy.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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);
-  }
-}
--- a/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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");
   }
 }
--- a/hotspot/test/runtime/CommandLine/VMAliasOptions.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/runtime/CommandLine/VMAliasOptions.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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" },
     };
 
--- a/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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"}
     };
 
--- a/hotspot/test/runtime/NMT/AutoshutdownNMT.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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");
-    }
-}
--- a/jaxp/.hgtags	Wed Jul 05 23:35:20 2017 +0200
+++ b/jaxp/.hgtags	Wed Jul 05 23:37:13 2017 +0200
@@ -396,9 +396,11 @@
 13c6906bfc861d99dc35a19c80b7a99f0b0ac58d jdk-9+151
 7e3da313b1746578da648155e37dd8526e83153d jdk-9+152
 1384504d2cd0e55c5e0becaeaf40ab05cae959d6 jdk-9+153
+0908877116d17c6e59092ec7d53ef687a96d3278 jdk-10+0
 7fa738305436d14c0926df0f04892890cacc766b jdk-9+154
 48fa77af153288b08ba794e1616a7b0685f3b67e jdk-9+155
 e930c373aaa4e0e712c9a25ba4b03d473b48c294 jdk-9+156
+b4257a40e55d5dea9fe27f7cc11c430531b7ad66 jdk-10+1
 412df235a8a229469a2cb9e7bb274d43277077d2 jdk-9+157
 60e670a65e07cc309951bd838b484401e6dd7847 jdk-9+158
 5695854e8831d0c088ab0ecf83b367ec16c9760a jdk-9+159
@@ -409,8 +411,18 @@
 6dc790a4e8310c86712cfdf7561a9820818546e6 jdk-9+164
 55419603989707ec50c84bb379bbdc1adeec3ab2 jdk-9+165
 8d3febd5c9d82e49f3e6e5f8eb10f959e7b50f83 jdk-9+166
+fb8f87183981ae0ea7afdafec64763e2f1a88227 jdk-10+2
+97423b4995a216d3fb566dcc5825f3d54dcfe17f jdk-10+3
+1f64e853c72b269a3e45878515c07dad9c533592 jdk-10+4
+ac697b2bdf486ef18caad2092bd24036e14946ac jdk-10+5
+26ed5e84fa13b8dca066b01ece5bc029323611be jdk-10+6
 646567dcfa64b9a39b33d71330427737d1c1a0d5 jdk-9+167
 23a87f409371fb8ce7b764cccb3a74c3f6b29900 jdk-9+168
 5d9d2a65fb26aa183019346c11d9314819621665 jdk-9+169
 6e78f902f477a093afca85a1042f97410d01eb69 jdk-9+170
+09cae4c36242734f5450de739b8264523a030809 jdk-10+7
+856998840907b67b7e1fc49259f785ac085a189b jdk-10+8
+3c75f07b2a49cb0a4f4eb5df8bbcbc64dda3153f jdk-10+9
 c27321c889cf4c8e465a61b84572c00ef7ee6004 jdk-9+171
+bd4b2c8835f35760a51c1475b03a16cc20c62973 jdk-10+10
+eedb6e54c8bd6197ecba5fc0d8568bac8ae852dd jdk-9+172
--- a/jaxp/.jcheck/conf	Wed Jul 05 23:35:20 2017 +0200
+++ b/jaxp/.jcheck/conf	Wed Jul 05 23:37:13 2017 +0200
@@ -1,1 +1,1 @@
-project=jdk9
+project=jdk10
--- a/jaxp/test/TEST.ROOT	Wed Jul 05 23:35:20 2017 +0200
+++ b/jaxp/test/TEST.ROOT	Wed Jul 05 23:37:13 2017 +0200
@@ -25,6 +25,10 @@
 # Minimum jtreg version
 requiredVersion=4.2 b07
 
+# Path to libraries in the topmost test directory. This is needed so @library
+# does not need ../../ notation to reach them
+external.lib.roots = ../../
+
 # Use new module options
 useNewOptions=true
 
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/Asserts.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,566 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.util.Objects;
-
-/**
- * Asserts that can be used for verifying assumptions in tests.
- *
- * An assertion will throw a {@link RuntimeException} if the assertion isn't true.
- * All the asserts can be imported into a test by using a static import:
- *
- * <pre>
- * {@code
- * import static jdk.testlibrary.Asserts.*;
- * }
- *
- * Always provide a message describing the assumption if the line number of the
- * failing assertion isn't enough to understand why the assumption failed. For
- * example, if the assertion is in a loop or in a method that is called
- * multiple times, then the line number won't provide enough context to
- * understand the failure.
- * </pre>
- *
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib}
- */
-@Deprecated
-public class Asserts {
-
-    /**
-     * Shorthand for {@link #assertLessThan(Comparable, Comparable)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertLessThan(Comparable, Comparable)
-     */
-    public static <T extends Comparable<T>> void assertLT(T lhs, T rhs) {
-        assertLessThan(lhs, rhs);
-    }
-
-    /**
-     * Shorthand for {@link #assertLessThan(Comparable, Comparable, String)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @see #assertLessThan(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertLT(T lhs, T rhs, String msg) {
-        assertLessThan(lhs, rhs, msg);
-    }
-
-    /**
-     * Calls {@link #assertLessThan(Comparable, Comparable, String)} with a default message.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertLessThan(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertLessThan(T lhs, T rhs) {
-        assertLessThan(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is less than {@code rhs}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static <T extends Comparable<T>>void assertLessThan(T lhs, T rhs, String msg) {
-        if (!(compare(lhs, rhs, msg) < 0)) {
-            msg = Objects.toString(msg, "assertLessThan")
-                    + ": expected that " + Objects.toString(lhs)
-                    + " < " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Shorthand for {@link #assertLessThanOrEqual(Comparable, Comparable)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertLessThanOrEqual(Comparable, Comparable)
-     */
-    public static <T extends Comparable<T>> void assertLTE(T lhs, T rhs) {
-        assertLessThanOrEqual(lhs, rhs);
-    }
-
-    /**
-     * Shorthand for {@link #assertLessThanOrEqual(Comparable, Comparable, String)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @see #assertLessThanOrEqual(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertLTE(T lhs, T rhs, String msg) {
-        assertLessThanOrEqual(lhs, rhs, msg);
-    }
-
-    /**
-     * Calls {@link #assertLessThanOrEqual(Comparable, Comparable, String)} with a default message.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertLessThanOrEqual(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertLessThanOrEqual(T lhs, T rhs) {
-        assertLessThanOrEqual(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is less than or equal to {@code rhs}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static <T extends Comparable<T>> void assertLessThanOrEqual(T lhs, T rhs, String msg) {
-        if (!(compare(lhs, rhs, msg) <= 0)) {
-            msg = Objects.toString(msg, "assertLessThanOrEqual")
-                    + ": expected that " + Objects.toString(lhs)
-                    + " <= " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Shorthand for {@link #assertEquals(Object, Object)}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertEquals(Object, Object)
-     */
-    public static void assertEQ(Object lhs, Object rhs) {
-        assertEquals(lhs, rhs);
-    }
-
-    /**
-     * Shorthand for {@link #assertEquals(Object, Object, String)}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @see #assertEquals(Object, Object, String)
-     */
-    public static void assertEQ(Object lhs, Object rhs, String msg) {
-        assertEquals(lhs, rhs, msg);
-    }
-
-    /**
-     * Calls {@link #assertEquals(java.lang.Object, java.lang.Object, java.lang.String)} with a default message.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertEquals(Object, Object, String)
-     */
-    public static void assertEquals(Object lhs, Object rhs) {
-        assertEquals(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is equal to {@code rhs}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertEquals(Object lhs, Object rhs, String msg) {
-        if ((lhs != rhs) && ((lhs == null) || !(lhs.equals(rhs)))) {
-            msg = Objects.toString(msg, "assertEquals")
-                    + ": expected " + Objects.toString(lhs)
-                    + " to equal " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Calls {@link #assertSame(java.lang.Object, java.lang.Object, java.lang.String)} with a default message.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertSame(Object, Object, String)
-     */
-    public static void assertSame(Object lhs, Object rhs) {
-        assertSame(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is the same as {@code rhs}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertSame(Object lhs, Object rhs, String msg) {
-        if (lhs != rhs) {
-            msg = Objects.toString(msg, "assertSame")
-                    + ": expected " + Objects.toString(lhs)
-                    + " to equal " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Shorthand for {@link #assertGreaterThanOrEqual(Comparable, Comparable)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertGreaterThanOrEqual(Comparable, Comparable)
-     */
-    public static <T extends Comparable<T>> void assertGTE(T lhs, T rhs) {
-        assertGreaterThanOrEqual(lhs, rhs);
-    }
-
-    /**
-     * Shorthand for {@link #assertGreaterThanOrEqual(Comparable, Comparable, String)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @see #assertGreaterThanOrEqual(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertGTE(T lhs, T rhs, String msg) {
-        assertGreaterThanOrEqual(lhs, rhs, msg);
-    }
-
-    /**
-     * Calls {@link #assertGreaterThanOrEqual(Comparable, Comparable, String)} with a default message.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertGreaterThanOrEqual(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertGreaterThanOrEqual(T lhs, T rhs) {
-        assertGreaterThanOrEqual(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is greater than or equal to {@code rhs}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static <T extends Comparable<T>> void assertGreaterThanOrEqual(T lhs, T rhs, String msg) {
-        if (!(compare(lhs, rhs, msg) >= 0)) {
-            msg = Objects.toString(msg, "assertGreaterThanOrEqual")
-                    + ": expected " + Objects.toString(lhs)
-                    + " >= " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Shorthand for {@link #assertGreaterThan(Comparable, Comparable)}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertGreaterThan(Comparable, Comparable)
-     */
-    public static <T extends Comparable<T>> void assertGT(T lhs, T rhs) {
-        assertGreaterThan(lhs, rhs);
-    }
-
-    /**
-     * Shorthand for {@link #assertGreaterThan(Comparable, Comparable, String)}.
-     *
-     * @param <T> a type
-     * @param lhs the left hand value
-     * @param rhs the right hand value
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @see #assertGreaterThan(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertGT(T lhs, T rhs, String msg) {
-        assertGreaterThan(lhs, rhs, msg);
-    }
-
-    /**
-     * Calls {@link #assertGreaterThan(Comparable, Comparable, String)} with a default message.
-     *
-     * @param <T> a type
-     * @param lhs the left hand value
-     * @param rhs the right hand value
-     * @see #assertGreaterThan(Comparable, Comparable, String)
-     */
-    public static <T extends Comparable<T>> void assertGreaterThan(T lhs, T rhs) {
-        assertGreaterThan(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is greater than {@code rhs}.
-     *
-     * @param <T> a type
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static <T extends Comparable<T>> void assertGreaterThan(T lhs, T rhs, String msg) {
-        if (!(compare(lhs, rhs, msg) > 0)) {
-            msg = Objects.toString(msg, "assertGreaterThan")
-                    + ": expected " + Objects.toString(lhs)
-                    + " > " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Shorthand for {@link #assertNotEquals(Object, Object)}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertNotEquals(Object, Object)
-     */
-    public static void assertNE(Object lhs, Object rhs) {
-        assertNotEquals(lhs, rhs);
-    }
-
-    /**
-     * Shorthand for {@link #assertNotEquals(Object, Object, String)}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @see #assertNotEquals(Object, Object, String)
-     */
-    public static void assertNE(Object lhs, Object rhs, String msg) {
-        assertNotEquals(lhs, rhs, msg);
-    }
-
-    /**
-     * Calls {@link #assertNotEquals(Object, Object, String)} with a default message.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @see #assertNotEquals(Object, Object, String)
-     */
-    public static void assertNotEquals(Object lhs, Object rhs) {
-        assertNotEquals(lhs, rhs, null);
-    }
-
-    /**
-     * Asserts that {@code lhs} is not equal to {@code rhs}.
-     *
-     * @param lhs The left hand side of the comparison.
-     * @param rhs The right hand side of the comparison.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertNotEquals(Object lhs, Object rhs, String msg) {
-        if ((lhs == rhs) || (lhs != null && lhs.equals(rhs))) {
-            msg = Objects.toString(msg, "assertNotEquals")
-                    + ": expected " + Objects.toString(lhs)
-                    + " to not equal " + Objects.toString(rhs);
-            fail(msg);
-        }
-    }
-
-    /**
-     * Calls {@link #assertNull(Object, String)} with a default message.
-     *
-     * @param o The reference assumed to be null.
-     * @see #assertNull(Object, String)
-     */
-    public static void assertNull(Object o) {
-        assertNull(o, null);
-    }
-
-    /**
-     * Asserts that {@code o} is null.
-     *
-     * @param o The reference assumed to be null.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertNull(Object o, String msg) {
-        assertEquals(o, null, msg);
-    }
-
-    /**
-     * Calls {@link #assertNotNull(Object, String)} with a default message.
-     *
-     * @param o The reference assumed <i>not</i> to be null,
-     * @see #assertNotNull(Object, String)
-     */
-    public static void assertNotNull(Object o) {
-        assertNotNull(o, null);
-    }
-
-    /**
-     * Asserts that {@code o} is <i>not</i> null.
-     *
-     * @param o The reference assumed <i>not</i> to be null,
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertNotNull(Object o, String msg) {
-        assertNotEquals(o, null, msg);
-    }
-
-    /**
-     * Calls {@link #assertFalse(boolean, String)} with a default message.
-     *
-     * @param value The value assumed to be false.
-     * @see #assertFalse(boolean, String)
-     */
-    public static void assertFalse(boolean value) {
-        assertFalse(value, null);
-    }
-
-    /**
-     * Asserts that {@code value} is {@code false}.
-     *
-     * @param value The value assumed to be false.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertFalse(boolean value, String msg) {
-        if (value) {
-            msg = Objects.toString(msg, "assertFalse")
-                    + ": expected false, was true";
-            fail(msg);
-        }
-    }
-
-    /**
-     * Calls {@link #assertTrue(boolean, String)} with a default message.
-     *
-     * @param value The value assumed to be true.
-     * @see #assertTrue(boolean, String)
-     */
-    public static void assertTrue(boolean value) {
-        assertTrue(value, null);
-    }
-
-    /**
-     * Asserts that {@code value} is {@code true}.
-     *
-     * @param value The value assumed to be true.
-     * @param msg A description of the assumption; {@code null} for a default message.
-     * @throws RuntimeException if the assertion is not true.
-     */
-    public static void assertTrue(boolean value, String msg) {
-        if (!value) {
-            msg = Objects.toString(msg, "assertTrue")
-                    + ": expected true, was false";
-            fail(msg);
-        }
-    }
-
-    private static <T extends Comparable<T>> int compare(T lhs, T rhs, String msg) {
-        if (lhs == null || rhs == null) {
-            fail(lhs, rhs, msg + ": values must be non-null:", ",");
-        }
-        return lhs.compareTo(rhs);
-    }
-
-    /**
-     * Returns a string formatted with a message and expected and actual values.
-     * @param lhs the actual value
-     * @param rhs  the expected value
-     * @param message the actual value
-     * @param relation the asserted relationship between lhs and rhs
-     * @return a formatted string
-     */
-    public static String format(Object lhs, Object rhs, String message, String relation) {
-        StringBuilder sb = new StringBuilder(80);
-        if (message != null) {
-            sb.append(message);
-            sb.append(' ');
-        }
-        sb.append("<");
-        sb.append(Objects.toString(lhs));
-        sb.append("> ");
-        sb.append(Objects.toString(relation, ","));
-        sb.append(" <");
-        sb.append(Objects.toString(rhs));
-        sb.append(">");
-        return sb.toString();
-    }
-
-    /**
-     * Fail reports a failure with message fail.
-     *
-     * @throws RuntimeException always
-     */
-    public static void fail() {
-        fail("fail");
-    }
-
-    /**
-     * Fail reports a failure with a message.
-     * @param message for the failure
-     * @throws RuntimeException always
-     */
-    public static void fail(String message) {
-        throw new RuntimeException(message);
-    }
-
-    /**
-     * Fail reports a failure with a formatted message.
-     *
-     * @param lhs the actual value
-     * @param rhs the expected value
-     * @param message to be format before the expected and actual values
-     * @param relation the asserted relationship between lhs and rhs
-     * @throws RuntimeException always
-     */
-    public static void fail(Object lhs, Object rhs, String message, String relation) {
-        throw new RuntimeException(format(lhs, rhs, message, relation));
-    }
-
-    /**
-     * Fail reports a failure with a message and a cause.
-     * @param message to be format before the expected and actual values
-     * @param cause the exception that caused this failure
-     * @throws RuntimeException always
-     */
-    public static void fail(String message, Throwable cause) {
-        throw new RuntimeException(message, cause);
-    }
-
-}
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/CompilerUtils.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import javax.tools.JavaCompiler;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
-import javax.tools.ToolProvider;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * This class consists exclusively of static utility methods for invoking the
- * java compiler.
- */
-
-public final class CompilerUtils {
-    private CompilerUtils() { }
-
-    /**
-     * Compile all the java sources in {@code <source>/**} to
-     * {@code <destination>/**}. The destination directory will be created if
-     * it doesn't exist.
-     *
-     * All warnings/errors emitted by the compiler are output to System.out/err.
-     *
-     * @return true if the compilation is successful
-     *
-     * @throws IOException if there is an I/O error scanning the source tree or
-     *                     creating the destination directory
-     */
-    public static boolean compile(Path source, Path destination, String ... options)
-        throws IOException
-    {
-        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
-        StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
-
-        List<Path> sources
-            = Files.find(source, Integer.MAX_VALUE,
-                (file, attrs) -> (file.toString().endsWith(".java")))
-                .collect(Collectors.toList());
-
-        Files.createDirectories(destination);
-        jfm.setLocation(StandardLocation.CLASS_PATH, Collections.EMPTY_LIST);
-        jfm.setLocationFromPaths(StandardLocation.CLASS_OUTPUT,
-                                 Arrays.asList(destination));
-
-        List<String> opts = Arrays.asList(options);
-        JavaCompiler.CompilationTask task
-            = compiler.getTask(null, jfm, null, opts, null,
-                jfm.getJavaFileObjectsFromPaths(sources));
-
-        return task.call();
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/JDKToolFinder.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.io.FileNotFoundException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib}
- */
-@Deprecated
-public final class JDKToolFinder {
-
-    private JDKToolFinder() {
-    }
-
-    /**
-     * Returns the full path to an executable in jdk/bin based on System
-     * property {@code test.jdk} or {@code compile.jdk} (both are set by the jtreg test suite)
-     *
-     * @return Full path to an executable in jdk/bin
-     */
-    public static String getJDKTool(String tool) {
-
-        // First try to find the executable in test.jdk
-        try {
-            return getTool(tool, "test.jdk");
-        } catch (FileNotFoundException e) {
-
-        }
-
-        // Now see if it's available in compile.jdk
-        try {
-            return getTool(tool, "compile.jdk");
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException("Failed to find " + tool +
-                    ", looked in test.jdk (" + System.getProperty("test.jdk") +
-                    ") and compile.jdk (" + System.getProperty("compile.jdk") + ")");
-        }
-    }
-
-    /**
-     * Returns the full path to an executable in jdk/bin based on System
-     * property {@code compile.jdk}
-     *
-     * @return Full path to an executable in jdk/bin
-     */
-    public static String getCompileJDKTool(String tool) {
-        try {
-            return getTool(tool, "compile.jdk");
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Returns the full path to an executable in jdk/bin based on System
-     * property {@code test.jdk}
-     *
-     * @return Full path to an executable in jdk/bin
-     */
-    public static String getTestJDKTool(String tool) {
-        try {
-            return getTool(tool, "test.jdk");
-        } catch (FileNotFoundException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    private static String getTool(String tool, String property) throws FileNotFoundException {
-        String jdkPath = System.getProperty(property);
-
-        if (jdkPath == null) {
-            throw new RuntimeException(
-                    "System property '" + property + "' not set. This property is normally set by jtreg. "
-                    + "When running test separately, set this property using '-D" + property + "=/path/to/jdk'.");
-        }
-
-        Path toolName = Paths.get("bin", tool + (Platform.isWindows() ? ".exe" : ""));
-
-        Path jdkTool = Paths.get(jdkPath, toolName.toString());
-        if (!jdkTool.toFile().exists()) {
-            throw new FileNotFoundException("Could not find file " + jdkTool.toAbsolutePath());
-        }
-
-        return jdkTool.toAbsolutePath().toString();
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/JDKToolLauncher.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * A utility for constructing command lines for starting JDK tool processes.
- *
- * The JDKToolLauncher can in particular be combined with a
- * java.lang.ProcessBuilder to easily run a JDK tool. For example, the following
- * code run {@code jmap -heap} against a process with GC logging turned on for
- * the {@code jmap} process:
- *
- * <pre>
- * {@code
- * JDKToolLauncher jmap = JDKToolLauncher.create("jmap")
- *                                       .addVMArg("-Xlog:gc*=debug")
- *                                       .addToolArg("-heap")
- *                                       .addToolArg(pid);
- * ProcessBuilder pb = new ProcessBuilder(jmap.getCommand());
- * Process p = pb.start();
- * }
- * </pre>
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib}
- */
-@Deprecated
-public class JDKToolLauncher {
-    private final String executable;
-    private final List<String> vmArgs = new ArrayList<String>();
-    private final List<String> toolArgs = new ArrayList<String>();
-
-    private JDKToolLauncher(String tool, boolean useCompilerJDK) {
-        if (useCompilerJDK) {
-            executable = JDKToolFinder.getJDKTool(tool);
-        } else {
-            executable = JDKToolFinder.getTestJDKTool(tool);
-        }
-        vmArgs.addAll(Arrays.asList(ProcessTools.getPlatformSpecificVMArgs()));
-    }
-
-    /**
-     * Creates a new JDKToolLauncher for the specified tool. Using tools path
-     * from the compiler JDK.
-     *
-     * @param tool
-     *            The name of the tool
-     * @return A new JDKToolLauncher
-     */
-    public static JDKToolLauncher create(String tool) {
-        return new JDKToolLauncher(tool, true);
-    }
-
-    /**
-     * Creates a new JDKToolLauncher for the specified tool in the Tested JDK.
-     *
-     * @param tool
-     *            The name of the tool
-     *
-     * @return A new JDKToolLauncher
-     */
-    public static JDKToolLauncher createUsingTestJDK(String tool) {
-        return new JDKToolLauncher(tool, false);
-    }
-
-    /**
-     * Adds an argument to the JVM running the tool.
-     *
-     * The JVM arguments are passed to the underlying JVM running the tool.
-     * Arguments will automatically be prepended with "-J".
-     *
-     * Any platform specific arguments required for running the tool are
-     * automatically added.
-     *
-     *
-     * @param arg
-     *            The argument to VM running the tool
-     * @return The JDKToolLauncher instance
-     */
-    public JDKToolLauncher addVMArg(String arg) {
-        vmArgs.add(arg);
-        return this;
-    }
-
-    /**
-     * Adds an argument to the tool.
-     *
-     * @param arg
-     *            The argument to the tool
-     * @return The JDKToolLauncher instance
-     */
-    public JDKToolLauncher addToolArg(String arg) {
-        toolArgs.add(arg);
-        return this;
-    }
-
-    /**
-     * Returns the command that can be used for running the tool.
-     *
-     * @return An array whose elements are the arguments of the command.
-     */
-    public String[] getCommand() {
-        List<String> command = new ArrayList<String>();
-        command.add(executable);
-        // Add -J in front of all vmArgs
-        for (String arg : vmArgs) {
-            command.add("-J" + arg);
-        }
-        command.addAll(toolArgs);
-        return command.toArray(new String[command.size()]);
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/OutputAnalyzer.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,576 +0,0 @@
-/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import static jdk.testlibrary.Asserts.*;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Utility class for verifying output and exit value from a {@code Process}.
- *
- * @deprecated  This class is deprecated. Use the one from
- *              {@code <root>/test/lib/share/classes/jdk/test/lib/process}
- *
- */
-@Deprecated
-public final class OutputAnalyzer {
-    private final OutputBuffer output;
-    private final String stdout;
-    private final String stderr;
-    private final int exitValue;    // useless now. output contains exit value.
-
-    /**
-     * Create an OutputAnalyzer, a utility class for verifying output and exit
-     * value from a Process.
-     * <p>
-     * OutputAnalyzer should never be instantiated directly -
-     * use {@linkplain ProcessTools#executeProcess(ProcessBuilder)} instead
-     *
-     * @param process
-     *            Process to analyze
-     * @throws IOException
-     *             If an I/O error occurs.
-     */
-    OutputAnalyzer(Process process) throws IOException {
-        output = new OutputBuffer(process);
-        exitValue = -1;
-        this.stdout = null;
-        this.stderr = null;
-    }
-
-    /**
-     * Create an OutputAnalyzer, a utility class for verifying output.
-     *
-     * @param buf
-     *            String buffer to analyze
-     */
-    OutputAnalyzer(String buf) {
-        this(buf, buf);
-    }
-
-    /**
-     * Create an OutputAnalyzer, a utility class for verifying output
-     *
-     * @param stdout
-     *            stdout buffer to analyze
-     * @param stderr
-     *            stderr buffer to analyze
-     */
-    OutputAnalyzer(String stdout, String stderr) {
-        this.output = null;
-        this.stdout = stdout;
-        this.stderr = stderr;
-        exitValue = -1;
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer contains the
-     * string
-     *
-     * @param expectedString
-     *            String that buffer should contain
-     * @throws RuntimeException
-     *             If the string was not found
-     */
-    public OutputAnalyzer shouldContain(String expectedString) {
-        if (!getStdout().contains(expectedString)
-                && !getStderr().contains(expectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + expectedString
-                    + "' missing from stdout/stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer contains the string
-     *
-     * @param expectedString
-     *            String that buffer should contain
-     * @throws RuntimeException
-     *             If the string was not found
-     */
-    public OutputAnalyzer stdoutShouldContain(String expectedString) {
-        if (!getStdout().contains(expectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + expectedString
-                    + "' missing from stdout \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stderr contents of output buffer contains the string
-     *
-     * @param expectedString
-     *            String that buffer should contain
-     * @throws RuntimeException
-     *             If the string was not found
-     */
-    public OutputAnalyzer stderrShouldContain(String expectedString) {
-        if (!getStderr().contains(expectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + expectedString
-                    + "' missing from stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer does not
-     * contain the string
-     *
-     * @param notExpectedString
-     *            String that the buffer should not contain
-     * @throws RuntimeException
-     *             If the string was found
-     */
-    public OutputAnalyzer shouldNotContain(String notExpectedString) {
-        if (getStdout().contains(notExpectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + notExpectedString
-                    + "' found in stdout \n");
-        }
-        if (getStderr().contains(notExpectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + notExpectedString
-                    + "' found in stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer does not contain the
-     * string
-     *
-     * @param notExpectedString
-     *            String that the buffer should not contain
-     * @throws RuntimeException
-     *             If the string was found
-     */
-    public OutputAnalyzer stdoutShouldNotContain(String notExpectedString) {
-        if (getStdout().contains(notExpectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + notExpectedString
-                    + "' found in stdout \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stderr contents of output buffer does not contain the
-     * string
-     *
-     * @param notExpectedString
-     *            String that the buffer should not contain
-     * @throws RuntimeException
-     *             If the string was found
-     */
-    public OutputAnalyzer stderrShouldNotContain(String notExpectedString) {
-        if (getStderr().contains(notExpectedString)) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + notExpectedString
-                    + "' found in stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer matches the
-     * pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was not found
-     */
-    public OutputAnalyzer shouldMatch(String pattern) {
-        Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE)
-                .matcher(getStdout());
-        Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE)
-                .matcher(getStderr());
-        if (!stdoutMatcher.find() && !stderrMatcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
-                    + "' missing from stdout/stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer matches the pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was not found
-     */
-    public OutputAnalyzer stdoutShouldMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStdout());
-        if (!matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
-                    + "' missing from stdout \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stderr contents of output buffer matches the pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was not found
-     */
-    public OutputAnalyzer stderrShouldMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStderr());
-        if (!matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern
-                    + "' missing from stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer does not
-     * match the pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was found
-     */
-    public OutputAnalyzer shouldNotMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStdout());
-        if (matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern + "' found in stdout: '"
-                    + matcher.group() + "' \n");
-        }
-        matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(getStderr());
-        if (matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern + "' found in stderr: '"
-                    + matcher.group() + "' \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer does not match the
-     * pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was found
-     */
-    public OutputAnalyzer stdoutShouldNotMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStdout());
-        if (matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern + "' found in stdout \n");
-        }
-        return this;
-    }
-
-    /**
-     * Verify that the stderr contents of output buffer does not match the
-     * pattern
-     *
-     * @param pattern
-     * @throws RuntimeException
-     *             If the pattern was found
-     */
-    public OutputAnalyzer stderrShouldNotMatch(String pattern) {
-        Matcher matcher = Pattern.compile(pattern, Pattern.MULTILINE).matcher(
-                getStderr());
-        if (matcher.find()) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("'" + pattern + "' found in stderr \n");
-        }
-        return this;
-    }
-
-    /**
-     * Get the captured group of the first string matching the pattern. stderr
-     * is searched before stdout.
-     *
-     * @param pattern
-     *            The multi-line pattern to match
-     * @param group
-     *            The group to capture
-     * @return The matched string or null if no match was found
-     */
-    public String firstMatch(String pattern, int group) {
-        Matcher stderrMatcher = Pattern.compile(pattern, Pattern.MULTILINE)
-                .matcher(getStderr());
-        Matcher stdoutMatcher = Pattern.compile(pattern, Pattern.MULTILINE)
-                .matcher(getStdout());
-        if (stderrMatcher.find()) {
-            return stderrMatcher.group(group);
-        }
-        if (stdoutMatcher.find()) {
-            return stdoutMatcher.group(group);
-        }
-        return null;
-    }
-
-    /**
-     * Get the first string matching the pattern. stderr is searched before
-     * stdout.
-     *
-     * @param pattern
-     *            The multi-line pattern to match
-     * @return The matched string or null if no match was found
-     */
-    public String firstMatch(String pattern) {
-        return firstMatch(pattern, 0);
-    }
-
-    /**
-     * Verify the exit value of the process
-     *
-     * @param expectedExitValue
-     *            Expected exit value from process
-     * @throws RuntimeException
-     *             If the exit value from the process did not match the expected
-     *             value
-     */
-    public OutputAnalyzer shouldHaveExitValue(int expectedExitValue) {
-        if (getExitValue() != expectedExitValue) {
-            reportDiagnosticSummary();
-            throw new RuntimeException("Expected to get exit value of ["
-                    + expectedExitValue + "]\n");
-        }
-        return this;
-    }
-
-    /**
-     * Report summary that will help to diagnose the problem Currently includes:
-     * - standard input produced by the process under test - standard output -
-     * exit code Note: the command line is printed by the ProcessTools
-     */
-    private OutputAnalyzer reportDiagnosticSummary() {
-        String msg = " stdout: [" + getStdout() + "];\n" + " stderr: [" + getStderr()
-                + "]\n" + " exitValue = " + getExitValue() + "\n";
-
-        System.err.println(msg);
-        return this;
-    }
-
-    /**
-     * Get the contents of the output buffer (stdout and stderr)
-     *
-     * @return Content of the output buffer
-     */
-    public String getOutput() {
-        return getStdout() + getStderr();
-    }
-
-    /**
-     * Get the contents of the stdout buffer
-     *
-     * @return Content of the stdout buffer
-     */
-    public String getStdout() {
-        return output == null ? stdout : output.getStdout();
-    }
-
-    /**
-     * Get the contents of the stderr buffer
-     *
-     * @return Content of the stderr buffer
-     */
-    public String getStderr() {
-        return output == null ? stderr : output.getStderr();
-    }
-
-    /**
-     * Get the process exit value
-     *
-     * @return Process exit value
-     */
-    public int getExitValue() {
-        return output == null ? exitValue : output.getExitValue();
-    }
-
-
-    /**
-     * Print the stdout buffer to the given {@code PrintStream}.
-     *
-     * @return this OutputAnalyzer
-     */
-    public OutputAnalyzer outputTo(PrintStream out) {
-        out.println(getStdout());
-        return this;
-    }
-
-    /**
-     * Print the stderr buffer to the given {@code PrintStream}.
-     *
-     * @return this OutputAnalyzer
-     */
-    public OutputAnalyzer errorTo(PrintStream out) {
-        out.println(getStderr());
-        return this;
-    }
-
-
-    /**
-     * Get the contents of the output buffer (stdout and stderr) as list of strings.
-     * Output will be split by system property 'line.separator'.
-     *
-     * @return Contents of the output buffer as list of strings
-     */
-    public List<String> asLines() {
-        return asLines(getOutput());
-    }
-
-    private List<String> asLines(String buffer) {
-        List<String> l = new ArrayList<>();
-        String[] a = buffer.split(Utils.NEW_LINE);
-        for (String string : a) {
-            l.add(string);
-        }
-        return l;
-    }
-
-    /**
-     * Check if there is a line matching {@code pattern} and return its index
-     *
-     * @param pattern Matching pattern
-     * @return Index of first matching line
-     */
-    private int indexOf(List<String> lines, String pattern) {
-        for (int i = 0; i < lines.size(); i++) {
-            if (lines.get(i).matches(pattern)) {
-                return i;
-            }
-        }
-        return -1;
-    }
-
-    /**
-     * @see #shouldMatchByLine(String, String, String)
-     */
-    public int shouldMatchByLine(String pattern) {
-        return shouldMatchByLine(null, null, pattern);
-    }
-
-    /**
-     * @see #stdoutShouldMatchByLine(String, String, String)
-     */
-    public int stdoutShouldMatchByLine(String pattern) {
-        return stdoutShouldMatchByLine(null, null, pattern);
-    }
-
-    /**
-     * @see #shouldMatchByLine(String, String, String)
-     */
-    public int shouldMatchByLineFrom(String from, String pattern) {
-        return shouldMatchByLine(from, null, pattern);
-    }
-
-    /**
-     * @see #shouldMatchByLine(String, String, String)
-     */
-    public int shouldMatchByLineTo(String to, String pattern) {
-        return shouldMatchByLine(null, to, pattern);
-    }
-
-    /**
-     * Verify that the stdout and stderr contents of output buffer match the
-     * {@code pattern} line by line. The whole output could be matched or
-     * just a subset of it.
-     *
-     * @param from
-     *            The line from where output will be matched.
-     *            Set {@code from} to null for matching from the first line.
-     * @param to
-     *            The line until where output will be matched.
-     *            Set {@code to} to null for matching until the last line.
-     * @param pattern
-     *            Matching pattern
-     * @return Count of lines which match the {@code pattern}
-     */
-    public int shouldMatchByLine(String from, String to, String pattern) {
-        return shouldMatchByLine(getOutput(), from, to, pattern);
-    }
-
-    /**
-     * Verify that the stdout contents of output buffer matches the
-     * {@code pattern} line by line. The whole stdout could be matched or
-     * just a subset of it.
-     *
-     * @param from
-     *            The line from where stdout will be matched.
-     *            Set {@code from} to null for matching from the first line.
-     * @param to
-     *            The line until where stdout will be matched.
-     *            Set {@code to} to null for matching until the last line.
-     * @param pattern
-     *            Matching pattern
-     * @return Count of lines which match the {@code pattern}
-     */
-    public int stdoutShouldMatchByLine(String from, String to, String pattern) {
-        return shouldMatchByLine(getStdout(), from, to, pattern);
-    }
-
-    private int shouldMatchByLine(String buffer, String from, String to, String pattern) {
-        List<String> lines = asLines(buffer);
-
-        int fromIndex = 0;
-        if (from != null) {
-            fromIndex = indexOf(lines, from);
-            assertGreaterThan(fromIndex, -1,
-                    "The line/pattern '" + from + "' from where the output should match can not be found");
-        }
-
-        int toIndex = lines.size();
-        if (to != null) {
-            toIndex = indexOf(lines, to);
-            assertGreaterThan(toIndex, -1,
-                    "The line/pattern '" + to + "' until where the output should match can not be found");
-        }
-
-        List<String> subList = lines.subList(fromIndex, toIndex);
-        int matchedCount = 0;
-        for (String line : subList) {
-            assertTrue(line.matches(pattern),
-                    "The line '" + line + "' does not match pattern '" + pattern + "'");
-            matchedCount++;
-        }
-
-        return matchedCount;
-    }
-
-}
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/OutputBuffer.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.io.ByteArrayOutputStream;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib/process}
- */
-@Deprecated
-class OutputBuffer {
-    private static class OutputBufferException extends RuntimeException {
-        private static final long serialVersionUID = 8528687792643129571L;
-
-        public OutputBufferException(Throwable cause) {
-            super(cause);
-        }
-    }
-
-    private final Process p;
-    private final Future<Void> outTask;
-    private final Future<Void> errTask;
-    private final ByteArrayOutputStream stderrBuffer = new ByteArrayOutputStream();
-    private final ByteArrayOutputStream stdoutBuffer = new ByteArrayOutputStream();
-
-    /**
-     * Create an OutputBuffer, a class for storing and managing stdout and
-     * stderr results separately
-     *
-     * @param stdout
-     *            stdout result
-     * @param stderr
-     *            stderr result
-     */
-    OutputBuffer(Process p) {
-        this.p = p;
-        StreamPumper outPumper = new StreamPumper(p.getInputStream(),
-                stdoutBuffer);
-        StreamPumper errPumper = new StreamPumper(p.getErrorStream(),
-                stderrBuffer);
-
-        outTask = outPumper.process();
-        errTask = errPumper.process();
-    }
-
-    /**
-     * Returns the stdout result
-     *
-     * @return stdout result
-     */
-    public String getStdout() {
-        try {
-            outTask.get();
-            return stdoutBuffer.toString();
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-            throw new OutputBufferException(e);
-        } catch (ExecutionException | CancellationException e) {
-            throw new OutputBufferException(e);
-        }
-    }
-
-    /**
-     * Returns the stderr result
-     *
-     * @return stderr result
-     */
-    public String getStderr() {
-        try {
-            errTask.get();
-            return stderrBuffer.toString();
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-            throw new OutputBufferException(e);
-        } catch (ExecutionException | CancellationException e) {
-            throw new OutputBufferException(e);
-        }
-    }
-
-    public int getExitValue() {
-        try {
-            return p.waitFor();
-        } catch (InterruptedException e) {
-            Thread.currentThread().interrupt();
-            throw new OutputBufferException(e);
-        }
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/Platform.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-import java.util.regex.Pattern;
-import java.io.RandomAccessFile;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib}
- */
-@Deprecated
-public class Platform {
-    private static final String osName      = System.getProperty("os.name");
-    private static final String dataModel   = System.getProperty("sun.arch.data.model");
-    private static final String vmVersion   = System.getProperty("java.vm.version");
-    private static final String jdkDebug    = System.getProperty("jdk.debug");
-    private static final String osArch      = System.getProperty("os.arch");
-    private static final String vmName      = System.getProperty("java.vm.name");
-    private static final String userName    = System.getProperty("user.name");
-    private static final String compiler    = System.getProperty("sun.management.compiler");
-
-    public static boolean isClient() {
-        return vmName.endsWith(" Client VM");
-    }
-
-    public static boolean isServer() {
-        return vmName.endsWith(" Server VM");
-    }
-
-    public static boolean isGraal() {
-        return vmName.endsWith(" Graal VM");
-    }
-
-    public static boolean isMinimal() {
-        return vmName.endsWith(" Minimal VM");
-    }
-
-    public static boolean isEmbedded() {
-        return vmName.contains("Embedded");
-    }
-
-    public static boolean isTieredSupported() {
-        return compiler.contains("Tiered Compilers");
-    }
-
-
-    public static boolean is32bit() {
-        return dataModel.equals("32");
-    }
-
-    public static boolean is64bit() {
-        return dataModel.equals("64");
-    }
-
-    public static boolean isAix() {
-        return isOs("aix");
-    }
-
-    public static boolean isLinux() {
-        return isOs("linux");
-    }
-
-    public static boolean isOSX() {
-        return isOs("mac");
-    }
-
-    public static boolean isSolaris() {
-        return isOs("sunos");
-    }
-
-    public static boolean isWindows() {
-        return isOs("win");
-    }
-
-    private static boolean isOs(String osname) {
-        return osName.toLowerCase().startsWith(osname.toLowerCase());
-    }
-
-    public static String getOsName() {
-        return osName;
-    }
-
-    public static boolean isDebugBuild() {
-        return (jdkDebug.toLowerCase().contains("debug"));
-    }
-
-    public static String getVMVersion() {
-        return vmVersion;
-    }
-
-    // Returns true for sparc and sparcv9.
-    public static boolean isSparc() {
-        return isArch("sparc.*");
-    }
-
-    public static boolean isARM() {
-        return isArch("arm.*");
-    }
-
-    public static boolean isPPC() {
-        return isArch("ppc.*");
-    }
-
-    public static boolean isX86() {
-        // On Linux it's 'i386', Windows 'x86' without '_64' suffix.
-        return isArch("(i386)|(x86(?!_64))");
-    }
-
-    public static boolean isX64() {
-        // On OSX it's 'x86_64' and on other (Linux, Windows and Solaris) platforms it's 'amd64'
-        return isArch("(amd64)|(x86_64)");
-    }
-
-    private static boolean isArch(String archnameRE) {
-        return Pattern.compile(archnameRE, Pattern.CASE_INSENSITIVE)
-                .matcher(osArch)
-                .matches();
-    }
-
-    public static String getOsArch() {
-        return osArch;
-    }
-
-    /**
-     * Return a boolean for whether we expect to be able to attach
-     * the SA to our own processes on this system.
-     */
-    public static boolean shouldSAAttach()
-                               throws IOException {
-
-        if (isAix()) {
-            return false;   // SA not implemented.
-        } else if (isLinux()) {
-            return canPtraceAttachLinux();
-        } else if (isOSX()) {
-            return canAttachOSX();
-        } else {
-            // Other platforms expected to work:
-            return true;
-        }
-    }
-
-    /**
-     * On Linux, first check the SELinux boolean "deny_ptrace" and return false
-     * as we expect to be denied if that is "1".
-     */
-    public static boolean canPtraceAttachLinux()
-                               throws IOException {
-
-        // SELinux deny_ptrace:
-        try(RandomAccessFile file = new RandomAccessFile("/sys/fs/selinux/booleans/deny_ptrace", "r")) {
-            if (file.readByte() != '0') {
-                return false;
-            }
-        }
-        catch(FileNotFoundException ex) {
-            // Ignored
-        }
-
-        // YAMA enhanced security ptrace_scope:
-        // 0 - a process can PTRACE_ATTACH to any other process running under the same uid
-        // 1 - restricted ptrace: a process must be a children of the inferior or user is root
-        // 2 - only processes with CAP_SYS_PTRACE may use ptrace or user is root
-        // 3 - no attach: no processes may use ptrace with PTRACE_ATTACH
-
-        try(RandomAccessFile file = new RandomAccessFile("/proc/sys/kernel/yama/ptrace_scope", "r")) {
-            byte yama_scope = file.readByte();
-            if (yama_scope == '3') {
-                return false;
-            }
-
-            if (!userName.equals("root") && yama_scope != '0') {
-                return false;
-            }
-        }
-        catch(FileNotFoundException ex) {
-            // Ignored
-        }
-
-        // Otherwise expect to be permitted:
-        return true;
-    }
-
-    /**
-     * On OSX, expect permission to attach only if we are root.
-     */
-    public static boolean canAttachOSX() {
-        return userName.equals("root");
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/ProcessTools.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,579 +0,0 @@
-/*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.concurrent.CountDownLatch;
-import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.function.Predicate;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib/process}
- */
-@Deprecated
-public final class ProcessTools {
-    private static final class LineForwarder extends StreamPumper.LinePump {
-        private final PrintStream ps;
-        private final String prefix;
-        LineForwarder(String prefix, PrintStream os) {
-            this.ps = os;
-            this.prefix = prefix;
-        }
-        @Override
-        protected void processLine(String line) {
-            ps.println("[" + prefix + "] " + line);
-        }
-    }
-
-    private ProcessTools() {
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * @param name The process name
-     * @param processBuilder The process builder
-     * @return Returns the initialized process
-     * @throws IOException
-     */
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder)
-    throws IOException {
-        return startProcess(name, processBuilder, (Consumer<String>)null);
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * <p>It is possible to monitor the in-streams via the provided {@code consumer}
-     * @param name The process name
-     * @param consumer {@linkplain Consumer} instance to process the in-streams
-     * @param processBuilder The process builder
-     * @return Returns the initialized process
-     * @throws IOException
-     */
-    @SuppressWarnings("overloads")
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder,
-                                       Consumer<String> consumer)
-    throws IOException {
-        try {
-            return startProcess(name, processBuilder, consumer, null, -1, TimeUnit.NANOSECONDS);
-        } catch (InterruptedException | TimeoutException e) {
-            // will never happen
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * <p>
-     * It is possible to wait for the process to get to a warmed-up state
-     * via {@linkplain Predicate} condition on the STDOUT
-     * </p>
-     * @param name The process name
-     * @param processBuilder The process builder
-     * @param linePredicate The {@linkplain Predicate} to use on the STDOUT
-     *                      Used to determine the moment the target app is
-     *                      properly warmed-up.
-     *                      It can be null - in that case the warmup is skipped.
-     * @param timeout The timeout for the warmup waiting; -1 = no wait; 0 = wait forever
-     * @param unit The timeout {@linkplain TimeUnit}
-     * @return Returns the initialized {@linkplain Process}
-     * @throws IOException
-     * @throws InterruptedException
-     * @throws TimeoutException
-     */
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder,
-                                       final Predicate<String> linePredicate,
-                                       long timeout,
-                                       TimeUnit unit)
-    throws IOException, InterruptedException, TimeoutException {
-        return startProcess(name, processBuilder, null, linePredicate, timeout, unit);
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * <p>
-     * It is possible to wait for the process to get to a warmed-up state
-     * via {@linkplain Predicate} condition on the STDOUT and monitor the
-     * in-streams via the provided {@linkplain Consumer}
-     * </p>
-     * @param name The process name
-     * @param processBuilder The process builder
-     * @param lineConsumer  The {@linkplain Consumer} the lines will be forwarded to
-     * @param linePredicate The {@linkplain Predicate} to use on the STDOUT
-     *                      Used to determine the moment the target app is
-     *                      properly warmed-up.
-     *                      It can be null - in that case the warmup is skipped.
-     * @param timeout The timeout for the warmup waiting; -1 = no wait; 0 = wait forever
-     * @param unit The timeout {@linkplain TimeUnit}
-     * @return Returns the initialized {@linkplain Process}
-     * @throws IOException
-     * @throws InterruptedException
-     * @throws TimeoutException
-     */
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder,
-                                       final Consumer<String> lineConsumer,
-                                       final Predicate<String> linePredicate,
-                                       long timeout,
-                                       TimeUnit unit)
-    throws IOException, InterruptedException, TimeoutException {
-        System.out.println("["+name+"]:" + processBuilder.command().stream().collect(Collectors.joining(" ")));
-        Process p = processBuilder.start();
-        StreamPumper stdout = new StreamPumper(p.getInputStream());
-        StreamPumper stderr = new StreamPumper(p.getErrorStream());
-
-        stdout.addPump(new LineForwarder(name, System.out));
-        stderr.addPump(new LineForwarder(name, System.err));
-        if (lineConsumer != null) {
-            StreamPumper.LinePump pump = new StreamPumper.LinePump() {
-                @Override
-                protected void processLine(String line) {
-                    lineConsumer.accept(line);
-                }
-            };
-            stdout.addPump(pump);
-            stderr.addPump(pump);
-        }
-
-
-        CountDownLatch latch = new CountDownLatch(1);
-        if (linePredicate != null) {
-            StreamPumper.LinePump pump = new StreamPumper.LinePump() {
-                @Override
-                protected void processLine(String line) {
-                    if (latch.getCount() > 0 && linePredicate.test(line)) {
-                        latch.countDown();
-                    }
-                }
-            };
-            stdout.addPump(pump);
-            stderr.addPump(pump);
-        } else {
-            latch.countDown();
-        }
-        final Future<Void> stdoutTask = stdout.process();
-        final Future<Void> stderrTask = stderr.process();
-
-        try {
-            if (timeout > -1) {
-                if (timeout == 0) {
-                    latch.await();
-                } else {
-                    if (!latch.await(Utils.adjustTimeout(timeout), unit)) {
-                        throw new TimeoutException();
-                    }
-                }
-            }
-        } catch (TimeoutException | InterruptedException e) {
-            System.err.println("Failed to start a process (thread dump follows)");
-            for(Map.Entry<Thread, StackTraceElement[]> s : Thread.getAllStackTraces().entrySet()) {
-                printStack(s.getKey(), s.getValue());
-            }
-
-            if (p.isAlive()) {
-                p.destroyForcibly();
-            }
-
-            stdoutTask.cancel(true);
-            stderrTask.cancel(true);
-            throw e;
-        }
-
-        return new ProcessImpl(p, stdoutTask, stderrTask);
-    }
-
-    /**
-     * <p>Starts a process from its builder.</p>
-     * <span>The default redirects of STDOUT and STDERR are started</span>
-     * <p>
-     * It is possible to wait for the process to get to a warmed-up state
-     * via {@linkplain Predicate} condition on the STDOUT. The warm-up will
-     * wait indefinitely.
-     * </p>
-     * @param name The process name
-     * @param processBuilder The process builder
-     * @param linePredicate The {@linkplain Predicate} to use on the STDOUT
-     *                      Used to determine the moment the target app is
-     *                      properly warmed-up.
-     *                      It can be null - in that case the warmup is skipped.
-     * @return Returns the initialized {@linkplain Process}
-     * @throws IOException
-     * @throws InterruptedException
-     * @throws TimeoutException
-     */
-    @SuppressWarnings("overloads")
-    public static Process startProcess(String name,
-                                       ProcessBuilder processBuilder,
-                                       final Predicate<String> linePredicate)
-    throws IOException, InterruptedException, TimeoutException {
-        return startProcess(name, processBuilder, linePredicate, 0, TimeUnit.SECONDS);
-    }
-
-    /**
-     * Get the process id of the current running Java process
-     *
-     * @return Process id
-     */
-    public static long getProcessId() {
-        return ProcessHandle.current().pid();
-    }
-
-    /**
-     * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris)
-     *
-     * @return String[] with platform specific arguments, empty if there are
-     *         none
-     */
-    public static String[] getPlatformSpecificVMArgs() {
-        String osName = System.getProperty("os.name");
-        String dataModel = System.getProperty("sun.arch.data.model");
-
-        if (osName.equals("SunOS") && dataModel.equals("64")) {
-            return new String[] { "-d64" };
-        }
-
-        return new String[] {};
-    }
-
-    /**
-     * Create ProcessBuilder using the java launcher from the jdk to be tested,
-     * and with any platform specific arguments prepended.
-     *
-     * @param command Arguments to pass to the java command.
-     * @return The ProcessBuilder instance representing the java command.
-     */
-    public static ProcessBuilder createJavaProcessBuilder(String... command)
-            throws Exception {
-        return createJavaProcessBuilder(false, command);
-    }
-
-    /**
-     * Create ProcessBuilder using the java launcher from the jdk to be tested,
-     * and with any platform specific arguments prepended.
-     *
-     * @param addTestVmAndJavaOptions If true, adds test.vm.opts and test.java.opts
-     *        to the java arguments.
-     * @param command Arguments to pass to the java command.
-     * @return The ProcessBuilder instance representing the java command.
-     */
-    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) throws Exception {
-        String javapath = JDKToolFinder.getJDKTool("java");
-
-        ArrayList<String> args = new ArrayList<>();
-        args.add(javapath);
-        Collections.addAll(args, getPlatformSpecificVMArgs());
-
-        if (addTestVmAndJavaOptions) {
-            // -cp is needed to make sure the same classpath is used whether the test is
-            // run in AgentVM mode or OtherVM mode. It was added to the hotspot version
-            // of this API as part of 8077608. However, for the jdk version it is only
-            // added when addTestVmAndJavaOptions is true in order to minimize
-            // disruption to existing JDK tests, which have yet to be tested with -cp
-            // being added. At some point -cp should always be added to be consistent
-            // with what the hotspot version does.
-            args.add("-cp");
-            args.add(System.getProperty("java.class.path"));
-            Collections.addAll(args, Utils.getTestJavaOpts());
-        }
-
-        Collections.addAll(args, command);
-
-        // Reporting
-        StringBuilder cmdLine = new StringBuilder();
-        for (String cmd : args)
-            cmdLine.append(cmd).append(' ');
-        System.out.println("Command line: [" + cmdLine.toString() + "]");
-
-        return new ProcessBuilder(args.toArray(new String[args.size()]));
-    }
-
-    private static void printStack(Thread t, StackTraceElement[] stack) {
-        System.out.println("\t" +  t +
-                           " stack: (length = " + stack.length + ")");
-        if (t != null) {
-            for (StackTraceElement stack1 : stack) {
-                System.out.println("\t" + stack1);
-            }
-            System.out.println();
-        }
-    }
-
-    /**
-     * Executes a test java process, waits for it to finish and returns the process output.
-     * The default options from jtreg, test.vm.opts and test.java.opts, are added.
-     * The java from the test.jdk is used to execute the command.
-     *
-     * The command line will be like:
-     * {test.jdk}/bin/java {test.vm.opts} {test.java.opts} cmds
-     *
-     * The java process will have exited before this method returns.
-     *
-     * @param cmds User specifed arguments.
-     * @return The output from the process.
-     */
-    public static OutputAnalyzer executeTestJava(String... options) throws Exception {
-        ProcessBuilder pb = createJavaProcessBuilder(Utils.addTestJavaOpts(options));
-        return executeProcess(pb);
-    }
-
-    /**
-     * @deprecated Use executeTestJava instead
-     */
-    public static OutputAnalyzer executeTestJvm(String... options) throws Exception {
-        return executeTestJava(options);
-    }
-
-    /**
-     * Executes a process, waits for it to finish and returns the process output.
-     * The process will have exited before this method returns.
-     * @param pb The ProcessBuilder to execute.
-     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
-     */
-    public static OutputAnalyzer executeProcess(ProcessBuilder pb) throws Exception {
-        return executeProcess(pb, null);
-    }
-
-    /**
-     * Executes a process, pipe some text into its STDIN, waits for it
-     * to finish and returns the process output. The process will have exited
-     * before this method returns.
-     * @param pb The ProcessBuilder to execute.
-     * @param input The text to pipe into STDIN. Can be null.
-     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
-     */
-    public static OutputAnalyzer executeProcess(ProcessBuilder pb, String input)
-            throws Exception {
-        OutputAnalyzer output = null;
-        Process p = null;
-        boolean failed = false;
-        try {
-            p = pb.start();
-            if (input != null) {
-                try (OutputStream os = p.getOutputStream();
-                        PrintStream ps = new PrintStream(os)) {
-                    ps.print(input);
-                    ps.flush();
-                }
-            }
-            output = new OutputAnalyzer(p);
-            p.waitFor();
-
-            return output;
-        } catch (Throwable t) {
-            if (p != null) {
-                p.destroyForcibly().waitFor();
-            }
-
-            failed = true;
-            System.out.println("executeProcess() failed: " + t);
-            throw t;
-        } finally {
-            if (failed) {
-                System.err.println(getProcessLog(pb, output));
-            }
-        }
-    }
-
-    /**
-     * Executes a process, waits for it to finish and returns the process output.
-     *
-     * The process will have exited before this method returns.
-     *
-     * @param cmds The command line to execute.
-     * @return The output from the process.
-     */
-    public static OutputAnalyzer executeProcess(String... cmds) throws Throwable {
-        return executeProcess(new ProcessBuilder(cmds));
-    }
-
-    /**
-     * Used to log command line, stdout, stderr and exit code from an executed process.
-     * @param pb The executed process.
-     * @param output The output from the process.
-     */
-    public static String getProcessLog(ProcessBuilder pb, OutputAnalyzer output) {
-        String stderr = output == null ? "null" : output.getStderr();
-        String stdout = output == null ? "null" : output.getStdout();
-        String exitValue = output == null ? "null": Integer.toString(output.getExitValue());
-        StringBuilder logMsg = new StringBuilder();
-        final String nl = System.getProperty("line.separator");
-        logMsg.append("--- ProcessLog ---" + nl);
-        logMsg.append("cmd: " + getCommandLine(pb) + nl);
-        logMsg.append("exitvalue: " + exitValue + nl);
-        logMsg.append("stderr: " + stderr + nl);
-        logMsg.append("stdout: " + stdout + nl);
-
-        return logMsg.toString();
-    }
-
-    /**
-     * @return The full command line for the ProcessBuilder.
-     */
-    public static String getCommandLine(ProcessBuilder pb) {
-        if (pb == null) {
-            return "null";
-        }
-        StringBuilder cmd = new StringBuilder();
-        for (String s : pb.command()) {
-            cmd.append(s).append(" ");
-        }
-        return cmd.toString().trim();
-    }
-
-    /**
-     * Executes a process, waits for it to finish, prints the process output
-     * to stdout, and returns the process output.
-     *
-     * The process will have exited before this method returns.
-     *
-     * @param cmds The command line to execute.
-     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
-     */
-    public static OutputAnalyzer executeCommand(String... cmds)
-            throws Throwable {
-        String cmdLine = Arrays.stream(cmds).collect(Collectors.joining(" "));
-        System.out.println("Command line: [" + cmdLine + "]");
-        OutputAnalyzer analyzer = ProcessTools.executeProcess(cmds);
-        System.out.println(analyzer.getOutput());
-        return analyzer;
-    }
-
-    /**
-     * Executes a process, waits for it to finish, prints the process output
-     * to stdout and returns the process output.
-     *
-     * The process will have exited before this method returns.
-     *
-     * @param pb The ProcessBuilder to execute.
-     * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
-     */
-    public static OutputAnalyzer executeCommand(ProcessBuilder pb)
-            throws Throwable {
-        String cmdLine = pb.command().stream().collect(Collectors.joining(" "));
-        System.out.println("Command line: [" + cmdLine + "]");
-        OutputAnalyzer analyzer = ProcessTools.executeProcess(pb);
-        System.out.println(analyzer.getOutput());
-        return analyzer;
-    }
-
-    private static class ProcessImpl extends Process {
-
-        private final Process p;
-        private final Future<Void> stdoutTask;
-        private final Future<Void> stderrTask;
-
-        public ProcessImpl(Process p, Future<Void> stdoutTask, Future<Void> stderrTask) {
-            this.p = p;
-            this.stdoutTask = stdoutTask;
-            this.stderrTask = stderrTask;
-        }
-
-        @Override
-        public OutputStream getOutputStream() {
-            return p.getOutputStream();
-        }
-
-        @Override
-        public InputStream getInputStream() {
-            return p.getInputStream();
-        }
-
-        @Override
-        public InputStream getErrorStream() {
-            return p.getErrorStream();
-        }
-
-        @Override
-        public int waitFor() throws InterruptedException {
-            int rslt = p.waitFor();
-            waitForStreams();
-            return rslt;
-        }
-
-        @Override
-        public int exitValue() {
-            return p.exitValue();
-        }
-
-        @Override
-        public void destroy() {
-            p.destroy();
-        }
-
-        @Override
-        public long pid() {
-            return p.pid();
-        }
-
-        @Override
-        public boolean isAlive() {
-            return p.isAlive();
-        }
-
-        @Override
-        public Process destroyForcibly() {
-            return p.destroyForcibly();
-        }
-
-        @Override
-        public boolean waitFor(long timeout, TimeUnit unit) throws InterruptedException {
-            boolean rslt = p.waitFor(timeout, unit);
-            if (rslt) {
-                waitForStreams();
-            }
-            return rslt;
-        }
-
-        private void waitForStreams() throws InterruptedException {
-            try {
-                stdoutTask.get();
-            } catch (ExecutionException e) {
-            }
-            try {
-                stderrTask.get();
-            } catch (ExecutionException e) {
-            }
-        }
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/README.txt	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-These files are copies of the corresponding files in test/lib/testlibrary/ from jdk repo.
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/StreamPumper.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,204 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.Future;
-import java.util.concurrent.FutureTask;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib/process}
- */
-@Deprecated
-public final class StreamPumper implements Runnable {
-
-    private static final int BUF_SIZE = 256;
-
-    /**
-     * Pump will be called by the StreamPumper to process the incoming data
-     */
-    abstract public static class Pump {
-        abstract void register(StreamPumper d);
-    }
-
-    /**
-     * OutputStream -> Pump adapter
-     */
-    final public static class StreamPump extends Pump {
-        private final OutputStream out;
-        public StreamPump(OutputStream out) {
-            this.out = out;
-        }
-
-        @Override
-        void register(StreamPumper sp) {
-            sp.addOutputStream(out);
-        }
-    }
-
-    /**
-     * Used to process the incoming data line-by-line
-     */
-    abstract public static class LinePump extends Pump {
-        @Override
-        final void register(StreamPumper sp) {
-            sp.addLineProcessor(this);
-        }
-
-        abstract protected void processLine(String line);
-    }
-
-    private final InputStream in;
-    private final Set<OutputStream> outStreams = new HashSet<>();
-    private final Set<LinePump> linePumps = new HashSet<>();
-
-    private final AtomicBoolean processing = new AtomicBoolean(false);
-    private final FutureTask<Void> processingTask = new FutureTask<>(this, null);
-
-    public StreamPumper(InputStream in) {
-        this.in = in;
-    }
-
-    /**
-     * Create a StreamPumper that reads from in and writes to out.
-     *
-     * @param in
-     *            The stream to read from.
-     * @param out
-     *            The stream to write to.
-     */
-    public StreamPumper(InputStream in, OutputStream out) {
-        this(in);
-        this.addOutputStream(out);
-    }
-
-    /**
-     * Implements Thread.run(). Continuously read from {@code in} and write to
-     * {@code out} until {@code in} has reached end of stream. Abort on
-     * interruption. Abort on IOExceptions.
-     */
-    @Override
-    public void run() {
-        try (BufferedInputStream is = new BufferedInputStream(in)) {
-            ByteArrayOutputStream lineBos = new ByteArrayOutputStream();
-            byte[] buf = new byte[BUF_SIZE];
-            int len = 0;
-            int linelen = 0;
-
-            while ((len = is.read(buf)) > 0 && !Thread.interrupted()) {
-                for(OutputStream out : outStreams) {
-                    out.write(buf, 0, len);
-                }
-                if (!linePumps.isEmpty()) {
-                    int i = 0;
-                    int lastcrlf = -1;
-                    while (i < len) {
-                        if (buf[i] == '\n' || buf[i] == '\r') {
-                            int bufLinelen = i - lastcrlf - 1;
-                            if (bufLinelen > 0) {
-                                lineBos.write(buf, lastcrlf + 1, bufLinelen);
-                            }
-                            linelen += bufLinelen;
-
-                            if (linelen > 0) {
-                                lineBos.flush();
-                                final String line = lineBos.toString();
-                                linePumps.stream().forEach((lp) -> {
-                                    lp.processLine(line);
-                                });
-                                lineBos.reset();
-                                linelen = 0;
-                            }
-                            lastcrlf = i;
-                        }
-
-                        i++;
-                    }
-                    if (lastcrlf == -1) {
-                        lineBos.write(buf, 0, len);
-                        linelen += len;
-                    } else if (lastcrlf < len - 1) {
-                        lineBos.write(buf, lastcrlf + 1, len - lastcrlf - 1);
-                        linelen += len - lastcrlf - 1;
-                    }
-                }
-            }
-
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            for(OutputStream out : outStreams) {
-                try {
-                    out.flush();
-                } catch (IOException e) {}
-            }
-            try {
-                in.close();
-            } catch (IOException e) {}
-        }
-    }
-
-    final void addOutputStream(OutputStream out) {
-        outStreams.add(out);
-    }
-
-    final void addLineProcessor(LinePump lp) {
-        linePumps.add(lp);
-    }
-
-    final public StreamPumper addPump(Pump ... pump) {
-        if (processing.get()) {
-            throw new IllegalStateException("Can not modify pumper while " +
-                                            "processing is in progress");
-        }
-        for(Pump p : pump) {
-            p.register(this);
-        }
-        return this;
-    }
-
-    final public Future<Void> process() {
-        if (!processing.compareAndSet(false, true)) {
-            throw new IllegalStateException("Can not re-run the processing");
-        }
-        Thread t = new Thread(new Runnable() {
-            @Override
-            public void run() {
-                processingTask.run();
-            }
-        });
-        t.setDaemon(true);
-        t.start();
-
-        return processingTask;
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/libs/jdk/testlibrary/Utils.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,365 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import static jdk.testlibrary.Asserts.assertTrue;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
-import java.util.concurrent.TimeUnit;
-import java.util.function.BooleanSupplier;
-import java.util.function.Function;
-
-/**
- * Common library for various test helper functions.
- *
- * @deprecated This class is deprecated. Use the one from
- *             {@code <root>/test/lib/share/classes/jdk/test/lib}
- */
-@Deprecated
-public final class Utils {
-
-    /**
-     * Returns the sequence used by operating system to separate lines.
-     */
-    public static final String NEW_LINE = System.getProperty("line.separator");
-
-    /**
-     * Returns the value of 'test.vm.opts'system property.
-     */
-    public static final String VM_OPTIONS = System.getProperty("test.vm.opts", "").trim();
-
-    /**
-     * Returns the value of 'test.java.opts'system property.
-     */
-    public static final String JAVA_OPTIONS = System.getProperty("test.java.opts", "").trim();
-
-    /**
-    * Returns the value of 'test.timeout.factor' system property
-    * converted to {@code double}.
-    */
-    public static final double TIMEOUT_FACTOR;
-    static {
-        String toFactor = System.getProperty("test.timeout.factor", "1.0");
-        TIMEOUT_FACTOR = Double.parseDouble(toFactor);
-    }
-
-    /**
-    * Returns the value of JTREG default test timeout in milliseconds
-    * converted to {@code long}.
-    */
-    public static final long DEFAULT_TEST_TIMEOUT = TimeUnit.SECONDS.toMillis(120);
-
-    private Utils() {
-        // Private constructor to prevent class instantiation
-    }
-
-    /**
-     * Returns the list of VM options.
-     *
-     * @return List of VM options
-     */
-    public static List<String> getVmOptions() {
-        return Arrays.asList(safeSplitString(VM_OPTIONS));
-    }
-
-    /**
-     * Returns the list of VM options with -J prefix.
-     *
-     * @return The list of VM options with -J prefix
-     */
-    public static List<String> getForwardVmOptions() {
-        String[] opts = safeSplitString(VM_OPTIONS);
-        for (int i = 0; i < opts.length; i++) {
-            opts[i] = "-J" + opts[i];
-        }
-        return Arrays.asList(opts);
-    }
-
-    /**
-     * Returns the default JTReg arguments for a jvm running a test.
-     * This is the combination of JTReg arguments test.vm.opts and test.java.opts.
-     * @return An array of options, or an empty array if no opptions.
-     */
-    public static String[] getTestJavaOpts() {
-        List<String> opts = new ArrayList<String>();
-        Collections.addAll(opts, safeSplitString(VM_OPTIONS));
-        Collections.addAll(opts, safeSplitString(JAVA_OPTIONS));
-        return opts.toArray(new String[0]);
-    }
-
-    /**
-     * Combines given arguments with default JTReg arguments for a jvm running a test.
-     * This is the combination of JTReg arguments test.vm.opts and test.java.opts
-     * @return The combination of JTReg test java options and user args.
-     */
-    public static String[] addTestJavaOpts(String... userArgs) {
-        List<String> opts = new ArrayList<String>();
-        Collections.addAll(opts, getTestJavaOpts());
-        Collections.addAll(opts, userArgs);
-        return opts.toArray(new String[0]);
-    }
-
-    /**
-     * Removes any options specifying which GC to use, for example "-XX:+UseG1GC".
-     * Removes any options matching: -XX:(+/-)Use*GC
-     * Used when a test need to set its own GC version. Then any
-     * GC specified by the framework must first be removed.
-     * @return A copy of given opts with all GC options removed.
-     */
-    private static final Pattern useGcPattern = Pattern.compile(
-            "(?:\\-XX\\:[\\+\\-]Use.+GC)"
-            + "|(?:\\-Xconcgc)");
-    public static List<String> removeGcOpts(List<String> opts) {
-        List<String> optsWithoutGC = new ArrayList<String>();
-        for (String opt : opts) {
-            if (useGcPattern.matcher(opt).matches()) {
-                System.out.println("removeGcOpts: removed " + opt);
-            } else {
-                optsWithoutGC.add(opt);
-            }
-        }
-        return optsWithoutGC;
-    }
-
-    /**
-     * Splits a string by white space.
-     * Works like String.split(), but returns an empty array
-     * if the string is null or empty.
-     */
-    private static String[] safeSplitString(String s) {
-        if (s == null || s.trim().isEmpty()) {
-            return new String[] {};
-        }
-        return s.trim().split("\\s+");
-    }
-
-    /**
-     * @return The full command line for the ProcessBuilder.
-     */
-    public static String getCommandLine(ProcessBuilder pb) {
-        StringBuilder cmd = new StringBuilder();
-        for (String s : pb.command()) {
-            cmd.append(s).append(" ");
-        }
-        return cmd.toString();
-    }
-
-    /**
-     * Returns the free port on the local host.
-     * The function will spin until a valid port number is found.
-     *
-     * @return The port number
-     * @throws InterruptedException if any thread has interrupted the current thread
-     * @throws IOException if an I/O error occurs when opening the socket
-     */
-    public static int getFreePort() throws InterruptedException, IOException {
-        int port = -1;
-
-        while (port <= 0) {
-            Thread.sleep(100);
-
-            ServerSocket serverSocket = null;
-            try {
-                serverSocket = new ServerSocket(0);
-                port = serverSocket.getLocalPort();
-            } finally {
-                serverSocket.close();
-            }
-        }
-
-        return port;
-    }
-
-    /**
-     * Returns the name of the local host.
-     *
-     * @return The host name
-     * @throws UnknownHostException if IP address of a host could not be determined
-     */
-    public static String getHostname() throws UnknownHostException {
-        InetAddress inetAddress = InetAddress.getLocalHost();
-        String hostName = inetAddress.getHostName();
-
-        assertTrue((hostName != null && !hostName.isEmpty()),
-                "Cannot get hostname");
-
-        return hostName;
-    }
-
-    /**
-     * Uses "jcmd -l" to search for a jvm pid. This function will wait
-     * forever (until jtreg timeout) for the pid to be found.
-     * @param key Regular expression to search for
-     * @return The found pid.
-     */
-    public static int waitForJvmPid(String key) throws Throwable {
-        final long iterationSleepMillis = 250;
-        System.out.println("waitForJvmPid: Waiting for key '" + key + "'");
-        System.out.flush();
-        while (true) {
-            int pid = tryFindJvmPid(key);
-            if (pid >= 0) {
-                return pid;
-            }
-            Thread.sleep(iterationSleepMillis);
-        }
-    }
-
-    /**
-     * Searches for a jvm pid in the output from "jcmd -l".
-     *
-     * Example output from jcmd is:
-     * 12498 sun.tools.jcmd.JCmd -l
-     * 12254 /tmp/jdk8/tl/jdk/JTwork/classes/com/sun/tools/attach/Application.jar
-     *
-     * @param key A regular expression to search for.
-     * @return The found pid, or -1 if Enot found.
-     * @throws Exception If multiple matching jvms are found.
-     */
-    public static int tryFindJvmPid(String key) throws Throwable {
-        OutputAnalyzer output = null;
-        try {
-            JDKToolLauncher jcmdLauncher = JDKToolLauncher.create("jcmd");
-            jcmdLauncher.addToolArg("-l");
-            output = ProcessTools.executeProcess(jcmdLauncher.getCommand());
-            output.shouldHaveExitValue(0);
-
-            // Search for a line starting with numbers (pid), follwed by the key.
-            Pattern pattern = Pattern.compile("([0-9]+)\\s.*(" + key + ").*\\r?\\n");
-            Matcher matcher = pattern.matcher(output.getStdout());
-
-            int pid = -1;
-            if (matcher.find()) {
-                pid = Integer.parseInt(matcher.group(1));
-                System.out.println("findJvmPid.pid: " + pid);
-                if (matcher.find()) {
-                    throw new Exception("Found multiple JVM pids for key: " + key);
-                }
-            }
-            return pid;
-        } catch (Throwable t) {
-            System.out.println(String.format("Utils.findJvmPid(%s) failed: %s", key, t));
-            throw t;
-        }
-    }
-
-    /**
-     * Adjusts the provided timeout value for the TIMEOUT_FACTOR
-     * @param tOut the timeout value to be adjusted
-     * @return The timeout value adjusted for the value of "test.timeout.factor"
-     *         system property
-     */
-    public static long adjustTimeout(long tOut) {
-        return Math.round(tOut * Utils.TIMEOUT_FACTOR);
-    }
-
-    /**
-     * Wait for condition to be true
-     *
-     * @param condition, a condition to wait for
-     */
-    public static final void waitForCondition(BooleanSupplier condition) {
-        waitForCondition(condition, -1L, 100L);
-    }
-
-    /**
-     * Wait until timeout for condition to be true
-     *
-     * @param condition, a condition to wait for
-     * @param timeout a time in milliseconds to wait for condition to be true
-     * specifying -1 will wait forever
-     * @return condition value, to determine if wait was successfull
-     */
-    public static final boolean waitForCondition(BooleanSupplier condition,
-            long timeout) {
-        return waitForCondition(condition, timeout, 100L);
-    }
-
-    /**
-     * Wait until timeout for condition to be true for specified time
-     *
-     * @param condition, a condition to wait for
-     * @param timeout a time in milliseconds to wait for condition to be true,
-     * specifying -1 will wait forever
-     * @param sleepTime a time to sleep value in milliseconds
-     * @return condition value, to determine if wait was successfull
-     */
-    public static final boolean waitForCondition(BooleanSupplier condition,
-            long timeout, long sleepTime) {
-        long startTime = System.currentTimeMillis();
-        while (!(condition.getAsBoolean() || (timeout != -1L
-                && ((System.currentTimeMillis() - startTime) > timeout)))) {
-            try {
-                Thread.sleep(sleepTime);
-            } catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
-                throw new Error(e);
-            }
-        }
-        return condition.getAsBoolean();
-    }
-
-    /**
-     * Interface same as java.lang.Runnable but with
-     * method {@code run()} able to throw any Throwable.
-     */
-    public static interface ThrowingRunnable {
-        void run() throws Throwable;
-    }
-
-    /**
-     * Filters out an exception that may be thrown by the given
-     * test according to the given filter.
-     *
-     * @param test - method that is invoked and checked for exception.
-     * @param filter - function that checks if the thrown exception matches
-     *                 criteria given in the filter's implementation.
-     * @return - exception that matches the filter if it has been thrown or
-     *           {@code null} otherwise.
-     * @throws Throwable - if test has thrown an exception that does not
-     *                     match the filter.
-     */
-    public static Throwable filterException(ThrowingRunnable test,
-            Function<Throwable, Boolean> filter) throws Throwable {
-        try {
-            test.run();
-        } catch (Throwable t) {
-            if (filter.apply(t)) {
-                return t;
-            } else {
-                throw t;
-            }
-        }
-        return null;
-    }
-}
--- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/BasicModularXMLParserTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -27,16 +27,15 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
-import static jdk.testlibrary.ProcessTools.executeTestJava;
-import jdk.testlibrary.CompilerUtils;
+import static jdk.test.lib.process.ProcessTools.executeTestJava;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
 /*
  * @test
- * @library /javax/xml/jaxp/libs
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run testng BasicModularXMLParserTest
  * @bug 8078820 8156119
  * @summary Tests JAXP lib can instantiate the following interfaces
--- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/LayerModularXMLParserTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -40,12 +40,11 @@
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
-import jdk.testlibrary.CompilerUtils;
+import jdk.test.lib.compiler.CompilerUtils;
 
 /*
  * @test
- * @library /javax/xml/jaxp/libs
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run testng LayerModularXMLParserTest
  * @bug 8078820 8156119
  * @summary Tests JAXP lib works with layer and TCCL
--- a/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/XMLReaderFactoryTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jaxp/test/javax/xml/jaxp/module/ServiceProviderTest/XMLReaderFactoryTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -31,7 +31,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
-import jdk.testlibrary.CompilerUtils;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.Assert;
 import org.testng.annotations.BeforeTest;
@@ -41,8 +41,7 @@
 
 /*
  * @test
- * @library /javax/xml/jaxp/libs
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run testng XMLReaderFactoryTest
  * @bug 8152912 8015099 8156119
  * @summary Tests XMLReaderFactory can work as ServiceLoader compliant, as well as backward compatible
--- a/jaxws/.hgtags	Wed Jul 05 23:35:20 2017 +0200
+++ b/jaxws/.hgtags	Wed Jul 05 23:37:13 2017 +0200
@@ -399,9 +399,11 @@
 c48b4d4768b1c2b8fe5d1a844ca13732e5dfbe2a jdk-9+151
 6f8fb1cf7e5f61c40dcc3654f9a623c505f6de1f jdk-9+152
 7a532a9a227137155b905341d4b99939db51220e jdk-9+153
+34af95c7dbff74f3448fcdb7d745524e8a1cc88a jdk-10+0
 34af95c7dbff74f3448fcdb7d745524e8a1cc88a jdk-9+154
 9b9918656c97724fd89c04a8547043bbd37f5935 jdk-9+155
 7c829eba781409b4fe15392639289af1553dcf63 jdk-9+156
+6afc1d9b8c41457cc8ebe2e1a27b8fd6d887c1fb jdk-10+1
 b7e70e1e0154e1d2c69f814e03a8800ef8634fe0 jdk-9+157
 e53b322357382209fb553b9a1541ccfd12cbcb6c jdk-9+158
 0ea34706c7fa5cd71accd493eb4f54262e4a5f4e jdk-9+159
@@ -412,5 +414,18 @@
 1a52de2da827459e866fd736f9e9c62eb2ecd6bb jdk-9+164
 a987401bac0d528475e57732c9d5d93f4405804c jdk-9+165
 b1f30c27367bd286fa4eb8a767335e917a5b5b82 jdk-9+166
+06b9f0de66d3a17a10af380c950619c63b62d4cd jdk-10+2
+2e2c78f1713b2c6b760b870946d2b4341a1522e3 jdk-10+3
+ac7e572a6a6ba5bbd7e6aa94a289f88cc86256a4 jdk-10+4
+879aad463c21065254918629e6dfd7d7bf98adb2 jdk-10+5
+85e15cdc75aaaea8a1bb00563af7889869d3e602 jdk-10+6
 1c610f1b4097c64cdd722a7fb59f5a4d9cc15ca9 jdk-9+167
 2746716dcc5a8c28ccf41df0c8fb620b1a1e7098 jdk-9+168
+912cf69806d518c5af7fba30b340c4cb5458dd22 jdk-9+169
+e75d3abe579a7b39b762fc0a1a337c49eb072d82 jdk-9+170
+b0efae7df1dfa14926058baebaf999e4268c955c jdk-10+7
+e705867d9989d00e4357f66f18b302c95e13b5e7 jdk-10+8
+2fe03e35bed54238bcaeeb298b011df240e3711d jdk-10+9
+139e7c786ee4885efe53eb650b72c7b5a2d3b964 jdk-9+171
+3ccd9f37faa601866db5edb827363e797f5a2493 jdk-10+10
+8c615099f3e3ca137325be34bf566b767d9e3c64 jdk-9+172
--- a/jaxws/.jcheck/conf	Wed Jul 05 23:35:20 2017 +0200
+++ b/jaxws/.jcheck/conf	Wed Jul 05 23:37:13 2017 +0200
@@ -1,1 +1,1 @@
-project=jdk9
+project=jdk10
--- a/jdk/.hgtags	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/.hgtags	Wed Jul 05 23:37:13 2017 +0200
@@ -396,9 +396,11 @@
 d27bab22ff62823902d93d1d35ca397cfd50d059 jdk-9+151
 a20f2cf90762673e1bc4980fd6597e70a2578045 jdk-9+152
 1c4411322327aea3f91011ec3977a12a05b09629 jdk-9+153
+f2325d80b37c2817e15039bf64189a08e29c6d39 jdk-10+0
 c97e7a8b8da062b9070df442f9cf308e10845fb7 jdk-9+154
 e170c858888e83d5c0994504599b6ed7a1fb0cfc jdk-9+155
 7d64e541a6c04c714bcad4c8b553db912f827cd5 jdk-9+156
+e209a98d40a1c353199285f31ca0ff6f0d68264a jdk-10+1
 fdfa7b2fe9a7db06792eae20f97748f3e85bb83a jdk-9+157
 c476ca73750698fa5654e101af699ee45db38e2a jdk-9+158
 49b54a4d9e84b7ba956b8c27fced5035465146ae jdk-9+159
@@ -409,8 +411,18 @@
 6dea581453d7c0e767e3169cfec8b423a381e71d jdk-9+164
 a7942c3b1e59495dbf51dc7c41aab355fcd253d7 jdk-9+165
 5d2b48f1f0a322aca719b49ff02ab421705bffc7 jdk-9+166
+5adecda6cf9a5623f983ea29e5511755ccfd1273 jdk-10+2
+4723e1d233195e253f018e8a46732c7ffbe6ce90 jdk-10+3
+37f8b938b680cf8fb551e9a48bffc5536b061fa8 jdk-10+4
+d1436b2945383cef15edbdba9bb41ef1656c987b jdk-10+5
+329609d00aef2443cf1e44ded94637c5ed55a143 jdk-10+6
 7828aedcb525df40b7c8122bcc3f997c75ebaf7f jdk-9+167
 e78da9db6299b3fcba49300d52e2359e82fdd218 jdk-9+168
 177436a54ca13730ffc725a6e5dbfcd9486f3da3 jdk-9+169
 ef9954f6896bb0b95ac62bf769f68b59a7a56ccd jdk-9+170
+cbd65760a005766610583949b3b5c9ace92e74b3 jdk-10+7
+f0adc10ed8316e6cf316e3208c5ecf6835d22bc4 jdk-10+8
+b9409a7daa6c793dd631e52fe6ef79d08a3b337a jdk-10+9
 29bbedd4cce8e14742bdb22118c057b877c02f0f jdk-9+171
+df64bd4757d0d130d62a22b8143ba31d3a16ac18 jdk-10+10
+0ff9ad7d067cd4fa14450cf208bf019175a0aaba jdk-9+172
--- a/jdk/.jcheck/conf	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/.jcheck/conf	Wed Jul 05 23:37:13 2017 +0200
@@ -1,1 +1,1 @@
-project=jdk9
+project=jdk10
--- a/jdk/make/launcher/Launcher-java.base.gmk	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/make/launcher/Launcher-java.base.gmk	Wed Jul 05 23:37:13 2017 +0200
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/aix/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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();
+    }
+}
--- a/jdk/src/java.base/aix/classes/sun/nio/ch/DefaultSelectorProvider.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/aix/classes/sun/nio/ch/DefaultSelectorProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,6 @@
      * Returns the default SelectorProvider.
      */
     public static SelectorProvider create() {
-        return new sun.nio.ch.PollSelectorProvider();
+        return new PollSelectorProvider();
     }
-
 }
--- a/jdk/src/java.base/aix/native/libnet/aix_close.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/aix/native/libnet/aix_close.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2016, SAP SE and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, SAP SE and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,6 +65,8 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/poll.h>
+#include "jvm.h"
+#include "net_util.h"
 
 /*
  * Stack allocated by thread when doing blocking operation
@@ -503,9 +505,9 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout0(int s, long timeout, long currentTime) {
-    long prevtime = currentTime, newtime;
-    struct timeval t;
+int NET_Timeout(JNIEnv *env, int s, long timeout, jlong nanoTimeStamp) {
+    jlong prevNanoTime = nanoTimeStamp;
+    jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
     fdEntry_t *fdEntry = getFdEntry(s);
 
     /*
@@ -529,7 +531,7 @@
         pfd.events = POLLIN | POLLERR;
 
         startOp(fdEntry, &self);
-        rv = poll(&pfd, 1, timeout);
+        rv = poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
         endOp(fdEntry, &self);
 
         /*
@@ -537,18 +539,14 @@
          * has expired return 0 (indicating timeout expired).
          */
         if (rv < 0 && errno == EINTR) {
-            if (timeout > 0) {
-                gettimeofday(&t, NULL);
-                newtime = t.tv_sec * 1000  +  t.tv_usec / 1000;
-                timeout -= newtime - prevtime;
-                if (timeout <= 0) {
-                    return 0;
-                }
-                prevtime = newtime;
+            jlong newNanoTime = JVM_NanoTime(env, 0);
+            nanoTimeout -= newNanoTime - prevNanoTime;
+            if (nanoTimeout < NET_NSEC_PER_MSEC) {
+                return 0;
             }
+            prevNanoTime = newNanoTime;
         } else {
             return rv;
         }
-
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/linux/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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();
+    }
+}
--- a/jdk/src/java.base/linux/classes/sun/nio/ch/DefaultSelectorProvider.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/linux/classes/sun/nio/ch/DefaultSelectorProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,6 @@
      * Returns the default SelectorProvider.
      */
     public static SelectorProvider create() {
-        return new sun.nio.ch.EPollSelectorProvider();
+        return new EPollSelectorProvider();
     }
-
 }
--- a/jdk/src/java.base/linux/native/libnet/linux_close.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/linux/native/libnet/linux_close.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,6 +37,8 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/poll.h>
+#include "jvm.h"
+#include "net_util.h"
 
 /*
  * Stack allocated by thread when doing blocking operation
@@ -410,9 +412,9 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout0(int s, long timeout, long currentTime) {
-    long prevtime = currentTime, newtime;
-    struct timeval t;
+int NET_Timeout(JNIEnv *env, int s, long timeout, jlong nanoTimeStamp) {
+    jlong prevNanoTime = nanoTimeStamp;
+    jlong nanoTimeout = (jlong)timeout * NET_NSEC_PER_MSEC;
     fdEntry_t *fdEntry = getFdEntry(s);
 
     /*
@@ -436,26 +438,21 @@
         pfd.events = POLLIN | POLLERR;
 
         startOp(fdEntry, &self);
-        rv = poll(&pfd, 1, timeout);
+        rv = poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
         endOp(fdEntry, &self);
-
         /*
          * If interrupted then adjust timeout. If timeout
          * has expired return 0 (indicating timeout expired).
          */
         if (rv < 0 && errno == EINTR) {
-            if (timeout > 0) {
-                gettimeofday(&t, NULL);
-                newtime = t.tv_sec * 1000  +  t.tv_usec / 1000;
-                timeout -= newtime - prevtime;
-                if (timeout <= 0) {
-                    return 0;
-                }
-                prevtime = newtime;
+            jlong newNanoTime = JVM_NanoTime(env, 0);
+            nanoTimeout -= newNanoTime - prevNanoTime;
+            if (nanoTimeout < NET_NSEC_PER_MSEC) {
+                return 0;
             }
+            prevNanoTime = newNanoTime;
         } else {
             return rv;
         }
-
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/macosx/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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();
+    }
+}
--- a/jdk/src/java.base/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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();
     }
-
 }
--- a/jdk/src/java.base/macosx/native/launcher/jexec.c	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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);
-}
--- a/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -136,8 +136,7 @@
  *  |
  * \|/
  * ParseArguments
- * (removes -d32 and -d64 if any,
- *  processes version options,
+ * (processes version options,
  *  creates argument list for vm,
  *  etc.)
  *   |
@@ -147,20 +146,20 @@
  *   |
  *   |
  *  \|/
- * Path is desired JRE ? YES --> Have Desired Model ? NO --> Re-exec --> Main
- *  NO                               YES --> Continue
+ * Path is desired JRE ? YES --> Continue
+ *  NO
  *   |
  *   |
  *  \|/
  * Paths have well known
- * jvm paths ?       --> NO --> Have Desired Model ? NO --> Re-exec --> Main
- *  YES                              YES --> Continue
+ * jvm paths ?       --> NO --> Continue
+ *  YES
  *   |
  *   |
  *  \|/
  *  Does libjvm.so exist
- *  in any of them ? --> NO --> Have Desired Model ? NO --> Re-exec --> Main
- *   YES                             YES --> Continue
+ *  in any of them ? --> NO --> Continue
+ *   YES
  *   |
  *   |
  *  \|/
@@ -217,7 +216,7 @@
     }
 
     char jvmPath[PATH_MAX];
-    jboolean gotJVMPath = GetJVMPath(jrePath, preferredJVM, jvmPath, sizeof(jvmPath), CURRENT_DATA_MODEL);
+    jboolean gotJVMPath = GetJVMPath(jrePath, preferredJVM, jvmPath, sizeof(jvmPath));
     if (!gotJVMPath) {
         JLI_ReportErrorMessage("Failed to GetJVMPath()");
         return NULL;
@@ -362,203 +361,51 @@
                            char jrepath[], jint so_jrepath,
                            char jvmpath[], jint so_jvmpath,
                            char jvmcfg[],  jint so_jvmcfg) {
-  /*
-   * First, determine if we are running the desired data model.  If we
-   * are running the desired data model, all the error messages
-   * associated with calling GetJREPath, ReadKnownVMs, etc. should be
-   * output.  However, if we are not running the desired data model,
-   * some of the errors should be suppressed since it is more
-   * informative to issue an error message based on whether or not the
-   * os/processor combination has dual mode capabilities.
-   */
     jboolean jvmpathExists;
 
     /* Compute/set the name of the executable */
     SetExecname(*pargv);
 
-    /* Check data model flags, and exec process, if needed */
-    {
-      char * jvmtype    = NULL;
-      int  argc         = *pargc;
-      char **argv       = *pargv;
-      int running       = CURRENT_DATA_MODEL;
-
-      int wanted        = running;      /* What data mode is being
-                                           asked for? Current model is
-                                           fine unless another model
-                                           is asked for */
-
-      char** newargv    = NULL;
-      int    newargc    = 0;
-
-      /*
-       * Starting in 1.5, all unix platforms accept the -d32 and -d64
-       * options.  On platforms where only one data-model is supported
-       * (e.g. ia-64 Linux), using the flag for the other data model is
-       * an error and will terminate the program.
-       */
-
-      { /* open new scope to declare local variables */
-        int i;
-
-        newargv = (char **)JLI_MemAlloc((argc+1) * sizeof(char*));
-        newargv[newargc++] = argv[0];
-
-        /* scan for data model arguments and remove from argument list;
-           last occurrence determines desired data model */
-        for (i=1; i < argc; i++) {
-
-          if (JLI_StrCmp(argv[i], "-J-d64") == 0 || JLI_StrCmp(argv[i], "-d64") == 0) {
-            wanted = 64;
-            continue;
-          }
-          if (JLI_StrCmp(argv[i], "-J-d32") == 0 || JLI_StrCmp(argv[i], "-d32") == 0) {
-            wanted = 32;
-            continue;
-          }
-          newargv[newargc++] = argv[i];
-
-          if (IsJavaArgs()) {
-            if (argv[i][0] != '-') continue;
-          } else {
-            if (JLI_StrCmp(argv[i], "-classpath") == 0 || JLI_StrCmp(argv[i], "-cp") == 0) {
-              i++;
-              if (i >= argc) break;
-              newargv[newargc++] = argv[i];
-              continue;
-            }
-            if (argv[i][0] != '-') { i++; break; }
-          }
-        }
-
-        /* copy rest of args [i .. argc) */
-        while (i < argc) {
-          newargv[newargc++] = argv[i++];
-        }
-        newargv[newargc] = NULL;
-
-        /*
-         * newargv has all proper arguments here
-         */
-
-        argc = newargc;
-        argv = newargv;
-      }
-
-      /* If the data model is not changing, it is an error if the
-         jvmpath does not exist */
-      if (wanted == running) {
-        /* Find out where the JRE is that we will be using. */
-        if (!GetJREPath(jrepath, so_jrepath, JNI_FALSE) ) {
-          JLI_ReportErrorMessage(JRE_ERROR1);
-          exit(2);
-        }
-        JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%s%s%sjvm.cfg",
-          jrepath, FILESEP, FILESEP,  "", "");
-        /* Find the specified JVM type */
-        if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) {
-          JLI_ReportErrorMessage(CFG_ERROR7);
-          exit(1);
-        }
+    char * jvmtype    = NULL;
+    int  argc         = *pargc;
+    char **argv       = *pargv;
 
-        jvmpath[0] = '\0';
-        jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE);
-        if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
-            JLI_ReportErrorMessage(CFG_ERROR9);
-            exit(4);
-        }
-
-        if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, wanted)) {
-          JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
-          exit(4);
-        }
-
-        /*
-         * Mac OS X requires the Cocoa event loop to be run on the "main"
-         * thread. Spawn off a new thread to run main() and pass
-         * this thread off to the Cocoa event loop.
-         */
-        MacOSXStartup(argc, argv);
-
-        /*
-         * we seem to have everything we need, so without further ado
-         * we return back, otherwise proceed to set the environment.
-         */
-        return;
-      } else {  /* do the same speculatively or exit */
-#if defined(DUAL_MODE)
-        if (running != wanted) {
-          /* Find out where the JRE is that we will be using. */
-          if (!GetJREPath(jrepath, so_jrepath, JNI_TRUE)) {
-            /* give up and let other code report error message */
-            JLI_ReportErrorMessage(JRE_ERROR2, wanted);
-            exit(1);
-          }
-          JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%s%s%sjvm.cfg",
-            jrepath, FILESEP, FILESEP,  "", "");
-          /*
-           * Read in jvm.cfg for target data model and process vm
-           * selection options.
-           */
-          if (ReadKnownVMs(jvmcfg, JNI_TRUE) < 1) {
-            /* give up and let other code report error message */
-            JLI_ReportErrorMessage(JRE_ERROR2, wanted);
-            exit(1);
-          }
-          jvmpath[0] = '\0';
-          jvmtype = CheckJvmType(pargc, pargv, JNI_TRUE);
-          if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
-            JLI_ReportErrorMessage(CFG_ERROR9);
-            exit(4);
-          }
-
-          /* exec child can do error checking on the existence of the path */
-          jvmpathExists = GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, wanted);
-        }
-#else /* ! DUAL_MODE */
-        JLI_ReportErrorMessage(JRE_ERROR2, wanted);
-        exit(1);
-#endif /* DUAL_MODE */
-        }
-        {
-            char *newexec = execname;
-            JLI_TraceLauncher("TRACER_MARKER:About to EXEC\n");
-            (void) fflush(stdout);
-            (void) fflush(stderr);
-            /*
-            * Use posix_spawn() instead of execv() on Mac OS X.
-            * This allows us to choose which architecture the child process
-            * should run as.
-            */
-            {
-                posix_spawnattr_t attr;
-                size_t unused_size;
-                pid_t  unused_pid;
-
-#if defined(__i386__) || defined(__x86_64__)
-                cpu_type_t cpu_type[] = { (wanted == 64) ? CPU_TYPE_X86_64 : CPU_TYPE_X86,
-                                    (running== 64) ? CPU_TYPE_X86_64 : CPU_TYPE_X86 };
-#else
-                cpu_type_t cpu_type[] = { CPU_TYPE_ANY };
-#endif /* __i386 .. */
-
-                posix_spawnattr_init(&attr);
-                posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETEXEC);
-                posix_spawnattr_setbinpref_np(&attr, sizeof(cpu_type) / sizeof(cpu_type_t),
-                                            cpu_type, &unused_size);
-
-                posix_spawn(&unused_pid, newexec, NULL, &attr, argv, environ);
-            }
-            JLI_ReportErrorMessageSys(JRE_ERROR4, newexec);
-
-#if defined(DUAL_MODE)
-            if (running != wanted) {
-                JLI_ReportErrorMessage(JRE_ERROR5, wanted, running);
-            }
-#endif /* DUAL_MODE */
-        }
+    /* Find out where the JRE is that we will be using. */
+    if (!GetJREPath(jrepath, so_jrepath, JNI_FALSE) ) {
+        JLI_ReportErrorMessage(JRE_ERROR1);
+        exit(2);
+    }
+    JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%sjvm.cfg",
+                 jrepath, FILESEP, FILESEP);
+    /* Find the specified JVM type */
+    if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) {
+        JLI_ReportErrorMessage(CFG_ERROR7);
         exit(1);
     }
+
+    jvmpath[0] = '\0';
+    jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE);
+    if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
+        JLI_ReportErrorMessage(CFG_ERROR9);
+        exit(4);
+    }
+
+    if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) {
+        JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
+        exit(4);
+    }
+
+    /*
+     * Mac OS X requires the Cocoa event loop to be run on the "main"
+     * thread. Spawn off a new thread to run main() and pass
+     * this thread off to the Cocoa event loop.
+     */
+    MacOSXStartup(argc, argv);
+
+    /*
+     * we seem to have everything we need
+     */
+    return;
 }
 
 /*
@@ -566,7 +413,7 @@
  */
 static jboolean
 GetJVMPath(const char *jrepath, const char *jvmtype,
-           char *jvmpath, jint jvmpathsize, int bitsWanted)
+           char *jvmpath, jint jvmpathsize)
 {
     struct stat s;
 
@@ -577,8 +424,7 @@
          * macosx client library is built thin, i386 only.
          * 64 bit client requests must load server library
          */
-        const char *jvmtypeUsed = ((bitsWanted == 64) && (strcmp(jvmtype, "client") == 0)) ? "server" : jvmtype;
-        JLI_Snprintf(jvmpath, jvmpathsize, "%s/lib/%s/" JVM_DLL, jrepath, jvmtypeUsed);
+        JLI_Snprintf(jvmpath, jvmpathsize, "%s/lib/%s/" JVM_DLL, jrepath, jvmtype);
     }
 
     JLI_TraceLauncher("Does `%s' exist ... ", jvmpath);
--- a/jdk/src/java.base/macosx/native/libnet/bsd_close.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/macosx/native/libnet/bsd_close.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,6 +39,8 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/poll.h>
+#include "jvm.h"
+#include "net_util.h"
 
 /*
  * Stack allocated by thread when doing blocking operation
@@ -414,8 +416,7 @@
  * Auto restarts with adjusted timeout if interrupted by
  * signal other than our wakeup signal.
  */
-int NET_Timeout0(int s, long timeout, long currentTime) {
-    long prevtime = currentTime, newtime;
+int NET_Timeout(JNIEnv *env, int s, long timeout, jlong nanoTimeStamp) {
     struct timeval t, *tp = &t;
     fd_set fds;
     fd_set* fdsp = NULL;
@@ -460,6 +461,8 @@
     }
     FD_SET(s, fdsp);
 
+    jlong prevNanoTime = nanoTimeStamp;
+    jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
     for(;;) {
         int rv;
 
@@ -477,25 +480,21 @@
          * has expired return 0 (indicating timeout expired).
          */
         if (rv < 0 && errno == EINTR) {
-            if (timeout > 0) {
-                struct timeval now;
-                gettimeofday(&now, NULL);
-                newtime = now.tv_sec * 1000  +  now.tv_usec / 1000;
-                timeout -= newtime - prevtime;
-                if (timeout <= 0) {
-                    if (allocated != 0)
-                        free(fdsp);
-                    return 0;
-                }
-                prevtime = newtime;
-                t.tv_sec = timeout / 1000;
-                t.tv_usec = (timeout % 1000) * 1000;
+            jlong newNanoTime = JVM_NanoTime(env, 0);
+            nanoTimeout -= newNanoTime - prevNanoTime;
+            if (nanoTimeout < NET_NSEC_PER_MSEC) {
+                if (allocated != 0)
+                    free(fdsp);
+                return 0;
             }
+            prevNanoTime = newNanoTime;
+            t.tv_sec = nanoTimeout / NET_NSEC_PER_SEC;
+            t.tv_usec = (nanoTimeout % NET_NSEC_PER_SEC) / NET_NSEC_PER_USEC;
+
         } else {
             if (allocated != 0)
                 free(fdsp);
             return rv;
         }
-
     }
 }
--- a/jdk/src/java.base/share/classes/java/lang/Class.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/Class.java	Wed Jul 05 23:37:13 2017 +0200
@@ -2880,19 +2880,19 @@
         static <T> boolean casReflectionData(Class<?> clazz,
                                              SoftReference<ReflectionData<T>> oldData,
                                              SoftReference<ReflectionData<T>> newData) {
-            return unsafe.compareAndSwapObject(clazz, reflectionDataOffset, oldData, newData);
+            return unsafe.compareAndSetObject(clazz, reflectionDataOffset, oldData, newData);
         }
 
         static <T> boolean casAnnotationType(Class<?> clazz,
                                              AnnotationType oldType,
                                              AnnotationType newType) {
-            return unsafe.compareAndSwapObject(clazz, annotationTypeOffset, oldType, newType);
+            return unsafe.compareAndSetObject(clazz, annotationTypeOffset, oldType, newType);
         }
 
         static <T> boolean casAnnotationData(Class<?> clazz,
                                              AnnotationData oldData,
                                              AnnotationData newData) {
-            return unsafe.compareAndSwapObject(clazz, annotationDataOffset, oldData, newData);
+            return unsafe.compareAndSetObject(clazz, annotationDataOffset, oldData, newData);
         }
     }
 
--- a/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/ClassLoader.java	Wed Jul 05 23:37:13 2017 +0200
@@ -2884,7 +2884,7 @@
         } catch (NoSuchFieldException e) {
             throw new InternalError(e);
         }
-        return unsafe.compareAndSwapObject(this, offset, null, obj);
+        return unsafe.compareAndSetObject(this, offset, null, obj);
     }
 }
 
--- a/jdk/src/java.base/share/classes/java/lang/Math.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/Math.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1442,8 +1442,8 @@
     }
 
     // Use raw bit-wise conversions on guaranteed non-NaN arguments.
-    private static long negativeZeroFloatBits  = Float.floatToRawIntBits(-0.0f);
-    private static long negativeZeroDoubleBits = Double.doubleToRawLongBits(-0.0d);
+    private static final long negativeZeroFloatBits  = Float.floatToRawIntBits(-0.0f);
+    private static final long negativeZeroDoubleBits = Double.doubleToRawLongBits(-0.0d);
 
     /**
      * Returns the greater of two {@code float} values.  That is,
--- a/jdk/src/java.base/share/classes/java/lang/StringCoding.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/StringCoding.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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();
--- a/jdk/src/java.base/share/classes/java/lang/System.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/System.java	Wed Jul 05 23:37:13 2017 +0200
@@ -534,6 +534,8 @@
      * @param x object for which the hashCode is to be calculated
      * @return  the hashCode
      * @since   1.1
+     * @see Object#hashCode
+     * @see java.util.Objects#hashCode(Object)
      */
     @HotSpotIntrinsicCandidate
     public static native int identityHashCode(Object x);
--- a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
             }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
         }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
         }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
     }
 
--- a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
         }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
+    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);
+        }
+    }
+
+    String lambdaName() {
+        if (DEBUG_NAMES != null) {
+            synchronized (DEBUG_NAMES) {
+                String name = DEBUG_NAMES.get(this);
+                if (name == null) {
+                    name = generateDebugName();
+                }
+                return name;
             }
-            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();
         }
-        return debugName;
+        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 {
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormBuffer.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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) {
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MemberName.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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.
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
+
+    /* 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;
 
-    static {
+    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);
     }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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) {
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodType.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -125,7 +125,7 @@
 
         @ForceInline
         static boolean compareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            return UNSAFE.compareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.compareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -133,7 +133,7 @@
 
         @ForceInline
         static $type$ compareAndExchange(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            return UNSAFE.compareAndExchange$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.compareAndExchange$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -157,7 +157,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetPlain(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.weakCompareAndSet$Type$Plain(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -165,7 +165,7 @@
 
         @ForceInline
         static boolean weakCompareAndSet(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.weakCompareAndSet$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -173,7 +173,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetAcquire(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.weakCompareAndSet$Type$Acquire(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -181,7 +181,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetRelease(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
+            return UNSAFE.weakCompareAndSet$Type$Release(Objects.requireNonNull(handle.receiverType.cast(holder)),
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -275,7 +275,7 @@
                                        handle.fieldOffset,
                                        value);
         }
-        
+
         @ForceInline
         static $type$ getAndBitwiseXor(FieldInstanceReadWrite handle, Object holder, $type$ value) {
             return UNSAFE.getAndBitwiseXor$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)),
@@ -392,7 +392,7 @@
 
         @ForceInline
         static boolean compareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            return UNSAFE.compareAndSwap$Type$(handle.base,
+            return UNSAFE.compareAndSet$Type$(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -401,7 +401,7 @@
 
         @ForceInline
         static $type$ compareAndExchange(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            return UNSAFE.compareAndExchange$Type$Volatile(handle.base,
+            return UNSAFE.compareAndExchange$Type$(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -425,7 +425,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetPlain(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$(handle.base,
+            return UNSAFE.weakCompareAndSet$Type$Plain(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -433,7 +433,7 @@
 
         @ForceInline
         static boolean weakCompareAndSet(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$Volatile(handle.base,
+            return UNSAFE.weakCompareAndSet$Type$(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -441,7 +441,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetAcquire(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$Acquire(handle.base,
+            return UNSAFE.weakCompareAndSet$Type$Acquire(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -449,7 +449,7 @@
 
         @ForceInline
         static boolean weakCompareAndSetRelease(FieldStaticReadWrite handle, $type$ expected, $type$ value) {
-            return UNSAFE.weakCompareAndSwap$Type$Release(handle.base,
+            return UNSAFE.weakCompareAndSet$Type$Release(handle.base,
                                                handle.fieldOffset,
                                                {#if[Object]?handle.fieldType.cast(expected):expected},
                                                {#if[Object]?handle.fieldType.cast(value):value});
@@ -689,7 +689,7 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            return UNSAFE.compareAndSwap$Type$(array,
+            return UNSAFE.compareAndSet$Type$(array,
                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
@@ -702,7 +702,7 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            return UNSAFE.compareAndExchange$Type$Volatile(array,
+            return UNSAFE.compareAndExchange$Type$(array,
                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
@@ -741,7 +741,7 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            return UNSAFE.weakCompareAndSwap$Type$(array,
+            return UNSAFE.weakCompareAndSet$Type$Plain(array,
                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
@@ -754,7 +754,7 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            return UNSAFE.weakCompareAndSwap$Type$Volatile(array,
+            return UNSAFE.weakCompareAndSet$Type$(array,
                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
@@ -767,7 +767,7 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            return UNSAFE.weakCompareAndSwap$Type$Acquire(array,
+            return UNSAFE.weakCompareAndSet$Type$Acquire(array,
                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
@@ -780,7 +780,7 @@
 #else[Object]
             $type$[] array = ($type$[]) oarray;
 #end[Object]
-            return UNSAFE.weakCompareAndSwap$Type$Release(array,
+            return UNSAFE.weakCompareAndSet$Type$Release(array,
                     (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                     {#if[Object]?handle.componentType.cast(expected):expected},
                     {#if[Object]?handle.componentType.cast(value):value});
@@ -897,7 +897,7 @@
                                        (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase,
                                        value);
         }
-        
+
         @ForceInline
         static $type$ getAndBitwiseXor(Array handle, Object oarray, int index, $type$ value) {
             $type$[] array = ($type$[]) oarray;
--- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -186,7 +186,7 @@
         @ForceInline
         static boolean compareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
-            return UNSAFE.compareAndSwap$RawType$(
+            return UNSAFE.compareAndSet$RawType$(
                     ba,
                     address(ba, index(ba, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -196,7 +196,7 @@
         static $type$ compareAndExchange(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
             return convEndian(handle.be,
-                              UNSAFE.compareAndExchange$RawType$Volatile(
+                              UNSAFE.compareAndExchange$RawType$(
                                       ba,
                                       address(ba, index(ba, index)),
                                       convEndian(handle.be, expected), convEndian(handle.be, value)));
@@ -225,7 +225,7 @@
         @ForceInline
         static boolean weakCompareAndSetPlain(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
-            return UNSAFE.weakCompareAndSwap$RawType$(
+            return UNSAFE.weakCompareAndSet$RawType$Plain(
                     ba,
                     address(ba, index(ba, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -234,7 +234,7 @@
         @ForceInline
         static boolean weakCompareAndSet(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
-            return UNSAFE.weakCompareAndSwap$RawType$Volatile(
+            return UNSAFE.weakCompareAndSet$RawType$(
                     ba,
                     address(ba, index(ba, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -243,7 +243,7 @@
         @ForceInline
         static boolean weakCompareAndSetAcquire(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
-            return UNSAFE.weakCompareAndSwap$RawType$Acquire(
+            return UNSAFE.weakCompareAndSet$RawType$Acquire(
                     ba,
                     address(ba, index(ba, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -252,7 +252,7 @@
         @ForceInline
         static boolean weakCompareAndSetRelease(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) {
             byte[] ba = (byte[]) oba;
-            return UNSAFE.weakCompareAndSwap$RawType$Release(
+            return UNSAFE.weakCompareAndSet$RawType$Release(
                     ba,
                     address(ba, index(ba, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -336,7 +336,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(ba, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta)));
             return expectedValue;
         }
@@ -389,7 +389,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(ba, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value)));
             return expectedValue;
         }
@@ -440,7 +440,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(ba, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value)));
             return expectedValue;
         }
@@ -491,7 +491,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(ba, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value)));
             return expectedValue;
         }
@@ -625,7 +625,7 @@
         @ForceInline
         static boolean compareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
-            return UNSAFE.compareAndSwap$RawType$(
+            return UNSAFE.compareAndSet$RawType$(
                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -635,7 +635,7 @@
         static $type$ compareAndExchange(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
             return convEndian(handle.be,
-                              UNSAFE.compareAndExchange$RawType$Volatile(
+                              UNSAFE.compareAndExchange$RawType$(
                                       UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                                       address(bb, indexRO(bb, index)),
                                       convEndian(handle.be, expected), convEndian(handle.be, value)));
@@ -664,7 +664,7 @@
         @ForceInline
         static boolean weakCompareAndSetPlain(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
-            return UNSAFE.weakCompareAndSwap$RawType$(
+            return UNSAFE.weakCompareAndSet$RawType$Plain(
                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -673,7 +673,7 @@
         @ForceInline
         static boolean weakCompareAndSet(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
-            return UNSAFE.weakCompareAndSwap$RawType$Volatile(
+            return UNSAFE.weakCompareAndSet$RawType$(
                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -682,7 +682,7 @@
         @ForceInline
         static boolean weakCompareAndSetAcquire(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
-            return UNSAFE.weakCompareAndSwap$RawType$Acquire(
+            return UNSAFE.weakCompareAndSet$RawType$Acquire(
                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -691,7 +691,7 @@
         @ForceInline
         static boolean weakCompareAndSetRelease(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
-            return UNSAFE.weakCompareAndSwap$RawType$Release(
+            return UNSAFE.weakCompareAndSet$RawType$Release(
                     UNSAFE.getObject(bb, BYTE_BUFFER_HB),
                     address(bb, indexRO(bb, index)),
                     convEndian(handle.be, expected), convEndian(handle.be, value));
@@ -776,7 +776,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta)));
             return expectedValue;
         }
@@ -830,7 +830,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue | value)));
             return expectedValue;
         }
@@ -882,12 +882,12 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue & value)));
             return expectedValue;
         }
-        
-        
+
+
         @ForceInline
         static $type$ getAndBitwiseXor(ByteBufferHandle handle, Object obb, int index, $type$ value) {
             ByteBuffer bb = (ByteBuffer) obb;
@@ -935,7 +935,7 @@
             do {
                 nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset);
                 expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue);
-            } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset,
+            } while (!UNSAFE.weakCompareAndSet$RawType$(base, offset,
                     nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue ^ value)));
             return expectedValue;
         }
--- a/jdk/src/java.base/share/classes/java/net/ContentHandler.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/net/ContentHandler.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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.
--- a/jdk/src/java.base/share/classes/java/net/URLConnection.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/net/URLConnection.java	Wed Jul 05 23:37:13 2017 +0200
@@ -881,7 +881,7 @@
      * Sets the value of the {@code doInput} field for this
      * {@code URLConnection} to the specified value.
      * <p>
-     * A URL connection can be used for input and/or output.  Set the DoInput
+     * A URL connection can be used for input and/or output.  Set the doInput
      * flag to true if you intend to use the URL connection for input,
      * false if not.  The default is true.
      *
@@ -911,7 +911,7 @@
      * Sets the value of the {@code doOutput} field for this
      * {@code URLConnection} to the specified value.
      * <p>
-     * A URL connection can be used for input and/or output.  Set the DoOutput
+     * A URL connection can be used for input and/or output.  Set the doOutput
      * flag to true if you intend to use the URL connection for output,
      * false if not.  The default is false.
      *
@@ -977,7 +977,7 @@
      * Returns the default value of the {@code allowUserInteraction}
      * field.
      * <p>
-     * Ths default is "sticky", being a part of the static state of all
+     * This default is "sticky", being a part of the static state of all
      * URLConnections.  This flag applies to the next, and all following
      * URLConnections that are created.
      *
@@ -998,7 +998,7 @@
      * "reload" button in a browser).  If the UseCaches flag on a connection
      * is true, the connection is allowed to use whatever caches it can.
      *  If false, caches are to be ignored.
-     *  The default value comes from DefaultUseCaches, which defaults to
+     *  The default value comes from defaultUseCaches, which defaults to
      * true. A default value can also be set per-protocol using
      * {@link #setDefaultUseCaches(String,boolean)}.
      *
@@ -1257,7 +1257,7 @@
      * application. It can be called at most once by an application.
      * <p>
      * The {@code ContentHandlerFactory} instance is used to
-     * construct a content handler from a content type
+     * construct a content handler from a content type.
      * <p>
      * If there is a security manager, this method first calls
      * the security manager's {@code checkSetFactory} method
--- a/jdk/src/java.base/share/classes/java/security/cert/X509CRL.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/cert/X509CRL.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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.");
+        }
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/security/cert/X509Certificate.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/security/cert/X509Certificate.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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.");
+        }
     }
 }
--- a/jdk/src/java.base/share/classes/java/text/DecimalFormat.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/text/DecimalFormat.java	Wed Jul 05 23:37:13 2017 +0200
@@ -3201,13 +3201,6 @@
         isCurrencyFormat = false;
         useExponentialNotation = false;
 
-        // Two variables are used to record the subrange of the pattern
-        // occupied by phase 1.  This is used during the processing of the
-        // second pattern (the one representing negative numbers) to ensure
-        // that no deviation exists in phase 1 between the two patterns.
-        int phaseOneStart = 0;
-        int phaseOneLength = 0;
-
         int start = 0;
         for (int j = 1; j >= 0 && start < pattern.length(); --j) {
             boolean inQuote = false;
@@ -3258,9 +3251,6 @@
                             ch == groupingSeparator ||
                             ch == decimalSeparator) {
                             phase = 1;
-                            if (j == 1) {
-                                phaseOneStart = pos;
-                            }
                             --pos; // Reprocess this character
                             continue;
                         } else if (ch == CURRENCY_SIGN) {
@@ -3331,17 +3321,29 @@
                     break;
 
                 case 1:
-                    // Phase one must be identical in the two sub-patterns. We
-                    // enforce this by doing a direct comparison. While
-                    // processing the first sub-pattern, we just record its
-                    // length. While processing the second, we compare
-                    // characters.
-                    if (j == 1) {
-                        ++phaseOneLength;
-                    } else {
-                        if (--phaseOneLength == 0) {
-                            phase = 2;
-                            affix = suffix;
+                    // The negative subpattern (j = 0) serves only to specify the
+                    // negative prefix and suffix, so all the phase 1 characters
+                    // e.g. digits, zeroDigit, groupingSeparator,
+                    // decimalSeparator, exponent are ignored
+                    if (j == 0) {
+                        while (pos < pattern.length()) {
+                            char negPatternChar = pattern.charAt(pos);
+                            if (negPatternChar == digit
+                                    || negPatternChar == zeroDigit
+                                    || negPatternChar == groupingSeparator
+                                    || negPatternChar == decimalSeparator) {
+                                ++pos;
+                            } else if (pattern.regionMatches(pos, exponent,
+                                    0, exponent.length())) {
+                                pos = pos + exponent.length();
+                            } else {
+                                // Not a phase 1 character, consider it as
+                                // suffix and parse it in phase 2
+                                --pos; //process it again in outer loop
+                                phase = 2;
+                                affix = suffix;
+                                break;
+                            }
                         }
                         continue;
                     }
@@ -3395,7 +3397,6 @@
                          while (pos < pattern.length() &&
                                pattern.charAt(pos) == zeroDigit) {
                             ++minExponentDigits;
-                            ++phaseOneLength;
                             ++pos;
                         }
 
@@ -3414,7 +3415,6 @@
                         phase = 2;
                         affix = suffix;
                         --pos;
-                        --phaseOneLength;
                         continue;
                     }
                     break;
--- a/jdk/src/java.base/share/classes/java/time/chrono/AbstractChronology.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/time/chrono/AbstractChronology.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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<>();
--- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDate.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDate.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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());
+        };
     }
 
     //-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDateTime.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoLocalDateTime.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
+        };
     }
 
     //-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/chrono/ChronoZonedDateTime.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/time/chrono/ChronoZonedDateTime.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
+            };
     }
 
     //-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/format/DateTimeTextProvider.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeTextProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -112,6 +112,9 @@
         }
     };
 
+    // Singleton instance
+    private static final DateTimeTextProvider INSTANCE = new DateTimeTextProvider();
+
     DateTimeTextProvider() {}
 
     /**
@@ -120,7 +123,7 @@
      * @return the provider, not null
      */
     static DateTimeTextProvider getInstance() {
-        return new DateTimeTextProvider();
+        return INSTANCE;
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/time/temporal/ValueRange.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/time/temporal/ValueRange.java	Wed Jul 05 23:37:13 2017 +0200
@@ -385,7 +385,7 @@
         }
         if (obj instanceof ValueRange) {
             ValueRange other = (ValueRange) obj;
-           return minSmallest == other.minSmallest && minLargest == other.minLargest &&
+            return minSmallest == other.minSmallest && minLargest == other.minLargest &&
                    maxSmallest == other.maxSmallest && maxLargest == other.maxLargest;
         }
         return false;
@@ -398,8 +398,9 @@
      */
     @Override
     public int hashCode() {
-        long hash = minSmallest + minLargest << 16 + minLargest >> 48 + maxSmallest << 32 +
-            maxSmallest >> 32 + maxLargest << 48 + maxLargest >> 16;
+        long hash = minSmallest + (minLargest << 16) + (minLargest >> 48) +
+                (maxSmallest << 32) + (maxSmallest >> 32) + (maxLargest << 48) +
+                (maxLargest >> 16);
         return (int) (hash ^ (hash >>> 32));
     }
 
--- a/jdk/src/java.base/share/classes/java/util/Calendar.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/Calendar.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -2216,7 +2216,7 @@
                                    Locale locale, int fieldMask) {
         int baseStyle = getBaseStyle(style); // Ignore the standalone mask
         if (field < 0 || field >= fields.length ||
-            baseStyle < minStyle || baseStyle > maxStyle) {
+            baseStyle < minStyle || baseStyle > maxStyle || baseStyle == 3) {
             throw new IllegalArgumentException();
         }
         if (locale == null) {
--- a/jdk/src/java.base/share/classes/java/util/Locale.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/Locale.java	Wed Jul 05 23:37:13 2017 +0200
@@ -2702,6 +2702,7 @@
          * @see #setExtension(char, String)
          */
         public Builder removeUnicodeLocaleAttribute(String attribute) {
+            Objects.requireNonNull(attribute);
             try {
                 localeBuilder.removeUnicodeLocaleAttribute(attribute);
             } catch (LocaleSyntaxException e) {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Wed Jul 05 23:37:13 2017 +0200
@@ -768,7 +768,7 @@
 
     static final <K,V> boolean casTabAt(Node<K,V>[] tab, int i,
                                         Node<K,V> c, Node<K,V> v) {
-        return U.compareAndSwapObject(tab, ((long)i << ASHIFT) + ABASE, c, v);
+        return U.compareAndSetObject(tab, ((long)i << ASHIFT) + ABASE, c, v);
     }
 
     static final <K,V> void setTabAt(Node<K,V>[] tab, int i, Node<K,V> v) {
@@ -1032,9 +1032,10 @@
             }
             else if ((fh = f.hash) == MOVED)
                 tab = helpTransfer(tab, f);
-            else if (onlyIfAbsent && fh == hash &&  // check first node
-                     ((fk = f.key) == key || fk != null && key.equals(fk)) &&
-                     (fv = f.val) != null)
+            else if (onlyIfAbsent // check first node without acquiring lock
+                     && fh == hash
+                     && ((fk = f.key) == key || (fk != null && key.equals(fk)))
+                     && (fv = f.val) != null)
                 return fv;
             else {
                 V oldVal = null;
@@ -1728,9 +1729,9 @@
             }
             else if ((fh = f.hash) == MOVED)
                 tab = helpTransfer(tab, f);
-            else if (fh == h &&                  // check first node
-                     ((fk = f.key) == key || fk != null && key.equals(fk)) &&
-                     (fv = f.val) != null)
+            else if (fh == h    // check first node without acquiring lock
+                     && ((fk = f.key) == key || (fk != null && key.equals(fk)))
+                     && (fv = f.val) != null)
                 return fv;
             else {
                 boolean added = false;
@@ -2299,7 +2300,7 @@
         while ((tab = table) == null || tab.length == 0) {
             if ((sc = sizeCtl) < 0)
                 Thread.yield(); // lost initialization race; just spin
-            else if (U.compareAndSwapInt(this, SIZECTL, sc, -1)) {
+            else if (U.compareAndSetInt(this, SIZECTL, sc, -1)) {
                 try {
                     if ((tab = table) == null || tab.length == 0) {
                         int n = (sc > 0) ? sc : DEFAULT_CAPACITY;
@@ -2330,13 +2331,13 @@
     private final void addCount(long x, int check) {
         CounterCell[] as; long b, s;
         if ((as = counterCells) != null ||
-            !U.compareAndSwapLong(this, BASECOUNT, b = baseCount, s = b + x)) {
+            !U.compareAndSetLong(this, BASECOUNT, b = baseCount, s = b + x)) {
             CounterCell a; long v; int m;
             boolean uncontended = true;
             if (as == null || (m = as.length - 1) < 0 ||
                 (a = as[ThreadLocalRandom.getProbe() & m]) == null ||
                 !(uncontended =
-                  U.compareAndSwapLong(a, CELLVALUE, v = a.value, v + x))) {
+                  U.compareAndSetLong(a, CELLVALUE, v = a.value, v + x))) {
                 fullAddCount(x, uncontended);
                 return;
             }
@@ -2354,10 +2355,10 @@
                         sc == rs + MAX_RESIZERS || (nt = nextTable) == null ||
                         transferIndex <= 0)
                         break;
-                    if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1))
+                    if (U.compareAndSetInt(this, SIZECTL, sc, sc + 1))
                         transfer(tab, nt);
                 }
-                else if (U.compareAndSwapInt(this, SIZECTL, sc,
+                else if (U.compareAndSetInt(this, SIZECTL, sc,
                                              (rs << RESIZE_STAMP_SHIFT) + 2))
                     transfer(tab, null);
                 s = sumCount();
@@ -2378,7 +2379,7 @@
                 if ((sc >>> RESIZE_STAMP_SHIFT) != rs || sc == rs + 1 ||
                     sc == rs + MAX_RESIZERS || transferIndex <= 0)
                     break;
-                if (U.compareAndSwapInt(this, SIZECTL, sc, sc + 1)) {
+                if (U.compareAndSetInt(this, SIZECTL, sc, sc + 1)) {
                     transfer(tab, nextTab);
                     break;
                 }
@@ -2401,7 +2402,7 @@
             Node<K,V>[] tab = table; int n;
             if (tab == null || (n = tab.length) == 0) {
                 n = (sc > c) ? sc : c;
-                if (U.compareAndSwapInt(this, SIZECTL, sc, -1)) {
+                if (U.compareAndSetInt(this, SIZECTL, sc, -1)) {
                     try {
                         if (table == tab) {
                             @SuppressWarnings("unchecked")
@@ -2418,7 +2419,7 @@
                 break;
             else if (tab == table) {
                 int rs = resizeStamp(n);
-                if (U.compareAndSwapInt(this, SIZECTL, sc,
+                if (U.compareAndSetInt(this, SIZECTL, sc,
                                         (rs << RESIZE_STAMP_SHIFT) + 2))
                     transfer(tab, null);
             }
@@ -2459,7 +2460,7 @@
                     i = -1;
                     advance = false;
                 }
-                else if (U.compareAndSwapInt
+                else if (U.compareAndSetInt
                          (this, TRANSFERINDEX, nextIndex,
                           nextBound = (nextIndex > stride ?
                                        nextIndex - stride : 0))) {
@@ -2476,7 +2477,7 @@
                     sizeCtl = (n << 1) - (n >>> 1);
                     return;
                 }
-                if (U.compareAndSwapInt(this, SIZECTL, sc = sizeCtl, sc - 1)) {
+                if (U.compareAndSetInt(this, SIZECTL, sc = sizeCtl, sc - 1)) {
                     if ((sc - 2) != resizeStamp(n) << RESIZE_STAMP_SHIFT)
                         return;
                     finishing = advance = true;
@@ -2601,7 +2602,7 @@
                     if (cellsBusy == 0) {            // Try to attach new Cell
                         CounterCell r = new CounterCell(x); // Optimistic create
                         if (cellsBusy == 0 &&
-                            U.compareAndSwapInt(this, CELLSBUSY, 0, 1)) {
+                            U.compareAndSetInt(this, CELLSBUSY, 0, 1)) {
                             boolean created = false;
                             try {               // Recheck under lock
                                 CounterCell[] rs; int m, j;
@@ -2623,14 +2624,14 @@
                 }
                 else if (!wasUncontended)       // CAS already known to fail
                     wasUncontended = true;      // Continue after rehash
-                else if (U.compareAndSwapLong(a, CELLVALUE, v = a.value, v + x))
+                else if (U.compareAndSetLong(a, CELLVALUE, v = a.value, v + x))
                     break;
                 else if (counterCells != as || n >= NCPU)
                     collide = false;            // At max size or stale
                 else if (!collide)
                     collide = true;
                 else if (cellsBusy == 0 &&
-                         U.compareAndSwapInt(this, CELLSBUSY, 0, 1)) {
+                         U.compareAndSetInt(this, CELLSBUSY, 0, 1)) {
                     try {
                         if (counterCells == as) {// Expand table unless stale
                             CounterCell[] rs = new CounterCell[n << 1];
@@ -2647,7 +2648,7 @@
                 h = ThreadLocalRandom.advanceProbe(h);
             }
             else if (cellsBusy == 0 && counterCells == as &&
-                     U.compareAndSwapInt(this, CELLSBUSY, 0, 1)) {
+                     U.compareAndSetInt(this, CELLSBUSY, 0, 1)) {
                 boolean init = false;
                 try {                           // Initialize table
                     if (counterCells == as) {
@@ -2662,7 +2663,7 @@
                 if (init)
                     break;
             }
-            else if (U.compareAndSwapLong(this, BASECOUNT, v = baseCount, v + x))
+            else if (U.compareAndSetLong(this, BASECOUNT, v = baseCount, v + x))
                 break;                          // Fall back on using base
         }
     }
@@ -2858,7 +2859,7 @@
          * Acquires write lock for tree restructuring.
          */
         private final void lockRoot() {
-            if (!U.compareAndSwapInt(this, LOCKSTATE, 0, WRITER))
+            if (!U.compareAndSetInt(this, LOCKSTATE, 0, WRITER))
                 contendedLock(); // offload to separate method
         }
 
@@ -2876,14 +2877,14 @@
             boolean waiting = false;
             for (int s;;) {
                 if (((s = lockState) & ~WAITER) == 0) {
-                    if (U.compareAndSwapInt(this, LOCKSTATE, s, WRITER)) {
+                    if (U.compareAndSetInt(this, LOCKSTATE, s, WRITER)) {
                         if (waiting)
                             waiter = null;
                         return;
                     }
                 }
                 else if ((s & WAITER) == 0) {
-                    if (U.compareAndSwapInt(this, LOCKSTATE, s, s | WAITER)) {
+                    if (U.compareAndSetInt(this, LOCKSTATE, s, s | WAITER)) {
                         waiting = true;
                         waiter = Thread.currentThread();
                     }
@@ -2908,7 +2909,7 @@
                             return e;
                         e = e.next;
                     }
-                    else if (U.compareAndSwapInt(this, LOCKSTATE, s,
+                    else if (U.compareAndSetInt(this, LOCKSTATE, s,
                                                  s + READER)) {
                         TreeNode<K,V> r, p;
                         try {
@@ -3468,9 +3469,9 @@
 
     static final class KeyIterator<K,V> extends BaseIterator<K,V>
         implements Iterator<K>, Enumeration<K> {
-        KeyIterator(Node<K,V>[] tab, int index, int size, int limit,
+        KeyIterator(Node<K,V>[] tab, int size, int index, int limit,
                     ConcurrentHashMap<K,V> map) {
-            super(tab, index, size, limit, map);
+            super(tab, size, index, limit, map);
         }
 
         public final K next() {
@@ -3488,9 +3489,9 @@
 
     static final class ValueIterator<K,V> extends BaseIterator<K,V>
         implements Iterator<V>, Enumeration<V> {
-        ValueIterator(Node<K,V>[] tab, int index, int size, int limit,
+        ValueIterator(Node<K,V>[] tab, int size, int index, int limit,
                       ConcurrentHashMap<K,V> map) {
-            super(tab, index, size, limit, map);
+            super(tab, size, index, limit, map);
         }
 
         public final V next() {
@@ -3508,9 +3509,9 @@
 
     static final class EntryIterator<K,V> extends BaseIterator<K,V>
         implements Iterator<Map.Entry<K,V>> {
-        EntryIterator(Node<K,V>[] tab, int index, int size, int limit,
+        EntryIterator(Node<K,V>[] tab, int size, int index, int limit,
                       ConcurrentHashMap<K,V> map) {
-            super(tab, index, size, limit, map);
+            super(tab, size, index, limit, map);
         }
 
         public final Map.Entry<K,V> next() {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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));
     }
 
     /**
--- a/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/ForkJoinWorkerThread.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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,
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicInteger.java	Wed Jul 05 23:37:13 2017 +0200
@@ -140,7 +140,7 @@
      * the actual value was not equal to the expected value.
      */
     public final boolean compareAndSet(int expectedValue, int newValue) {
-        return U.compareAndSwapInt(this, VALUE, expectedValue, newValue);
+        return U.compareAndSetInt(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -161,7 +161,7 @@
      */
     @Deprecated(since="9")
     public final boolean weakCompareAndSet(int expectedValue, int newValue) {
-        return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetIntPlain(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -175,7 +175,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetPlain(int expectedValue, int newValue) {
-        return U.weakCompareAndSwapInt(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetIntPlain(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -473,7 +473,7 @@
      * @since 9
      */
     public final int compareAndExchange(int expectedValue, int newValue) {
-        return U.compareAndExchangeIntVolatile(this, VALUE, expectedValue, newValue);
+        return U.compareAndExchangeInt(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -520,7 +520,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetVolatile(int expectedValue, int newValue) {
-        return U.weakCompareAndSwapIntVolatile(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetInt(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -535,7 +535,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetAcquire(int expectedValue, int newValue) {
-        return U.weakCompareAndSwapIntAcquire(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetIntAcquire(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -550,7 +550,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetRelease(int expectedValue, int newValue) {
-        return U.weakCompareAndSwapIntRelease(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetIntRelease(this, VALUE, expectedValue, newValue);
     }
 
 }
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicIntegerFieldUpdater.java	Wed Jul 05 23:37:13 2017 +0200
@@ -481,12 +481,12 @@
 
         public final boolean compareAndSet(T obj, int expect, int update) {
             accessCheck(obj);
-            return U.compareAndSwapInt(obj, offset, expect, update);
+            return U.compareAndSetInt(obj, offset, expect, update);
         }
 
         public final boolean weakCompareAndSet(T obj, int expect, int update) {
             accessCheck(obj);
-            return U.compareAndSwapInt(obj, offset, expect, update);
+            return U.compareAndSetInt(obj, offset, expect, update);
         }
 
         public final void set(T obj, int newValue) {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLong.java	Wed Jul 05 23:37:13 2017 +0200
@@ -56,7 +56,7 @@
 
     /**
      * Records whether the underlying JVM supports lockless
-     * compareAndSwap for longs. While the intrinsic compareAndSwapLong
+     * compareAndSet for longs. While the intrinsic compareAndSetLong
      * method works in either case, some constructions should be
      * handled at Java level to avoid locking user-visible locks.
      */
@@ -119,7 +119,7 @@
      */
     public final void set(long newValue) {
         // Use putLongVolatile instead of ordinary volatile store when
-        // using compareAndSwapLong, for sake of some 32bit systems.
+        // using compareAndSetLong, for sake of some 32bit systems.
         U.putLongVolatile(this, VALUE, newValue);
     }
 
@@ -156,7 +156,7 @@
      * the actual value was not equal to the expected value.
      */
     public final boolean compareAndSet(long expectedValue, long newValue) {
-        return U.compareAndSwapLong(this, VALUE, expectedValue, newValue);
+        return U.compareAndSetLong(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -177,7 +177,7 @@
      */
     @Deprecated(since="9")
     public final boolean weakCompareAndSet(long expectedValue, long newValue) {
-        return U.weakCompareAndSwapLong(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetLongPlain(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -191,7 +191,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetPlain(long expectedValue, long newValue) {
-        return U.weakCompareAndSwapLong(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetLongPlain(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -487,7 +487,7 @@
      * @since 9
      */
     public final long compareAndExchange(long expectedValue, long newValue) {
-        return U.compareAndExchangeLongVolatile(this, VALUE, expectedValue, newValue);
+        return U.compareAndExchangeLong(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -534,7 +534,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetVolatile(long expectedValue, long newValue) {
-        return U.weakCompareAndSwapLongVolatile(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetLong(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -549,7 +549,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetAcquire(long expectedValue, long newValue) {
-        return U.weakCompareAndSwapLongAcquire(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetLongAcquire(this, VALUE, expectedValue, newValue);
     }
 
     /**
@@ -564,7 +564,7 @@
      * @since 9
      */
     public final boolean weakCompareAndSetRelease(long expectedValue, long newValue) {
-        return U.weakCompareAndSwapLongRelease(this, VALUE, expectedValue, newValue);
+        return U.weakCompareAndSetLongRelease(this, VALUE, expectedValue, newValue);
     }
 
 }
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java	Wed Jul 05 23:37:13 2017 +0200
@@ -454,12 +454,12 @@
 
         public final boolean compareAndSet(T obj, long expect, long update) {
             accessCheck(obj);
-            return U.compareAndSwapLong(obj, offset, expect, update);
+            return U.compareAndSetLong(obj, offset, expect, update);
         }
 
         public final boolean weakCompareAndSet(T obj, long expect, long update) {
             accessCheck(obj);
-            return U.compareAndSwapLong(obj, offset, expect, update);
+            return U.compareAndSetLong(obj, offset, expect, update);
         }
 
         public final void set(T obj, long newValue) {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java	Wed Jul 05 23:37:13 2017 +0200
@@ -432,14 +432,14 @@
         public final boolean compareAndSet(T obj, V expect, V update) {
             accessCheck(obj);
             valueCheck(update);
-            return U.compareAndSwapObject(obj, offset, expect, update);
+            return U.compareAndSetObject(obj, offset, expect, update);
         }
 
         public final boolean weakCompareAndSet(T obj, V expect, V update) {
             // same implementation as strong form for now
             accessCheck(obj);
             valueCheck(update);
-            return U.compareAndSwapObject(obj, offset, expect, update);
+            return U.compareAndSetObject(obj, offset, expect, update);
         }
 
         public final void set(T obj, V newValue) {
--- a/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/locks/ReentrantReadWriteLock.java	Wed Jul 05 23:37:13 2017 +0200
@@ -444,7 +444,7 @@
             }
         }
 
-        private IllegalMonitorStateException unmatchedUnlockException() {
+        private static IllegalMonitorStateException unmatchedUnlockException() {
             return new IllegalMonitorStateException(
                 "attempt to unlock read lock, not locked by current thread");
         }
--- a/jdk/src/java.base/share/classes/java/util/stream/FindOps.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/java/util/stream/FindOps.java	Wed Jul 05 23:37:13 2017 +0200
@@ -54,9 +54,10 @@
      *        first element in the encounter order
      * @return a {@code TerminalOp} implementing the find operation
      */
+    @SuppressWarnings("unchecked")
     public static <T> TerminalOp<T, Optional<T>> makeRef(boolean mustFindFirst) {
-        return new FindOp<>(mustFindFirst, StreamShape.REFERENCE, Optional.empty(),
-                            Optional::isPresent, FindSink.OfRef::new);
+        return (TerminalOp<T, Optional<T>>)
+                (mustFindFirst ? FindSink.OfRef.OP_FIND_FIRST : FindSink.OfRef.OP_FIND_ANY);
     }
 
     /**
@@ -67,8 +68,7 @@
      * @return a {@code TerminalOp} implementing the find operation
      */
     public static TerminalOp<Integer, OptionalInt> makeInt(boolean mustFindFirst) {
-        return new FindOp<>(mustFindFirst, StreamShape.INT_VALUE, OptionalInt.empty(),
-                            OptionalInt::isPresent, FindSink.OfInt::new);
+        return mustFindFirst ? FindSink.OfInt.OP_FIND_FIRST : FindSink.OfInt.OP_FIND_ANY;
     }
 
     /**
@@ -79,8 +79,7 @@
      * @return a {@code TerminalOp} implementing the find operation
      */
     public static TerminalOp<Long, OptionalLong> makeLong(boolean mustFindFirst) {
-        return new FindOp<>(mustFindFirst, StreamShape.LONG_VALUE, OptionalLong.empty(),
-                            OptionalLong::isPresent, FindSink.OfLong::new);
+        return mustFindFirst ? FindSink.OfLong.OP_FIND_FIRST : FindSink.OfLong.OP_FIND_ANY;
     }
 
     /**
@@ -91,8 +90,7 @@
      * @return a {@code TerminalOp} implementing the find operation
      */
     public static TerminalOp<Double, OptionalDouble> makeDouble(boolean mustFindFirst) {
-        return new FindOp<>(mustFindFirst, StreamShape.DOUBLE_VALUE, OptionalDouble.empty(),
-                            OptionalDouble::isPresent, FindSink.OfDouble::new);
+        return mustFindFirst ? FindSink.OfDouble.OP_FIND_FIRST : FindSink.OfDouble.OP_FIND_ANY;
     }
 
     /**
@@ -195,6 +193,14 @@
             public Optional<T> get() {
                 return hasValue ? Optional.of(value) : null;
             }
+
+            static final TerminalOp<?, ?> OP_FIND_FIRST = new FindOp<>(true,
+                    StreamShape.REFERENCE, Optional.empty(),
+                    Optional::isPresent, FindSink.OfRef::new);
+
+            static final TerminalOp<?, ?> OP_FIND_ANY = new FindOp<>(false,
+                    StreamShape.REFERENCE, Optional.empty(),
+                    Optional::isPresent, FindSink.OfRef::new);
         }
 
         /** Specialization of {@code FindSink} for int streams */
@@ -210,6 +216,13 @@
             public OptionalInt get() {
                 return hasValue ? OptionalInt.of(value) : null;
             }
+
+            static final TerminalOp<Integer, OptionalInt> OP_FIND_FIRST = new FindOp<>(true,
+                    StreamShape.INT_VALUE, OptionalInt.empty(),
+                    OptionalInt::isPresent, FindSink.OfInt::new);
+            static final TerminalOp<Integer, OptionalInt> OP_FIND_ANY = new FindOp<>(false,
+                    StreamShape.INT_VALUE, OptionalInt.empty(),
+                    OptionalInt::isPresent, FindSink.OfInt::new);
         }
 
         /** Specialization of {@code FindSink} for long streams */
@@ -225,6 +238,13 @@
             public OptionalLong get() {
                 return hasValue ? OptionalLong.of(value) : null;
             }
+
+            static final TerminalOp<Long, OptionalLong> OP_FIND_FIRST = new FindOp<>(true,
+                    StreamShape.LONG_VALUE, OptionalLong.empty(),
+                    OptionalLong::isPresent, FindSink.OfLong::new);
+            static final TerminalOp<Long, OptionalLong> OP_FIND_ANY = new FindOp<>(false,
+                    StreamShape.LONG_VALUE, OptionalLong.empty(),
+                    OptionalLong::isPresent, FindSink.OfLong::new);
         }
 
         /** Specialization of {@code FindSink} for double streams */
@@ -240,6 +260,13 @@
             public OptionalDouble get() {
                 return hasValue ? OptionalDouble.of(value) : null;
             }
+
+            static final TerminalOp<Double, OptionalDouble> OP_FIND_FIRST = new FindOp<>(true,
+                    StreamShape.DOUBLE_VALUE, OptionalDouble.empty(),
+                    OptionalDouble::isPresent, FindSink.OfDouble::new);
+            static final TerminalOp<Double, OptionalDouble> OP_FIND_ANY = new FindOp<>(false,
+                    StreamShape.DOUBLE_VALUE, OptionalDouble.empty(),
+                    OptionalDouble::isPresent, FindSink.OfDouble::new);
         }
     }
 
--- a/jdk/src/java.base/share/classes/jdk/internal/logger/SimpleConsoleLogger.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/logger/SimpleConsoleLogger.java	Wed Jul 05 23:37:13 2017 +0200
@@ -33,6 +33,7 @@
 import java.security.PrivilegedAction;
 import java.time.ZonedDateTime;
 import java.util.Optional;
+import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 import java.util.function.Function;
 import java.lang.System.Logger;
@@ -106,7 +107,7 @@
     public final void log(Level level, ResourceBundle bundle, String key, Throwable thrown) {
         if (isLoggable(level)) {
             if (bundle != null) {
-                key = bundle.getString(key);
+                key = getString(bundle, key);
             }
             publish(getCallerInfo(), logLevel(level), key, thrown);
         }
@@ -116,7 +117,7 @@
     public final void log(Level level, ResourceBundle bundle, String format, Object... params) {
         if (isLoggable(level)) {
             if (bundle != null) {
-                format = bundle.getString(format);
+                format = getString(bundle, format);
             }
             publish(getCallerInfo(), logLevel(level), format, params);
         }
@@ -364,7 +365,7 @@
     public final void logrb(PlatformLogger.Level level, String sourceClass,
             String sourceMethod, ResourceBundle bundle, String key, Object... params) {
         if (isLoggable(level)) {
-            String msg = bundle == null ? key : bundle.getString(key);
+            String msg = bundle == null ? key : getString(bundle, key);
             publish(getCallerInfo(sourceClass, sourceMethod), logLevel(level), msg, params);
         }
     }
@@ -373,7 +374,7 @@
     public final void logrb(PlatformLogger.Level level, String sourceClass,
             String sourceMethod, ResourceBundle bundle, String key, Throwable thrown) {
         if (isLoggable(level)) {
-            String msg = bundle == null ? key : bundle.getString(key);
+            String msg = bundle == null ? key : getString(bundle, key);
             publish(getCallerInfo(sourceClass, sourceMethod), logLevel(level), msg, thrown);
         }
     }
@@ -382,7 +383,7 @@
     public final void logrb(PlatformLogger.Level level, ResourceBundle bundle,
             String key, Object... params) {
         if (isLoggable(level)) {
-            String msg = bundle == null ? key : bundle.getString(key);
+            String msg = bundle == null ? key : getString(bundle,key);
             publish(getCallerInfo(), logLevel(level), msg, params);
         }
     }
@@ -391,11 +392,23 @@
     public final void logrb(PlatformLogger.Level level, ResourceBundle bundle,
             String key, Throwable thrown) {
         if (isLoggable(level)) {
-            String msg = bundle == null ? key : bundle.getString(key);
+            String msg = bundle == null ? key : getString(bundle,key);
             publish(getCallerInfo(), logLevel(level), msg, thrown);
         }
     }
 
+    static String getString(ResourceBundle bundle, String key) {
+        if (bundle == null || key == null) return key;
+        try {
+            return bundle.getString(key);
+        } catch (MissingResourceException x) {
+            // Emulate what java.util.logging Formatters do
+            // We don't want unchecked exception to propagate up to
+            // the caller's code.
+            return key;
+        }
+    }
+
     static final class Formatting {
         // The default simple log format string.
         // Used both by SimpleConsoleLogger when java.logging is not present,
--- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1278,55 +1278,55 @@
      * @return {@code true} if successful
      */
     @HotSpotIntrinsicCandidate
-    public final native boolean compareAndSwapObject(Object o, long offset,
-                                                     Object expected,
-                                                     Object x);
+    public final native boolean compareAndSetObject(Object o, long offset,
+                                                    Object expected,
+                                                    Object x);
 
     @HotSpotIntrinsicCandidate
-    public final native Object compareAndExchangeObjectVolatile(Object o, long offset,
-                                                                Object expected,
-                                                                Object x);
+    public final native Object compareAndExchangeObject(Object o, long offset,
+                                                        Object expected,
+                                                        Object x);
 
     @HotSpotIntrinsicCandidate
     public final Object compareAndExchangeObjectAcquire(Object o, long offset,
                                                                Object expected,
                                                                Object x) {
-        return compareAndExchangeObjectVolatile(o, offset, expected, x);
+        return compareAndExchangeObject(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
     public final Object compareAndExchangeObjectRelease(Object o, long offset,
                                                                Object expected,
                                                                Object x) {
-        return compareAndExchangeObjectVolatile(o, offset, expected, x);
+        return compareAndExchangeObject(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapObject(Object o, long offset,
-                                                         Object expected,
-                                                         Object x) {
-        return compareAndSwapObject(o, offset, expected, x);
+    public final boolean weakCompareAndSetObjectPlain(Object o, long offset,
+                                                      Object expected,
+                                                      Object x) {
+        return compareAndSetObject(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapObjectAcquire(Object o, long offset,
-                                                                Object expected,
-                                                                Object x) {
-        return compareAndSwapObject(o, offset, expected, x);
+    public final boolean weakCompareAndSetObjectAcquire(Object o, long offset,
+                                                        Object expected,
+                                                        Object x) {
+        return compareAndSetObject(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapObjectRelease(Object o, long offset,
-                                                                Object expected,
-                                                                Object x) {
-        return compareAndSwapObject(o, offset, expected, x);
+    public final boolean weakCompareAndSetObjectRelease(Object o, long offset,
+                                                        Object expected,
+                                                        Object x) {
+        return compareAndSetObject(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapObjectVolatile(Object o, long offset,
-                                                                Object expected,
-                                                                Object x) {
-        return compareAndSwapObject(o, offset, expected, x);
+    public final boolean weakCompareAndSetObject(Object o, long offset,
+                                                 Object expected,
+                                                 Object x) {
+        return compareAndSetObject(o, offset, expected, x);
     }
 
     /**
@@ -1339,61 +1339,61 @@
      * @return {@code true} if successful
      */
     @HotSpotIntrinsicCandidate
-    public final native boolean compareAndSwapInt(Object o, long offset,
+    public final native boolean compareAndSetInt(Object o, long offset,
+                                                 int expected,
+                                                 int x);
+
+    @HotSpotIntrinsicCandidate
+    public final native int compareAndExchangeInt(Object o, long offset,
                                                   int expected,
                                                   int x);
 
     @HotSpotIntrinsicCandidate
-    public final native int compareAndExchangeIntVolatile(Object o, long offset,
-                                                          int expected,
-                                                          int x);
-
-    @HotSpotIntrinsicCandidate
     public final int compareAndExchangeIntAcquire(Object o, long offset,
                                                          int expected,
                                                          int x) {
-        return compareAndExchangeIntVolatile(o, offset, expected, x);
+        return compareAndExchangeInt(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
     public final int compareAndExchangeIntRelease(Object o, long offset,
                                                          int expected,
                                                          int x) {
-        return compareAndExchangeIntVolatile(o, offset, expected, x);
+        return compareAndExchangeInt(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapInt(Object o, long offset,
-                                                      int expected,
-                                                      int x) {
-        return compareAndSwapInt(o, offset, expected, x);
+    public final boolean weakCompareAndSetIntPlain(Object o, long offset,
+                                                   int expected,
+                                                   int x) {
+        return compareAndSetInt(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapIntAcquire(Object o, long offset,
-                                                             int expected,
-                                                             int x) {
-        return compareAndSwapInt(o, offset, expected, x);
+    public final boolean weakCompareAndSetIntAcquire(Object o, long offset,
+                                                     int expected,
+                                                     int x) {
+        return compareAndSetInt(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapIntRelease(Object o, long offset,
-                                                             int expected,
-                                                             int x) {
-        return compareAndSwapInt(o, offset, expected, x);
+    public final boolean weakCompareAndSetIntRelease(Object o, long offset,
+                                                     int expected,
+                                                     int x) {
+        return compareAndSetInt(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapIntVolatile(Object o, long offset,
-                                                             int expected,
-                                                             int x) {
-        return compareAndSwapInt(o, offset, expected, x);
+    public final boolean weakCompareAndSetInt(Object o, long offset,
+                                              int expected,
+                                              int x) {
+        return compareAndSetInt(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final byte compareAndExchangeByteVolatile(Object o, long offset,
-                                                     byte expected,
-                                                     byte x) {
+    public final byte compareAndExchangeByte(Object o, long offset,
+                                             byte expected,
+                                             byte x) {
         long wordOffset = offset & ~3;
         int shift = (int) (offset & 3) << 3;
         if (BE) {
@@ -1407,64 +1407,64 @@
             fullWord = getIntVolatile(o, wordOffset);
             if ((fullWord & mask) != maskedExpected)
                 return (byte) ((fullWord & mask) >> shift);
-        } while (!weakCompareAndSwapIntVolatile(o, wordOffset,
+        } while (!weakCompareAndSetInt(o, wordOffset,
                                                 fullWord, (fullWord & ~mask) | maskedX));
         return expected;
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean compareAndSwapByte(Object o, long offset,
-                                            byte expected,
-                                            byte x) {
-        return compareAndExchangeByteVolatile(o, offset, expected, x) == expected;
+    public final boolean compareAndSetByte(Object o, long offset,
+                                           byte expected,
+                                           byte x) {
+        return compareAndExchangeByte(o, offset, expected, x) == expected;
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapByteVolatile(Object o, long offset,
-                                                        byte expected,
-                                                        byte x) {
-        return compareAndSwapByte(o, offset, expected, x);
+    public final boolean weakCompareAndSetByte(Object o, long offset,
+                                               byte expected,
+                                               byte x) {
+        return compareAndSetByte(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapByteAcquire(Object o, long offset,
-                                                       byte expected,
-                                                       byte x) {
-        return weakCompareAndSwapByteVolatile(o, offset, expected, x);
+    public final boolean weakCompareAndSetByteAcquire(Object o, long offset,
+                                                      byte expected,
+                                                      byte x) {
+        return weakCompareAndSetByte(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapByteRelease(Object o, long offset,
-                                                       byte expected,
-                                                       byte x) {
-        return weakCompareAndSwapByteVolatile(o, offset, expected, x);
+    public final boolean weakCompareAndSetByteRelease(Object o, long offset,
+                                                      byte expected,
+                                                      byte x) {
+        return weakCompareAndSetByte(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapByte(Object o, long offset,
-                                                        byte expected,
-                                                        byte x) {
-        return weakCompareAndSwapByteVolatile(o, offset, expected, x);
+    public final boolean weakCompareAndSetBytePlain(Object o, long offset,
+                                                    byte expected,
+                                                    byte x) {
+        return weakCompareAndSetByte(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
     public final byte compareAndExchangeByteAcquire(Object o, long offset,
                                                     byte expected,
                                                     byte x) {
-        return compareAndExchangeByteVolatile(o, offset, expected, x);
+        return compareAndExchangeByte(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
     public final byte compareAndExchangeByteRelease(Object o, long offset,
                                                     byte expected,
                                                     byte x) {
-        return compareAndExchangeByteVolatile(o, offset, expected, x);
+        return compareAndExchangeByte(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final short compareAndExchangeShortVolatile(Object o, long offset,
-                                             short expected,
-                                             short x) {
+    public final short compareAndExchangeShort(Object o, long offset,
+                                               short expected,
+                                               short x) {
         if ((offset & 3) == 3) {
             throw new IllegalArgumentException("Update spans the word, not supported");
         }
@@ -1482,44 +1482,44 @@
             if ((fullWord & mask) != maskedExpected) {
                 return (short) ((fullWord & mask) >> shift);
             }
-        } while (!weakCompareAndSwapIntVolatile(o, wordOffset,
+        } while (!weakCompareAndSetInt(o, wordOffset,
                                                 fullWord, (fullWord & ~mask) | maskedX));
         return expected;
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean compareAndSwapShort(Object o, long offset,
-                                             short expected,
-                                             short x) {
-        return compareAndExchangeShortVolatile(o, offset, expected, x) == expected;
+    public final boolean compareAndSetShort(Object o, long offset,
+                                            short expected,
+                                            short x) {
+        return compareAndExchangeShort(o, offset, expected, x) == expected;
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapShortVolatile(Object o, long offset,
-                                                         short expected,
-                                                         short x) {
-        return compareAndSwapShort(o, offset, expected, x);
+    public final boolean weakCompareAndSetShort(Object o, long offset,
+                                                short expected,
+                                                short x) {
+        return compareAndSetShort(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapShortAcquire(Object o, long offset,
-                                                        short expected,
-                                                        short x) {
-        return weakCompareAndSwapShortVolatile(o, offset, expected, x);
+    public final boolean weakCompareAndSetShortAcquire(Object o, long offset,
+                                                       short expected,
+                                                       short x) {
+        return weakCompareAndSetShort(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapShortRelease(Object o, long offset,
-                                                        short expected,
-                                                        short x) {
-        return weakCompareAndSwapShortVolatile(o, offset, expected, x);
+    public final boolean weakCompareAndSetShortRelease(Object o, long offset,
+                                                       short expected,
+                                                       short x) {
+        return weakCompareAndSetShort(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapShort(Object o, long offset,
-                                                 short expected,
-                                                 short x) {
-        return weakCompareAndSwapShortVolatile(o, offset, expected, x);
+    public final boolean weakCompareAndSetShortPlain(Object o, long offset,
+                                                     short expected,
+                                                     short x) {
+        return weakCompareAndSetShort(o, offset, expected, x);
     }
 
 
@@ -1527,14 +1527,14 @@
     public final short compareAndExchangeShortAcquire(Object o, long offset,
                                                      short expected,
                                                      short x) {
-        return compareAndExchangeShortVolatile(o, offset, expected, x);
+        return compareAndExchangeShort(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
     public final short compareAndExchangeShortRelease(Object o, long offset,
                                                     short expected,
                                                     short x) {
-        return compareAndExchangeShortVolatile(o, offset, expected, x);
+        return compareAndExchangeShort(o, offset, expected, x);
     }
 
     @ForceInline
@@ -1548,17 +1548,17 @@
     }
 
     @ForceInline
-    public final boolean compareAndSwapChar(Object o, long offset,
-                                            char expected,
-                                            char x) {
-        return compareAndSwapShort(o, offset, c2s(expected), c2s(x));
+    public final boolean compareAndSetChar(Object o, long offset,
+                                           char expected,
+                                           char x) {
+        return compareAndSetShort(o, offset, c2s(expected), c2s(x));
     }
 
     @ForceInline
-    public final char compareAndExchangeCharVolatile(Object o, long offset,
-                                            char expected,
-                                            char x) {
-        return s2c(compareAndExchangeShortVolatile(o, offset, c2s(expected), c2s(x)));
+    public final char compareAndExchangeChar(Object o, long offset,
+                                             char expected,
+                                             char x) {
+        return s2c(compareAndExchangeShort(o, offset, c2s(expected), c2s(x)));
     }
 
     @ForceInline
@@ -1576,31 +1576,31 @@
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapCharVolatile(Object o, long offset,
-                                            char expected,
-                                            char x) {
-        return weakCompareAndSwapShortVolatile(o, offset, c2s(expected), c2s(x));
+    public final boolean weakCompareAndSetChar(Object o, long offset,
+                                               char expected,
+                                               char x) {
+        return weakCompareAndSetShort(o, offset, c2s(expected), c2s(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapCharAcquire(Object o, long offset,
-                                            char expected,
-                                            char x) {
-        return weakCompareAndSwapShortAcquire(o, offset, c2s(expected), c2s(x));
+    public final boolean weakCompareAndSetCharAcquire(Object o, long offset,
+                                                      char expected,
+                                                      char x) {
+        return weakCompareAndSetShortAcquire(o, offset, c2s(expected), c2s(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapCharRelease(Object o, long offset,
-                                            char expected,
-                                            char x) {
-        return weakCompareAndSwapShortRelease(o, offset, c2s(expected), c2s(x));
+    public final boolean weakCompareAndSetCharRelease(Object o, long offset,
+                                                      char expected,
+                                                      char x) {
+        return weakCompareAndSetShortRelease(o, offset, c2s(expected), c2s(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapChar(Object o, long offset,
-                                            char expected,
-                                            char x) {
-        return weakCompareAndSwapShort(o, offset, c2s(expected), c2s(x));
+    public final boolean weakCompareAndSetCharPlain(Object o, long offset,
+                                                    char expected,
+                                                    char x) {
+        return weakCompareAndSetShortPlain(o, offset, c2s(expected), c2s(x));
     }
 
     /**
@@ -1653,17 +1653,17 @@
     }
 
     @ForceInline
-    public final boolean compareAndSwapBoolean(Object o, long offset,
-                                               boolean expected,
-                                               boolean x) {
-        return compareAndSwapByte(o, offset, bool2byte(expected), bool2byte(x));
+    public final boolean compareAndSetBoolean(Object o, long offset,
+                                              boolean expected,
+                                              boolean x) {
+        return compareAndSetByte(o, offset, bool2byte(expected), bool2byte(x));
     }
 
     @ForceInline
-    public final boolean compareAndExchangeBooleanVolatile(Object o, long offset,
-                                                        boolean expected,
-                                                        boolean x) {
-        return byte2bool(compareAndExchangeByteVolatile(o, offset, bool2byte(expected), bool2byte(x)));
+    public final boolean compareAndExchangeBoolean(Object o, long offset,
+                                                   boolean expected,
+                                                   boolean x) {
+        return byte2bool(compareAndExchangeByte(o, offset, bool2byte(expected), bool2byte(x)));
     }
 
     @ForceInline
@@ -1681,31 +1681,31 @@
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapBooleanVolatile(Object o, long offset,
-                                                           boolean expected,
-                                                           boolean x) {
-        return weakCompareAndSwapByteVolatile(o, offset, bool2byte(expected), bool2byte(x));
+    public final boolean weakCompareAndSetBoolean(Object o, long offset,
+                                                  boolean expected,
+                                                  boolean x) {
+        return weakCompareAndSetByte(o, offset, bool2byte(expected), bool2byte(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapBooleanAcquire(Object o, long offset,
-                                                          boolean expected,
-                                                          boolean x) {
-        return weakCompareAndSwapByteAcquire(o, offset, bool2byte(expected), bool2byte(x));
+    public final boolean weakCompareAndSetBooleanAcquire(Object o, long offset,
+                                                         boolean expected,
+                                                         boolean x) {
+        return weakCompareAndSetByteAcquire(o, offset, bool2byte(expected), bool2byte(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapBooleanRelease(Object o, long offset,
-                                                          boolean expected,
-                                                          boolean x) {
-        return weakCompareAndSwapByteRelease(o, offset, bool2byte(expected), bool2byte(x));
+    public final boolean weakCompareAndSetBooleanRelease(Object o, long offset,
+                                                         boolean expected,
+                                                         boolean x) {
+        return weakCompareAndSetByteRelease(o, offset, bool2byte(expected), bool2byte(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapBoolean(Object o, long offset,
-                                                   boolean expected,
-                                                   boolean x) {
-        return weakCompareAndSwapByte(o, offset, bool2byte(expected), bool2byte(x));
+    public final boolean weakCompareAndSetBooleanPlain(Object o, long offset,
+                                                       boolean expected,
+                                                       boolean x) {
+        return weakCompareAndSetBytePlain(o, offset, bool2byte(expected), bool2byte(x));
     }
 
     /**
@@ -1718,21 +1718,21 @@
      * @return {@code true} if successful
      */
     @ForceInline
-    public final boolean compareAndSwapFloat(Object o, long offset,
-                                             float expected,
-                                             float x) {
-        return compareAndSwapInt(o, offset,
+    public final boolean compareAndSetFloat(Object o, long offset,
+                                            float expected,
+                                            float x) {
+        return compareAndSetInt(o, offset,
                                  Float.floatToRawIntBits(expected),
                                  Float.floatToRawIntBits(x));
     }
 
     @ForceInline
-    public final float compareAndExchangeFloatVolatile(Object o, long offset,
-                                                       float expected,
-                                                       float x) {
-        int w = compareAndExchangeIntVolatile(o, offset,
-                                              Float.floatToRawIntBits(expected),
-                                              Float.floatToRawIntBits(x));
+    public final float compareAndExchangeFloat(Object o, long offset,
+                                               float expected,
+                                               float x) {
+        int w = compareAndExchangeInt(o, offset,
+                                      Float.floatToRawIntBits(expected),
+                                      Float.floatToRawIntBits(x));
         return Float.intBitsToFloat(w);
     }
 
@@ -1757,37 +1757,37 @@
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapFloat(Object o, long offset,
-                                               float expected,
-                                               float x) {
-        return weakCompareAndSwapInt(o, offset,
+    public final boolean weakCompareAndSetFloatPlain(Object o, long offset,
+                                                     float expected,
+                                                     float x) {
+        return weakCompareAndSetIntPlain(o, offset,
                                      Float.floatToRawIntBits(expected),
                                      Float.floatToRawIntBits(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapFloatAcquire(Object o, long offset,
-                                                      float expected,
-                                                      float x) {
-        return weakCompareAndSwapIntAcquire(o, offset,
+    public final boolean weakCompareAndSetFloatAcquire(Object o, long offset,
+                                                       float expected,
+                                                       float x) {
+        return weakCompareAndSetIntAcquire(o, offset,
                                             Float.floatToRawIntBits(expected),
                                             Float.floatToRawIntBits(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapFloatRelease(Object o, long offset,
-                                                      float expected,
-                                                      float x) {
-        return weakCompareAndSwapIntRelease(o, offset,
+    public final boolean weakCompareAndSetFloatRelease(Object o, long offset,
+                                                       float expected,
+                                                       float x) {
+        return weakCompareAndSetIntRelease(o, offset,
                                             Float.floatToRawIntBits(expected),
                                             Float.floatToRawIntBits(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapFloatVolatile(Object o, long offset,
-                                                       float expected,
-                                                       float x) {
-        return weakCompareAndSwapIntVolatile(o, offset,
+    public final boolean weakCompareAndSetFloat(Object o, long offset,
+                                                float expected,
+                                                float x) {
+        return weakCompareAndSetInt(o, offset,
                                              Float.floatToRawIntBits(expected),
                                              Float.floatToRawIntBits(x));
     }
@@ -1802,21 +1802,21 @@
      * @return {@code true} if successful
      */
     @ForceInline
-    public final boolean compareAndSwapDouble(Object o, long offset,
-                                              double expected,
-                                              double x) {
-        return compareAndSwapLong(o, offset,
-                                  Double.doubleToRawLongBits(expected),
-                                  Double.doubleToRawLongBits(x));
+    public final boolean compareAndSetDouble(Object o, long offset,
+                                             double expected,
+                                             double x) {
+        return compareAndSetLong(o, offset,
+                                 Double.doubleToRawLongBits(expected),
+                                 Double.doubleToRawLongBits(x));
     }
 
     @ForceInline
-    public final double compareAndExchangeDoubleVolatile(Object o, long offset,
-                                                         double expected,
-                                                         double x) {
-        long w = compareAndExchangeLongVolatile(o, offset,
-                                                Double.doubleToRawLongBits(expected),
-                                                Double.doubleToRawLongBits(x));
+    public final double compareAndExchangeDouble(Object o, long offset,
+                                                 double expected,
+                                                 double x) {
+        long w = compareAndExchangeLong(o, offset,
+                                        Double.doubleToRawLongBits(expected),
+                                        Double.doubleToRawLongBits(x));
         return Double.longBitsToDouble(w);
     }
 
@@ -1841,37 +1841,37 @@
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapDouble(Object o, long offset,
-                                                  double expected,
-                                                  double x) {
-        return weakCompareAndSwapLong(o, offset,
+    public final boolean weakCompareAndSetDoublePlain(Object o, long offset,
+                                                      double expected,
+                                                      double x) {
+        return weakCompareAndSetLongPlain(o, offset,
                                      Double.doubleToRawLongBits(expected),
                                      Double.doubleToRawLongBits(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapDoubleAcquire(Object o, long offset,
-                                                         double expected,
-                                                         double x) {
-        return weakCompareAndSwapLongAcquire(o, offset,
+    public final boolean weakCompareAndSetDoubleAcquire(Object o, long offset,
+                                                        double expected,
+                                                        double x) {
+        return weakCompareAndSetLongAcquire(o, offset,
                                              Double.doubleToRawLongBits(expected),
                                              Double.doubleToRawLongBits(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapDoubleRelease(Object o, long offset,
-                                                         double expected,
-                                                         double x) {
-        return weakCompareAndSwapLongRelease(o, offset,
+    public final boolean weakCompareAndSetDoubleRelease(Object o, long offset,
+                                                        double expected,
+                                                        double x) {
+        return weakCompareAndSetLongRelease(o, offset,
                                              Double.doubleToRawLongBits(expected),
                                              Double.doubleToRawLongBits(x));
     }
 
     @ForceInline
-    public final boolean weakCompareAndSwapDoubleVolatile(Object o, long offset,
-                                                          double expected,
-                                                          double x) {
-        return weakCompareAndSwapLongVolatile(o, offset,
+    public final boolean weakCompareAndSetDouble(Object o, long offset,
+                                                 double expected,
+                                                 double x) {
+        return weakCompareAndSetLong(o, offset,
                                               Double.doubleToRawLongBits(expected),
                                               Double.doubleToRawLongBits(x));
     }
@@ -1886,55 +1886,55 @@
      * @return {@code true} if successful
      */
     @HotSpotIntrinsicCandidate
-    public final native boolean compareAndSwapLong(Object o, long offset,
-                                                   long expected,
-                                                   long x);
+    public final native boolean compareAndSetLong(Object o, long offset,
+                                                  long expected,
+                                                  long x);
 
     @HotSpotIntrinsicCandidate
-    public final native long compareAndExchangeLongVolatile(Object o, long offset,
-                                                            long expected,
-                                                            long x);
+    public final native long compareAndExchangeLong(Object o, long offset,
+                                                    long expected,
+                                                    long x);
 
     @HotSpotIntrinsicCandidate
     public final long compareAndExchangeLongAcquire(Object o, long offset,
                                                            long expected,
                                                            long x) {
-        return compareAndExchangeLongVolatile(o, offset, expected, x);
+        return compareAndExchangeLong(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
     public final long compareAndExchangeLongRelease(Object o, long offset,
                                                            long expected,
                                                            long x) {
-        return compareAndExchangeLongVolatile(o, offset, expected, x);
+        return compareAndExchangeLong(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapLong(Object o, long offset,
-                                                       long expected,
-                                                       long x) {
-        return compareAndSwapLong(o, offset, expected, x);
+    public final boolean weakCompareAndSetLongPlain(Object o, long offset,
+                                                    long expected,
+                                                    long x) {
+        return compareAndSetLong(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapLongAcquire(Object o, long offset,
-                                                              long expected,
-                                                              long x) {
-        return compareAndSwapLong(o, offset, expected, x);
+    public final boolean weakCompareAndSetLongAcquire(Object o, long offset,
+                                                      long expected,
+                                                      long x) {
+        return compareAndSetLong(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapLongRelease(Object o, long offset,
-                                                              long expected,
-                                                              long x) {
-        return compareAndSwapLong(o, offset, expected, x);
+    public final boolean weakCompareAndSetLongRelease(Object o, long offset,
+                                                      long expected,
+                                                      long x) {
+        return compareAndSetLong(o, offset, expected, x);
     }
 
     @HotSpotIntrinsicCandidate
-    public final boolean weakCompareAndSwapLongVolatile(Object o, long offset,
-                                                              long expected,
-                                                              long x) {
-        return compareAndSwapLong(o, offset, expected, x);
+    public final boolean weakCompareAndSetLong(Object o, long offset,
+                                               long expected,
+                                               long x) {
+        return compareAndSetLong(o, offset, expected, x);
     }
 
     /**
@@ -2316,7 +2316,7 @@
         int v;
         do {
             v = getIntVolatile(o, offset);
-        } while (!weakCompareAndSwapIntVolatile(o, offset, v, v + delta));
+        } while (!weakCompareAndSetInt(o, offset, v, v + delta));
         return v;
     }
 
@@ -2325,7 +2325,7 @@
         int v;
         do {
             v = getInt(o, offset);
-        } while (!weakCompareAndSwapIntRelease(o, offset, v, v + delta));
+        } while (!weakCompareAndSetIntRelease(o, offset, v, v + delta));
         return v;
     }
 
@@ -2334,7 +2334,7 @@
         int v;
         do {
             v = getIntAcquire(o, offset);
-        } while (!weakCompareAndSwapIntAcquire(o, offset, v, v + delta));
+        } while (!weakCompareAndSetIntAcquire(o, offset, v, v + delta));
         return v;
     }
 
@@ -2354,7 +2354,7 @@
         long v;
         do {
             v = getLongVolatile(o, offset);
-        } while (!weakCompareAndSwapLongVolatile(o, offset, v, v + delta));
+        } while (!weakCompareAndSetLong(o, offset, v, v + delta));
         return v;
     }
 
@@ -2363,7 +2363,7 @@
         long v;
         do {
             v = getLong(o, offset);
-        } while (!weakCompareAndSwapLongRelease(o, offset, v, v + delta));
+        } while (!weakCompareAndSetLongRelease(o, offset, v, v + delta));
         return v;
     }
 
@@ -2372,7 +2372,7 @@
         long v;
         do {
             v = getLongAcquire(o, offset);
-        } while (!weakCompareAndSwapLongAcquire(o, offset, v, v + delta));
+        } while (!weakCompareAndSetLongAcquire(o, offset, v, v + delta));
         return v;
     }
 
@@ -2381,7 +2381,7 @@
         byte v;
         do {
             v = getByteVolatile(o, offset);
-        } while (!weakCompareAndSwapByteVolatile(o, offset, v, (byte) (v + delta)));
+        } while (!weakCompareAndSetByte(o, offset, v, (byte) (v + delta)));
         return v;
     }
 
@@ -2390,7 +2390,7 @@
         byte v;
         do {
             v = getByte(o, offset);
-        } while (!weakCompareAndSwapByteRelease(o, offset, v, (byte) (v + delta)));
+        } while (!weakCompareAndSetByteRelease(o, offset, v, (byte) (v + delta)));
         return v;
     }
 
@@ -2399,7 +2399,7 @@
         byte v;
         do {
             v = getByteAcquire(o, offset);
-        } while (!weakCompareAndSwapByteAcquire(o, offset, v, (byte) (v + delta)));
+        } while (!weakCompareAndSetByteAcquire(o, offset, v, (byte) (v + delta)));
         return v;
     }
 
@@ -2408,7 +2408,7 @@
         short v;
         do {
             v = getShortVolatile(o, offset);
-        } while (!weakCompareAndSwapShortVolatile(o, offset, v, (short) (v + delta)));
+        } while (!weakCompareAndSetShort(o, offset, v, (short) (v + delta)));
         return v;
     }
 
@@ -2417,7 +2417,7 @@
         short v;
         do {
             v = getShort(o, offset);
-        } while (!weakCompareAndSwapShortRelease(o, offset, v, (short) (v + delta)));
+        } while (!weakCompareAndSetShortRelease(o, offset, v, (short) (v + delta)));
         return v;
     }
 
@@ -2426,7 +2426,7 @@
         short v;
         do {
             v = getShortAcquire(o, offset);
-        } while (!weakCompareAndSwapShortAcquire(o, offset, v, (short) (v + delta)));
+        } while (!weakCompareAndSetShortAcquire(o, offset, v, (short) (v + delta)));
         return v;
     }
 
@@ -2455,7 +2455,7 @@
             // may result in the loop not terminating.
             expectedBits = getIntVolatile(o, offset);
             v = Float.intBitsToFloat(expectedBits);
-        } while (!weakCompareAndSwapIntVolatile(o, offset,
+        } while (!weakCompareAndSetInt(o, offset,
                                                 expectedBits, Float.floatToRawIntBits(v + delta)));
         return v;
     }
@@ -2470,7 +2470,7 @@
             // may result in the loop not terminating.
             expectedBits = getInt(o, offset);
             v = Float.intBitsToFloat(expectedBits);
-        } while (!weakCompareAndSwapIntRelease(o, offset,
+        } while (!weakCompareAndSetIntRelease(o, offset,
                                                expectedBits, Float.floatToRawIntBits(v + delta)));
         return v;
     }
@@ -2485,7 +2485,7 @@
             // may result in the loop not terminating.
             expectedBits = getIntAcquire(o, offset);
             v = Float.intBitsToFloat(expectedBits);
-        } while (!weakCompareAndSwapIntAcquire(o, offset,
+        } while (!weakCompareAndSetIntAcquire(o, offset,
                                                expectedBits, Float.floatToRawIntBits(v + delta)));
         return v;
     }
@@ -2500,7 +2500,7 @@
             // may result in the loop not terminating.
             expectedBits = getLongVolatile(o, offset);
             v = Double.longBitsToDouble(expectedBits);
-        } while (!weakCompareAndSwapLongVolatile(o, offset,
+        } while (!weakCompareAndSetLong(o, offset,
                                                  expectedBits, Double.doubleToRawLongBits(v + delta)));
         return v;
     }
@@ -2515,7 +2515,7 @@
             // may result in the loop not terminating.
             expectedBits = getLong(o, offset);
             v = Double.longBitsToDouble(expectedBits);
-        } while (!weakCompareAndSwapLongRelease(o, offset,
+        } while (!weakCompareAndSetLongRelease(o, offset,
                                                 expectedBits, Double.doubleToRawLongBits(v + delta)));
         return v;
     }
@@ -2530,7 +2530,7 @@
             // may result in the loop not terminating.
             expectedBits = getLongAcquire(o, offset);
             v = Double.longBitsToDouble(expectedBits);
-        } while (!weakCompareAndSwapLongAcquire(o, offset,
+        } while (!weakCompareAndSetLongAcquire(o, offset,
                                                 expectedBits, Double.doubleToRawLongBits(v + delta)));
         return v;
     }
@@ -2551,7 +2551,7 @@
         int v;
         do {
             v = getIntVolatile(o, offset);
-        } while (!weakCompareAndSwapIntVolatile(o, offset, v, newValue));
+        } while (!weakCompareAndSetInt(o, offset, v, newValue));
         return v;
     }
 
@@ -2560,7 +2560,7 @@
         int v;
         do {
             v = getInt(o, offset);
-        } while (!weakCompareAndSwapIntRelease(o, offset, v, newValue));
+        } while (!weakCompareAndSetIntRelease(o, offset, v, newValue));
         return v;
     }
 
@@ -2569,7 +2569,7 @@
         int v;
         do {
             v = getIntAcquire(o, offset);
-        } while (!weakCompareAndSwapIntAcquire(o, offset, v, newValue));
+        } while (!weakCompareAndSetIntAcquire(o, offset, v, newValue));
         return v;
     }
 
@@ -2589,7 +2589,7 @@
         long v;
         do {
             v = getLongVolatile(o, offset);
-        } while (!weakCompareAndSwapLongVolatile(o, offset, v, newValue));
+        } while (!weakCompareAndSetLong(o, offset, v, newValue));
         return v;
     }
 
@@ -2598,7 +2598,7 @@
         long v;
         do {
             v = getLong(o, offset);
-        } while (!weakCompareAndSwapLongRelease(o, offset, v, newValue));
+        } while (!weakCompareAndSetLongRelease(o, offset, v, newValue));
         return v;
     }
 
@@ -2607,7 +2607,7 @@
         long v;
         do {
             v = getLongAcquire(o, offset);
-        } while (!weakCompareAndSwapLongAcquire(o, offset, v, newValue));
+        } while (!weakCompareAndSetLongAcquire(o, offset, v, newValue));
         return v;
     }
 
@@ -2627,7 +2627,7 @@
         Object v;
         do {
             v = getObjectVolatile(o, offset);
-        } while (!weakCompareAndSwapObjectVolatile(o, offset, v, newValue));
+        } while (!weakCompareAndSetObject(o, offset, v, newValue));
         return v;
     }
 
@@ -2636,7 +2636,7 @@
         Object v;
         do {
             v = getObject(o, offset);
-        } while (!weakCompareAndSwapObjectRelease(o, offset, v, newValue));
+        } while (!weakCompareAndSetObjectRelease(o, offset, v, newValue));
         return v;
     }
 
@@ -2645,7 +2645,7 @@
         Object v;
         do {
             v = getObjectAcquire(o, offset);
-        } while (!weakCompareAndSwapObjectAcquire(o, offset, v, newValue));
+        } while (!weakCompareAndSetObjectAcquire(o, offset, v, newValue));
         return v;
     }
 
@@ -2654,7 +2654,7 @@
         byte v;
         do {
             v = getByteVolatile(o, offset);
-        } while (!weakCompareAndSwapByteVolatile(o, offset, v, newValue));
+        } while (!weakCompareAndSetByte(o, offset, v, newValue));
         return v;
     }
 
@@ -2663,7 +2663,7 @@
         byte v;
         do {
             v = getByte(o, offset);
-        } while (!weakCompareAndSwapByteRelease(o, offset, v, newValue));
+        } while (!weakCompareAndSetByteRelease(o, offset, v, newValue));
         return v;
     }
 
@@ -2672,7 +2672,7 @@
         byte v;
         do {
             v = getByteAcquire(o, offset);
-        } while (!weakCompareAndSwapByteAcquire(o, offset, v, newValue));
+        } while (!weakCompareAndSetByteAcquire(o, offset, v, newValue));
         return v;
     }
 
@@ -2696,7 +2696,7 @@
         short v;
         do {
             v = getShortVolatile(o, offset);
-        } while (!weakCompareAndSwapShortVolatile(o, offset, v, newValue));
+        } while (!weakCompareAndSetShort(o, offset, v, newValue));
         return v;
     }
 
@@ -2705,7 +2705,7 @@
         short v;
         do {
             v = getShort(o, offset);
-        } while (!weakCompareAndSwapShortRelease(o, offset, v, newValue));
+        } while (!weakCompareAndSetShortRelease(o, offset, v, newValue));
         return v;
     }
 
@@ -2714,7 +2714,7 @@
         short v;
         do {
             v = getShortAcquire(o, offset);
-        } while (!weakCompareAndSwapShortAcquire(o, offset, v, newValue));
+        } while (!weakCompareAndSetShortAcquire(o, offset, v, newValue));
         return v;
     }
 
@@ -2824,7 +2824,7 @@
         byte current;
         do {
             current = getByteVolatile(o, offset);
-        } while (!weakCompareAndSwapByteVolatile(o, offset,
+        } while (!weakCompareAndSetByte(o, offset,
                                                   current, (byte) (current | mask)));
         return current;
     }
@@ -2834,7 +2834,7 @@
         byte current;
         do {
             current = getByte(o, offset);
-        } while (!weakCompareAndSwapByteRelease(o, offset,
+        } while (!weakCompareAndSetByteRelease(o, offset,
                                                  current, (byte) (current | mask)));
         return current;
     }
@@ -2845,7 +2845,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getByte(o, offset);
-        } while (!weakCompareAndSwapByteAcquire(o, offset,
+        } while (!weakCompareAndSetByteAcquire(o, offset,
                                                  current, (byte) (current | mask)));
         return current;
     }
@@ -2855,7 +2855,7 @@
         byte current;
         do {
             current = getByteVolatile(o, offset);
-        } while (!weakCompareAndSwapByteVolatile(o, offset,
+        } while (!weakCompareAndSetByte(o, offset,
                                                   current, (byte) (current & mask)));
         return current;
     }
@@ -2865,7 +2865,7 @@
         byte current;
         do {
             current = getByte(o, offset);
-        } while (!weakCompareAndSwapByteRelease(o, offset,
+        } while (!weakCompareAndSetByteRelease(o, offset,
                                                  current, (byte) (current & mask)));
         return current;
     }
@@ -2876,7 +2876,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getByte(o, offset);
-        } while (!weakCompareAndSwapByteAcquire(o, offset,
+        } while (!weakCompareAndSetByteAcquire(o, offset,
                                                  current, (byte) (current & mask)));
         return current;
     }
@@ -2886,7 +2886,7 @@
         byte current;
         do {
             current = getByteVolatile(o, offset);
-        } while (!weakCompareAndSwapByteVolatile(o, offset,
+        } while (!weakCompareAndSetByte(o, offset,
                                                   current, (byte) (current ^ mask)));
         return current;
     }
@@ -2896,7 +2896,7 @@
         byte current;
         do {
             current = getByte(o, offset);
-        } while (!weakCompareAndSwapByteRelease(o, offset,
+        } while (!weakCompareAndSetByteRelease(o, offset,
                                                  current, (byte) (current ^ mask)));
         return current;
     }
@@ -2907,7 +2907,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getByte(o, offset);
-        } while (!weakCompareAndSwapByteAcquire(o, offset,
+        } while (!weakCompareAndSetByteAcquire(o, offset,
                                                  current, (byte) (current ^ mask)));
         return current;
     }
@@ -2964,7 +2964,7 @@
         short current;
         do {
             current = getShortVolatile(o, offset);
-        } while (!weakCompareAndSwapShortVolatile(o, offset,
+        } while (!weakCompareAndSetShort(o, offset,
                                                 current, (short) (current | mask)));
         return current;
     }
@@ -2974,7 +2974,7 @@
         short current;
         do {
             current = getShort(o, offset);
-        } while (!weakCompareAndSwapShortRelease(o, offset,
+        } while (!weakCompareAndSetShortRelease(o, offset,
                                                current, (short) (current | mask)));
         return current;
     }
@@ -2985,7 +2985,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getShort(o, offset);
-        } while (!weakCompareAndSwapShortAcquire(o, offset,
+        } while (!weakCompareAndSetShortAcquire(o, offset,
                                                current, (short) (current | mask)));
         return current;
     }
@@ -2995,7 +2995,7 @@
         short current;
         do {
             current = getShortVolatile(o, offset);
-        } while (!weakCompareAndSwapShortVolatile(o, offset,
+        } while (!weakCompareAndSetShort(o, offset,
                                                 current, (short) (current & mask)));
         return current;
     }
@@ -3005,7 +3005,7 @@
         short current;
         do {
             current = getShort(o, offset);
-        } while (!weakCompareAndSwapShortRelease(o, offset,
+        } while (!weakCompareAndSetShortRelease(o, offset,
                                                current, (short) (current & mask)));
         return current;
     }
@@ -3016,7 +3016,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getShort(o, offset);
-        } while (!weakCompareAndSwapShortAcquire(o, offset,
+        } while (!weakCompareAndSetShortAcquire(o, offset,
                                                current, (short) (current & mask)));
         return current;
     }
@@ -3026,7 +3026,7 @@
         short current;
         do {
             current = getShortVolatile(o, offset);
-        } while (!weakCompareAndSwapShortVolatile(o, offset,
+        } while (!weakCompareAndSetShort(o, offset,
                                                 current, (short) (current ^ mask)));
         return current;
     }
@@ -3036,7 +3036,7 @@
         short current;
         do {
             current = getShort(o, offset);
-        } while (!weakCompareAndSwapShortRelease(o, offset,
+        } while (!weakCompareAndSetShortRelease(o, offset,
                                                current, (short) (current ^ mask)));
         return current;
     }
@@ -3047,7 +3047,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getShort(o, offset);
-        } while (!weakCompareAndSwapShortAcquire(o, offset,
+        } while (!weakCompareAndSetShortAcquire(o, offset,
                                                current, (short) (current ^ mask)));
         return current;
     }
@@ -3058,7 +3058,7 @@
         int current;
         do {
             current = getIntVolatile(o, offset);
-        } while (!weakCompareAndSwapIntVolatile(o, offset,
+        } while (!weakCompareAndSetInt(o, offset,
                                                 current, current | mask));
         return current;
     }
@@ -3068,7 +3068,7 @@
         int current;
         do {
             current = getInt(o, offset);
-        } while (!weakCompareAndSwapIntRelease(o, offset,
+        } while (!weakCompareAndSetIntRelease(o, offset,
                                                current, current | mask));
         return current;
     }
@@ -3079,7 +3079,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getInt(o, offset);
-        } while (!weakCompareAndSwapIntAcquire(o, offset,
+        } while (!weakCompareAndSetIntAcquire(o, offset,
                                                current, current | mask));
         return current;
     }
@@ -3100,7 +3100,7 @@
         int current;
         do {
             current = getIntVolatile(o, offset);
-        } while (!weakCompareAndSwapIntVolatile(o, offset,
+        } while (!weakCompareAndSetInt(o, offset,
                                                 current, current & mask));
         return current;
     }
@@ -3110,7 +3110,7 @@
         int current;
         do {
             current = getInt(o, offset);
-        } while (!weakCompareAndSwapIntRelease(o, offset,
+        } while (!weakCompareAndSetIntRelease(o, offset,
                                                current, current & mask));
         return current;
     }
@@ -3121,7 +3121,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getInt(o, offset);
-        } while (!weakCompareAndSwapIntAcquire(o, offset,
+        } while (!weakCompareAndSetIntAcquire(o, offset,
                                                current, current & mask));
         return current;
     }
@@ -3131,7 +3131,7 @@
         int current;
         do {
             current = getIntVolatile(o, offset);
-        } while (!weakCompareAndSwapIntVolatile(o, offset,
+        } while (!weakCompareAndSetInt(o, offset,
                                                 current, current ^ mask));
         return current;
     }
@@ -3141,7 +3141,7 @@
         int current;
         do {
             current = getInt(o, offset);
-        } while (!weakCompareAndSwapIntRelease(o, offset,
+        } while (!weakCompareAndSetIntRelease(o, offset,
                                                current, current ^ mask));
         return current;
     }
@@ -3152,7 +3152,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getInt(o, offset);
-        } while (!weakCompareAndSwapIntAcquire(o, offset,
+        } while (!weakCompareAndSetIntAcquire(o, offset,
                                                current, current ^ mask));
         return current;
     }
@@ -3163,7 +3163,7 @@
         long current;
         do {
             current = getLongVolatile(o, offset);
-        } while (!weakCompareAndSwapLongVolatile(o, offset,
+        } while (!weakCompareAndSetLong(o, offset,
                                                 current, current | mask));
         return current;
     }
@@ -3173,7 +3173,7 @@
         long current;
         do {
             current = getLong(o, offset);
-        } while (!weakCompareAndSwapLongRelease(o, offset,
+        } while (!weakCompareAndSetLongRelease(o, offset,
                                                current, current | mask));
         return current;
     }
@@ -3184,7 +3184,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getLong(o, offset);
-        } while (!weakCompareAndSwapLongAcquire(o, offset,
+        } while (!weakCompareAndSetLongAcquire(o, offset,
                                                current, current | mask));
         return current;
     }
@@ -3194,7 +3194,7 @@
         long current;
         do {
             current = getLongVolatile(o, offset);
-        } while (!weakCompareAndSwapLongVolatile(o, offset,
+        } while (!weakCompareAndSetLong(o, offset,
                                                 current, current & mask));
         return current;
     }
@@ -3204,7 +3204,7 @@
         long current;
         do {
             current = getLong(o, offset);
-        } while (!weakCompareAndSwapLongRelease(o, offset,
+        } while (!weakCompareAndSetLongRelease(o, offset,
                                                current, current & mask));
         return current;
     }
@@ -3215,7 +3215,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getLong(o, offset);
-        } while (!weakCompareAndSwapLongAcquire(o, offset,
+        } while (!weakCompareAndSetLongAcquire(o, offset,
                                                current, current & mask));
         return current;
     }
@@ -3225,7 +3225,7 @@
         long current;
         do {
             current = getLongVolatile(o, offset);
-        } while (!weakCompareAndSwapLongVolatile(o, offset,
+        } while (!weakCompareAndSetLong(o, offset,
                                                 current, current ^ mask));
         return current;
     }
@@ -3235,7 +3235,7 @@
         long current;
         do {
             current = getLong(o, offset);
-        } while (!weakCompareAndSwapLongRelease(o, offset,
+        } while (!weakCompareAndSetLongRelease(o, offset,
                                                current, current ^ mask));
         return current;
     }
@@ -3246,7 +3246,7 @@
         do {
             // Plain read, the value is a hint, the acquire CAS does the work
             current = getLong(o, offset);
-        } while (!weakCompareAndSwapLongAcquire(o, offset,
+        } while (!weakCompareAndSetLongAcquire(o, offset,
                                                current, current ^ mask));
         return current;
     }
--- a/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
     }
--- a/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/invoke/util/Wrapper.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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) ||
--- a/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/launcher/LauncherHelper.java	Wed Jul 05 23:37:13 2017 +0200
@@ -363,10 +363,6 @@
     static void initHelpMessage(String progname) {
         outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.header",
                 (progname == null) ? "java" : progname ));
-        outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.datamodel",
-                32));
-        outBuf = outBuf.append(getLocalizedMessage("java.launcher.opt.datamodel",
-                64));
     }
 
     /**
--- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties	Wed Jul 05 23:37:13 2017 +0200
@@ -34,7 +34,6 @@
 \ <module>/<mainclass> are passed as the arguments to main class.\n\n\
 \ where options include:\n\n
 
-java.launcher.opt.datamodel  =\    -d{0}\t  Deprecated, will be removed in a future release\n
 java.launcher.opt.vmselect   =\    {0}\t  to select the "{1}" VM\n
 java.launcher.opt.hotspot    =\    {0}\t  is a synonym for the "{1}" VM  [deprecated]\n
 
--- a/jdk/src/java.base/share/classes/sun/security/provider/X509Factory.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/provider/X509Factory.java	Wed Jul 05 23:37:13 2017 +0200
@@ -553,8 +553,7 @@
             return bout.toByteArray();
         } else {
             // Read BASE64 encoded data, might skip info at the beginning
-            char[] data = new char[2048];
-            int pos = 0;
+            ByteArrayOutputStream data = new ByteArrayOutputStream();
 
             // Step 1: Read until header is found
             int hyphen = (c=='-') ? 1: 0;   // count of consequent hyphens
@@ -598,7 +597,10 @@
                         end = '\n';
                     } else {
                         end = '\r';
-                        data[pos++] = (char)next;
+                        // Skip all white space chars
+                        if (next != 9 && next != 10 && next != 13 && next != 32) {
+                            data.write(next);
+                        }
                     }
                     break;
                 }
@@ -612,9 +614,9 @@
                     throw new IOException("Incomplete data");
                 }
                 if (next != '-') {
-                    data[pos++] = (char)next;
-                    if (pos >= data.length) {
-                        data = Arrays.copyOf(data, data.length+1024);
+                    // Skip all white space chars
+                    if (next != 9 && next != 10 && next != 13 && next != 32) {
+                        data.write(next);
                     }
                 } else {
                     break;
@@ -635,7 +637,11 @@
 
             checkHeaderFooter(header.toString(), footer.toString());
 
-            return Pem.decode(new String(data, 0, pos));
+            try {
+                return Base64.getDecoder().decode(data.toByteArray());
+            } catch (IllegalArgumentException e) {
+                throw new IOException(e);
+            }
         }
     }
 
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/AdaptableX509CertSelector.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -214,7 +214,7 @@
         try {
             byte[] extVal = xcert.getExtensionValue("2.5.29.14");
             if (extVal == null) {
-                if (debug != null) {
+                if (debug != null && Debug.isVerbose()) {
                     debug.println("AdaptableX509CertSelector.match: "
                         + "no subject key ID extension. Subject: "
                         + xcert.getSubjectX500Principal());
@@ -225,7 +225,7 @@
             byte[] certSubjectKeyID = in.getOctetString();
             if (certSubjectKeyID == null ||
                     !Arrays.equals(ski, certSubjectKeyID)) {
-                if (debug != null) {
+                if (debug != null && Debug.isVerbose()) {
                     debug.println("AdaptableX509CertSelector.match: "
                         + "subject key IDs don't match. "
                         + "Expected: " + Arrays.toString(ski) + " "
@@ -234,7 +234,7 @@
                 return false;
             }
         } catch (IOException ex) {
-            if (debug != null) {
+            if (debug != null && Debug.isVerbose()) {
                 debug.println("AdaptableX509CertSelector.match: "
                     + "exception in subject key ID check");
             }
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java	Wed Jul 05 23:37:13 2017 +0200
@@ -117,7 +117,7 @@
                 // if this trust anchor is not worth trying,
                 // we move on to the next one
                 if (selector != null && !selector.match(trustedCert)) {
-                    if (debug != null) {
+                    if (debug != null && Debug.isVerbose()) {
                         debug.println("NO - don't try this trustedCert");
                     }
                     continue;
--- a/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/provider/certpath/RevocationChecker.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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.
--- a/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuite.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuite.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,6 +44,7 @@
 import static sun.security.ssl.CipherSuite.MacAlg.*;
 import static sun.security.ssl.CipherSuite.BulkCipher.*;
 import static sun.security.ssl.JsseJce.*;
+import static sun.security.ssl.NamedGroupType.*;
 
 /**
  * An SSL/TLS CipherSuite. Constants for the standard key exchange, cipher,
@@ -376,38 +377,38 @@
     static enum KeyExchange {
 
         // key exchange algorithms
-        K_NULL       ("NULL",       false,      false),
-        K_RSA        ("RSA",        true,       false),
-        K_RSA_EXPORT ("RSA_EXPORT", true,       false),
-        K_DH_RSA     ("DH_RSA",     false,      false),
-        K_DH_DSS     ("DH_DSS",     false,      false),
-        K_DHE_DSS    ("DHE_DSS",    true,       false),
-        K_DHE_RSA    ("DHE_RSA",    true,       false),
-        K_DH_ANON    ("DH_anon",    true,       false),
+        K_NULL       ("NULL",       false,      NAMED_GROUP_NONE),
+        K_RSA        ("RSA",        true,       NAMED_GROUP_NONE),
+        K_RSA_EXPORT ("RSA_EXPORT", true,       NAMED_GROUP_NONE),
+        K_DH_RSA     ("DH_RSA",     false,      NAMED_GROUP_NONE),
+        K_DH_DSS     ("DH_DSS",     false,      NAMED_GROUP_NONE),
+        K_DHE_DSS    ("DHE_DSS",    true,       NAMED_GROUP_FFDHE),
+        K_DHE_RSA    ("DHE_RSA",    true,       NAMED_GROUP_FFDHE),
+        K_DH_ANON    ("DH_anon",    true,       NAMED_GROUP_FFDHE),
 
-        K_ECDH_ECDSA ("ECDH_ECDSA",  ALLOW_ECC, true),
-        K_ECDH_RSA   ("ECDH_RSA",    ALLOW_ECC, true),
-        K_ECDHE_ECDSA("ECDHE_ECDSA", ALLOW_ECC, true),
-        K_ECDHE_RSA  ("ECDHE_RSA",   ALLOW_ECC, true),
-        K_ECDH_ANON  ("ECDH_anon",   ALLOW_ECC, true),
+        K_ECDH_ECDSA ("ECDH_ECDSA",  ALLOW_ECC, NAMED_GROUP_ECDHE),
+        K_ECDH_RSA   ("ECDH_RSA",    ALLOW_ECC, NAMED_GROUP_ECDHE),
+        K_ECDHE_ECDSA("ECDHE_ECDSA", ALLOW_ECC, NAMED_GROUP_ECDHE),
+        K_ECDHE_RSA  ("ECDHE_RSA",   ALLOW_ECC, NAMED_GROUP_ECDHE),
+        K_ECDH_ANON  ("ECDH_anon",   ALLOW_ECC, NAMED_GROUP_ECDHE),
 
         // Kerberos cipher suites
-        K_KRB5       ("KRB5", true,             false),
-        K_KRB5_EXPORT("KRB5_EXPORT", true,      false),
+        K_KRB5       ("KRB5", true,             NAMED_GROUP_NONE),
+        K_KRB5_EXPORT("KRB5_EXPORT", true,      NAMED_GROUP_NONE),
 
         // renegotiation protection request signaling cipher suite
-        K_SCSV       ("SCSV",        true,      false);
+        K_SCSV       ("SCSV",        true,      NAMED_GROUP_NONE);
 
         // name of the key exchange algorithm, e.g. DHE_DSS
         final String name;
         final boolean allowed;
-        final boolean isEC;
+        final NamedGroupType groupType;
         private final boolean alwaysAvailable;
 
-        KeyExchange(String name, boolean allowed, boolean isEC) {
+        KeyExchange(String name, boolean allowed, NamedGroupType groupType) {
             this.name = name;
             this.allowed = allowed;
-            this.isEC = isEC;
+            this.groupType = groupType;
             this.alwaysAvailable = allowed &&
                 (!name.startsWith("EC")) && (!name.startsWith("KRB"));
         }
@@ -417,7 +418,7 @@
                 return true;
             }
 
-            if (isEC) {
+            if (groupType == NAMED_GROUP_ECDHE) {
                 return (allowed && JsseJce.isEcAvailable());
             } else if (name.startsWith("KRB")) {
                 return (allowed && JsseJce.isKerberosAvailable());
--- a/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuiteList.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/CipherSuiteList.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 import java.util.*;
 
 import javax.net.ssl.SSLException;
+import static sun.security.ssl.NamedGroupType.*;
 
 /**
  * A list of CipherSuites. Also maintains the lists of supported and
@@ -42,15 +43,16 @@
 
     private final Collection<CipherSuite> cipherSuites;
     private String[] suiteNames;
-
-    // flag indicating whether this list contains any ECC ciphersuites.
-    // null if not yet checked.
-    private volatile Boolean containsEC;
+    private final EnumSet<NamedGroupType> groupsTypes =
+            EnumSet.noneOf(NamedGroupType.class);
 
     // for use by buildAvailableCache() and
     // Handshaker.getKickstartMessage() only
     CipherSuiteList(Collection<CipherSuite> cipherSuites) {
         this.cipherSuites = cipherSuites;
+        for (CipherSuite suite : cipherSuites) {
+            updateGroupTypes(suite);
+        }
     }
 
     /**
@@ -59,6 +61,7 @@
     CipherSuiteList(CipherSuite suite) {
         cipherSuites = new ArrayList<CipherSuite>(1);
         cipherSuites.add(suite);
+        updateGroupTypes(suite);
     }
 
     /**
@@ -82,6 +85,7 @@
                     + suiteName + " with currently installed providers");
             }
             cipherSuites.add(suite);
+            updateGroupTypes(suite);
         }
     }
 
@@ -97,7 +101,20 @@
         }
         cipherSuites = new ArrayList<CipherSuite>(bytes.length >> 1);
         for (int i = 0; i < bytes.length; i += 2) {
-            cipherSuites.add(CipherSuite.valueOf(bytes[i], bytes[i+1]));
+            CipherSuite suite = CipherSuite.valueOf(bytes[i], bytes[i+1]);
+            cipherSuites.add(suite);
+            updateGroupTypes(suite);
+        }
+    }
+
+    // Please don't use this method except constructors.
+    private void updateGroupTypes(CipherSuite cipherSuite) {
+        if (cipherSuite.keyExchange != null && (!cipherSuite.exportable)) {
+            NamedGroupType groupType = cipherSuite.keyExchange.groupType;
+            if ((groupType != NAMED_GROUP_NONE) &&
+                    (!groupsTypes.contains(groupType))) {
+                groupsTypes.add(groupType);
+            }
         }
     }
 
@@ -108,20 +125,9 @@
         return cipherSuites.contains(suite);
     }
 
-    // Return whether this list contains any ECC ciphersuites
-    boolean containsEC() {
-        if (containsEC == null) {
-            for (CipherSuite c : cipherSuites) {
-                if (c.keyExchange.isEC) {
-                    containsEC = true;
-                    return true;
-                }
-            }
-
-            containsEC = false;
-        }
-
-        return containsEC;
+    // Return whether this list contains cipher suites of a named group type.
+    boolean contains(NamedGroupType groupType) {
+        return groupsTypes.contains(groupType);
     }
 
     /**
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ClientHandshaker.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -148,6 +148,10 @@
     private static final boolean enableMFLExtension =
             Debug.getBooleanProperty("jsse.enableMFLExtension", false);
 
+    // To switch off the supported_groups extension for DHE cipher suite.
+    private static final boolean enableFFDHE =
+            Debug.getBooleanProperty("jsse.enableFFDHE", true);
+
     // Whether an ALPN extension was sent in the ClientHello
     private boolean alpnActive = false;
 
@@ -767,13 +771,15 @@
                     fatalSE(Alerts.alert_unexpected_message, "Server set " +
                             type + " extension when not requested by client");
                 }
-            } else if ((type != ExtensionType.EXT_ELLIPTIC_CURVES)
+            } else if ((type != ExtensionType.EXT_SUPPORTED_GROUPS)
                     && (type != ExtensionType.EXT_EC_POINT_FORMATS)
                     && (type != ExtensionType.EXT_SERVER_NAME)
                     && (type != ExtensionType.EXT_ALPN)
                     && (type != ExtensionType.EXT_RENEGOTIATION_INFO)
                     && (type != ExtensionType.EXT_STATUS_REQUEST)
                     && (type != ExtensionType.EXT_STATUS_REQUEST_V2)) {
+                // Note: Better to check client requested extensions rather
+                // than all supported extensions.
                 fatalSE(Alerts.alert_unsupported_extension,
                     "Server sent an unsupported extension: " + type);
             }
@@ -823,6 +829,17 @@
      * our own D-H algorithm object so we can defer key calculations
      * until after we've sent the client key exchange message (which
      * gives client and server some useful parallelism).
+     *
+     * Note per section 3 of RFC 7919, if the server is not compatible with
+     * FFDHE specification, the client MAY decide to continue the connection
+     * if the selected DHE group is acceptable under local policy, or it MAY
+     * decide to terminate the connection with a fatal insufficient_security
+     * (71) alert.  The algorithm constraints mechanism is JDK local policy
+     * used for additional DHE parameters checking.  So this implementation
+     * does not check the server compatibility and just pass to the local
+     * algorithm constraints checking.  The client will continue the
+     * connection if the server selected DHE group is acceptable by the
+     * specified algorithm constraints.
      */
     private void serverKeyExchange(DH_ServerKeyExchange mesg)
             throws IOException {
@@ -1495,14 +1512,17 @@
                 sslContext.getSecureRandom(), maxProtocolVersion,
                 sessionId, cipherSuites, isDTLS);
 
-        // add elliptic curves and point format extensions
-        if (cipherSuites.containsEC()) {
-            EllipticCurvesExtension ece =
-                EllipticCurvesExtension.createExtension(algorithmConstraints);
-            if (ece != null) {
-                clientHelloMessage.extensions.add(ece);
+        // Add named groups extension for ECDHE and FFDHE if necessary.
+        SupportedGroupsExtension sge =
+                SupportedGroupsExtension.createExtension(
+                        algorithmConstraints,
+                        cipherSuites, enableFFDHE);
+        if (sge != null) {
+            clientHelloMessage.extensions.add(sge);
+            // Add elliptic point format extensions
+            if (cipherSuites.contains(NamedGroupType.NAMED_GROUP_ECDHE)) {
                 clientHelloMessage.extensions.add(
-                        EllipticPointFormatsExtension.DEFAULT);
+                    EllipticPointFormatsExtension.DEFAULT);
             }
         }
 
--- a/jdk/src/java.base/share/classes/sun/security/ssl/DHCrypt.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/DHCrypt.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,14 +26,8 @@
 
 package sun.security.ssl;
 
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
-import java.util.regex.Pattern;
-import java.util.regex.Matcher;
 import java.math.BigInteger;
 import java.security.*;
-import java.io.IOException;
 import javax.net.ssl.SSLHandshakeException;
 import javax.crypto.SecretKey;
 import javax.crypto.KeyAgreement;
@@ -101,7 +95,7 @@
      */
     DHCrypt(int keyLength, SecureRandom random) {
         this(keyLength,
-                ParametersHolder.definedParams.get(keyLength), random);
+            PredefinedDHParameterSpecs.definedParams.get(keyLength), random);
     }
 
     /**
@@ -116,6 +110,14 @@
     }
 
     /**
+     * Generate a Diffie-Hellman keypair using the named group.
+     */
+    DHCrypt(NamedGroup namedGroup, SecureRandom random) {
+        this(-1,        // The length (-1) is not used in the implementation.
+            SupportedGroupsExtension.getDHParameterSpec(namedGroup), random);
+    }
+
+    /**
      * Generate a Diffie-Hellman keypair using the specified size and
      * parameters.
      */
@@ -272,266 +274,5 @@
 
         return null;
     }
-
-    // lazy initialization holder class idiom for static default parameters
-    //
-    // See Effective Java Second Edition: Item 71.
-    private static class ParametersHolder {
-        private final static boolean debugIsOn =
-                (Debug.getInstance("ssl") != null) && Debug.isOn("sslctx");
-
-        //
-        // Default DH ephemeral parameters
-        //
-        private static final BigInteger p512 = new BigInteger(   // generated
-                "D87780E15FF50B4ABBE89870188B049406B5BEA98AB23A02" +
-                "41D88EA75B7755E669C08093D3F0CA7FC3A5A25CF067DCB9" +
-                "A43DD89D1D90921C6328884461E0B6D3", 16);
-        private static final BigInteger p768 = new BigInteger(   // RFC 2409
-                "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
-                "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
-                "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
-                "E485B576625E7EC6F44C42E9A63A3620FFFFFFFFFFFFFFFF", 16);
+}
 
-        private static final BigInteger p1024 = new BigInteger(  // RFC 2409
-                "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
-                "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
-                "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
-                "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
-                "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381" +
-                "FFFFFFFFFFFFFFFF", 16);
-        private static final BigInteger p1536 = new BigInteger(  // RFC 3526
-                "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
-                "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
-                "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
-                "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
-                "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" +
-                "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" +
-                "83655D23DCA3AD961C62F356208552BB9ED529077096966D" +
-                "670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF", 16);
-        private static final BigInteger p2048 = new BigInteger(  // TLS FFDHE
-                "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
-                "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
-                "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
-                "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
-                "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
-                "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
-                "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
-                "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
-                "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
-                "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
-                "886B423861285C97FFFFFFFFFFFFFFFF", 16);
-        private static final BigInteger p3072 = new BigInteger(  // TLS FFDHE
-                "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
-                "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
-                "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
-                "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
-                "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
-                "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
-                "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
-                "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
-                "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
-                "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
-                "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
-                "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
-                "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
-                "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
-                "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
-                "3C1B20EE3FD59D7C25E41D2B66C62E37FFFFFFFFFFFFFFFF", 16);
-        private static final BigInteger p4096 = new BigInteger(  // TLS FFDHE
-                "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
-                "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
-                "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
-                "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
-                "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
-                "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
-                "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
-                "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
-                "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
-                "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
-                "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
-                "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
-                "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
-                "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
-                "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
-                "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
-                "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
-                "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
-                "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
-                "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
-                "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E655F6A" +
-                "FFFFFFFFFFFFFFFF", 16);
-        private static final BigInteger p6144 = new BigInteger(  // TLS FFDHE
-                "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
-                "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
-                "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
-                "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
-                "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
-                "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
-                "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
-                "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
-                "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
-                "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
-                "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
-                "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
-                "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
-                "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
-                "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
-                "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
-                "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
-                "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
-                "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
-                "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
-                "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD902" +
-                "0BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA6" +
-                "3BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3A" +
-                "CDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477" +
-                "A52471F7A9A96910B855322EDB6340D8A00EF092350511E3" +
-                "0ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4" +
-                "763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6" +
-                "B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538C" +
-                "D72B03746AE77F5E62292C311562A846505DC82DB854338A" +
-                "E49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B04" +
-                "5B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1" +
-                "A41D570D7938DAD4A40E329CD0E40E65FFFFFFFFFFFFFFFF", 16);
-        private static final BigInteger p8192 = new BigInteger(  // TLS FFDHE
-                "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
-                "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
-                "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
-                "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
-                "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
-                "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
-                "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
-                "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
-                "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
-                "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
-                "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
-                "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
-                "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
-                "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
-                "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
-                "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
-                "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
-                "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
-                "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
-                "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
-                "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD902" +
-                "0BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA6" +
-                "3BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3A" +
-                "CDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477" +
-                "A52471F7A9A96910B855322EDB6340D8A00EF092350511E3" +
-                "0ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4" +
-                "763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6" +
-                "B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538C" +
-                "D72B03746AE77F5E62292C311562A846505DC82DB854338A" +
-                "E49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B04" +
-                "5B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1" +
-                "A41D570D7938DAD4A40E329CCFF46AAA36AD004CF600C838" +
-                "1E425A31D951AE64FDB23FCEC9509D43687FEB69EDD1CC5E" +
-                "0B8CC3BDF64B10EF86B63142A3AB8829555B2F747C932665" +
-                "CB2C0F1CC01BD70229388839D2AF05E454504AC78B758282" +
-                "2846C0BA35C35F5C59160CC046FD8251541FC68C9C86B022" +
-                "BB7099876A460E7451A8A93109703FEE1C217E6C3826E52C" +
-                "51AA691E0E423CFC99E9E31650C1217B624816CDAD9A95F9" +
-                "D5B8019488D9C0A0A1FE3075A577E23183F81D4A3F2FA457" +
-                "1EFC8CE0BA8A4FE8B6855DFE72B0A66EDED2FBABFBE58A30" +
-                "FAFABE1C5D71A87E2F741EF8C1FE86FEA6BBFDE530677F0D" +
-                "97D11D49F7A8443D0822E506A9F4614E011E2A94838FF88C" +
-                "D68C8BB7C5C6424CFFFFFFFFFFFFFFFF", 16);
-
-        private static final BigInteger[] supportedPrimes = {
-                p512, p768, p1024, p1536, p2048, p3072, p4096, p6144, p8192};
-
-        // a measure of the uncertainty that prime modulus p is not a prime
-        //
-        // see BigInteger.isProbablePrime(int certainty)
-        private final static int PRIME_CERTAINTY = 120;
-
-        // the known security property, jdk.tls.server.defaultDHEParameters
-        private final static String PROPERTY_NAME =
-                "jdk.tls.server.defaultDHEParameters";
-
-        private static final Pattern spacesPattern = Pattern.compile("\\s+");
-
-        private final static Pattern syntaxPattern = Pattern.compile(
-                "(\\{[0-9A-Fa-f]+,[0-9A-Fa-f]+\\})" +
-                "(,\\{[0-9A-Fa-f]+,[0-9A-Fa-f]+\\})*");
-
-        private static final Pattern paramsPattern = Pattern.compile(
-                "\\{([0-9A-Fa-f]+),([0-9A-Fa-f]+)\\}");
-
-        // cache of predefined default DH ephemeral parameters
-        private final static Map<Integer,DHParameterSpec> definedParams;
-
-        static {
-            String property = AccessController.doPrivileged(
-                new PrivilegedAction<String>() {
-                    public String run() {
-                        return Security.getProperty(PROPERTY_NAME);
-                    }
-                });
-
-            if (property != null && !property.isEmpty()) {
-                // remove double quote marks from beginning/end of the property
-                if (property.length() >= 2 && property.charAt(0) == '"' &&
-                        property.charAt(property.length() - 1) == '"') {
-                    property = property.substring(1, property.length() - 1);
-                }
-
-                property = property.trim();
-            }
-
-            if (property != null && !property.isEmpty()) {
-                Matcher spacesMatcher = spacesPattern.matcher(property);
-                property = spacesMatcher.replaceAll("");
-
-                if (debugIsOn) {
-                    System.out.println("The Security Property " +
-                            PROPERTY_NAME + ": " + property);
-                }
-            }
-
-            Map<Integer,DHParameterSpec> defaultParams = new HashMap<>();
-            if (property != null && !property.isEmpty()) {
-                Matcher syntaxMatcher = syntaxPattern.matcher(property);
-                if (syntaxMatcher.matches()) {
-                    Matcher paramsFinder = paramsPattern.matcher(property);
-                    while(paramsFinder.find()) {
-                        String primeModulus = paramsFinder.group(1);
-                        BigInteger p = new BigInteger(primeModulus, 16);
-                        if (!p.isProbablePrime(PRIME_CERTAINTY)) {
-                            if (debugIsOn) {
-                                System.out.println(
-                                    "Prime modulus p in Security Property, " +
-                                    PROPERTY_NAME + ", is not a prime: " +
-                                    primeModulus);
-                            }
-
-                            continue;
-                        }
-
-                        String baseGenerator = paramsFinder.group(2);
-                        BigInteger g = new BigInteger(baseGenerator, 16);
-
-                        DHParameterSpec spec = new DHParameterSpec(p, g);
-                        int primeLen = p.bitLength();
-                        defaultParams.put(primeLen, spec);
-                    }
-                } else if (debugIsOn) {
-                    System.out.println("Invalid Security Property, " +
-                            PROPERTY_NAME + ", definition");
-                }
-            }
-
-            for (BigInteger p : supportedPrimes) {
-                int primeLen = p.bitLength();
-                defaultParams.putIfAbsent(primeLen,
-                        new DHParameterSpec(p, BigInteger.TWO));
-            }
-
-            definedParams =
-                    Collections.<Integer,DHParameterSpec>unmodifiableMap(
-                                                                defaultParams);
-        }
-    }
-}
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ECDHCrypt.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ECDHCrypt.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -56,17 +56,17 @@
     }
 
     // Called by ServerHandshaker for ephemeral ECDH
-    ECDHCrypt(int curveId, SecureRandom random) {
+    ECDHCrypt(NamedGroup namedGroup, SecureRandom random) {
         try {
             KeyPairGenerator kpg = JsseJce.getKeyPairGenerator("EC");
             ECGenParameterSpec params =
-                    EllipticCurvesExtension.getECGenParamSpec(curveId);
+                    SupportedGroupsExtension.getECGenParamSpec(namedGroup);
             kpg.initialize(params, random);
             KeyPair kp = kpg.generateKeyPair();
             privateKey = kp.getPrivate();
             publicKey = (ECPublicKey)kp.getPublic();
         } catch (GeneralSecurityException e) {
-            throw new RuntimeException("Could not generate DH keypair", e);
+            throw new RuntimeException("Could not generate ECDH keypair", e);
         }
     }
 
@@ -79,7 +79,7 @@
             privateKey = kp.getPrivate();
             publicKey = (ECPublicKey)kp.getPublic();
         } catch (GeneralSecurityException e) {
-            throw new RuntimeException("Could not generate DH keypair", e);
+            throw new RuntimeException("Could not generate ECDH keypair", e);
         }
     }
 
--- a/jdk/src/java.base/share/classes/sun/security/ssl/EllipticCurvesExtension.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,400 +0,0 @@
-/*
- * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.ssl;
-
-import java.io.IOException;
-import java.security.spec.ECParameterSpec;
-import java.security.spec.ECGenParameterSpec;
-import java.security.spec.InvalidParameterSpecException;
-import java.security.AlgorithmParameters;
-import java.security.AlgorithmConstraints;
-import java.security.CryptoPrimitive;
-import java.security.AccessController;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.ArrayList;
-import javax.net.ssl.SSLProtocolException;
-
-import sun.security.action.GetPropertyAction;
-
-final class EllipticCurvesExtension extends HelloExtension {
-
-    /* Class and subclass dynamic debugging support */
-    private static final Debug debug = Debug.getInstance("ssl");
-
-    private static final int ARBITRARY_PRIME = 0xff01;
-    private static final int ARBITRARY_CHAR2 = 0xff02;
-
-    // speed up the searching
-    private static final Map<String, Integer> oidToIdMap = new HashMap<>();
-    private static final Map<Integer, String> idToOidMap = new HashMap<>();
-
-    // speed up the parameters construction
-    private static final Map<Integer,
-                AlgorithmParameters> idToParams = new HashMap<>();
-
-    // the supported elliptic curves
-    private static final int[] supportedCurveIds;
-
-    // the curves of the extension
-    private final int[] curveIds;
-
-    // See sun.security.util.CurveDB for the OIDs
-    private static enum NamedEllipticCurve {
-        T163_K1(1,  "sect163k1",    "1.3.132.0.1",      true),  // NIST K-163
-        T163_R1(2,  "sect163r1",    "1.3.132.0.2",      false),
-        T163_R2(3,  "sect163r2",    "1.3.132.0.15",     true),  // NIST B-163
-        T193_R1(4,  "sect193r1",    "1.3.132.0.24",     false),
-        T193_R2(5,  "sect193r2",    "1.3.132.0.25",     false),
-        T233_K1(6,  "sect233k1",    "1.3.132.0.26",     true),  // NIST K-233
-        T233_R1(7,  "sect233r1",    "1.3.132.0.27",     true),  // NIST B-233
-        T239_K1(8,  "sect239k1",    "1.3.132.0.3",      false),
-        T283_K1(9,  "sect283k1",    "1.3.132.0.16",     true),  // NIST K-283
-        T283_R1(10, "sect283r1",    "1.3.132.0.17",     true),  // NIST B-283
-        T409_K1(11, "sect409k1",    "1.3.132.0.36",     true),  // NIST K-409
-        T409_R1(12, "sect409r1",    "1.3.132.0.37",     true),  // NIST B-409
-        T571_K1(13, "sect571k1",    "1.3.132.0.38",     true),  // NIST K-571
-        T571_R1(14, "sect571r1",    "1.3.132.0.39",     true),  // NIST B-571
-
-        P160_K1(15, "secp160k1",    "1.3.132.0.9",      false),
-        P160_R1(16, "secp160r1",    "1.3.132.0.8",      false),
-        P160_R2(17, "secp160r2",    "1.3.132.0.30",     false),
-        P192_K1(18, "secp192k1",    "1.3.132.0.31",     false),
-        P192_R1(19, "secp192r1",    "1.2.840.10045.3.1.1", true), // NIST P-192
-        P224_K1(20, "secp224k1",    "1.3.132.0.32",     false),
-        P224_R1(21, "secp224r1",    "1.3.132.0.33",     true),  // NIST P-224
-        P256_K1(22, "secp256k1",    "1.3.132.0.10",     false),
-        P256_R1(23, "secp256r1",    "1.2.840.10045.3.1.7", true), // NIST P-256
-        P384_R1(24, "secp384r1",    "1.3.132.0.34",     true),  // NIST P-384
-        P521_R1(25, "secp521r1",    "1.3.132.0.35",     true);  // NIST P-521
-
-        int          id;
-        String       name;
-        String       oid;
-        boolean      isFips;
-
-        NamedEllipticCurve(int id, String name, String oid, boolean isFips) {
-            this.id = id;
-            this.name = name;
-            this.oid = oid;
-            this.isFips = isFips;
-
-            if (oidToIdMap.put(oid, id) != null ||
-                idToOidMap.put(id, oid) != null) {
-
-                throw new RuntimeException(
-                        "Duplicate named elliptic curve definition: " + name);
-            }
-        }
-
-        static NamedEllipticCurve getCurve(String name, boolean requireFips) {
-            for (NamedEllipticCurve curve : NamedEllipticCurve.values()) {
-                if (curve.name.equals(name) && (!requireFips || curve.isFips)) {
-                    return curve;
-                }
-            }
-
-            return null;
-        }
-    }
-
-    static {
-        boolean requireFips = SunJSSE.isFIPS();
-
-        // hack code to initialize NamedEllipticCurve
-        NamedEllipticCurve nec =
-                NamedEllipticCurve.getCurve("secp256r1", false);
-
-        // The value of the System Property defines a list of enabled named
-        // curves in preference order, separated with comma.  For example:
-        //
-        //      jdk.tls.namedGroups="secp521r1, secp256r1, secp384r1"
-        //
-        // If the System Property is not defined or the value is empty, the
-        // default curves and preferences will be used.
-        String property = AccessController.doPrivileged(
-                    new GetPropertyAction("jdk.tls.namedGroups"));
-        if (property != null && property.length() != 0) {
-            // remove double quote marks from beginning/end of the property
-            if (property.length() > 1 && property.charAt(0) == '"' &&
-                    property.charAt(property.length() - 1) == '"') {
-                property = property.substring(1, property.length() - 1);
-            }
-        }
-
-        ArrayList<Integer> idList;
-        if (property != null && property.length() != 0) {   // customized curves
-            String[] curves = property.split(",");
-            idList = new ArrayList<>(curves.length);
-            for (String curve : curves) {
-                curve = curve.trim();
-                if (!curve.isEmpty()) {
-                    NamedEllipticCurve namedCurve =
-                            NamedEllipticCurve.getCurve(curve, requireFips);
-                    if (namedCurve != null) {
-                        if (isAvailableCurve(namedCurve.id)) {
-                            idList.add(namedCurve.id);
-                        }
-                    }   // ignore unknown curves
-                }
-            }
-            if (idList.isEmpty() && JsseJce.isEcAvailable()) {
-                throw new IllegalArgumentException(
-                    "System property jdk.tls.namedGroups(" + property + ") " +
-                    "contains no supported elliptic curves");
-            }
-        } else {        // default curves
-            int[] ids;
-            if (requireFips) {
-                ids = new int[] {
-                    // only NIST curves in FIPS mode
-                    23, 24, 25, 9, 10, 11, 12, 13, 14,
-                };
-            } else {
-                ids = new int[] {
-                    // NIST curves first
-                    23, 24, 25, 9, 10, 11, 12, 13, 14,
-                    // non-NIST curves
-                    22,
-                };
-            }
-
-            idList = new ArrayList<>(ids.length);
-            for (int curveId : ids) {
-                if (isAvailableCurve(curveId)) {
-                    idList.add(curveId);
-                }
-            }
-        }
-
-        if (debug != null && idList.isEmpty()) {
-            Debug.log(
-                "Initialized [jdk.tls.namedGroups|default] list contains " +
-                "no available elliptic curves. " +
-                (property != null ? "(" + property + ")" : "[Default]"));
-        }
-
-        supportedCurveIds = new int[idList.size()];
-        int i = 0;
-        for (Integer id : idList) {
-            supportedCurveIds[i++] = id;
-        }
-    }
-
-    // check whether the curve is supported by the underlying providers
-    private static boolean isAvailableCurve(int curveId) {
-        String oid = idToOidMap.get(curveId);
-        if (oid != null) {
-            AlgorithmParameters params = null;
-            try {
-                params = JsseJce.getAlgorithmParameters("EC");
-                params.init(new ECGenParameterSpec(oid));
-            } catch (Exception e) {
-                return false;
-            }
-
-            // cache the parameters
-            idToParams.put(curveId, params);
-
-            return true;
-        }
-
-        return false;
-    }
-
-    private EllipticCurvesExtension(int[] curveIds) {
-        super(ExtensionType.EXT_ELLIPTIC_CURVES);
-
-        this.curveIds = curveIds;
-    }
-
-    EllipticCurvesExtension(HandshakeInStream s, int len)
-            throws IOException {
-        super(ExtensionType.EXT_ELLIPTIC_CURVES);
-
-        int k = s.getInt16();
-        if (((len & 1) != 0) || (k + 2 != len)) {
-            throw new SSLProtocolException("Invalid " + type + " extension");
-        }
-
-        // Note: unknown curves will be ignored later.
-        curveIds = new int[k >> 1];
-        for (int i = 0; i < curveIds.length; i++) {
-            curveIds[i] = s.getInt16();
-        }
-    }
-
-    // get the preferred active curve
-    static int getActiveCurves(AlgorithmConstraints constraints) {
-        return getPreferredCurve(supportedCurveIds, constraints);
-    }
-
-    static boolean hasActiveCurves(AlgorithmConstraints constraints) {
-        return getActiveCurves(constraints) >= 0;
-    }
-
-    static EllipticCurvesExtension createExtension(
-                AlgorithmConstraints constraints) {
-
-        ArrayList<Integer> idList = new ArrayList<>(supportedCurveIds.length);
-        for (int curveId : supportedCurveIds) {
-            if (constraints.permits(
-                    EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
-                                "EC", idToParams.get(curveId))) {
-                idList.add(curveId);
-            }
-        }
-
-        if (!idList.isEmpty()) {
-            int[] ids = new int[idList.size()];
-            int i = 0;
-            for (Integer id : idList) {
-                ids[i++] = id;
-            }
-
-            return new EllipticCurvesExtension(ids);
-        }
-
-        return null;
-    }
-
-    // get the preferred activated curve
-    int getPreferredCurve(AlgorithmConstraints constraints) {
-        return getPreferredCurve(curveIds, constraints);
-    }
-
-    // get a preferred activated curve
-    private static int getPreferredCurve(int[] curves,
-                AlgorithmConstraints constraints) {
-        for (int curveId : curves) {
-            if (isSupported(curveId) && constraints.permits(
-                    EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
-                                "EC", idToParams.get(curveId))) {
-                return curveId;
-            }
-        }
-
-        return -1;
-    }
-
-    boolean contains(int index) {
-        for (int curveId : curveIds) {
-            if (index == curveId) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    @Override
-    int length() {
-        return 6 + (curveIds.length << 1);
-    }
-
-    @Override
-    void send(HandshakeOutStream s) throws IOException {
-        s.putInt16(type.id);
-        int k = curveIds.length << 1;
-        s.putInt16(k + 2);
-        s.putInt16(k);
-        for (int curveId : curveIds) {
-            s.putInt16(curveId);
-        }
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append("Extension " + type + ", curve names: {");
-        boolean first = true;
-        for (int curveId : curveIds) {
-            if (first) {
-                first = false;
-            } else {
-                sb.append(", ");
-            }
-            // first check if it is a known named curve, then try other cases.
-            String curveName = getCurveName(curveId);
-            if (curveName != null) {
-                sb.append(curveName);
-            } else if (curveId == ARBITRARY_PRIME) {
-                sb.append("arbitrary_explicit_prime_curves");
-            } else if (curveId == ARBITRARY_CHAR2) {
-                sb.append("arbitrary_explicit_char2_curves");
-            } else {
-                sb.append("unknown curve " + curveId);
-            }
-        }
-        sb.append("}");
-        return sb.toString();
-    }
-
-    // Test whether the given curve is supported.
-    static boolean isSupported(int index) {
-        for (int curveId : supportedCurveIds) {
-            if (index == curveId) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    static int getCurveIndex(ECParameterSpec params) {
-        String oid = JsseJce.getNamedCurveOid(params);
-        if (oid == null) {
-            return -1;
-        }
-        Integer n = oidToIdMap.get(oid);
-        return (n == null) ? -1 : n;
-    }
-
-    static String getCurveOid(int index) {
-        return idToOidMap.get(index);
-    }
-
-    static ECGenParameterSpec getECGenParamSpec(int index) {
-        AlgorithmParameters params = idToParams.get(index);
-        try {
-            return params.getParameterSpec(ECGenParameterSpec.class);
-        } catch (InvalidParameterSpecException ipse) {
-            // should be unlikely
-            String curveOid = getCurveOid(index);
-            return new ECGenParameterSpec(curveOid);
-        }
-    }
-
-    private static String getCurveName(int index) {
-        for (NamedEllipticCurve namedCurve : NamedEllipticCurve.values()) {
-            if (namedCurve.id == index) {
-                return namedCurve.name;
-            }
-        }
-
-        return null;
-    }
-}
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ExtensionType.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ExtensionType.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -82,9 +82,9 @@
     static final ExtensionType EXT_CERT_TYPE =
             e(0x0009, "cert_type");              // IANA registry value: 9
 
-    // extensions defined in RFC 4492 (ECC)
-    static final ExtensionType EXT_ELLIPTIC_CURVES =
-            e(0x000A, "elliptic_curves");        // IANA registry value: 10
+    // extensions defined in RFC 4492 (ECC) and RFC 7919 (FFDHE)
+    static final ExtensionType EXT_SUPPORTED_GROUPS =
+            e(0x000A, "supported_groups");       // IANA registry value: 10
     static final ExtensionType EXT_EC_POINT_FORMATS =
             e(0x000B, "ec_point_formats");       // IANA registry value: 11
 
--- a/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/HandshakeMessage.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1369,8 +1369,9 @@
     private static final int CURVE_EXPLICIT_CHAR2 = 2;
     private static final int CURVE_NAMED_CURVE    = 3;
 
-    // id of the curve we are using
-    private int curveId;
+    // id of the named group we are using
+    private int groupId;
+
     // encoded public point
     private byte[] pointBytes;
 
@@ -1389,7 +1390,8 @@
     ECDH_ServerKeyExchange(ECDHCrypt obj, PrivateKey privateKey,
             byte[] clntNonce, byte[] svrNonce, SecureRandom sr,
             SignatureAndHashAlgorithm signAlgorithm,
-            ProtocolVersion protocolVersion) throws GeneralSecurityException {
+            ProtocolVersion protocolVersion)
+            throws SSLHandshakeException, GeneralSecurityException {
 
         this.protocolVersion = protocolVersion;
 
@@ -1397,7 +1399,14 @@
         ECParameterSpec params = publicKey.getParams();
         ECPoint point = publicKey.getW();
         pointBytes = JsseJce.encodePoint(point, params.getCurve());
-        curveId = EllipticCurvesExtension.getCurveIndex(params);
+
+        NamedGroup namedGroup = NamedGroup.valueOf(params);
+        if ((namedGroup == null) || (namedGroup.oid == null) ){
+            // unlikely
+            throw new SSLHandshakeException(
+                "Unnamed EC parameter spec: " + params);
+        }
+        groupId = namedGroup.id;
 
         if (privateKey == null) {
             // ECDH_anon
@@ -1434,20 +1443,27 @@
         // These parsing errors should never occur as we negotiated
         // the supported curves during the exchange of the Hello messages.
         if (curveType == CURVE_NAMED_CURVE) {
-            curveId = input.getInt16();
-            if (!EllipticCurvesExtension.isSupported(curveId)) {
+            groupId = input.getInt16();
+            NamedGroup namedGroup = NamedGroup.valueOf(groupId);
+            if (namedGroup == null) {
                 throw new SSLHandshakeException(
-                    "Unsupported curveId: " + curveId);
+                    "Unknown named group ID: " + groupId);
             }
-            String curveOid = EllipticCurvesExtension.getCurveOid(curveId);
-            if (curveOid == null) {
+
+            if (!SupportedGroupsExtension.supports(namedGroup)) {
                 throw new SSLHandshakeException(
-                    "Unknown named curve: " + curveId);
+                    "Unsupported named group: " + namedGroup);
             }
-            parameters = JsseJce.getECParameterSpec(curveOid);
+
+            if (namedGroup.oid == null) {
+                throw new SSLHandshakeException(
+                    "Unknown named EC curve: " + namedGroup);
+            }
+
+            parameters = JsseJce.getECParameterSpec(namedGroup.oid);
             if (parameters == null) {
                 throw new SSLHandshakeException(
-                    "Unsupported curve: " + curveOid);
+                    "No supported EC parameter for named group: " + namedGroup);
             }
         } else {
             throw new SSLHandshakeException(
@@ -1530,8 +1546,8 @@
         sig.update(svrNonce);
 
         sig.update((byte)CURVE_NAMED_CURVE);
-        sig.update((byte)(curveId >> 8));
-        sig.update((byte)curveId);
+        sig.update((byte)(groupId >> 8));
+        sig.update((byte)groupId);
         sig.update((byte)pointBytes.length);
         sig.update(pointBytes);
     }
@@ -1552,7 +1568,7 @@
     @Override
     void send(HandshakeOutStream s) throws IOException {
         s.putInt8(CURVE_NAMED_CURVE);
-        s.putInt16(curveId);
+        s.putInt16(groupId);
         s.putBytes8(pointBytes);
 
         if (signatureBytes != null) {
--- a/jdk/src/java.base/share/classes/sun/security/ssl/Handshaker.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/Handshaker.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -52,6 +52,7 @@
 
 import static sun.security.ssl.CipherSuite.PRF.*;
 import static sun.security.ssl.CipherSuite.CipherType.*;
+import static sun.security.ssl.NamedGroupType.*;
 
 /**
  * Handshaker ... processes handshake records from an SSL V3.0
@@ -685,42 +686,14 @@
             ArrayList<CipherSuite> suites = new ArrayList<>();
             if (!(activeProtocols.collection().isEmpty()) &&
                     activeProtocols.min.v != ProtocolVersion.NONE.v) {
-                boolean checkedCurves = false;
-                boolean hasCurves = false;
+                Map<NamedGroupType, Boolean> cachedStatus =
+                        new EnumMap<>(NamedGroupType.class);
                 for (CipherSuite suite : enabledCipherSuites.collection()) {
-                    if (!activeProtocols.min.obsoletes(suite) &&
+                    if (suite.isAvailable() &&
+                            (!activeProtocols.min.obsoletes(suite)) &&
                             activeProtocols.max.supports(suite)) {
-                        if (algorithmConstraints.permits(
-                                EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
-                                suite.name, null)) {
-
-                            boolean available = true;
-                            if (suite.keyExchange.isEC) {
-                                if (!checkedCurves) {
-                                    hasCurves = EllipticCurvesExtension
-                                        .hasActiveCurves(algorithmConstraints);
-                                    checkedCurves = true;
-
-                                    if (!hasCurves && debug != null &&
-                                                Debug.isOn("verbose")) {
-                                        System.out.println(
-                                            "No available elliptic curves");
-                                    }
-                                }
-
-                                available = hasCurves;
-
-                                if (!available && debug != null &&
-                                        Debug.isOn("verbose")) {
-                                    System.out.println(
-                                        "No active elliptic curves, ignore " +
-                                        suite);
-                                }
-                            }
-
-                            if (available) {
-                                suites.add(suite);
-                            }
+                        if (isActivatable(suite, cachedStatus)) {
+                            suites.add(suite);
                         }
                     } else if (debug != null && Debug.isOn("verbose")) {
                         if (activeProtocols.min.obsoletes(suite)) {
@@ -779,46 +752,15 @@
                 }
 
                 boolean found = false;
+                Map<NamedGroupType, Boolean> cachedStatus =
+                        new EnumMap<>(NamedGroupType.class);
                 for (CipherSuite suite : enabledCipherSuites.collection()) {
                     if (suite.isAvailable() && (!protocol.obsoletes(suite)) &&
                                                protocol.supports(suite)) {
-                        if (algorithmConstraints.permits(
-                                EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
-                                suite.name, null)) {
-
-                            boolean available = true;
-                            if (suite.keyExchange.isEC) {
-                                if (!checkedCurves) {
-                                    hasCurves = EllipticCurvesExtension
-                                        .hasActiveCurves(algorithmConstraints);
-                                    checkedCurves = true;
-
-                                    if (!hasCurves && debug != null &&
-                                                Debug.isOn("verbose")) {
-                                        System.out.println(
-                                            "No activated elliptic curves");
-                                    }
-                                }
-
-                                available = hasCurves;
-
-                                if (!available && debug != null &&
-                                        Debug.isOn("verbose")) {
-                                    System.out.println(
-                                        "No active elliptic curves, ignore " +
-                                        suite + " for " + protocol);
-                                }
-                            }
-
-                            if (available) {
-                                protocols.add(protocol);
-                                found = true;
-                                break;
-                            }
-                        } else if (debug != null && Debug.isOn("verbose")) {
-                            System.out.println(
-                                "Ignoring disabled cipher suite: " + suite +
-                                 " for " + protocol);
+                        if (isActivatable(suite, cachedStatus)) {
+                            protocols.add(protocol);
+                            found = true;
+                            break;
                         }
                     } else if (debug != null && Debug.isOn("verbose")) {
                         System.out.println(
@@ -826,6 +768,7 @@
                                  " for " + protocol);
                     }
                 }
+
                 if (!found && (debug != null) && Debug.isOn("handshake")) {
                     System.out.println(
                         "No available cipher suite for " + protocol);
@@ -842,6 +785,43 @@
         return activeProtocols;
     }
 
+    private boolean isActivatable(CipherSuite suite,
+            Map<NamedGroupType, Boolean> cachedStatus) {
+
+        if (algorithmConstraints.permits(
+                EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), suite.name, null)) {
+            boolean available = true;
+            NamedGroupType groupType = suite.keyExchange.groupType;
+            if (groupType != NAMED_GROUP_NONE) {
+                Boolean checkedStatus = cachedStatus.get(groupType);
+                if (checkedStatus == null) {
+                    available = SupportedGroupsExtension.isActivatable(
+                            algorithmConstraints, groupType);
+                    cachedStatus.put(groupType, available);
+
+                    if (!available && debug != null && Debug.isOn("verbose")) {
+                        System.out.println("No activated named group");
+                    }
+                } else {
+                    available = checkedStatus.booleanValue();
+                }
+
+                if (!available && debug != null && Debug.isOn("verbose")) {
+                    System.out.println(
+                        "No active named group, ignore " + suite);
+                }
+
+                return available;
+            } else {
+                return true;
+            }
+        } else if (debug != null && Debug.isOn("verbose")) {
+            System.out.println("Ignoring disabled cipher suite: " + suite);
+        }
+
+        return false;
+    }
+
     /**
      * As long as handshaking has not activated, we can
      * change whether session creations are allowed.
--- a/jdk/src/java.base/share/classes/sun/security/ssl/HelloExtensions.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/HelloExtensions.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,7 +49,7 @@
  *      explicitly support.
  *  . ServerNameExtension: the server_name extension.
  *  . SignatureAlgorithmsExtension: the signature_algorithms extension.
- *  . EllipticCurvesExtension: the ECC supported curves extension.
+ *  . SupportedGroupsExtension: the supported groups extension.
  *  . EllipticPointFormatsExtension: the ECC supported point formats
  *      (compressed/uncompressed) extension.
  *  . ALPNExtension: the application_layer_protocol_negotiation extension.
@@ -79,8 +79,8 @@
                 extension = new ServerNameExtension(s, extlen);
             } else if (extType == ExtensionType.EXT_SIGNATURE_ALGORITHMS) {
                 extension = new SignatureAlgorithmsExtension(s, extlen);
-            } else if (extType == ExtensionType.EXT_ELLIPTIC_CURVES) {
-                extension = new EllipticCurvesExtension(s, extlen);
+            } else if (extType == ExtensionType.EXT_SUPPORTED_GROUPS) {
+                extension = new SupportedGroupsExtension(s, extlen);
             } else if (extType == ExtensionType.EXT_EC_POINT_FORMATS) {
                 extension = new EllipticPointFormatsExtension(s, extlen);
             } else if (extType == ExtensionType.EXT_RENEGOTIATION_INFO) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/NamedGroup.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.ssl;
+
+import java.security.spec.ECParameterSpec;
+import java.security.spec.ECGenParameterSpec;
+import static sun.security.ssl.NamedGroupType.*;
+
+enum NamedGroup {
+    // Elliptic Curves (RFC 4492)
+    //
+    // See sun.security.util.CurveDB for the OIDs
+
+    // NIST K-163
+    SECT163_K1(1, NAMED_GROUP_ECDHE, "sect163k1", "1.3.132.0.1", true),
+
+    SECT163_R1(2, NAMED_GROUP_ECDHE, "sect163r1", "1.3.132.0.2", false),
+
+    // NIST B-163
+    SECT163_R2(3, NAMED_GROUP_ECDHE, "sect163r2", "1.3.132.0.15", true),
+
+    SECT193_R1(4, NAMED_GROUP_ECDHE, "sect193r1", "1.3.132.0.24", false),
+    SECT193_R2(5, NAMED_GROUP_ECDHE, "sect193r2", "1.3.132.0.25", false),
+
+    // NIST K-233
+    SECT233_K1(6, NAMED_GROUP_ECDHE, "sect233k1", "1.3.132.0.26", true),
+
+    // NIST B-233
+    SECT233_R1(7, NAMED_GROUP_ECDHE, "sect233r1", "1.3.132.0.27", true),
+
+    SECT239_K1(8, NAMED_GROUP_ECDHE, "sect239k1", "1.3.132.0.3", false),
+
+    // NIST K-283
+    SECT283_K1(9, NAMED_GROUP_ECDHE, "sect283k1", "1.3.132.0.16", true),
+
+    // NIST B-283
+    SECT283_R1(10, NAMED_GROUP_ECDHE, "sect283r1", "1.3.132.0.17", true),
+
+    // NIST K-409
+    SECT409_K1(11, NAMED_GROUP_ECDHE, "sect409k1", "1.3.132.0.36", true),
+
+    // NIST B-409
+    SECT409_R1(12, NAMED_GROUP_ECDHE, "sect409r1", "1.3.132.0.37", true),
+
+    // NIST K-571
+    SECT571_K1(13, NAMED_GROUP_ECDHE, "sect571k1", "1.3.132.0.38", true),
+
+    // NIST B-571
+    SECT571_R1(14, NAMED_GROUP_ECDHE, "sect571r1", "1.3.132.0.39", true),
+
+    SECP160_K1(15, NAMED_GROUP_ECDHE, "secp160k1", "1.3.132.0.9", false),
+    SECP160_R1(16, NAMED_GROUP_ECDHE, "secp160r1", "1.3.132.0.8", false),
+    SECP160_R2(17, NAMED_GROUP_ECDHE, "secp160r2", "1.3.132.0.30", false),
+    SECP192_K1(18, NAMED_GROUP_ECDHE, "secp192k1", "1.3.132.0.31", false),
+
+    // NIST P-192
+    SECP192_R1(19, NAMED_GROUP_ECDHE, "secp192r1", "1.2.840.10045.3.1.1", true),
+
+    SECP224_K1(20, NAMED_GROUP_ECDHE, "secp224k1", "1.3.132.0.32", false),
+    // NIST P-224
+    SECP224_R1(21, NAMED_GROUP_ECDHE, "secp224r1", "1.3.132.0.33", true),
+
+    SECP256_K1(22, NAMED_GROUP_ECDHE, "secp256k1", "1.3.132.0.10", false),
+
+    // NIST P-256
+    SECP256_R1(23, NAMED_GROUP_ECDHE, "secp256r1", "1.2.840.10045.3.1.7", true),
+
+    // NIST P-384
+    SECP384_R1(24, NAMED_GROUP_ECDHE, "secp384r1", "1.3.132.0.34", true),
+
+    // NIST P-521
+    SECP521_R1(25, NAMED_GROUP_ECDHE, "secp521r1", "1.3.132.0.35", true),
+
+    // Finite Field Diffie-Hellman Ephemeral Parameters (RFC 7919)
+    FFDHE_2048(256, NAMED_GROUP_FFDHE, "ffdhe2048",  true),
+    FFDHE_3072(257, NAMED_GROUP_FFDHE, "ffdhe3072",  true),
+    FFDHE_4096(258, NAMED_GROUP_FFDHE, "ffdhe4096",  true),
+    FFDHE_6144(259, NAMED_GROUP_FFDHE, "ffdhe6144",  true),
+    FFDHE_8192(260, NAMED_GROUP_FFDHE, "ffdhe8192",  true);
+
+    int             id;
+    NamedGroupType  type;
+    String          name;
+    String          oid;
+    String          algorithm;
+    boolean         isFips;
+
+    // Constructor used for Elliptic Curve Groups (ECDHE)
+    NamedGroup(int id, NamedGroupType type,
+                String name, String oid, boolean isFips) {
+        this.id = id;
+        this.type = type;
+        this.name = name;
+        this.oid = oid;
+        this.algorithm = "EC";
+        this.isFips = isFips;
+    }
+
+    // Constructor used for Finite Field Diffie-Hellman Groups (FFDHE)
+    NamedGroup(int id, NamedGroupType type, String name, boolean isFips) {
+        this.id = id;
+        this.type = type;
+        this.name = name;
+        this.oid = null;
+        this.algorithm = "DiffieHellman";
+        this.isFips = isFips;
+    }
+
+    static NamedGroup valueOf(int id) {
+        for (NamedGroup group : NamedGroup.values()) {
+            if (group.id == id) {
+                return group;
+            }
+        }
+
+        return null;
+    }
+
+    static NamedGroup nameOf(String name) {
+        for (NamedGroup group : NamedGroup.values()) {
+            if (group.name.equals(name)) {
+                return group;
+            }
+        }
+
+        return null;
+    }
+
+    static NamedGroup valueOf(ECParameterSpec params) {
+        String oid = JsseJce.getNamedCurveOid(params);
+        if ((oid != null) && (!oid.isEmpty())) {
+            for (NamedGroup group : NamedGroup.values()) {
+                if (oid.equals(group.oid)) {
+                    return group;
+                }
+            }
+        }
+
+        return null;
+    }
+
+    @Override
+    public String toString() {
+        return this.name;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/NamedGroupType.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.ssl;
+
+enum NamedGroupType {
+    NAMED_GROUP_ECDHE,          // Elliptic Curve Groups (ECDHE)
+    NAMED_GROUP_FFDHE,          // Finite Field Groups (DHE)
+    NAMED_GROUP_NONE            // No predefined named group
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/PredefinedDHParameterSpecs.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,314 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.ssl;
+
+import java.security.*;
+import java.math.BigInteger;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+import javax.crypto.spec.DHParameterSpec;
+
+/**
+ * Predefined default DH ephemeral parameters.
+ */
+final class PredefinedDHParameterSpecs {
+    private final static boolean debugIsOn =
+            (Debug.getInstance("ssl") != null) && Debug.isOn("sslctx");
+
+    //
+    // Default DH ephemeral parameters
+    //
+    private static final BigInteger p512 = new BigInteger(       // generated
+            "D87780E15FF50B4ABBE89870188B049406B5BEA98AB23A02" +
+            "41D88EA75B7755E669C08093D3F0CA7FC3A5A25CF067DCB9" +
+            "A43DD89D1D90921C6328884461E0B6D3", 16);
+    private static final BigInteger p768 = new BigInteger(       // RFC 2409
+            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+            "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+            "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+            "E485B576625E7EC6F44C42E9A63A3620FFFFFFFFFFFFFFFF", 16);
+
+    private static final BigInteger p1024 = new BigInteger(      // RFC 2409
+            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+            "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+            "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+            "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
+            "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381" +
+            "FFFFFFFFFFFFFFFF", 16);
+    private static final BigInteger p1536 = new BigInteger(      // RFC 3526
+            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
+            "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
+            "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
+            "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
+            "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" +
+            "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" +
+            "83655D23DCA3AD961C62F356208552BB9ED529077096966D" +
+            "670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF", 16);
+    private static final BigInteger p2048 = new BigInteger(      // TLS FFDHE
+            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+            "886B423861285C97FFFFFFFFFFFFFFFF", 16);
+    private static final BigInteger p3072 = new BigInteger(      // TLS FFDHE
+            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+            "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
+            "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
+            "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
+            "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
+            "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
+            "3C1B20EE3FD59D7C25E41D2B66C62E37FFFFFFFFFFFFFFFF", 16);
+    private static final BigInteger p4096 = new BigInteger(      // TLS FFDHE
+            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+            "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
+            "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
+            "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
+            "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
+            "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
+            "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
+            "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
+            "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
+            "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
+            "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
+            "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E655F6A" +
+            "FFFFFFFFFFFFFFFF", 16);
+    private static final BigInteger p6144 = new BigInteger(      // TLS FFDHE
+            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+            "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
+            "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
+            "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
+            "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
+            "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
+            "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
+            "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
+            "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
+            "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
+            "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
+            "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD902" +
+            "0BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA6" +
+            "3BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3A" +
+            "CDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477" +
+            "A52471F7A9A96910B855322EDB6340D8A00EF092350511E3" +
+            "0ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4" +
+            "763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6" +
+            "B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538C" +
+            "D72B03746AE77F5E62292C311562A846505DC82DB854338A" +
+            "E49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B04" +
+            "5B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1" +
+            "A41D570D7938DAD4A40E329CD0E40E65FFFFFFFFFFFFFFFF", 16);
+    private static final BigInteger p8192 = new BigInteger(      // TLS FFDHE
+            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
+            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
+            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
+            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
+            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
+            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
+            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
+            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
+            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
+            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
+            "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
+            "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
+            "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
+            "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
+            "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
+            "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
+            "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
+            "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
+            "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
+            "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
+            "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD902" +
+            "0BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA6" +
+            "3BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3A" +
+            "CDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477" +
+            "A52471F7A9A96910B855322EDB6340D8A00EF092350511E3" +
+            "0ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4" +
+            "763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6" +
+            "B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538C" +
+            "D72B03746AE77F5E62292C311562A846505DC82DB854338A" +
+            "E49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B04" +
+            "5B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1" +
+            "A41D570D7938DAD4A40E329CCFF46AAA36AD004CF600C838" +
+            "1E425A31D951AE64FDB23FCEC9509D43687FEB69EDD1CC5E" +
+            "0B8CC3BDF64B10EF86B63142A3AB8829555B2F747C932665" +
+            "CB2C0F1CC01BD70229388839D2AF05E454504AC78B758282" +
+            "2846C0BA35C35F5C59160CC046FD8251541FC68C9C86B022" +
+            "BB7099876A460E7451A8A93109703FEE1C217E6C3826E52C" +
+            "51AA691E0E423CFC99E9E31650C1217B624816CDAD9A95F9" +
+            "D5B8019488D9C0A0A1FE3075A577E23183F81D4A3F2FA457" +
+            "1EFC8CE0BA8A4FE8B6855DFE72B0A66EDED2FBABFBE58A30" +
+            "FAFABE1C5D71A87E2F741EF8C1FE86FEA6BBFDE530677F0D" +
+            "97D11D49F7A8443D0822E506A9F4614E011E2A94838FF88C" +
+            "D68C8BB7C5C6424CFFFFFFFFFFFFFFFF", 16);
+
+    private static final BigInteger[] supportedPrimes = {
+            p512, p768, p1024, p1536, p2048, p3072, p4096, p6144, p8192};
+
+    private static final BigInteger[] ffdhePrimes = {
+            p2048, p3072, p4096, p6144, p8192};
+
+    // a measure of the uncertainty that prime modulus p is not a prime
+    //
+    // see BigInteger.isProbablePrime(int certainty)
+    private final static int PRIME_CERTAINTY = 120;
+
+    // the known security property, jdk.tls.server.defaultDHEParameters
+    private final static String PROPERTY_NAME =
+            "jdk.tls.server.defaultDHEParameters";
+
+    private static final Pattern spacesPattern = Pattern.compile("\\s+");
+
+    private final static Pattern syntaxPattern = Pattern.compile(
+            "(\\{[0-9A-Fa-f]+,[0-9A-Fa-f]+\\})" +
+            "(,\\{[0-9A-Fa-f]+,[0-9A-Fa-f]+\\})*");
+
+    private static final Pattern paramsPattern = Pattern.compile(
+            "\\{([0-9A-Fa-f]+),([0-9A-Fa-f]+)\\}");
+
+    // cache of predefined default DH ephemeral parameters
+    final static Map<Integer, DHParameterSpec> definedParams;
+
+    // cache of Finite Field DH Ephemeral parameters (RFC 7919/FFDHE)
+    final static Map<Integer, DHParameterSpec> ffdheParams;
+
+    static {
+        String property = AccessController.doPrivileged(
+            new PrivilegedAction<String>() {
+                public String run() {
+                    return Security.getProperty(PROPERTY_NAME);
+                }
+            });
+
+        if (property != null && !property.isEmpty()) {
+            // remove double quote marks from beginning/end of the property
+            if (property.length() >= 2 && property.charAt(0) == '"' &&
+                    property.charAt(property.length() - 1) == '"') {
+                property = property.substring(1, property.length() - 1);
+            }
+
+            property = property.trim();
+        }
+
+        if (property != null && !property.isEmpty()) {
+            Matcher spacesMatcher = spacesPattern.matcher(property);
+            property = spacesMatcher.replaceAll("");
+
+            if (debugIsOn) {
+                System.out.println("The Security Property " +
+                        PROPERTY_NAME + ": " + property);
+            }
+        }
+
+        Map<Integer,DHParameterSpec> defaultParams = new HashMap<>();
+        if (property != null && !property.isEmpty()) {
+            Matcher syntaxMatcher = syntaxPattern.matcher(property);
+            if (syntaxMatcher.matches()) {
+                Matcher paramsFinder = paramsPattern.matcher(property);
+                while(paramsFinder.find()) {
+                    String primeModulus = paramsFinder.group(1);
+                    BigInteger p = new BigInteger(primeModulus, 16);
+                    if (!p.isProbablePrime(PRIME_CERTAINTY)) {
+                        if (debugIsOn) {
+                            System.out.println(
+                                "Prime modulus p in Security Property, " +
+                                PROPERTY_NAME + ", is not a prime: " +
+                                primeModulus);
+                        }
+
+                        continue;
+                    }
+
+                    String baseGenerator = paramsFinder.group(2);
+                    BigInteger g = new BigInteger(baseGenerator, 16);
+
+                    DHParameterSpec spec = new DHParameterSpec(p, g);
+                    int primeLen = p.bitLength();
+                    defaultParams.put(primeLen, spec);
+                }
+            } else if (debugIsOn) {
+                System.out.println("Invalid Security Property, " +
+                        PROPERTY_NAME + ", definition");
+            }
+        }
+
+        Map<Integer,DHParameterSpec> tempFFDHEs = new HashMap<>();
+        for (BigInteger p : ffdhePrimes) {
+            int primeLen = p.bitLength();
+            DHParameterSpec dhps = new DHParameterSpec(p, BigInteger.TWO);
+            tempFFDHEs.put(primeLen, dhps);
+            defaultParams.putIfAbsent(primeLen, dhps);
+        }
+
+        for (BigInteger p : supportedPrimes) {
+            int primeLen = p.bitLength();
+            if (defaultParams.get(primeLen) == null) {
+                defaultParams.put(primeLen,
+                    new DHParameterSpec(p, BigInteger.TWO));
+            }
+        }
+
+        ffdheParams =
+            Collections.<Integer,DHParameterSpec>unmodifiableMap(tempFFDHEs);
+        definedParams =
+            Collections.<Integer,DHParameterSpec>unmodifiableMap(defaultParams);
+    }
+}
--- a/jdk/src/java.base/share/classes/sun/security/ssl/RecordType.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.ssl;
-
-/*
- * enumation of record type
- */
-enum RecordType {
-
-    RECORD_CHANGE_CIPHER_SPEC   (Record.ct_change_cipher_spec,
-                                    HandshakeMessage.ht_not_applicable),
-    RECORD_ALERT                (Record.ct_alert,
-                                    HandshakeMessage.ht_not_applicable),
-    RECORD_HELLO_REQUEST        (Record.ct_handshake,
-                                    HandshakeMessage.ht_hello_request),
-    RECORD_CLIENT_HELLO         (Record.ct_handshake,
-                                    HandshakeMessage.ht_client_hello),
-    RECORD_SERVER_HELLO         (Record.ct_handshake,
-                                    HandshakeMessage.ht_server_hello),
-    RECORD_HELLO_VERIFY_REQUEST (Record.ct_handshake,
-                                    HandshakeMessage.ht_hello_verify_request),
-    RECORD_NEW_SESSION_TICKET   (Record.ct_handshake,
-                                    HandshakeMessage.ht_new_session_ticket),
-    RECORD_CERTIFICATE          (Record.ct_handshake,
-                                    HandshakeMessage.ht_certificate),
-    RECORD_SERVER_KEY_EXCHANGE  (Record.ct_handshake,
-                                    HandshakeMessage.ht_server_key_exchange),
-    RECORD_CERTIFICATE_REQUEST  (Record.ct_handshake,
-                                    HandshakeMessage.ht_certificate_request),
-    RECORD_SERVER_HELLO_DONE    (Record.ct_handshake,
-                                    HandshakeMessage.ht_server_hello_done),
-    RECORD_CERTIFICATE_VERIFY   (Record.ct_handshake,
-                                    HandshakeMessage.ht_certificate_verify),
-    RECORD_CLIENT_KEY_EXCHANGE  (Record.ct_handshake,
-                                    HandshakeMessage.ht_client_key_exchange),
-    RECORD_FINISHED             (Record.ct_handshake,
-                                    HandshakeMessage.ht_finished),
-    RECORD_CERTIFICATE_URL      (Record.ct_handshake,
-                                    HandshakeMessage.ht_certificate_url),
-    RECORD_CERTIFICATE_STATUS   (Record.ct_handshake,
-                                    HandshakeMessage.ht_certificate_status),
-    RECORD_SUPPLIEMENTAL_DATA   (Record.ct_handshake,
-                                    HandshakeMessage.ht_supplemental_data),
-    RECORD_APPLICATION_DATA     (Record.ct_application_data,
-                                    HandshakeMessage.ht_not_applicable);
-
-    byte            contentType;
-    byte            handshakeType;
-
-    private RecordType(byte contentType, byte handshakeType) {
-        this.contentType = contentType;
-        this.handshakeType = handshakeType;
-    }
-
-    static RecordType valueOf(byte contentType, byte handshakeType) {
-        if (contentType == Record.ct_change_cipher_spec) {
-            return RECORD_CHANGE_CIPHER_SPEC;
-        } else if (contentType == Record.ct_alert) {
-            return RECORD_ALERT;
-        } else if (contentType == Record.ct_application_data) {
-            return RECORD_APPLICATION_DATA;
-        } else if (handshakeType == HandshakeMessage.ht_hello_request) {
-            return RECORD_HELLO_REQUEST;
-        } else if (handshakeType == HandshakeMessage.ht_client_hello) {
-            return RECORD_CLIENT_HELLO;
-        } else if (handshakeType == HandshakeMessage.ht_server_hello) {
-            return RECORD_SERVER_HELLO;
-        } else if (handshakeType == HandshakeMessage.ht_hello_verify_request) {
-            return RECORD_HELLO_VERIFY_REQUEST;
-        } else if (handshakeType == HandshakeMessage.ht_new_session_ticket) {
-            return RECORD_NEW_SESSION_TICKET;
-        } else if (handshakeType == HandshakeMessage.ht_certificate) {
-            return RECORD_CERTIFICATE;
-        } else if (handshakeType == HandshakeMessage.ht_server_key_exchange) {
-            return RECORD_SERVER_KEY_EXCHANGE;
-        } else if (handshakeType == HandshakeMessage.ht_certificate_request) {
-            return RECORD_CERTIFICATE_REQUEST;
-        } else if (handshakeType == HandshakeMessage.ht_server_hello_done) {
-            return RECORD_SERVER_HELLO_DONE;
-        } else if (handshakeType == HandshakeMessage.ht_certificate_verify) {
-            return RECORD_CERTIFICATE_VERIFY;
-        } else if (handshakeType == HandshakeMessage.ht_client_key_exchange) {
-            return RECORD_CLIENT_KEY_EXCHANGE;
-        } else if (handshakeType == HandshakeMessage.ht_finished) {
-            return RECORD_FINISHED;
-        } else if (handshakeType == HandshakeMessage.ht_certificate_url) {
-            return RECORD_CERTIFICATE_URL;
-        } else if (handshakeType == HandshakeMessage.ht_certificate_status) {
-            return RECORD_CERTIFICATE_STATUS;
-        } else if (handshakeType == HandshakeMessage.ht_supplemental_data) {
-            return RECORD_SUPPLIEMENTAL_DATA;
-        }
-
-        // otherwise, invalid record type
-        throw new IllegalArgumentException(
-                "Invalid record type (ContentType:" + contentType +
-                ", HandshakeType:" + handshakeType + ")");
-    }
-}
--- a/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/ServerHandshaker.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -96,7 +96,7 @@
     private ProtocolVersion clientRequestedVersion;
 
     // client supported elliptic curves
-    private EllipticCurvesExtension requestedCurves;
+    private SupportedGroupsExtension requestedGroups;
 
     // the preferable signature algorithm used by ServerKeyExchange message
     SignatureAndHashAlgorithm preferableSignatureAlgorithm;
@@ -751,8 +751,8 @@
                 throw new SSLException("Client did not resume a session");
             }
 
-            requestedCurves = (EllipticCurvesExtension)
-                        mesg.extensions.get(ExtensionType.EXT_ELLIPTIC_CURVES);
+            requestedGroups = (SupportedGroupsExtension)
+                    mesg.extensions.get(ExtensionType.EXT_SUPPORTED_GROUPS);
 
             // We only need to handle the "signature_algorithm" extension
             // for full handshakes and TLS 1.2 or later.
@@ -1341,6 +1341,8 @@
             }
         }
 
+        // The named group used for ECDHE and FFDHE.
+        NamedGroup namedGroup = null;
         switch (keyExchange) {
         case K_RSA:
             // need RSA certs for authentication
@@ -1366,6 +1368,37 @@
             }
             break;
         case K_DHE_RSA:
+            // Is ephemeral DH cipher suite usable for the connection?
+            //
+            // [RFC 7919] If a compatible TLS server receives a Supported
+            // Groups extension from a client that includes any FFDHE group
+            // (i.e., any codepoint between 256 and 511, inclusive, even if
+            // unknown to the server), and if none of the client-proposed
+            // FFDHE groups are known and acceptable to the server, then
+            // the server MUST NOT select an FFDHE cipher suite.  In this
+            // case, the server SHOULD select an acceptable non-FFDHE cipher
+            // suite from the client's offered list.  If the extension is
+            // present with FFDHE groups, none of the client's offered
+            // groups are acceptable by the server, and none of the client's
+            // proposed non-FFDHE cipher suites are acceptable to the server,
+            // the server MUST end the connection with a fatal TLS alert
+            // of type insufficient_security(71).
+            //
+            // Note: For compatibility, if an application is customized to
+            // use legacy sizes (512 bits for exportable cipher suites and
+            // 768 bits for others), or the cipher suite is exportable, the
+            // FFDHE extension will not be used.
+            if ((!useLegacyEphemeralDHKeys) && (!suite.exportable) &&
+                (requestedGroups != null) && requestedGroups.hasFFDHEGroup()) {
+
+                namedGroup = requestedGroups.getPreferredGroup(
+                    algorithmConstraints, NamedGroupType.NAMED_GROUP_FFDHE);
+                if (namedGroup == null) {
+                    // no match found, cannot use this cipher suite.
+                    return false;
+                }
+            }
+
             // need RSA certs for authentication
             if (setupPrivateKeyAndChain("RSA") == false) {
                 return false;
@@ -1386,9 +1419,20 @@
                 }
             }
 
-            setupEphemeralDHKeys(suite.exportable, privateKey);
+            setupEphemeralDHKeys(namedGroup, suite.exportable, privateKey);
             break;
         case K_ECDHE_RSA:
+            // Is ECDHE cipher suite usable for the connection?
+            namedGroup = (requestedGroups != null) ?
+                requestedGroups.getPreferredGroup(
+                    algorithmConstraints, NamedGroupType.NAMED_GROUP_ECDHE) :
+                SupportedGroupsExtension.getPreferredECGroup(
+                    algorithmConstraints);
+            if (namedGroup == null) {
+                // no match found, cannot use this ciphersuite
+                return false;
+            }
+
             // need RSA certs for authentication
             if (setupPrivateKeyAndChain("RSA") == false) {
                 return false;
@@ -1409,11 +1453,23 @@
                 }
             }
 
-            if (setupEphemeralECDHKeys() == false) {
-                return false;
-            }
+            setupEphemeralECDHKeys(namedGroup);
             break;
         case K_DHE_DSS:
+            // Is ephemeral DH cipher suite usable for the connection?
+            //
+            // See comment in K_DHE_RSA case.
+            if ((!useLegacyEphemeralDHKeys) && (!suite.exportable) &&
+                (requestedGroups != null) && requestedGroups.hasFFDHEGroup()) {
+
+                namedGroup = requestedGroups.getPreferredGroup(
+                    algorithmConstraints, NamedGroupType.NAMED_GROUP_FFDHE);
+                if (namedGroup == null) {
+                    // no match found, cannot use this cipher suite.
+                    return false;
+                }
+            }
+
             // get preferable peer signature algorithm for server key exchange
             if (protocolVersion.useTLS12PlusSpec()) {
                 preferableSignatureAlgorithm =
@@ -1434,9 +1490,20 @@
                 return false;
             }
 
-            setupEphemeralDHKeys(suite.exportable, privateKey);
+            setupEphemeralDHKeys(namedGroup, suite.exportable, privateKey);
             break;
         case K_ECDHE_ECDSA:
+            // Is ECDHE cipher suite usable for the connection?
+            namedGroup = (requestedGroups != null) ?
+                requestedGroups.getPreferredGroup(
+                    algorithmConstraints, NamedGroupType.NAMED_GROUP_ECDHE) :
+                SupportedGroupsExtension.getPreferredECGroup(
+                    algorithmConstraints);
+            if (namedGroup == null) {
+                // no match found, cannot use this ciphersuite
+                return false;
+            }
+
             // get preferable peer signature algorithm for server key exchange
             if (protocolVersion.useTLS12PlusSpec()) {
                 preferableSignatureAlgorithm =
@@ -1456,9 +1523,8 @@
             if (setupPrivateKeyAndChain("EC") == false) {
                 return false;
             }
-            if (setupEphemeralECDHKeys() == false) {
-                return false;
-            }
+
+            setupEphemeralECDHKeys(namedGroup);
             break;
         case K_ECDH_RSA:
             // need EC cert
@@ -1475,14 +1541,36 @@
             setupStaticECDHKeys();
             break;
         case K_DH_ANON:
+            // Is ephemeral DH cipher suite usable for the connection?
+            //
+            // See comment in K_DHE_RSA case.
+            if ((!useLegacyEphemeralDHKeys) && (!suite.exportable) &&
+                (requestedGroups != null) && requestedGroups.hasFFDHEGroup()) {
+                namedGroup = requestedGroups.getPreferredGroup(
+                    algorithmConstraints, NamedGroupType.NAMED_GROUP_FFDHE);
+                if (namedGroup == null) {
+                    // no match found, cannot use this cipher suite.
+                    return false;
+                }
+            }
+
             // no certs needed for anonymous
-            setupEphemeralDHKeys(suite.exportable, null);
+            setupEphemeralDHKeys(namedGroup, suite.exportable, null);
             break;
         case K_ECDH_ANON:
-            // no certs needed for anonymous
-            if (setupEphemeralECDHKeys() == false) {
+            // Is ECDHE cipher suite usable for the connection?
+            namedGroup = (requestedGroups != null) ?
+                requestedGroups.getPreferredGroup(
+                    algorithmConstraints, NamedGroupType.NAMED_GROUP_ECDHE) :
+                SupportedGroupsExtension.getPreferredECGroup(
+                    algorithmConstraints);
+            if (namedGroup == null) {
+                // no match found, cannot use this ciphersuite
                 return false;
             }
+
+            // no certs needed for anonymous
+            setupEphemeralECDHKeys(namedGroup);
             break;
         default:
             ClientKeyExchangeService p =
@@ -1544,7 +1632,15 @@
      * Acquire some "ephemeral" Diffie-Hellman  keys for this handshake.
      * We don't reuse these, for improved forward secrecy.
      */
-    private void setupEphemeralDHKeys(boolean export, Key key) {
+    private void setupEphemeralDHKeys(
+            NamedGroup namedGroup, boolean export, Key key) {
+        // Are the client and server willing to negotiate FFDHE groups?
+        if ((!useLegacyEphemeralDHKeys) && (!export) && (namedGroup != null)) {
+            dh = new DHCrypt(namedGroup, sslContext.getSecureRandom());
+
+            return;
+        }   // Otherwise, the client is not compatible with FFDHE extension.
+
         /*
          * 768 bits ephemeral DH private keys were used to be used in
          * ServerKeyExchange except that exportable ciphers max out at 512
@@ -1613,20 +1709,11 @@
         dh = new DHCrypt(keySize, sslContext.getSecureRandom());
     }
 
-    // Setup the ephemeral ECDH parameters.
-    // If we cannot continue because we do not support any of the curves that
-    // the client requested, return false. Otherwise (all is well), return true.
-    private boolean setupEphemeralECDHKeys() {
-        int index = (requestedCurves != null) ?
-                requestedCurves.getPreferredCurve(algorithmConstraints) :
-                EllipticCurvesExtension.getActiveCurves(algorithmConstraints);
-        if (index < 0) {
-            // no match found, cannot use this ciphersuite
-            return false;
-        }
-
-        ecdh = new ECDHCrypt(index, sslContext.getSecureRandom());
-        return true;
+    /**
+     * Setup the ephemeral ECDH parameters.
+     */
+    private void setupEphemeralECDHKeys(NamedGroup namedGroup) {
+        ecdh = new ECDHCrypt(namedGroup, sslContext.getSecureRandom());
     }
 
     private void setupStaticECDHKeys() {
@@ -1674,9 +1761,11 @@
                 return false;
             }
             ECParameterSpec params = ((ECPublicKey)publicKey).getParams();
-            int id = EllipticCurvesExtension.getCurveIndex(params);
-            if ((id <= 0) || !EllipticCurvesExtension.isSupported(id) ||
-                ((requestedCurves != null) && !requestedCurves.contains(id))) {
+            NamedGroup namedGroup = NamedGroup.valueOf(params);
+            if ((namedGroup == null) ||
+                (!SupportedGroupsExtension.supports(namedGroup)) ||
+                ((requestedGroups != null) &&
+                        !requestedGroups.contains(namedGroup.id))) {
                 return false;
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,491 @@
+/*
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.ssl;
+
+import java.io.IOException;
+import java.security.spec.ECGenParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
+import java.security.AlgorithmParameters;
+import java.security.AlgorithmConstraints;
+import java.security.CryptoPrimitive;
+import java.security.AccessController;
+import java.security.spec.AlgorithmParameterSpec;
+import javax.crypto.spec.DHParameterSpec;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.ArrayList;
+import javax.net.ssl.SSLProtocolException;
+
+import sun.security.action.GetPropertyAction;
+
+//
+// Note: Since RFC 7919, the extension's semantics are expanded from
+// "Supported Elliptic Curves" to "Supported Groups".  The enum datatype
+// used in the extension has been renamed from NamedCurve to NamedGroup.
+// Its semantics are likewise expanded from "named curve" to "named group".
+//
+final class SupportedGroupsExtension extends HelloExtension {
+
+    /* Class and subclass dynamic debugging support */
+    private static final Debug debug = Debug.getInstance("ssl");
+
+    private static final int ARBITRARY_PRIME = 0xff01;
+    private static final int ARBITRARY_CHAR2 = 0xff02;
+
+    // cache to speed up the parameters construction
+    private static final Map<NamedGroup,
+                AlgorithmParameters> namedGroupParams = new HashMap<>();
+
+    // the supported named groups
+    private static final NamedGroup[] supportedNamedGroups;
+
+    // the named group presented in the extension
+    private final int[] requestedNamedGroupIds;
+
+    static {
+        boolean requireFips = SunJSSE.isFIPS();
+
+        // The value of the System Property defines a list of enabled named
+        // groups in preference order, separated with comma.  For example:
+        //
+        //      jdk.tls.namedGroups="secp521r1, secp256r1, ffdhe2048"
+        //
+        // If the System Property is not defined or the value is empty, the
+        // default groups and preferences will be used.
+        String property = AccessController.doPrivileged(
+                    new GetPropertyAction("jdk.tls.namedGroups"));
+        if (property != null && property.length() != 0) {
+            // remove double quote marks from beginning/end of the property
+            if (property.length() > 1 && property.charAt(0) == '"' &&
+                    property.charAt(property.length() - 1) == '"') {
+                property = property.substring(1, property.length() - 1);
+            }
+        }
+
+        ArrayList<NamedGroup> groupList;
+        if (property != null && property.length() != 0) {   // customized groups
+            String[] groups = property.split(",");
+            groupList = new ArrayList<>(groups.length);
+            for (String group : groups) {
+                group = group.trim();
+                if (!group.isEmpty()) {
+                    NamedGroup namedGroup = NamedGroup.nameOf(group);
+                    if (namedGroup != null &&
+                            (!requireFips || namedGroup.isFips)) {
+                        if (isAvailableGroup(namedGroup)) {
+                            groupList.add(namedGroup);
+                        }
+                    }   // ignore unknown groups
+                }
+            }
+
+            if (groupList.isEmpty() && JsseJce.isEcAvailable()) {
+                throw new IllegalArgumentException(
+                    "System property jdk.tls.namedGroups(" + property + ") " +
+                    "contains no supported elliptic curves");
+            }
+        } else {        // default groups
+            NamedGroup[] groups;
+            if (requireFips) {
+                groups = new NamedGroup[] {
+                    // only NIST curves in FIPS mode
+                    NamedGroup.SECP256_R1,
+                    NamedGroup.SECP384_R1,
+                    NamedGroup.SECP521_R1,
+                    NamedGroup.SECT283_K1,
+                    NamedGroup.SECT283_R1,
+                    NamedGroup.SECT409_K1,
+                    NamedGroup.SECT409_R1,
+                    NamedGroup.SECT571_K1,
+                    NamedGroup.SECT571_R1,
+
+                    // FFDHE 2048
+                    NamedGroup.FFDHE_2048,
+                    NamedGroup.FFDHE_3072,
+                    NamedGroup.FFDHE_4096,
+                    NamedGroup.FFDHE_6144,
+                    NamedGroup.FFDHE_8192,
+                };
+            } else {
+                groups = new NamedGroup[] {
+                    // NIST curves first
+                    NamedGroup.SECP256_R1,
+                    NamedGroup.SECP384_R1,
+                    NamedGroup.SECP521_R1,
+                    NamedGroup.SECT283_K1,
+                    NamedGroup.SECT283_R1,
+                    NamedGroup.SECT409_K1,
+                    NamedGroup.SECT409_R1,
+                    NamedGroup.SECT571_K1,
+                    NamedGroup.SECT571_R1,
+
+                    // non-NIST curves
+                    NamedGroup.SECP256_K1,
+
+                    // FFDHE 2048
+                    NamedGroup.FFDHE_2048,
+                    NamedGroup.FFDHE_3072,
+                    NamedGroup.FFDHE_4096,
+                    NamedGroup.FFDHE_6144,
+                    NamedGroup.FFDHE_8192,
+                };
+            }
+
+            groupList = new ArrayList<>(groups.length);
+            for (NamedGroup group : groups) {
+                if (isAvailableGroup(group)) {
+                    groupList.add(group);
+                }
+            }
+        }
+
+        if (debug != null && groupList.isEmpty()) {
+            Debug.log(
+                "Initialized [jdk.tls.namedGroups|default] list contains " +
+                "no available elliptic curves. " +
+                (property != null ? "(" + property + ")" : "[Default]"));
+        }
+
+        supportedNamedGroups = new NamedGroup[groupList.size()];
+        int i = 0;
+        for (NamedGroup namedGroup : groupList) {
+            supportedNamedGroups[i++] = namedGroup;
+        }
+    }
+
+    // check whether the group is supported by the underlying providers
+    private static boolean isAvailableGroup(NamedGroup namedGroup) {
+        AlgorithmParameters params = null;
+        AlgorithmParameterSpec spec = null;
+        if ("EC".equals(namedGroup.algorithm)) {
+            if (namedGroup.oid != null) {
+                try {
+                    params = JsseJce.getAlgorithmParameters("EC");
+                    spec = new ECGenParameterSpec(namedGroup.oid);
+                } catch (Exception e) {
+                    return false;
+                }
+            }
+        } else if ("DiffieHellman".equals(namedGroup.algorithm)) {
+            try {
+                params = JsseJce.getAlgorithmParameters("DiffieHellman");
+                spec = getFFDHEDHParameterSpec(namedGroup);
+            } catch (Exception e) {
+                return false;
+            }
+        }
+
+        if ((params != null) && (spec != null)) {
+            try {
+                params.init(spec);
+            } catch (Exception e) {
+                return false;
+            }
+
+            // cache the parameters
+            namedGroupParams.put(namedGroup, params);
+
+            return true;
+        }
+
+        return false;
+    }
+
+    private static DHParameterSpec getFFDHEDHParameterSpec(
+            NamedGroup namedGroup) {
+        DHParameterSpec spec = null;
+        switch (namedGroup) {
+            case FFDHE_2048:
+                spec = PredefinedDHParameterSpecs.ffdheParams.get(2048);
+                break;
+            case FFDHE_3072:
+                spec = PredefinedDHParameterSpecs.ffdheParams.get(3072);
+                break;
+            case FFDHE_4096:
+                spec = PredefinedDHParameterSpecs.ffdheParams.get(4096);
+                break;
+            case FFDHE_6144:
+                spec = PredefinedDHParameterSpecs.ffdheParams.get(6144);
+                break;
+            case FFDHE_8192:
+                spec = PredefinedDHParameterSpecs.ffdheParams.get(8192);
+        }
+
+        return spec;
+    }
+
+    private static DHParameterSpec getPredefinedDHParameterSpec(
+            NamedGroup namedGroup) {
+        DHParameterSpec spec = null;
+        switch (namedGroup) {
+            case FFDHE_2048:
+                spec = PredefinedDHParameterSpecs.definedParams.get(2048);
+                break;
+            case FFDHE_3072:
+                spec = PredefinedDHParameterSpecs.definedParams.get(3072);
+                break;
+            case FFDHE_4096:
+                spec = PredefinedDHParameterSpecs.definedParams.get(4096);
+                break;
+            case FFDHE_6144:
+                spec = PredefinedDHParameterSpecs.definedParams.get(6144);
+                break;
+            case FFDHE_8192:
+                spec = PredefinedDHParameterSpecs.definedParams.get(8192);
+        }
+
+        return spec;
+    }
+
+    private SupportedGroupsExtension(int[] requestedNamedGroupIds) {
+        super(ExtensionType.EXT_SUPPORTED_GROUPS);
+
+        this.requestedNamedGroupIds = requestedNamedGroupIds;
+    }
+
+    SupportedGroupsExtension(HandshakeInStream s, int len) throws IOException {
+        super(ExtensionType.EXT_SUPPORTED_GROUPS);
+
+        int k = s.getInt16();
+        if (((len & 1) != 0) || (k == 0) || (k + 2 != len)) {
+            throw new SSLProtocolException("Invalid " + type + " extension");
+        }
+
+        // Note: unknown named group will be ignored later.
+        requestedNamedGroupIds = new int[k >> 1];
+        for (int i = 0; i < requestedNamedGroupIds.length; i++) {
+            requestedNamedGroupIds[i] = s.getInt16();
+        }
+    }
+
+    // Get a local preferred supported ECDHE group permitted by the constraints.
+    static NamedGroup getPreferredECGroup(AlgorithmConstraints constraints) {
+        for (NamedGroup namedGroup : supportedNamedGroups) {
+            if ((namedGroup.type == NamedGroupType.NAMED_GROUP_ECDHE) &&
+                constraints.permits(EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
+                    namedGroup.algorithm, namedGroupParams.get(namedGroup))) {
+
+                return namedGroup;
+            }
+        }
+
+        return null;
+    }
+
+    // Is there any supported group permitted by the constraints?
+    static boolean isActivatable(
+            AlgorithmConstraints constraints, NamedGroupType type) {
+
+        boolean hasFFDHEGroups = false;
+        for (NamedGroup namedGroup : supportedNamedGroups) {
+            if (namedGroup.type == type) {
+                if (constraints.permits(
+                        EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
+                        namedGroup.algorithm,
+                        namedGroupParams.get(namedGroup))) {
+
+                    return true;
+                }
+
+                if (!hasFFDHEGroups &&
+                        (type == NamedGroupType.NAMED_GROUP_FFDHE)) {
+
+                    hasFFDHEGroups = true;
+                }
+            }
+        }
+
+        // For compatibility, if no FFDHE groups are defined, the non-FFDHE
+        // compatible mode (using DHE cipher suite without FFDHE extension)
+        // is allowed.
+        //
+        // Note that the constraints checking on DHE parameters will be
+        // performed during key exchanging in a handshake.
+        if (!hasFFDHEGroups && (type == NamedGroupType.NAMED_GROUP_FFDHE)) {
+            return true;
+        }
+
+        return false;
+    }
+
+    // Create the default supported groups extension.
+    static SupportedGroupsExtension createExtension(
+            AlgorithmConstraints constraints,
+            CipherSuiteList cipherSuites, boolean enableFFDHE) {
+
+        ArrayList<Integer> groupList =
+                new ArrayList<>(supportedNamedGroups.length);
+        for (NamedGroup namedGroup : supportedNamedGroups) {
+            if ((!enableFFDHE) &&
+                (namedGroup.type == NamedGroupType.NAMED_GROUP_FFDHE)) {
+                continue;
+            }
+
+            if (cipherSuites.contains(namedGroup.type) &&
+                constraints.permits(EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
+                    namedGroup.algorithm, namedGroupParams.get(namedGroup))) {
+
+                groupList.add(namedGroup.id);
+            }
+        }
+
+        if (!groupList.isEmpty()) {
+            int[] ids = new int[groupList.size()];
+            int i = 0;
+            for (Integer id : groupList) {
+                ids[i++] = id;
+            }
+
+            return new SupportedGroupsExtension(ids);
+        }
+
+        return null;
+    }
+
+    // get the preferred activated named group
+    NamedGroup getPreferredGroup(
+            AlgorithmConstraints constraints, NamedGroupType type) {
+
+        for (int groupId : requestedNamedGroupIds) {
+            NamedGroup namedGroup = NamedGroup.valueOf(groupId);
+            if ((namedGroup != null) && (namedGroup.type == type) &&
+                SupportedGroupsExtension.supports(namedGroup) &&
+                constraints.permits(EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
+                    namedGroup.algorithm, namedGroupParams.get(namedGroup))) {
+
+                return namedGroup;
+            }
+        }
+
+        return null;
+    }
+
+    boolean hasFFDHEGroup() {
+        for (int groupId : requestedNamedGroupIds) {
+            /*
+             * [RFC 7919] Codepoints in the "Supported Groups Registry"
+             * with a high byte of 0x01 (that is, between 256 and 511,
+             * inclusive) are set aside for FFDHE groups.
+             */
+            if ((groupId >= 256) && (groupId <= 511)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    boolean contains(int index) {
+        for (int groupId : requestedNamedGroupIds) {
+            if (index == groupId) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    int length() {
+        return 6 + (requestedNamedGroupIds.length << 1);
+    }
+
+    @Override
+    void send(HandshakeOutStream s) throws IOException {
+        s.putInt16(type.id);
+        int k = requestedNamedGroupIds.length << 1;
+        s.putInt16(k + 2);
+        s.putInt16(k);
+        for (int groupId : requestedNamedGroupIds) {
+            s.putInt16(groupId);
+        }
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("Extension " + type + ", group names: {");
+        boolean first = true;
+        for (int groupId : requestedNamedGroupIds) {
+            if (first) {
+                first = false;
+            } else {
+                sb.append(", ");
+            }
+            // first check if it is a known named group, then try other cases.
+            NamedGroup namedGroup = NamedGroup.valueOf(groupId);
+            if (namedGroup != null) {
+                sb.append(namedGroup.name);
+            } else if (groupId == ARBITRARY_PRIME) {
+                sb.append("arbitrary_explicit_prime_curves");
+            } else if (groupId == ARBITRARY_CHAR2) {
+                sb.append("arbitrary_explicit_char2_curves");
+            } else {
+                sb.append("unknown named group " + groupId);
+            }
+        }
+        sb.append("}");
+        return sb.toString();
+    }
+
+    static boolean supports(NamedGroup namedGroup) {
+        for (NamedGroup group : supportedNamedGroups) {
+            if (namedGroup.id == group.id) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    static ECGenParameterSpec getECGenParamSpec(NamedGroup namedGroup) {
+        if (namedGroup.type != NamedGroupType.NAMED_GROUP_ECDHE) {
+            throw new RuntimeException("Not a named EC group: " + namedGroup);
+        }
+
+        AlgorithmParameters params = namedGroupParams.get(namedGroup);
+        try {
+            return params.getParameterSpec(ECGenParameterSpec.class);
+        } catch (InvalidParameterSpecException ipse) {
+            // should be unlikely
+            return new ECGenParameterSpec(namedGroup.oid);
+        }
+    }
+
+    static DHParameterSpec getDHParameterSpec(NamedGroup namedGroup) {
+        if (namedGroup.type != NamedGroupType.NAMED_GROUP_FFDHE) {
+            throw new RuntimeException("Not a named DH group: " + namedGroup);
+        }
+
+        AlgorithmParameters params = namedGroupParams.get(namedGroup);
+        try {
+            return params.getParameterSpec(DHParameterSpec.class);
+        } catch (InvalidParameterSpecException ipse) {
+            // should be unlikely
+            return getPredefinedDHParameterSpec(namedGroup);
+        }
+    }
+}
--- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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++;
--- a/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/util/AlgorithmDecomposer.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
 
 import java.util.HashSet;
 import java.util.Set;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.regex.Pattern;
 
 /**
@@ -134,6 +136,23 @@
         return elements;
     }
 
+    /**
+     * Get aliases of the specified algorithm.
+     *
+     * May support more algorithms in the future.
+     */
+    public static Collection<String> getAliases(String algorithm) {
+        String[] aliases;
+        if (algorithm.equalsIgnoreCase("DH") ||
+                algorithm.equalsIgnoreCase("DiffieHellman")) {
+            aliases = new String[] {"DH", "DiffieHellman"};
+        } else {
+            aliases = new String[] {algorithm};
+        }
+
+        return Arrays.asList(aliases);
+    }
+
     private static void hasLoop(Set<String> elements, String find, String replace) {
         if (elements.contains(find)) {
             if (!elements.contains(replace)) {
--- a/jdk/src/java.base/share/classes/sun/security/util/Debug.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/util/Debug.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 
 package sun.security.util;
 
+import java.io.PrintStream;
 import java.math.BigInteger;
 import java.util.regex.Pattern;
 import java.util.regex.Matcher;
@@ -32,7 +33,7 @@
 import sun.security.action.GetPropertyAction;
 
 /**
- * A utility class for debuging.
+ * A utility class for debugging.
  *
  * @author Roland Schemers
  */
@@ -118,6 +119,7 @@
         System.err.println("The following can be used with certpath:");
         System.err.println();
         System.err.println("ocsp          dump the OCSP protocol exchanges");
+        System.err.println("verbose       verbose debugging");
         System.err.println();
         System.err.println("Note: Separate multiple options with a comma");
         System.exit(0);
@@ -166,6 +168,13 @@
     }
 
     /**
+     * Check if verbose messages is enabled for extra debugging.
+     */
+    public static boolean isVerbose() {
+        return isOn("verbose");
+    }
+
+    /**
      * print a message to stderr that is prefixed with the prefix
      * created from the call to getInstance.
      */
@@ -204,6 +213,13 @@
     }
 
     /**
+     * PrintStream for debug methods. Currently only System.err is supported.
+     */
+    public PrintStream getPrintStream() {
+        return System.err;
+    }
+
+    /**
      * return a hexadecimal printed representation of the specified
      * BigInteger object. the value is formatted to fit on lines of
      * at least 75 characters, with embedded newlines. Words are
--- a/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java	Wed Jul 05 23:37:13 2017 +0200
@@ -45,6 +45,7 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+import java.util.Collection;
 import java.util.StringTokenizer;
 import java.util.TimeZone;
 import java.util.regex.Pattern;
@@ -106,7 +107,15 @@
     @Override
     public final boolean permits(Set<CryptoPrimitive> primitives,
             String algorithm, AlgorithmParameters parameters) {
-        return checkAlgorithm(disabledAlgorithms, algorithm, decomposer);
+        if (!checkAlgorithm(disabledAlgorithms, algorithm, decomposer)) {
+            return false;
+        }
+
+        if (parameters != null) {
+            return algorithmConstraints.permits(algorithm, parameters);
+        }
+
+        return true;
     }
 
     /*
@@ -242,7 +251,12 @@
                 List<Constraint> constraintList =
                         constraintsMap.getOrDefault(algorithm,
                                 new ArrayList<>(1));
-                constraintsMap.putIfAbsent(algorithm, constraintList);
+
+                // Consider the impact of algorithm aliases.
+                for (String alias : AlgorithmDecomposer.getAliases(algorithm)) {
+                    constraintsMap.putIfAbsent(alias, constraintList);
+                }
+
                 if (space <= 0) {
                     constraintList.add(new DisabledConstraint(algorithm));
                     continue;
@@ -351,6 +365,27 @@
             return true;
         }
 
+        // Check if constraints permit this AlgorithmParameters.
+        public boolean permits(String algorithm, AlgorithmParameters aps) {
+            List<Constraint> list = getConstraints(algorithm);
+            if (list == null) {
+                return true;
+            }
+
+            for (Constraint constraint : list) {
+                if (!constraint.permits(aps)) {
+                    if (debug != null) {
+                        debug.println("keySizeConstraint: failed algorithm " +
+                                "parameters constraint check " + aps);
+                    }
+
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
         // Check if constraints permit this cert.
         public void permits(String algorithm, ConstraintsParameters cp)
                 throws CertPathValidatorException {
@@ -445,6 +480,18 @@
         }
 
         /**
+         * Check if the algorithm constraint permits a given cryptographic
+         * parameters.
+         *
+         * @param parameters the cryptographic parameters
+         * @return 'true' if the cryptographic parameters is allowed,
+         *         'false' ortherwise.
+         */
+        public boolean permits(AlgorithmParameters parameters) {
+            return true;
+        }
+
+        /**
          * Check if an algorithm constraint is permitted with a given
          * ConstraintsParameters.
          *
@@ -528,6 +575,7 @@
          * call next() for any following constraints. If it does not, exit
          * as this constraint(s) does not restrict the operation.
          */
+        @Override
         public void permits(ConstraintsParameters cp)
                 throws CertPathValidatorException {
             if (debug != null) {
@@ -551,100 +599,101 @@
      * This class handles the denyAfter constraint.  The date is in the UTC/GMT
      * timezone.
      */
-     private static class DenyAfterConstraint extends Constraint {
-         private Date denyAfterDate;
-         private static final SimpleDateFormat dateFormat =
-                 new SimpleDateFormat("EEE, MMM d HH:mm:ss z yyyy");
+    private static class DenyAfterConstraint extends Constraint {
+        private Date denyAfterDate;
+        private static final SimpleDateFormat dateFormat =
+                new SimpleDateFormat("EEE, MMM d HH:mm:ss z yyyy");
 
-         DenyAfterConstraint(String algo, int year, int month, int day) {
-             Calendar c;
+        DenyAfterConstraint(String algo, int year, int month, int day) {
+            Calendar c;
 
-             algorithm = algo;
+            algorithm = algo;
 
-             if (debug != null) {
-                 debug.println("DenyAfterConstraint read in as:  year " +
-                         year + ", month = " + month + ", day = " + day);
-             }
+            if (debug != null) {
+                debug.println("DenyAfterConstraint read in as:  year " +
+                        year + ", month = " + month + ", day = " + day);
+            }
 
-             c = new Calendar.Builder().setTimeZone(TimeZone.getTimeZone("GMT"))
-                     .setDate(year, month - 1, day).build();
+            c = new Calendar.Builder().setTimeZone(TimeZone.getTimeZone("GMT"))
+                    .setDate(year, month - 1, day).build();
 
-             if (year > c.getActualMaximum(Calendar.YEAR) ||
-                     year < c.getActualMinimum(Calendar.YEAR)) {
-                 throw new IllegalArgumentException(
-                         "Invalid year given in constraint: " + year);
-             }
-             if ((month - 1) > c.getActualMaximum(Calendar.MONTH) ||
-                     (month - 1) < c.getActualMinimum(Calendar.MONTH)) {
-                 throw new IllegalArgumentException(
-                         "Invalid month given in constraint: " + month);
-             }
-             if (day > c.getActualMaximum(Calendar.DAY_OF_MONTH) ||
-                     day < c.getActualMinimum(Calendar.DAY_OF_MONTH)) {
-                 throw new IllegalArgumentException(
-                         "Invalid Day of Month given in constraint: " + day);
-             }
+            if (year > c.getActualMaximum(Calendar.YEAR) ||
+                    year < c.getActualMinimum(Calendar.YEAR)) {
+                throw new IllegalArgumentException(
+                        "Invalid year given in constraint: " + year);
+            }
+            if ((month - 1) > c.getActualMaximum(Calendar.MONTH) ||
+                    (month - 1) < c.getActualMinimum(Calendar.MONTH)) {
+                throw new IllegalArgumentException(
+                        "Invalid month given in constraint: " + month);
+            }
+            if (day > c.getActualMaximum(Calendar.DAY_OF_MONTH) ||
+                    day < c.getActualMinimum(Calendar.DAY_OF_MONTH)) {
+                throw new IllegalArgumentException(
+                        "Invalid Day of Month given in constraint: " + day);
+            }
 
-             denyAfterDate = c.getTime();
-             if (debug != null) {
-                 debug.println("DenyAfterConstraint date set to: " +
-                         dateFormat.format(denyAfterDate));
-             }
-         }
+            denyAfterDate = c.getTime();
+            if (debug != null) {
+                debug.println("DenyAfterConstraint date set to: " +
+                        dateFormat.format(denyAfterDate));
+            }
+        }
 
-         /*
-          * Checking that the provided date is not beyond the constraint date.
-          * The provided date can be the PKIXParameter date if given,
-          * otherwise it is the current date.
-          *
-          * If the constraint disallows, call next() for any following
-          * constraints. Throw an exception if this is the last constraint.
-          */
-         @Override
-         public void permits(ConstraintsParameters cp)
-                 throws CertPathValidatorException {
-             Date currentDate;
-             String errmsg;
+        /*
+         * Checking that the provided date is not beyond the constraint date.
+         * The provided date can be the PKIXParameter date if given,
+         * otherwise it is the current date.
+         *
+         * If the constraint disallows, call next() for any following
+         * constraints. Throw an exception if this is the last constraint.
+         */
+        @Override
+        public void permits(ConstraintsParameters cp)
+                throws CertPathValidatorException {
+            Date currentDate;
+            String errmsg;
 
-             if (cp.getJARTimestamp() != null) {
-                 currentDate = cp.getJARTimestamp().getTimestamp();
-                 errmsg = "JAR Timestamp date: ";
-             } else if (cp.getPKIXParamDate() != null) {
-                 currentDate = cp.getPKIXParamDate();
-                 errmsg = "PKIXParameter date: ";
-             } else {
-                 currentDate = new Date();
-                 errmsg = "Current date: ";
-             }
+            if (cp.getJARTimestamp() != null) {
+                currentDate = cp.getJARTimestamp().getTimestamp();
+                errmsg = "JAR Timestamp date: ";
+            } else if (cp.getPKIXParamDate() != null) {
+                currentDate = cp.getPKIXParamDate();
+                errmsg = "PKIXParameter date: ";
+            } else {
+                currentDate = new Date();
+                errmsg = "Current date: ";
+            }
 
-             if (!denyAfterDate.after(currentDate)) {
-                 if (next(cp)) {
-                     return;
-                 }
-                 throw new CertPathValidatorException(
-                         "denyAfter constraint check failed: " + algorithm +
-                         " used with Constraint date: " +
-                         dateFormat.format(denyAfterDate) + "; " + errmsg +
-                         dateFormat.format(currentDate) + extendedMsg(cp),
-                         null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
-             }
-         }
+            if (!denyAfterDate.after(currentDate)) {
+                if (next(cp)) {
+                    return;
+                }
+                throw new CertPathValidatorException(
+                        "denyAfter constraint check failed: " + algorithm +
+                        " used with Constraint date: " +
+                        dateFormat.format(denyAfterDate) + "; " + errmsg +
+                        dateFormat.format(currentDate) + extendedMsg(cp),
+                        null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
+            }
+        }
 
-         /*
-          * Return result if the constraint's date is beyond the current date
-          * in UTC timezone.
-          */
-         public boolean permits(Key key) {
-             if (next(key)) {
-                 return true;
-             }
-             if (debug != null) {
-                 debug.println("DenyAfterConstraints.permits(): " + algorithm);
-             }
+        /*
+         * Return result if the constraint's date is beyond the current date
+         * in UTC timezone.
+         */
+        @Override
+        public boolean permits(Key key) {
+            if (next(key)) {
+                return true;
+            }
+            if (debug != null) {
+                debug.println("DenyAfterConstraints.permits(): " + algorithm);
+            }
 
-             return denyAfterDate.after(new Date());
-         }
-     }
+            return denyAfterDate.after(new Date());
+        }
+    }
 
     /*
      * The usage constraint is for the "usage" keyword.  It checks against the
@@ -658,6 +707,7 @@
             this.usages = usages;
         }
 
+        @Override
         public void permits(ConstraintsParameters cp)
                 throws CertPathValidatorException {
             for (String usage : usages) {
@@ -674,12 +724,11 @@
                 if (debug != null) {
                     debug.println("Checking if usage constraint \"" + v +
                             "\" matches \"" + cp.getVariant() + "\"");
-                    // Because usage checking can come from many places
-                    // a stack trace is very helpful.
-                    ByteArrayOutputStream ba = new ByteArrayOutputStream();
-                    PrintStream ps = new PrintStream(ba);
-                    (new Exception()).printStackTrace(ps);
-                    debug.println(ba.toString());
+                    if (Debug.isVerbose()) {
+                        // Because usage checking can come from many places
+                        // a stack trace is very helpful.
+                        (new Exception()).printStackTrace(debug.getPrintStream());
+                    }
                 }
                 if (cp.getVariant().compareTo(v) == 0) {
                     if (next(cp)) {
@@ -747,6 +796,7 @@
          * constraint  Any permitted constraint will exit the linked list
          * to allow the operation.
          */
+        @Override
         public void permits(ConstraintsParameters cp)
                 throws CertPathValidatorException {
             Key key = null;
@@ -770,6 +820,7 @@
 
         // Check if key constraint disable the specified key
         // Uses old style permit()
+        @Override
         public boolean permits(Key key) {
             // If we recursively find a constraint that permits us to use
             // this key, return true and skip any other constraint checks.
@@ -783,6 +834,30 @@
             return permitsImpl(key);
         }
 
+        @Override
+        public boolean permits(AlgorithmParameters parameters) {
+            String paramAlg = parameters.getAlgorithm();
+            if (!algorithm.equalsIgnoreCase(parameters.getAlgorithm())) {
+                // Consider the impact of the algorithm aliases.
+                Collection<String> aliases =
+                        AlgorithmDecomposer.getAliases(algorithm);
+                if (!aliases.contains(paramAlg)) {
+                    return true;
+                }
+            }
+
+            int keySize = KeyUtil.getKeySize(parameters);
+            if (keySize == 0) {
+                return false;
+            } else if (keySize > 0) {
+                return !((keySize < minSize) || (keySize > maxSize) ||
+                    (prohibitedSize == keySize));
+            }   // Otherwise, the key size is not accessible or determined.
+                // Conservatively, please don't disable such keys.
+
+            return true;
+        }
+
         private boolean permitsImpl(Key key) {
             // Verify this constraint is for this public key algorithm
             if (algorithm.compareToIgnoreCase(key.getAlgorithm()) != 0) {
@@ -810,6 +885,7 @@
             algorithm = algo;
         }
 
+        @Override
         public void permits(ConstraintsParameters cp)
                 throws CertPathValidatorException {
             throw new CertPathValidatorException(
@@ -818,6 +894,7 @@
                     null, null, -1, BasicReason.ALGORITHM_CONSTRAINED);
         }
 
+        @Override
         public boolean permits(Key key) {
             return false;
         }
--- a/jdk/src/java.base/share/classes/sun/security/util/KeyUtil.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/util/KeyUtil.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,6 +25,7 @@
 
 package sun.security.util;
 
+import java.security.AlgorithmParameters;
 import java.security.Key;
 import java.security.PrivilegedAction;
 import java.security.AccessController;
@@ -35,6 +36,8 @@
 import java.security.interfaces.DSAParams;
 import java.security.SecureRandom;
 import java.security.spec.KeySpec;
+import java.security.spec.ECParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
 import javax.crypto.SecretKey;
 import javax.crypto.interfaces.DHKey;
 import javax.crypto.interfaces.DHPublicKey;
@@ -100,6 +103,61 @@
     }
 
     /**
+     * Returns the key size of the given cryptographic parameters in bits.
+     *
+     * @param parameters the cryptographic parameters, cannot be null
+     * @return the key size of the given cryptographic parameters in bits,
+     *       or -1 if the key size is not accessible
+     */
+    public static final int getKeySize(AlgorithmParameters parameters) {
+
+        String algorithm = parameters.getAlgorithm();
+        switch (algorithm) {
+            case "EC":
+                try {
+                    ECKeySizeParameterSpec ps = parameters.getParameterSpec(
+                            ECKeySizeParameterSpec.class);
+                    if (ps != null) {
+                        return ps.getKeySize();
+                    }
+                } catch (InvalidParameterSpecException ipse) {
+                    // ignore
+                }
+
+                try {
+                    ECParameterSpec ps = parameters.getParameterSpec(
+                            ECParameterSpec.class);
+                    if (ps != null) {
+                        return ps.getOrder().bitLength();
+                    }
+                } catch (InvalidParameterSpecException ipse) {
+                    // ignore
+                }
+
+                // Note: the ECGenParameterSpec case should be covered by the
+                // ECParameterSpec case above.
+                // See ECUtil.getECParameterSpec(Provider, String).
+
+                break;
+            case "DiffieHellman":
+                try {
+                    DHParameterSpec ps = parameters.getParameterSpec(
+                            DHParameterSpec.class);
+                    if (ps != null) {
+                        return ps.getP().bitLength();
+                    }
+                } catch (InvalidParameterSpecException ipse) {
+                    // ignore
+                }
+                break;
+
+            // May support more AlgorithmParameters algorithms in the future.
+        }
+
+        return -1;
+    }
+
+    /**
      * Returns whether the key is valid or not.
      * <P>
      * Note that this method is only apply to DHPublicKey at present.
--- a/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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.
--- a/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/security/x509/X509CertImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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).
--- a/jdk/src/java.base/share/classes/sun/util/calendar/AbstractCalendar.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/classes/sun/util/calendar/AbstractCalendar.java	Wed Jul 05 23:37:13 2017 +0200
@@ -63,9 +63,9 @@
 
     public Era getEra(String eraName) {
         if (eras != null) {
-            for (int i = 0; i < eras.length; i++) {
-                if (eras[i].equals(eraName)) {
-                    return eras[i];
+            for (Era era : eras) {
+                if (era.getName().equals(eraName)) {
+                    return era;
                 }
             }
         }
--- a/jdk/src/java.base/share/native/libjli/java.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/share/native/libjli/java.c	Wed Jul 05 23:37:13 2017 +0200
@@ -129,7 +129,6 @@
 static void SetPaths(int argc, char **argv);
 
 static void DumpState();
-static jboolean RemovableOption(char *option);
 
 enum OptionKind {
     LAUNCHER_OPTION = 0,
@@ -771,17 +770,16 @@
 }
 
 /*
- * static void SetJvmEnvironment(int argc, char **argv);
- *   Is called just before the JVM is loaded.  We can set env variables
- *   that are consumed by the JVM.  This function is non-destructive,
- *   leaving the arg list intact.  The first use is for the JVM flag
- *   -XX:NativeMemoryTracking=value.
+ * This method must be called before the VM is loaded, primarily
+ * used to parse and set any VM related options or env variables.
+ * This function is non-destructive leaving the argument list intact.
  */
 static void
 SetJvmEnvironment(int argc, char **argv) {
 
     static const char*  NMT_Env_Name    = "NMT_LEVEL_";
     int i;
+    /* process only the launcher arguments */
     for (i = 0; i < argc; i++) {
         char *arg = argv[i];
         /*
@@ -840,11 +838,8 @@
                     printf("TRACER_MARKER: NativeMemoryTracking: got value %s\n",envBuf);
                     free(envName);
                 }
-
             }
-
         }
-
     }
 }
 
@@ -1411,8 +1406,6 @@
             ; /* Ignore machine independent options already handled */
         } else if (ProcessPlatformOption(arg)) {
             ; /* Processing of platform dependent options */
-        } else if (RemovableOption(arg)) {
-            ; /* Do not pass option to vm. */
         } else {
             /* java.class.path set on the command line */
             if (JLI_StrCCmp(arg, "-Djava.class.path=") == 0) {
@@ -2334,34 +2327,6 @@
 }
 
 /*
- * Return JNI_TRUE for an option string that has no effect but should
- * _not_ be passed on to the vm; return JNI_FALSE otherwise.  On
- * Solaris SPARC, this screening needs to be done if:
- *    -d32 or -d64 is passed to a binary with an unmatched data model
- *    (the exec in CreateExecutionEnvironment removes -d<n> options and points the
- *    exec to the proper binary).  In the case of when the data model and the
- *    requested version is matched, an exec would not occur, and these options
- *    were erroneously passed to the vm.
- */
-jboolean
-RemovableOption(char * option)
-{
-  /*
-   * Unconditionally remove both -d32 and -d64 options since only
-   * the last such options has an effect; e.g.
-   * java -d32 -d64 -d32 -version
-   * is equivalent to
-   * java -d32 -version
-   */
-
-  if( (JLI_StrCCmp(option, "-d32")  == 0 ) ||
-      (JLI_StrCCmp(option, "-d64")  == 0 ) )
-    return JNI_TRUE;
-  else
-    return JNI_FALSE;
-}
-
-/*
  * A utility procedure to always print to stderr
  */
 void
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/solaris/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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();
+    }
+}
--- a/jdk/src/java.base/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/solaris/classes/sun/nio/ch/DefaultSelectorProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,6 @@
      * Returns the default SelectorProvider.
      */
     public static SelectorProvider create() {
-        return new sun.nio.ch.DevPollSelectorProvider();
+        return new DevPollSelectorProvider();
     }
-
 }
--- a/jdk/src/java.base/solaris/native/libnet/solaris_close.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/solaris/native/libnet/solaris_close.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,8 @@
 #include <sys/socket.h>
 #include <stropts.h>
 #include <unistd.h>
+#include "jvm.h"
+#include "net_util.h"
 
 /* Support for restartable system calls on Solaris. */
 
@@ -90,25 +92,22 @@
     RESTARTABLE_RETURN_INT(poll(ufds, nfds, timeout));
 }
 
-int NET_Timeout0(int s, long timeout, long currentTime) {
+int NET_Timeout(JNIEnv *env, int s, long timeout, jlong nanoTimeStamp) {
     int result;
-    struct timeval t;
-    long prevtime = currentTime, newtime;
+    jlong prevNanoTime = nanoTimeStamp;
+    jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
     struct pollfd pfd;
     pfd.fd = s;
     pfd.events = POLLIN;
 
     for(;;) {
-        result = poll(&pfd, 1, timeout);
+        result = poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
         if (result < 0 && errno == EINTR) {
-            if (timeout > 0) {
-                gettimeofday(&t, NULL);
-                newtime = (t.tv_sec * 1000)  +  t.tv_usec /1000;
-                timeout -= newtime - prevtime;
-                if (timeout <= 0)
-                    return 0;
-                prevtime = newtime;
-            }
+            jlong newNanoTime = JVM_NanoTime(env, 0);
+            nanoTimeout -= newNanoTime - prevNanoTime;
+            if (nanoTimeout < NET_NSEC_PER_MSEC)
+                return 0;
+            prevNanoTime = newNanoTime;
         } else {
             return result;
         }
--- a/jdk/src/java.base/unix/classes/sun/nio/ch/DefaultAsynchronousChannelProvider.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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");
-    }
-}
--- a/jdk/src/java.base/unix/native/libjava/UnixFileSystem_md.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libjava/UnixFileSystem_md.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -229,7 +229,16 @@
     WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
         struct stat64 sb;
         if (stat64(path, &sb) == 0) {
-            rv = 1000 * (jlong)sb.st_mtime;
+#if defined(_AIX)
+            rv =  (jlong)sb.st_mtime * 1000;
+            rv += (jlong)sb.st_mtime_n / 1000000;
+#elif defined(MACOSX)
+            rv  = (jlong)sb.st_mtimespec.tv_sec * 1000;
+            rv += (jlong)sb.st_mtimespec.tv_nsec / 1000000;
+#else
+            rv  = (jlong)sb.st_mtim.tv_sec * 1000;
+            rv += (jlong)sb.st_mtim.tv_nsec / 1000000;
+#endif
         }
     } END_PLATFORM_STRING(env, path);
     return rv;
@@ -413,9 +422,16 @@
             struct timeval tv[2];
 
             /* Preserve access time */
+#if defined(_AIX)
             tv[0].tv_sec = sb.st_atime;
-            tv[0].tv_usec = 0;
-
+            tv[0].tv_usec = sb.st_atime_n / 1000;
+#elif defined(MACOSX)
+            tv[0].tv_sec = sb.st_atimespec.tv_sec;
+            tv[0].tv_usec = sb.st_atimespec.tv_nsec / 1000;
+#else
+            tv[0].tv_sec = sb.st_atim.tv_sec;
+            tv[0].tv_usec = sb.st_atim.tv_nsec / 1000;
+#endif
             /* Change last-modified time */
             tv[1].tv_sec = time / 1000;
             tv[1].tv_usec = (time % 1000) * 1000;
--- a/jdk/src/java.base/unix/native/libjli/java_md.h	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libjli/java_md.h	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -54,7 +54,7 @@
 const char *SetExecname(char **argv);
 const char *GetExecName();
 static jboolean GetJVMPath(const char *jrepath, const char *jvmtype,
-                           char *jvmpath, jint jvmpathsize, int bitsWanted);
+                           char *jvmpath, jint jvmpathsize);
 static jboolean GetJREPath(char *path, jint pathsize, jboolean speculative);
 
 #if defined(_AIX)
--- a/jdk/src/java.base/unix/native/libjli/java_md_solinux.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libjli/java_md_solinux.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,9 +62,7 @@
  *
  * The selection of the proper vm shared library to open depends on
  * several classes of command line options, including vm "flavor"
- * options (-client, -server) and the data model options, -d32  and
- * -d64, as well as a version specification which may have come from
- * the command line or from the manifest of an executable jar file.
+ * options (-client, -server).
  * The vm selection options are not passed to the running
  * virtual machine; they must be screened out by the launcher.
  *
@@ -120,34 +118,30 @@
  *  |
  * \|/
  * ParseArguments
- * (removes -d32 and -d64 if any,
- *  processes version options,
- *  creates argument list for vm,
- *  etc.)
  *   |
  *   |
  *  \|/
  * RequiresSetenv
  * Is LD_LIBRARY_PATH
- * and friends set ? --> NO --> Have Desired Model ? NO --> Error/Exit
- *  YES                              YES --> Continue
+ * and friends set ? --> NO --> Continue
+ *  YES
  *   |
  *   |
  *  \|/
- * Path is desired JRE ? YES --> Have Desired Model ? NO --> Error/Exit
- *  NO                               YES --> Continue
+ * Path is desired JRE ? YES --> Continue
+ *  NO
  *   |
  *   |
  *  \|/
  * Paths have well known
- * jvm paths ?       --> NO --> Have Desired Model ? NO --> Error/Exit
- *  YES                              YES --> Continue
+ * jvm paths ?       --> NO --> Error/Exit
+ *  YES
  *   |
  *   |
  *  \|/
- *  Does libjvm.so exit
- *  in any of them ? --> NO --> Have Desired Model ? NO --> Error/Exit
- *   YES                             YES --> Continue
+ *  Does libjvm.so exist
+ *  in any of them ? --> NO  --> Continue
+ *   YES
  *   |
  *   |
  *  \|/
@@ -302,229 +296,97 @@
                            char jrepath[], jint so_jrepath,
                            char jvmpath[], jint so_jvmpath,
                            char jvmcfg[],  jint so_jvmcfg) {
-  /*
-   * First, determine if we are running the desired data model.  If we
-   * are running the desired data model, all the error messages
-   * associated with calling GetJREPath, ReadKnownVMs, etc. should be
-   * output, otherwise we simply exit with an error, as we no longer
-   * support dual data models.
-   */
-    jboolean jvmpathExists;
+
+    char * jvmtype = NULL;
+    int argc = *pargc;
+    char **argv = *pargv;
+
+#ifdef SETENV_REQUIRED
+    jboolean mustsetenv = JNI_FALSE;
+    char *runpath = NULL; /* existing effective LD_LIBRARY_PATH setting */
+    char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */
+    char* newpath = NULL; /* path on new LD_LIBRARY_PATH */
+    char* lastslash = NULL;
+    char** newenvp = NULL; /* current environment */
+    size_t new_runpath_size;
+#endif  /* SETENV_REQUIRED */
 
     /* Compute/set the name of the executable */
     SetExecname(*pargv);
 
-    /* Check data model flags, and exec process, if needed */
-    {
-      char * jvmtype    = NULL;
-      int  argc         = *pargc;
-      char **argv       = *pargv;
-      int running       = CURRENT_DATA_MODEL;
-      /*
-       * As of jdk9, there is no support for dual mode operations, however
-       * for legacy error reporting purposes and until -d options are supported
-       * we need this.
-       */
-      int wanted        = running;
-#ifdef SETENV_REQUIRED
-      jboolean mustsetenv = JNI_FALSE;
-      char *runpath     = NULL; /* existing effective LD_LIBRARY_PATH setting */
-      char* new_runpath = NULL; /* desired new LD_LIBRARY_PATH string */
-      char* newpath     = NULL; /* path on new LD_LIBRARY_PATH */
-      char* lastslash   = NULL;
-      char** newenvp    = NULL; /* current environment */
-      size_t new_runpath_size;
-#ifdef __solaris__
-      char*  dmpath     = NULL;  /* data model specific LD_LIBRARY_PATH,
-                                    Solaris only */
-#endif /* __solaris__ */
-#endif  /* SETENV_REQUIRED */
+    /* Check to see if the jvmpath exists */
+    /* Find out where the JRE is that we will be using. */
+    if (!GetJREPath(jrepath, so_jrepath, JNI_FALSE)) {
+        JLI_ReportErrorMessage(JRE_ERROR1);
+        exit(2);
+    }
+    JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%sjvm.cfg",
+            jrepath, FILESEP, FILESEP);
+    /* Find the specified JVM type */
+    if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) {
+        JLI_ReportErrorMessage(CFG_ERROR7);
+        exit(1);
+    }
 
-      char** newargv    = NULL;
-      int    newargc    = 0;
-
-      /*
-       * Starting in 1.5, all unix platforms accept the -d32 and -d64
-       * options.  On platforms where only one data-model is supported
-       * (e.g. ia-64 Linux), using the flag for the other data model is
-       * an error and will terminate the program.
-       */
-
-      { /* open new scope to declare local variables */
-        int i;
+    jvmpath[0] = '\0';
+    jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE);
+    if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
+        JLI_ReportErrorMessage(CFG_ERROR9);
+        exit(4);
+    }
 
-        newargv = (char **)JLI_MemAlloc((argc+1) * sizeof(char*));
-        newargv[newargc++] = argv[0];
-
-        /* scan for data model arguments and remove from argument list;
-           last occurrence determines desired data model */
-        for (i=1; i < argc; i++) {
-
-          if (JLI_StrCmp(argv[i], "-J-d64") == 0 || JLI_StrCmp(argv[i], "-d64") == 0) {
-            wanted = 64;
-            continue;
-          }
-          if (JLI_StrCmp(argv[i], "-J-d32") == 0 || JLI_StrCmp(argv[i], "-d32") == 0) {
-            wanted = 32;
-            continue;
-          }
-          newargv[newargc++] = argv[i];
+    if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) {
+        JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
+        exit(4);
+    }
+    /*
+     * we seem to have everything we need, so without further ado
+     * we return back, otherwise proceed to set the environment.
+     */
+#ifdef SETENV_REQUIRED
+    mustsetenv = RequiresSetenv(jvmpath);
+    JLI_TraceLauncher("mustsetenv: %s\n", mustsetenv ? "TRUE" : "FALSE");
 
-          if (IsJavaArgs()) {
-            if (argv[i][0] != '-') continue;
-          } else {
-            if (JLI_StrCmp(argv[i], "-classpath") == 0 || JLI_StrCmp(argv[i], "-cp") == 0) {
-              i++;
-              if (i >= argc) break;
-              newargv[newargc++] = argv[i];
-              continue;
-            }
-            if (argv[i][0] != '-') { i++; break; }
-          }
-        }
+    if (mustsetenv == JNI_FALSE) {
+        return;
+    }
+#else
+    return;
+#endif /* SETENV_REQUIRED */
 
-        /* copy rest of args [i .. argc) */
-        while (i < argc) {
-          newargv[newargc++] = argv[i++];
-        }
-        newargv[newargc] = NULL;
-
+#ifdef SETENV_REQUIRED
+    if (mustsetenv) {
         /*
-         * newargv has all proper arguments here
+         * We will set the LD_LIBRARY_PATH as follows:
+         *
+         *     o          $JVMPATH (directory portion only)
+         *     o          $JRE/lib
+         *     o          $JRE/../lib
+         *
+         * followed by the user's previous effective LD_LIBRARY_PATH, if
+         * any.
          */
 
-        argc = newargc;
-        argv = newargv;
-      }
-
-      /* If the data model is not changing, it is an error if the
-         jvmpath does not exist */
-      if (wanted == running) {
-        /* Find out where the JRE is that we will be using. */
-        if (!GetJREPath(jrepath, so_jrepath, JNI_FALSE) ) {
-          JLI_ReportErrorMessage(JRE_ERROR1);
-          exit(2);
-        }
-        JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%s%sjvm.cfg",
-                     jrepath, FILESEP, FILESEP, FILESEP);
-        /* Find the specified JVM type */
-        if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) {
-          JLI_ReportErrorMessage(CFG_ERROR7);
-          exit(1);
-        }
-
-        jvmpath[0] = '\0';
-        jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE);
-        if (JLI_StrCmp(jvmtype, "ERROR") == 0) {
-            JLI_ReportErrorMessage(CFG_ERROR9);
-            exit(4);
-        }
-
-        if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath, 0 )) {
-          JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath);
-          exit(4);
-        }
-        /*
-         * we seem to have everything we need, so without further ado
-         * we return back, otherwise proceed to set the environment.
-         */
-#ifdef SETENV_REQUIRED
-        mustsetenv = RequiresSetenv(jvmpath);
-        JLI_TraceLauncher("mustsetenv: %s\n", mustsetenv ? "TRUE" : "FALSE");
+        runpath = getenv(LD_LIBRARY_PATH);
 
-        if (mustsetenv == JNI_FALSE) {
-            JLI_MemFree(newargv);
-            return;
-        }
-#else
-        JLI_MemFree(newargv);
-        return;
-#endif /* SETENV_REQUIRED */
-      } else {  /* do the same speculatively or exit */
-        JLI_ReportErrorMessage(JRE_ERROR2, wanted);
-        exit(1);
-      }
-#ifdef SETENV_REQUIRED
-        if (mustsetenv) {
-            /*
-             * We will set the LD_LIBRARY_PATH as follows:
-             *
-             *     o          $JVMPATH (directory portion only)
-             *     o          $JRE/lib
-             *     o          $JRE/../lib
-             *
-             * followed by the user's previous effective LD_LIBRARY_PATH, if
-             * any.
-             */
+        /* runpath contains current effective LD_LIBRARY_PATH setting */
+        { /* New scope to declare local variable */
+            char *new_jvmpath = JLI_StringDup(jvmpath);
+            new_runpath_size = ((runpath != NULL) ? JLI_StrLen(runpath) : 0) +
+                    2 * JLI_StrLen(jrepath) +
+#ifdef AIX
+                    /* On AIX we additionally need 'jli' in the path because ld doesn't support $ORIGIN. */
+                    JLI_StrLen(jrepath) + JLI_StrLen("/lib//jli:") +
+#endif
+                    JLI_StrLen(new_jvmpath) + 52;
+            new_runpath = JLI_MemAlloc(new_runpath_size);
+            newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "=");
 
-#ifdef __solaris__
-            /*
-             * Starting in Solaris 7, ld.so.1 supports three LD_LIBRARY_PATH
-             * variables:
-             *
-             * 1. LD_LIBRARY_PATH -- used for 32 and 64 bit searches if
-             * data-model specific variables are not set.
-             *
-             * 2. LD_LIBRARY_PATH_64 -- overrides and replaces LD_LIBRARY_PATH
-             * for 64-bit binaries.
-             * The vm uses LD_LIBRARY_PATH to set the java.library.path system
-             * property.  To shield the vm from the complication of multiple
-             * LD_LIBRARY_PATH variables, if the appropriate data model
-             * specific variable is set, we will act as if LD_LIBRARY_PATH had
-             * the value of the data model specific variant and the data model
-             * specific variant will be unset.  Note that the variable for the
-             * *wanted* data model must be used (if it is set), not simply the
-             * current running data model.
-             */
-
-            switch (wanted) {
-                case 0:
-                case 64:
-                    dmpath = getenv("LD_LIBRARY_PATH_64");
-                    wanted = 64;
-                    break;
-
-                default:
-                    JLI_ReportErrorMessage(JRE_ERROR3, __LINE__);
-                    exit(1); /* unknown value in wanted */
-                    break;
-            }
 
             /*
-             * If dmpath is NULL, the relevant data model specific variable is
-             * not set and normal LD_LIBRARY_PATH should be used.
-             */
-            if (dmpath == NULL) {
-                runpath = getenv("LD_LIBRARY_PATH");
-            } else {
-                runpath = dmpath;
-            }
-#else /* ! __solaris__ */
-            /*
-             * If not on Solaris, assume only a single LD_LIBRARY_PATH
-             * variable.
+             * Create desired LD_LIBRARY_PATH value for target data model.
              */
-            runpath = getenv(LD_LIBRARY_PATH);
-#endif /* __solaris__ */
-
-            /* runpath contains current effective LD_LIBRARY_PATH setting */
-            { /* New scope to declare local variable */
-              char *new_jvmpath = JLI_StringDup(jvmpath);
-              new_runpath_size = ((runpath != NULL) ? JLI_StrLen(runpath) : 0) +
-                      2 * JLI_StrLen(jrepath) +
-#ifdef AIX
-                      /* On AIX we additionally need 'jli' in the path because ld doesn't support $ORIGIN. */
-                      JLI_StrLen(jrepath) + JLI_StrLen("/lib//jli:") +
-#endif
-                      JLI_StrLen(new_jvmpath) + 52;
-              new_runpath = JLI_MemAlloc(new_runpath_size);
-              newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "=");
-
-
-              /*
-               * Create desired LD_LIBRARY_PATH value for target data model.
-               */
-              {
+            {
                 /* remove the name of the .so from the JVM path */
                 lastslash = JLI_StrRChr(new_jvmpath, '/');
                 if (lastslash)
@@ -555,85 +417,66 @@
                  */
                 if (runpath != NULL &&
                         JLI_StrNCmp(newpath, runpath, JLI_StrLen(newpath)) == 0 &&
-                        (runpath[JLI_StrLen(newpath)] == 0 || runpath[JLI_StrLen(newpath)] == ':') &&
-                        (running == wanted) /* data model does not have to be changed */
-#ifdef __solaris__
-                        && (dmpath == NULL) /* data model specific variables not set  */
-#endif /* __solaris__ */
-                        ) {
-                    JLI_MemFree(newargv);
+                        (runpath[JLI_StrLen(newpath)] == 0 ||
+                        runpath[JLI_StrLen(newpath)] == ':')) {
                     JLI_MemFree(new_runpath);
                     return;
                 }
-              }
             }
+        }
 
-            /*
-             * Place the desired environment setting onto the prefix of
-             * LD_LIBRARY_PATH.  Note that this prevents any possible infinite
-             * loop of execv() because we test for the prefix, above.
-             */
-            if (runpath != 0) {
-                /* ensure storage for runpath + colon + NULL */
-                if ((JLI_StrLen(runpath) + 1 + 1) > new_runpath_size) {
-                    JLI_ReportErrorMessageSys(JRE_ERROR11);
-                    exit(1);
-                }
-                JLI_StrCat(new_runpath, ":");
-                JLI_StrCat(new_runpath, runpath);
+        /*
+         * Place the desired environment setting onto the prefix of
+         * LD_LIBRARY_PATH.  Note that this prevents any possible infinite
+         * loop of execv() because we test for the prefix, above.
+         */
+        if (runpath != 0) {
+            /* ensure storage for runpath + colon + NULL */
+            if ((JLI_StrLen(runpath) + 1 + 1) > new_runpath_size) {
+                JLI_ReportErrorMessageSys(JRE_ERROR11);
+                exit(1);
             }
-
-            if (putenv(new_runpath) != 0) {
-                exit(1); /* problem allocating memory; LD_LIBRARY_PATH not set
-                    properly */
-            }
+            JLI_StrCat(new_runpath, ":");
+            JLI_StrCat(new_runpath, runpath);
+        }
 
-            /*
-             * Unix systems document that they look at LD_LIBRARY_PATH only
-             * once at startup, so we have to re-exec the current executable
-             * to get the changed environment variable to have an effect.
-             */
+        if (putenv(new_runpath) != 0) {
+            /* problem allocating memory; LD_LIBRARY_PATH not set properly */
+            exit(1);
+        }
 
-#ifdef __solaris__
-            /*
-             * If dmpath is not NULL, remove the data model specific string
-             * in the environment for the exec'ed child.
-             */
-            if (dmpath != NULL)
-                (void)UnsetEnv("LD_LIBRARY_PATH_64");
-#endif /* __solaris */
+        /*
+         * Unix systems document that they look at LD_LIBRARY_PATH only
+         * once at startup, so we have to re-exec the current executable
+         * to get the changed environment variable to have an effect.
+         */
 
-            newenvp = environ;
-        }
+        newenvp = environ;
+    }
 #endif /* SETENV_REQUIRED */
-        {
-            char *newexec = execname;
-            JLI_TraceLauncher("TRACER_MARKER:About to EXEC\n");
-            (void) fflush(stdout);
-            (void) fflush(stderr);
+    {
+        char *newexec = execname;
+        JLI_TraceLauncher("TRACER_MARKER:About to EXEC\n");
+        (void) fflush(stdout);
+        (void) fflush(stderr);
 #ifdef SETENV_REQUIRED
-            if (mustsetenv) {
-                execve(newexec, argv, newenvp);
-            } else {
-                execv(newexec, argv);
-            }
+        if (mustsetenv) {
+            execve(newexec, argv, newenvp);
+        } else {
+            execv(newexec, argv);
+        }
 #else /* !SETENV_REQUIRED */
-            execv(newexec, argv);
+        execv(newexec, argv);
 #endif /* SETENV_REQUIRED */
-            JLI_ReportErrorMessageSys(JRE_ERROR4, newexec);
-        }
-        exit(1);
+        JLI_ReportErrorMessageSys(JRE_ERROR4, newexec);
     }
+    exit(1);
 }
 
-/*
- * On Solaris VM choosing is done by the launcher (java.c),
- * bitsWanted is used by MacOSX,  on Solaris and Linux this.
- * parameter is unused.
- */
+
 static jboolean
 GetJVMPath(const char *jrepath, const char *jvmtype,
-           char *jvmpath, jint jvmpathsize, int bitsWanted)
+           char *jvmpath, jint jvmpathsize)
 {
     struct stat s;
 
--- a/jdk/src/java.base/unix/native/libnet/Inet4AddressImpl.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libnet/Inet4AddressImpl.c	Wed Jul 05 23:37:13 2017 +0200
@@ -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];
+    jbyte caddr[4];
+    jint addr;
+    struct sockaddr_in sa;
 
-    char host[NI_MAXHOST+1];
-    int error = 0;
-    int len = 0;
-    jbyte caddr[4];
-
-    struct sockaddr_in him4;
-    struct sockaddr *sa;
-
-    jint addr;
+    // 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;
-      }
+        // 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");
+            }
+#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);
-          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;
+        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;
+                    }
+                }
             }
-
-            if (him->sin_addr.s_addr == 0) {
-              close(fd);
-              return JNI_TRUE;
-            }
-         }
-
-        }
-      } while (tmout2 > 0);
-      timeout -= 1000;
-    } while (timeout >0);
+        } 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.
-     */
-    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 *)&sa, 0, sizeof(SOCKETADDRESS));
+    sa.sa4.sin_addr.s_addr = htonl(addr);
+    sa.sa4.sin_family = AF_INET;
 
-    /*
-     * 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));
+    // 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);
+        memset((char *)&inf, 0, sizeof(SOCKETADDRESS));
+        inf.sa4.sin_addr.s_addr = htonl(addr);
+        inf.sa4.sin_family = AF_INET;
+        netif = &inf;
     }
 
-    /*
-     * 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;
+    // 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) {
+        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);
     }
 }
--- a/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libnet/Inet6AddressImpl.c	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
+    setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
 
-    /* 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;
-      }
+        if (bind(fd, &netif->sa, sizeof(struct sockaddr_in6)) <0) {
+            NET_ThrowNew(env, errno, "Can't bind socket");
+            close(fd);
+            return JNI_FALSE;
+        }
     }
+
+    // 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 {
-      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;
-      }
+        // 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);
-          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;
+        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;
+                    }
+                }
             }
-            if (NET_IsZeroAddr(caddr)) {
-              close(fd);
-              return JNI_TRUE;
-            }
-          }
-        }
-      } while (tmout2 > 0);
-      timeout -= 1000;
+        } 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;
-    }
-    /*
-     * 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 JNI_FALSE;
     }
 
-    memset((void *) caddr, 0, 16);
-    memset((void *) &him6, 0, sizeof(him6));
-    (*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);
+    // 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);
     }
 
-    /* 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));
+    // load address to SOCKETADDRESS
+    memset((char *)caddr, 0, 16);
+    (*env)->GetByteArrayRegion(env, addrArray, 0, 16, caddr);
+    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 {
+        sa.sa6.sin6_scope_id = getDefaultIPv6Interface(&sa.sa6.sin6_addr);
+#endif
     }
 
-    /*
-     * 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;
-      }
+    // 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;
     }
-    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;
-    } 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;
+    // 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);
     }
 }
--- a/jdk/src/java.base/unix/native/libnet/NetworkInterface.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libnet/NetworkInterface.c	Wed Jul 05 23:37:13 2017 +0200
@@ -361,7 +361,11 @@
                         ((struct sockaddr_in6*)addrP->addr)->sin6_addr);
                     jbyte caddr[16];
                     int i;
+                    unsigned int scopeid;
                     getInet6Address_ipaddress(env, iaObj, (char *)caddr);
+                    scopeid = (unsigned int)getInet6Address_scopeid(env, iaObj);
+                    if (scopeid != 0 && scopeid != ((struct sockaddr_in6*)addrP->addr)->sin6_scope_id)
+                        break;
                     i = 0;
                     while (i < 16) {
                         if (caddr[i] != bytes[i]) {
--- a/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libnet/PlainDatagramSocketImpl.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -485,7 +485,7 @@
         return -1;
     }
     if (timeout) {
-        int ret = NET_Timeout(fd, timeout);
+        int ret = NET_Timeout(env, fd, timeout, JVM_NanoTime(env, 0));
         if (ret == 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Peek timed out");
@@ -576,7 +576,7 @@
     packetBufferOffset = (*env)->GetIntField(env, packet, dp_offsetID);
     packetBufferLen = (*env)->GetIntField(env, packet, dp_bufLengthID);
     if (timeout) {
-        int ret = NET_Timeout(fd, timeout);
+        int ret = NET_Timeout(env, fd, timeout, JVM_NanoTime(env, 0));
         if (ret == 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
                             "Receive timed out");
@@ -789,7 +789,7 @@
         retry = JNI_FALSE;
 
         if (timeout) {
-            int ret = NET_Timeout(fd, timeout);
+            int ret = NET_Timeout(env, fd, timeout, JVM_NanoTime(env, 0));
             if (ret <= 0) {
                 if (ret == 0) {
                     JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
--- a/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libnet/PlainSocketImpl.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,6 +24,7 @@
  */
 #include <errno.h>
 
+#include "jvm.h"
 #include "net_util.h"
 
 #include "java_net_SocketOptions.h"
@@ -231,7 +232,6 @@
 {
     jint localport = (*env)->GetIntField(env, this, psi_localportID);
     int len = 0;
-
     /* fdObj is the FileDescriptor field on this */
     jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
 
@@ -325,7 +325,8 @@
         /* connection not established immediately */
         if (connect_rv != 0) {
             socklen_t optlen;
-            jlong prevTime = JVM_CurrentTimeMillis(env, 0);
+            jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
+            jlong prevNanoTime = JVM_NanoTime(env, 0);
 
             if (errno != EINPROGRESS) {
                 NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
@@ -341,13 +342,13 @@
              * this thread.
              */
             while (1) {
-                jlong newTime;
+                jlong newNanoTime;
                 struct pollfd pfd;
                 pfd.fd = fd;
                 pfd.events = POLLOUT;
 
                 errno = 0;
-                connect_rv = NET_Poll(&pfd, 1, timeout);
+                connect_rv = NET_Poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
 
                 if (connect_rv >= 0) {
                     break;
@@ -360,13 +361,13 @@
                  * The poll was interrupted so adjust timeout and
                  * restart
                  */
-                newTime = JVM_CurrentTimeMillis(env, 0);
-                timeout -= (newTime - prevTime);
-                if (timeout <= 0) {
+                newNanoTime = JVM_NanoTime(env, 0);
+                nanoTimeout -= (newNanoTime - prevNanoTime);
+                if (nanoTimeout < NET_NSEC_PER_MSEC) {
                     connect_rv = 0;
                     break;
                 }
-                prevTime = newTime;
+                prevNanoTime = newNanoTime;
 
             } /* while */
 
@@ -593,7 +594,8 @@
     /* fields on this */
     int port;
     jint timeout = (*env)->GetIntField(env, this, psi_timeoutID);
-    jlong prevTime = 0;
+    jlong prevNanoTime = 0;
+    jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
     jobject fdObj = (*env)->GetObjectField(env, this, psi_fdID);
 
     /* the FileDescriptor field on socket */
@@ -633,18 +635,19 @@
      */
     for (;;) {
         int ret;
+        jlong currNanoTime;
 
         /* first usage pick up current time */
-        if (prevTime == 0 && timeout > 0) {
-            prevTime = JVM_CurrentTimeMillis(env, 0);
+        if (prevNanoTime == 0 && nanoTimeout > 0) {
+            prevNanoTime = JVM_NanoTime(env, 0);
         }
 
         /* passing a timeout of 0 to poll will return immediately,
            but in the case of ServerSocket 0 means infinite. */
         if (timeout <= 0) {
-            ret = NET_Timeout(fd, -1);
+            ret = NET_Timeout(env, fd, -1, 0);
         } else {
-            ret = NET_Timeout(fd, timeout);
+            ret = NET_Timeout(env, fd, nanoTimeout / NET_NSEC_PER_MSEC, prevNanoTime);
         }
         if (ret == 0) {
             JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
@@ -676,17 +679,14 @@
         }
 
         /* ECONNABORTED or EWOULDBLOCK error so adjust timeout if there is one. */
-        if (timeout) {
-            jlong currTime = JVM_CurrentTimeMillis(env, 0);
-            timeout -= (currTime - prevTime);
-
-            if (timeout <= 0) {
-                JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
-                                "Accept timed out");
-                return;
-            }
-            prevTime = currTime;
+        currNanoTime = JVM_NanoTime(env, 0);
+        nanoTimeout -= (currNanoTime - prevNanoTime);
+        if (nanoTimeout < NET_NSEC_PER_MSEC) {
+            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketTimeoutException",
+                    "Accept timed out");
+            return;
         }
+        prevNanoTime = currNanoTime;
     }
 
     if (newfd < 0) {
--- a/jdk/src/java.base/unix/native/libnet/SocketInputStream.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libnet/SocketInputStream.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "jvm.h"
 #include "net_util.h"
 
 #include "java_net_SocketInputStream.h"
@@ -48,9 +49,10 @@
 
 static int NET_ReadWithTimeout(JNIEnv *env, int fd, char *bufP, int len, long timeout) {
     int result = 0;
-    long prevtime = NET_GetCurrentTime(), newtime;
-    while (timeout > 0) {
-        result = NET_TimeoutWithCurrentTime(fd, timeout, prevtime);
+    jlong prevNanoTime = JVM_NanoTime(env, 0);
+    jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
+    while (nanoTimeout >= NET_NSEC_PER_MSEC) {
+        result = NET_Timeout(env, fd, nanoTimeout / NET_NSEC_PER_MSEC, prevNanoTime);
         if (result <= 0) {
             if (result == 0) {
                 JNU_ThrowByName(env, "java/net/SocketTimeoutException", "Read timed out");
@@ -68,10 +70,10 @@
         }
         result = NET_NonBlockingRead(fd, bufP, len);
         if (result == -1 && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) {
-            newtime = NET_GetCurrentTime();
-            timeout -= newtime - prevtime;
-            if (timeout > 0) {
-                prevtime = newtime;
+            jlong newtNanoTime = JVM_NanoTime(env, 0);
+            nanoTimeout -= newtNanoTime - prevNanoTime;
+            if (nanoTimeout >= NET_NSEC_PER_MSEC) {
+                prevNanoTime = newtNanoTime;
             }
         } else {
             break;
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,6 +49,7 @@
 #include <sys/sysctl.h>
 #endif
 
+#include "jvm.h"
 #include "net_util.h"
 
 #include "java_net_SocketOptions.h"
@@ -1543,11 +1544,12 @@
 jint
 NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout)
 {
-    jlong prevTime = JVM_CurrentTimeMillis(env, 0);
+    jlong prevNanoTime = JVM_NanoTime(env, 0);
+    jlong nanoTimeout = (jlong) timeout * NET_NSEC_PER_MSEC;
     jint read_rv;
 
     while (1) {
-        jlong newTime;
+        jlong newNanoTime;
         struct pollfd pfd;
         pfd.fd = fd;
         pfd.events = 0;
@@ -1559,36 +1561,18 @@
           pfd.events |= POLLOUT;
 
         errno = 0;
-        read_rv = NET_Poll(&pfd, 1, timeout);
+        read_rv = NET_Poll(&pfd, 1, nanoTimeout / NET_NSEC_PER_MSEC);
 
-        newTime = JVM_CurrentTimeMillis(env, 0);
-        timeout -= (newTime - prevTime);
-        if (timeout <= 0) {
+        newNanoTime = JVM_NanoTime(env, 0);
+        nanoTimeout -= (newNanoTime - prevNanoTime);
+        if (nanoTimeout < NET_NSEC_PER_MSEC) {
           return read_rv > 0 ? 0 : -1;
         }
-        prevTime = newTime;
+        prevNanoTime = newNanoTime;
 
         if (read_rv > 0) {
           break;
         }
-
-
       } /* while */
-
-    return timeout;
+    return (nanoTimeout / NET_NSEC_PER_MSEC);
 }
-
-long NET_GetCurrentTime() {
-    struct timeval time;
-    gettimeofday(&time, NULL);
-    return (time.tv_sec * 1000 + time.tv_usec / 1000);
-}
-
-int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime) {
-    return NET_Timeout0(s, timeout, currentTime);
-}
-
-int NET_Timeout(int s, long timeout) {
-    long currentTime = (timeout > 0) ? NET_GetCurrentTime() : 0;
-    return NET_Timeout0(s, timeout, currentTime);
-}
--- a/jdk/src/java.base/unix/native/libnet/net_util_md.h	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libnet/net_util_md.h	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,10 @@
  * Macros and constants
  */
 
+#define NET_NSEC_PER_MSEC 1000000
+#define NET_NSEC_PER_SEC  1000000000
+#define NET_NSEC_PER_USEC 1000
+
 /* Defines SO_REUSEPORT */
 #ifndef SO_REUSEPORT
 #ifdef __linux__
@@ -68,12 +72,9 @@
  * Functions
  */
 
-int NET_Timeout(int s, long timeout);
-int NET_Timeout0(int s, long timeout, long currentTime);
+int NET_Timeout(JNIEnv *env, int s, long timeout, jlong  nanoTimeStamp);
 int NET_Read(int s, void* buf, size_t len);
 int NET_NonBlockingRead(int s, void* buf, size_t len);
-int NET_TimeoutWithCurrentTime(int s, long timeout, long currentTime);
-long NET_GetCurrentTime();
 int NET_RecvFrom(int s, void *buf, int len, unsigned int flags,
                  struct sockaddr *from, socklen_t *fromlen);
 int NET_ReadV(int s, const struct iovec * vector, int count);
--- a/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libnio/ch/DatagramChannelImpl.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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);
--- a/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libnio/ch/InheritedChannel.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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 */
--- a/jdk/src/java.base/unix/native/libnio/ch/Net.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/unix/native/libnio/ch/Net.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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
 }
 
--- a/jdk/src/java.base/windows/native/libjava/WinNTFileSystem_md.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/windows/native/libjava/WinNTFileSystem_md.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -472,7 +472,7 @@
                                                  jobject file)
 {
     jlong rv = 0;
-    LARGE_INTEGER modTime;
+    ULARGE_INTEGER modTime;
     FILETIME t;
     HANDLE h;
     WCHAR *pathbuf = fileToNTPath(env, file, ids.path);
@@ -784,7 +784,7 @@
                     FILE_FLAG_BACKUP_SEMANTICS,
                     0);
     if (h != INVALID_HANDLE_VALUE) {
-        LARGE_INTEGER modTime;
+        ULARGE_INTEGER modTime;
         FILETIME t;
         modTime.QuadPart = (time + 11644473600000L) * 10000L;
         t.dwLowDateTime = (DWORD)modTime.LowPart;
--- a/jdk/src/java.base/windows/native/libjli/java_md.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/windows/native/libjli/java_md.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -158,32 +158,10 @@
                            char *jrepath, jint so_jrepath,
                            char *jvmpath, jint so_jvmpath,
                            char *jvmcfg,  jint so_jvmcfg) {
-    char * jvmtype;
+
+    char *jvmtype;
     int i = 0;
-    int running = CURRENT_DATA_MODEL;
-
-    int wanted = running;
-
     char** argv = *pargv;
-    for (i = 1; i < *pargc ; i++) {
-        if (JLI_StrCmp(argv[i], "-J-d64") == 0 || JLI_StrCmp(argv[i], "-d64") == 0) {
-            wanted = 64;
-            continue;
-        }
-        if (JLI_StrCmp(argv[i], "-J-d32") == 0 || JLI_StrCmp(argv[i], "-d32") == 0) {
-            wanted = 32;
-            continue;
-        }
-
-        if (IsJavaArgs() && argv[i][0] != '-')
-            continue;
-        if (argv[i][0] != '-')
-            break;
-    }
-    if (running != wanted) {
-        JLI_ReportErrorMessage(JRE_ERROR2, wanted);
-        exit(1);
-    }
 
     /* Find out where the JRE is that we will be using. */
     if (!GetJREPath(jrepath, so_jrepath)) {
--- a/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/windows/native/libnet/Inet4AddressImpl.c	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
+    int connect_rv = -1;
     WSAEVENT hEvent;
-    int connect_rv = -1;
-    int sz;
 
-    /**
-     * 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 */
-            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;
+    }
+
+    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 (WSAGetLastError() != WSAEWOULDBLOCK) {
-            NET_ThrowByNameWithLastError(env, JNU_JAVANETPKG "ConnectException",
-                                         "connect failed");
+        if (connect_rv == 0 || connect_rv == WSAECONNREFUSED) {
             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));
+
+    // convert IP address from byte array to integer
+    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);
+    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 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);
     }
 }
-
--- a/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/windows/native/libnet/Inet6AddressImpl.c	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
+    int connect_rv = -1;
     WSAEVENT hEvent;
-    int connect_rv = -1;
 
+    // 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;
-        }
+    }
 
-        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);
+    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 (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) {
+    if (dwRetVal == 0) { // if the call failed
+        return JNI_FALSE;
+    } else {
         return JNI_TRUE;
-    } else {
-        return JNI_FALSE;
     }
 }
 
@@ -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;
-    }
-    len = sizeof(struct sockaddr_in6);
-
-    /**
-     * A network interface was specified, let's convert the address
-     */
-    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;
+        sa.sa6.sin6_scope_id = scope;
     }
 
+    // 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;
+    }
+
+    // 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;
 }
--- a/jdk/src/java.base/windows/native/libnio/ch/Net.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.base/windows/native/libnio/ch/Net.c	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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;
--- a/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnector.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1258,7 +1258,7 @@
                     + ", listener=" + listener);
 
             final Integer[] ret =
-                    rmiNotifClient.removeNotificationListener(name, listener);
+                    rmiNotifClient.getListenerIds(name, listener);
 
             if (debug) logger.debug("removeNotificationListener",
                     "listenerIDs=" + objects(ret));
@@ -1278,7 +1278,7 @@
             } finally {
                 popDefaultClassLoader(old);
             }
-
+            rmiNotifClient.removeNotificationListener(name, listener);
         }
 
         public void removeNotificationListener(ObjectName name,
@@ -1300,7 +1300,7 @@
                         + ", handback=" + handback);
 
             final Integer ret =
-                    rmiNotifClient.removeNotificationListener(name, listener,
+                    rmiNotifClient.getListenerId(name, listener,
                     filter, handback);
 
             if (debug) logger.debug("removeNotificationListener",
@@ -1320,7 +1320,8 @@
             } finally {
                 popDefaultClassLoader(old);
             }
-
+            rmiNotifClient.removeNotificationListener(name, listener,
+                    filter, handback);
         }
     }
 
--- a/jdk/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.management/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -188,6 +188,53 @@
     }
 
     public synchronized Integer[]
+    getListenerIds(ObjectName name,
+                   NotificationListener listener)
+            throws ListenerNotFoundException, IOException {
+
+        List<Integer> ids = new ArrayList<Integer>();
+        List<ClientListenerInfo> values =
+                new ArrayList<ClientListenerInfo>(infoList.values());
+        for (int i=values.size()-1; i>=0; i--) {
+            ClientListenerInfo li = values.get(i);
+
+            if (li.sameAs(name, listener)) {
+                ids.add(li.getListenerID());
+            }
+        }
+
+        if (ids.isEmpty())
+            throw new ListenerNotFoundException("Listener not found");
+
+        return ids.toArray(new Integer[0]);
+    }
+
+    public synchronized Integer
+    getListenerId(ObjectName name,
+                   NotificationListener listener,
+                   NotificationFilter filter,
+                   Object handback)
+            throws ListenerNotFoundException, IOException {
+
+        Integer id = null;
+
+        List<ClientListenerInfo> values =
+                new ArrayList<ClientListenerInfo>(infoList.values());
+        for (int i=values.size()-1; i>=0; i--) {
+            ClientListenerInfo li = values.get(i);
+            if (li.sameAs(name, listener, filter, handback)) {
+                id=li.getListenerID();
+                break;
+            }
+        }
+
+        if (id == null)
+            throw new ListenerNotFoundException("Listener not found");
+
+        return id;
+    }
+
+    public synchronized Integer[]
         removeNotificationListener(ObjectName name,
                                    NotificationListener listener)
         throws ListenerNotFoundException, IOException {
@@ -198,24 +245,12 @@
             logger.trace("removeNotificationListener",
                          "Remove the listener "+listener+" from "+name);
         }
-
-        List<Integer> ids = new ArrayList<Integer>();
-        List<ClientListenerInfo> values =
-                new ArrayList<ClientListenerInfo>(infoList.values());
-        for (int i=values.size()-1; i>=0; i--) {
-            ClientListenerInfo li = values.get(i);
-
-            if (li.sameAs(name, listener)) {
-                ids.add(li.getListenerID());
-
-                infoList.remove(li.getListenerID());
-            }
+        Integer[] liIds = getListenerIds(name, listener);
+        for (int i = 0; i < liIds.length; i++) {
+            infoList.remove(liIds[i]);
         }
 
-        if (ids.isEmpty())
-            throw new ListenerNotFoundException("Listener not found");
-
-        return ids.toArray(new Integer[0]);
+        return liIds;
     }
 
     public synchronized Integer
@@ -231,26 +266,11 @@
         }
 
         beforeRemove();
-
-        Integer id = null;
-
-        List<ClientListenerInfo> values =
-                new ArrayList<ClientListenerInfo>(infoList.values());
-        for (int i=values.size()-1; i>=0; i--) {
-            ClientListenerInfo li = values.get(i);
-            if (li.sameAs(name, listener, filter, handback)) {
-                id=li.getListenerID();
+        Integer liId = getListenerId(name, listener,
+                filter, handback);
+        infoList.remove(liId);
 
-                infoList.remove(id);
-
-                break;
-            }
-        }
-
-        if (id == null)
-            throw new ListenerNotFoundException("Listener not found");
-
-        return id;
+        return liId;
     }
 
     public synchronized Integer[] removeNotificationListener(ObjectName name) {
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/Config.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/Config.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
                             }
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbAsRep.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbAsRep.java	Wed Jul 05 23:37:13 2017 +0200
@@ -160,7 +160,7 @@
         creds = new Credentials(
                                 rep.ticket,
                                 req.reqBody.cname,
-                                rep.ticket.sname,
+                                enc_part.sname,
                                 enc_part.key,
                                 enc_part.flags,
                                 enc_part.authtime,
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbTgsRep.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbTgsRep.java	Wed Jul 05 23:37:13 2017 +0200
@@ -88,7 +88,7 @@
 
         this.creds = new Credentials(rep.ticket,
                                 rep.cname,
-                                rep.ticket.sname,
+                                enc_part.sname,
                                 enc_part.key,
                                 enc_part.flags,
                                 enc_part.authtime,
--- a/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/jdk.crypto.mscapi/windows/classes/sun/security/mscapi/KeyStore.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -513,7 +513,7 @@
         if (entry != null) {
             // Get end-entity certificate and remove from system cert store
             X509Certificate[] certChain = entry.getCertificateChain();
-            if (certChain != null) {
+            if (certChain != null && certChain.length > 0) {
 
                 try {
 
@@ -629,7 +629,9 @@
 
         for (Map.Entry<String,KeyEntry> mapEntry : entries.entrySet()) {
             KeyEntry entry = mapEntry.getValue();
-            if (entry.certChain != null && entry.certChain[0].equals(cert)) {
+            if (entry.certChain != null &&
+                entry.certChain.length > 0 &&
+                entry.certChain[0].equals(cert)) {
                 return entry.getAlias();
             }
         }
--- a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/LeftOverInputStream.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/LeftOverInputStream.java	Wed Jul 05 23:37:13 2017 +0200
@@ -41,8 +41,8 @@
  * isEOF() returns true, when all expected bytes have been read
  */
 abstract class LeftOverInputStream extends FilterInputStream {
-    ExchangeImpl t;
-    ServerImpl server;
+    final ExchangeImpl t;
+    final ServerImpl server;
     protected boolean closed = false;
     protected boolean eof = false;
     byte[] one = new byte [1];
@@ -109,6 +109,9 @@
         int bufSize = 2048;
         byte[] db = new byte [bufSize];
         while (l > 0) {
+            if (server.isFinishing()) {
+                break;
+            }
             long len = readImpl (db, 0, bufSize);
             if (len == -1) {
                 eof = true;
--- a/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/jdk.httpserver/share/classes/sun/net/httpserver/ServerImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -179,6 +179,10 @@
         return httpsConfig;
     }
 
+    public final boolean isFinishing() {
+        return finished;
+    }
+
     public void stop (int delay) {
         if (delay < 0) {
             throw new IllegalArgumentException ("negative delay parameter");
--- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java	Wed Jul 05 23:37:13 2017 +0200
@@ -264,9 +264,8 @@
     }
 
     public boolean previousSnippet() {
-        for (int i = index() - 1; i >= 0; i--) {
-            if (get(i) instanceof NarrowingHistoryLine) {
-                moveTo(i);
+        while (previous()) {
+            if (current() instanceof NarrowingHistoryLine) {
                 return true;
             }
         }
@@ -275,19 +274,17 @@
     }
 
     public boolean nextSnippet() {
-        for (int i = index() + 1; i < size(); i++) {
-            if (get(i) instanceof NarrowingHistoryLine) {
-                moveTo(i);
+        boolean success = false;
+
+        while (next()) {
+            success = true;
+
+            if (current() instanceof NarrowingHistoryLine) {
                 return true;
             }
         }
 
-        if (index() < size()) {
-            moveToEnd();
-            return true;
-        }
-
-        return false;
+        return success;
     }
 
     public final void load(Iterable<? extends String> originalHistory) {
--- a/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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 {
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/util.c	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/util.c	Wed Jul 05 23:37:13 2017 +0200
@@ -2421,7 +2421,6 @@
     /* Check data structure */
     data = (ClassInstancesData*)user_data;
     if (data == NULL) {
-        data->error = AGENT_ERROR_ILLEGAL_ARGUMENT;
         return JVMTI_VISIT_ABORT;
     }
 
@@ -2540,7 +2539,6 @@
     /* Check data structure */
     data = (ClassCountData*)user_data;
     if (data == NULL) {
-        data->error = AGENT_ERROR_ILLEGAL_ARGUMENT;
         return JVMTI_VISIT_ABORT;
     }
 
@@ -2598,7 +2596,6 @@
     /* Check data structure */
     data = (ClassCountData*)user_data;
     if (data == NULL) {
-        data->error = AGENT_ERROR_ILLEGAL_ARGUMENT;
         return JVMTI_VISIT_ABORT;
     }
 
@@ -2757,7 +2754,6 @@
     /* Check data structure */
     data = (ReferrerData*)user_data;
     if (data == NULL) {
-        data->error = AGENT_ERROR_ILLEGAL_ARGUMENT;
         return JVMTI_VISIT_ABORT;
     }
 
--- a/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -872,7 +872,7 @@
     public final boolean compareAndSwapObject(Object o, long offset,
                                               Object expected,
                                               Object x) {
-        return theInternalUnsafe.compareAndSwapObject(o, offset, expected, x);
+        return theInternalUnsafe.compareAndSetObject(o, offset, expected, x);
     }
 
     /**
@@ -888,7 +888,7 @@
     public final boolean compareAndSwapInt(Object o, long offset,
                                            int expected,
                                            int x) {
-        return theInternalUnsafe.compareAndSwapInt(o, offset, expected, x);
+        return theInternalUnsafe.compareAndSetInt(o, offset, expected, x);
     }
 
     /**
@@ -904,7 +904,7 @@
     public final boolean compareAndSwapLong(Object o, long offset,
                                             long expected,
                                             long x) {
-        return theInternalUnsafe.compareAndSwapLong(o, offset, expected, x);
+        return theInternalUnsafe.compareAndSetLong(o, offset, expected, x);
     }
 
     /**
--- a/jdk/test/ProblemList.txt	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/ProblemList.txt	Wed Jul 05 23:37:13 2017 +0200
@@ -99,9 +99,8 @@
 #  1. Make sure test passes on all platforms with samevm, or mark it othervm
 #  2. Make sure test passes on all platforms when run with it's entire group
 #  3. Make sure both VMs are tested, -server and -client, if possible
-#  4. Make sure you try the -d64 option on Solaris
-#  5. Use a tool like JPRT or something to verify these results
-#  6. Delete lines in this file, include the changes with your test changes
+#  4. Use a tool like JPRT or something to verify these results
+#  5. Delete lines in this file, include the changes with your test changes
 #
 # You may need to repeat your testing 2 or even 3 times to verify good
 #   results, some of these samevm failures are not very predictable.
@@ -143,6 +142,8 @@
 
 # jdk_io
 
+java/io/pathNames/GeneralWin32.java                             8180264 windows-all
+
 ############################################################################
 
 # jdk_management
@@ -211,6 +212,8 @@
 javax/net/ssl/DTLS/PacketLossRetransmission.java                8169086 macosx-x64
 javax/net/ssl/DTLS/RespondToRetransmit.java                     8169086 macosx-x64
 
+sun/security/krb5/auto/UnboundSSL.java                          8180265 windows-all
+sun/security/provider/KeyStore/DKSTest.sh                       8180266 windows-all
 sun/security/ssl/X509KeyManager/PreferredKey.java               8176354 generic-all
 
 ############################################################################
@@ -259,6 +262,9 @@
 tools/jimage/JImageListTest.java                                8170120 generic-all
 tools/jimage/JImageVerifyTest.java                              8170120 generic-all
 
+tools/schemagen/MultiReleaseJarTest.java                        8174692 generic-all
+tools/wsgen/MultiReleaseJarTest.java                            8174692 generic-all
+
 ############################################################################
 
 # jdk_jdi
--- a/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 7130985
  * @summary Four helper classes missing in Sun JDK
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @build jdk.testlibrary.*
  * @modules java.corba
  * @run main CorbaExceptionsCompileTest
@@ -35,12 +35,12 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.rmi.RemoteException;
+
 import org.omg.CORBA.ORBPackage.InvalidName;
 import org.omg.CORBA.TypeCodePackage.BadKind;
 import org.omg.CORBA.TypeCodePackage.Bounds;
 
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 import jdk.testlibrary.JDKToolLauncher;
 
 public class CorbaExceptionsCompileTest implements CorbaExceptionsTest {
--- a/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CipherNCFuncTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CipherNCFuncTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2015, 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
@@ -20,20 +20,22 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
 /*
  * @test
  * @bug 8048604
- * @library ../ /lib/testlibrary
+ * @library ../ /test/lib
  * @summary This test verifies the assertion "There should be no transformation
- *  on the plaintext/ciphertext in encryption/decryption mechanism" for
- *  feature "NullCipher".
+ *          on the plaintext/ciphertext in encryption/decryption mechanism" for
+ *          feature "NullCipher".
  */
+
 import javax.crypto.BadPaddingException;
 import javax.crypto.Cipher;
 import javax.crypto.IllegalBlockSizeException;
 import javax.crypto.NullCipher;
 import javax.crypto.ShortBufferException;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class CipherNCFuncTest {
     public static void main(String[] args) throws ShortBufferException,
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,7 +62,7 @@
             ProcessBuilder pb = ProcessTools.
                 createJavaProcessBuilder(
                     "--add-exports", "jdk.attach/sun.tools.attach=ALL-UNNAMED",
-                    "-XX:+UseConcMarkSweepGC",  // this will cause UseParNewGC to be FLAG_SET_ERGO
+                    "-XX:+UseConcMarkSweepGC",  // this will cause MaxNewSize to be FLAG_SET_ERGO
                     "-XX:+UseCodeAging",
                     "-XX:+UseCerealGC",         // Should be ignored.
                     "-XX:Flags=" + flagsFile.getAbsolutePath(),
@@ -110,7 +110,7 @@
             // Set through j.l.m
             checkOrigin("HeapDumpOnOutOfMemoryError", Origin.MANAGEMENT);
             // Should be set by the VM, when we set UseConcMarkSweepGC
-            checkOrigin("UseParNewGC", Origin.ERGONOMIC);
+            checkOrigin("MaxNewSize", Origin.ERGONOMIC);
             // Set using attach
             checkOrigin("HeapDumpPath", Origin.ATTACH_ON_DEMAND);
         }
--- a/jdk/test/java/awt/JAWT/JAWT.sh	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/awt/JAWT/JAWT.sh	Wed Jul 05 23:37:13 2017 +0200
@@ -85,7 +85,7 @@
     MAKEFILE="Makefile.win"
     CC="cl"
 	MAKE="nmake"
-	${TESTJAVA}${FS}bin${FS}java -d64 -version 2>&1 | grep '64-Bit' > $NULL
+	${TESTJAVA}${FS}bin${FS}java -version 2>&1 | grep '64-Bit' > $NULL
     if [ "$?" -eq '0' ]
     then
         ARCH="amd64"
@@ -100,7 +100,7 @@
     FS="/"
     MAKEFILE="Makefile.cygwin"
     CC="gcc"
-	${TESTJAVA}${FS}bin${FS}java -d64 -version 2>&1 | grep '64-Bit' > $NULL
+	${TESTJAVA}${FS}bin${FS}java -version 2>&1 | grep '64-Bit' > $NULL
     if [ "$?" -eq '0' ]
     then
         ARCH="amd64"
--- a/jdk/test/java/io/File/SetLastModified.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/io/File/SetLastModified.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
  */
 
 /* @test
-   @bug 4091757 6652379
+   @bug 4091757 6652379 8177809
    @summary Basic test for setLastModified method
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/File/createTempFile/SecurityTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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.
+ *
+ * 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 4138064
+ * @build SecurityTest
+ * @run main/othervm/policy=java.policy SecurityTest
+ */
+
+import java.io.File;
+
+public class SecurityTest {
+
+    public static void main(String[] args) throws Exception {
+        try {
+            File f = File.createTempFile("foo", null);
+        } catch (java.security.AccessControlException x) {
+            throw x;
+        } catch (SecurityException x) {
+            if (x.getMessage().equals("Unable to create temporary file")) {
+                return;
+            }
+            throw x;
+        }
+        throw new Exception("SecurityException not thrown");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/File/createTempFile/java.policy	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,2 @@
+grant {
+};
--- a/jdk/test/java/io/FilePermission/ReadFileOnPath.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/io/FilePermission/ReadFileOnPath.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
  */
 
 import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import java.nio.file.Files;
 import java.nio.file.Path;
--- a/jdk/test/java/io/InputStream/ReadAllBytes.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/io/InputStream/ReadAllBytes.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,13 +27,12 @@
 import java.io.InputStream;
 import java.util.Arrays;
 import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /*
  * @test
  * @bug 8080835
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main ReadAllBytes
  * @summary Basic test for InputStream.readAllBytes
  * @key randomness
--- a/jdk/test/java/io/InputStream/ReadNBytes.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/io/InputStream/ReadNBytes.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,13 +27,12 @@
 import java.io.InputStream;
 import java.util.Arrays;
 import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /*
  * @test
  * @bug 8080835
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main ReadNBytes
  * @summary Basic test for InputStream.readNBytes
  * @key randomness
--- a/jdk/test/java/io/Serializable/class/NonSerialA_1.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-public class A {
-    int field1;
-};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/NonSerialA_1/A.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+public class A {
+    int field1;
+};
--- a/jdk/test/java/io/Serializable/class/NonSerialA_2.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-public class A {
-    int field1;
-    int field2;
-};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/NonSerialA_2/A.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+public class A {
+    int field1;
+    int field2;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/NonSerializableTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,105 @@
+/*
+ * 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 4075221
+ * @library /test/lib
+ * @build jdk.test.lib.compiler.*
+ * @build jdk.test.lib.process.*
+ * @run testng/timeout=300 NonSerializableTest
+ * @summary Enable serialize of nonSerializable Class descriptor.
+ */
+
+import java.nio.file.Paths;
+import java.util.Arrays;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+
+import jdk.test.lib.compiler.CompilerUtils;
+import jdk.test.lib.process.ProcessTools;
+
+
+public class NonSerializableTest {
+
+    @BeforeClass
+    public void setup() throws Exception {
+        boolean b = CompilerUtils.compile(
+                Paths.get(System.getProperty("test.src"), "TestEntry.java"),
+                Paths.get(System.getProperty("user.dir")));
+        assertTrue(b, "Compilation failed");
+    }
+
+    @DataProvider
+    public Object[][] provider() {
+        return new String[][][] {
+            // Write NonSerial1, Read NonSerial1
+            {{"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"NonSerialA_1", "-cp", ".", "TestEntry", "-d"}},
+
+            // Write NonSerial1, Read NonSerial2
+            {{"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"NonSerialA_2", "-cp", ".", "TestEntry", "-d"}},
+
+            // Write NonSerial1, Read Serial1
+            {{"NonSerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"SerialA_1", "-cp", ".", "TestEntry", "-d"}},
+
+            // Write Serial1, Read NonSerial1
+            {{"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"NonSerialA_1", "-cp", ".", "TestEntry", "-doe"}},
+
+            // Write Serial1, Read Serial2
+            {{"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"SerialA_2", "-cp", ".", "TestEntry", "-d"}},
+
+            // Write Serial2, Read Serial1
+            {{"SerialA_2", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"SerialA_1", "-cp", ".", "TestEntry", "-d"}},
+
+            // Write Serial1, Read Serial3
+            {{"SerialA_1", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"SerialA_3", "-cp", ".", "TestEntry", "-de"}},
+
+            // Write Serial3, Read Serial1
+            {{"SerialA_3", "-cp", ".", "TestEntry", "-s", "A"}},
+            {{"SerialA_1", "-cp", ".", "TestEntry", "-de"}},
+        };
+    }
+
+    @Test(dataProvider="provider")
+    public void test(String[] args) throws Exception {
+        boolean b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), args[0]),
+                                          Paths.get(System.getProperty("user.dir")));
+        assertTrue(b, "Compilation failed");
+        String params[] = Arrays.copyOfRange(args, 1, args.length);
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(params);
+        Process p = ProcessTools.startProcess("Serializable Test", pb);
+        int exitValue = p.waitFor();
+        assertEquals(exitValue, 0, "Test failed");
+    }
+}
--- a/jdk/test/java/io/Serializable/class/SerialA.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.Serializable;
-
-public class A implements Serializable {
-    int field1;
-};
--- a/jdk/test/java/io/Serializable/class/SerialA_1.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.Serializable;
-
-public class A implements Serializable {
-    int field1;
-};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/SerialA_1/A.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.Serializable;
+
+public class A implements Serializable {
+    int field1;
+};
--- a/jdk/test/java/io/Serializable/class/SerialA_2.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.Serializable;
-
-public class A implements Serializable {
-    static final long serialVersionUID = 746945609796141988L;
-
-    int field1;
-    int field2;
-};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/SerialA_2/A.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.Serializable;
+
+public class A implements Serializable {
+    static final long serialVersionUID = 746945609796141988L;
+
+    int field1;
+    int field2;
+};
--- a/jdk/test/java/io/Serializable/class/SerialA_3.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.Serializable;
-
-/* THis class is purposely not compatible with previous versions of class.*/
-public class A implements Serializable {
-    int field1;
-    int field2;
-    int field3;
-};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/SerialA_3/A.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.Serializable;
+
+/* THis class is purposely not compatible with previous versions of class.*/
+public class A implements Serializable {
+    int field1;
+    int field2;
+    int field3;
+};
--- a/jdk/test/java/io/Serializable/class/Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved.
- * 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.
- */
-
-/*
- * @bug 4075221
- * @summary Enable serialize of nonSerializable Class descriptor.
- */
-
-import java.io.*;
-
-class Test {
-    public static void main(String args[]) throws Exception {
-        File f = new File("tmp.ser");
-        if (args[0].compareTo("-s") == 0) {
-            FileOutputStream of = new FileOutputStream(f);
-            ObjectOutputStream oos = new ObjectOutputStream(of);
-            Class cl = Class.forName(args[1]);
-            oos.writeObject(cl);
-            if (ObjectStreamClass.lookup(cl) != null)
-                oos.writeObject(cl.newInstance());
-            oos.close();
-            System.out.println("Serialized Class " + cl.getName());
-        } else if (args[0].compareTo("-de") == 0) {
-            FileInputStream inf = new FileInputStream(f);
-            ObjectInputStream ois = new ObjectInputStream(inf);
-            Class cl = null;
-            try {
-                cl = (Class)ois.readObject();
-                throw new Error("Expected InvalidClassException to be thrown");
-            } catch (InvalidClassException e) {
-                System.out.println("Caught expected exception DeSerializing class " + e.getMessage());
-            }
-            ois.close();
-        } else if (args[0].compareTo("-doe") == 0) {
-            FileInputStream inf = new FileInputStream(f);
-            ObjectInputStream ois = new ObjectInputStream(inf);
-            Class cl = null;
-            cl = (Class)ois.readObject();
-            try {
-                ois.readObject();
-                throw new Error("Expected InvalidClassException to be thrown");
-            } catch (InvalidClassException e) {
-                System.out.println("Caught expected exception DeSerializing class " + e.getMessage());
-            }
-            ois.close();
-        } else if (args[0].compareTo("-d") == 0) {
-            FileInputStream inf = new FileInputStream(f);
-            ObjectInputStream ois = new ObjectInputStream(inf);
-            Class cl = (Class)ois.readObject();
-            try {
-                ois.readObject();
-            } catch (EOFException e) {
-            }
-            ois.close();
-            System.out.println("DeSerialized Class " + cl.getName());
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/class/TestEntry.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.
+ */
+
+/*
+ * @bug 4075221
+ * @summary Enable serialize of nonSerializable Class descriptor.
+ */
+
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+import java.io.InvalidClassException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+
+class TestEntry {
+    public static void main(String args[]) throws Exception {
+        File f = new File("tmp.ser");
+        if (args[0].compareTo("-s") == 0) {
+            FileOutputStream of = new FileOutputStream(f);
+            ObjectOutputStream oos = new ObjectOutputStream(of);
+            Class cl = Class.forName(args[1]);
+            oos.writeObject(cl);
+            if (ObjectStreamClass.lookup(cl) != null)
+                oos.writeObject(cl.newInstance());
+            oos.close();
+            System.out.println("Serialized Class " + cl.getName());
+        } else if (args[0].compareTo("-de") == 0) {
+            FileInputStream inf = new FileInputStream(f);
+            ObjectInputStream ois = new ObjectInputStream(inf);
+            Class cl = null;
+            try {
+                cl = (Class)ois.readObject();
+                throw new Error("Expected InvalidClassException to be thrown");
+            } catch (InvalidClassException e) {
+                System.out.println("Caught expected exception DeSerializing class " + e.getMessage());
+            }
+            ois.close();
+        } else if (args[0].compareTo("-doe") == 0) {
+            FileInputStream inf = new FileInputStream(f);
+            ObjectInputStream ois = new ObjectInputStream(inf);
+            Class cl = null;
+            cl = (Class)ois.readObject();
+            try {
+                ois.readObject();
+                throw new Error("Expected InvalidClassException to be thrown");
+            } catch (InvalidClassException e) {
+                System.out.println("Caught expected exception DeSerializing class " + e.getMessage());
+            }
+            ois.close();
+        } else if (args[0].compareTo("-d") == 0) {
+            FileInputStream inf = new FileInputStream(f);
+            ObjectInputStream ois = new ObjectInputStream(inf);
+            Class cl = (Class)ois.readObject();
+            try {
+                ois.readObject();
+            } catch (EOFException e) {
+            }
+            ois.close();
+            System.out.println("DeSerialized Class " + cl.getName());
+        } else {
+            throw new RuntimeException("Unrecognized argument");
+        }
+    }
+}
--- a/jdk/test/java/io/Serializable/class/run.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +0,0 @@
-#
-# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4075221
-# @run shell/timeout=300 run.sh
-# @summary Enable serialize of nonSerializable Class descriptor.
-
-set -ex	
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
-  COMPILEJAVA="${TESTJAVA}"
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
-TESTSRC="."
-fi
-
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Test.java
-
-echo Write NonSerial1, Read NonSerial1
-rm -f A.java     
-cp ${TESTSRC}/NonSerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -d
-echo
-
-echo Write NonSerial1, Read NonSerial2
-rm -f A.java     
-cp ${TESTSRC}/NonSerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/NonSerialA_2.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -d
-echo
-
-echo Write NonSerial1, Read Serial1
-rm -f A.java     
-cp ${TESTSRC}/NonSerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java 
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/SerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -d
-echo
-
-echo Write Serial1, Read NonSerial1
-rm -f A.java     
-cp ${TESTSRC}/SerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java 
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/NonSerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -doe
-echo
-
-echo Write Serial1, Read Serial2
-rm -f A.java     
-cp ${TESTSRC}/SerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java 
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/SerialA_2.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -d
-echo
-
-echo Write Serial2, Read Serial1
-rm -f A.java     
-cp ${TESTSRC}/SerialA_2.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java 
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/SerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -d
-echo
-
-echo Write Serial1, Read Serial3
-rm -f A.java     
-cp ${TESTSRC}/SerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java 
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/SerialA_3.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -de
-echo
-
-echo Write Serial3, Read Serial1
-rm -f A.java     
-cp ${TESTSRC}/SerialA_3.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java 
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -s A
-rm -f A.java     
-cp ${TESTSRC}/SerialA_1.java A.java
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} A.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test -de
-echo
-
-echo Passed
--- a/jdk/test/java/io/Serializable/evolution/AddedExternField/run.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-#
-# Copyright (c) 1998, 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.
-#
-
-#
-# @bug 4088176
-# @summary  Test reading an evolved class serialization into the original class
-
-rm *.class tmp.ser
-javac WriteAddedField.java
-java ${TESTVMOPTS} WriteAddedField
-rm *.class
-javac ReadAddedField.java
-java ${TESTVMOPTS} ReadAddedField
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,107 @@
+/*
+ * 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 4087295 4785472
+ * @library /test/lib
+ * @build jdk.test.lib.compiler.CompilerUtils
+ * @build jdk.test.lib.process.ProcessTools
+ * @build RenamePackageTest
+ * @run main RenamePackageTest
+ * @summary Enable resolveClass() to accommodate package renaming.
+ *          This fix enables one to implement a resolveClass method that maps a
+ *          Serialiazable class within a serialization stream to the same class
+ *          in a different package within the JVM runtime. See run shell script
+ *          for instructions on how to run this test.
+ */
+
+import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import jdk.test.lib.compiler.CompilerUtils;
+import jdk.test.lib.process.ProcessTools;
+
+public class RenamePackageTest {
+    public static void main(String args[]) throws Exception {
+        setup();
+
+        runTestSerialDriver();
+        runInstallSerialDriver();
+
+        runInstallSerialDriver();
+        runTestSerialDriver();
+    }
+
+    private static final Path SHARE = Paths.get(System.getProperty("test.classes"), "share");
+    private static final Path OCLASSES = Paths.get(System.getProperty("test.classes"), "oclasses");
+    private static final Path NCLASSES = Paths.get(System.getProperty("test.classes"), "nclasses");
+
+    private static void setup() throws Exception {
+
+        boolean b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), "extension"),
+                                          SHARE);
+        assertTrue(b);
+        b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), "test"),
+                                  OCLASSES,
+                                  "-classpath",
+                                  SHARE.toString());
+        assertTrue(b);
+        b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), "install"),
+                                  NCLASSES,
+                                  "-classpath",
+                                  SHARE.toString());
+        assertTrue(b);
+    }
+
+    private static void runTestSerialDriver() throws Exception {
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
+                "-classpath",
+                SHARE.toString()
+                    + File.pathSeparator
+                    + OCLASSES.toString(),
+                "test.SerialDriver", "-s");
+        Process p = ProcessTools.startProcess("test SerialDriver", pb);
+        p.waitFor();
+        assertTrue(p.exitValue() == 0);
+    }
+
+    private static void runInstallSerialDriver() throws Exception {
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
+                "-classpath",
+                SHARE.toString()
+                    + File.pathSeparator
+                    + NCLASSES.toString(),
+                "install.SerialDriver", "-d");
+        Process p = ProcessTools.startProcess("install SerialDriver", pb);
+        p.waitFor();
+        assertTrue(p.exitValue() == 0);
+    }
+
+    private static void assertTrue(boolean b) {
+        if (!b) {
+            throw new RuntimeException("expected true, get false");
+        }
+    }
+}
--- a/jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-#
-# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4087295 4785472
-# @summary Enable resolveClass() to accommodate package renaming.
-# This fix enables one to implement a resolveClass method that maps a
-# Serialiazable class within a serialization stream to the same class
-# in a different package within the JVM runtime. See run shell script
-# for instructions on how to run this test.
-
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
-  COMPILEJAVA="${TESTJAVA}"
-fi
-
-
-OS=`uname -s`
-# Need to determine the classpath separator and filepath separator based on the
-# operating system.
-case "$OS" in
-SunOS | Linux | Darwin | AIX )
-  PS=":"  ;;
-Windows* | CYGWIN* )
-  PS=";"  ;;
-* )
-  echo "Unrecognized system!"
-  exit 1  ;;
-esac
-
-JAVA=${TESTJAVA}/bin/java
-JAVAC=${COMPILEJAVA}/bin/javac
-MKDIR=mkdir
-RDEL="rm -r"
-
-if [ -d ${TESTCLASSES}/oclasses ]
-then
-   ${RDEL} ${TESTCLASSES}/oclasses
-fi
-if [ -d ${TESTCLASSES}/nclasses ]
-then
-   ${RDEL} ${TESTCLASSES}/nclasses
-fi
-if [ -d ${TESTCLASSES}/share ]
-then
-   ${RDEL} ${TESTCLASSES}/share
-fi
-if [ -f ${TESTCLASSES}/stream.ser ]
-then
-   ${RDEL} ${TESTCLASSES}/stream.ser
-fi
-
-mkdir ${TESTCLASSES}/oclasses
-mkdir ${TESTCLASSES}/share
-mkdir ${TESTCLASSES}/nclasses
-
-# Build sources
-set -e
-${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}/share \
-    ${TESTSRC}/extension/ExtendedObjectInputStream.java
-CLASSPATH=${TESTCLASSES}/share; export CLASSPATH;
-${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}/oclasses \
-    ${TESTSRC}/test/SerialDriver.java
-CLASSPATH=${TESTCLASSES}/share; export CLASSPATH;
-${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}/nclasses \
-    ${TESTSRC}/install/SerialDriver.java
-
-# Run Case 1. Map test.SerialDriver within stream to install.SerialDriver.
-CLASSPATH="${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share"; export CLASSPATH;
-${JAVA} ${TESTVMOPTS} test.SerialDriver -s
-CLASSPATH="${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share"; export CLASSPATH;
-${JAVA} ${TESTVMOPTS} install.SerialDriver -d
-rm stream.ser
-
-# Run Case 2. Map install.SerialDriver within stream to test.SerialDriver.
-CLASSPATH="${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share"; export CLASSPATH;
-${JAVA} ${TESTVMOPTS} install.SerialDriver -s
-CLASSPATH="${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share"; export CLASSPATH;
-${JAVA} ${TESTVMOPTS} test.SerialDriver -d
--- a/jdk/test/java/io/Serializable/failureAtomicity/FailureAtomicity.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/io/Serializable/failureAtomicity/FailureAtomicity.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,7 @@
  * @bug 8071474
  * @summary Better failure atomicity for default read object.
  * @modules jdk.compiler
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library /test/lib
  * @compile FailureAtomicity.java SerialRef.java
  * @run main failureAtomicity.FailureAtomicity
  */
@@ -59,7 +58,7 @@
 import javax.tools.StandardJavaFileManager;
 import javax.tools.StandardLocation;
 import javax.tools.ToolProvider;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 
 @SuppressWarnings("unchecked")
 public class FailureAtomicity {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/maskSyntheticModifier/MaskSyntheticModifierTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,52 @@
+/*
+ * 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
+ * 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 4897937
+ * @run main MaskSyntheticModifierTest
+ * @summary Verify that the presence of the JVM_ACC_SYNTHETIC bit in the
+ *          modifiers of fields and methods does not affect default
+ *          serialVersionUID calculation.
+ */
+
+import java.io.ObjectStreamClass;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+
+public class MaskSyntheticModifierTest {
+    public static void main(String[] args) throws Exception {
+        setup();
+
+        long suid = ObjectStreamClass.lookup(Foo.class).getSerialVersionUID();
+        if (suid != 8027844768744011556L) {
+            throw new Error("incorrect serialVersionUID: " + suid);
+        }
+    }
+
+    private static void setup() throws Exception {
+        Files.copy(Paths.get(System.getProperty("test.src"), "Foo.class"),
+                Paths.get("Foo.class"), StandardCopyOption.REPLACE_EXISTING);
+    }
+}
--- a/jdk/test/java/io/Serializable/maskSyntheticModifier/Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * 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.
- */
-
-/*
- * @bug 4897937
- * @summary Verify that the presence of the JVM_ACC_SYNTHETIC bit in the
- *          modifiers of fields and methods does not affect default
- *          serialVersionUID calculation.
- */
-
-import java.io.ObjectStreamClass;
-
-public class Test {
-    public static void main(String[] args) {
-        long suid = ObjectStreamClass.lookup(Foo.class).getSerialVersionUID();
-        if (suid != 8027844768744011556L) {
-            throw new Error("incorrect serialVersionUID: " + suid);
-        }
-    }
-}
--- a/jdk/test/java/io/Serializable/maskSyntheticModifier/run.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-#
-# Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4897937
-# @summary Verify that the presence of the JVM_ACC_SYNTHETIC bit in the
-#          modifiers of fields and methods does not affect default
-#          serialVersionUID calculation.
-
-if [ "${TESTJAVA}" = "" ]
-then
-    echo "TESTJAVA not set.  Test cannot execute.  Failed."
-exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
-    COMPILEJAVA="${TESTJAVA}"
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
-    TESTSRC="."
-fi
-
-set -ex
-cp ${TESTSRC}/Foo.class .
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Test.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test
-rm -f *.class
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/packageAccess/PackageAccessTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,116 @@
+/*
+ * 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
+ * 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 4765255
+ * @library /lib/testlibrary
+ * @build JarUtils A B C D PackageAccessTest
+ * @run main PackageAccessTest
+ * @summary Verify proper functioning of package equality checks used to
+ *          determine accessibility of superclass constructor and inherited
+ *          writeReplace/readResolve methods.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.io.InvalidClassException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class PackageAccessTest {
+
+    static Class bcl;
+    static Class dcl;
+
+    public static void main(String[] args) throws Exception {
+        setup();
+
+        try (URLClassLoader ldr =
+            new URLClassLoader(new URL[]{ new URL("file:foo.jar") },
+                    PackageAccessTest.class.getClassLoader())) {
+            bcl = Class.forName("B", true, ldr);
+            dcl = Class.forName("D", true, ldr);
+
+            Object b = bcl.newInstance();
+            try {
+                swizzle(b);
+                throw new Error("expected InvalidClassException for class B");
+            } catch (InvalidClassException e) {
+                System.out.println("caught " + e);
+                e.printStackTrace();
+            }
+            if (A.packagePrivateConstructorInvoked) {
+                throw new Error("package private constructor of A invoked");
+            }
+
+            Object d = dcl.newInstance();
+            swizzle(d);
+        }
+    }
+
+    static void swizzle(Object obj) throws Exception {
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        ObjectOutputStream oout = new ObjectOutputStream(bout);
+        oout.writeObject(obj);
+        oout.close();
+        ByteArrayInputStream bin =
+            new ByteArrayInputStream(bout.toByteArray());
+        new TestObjectInputStream(bin).readObject();
+    }
+
+    static void setup() throws Exception {
+        Path classes = Paths.get(System.getProperty("test.classes", ""));
+        JarUtils.createJarFile(Paths.get("foo.jar"), classes,
+                classes.resolve("B.class"), classes.resolve("D.class"));
+        Files.delete(classes.resolve("B.class"));
+        Files.delete(classes.resolve("D.class"));
+    }
+}
+
+class TestObjectInputStream extends ObjectInputStream {
+    TestObjectInputStream(InputStream in) throws IOException {
+        super(in);
+    }
+
+    protected Class resolveClass(ObjectStreamClass desc)
+        throws IOException, ClassNotFoundException
+    {
+        String n = desc.getName();
+        if (n.equals("B")) {
+            return PackageAccessTest.bcl;
+        } else if (n.equals("D")) {
+            return PackageAccessTest.dcl;
+        } else {
+            return super.resolveClass(desc);
+        }
+    }
+}
--- a/jdk/test/java/io/Serializable/packageAccess/Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
- * 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.
- */
-
-/*
- * @bug 4765255
- * @summary Verify proper functioning of package equality checks used to
- *          determine accessibility of superclass constructor and inherited
- *          writeReplace/readResolve methods.
- */
-
-import java.io.*;
-import java.net.*;
-
-public class Test {
-
-    static Class bcl;
-    static Class dcl;
-
-    public static void main(String[] args) throws Exception {
-        ClassLoader ldr =
-            new URLClassLoader(new URL[]{ new URL("file:foo.jar") },
-                               Test.class.getClassLoader());
-        bcl = Class.forName("B", true, ldr);
-        dcl = Class.forName("D", true, ldr);
-
-        Object b = bcl.newInstance();
-        try {
-            swizzle(b);
-            throw new Error("expected InvalidClassException for class B");
-        } catch (InvalidClassException e) {
-            System.out.println("caught " + e);
-            e.printStackTrace();
-        }
-        if (A.packagePrivateConstructorInvoked) {
-            throw new Error("package private constructor of A invoked");
-        }
-
-        Object d = dcl.newInstance();
-        swizzle(d);
-    }
-
-    static void swizzle(Object obj) throws Exception {
-        ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        ObjectOutputStream oout = new ObjectOutputStream(bout);
-        oout.writeObject(obj);
-        oout.close();
-        ByteArrayInputStream bin =
-            new ByteArrayInputStream(bout.toByteArray());
-        new TestObjectInputStream(bin).readObject();
-    }
-}
-
-class TestObjectInputStream extends ObjectInputStream {
-    TestObjectInputStream(InputStream in) throws IOException {
-        super(in);
-    }
-
-    protected Class resolveClass(ObjectStreamClass desc)
-        throws IOException, ClassNotFoundException
-    {
-        String n = desc.getName();
-        if (n.equals("B")) {
-            return Test.bcl;
-        } else if (n.equals("D")) {
-            return Test.dcl;
-        } else {
-            return super.resolveClass(desc);
-        }
-    }
-}
--- a/jdk/test/java/io/Serializable/packageAccess/run.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#
-# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4765255
-# @summary Verify proper functioning of package equality checks used to
-#          determine accessibility of superclass constructor and inherited
-#          writeReplace/readResolve methods.
-
-if [ "${TESTJAVA}" = "" ]
-then
-    echo "TESTJAVA not set.  Test cannot execute.  Failed."
-exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
-    COMPILEJAVA="${TESTJAVA}"
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
-    TESTSRC="."
-fi
-
-set -ex
-
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \
-    ${TESTSRC}/A.java ${TESTSRC}/B.java ${TESTSRC}/C.java ${TESTSRC}/D.java \
-    ${TESTSRC}/Test.java
-${COMPILEJAVA}/bin/jar ${TESTTOOLVMOPTS} cf foo.jar B.class D.class
-rm -f B.class D.class
-
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test
-rm -f *.class *.jar
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/resolveClass/consTest/ConsTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,57 @@
+/*
+ * 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
+ * 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 4413434
+ * @library /lib/testlibrary
+ * @build JarUtils SetupJar Boot
+ * @run driver SetupJar
+ * @run main/othervm -Xbootclasspath/a:boot.jar ConsTest
+ * @summary Verify that generated java.lang.reflect implementation classes do
+ *          not interfere with serialization's class resolution mechanism.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
+
+public class ConsTest implements Serializable {
+    public static void main(String[] args) throws Exception {
+        Constructor cons = Boot.class.getConstructor(
+            new Class[] { ObjectInputStream.class });
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        ObjectOutputStream oout = new ObjectOutputStream(bout);
+        oout.writeObject(new ConsTest());
+        oout.close();
+
+        for (int i = 0; i < 100; i++) {
+            ObjectInputStream oin = new ObjectInputStream(
+                new ByteArrayInputStream(bout.toByteArray()));
+            cons.newInstance(new Object[]{ oin });
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/resolveClass/consTest/SetupJar.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class SetupJar {
+
+    public static void main(String args[]) throws Exception {
+        Path classes = Paths.get(System.getProperty("test.classes", ""));
+        JarUtils.createJarFile(Paths.get("boot.jar"), classes,
+                classes.resolve("Boot.class"));
+    }
+}
--- a/jdk/test/java/io/Serializable/resolveClass/consTest/Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
- * 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.
- */
-
-/*
- * @bug 4413434
- * @summary Verify that generated java.lang.reflect implementation classes do
- *          not interfere with serialization's class resolution mechanism.
- */
-
-import java.io.*;
-import java.lang.reflect.*;
-
-public class Test implements Serializable {
-    public static void main(String[] args) throws Exception {
-        Constructor cons = Boot.class.getConstructor(
-            new Class[] { ObjectInputStream.class });
-        ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        ObjectOutputStream oout = new ObjectOutputStream(bout);
-        oout.writeObject(new Test());
-        oout.close();
-
-        for (int i = 0; i < 100; i++) {
-            ObjectInputStream oin = new ObjectInputStream(
-                new ByteArrayInputStream(bout.toByteArray()));
-            cons.newInstance(new Object[]{ oin });
-        }
-    }
-}
--- a/jdk/test/java/io/Serializable/resolveClass/consTest/run.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-#
-# Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4413434
-# @summary Verify that generated java.lang.reflect implementation classes do
-#          not interfere with serialization's class resolution mechanism.
-
-if [ "${TESTJAVA}" = "" ]
-then
-    echo "TESTJAVA not set.  Test cannot execute.  Failed."
-exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
-    COMPILEJAVA="${TESTJAVA}"
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
-    TESTSRC="."
-fi
-
-set -ex
-
-rm -f *.class *.jar
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Boot.java
-${COMPILEJAVA}/bin/jar ${TESTTOOLVMOPTS} cf boot.jar *.class
-rm -f *.class
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -classpath boot.jar -d . \
-    ${TESTSRC}/Test.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} -Xbootclasspath/a:boot.jar Test
-rm -f *.class *.jar
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/resolveClass/deserializeButton/DeserializeButtonTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,59 @@
+/*
+ * 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
+ * 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 4413434
+ * @library /lib/testlibrary
+ * @build JarUtils Foo
+ * @run main DeserializeButtonTest
+ * @summary Verify that class loaded outside of application class loader is
+ *          correctly resolved during deserialization when read in by custom
+ *          readObject() method of a bootstrap class (in this case,
+ *          java.util.Vector).
+ */
+
+import java.net.URLClassLoader;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class DeserializeButtonTest {
+    public static void main(String[] args) throws Exception {
+        setup();
+
+        try (URLClassLoader ldr =
+            new URLClassLoader(new URL[]{ new URL("file:cb.jar") })) {
+            Runnable r = (Runnable) Class.forName("Foo", true, ldr).newInstance();
+            r.run();
+        }
+    }
+
+    private static void setup() throws Exception {
+        Path classes = Paths.get(System.getProperty("test.classes", ""));
+        JarUtils.createJarFile(Paths.get("cb.jar"),
+                               classes,
+                               classes.resolve("Foo.class"),
+                               classes.resolve("Foo$TestElement.class"));
+    }
+}
--- a/jdk/test/java/io/Serializable/resolveClass/deserializeButton/Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-/*
- * @bug 4413434
- * @summary Verify that class loaded outside of application class loader is
- *          correctly resolved during deserialization when read in by custom
- *          readObject() method of a bootstrap class (in this case,
- *          java.util.Vector).
- */
-
-import java.io.*;
-import java.net.*;
-
-public class Test {
-    public static void main(String[] args) throws Exception {
-        ClassLoader ldr =
-            new URLClassLoader(new URL[]{ new URL("file:cb.jar") });
-        Runnable r = (Runnable) Class.forName("Foo", true, ldr).newInstance();
-        r.run();
-    }
-}
--- a/jdk/test/java/io/Serializable/resolveClass/deserializeButton/run.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#
-# Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4413434
-# @summary Verify that class loaded outside of application class loader is
-#          correctly resolved during deserialization when read in by custom
-#          readObject() method of a bootstrap class (in this case,
-#          java.util.Vector).
-
-if [ "${TESTJAVA}" = "" ]
-then
-    echo "TESTJAVA not set.  Test cannot execute.  Failed."
-exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
-    COMPILEJAVA="${TESTJAVA}"
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
-    TESTSRC="."
-fi
-
-set -ex
-
-rm -f *.class *.jar
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Foo.java
-${COMPILEJAVA}/bin/jar ${TESTTOOLVMOPTS} cf cb.jar *.class
-rm -f *.class
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Test.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test
-rm -f *.class *.jar
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/serialver/classpath/ClasspathTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,59 @@
+/*
+ * 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
+ * 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 4035147 4785472
+ * @library /test/lib
+ * @build jdk.test.lib.JDKToolLauncher
+ * @build jdk.test.lib.process.ProcessTools
+ * @build ClasspathTest
+ * @run main serialver.ClasspathTest
+ * @summary Test the use of the -classpath switch in the serialver application.
+ */
+
+package serialver;
+
+import java.io.File;
+
+import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.process.ProcessTools;
+
+public class ClasspathTest implements java.io.Serializable {
+    int a;
+    int b;
+
+    public static void main(String args[]) throws Exception {
+        JDKToolLauncher serialver =
+                JDKToolLauncher.create("serialver")
+                               .addToolArg("-classpath")
+                               .addToolArg(System.getProperty("test.class.path"))
+                               .addToolArg("serialver.ClasspathTest");
+        Process p = ProcessTools.startProcess("serialver",
+                        new ProcessBuilder(serialver.getCommand()));
+        p.waitFor();
+        if (p.exitValue() != 0) {
+            throw new RuntimeException("error occurs in serialver");
+        }
+    }
+}
--- a/jdk/test/java/io/Serializable/serialver/classpath/Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
- * 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.
- */
-
-/*
- *
- *  @bug 4035147
- *  @sumary     Simple java class for test purposes
- */
-
-package serialver;
-
-public class Test implements java.io.Serializable{
-    int a;
-    int b;
-}
--- a/jdk/test/java/io/Serializable/serialver/classpath/run.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-#
-# Copyright (c) 2000, 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.
-#
-
-# @test
-# @bug 4035147 4785472
-# @summary Test the use of the -classpath switch in the serialver application.
-# @author Naveen Sanjeeva
-#
-# @build Test
-# @run shell run.sh
-
-# set a few environment variables so that the shell-script can run stand-alone
-# in the source directory
-
-if [ "${TESTSRC}" = "" ] ; then
-  TESTSRC="."
-fi
-if [ "${TESTCLASSES}" = "" ] ; then
-  TESTCLASSES="."
-fi
-if [ "${TESTJAVA}" = "" ] ; then
-  echo "TESTJAVA not set.  Test cannot execute."
-  echo "FAILED!!!"
-  exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | AIX )
-    PS=":"    ;;
-  Windows* | CYGWIN* )
-    PS=";"    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1    ;;
-esac
-
-# the test code
-
-echo "Using the classpath .${PS}${TESTCLASSES}"
-${TESTJAVA}/bin/serialver -classpath ".${PS}${TESTCLASSES}" serialver.Test
-
-exit $?
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/serialver/nested/NestedTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,63 @@
+/*
+ * 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
+ * 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 4312217 4785473
+ * @library /test/lib
+ * @build jdk.test.lib.JDKToolLauncher
+ * @build jdk.test.lib.process.ProcessTools
+ * @build NestedTest
+ * @run main serialver.NestedTest
+ * @summary  To test the use of nested class specification using the '.'
+ *           notation instead of the '$' notation.
+ */
+
+package serialver;
+
+import java.io.Serializable;
+
+import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.process.ProcessTools;
+
+public class NestedTest implements Serializable {
+    public static class Test1 implements Serializable {
+        public static class Test2 implements Serializable{
+            private static final long serialVersionUID = 100L;
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+        JDKToolLauncher serialver =
+                JDKToolLauncher.create("serialver")
+                               .addToolArg("-classpath")
+                               .addToolArg(System.getProperty("test.class.path"))
+                               .addToolArg("serialver.NestedTest.Test1.Test2");
+        Process p = ProcessTools.startProcess("serialver",
+                        new ProcessBuilder(serialver.getCommand()));
+        p.waitFor();
+        if (p.exitValue() != 0) {
+            throw new RuntimeException("error occurs in serialver.");
+        }
+    }
+}
--- a/jdk/test/java/io/Serializable/serialver/nested/Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
- * 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.
- */
-
-/*
- *
- * @bug 4312217
- * @summary  To test the use of nested class specification using the '.'
- *           notation instead of the '$' notation.
- */
-package serialver;
-
-import java.io.*;
-
-public class Test implements Serializable {
-    public static class Test1 implements Serializable {
-        public static class Test2 implements Serializable{
-            private static final long serialVersionUID = 100L;
-        }
-    }
-}
--- a/jdk/test/java/io/Serializable/serialver/nested/run.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-#
-# Copyright (c) 2000, 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.
-#
-
-# @test
-# @bug 4312217 4785473
-# @summary Test the use of the -classpath switch in the serialver application.
-# @author Naveen Sanjeeva
-#
-# @build Test
-# @run shell run.sh
-
-# set a few environment variables so that the shell-script can run stand-alone
-# in the source directory
-
-if [ "${TESTSRC}" = "" ] ; then
-  TESTSRC="."
-fi
-if [ "${TESTCLASSES}" = "" ] ; then
-  TESTCLASSES="."
-fi
-if [ "${TESTJAVA}" = "" ] ; then
-  echo "TESTJAVA not set.  Test cannot execute."
-  echo "FAILED!!!"
-  exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | AIX )
-    PS=":"    ;;
-  Windows* | CYGWIN* )
-    PS=";"    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1    ;;
-esac
-
-# the test code
-
-echo "Using the classpath .${PS}${TESTCLASSES}"
-${TESTJAVA}/bin/serialver -classpath ".${PS}${TESTCLASSES}" 'serialver.Test.Test1.Test2'
-
-exit $?
--- a/jdk/test/java/io/Serializable/subclass/Allow.policy	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/io/Serializable/subclass/Allow.policy	Wed Jul 05 23:37:13 2017 +0200
@@ -2,7 +2,6 @@
 	// "standard" properies that can be read by anyone
 	permission java.io.FilePermission "-","read,write,execute";
 	permission java.io.SerializablePermission "enableSubstitution";
-	permission java.io.SerializablePermission "enableSubclassImplementation";
 
 	// Needed to get access to private writeObjectMethod and
         // to be able to call it.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/subclass/SubclassTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4100915
+ * @summary Verify that [write/read]ObjectOverride methods get called.
+ *          Test verifies that ALL methods to write an object can
+ *          be overridden. However, the testing for reading an object
+ *          is incomplete. Only test that readObjectOverride is called.
+ *          An entire protocol would need to be implemented and written
+ *          out before being able to test the input side of the API.
+ *
+ *          Also, would be appropriate that this program verify
+ *          that if SerializablePermission "enableSubclassImplementation"
+ *          is not in the security policy and security is enabled, that
+ *          a security exception is thrown when constructing the
+ *          ObjectOutputStream subclass.
+ *
+ *
+ * @compile AbstractObjectInputStream.java AbstractObjectOutputStream.java
+ * @compile XObjectInputStream.java XObjectOutputStream.java
+ * @compile SubclassTest.java
+ * @run main SubclassTest
+ * @run main/othervm/policy=Allow.policy SubclassTest -expectSecurityException
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.io.Serializable;
+
+/**
+ * Test if customized readObject and writeObject are called.
+ */
+class B implements Serializable {
+    public int publicIntField;
+    public static int numWriteObjectCalled = 0;
+    B(int v) {
+        publicIntField = v;
+    }
+    private void writeObject(ObjectOutputStream os) throws IOException {
+        numWriteObjectCalled++;
+        os.defaultWriteObject();
+    }
+
+    private void readObject(ObjectInputStream is)
+        throws IOException, ClassNotFoundException
+    {
+        is.defaultReadObject();
+    }
+
+};
+
+/**
+ * Test PutFields interface.
+ */
+
+class C implements Serializable {
+    public int xx1;
+    public int xx2;
+    static final ObjectStreamField[] serialPersistentFields = {
+        new ObjectStreamField("x1", Integer.TYPE),
+        new ObjectStreamField("x2", Integer.TYPE),
+        new ObjectStreamField("x3", Integer.TYPE),
+        new ObjectStreamField("x4", Integer.TYPE)
+    };
+    C() {
+        xx1 = 300;
+        xx2 = 400;
+    }
+
+    private void writeObject(ObjectOutputStream os) throws IOException {
+        ObjectOutputStream.PutField putFields = os.putFields();
+        putFields.put("x1", xx1);
+        putFields.put("x2", xx2);
+        putFields.put("x3", xx1 * 2);
+        putFields.put("x4", xx2 * 2);
+        os.writeFields();
+    }
+
+};
+
+
+class A implements Serializable {
+    public int  publicIntField;
+    public long publicLongField;
+    public B    publicBField;
+    public B[]  publicBArray = { new B(4), new B(6)};
+    public C    publicCField;
+
+    public A() {
+        publicIntField = 3;
+        publicLongField = 10L;
+        publicBField = new B(5);
+        publicCField = new C();
+    }
+};
+
+public class SubclassTest {
+    public static void main(String argv[])
+        throws IOException, ClassNotFoundException
+    {
+        boolean expectSecurityException = false;
+
+        if (argv.length > 0 &&
+            argv[0].compareTo("-expectSecurityException") == 0)
+            expectSecurityException = true;
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream(20);
+        XObjectOutputStream os = null;
+        try {
+            os = new XObjectOutputStream(baos);
+            if (expectSecurityException)
+                throw new Error("Assertion failure. " +
+                                "Expected a security exception on previous line.");
+        } catch (SecurityException e) {
+            if (expectSecurityException) {
+                System.err.println("Caught expected security exception.");
+                return;
+            }
+            throw e;
+        }
+        os.writeObject(new A());
+        os.close();
+        if (B.numWriteObjectCalled != 3)
+            throw new Error("Expected B.writeObject() to be called 3 times;" +
+                            " observed only " + B.numWriteObjectCalled + " times");
+
+        XObjectInputStream is =
+            new XObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+        try {
+            A a = (A)is.readObject();
+            throw new Error("Expected readObjectOverride() to be called and throw IOException(not implemented)");
+        } catch (IOException e) {
+        }
+        is.close();
+    }
+};
--- a/jdk/test/java/io/Serializable/subclass/Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
- * 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 4100915
- * @summary Verify that [write/read]ObjectOverride methods get called.
- *          Test verifies that ALL methods to write an object can
- *          be overridden. Howver, the testing for reading an object
- *          is incomplete. Only test that readObjectOverride is called.
- *          An entire protocol would need to be implemented and written
- *          out before being able to test the input side of the API.
- *
- *          Also, would be appropriate that this program verify
- *          that if SerializablePermission "enableSubclassImplamentation"
- *          is not in the security policy and security is enabled, that
- *          a security excepiton is thrown when constructing the
- *          ObjectOutputStream subclass.
- *
- *
- * @compile AbstractObjectInputStream.java AbstractObjectOutputStream.java XObjectInputStream.java XObjectOutputStream.java Test.java
- * @run main  Test
- */
-
-import java.io.*;
-
-/**
- * Test if customized readObject and writeObject are called.
- */
-class B implements Serializable {
-    public int publicIntField;
-    public static int numWriteObjectCalled = 0;
-    B(int v) {
-        publicIntField = v;
-    }
-    private void writeObject(ObjectOutputStream os) throws IOException {
-        numWriteObjectCalled++;
-        os.defaultWriteObject();
-    }
-
-    private void readObject(ObjectInputStream is)
-        throws IOException, ClassNotFoundException
-    {
-        is.defaultReadObject();
-    }
-
-};
-
-/**
- * Test PutFields interface.
- */
-
-class C implements Serializable {
-    public int xx1;
-    public int xx2;
-    static final ObjectStreamField[] serialPersistentFields = {
-        new ObjectStreamField("x1", Integer.TYPE),
-        new ObjectStreamField("x2", Integer.TYPE),
-        new ObjectStreamField("x3", Integer.TYPE),
-        new ObjectStreamField("x4", Integer.TYPE)
-    };
-    C() {
-        xx1 = 300;
-        xx2 = 400;
-    }
-
-    private void writeObject(ObjectOutputStream os) throws IOException {
-        ObjectOutputStream.PutField putFields = os.putFields();
-        putFields.put("x1", xx1);
-        putFields.put("x2", xx2);
-        putFields.put("x3", xx1 * 2);
-        putFields.put("x4", xx2 * 2);
-        os.writeFields();
-    }
-
-};
-
-
-class A implements Serializable {
-    public int  publicIntField;
-    public long publicLongField;
-    public B    publicBField;
-    public B[]  publicBArray = { new B(4), new B(6)};
-    public C    publicCField;
-
-    public A() {
-        publicIntField = 3;
-        publicLongField = 10L;
-        publicBField = new B(5);
-        publicCField = new C();
-    }
-};
-
-public class Test {
-    public static void main(String argv[])
-        throws IOException, ClassNotFoundException
-    {
-        boolean expectSecurityException = false;
-
-        if (argv.length > 0 &&
-            argv[0].compareTo("-expectSecurityException") == 0)
-            expectSecurityException = true;
-
-        ByteArrayOutputStream baos = new ByteArrayOutputStream(20);
-        XObjectOutputStream os = null;
-        try {
-            os = new XObjectOutputStream(baos);
-            if (expectSecurityException)
-                throw new Error("Assertion failure. " +
-                                "Expected a security exception on previous line.");
-        } catch (SecurityException e) {
-            if (expectSecurityException)
-                return;
-            else
-                throw e;
-        }
-        os.writeObject(new A());
-        os.close();
-        if (B.numWriteObjectCalled != 3)
-            throw new Error("Expected B.writeObject() to be called 3 times;" +
-                            " observed only " + B.numWriteObjectCalled + " times");
-
-        XObjectInputStream is =
-            new XObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
-        try {
-            A a = (A)is.readObject();
-            throw new Error("Expected readObjectOverride() to be called and throw IOException(not implemented)");
-        } catch (IOException e) {
-        }
-        is.close();
-    }
-};
--- a/jdk/test/java/io/Serializable/subclass/run.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-#
-# Copyright (c) 1998, 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.
-#
-
-#
-# @bug 4100915
-mkdir classes
-javac -d classes *.java
-java ${TESTVMOPTS} -classpath classes -Djava.policy=Allow.policy Test 
-# ENABLE next line when new method for invoking a main with a SecureClassLoader is known
-#java -classpath classes -Djava.policy=NotAllow.policy Test -expectSecurityException
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/superclassDataLoss/SuperclassDataLossTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,121 @@
+/*
+ * 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
+ * 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 4325590
+ * @library /lib/testlibrary
+ * @build JarUtils A B
+ * @run main SuperclassDataLossTest
+ * @summary Verify that superclass data is not lost when incoming superclass
+ *          descriptor is matched with local class that is not a superclass of
+ *          the deserialized instance's class.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.MalformedURLException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+
+class MixedSuperclassStream extends ObjectInputStream {
+    private boolean ldr12A;
+    private URLClassLoader ldr1;
+    private URLClassLoader ldr2;
+
+    MixedSuperclassStream(InputStream in, URLClassLoader ldr1,
+            URLClassLoader ldr2, boolean ldr1First) throws IOException {
+        super(in);
+        this.ldr1 = ldr1;
+        this.ldr2 = ldr2;
+        this.ldr12A = ldr12A;
+    }
+
+    protected Class resolveClass(ObjectStreamClass desc)
+        throws IOException, ClassNotFoundException
+    {
+        // resolve A's classdesc to class != B's superclass
+        String name = desc.getName();
+        if (ldr12A) {
+            if (name.equals("A")) {
+                return Class.forName(name, true, ldr1);
+            } else if (name.equals("B")) {
+                return Class.forName(name, true, ldr2);
+            }
+        } else {
+            if (name.equals("B")) {
+                return Class.forName(name, true, ldr1);
+            } else if (name.equals("A")) {
+                return Class.forName(name, true, ldr2);
+            }
+        }
+        return super.resolveClass(desc);
+    }
+}
+
+public class SuperclassDataLossTest {
+
+    public static void main(String[] args) throws Exception {
+        try (URLClassLoader ldr1 = new URLClassLoader(new URL[] { new URL("file:cb1.jar") });
+             URLClassLoader ldr2 = new URLClassLoader(new URL[] { new URL("file:cb2.jar") })) {
+            setup();
+
+            Runnable a = (Runnable) Class.forName("B", true, ldr1).newInstance();
+            a.run();
+
+            ByteArrayOutputStream bout = new ByteArrayOutputStream();
+            ObjectOutputStream oout = new ObjectOutputStream(bout);
+            oout.writeObject(a);
+            oout.close();
+
+            test(bout, ldr1, ldr2, true);
+            test(bout, ldr1, ldr2, false);
+        }
+    }
+
+    private static void test(ByteArrayOutputStream bout, URLClassLoader ldr1,
+                             URLClassLoader ldr2, boolean ldr12A) throws Exception {
+        ByteArrayInputStream bin =
+            new ByteArrayInputStream(bout.toByteArray());
+        ObjectInputStream oin = new MixedSuperclassStream(bin, ldr1, ldr2, ldr12A);
+        Runnable a = (Runnable) oin.readObject();
+        a.run();
+    }
+
+    private static void setup() throws Exception {
+        Path classes = Paths.get(System.getProperty("test.classes", ""));
+        JarUtils.createJarFile(Paths.get("cb1.jar"), classes,
+                classes.resolve("A.class"), classes.resolve("B.class"));
+        Files.copy(Paths.get("cb1.jar"), Paths.get("cb2.jar"),
+                   StandardCopyOption.REPLACE_EXISTING);
+    }
+}
--- a/jdk/test/java/io/Serializable/superclassDataLoss/Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
- * 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.
- */
-
-/*
- * @bug 4325590
- * @summary Verify that superclass data is not lost when incoming superclass
- *          descriptor is matched with local class that is not a superclass of
- *          the deserialized instance's class.
- */
-
-import java.io.*;
-import java.net.*;
-
-class MixedSuperclassStream extends ObjectInputStream {
-    MixedSuperclassStream(InputStream in) throws IOException { super(in); }
-
-    protected Class resolveClass(ObjectStreamClass desc)
-        throws IOException, ClassNotFoundException
-    {
-        // resolve A's classdesc to class != B's superclass
-        String name = desc.getName();
-        if (name.equals("A")) {
-            return Class.forName(name, true, Test.ldr1);
-        } else if (name.equals("B")) {
-            return Class.forName(name, true, Test.ldr2);
-        } else {
-            return super.resolveClass(desc);
-        }
-    }
-}
-
-public class Test {
-
-    static URLClassLoader ldr1, ldr2;
-    static {
-        try {
-            ldr1 = new URLClassLoader(new URL[] { new URL("file:cb1.jar") });
-            ldr2 = new URLClassLoader(new URL[] { new URL("file:cb2.jar") });
-        } catch (MalformedURLException ex) {
-            throw new Error();
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        Runnable a = (Runnable) Class.forName("B", true, ldr1).newInstance();
-        a.run();
-
-        ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        ObjectOutputStream oout = new ObjectOutputStream(bout);
-        oout.writeObject(a);
-        oout.close();
-
-        ByteArrayInputStream bin =
-            new ByteArrayInputStream(bout.toByteArray());
-        ObjectInputStream oin = new MixedSuperclassStream(bin);
-        a = (Runnable) oin.readObject();
-        a.run();
-    }
-}
--- a/jdk/test/java/io/Serializable/superclassDataLoss/run.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-#
-# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4325590
-# @summary Verify that superclass data is not lost when incoming superclass
-#          descriptor is matched with local class that is not a superclass of
-#          the deserialized instance's class.
-
-if [ "${TESTJAVA}" = "" ]
-then
-    echo "TESTJAVA not set.  Test cannot execute.  Failed."
-exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
-    COMPILEJAVA="${TESTJAVA}"
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
-    TESTSRC="."
-fi
-
-set -ex
-
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \
-    ${TESTSRC}/A.java ${TESTSRC}/B.java
-${COMPILEJAVA}/bin/jar ${TESTTOOLVMOPTS} cf cb1.jar A.class B.class
-cp cb1.jar cb2.jar
-rm -f A.class B.class
-
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \
-    ${TESTSRC}/Test.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test
-rm -f *.class *.jar
--- a/jdk/test/java/io/Serializable/unnamedPackageSwitch/Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
- * 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.
- */
-
-/*
- * @bug 4348213
- * @summary Verify that deserialization allows an incoming class descriptor
- *          representing a class in the unnamed package to be resolved to a
- *          local class with the same name in a named package, and vice-versa.
- */
-
-import java.io.*;
-
-class A implements Serializable {
-    private static final long serialVersionUID = 0L;
-}
-
-class TestObjectInputStream extends ObjectInputStream {
-    TestObjectInputStream(InputStream in) throws IOException { super(in); }
-    protected Class resolveClass(ObjectStreamClass desc)
-        throws IOException, ClassNotFoundException
-    {
-        String name = desc.getName();
-        if (name.equals("A")) {
-            return pkg.A.class;
-        } else if (name.equals("pkg.A")) {
-            return A.class;
-        } else {
-            return super.resolveClass(desc);
-        }
-    }
-}
-
-public class Test {
-    public static void main(String[] args) throws Exception {
-        ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        ObjectOutputStream oout = new ObjectOutputStream(bout);
-        oout.writeObject(new A());
-        oout.writeObject(new pkg.A());
-        oout.close();
-
-        ObjectInputStream oin = new TestObjectInputStream(
-            new ByteArrayInputStream(bout.toByteArray()));
-        oin.readObject();
-        oin.readObject();
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/io/Serializable/unnamedPackageSwitch/UnnamedPackageSwitchTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,76 @@
+/*
+ * 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
+ * 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 4348213
+ * @build UnnamedPackageSwitchTest pkg.A
+ * @run main UnnamedPackageSwitchTest
+ * @summary Verify that deserialization allows an incoming class descriptor
+ *          representing a class in the unnamed package to be resolved to a
+ *          local class with the same name in a named package, and vice-versa.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+import java.io.Serializable;
+
+class A implements Serializable {
+    private static final long serialVersionUID = 0L;
+}
+
+class TestObjectInputStream extends ObjectInputStream {
+    TestObjectInputStream(InputStream in) throws IOException { super(in); }
+    protected Class resolveClass(ObjectStreamClass desc)
+        throws IOException, ClassNotFoundException
+    {
+        String name = desc.getName();
+        if (name.equals("A")) {
+            return pkg.A.class;
+        } else if (name.equals("pkg.A")) {
+            return A.class;
+        } else {
+            return super.resolveClass(desc);
+        }
+    }
+}
+
+public class UnnamedPackageSwitchTest {
+    public static void main(String[] args) throws Exception {
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        ObjectOutputStream oout = new ObjectOutputStream(bout);
+        oout.writeObject(new A());
+        oout.writeObject(new pkg.A());
+        oout.close();
+
+        ObjectInputStream oin = new TestObjectInputStream(
+            new ByteArrayInputStream(bout.toByteArray()));
+        oin.readObject();
+        oin.readObject();
+    }
+}
--- a/jdk/test/java/io/Serializable/unnamedPackageSwitch/run.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-#
-# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4348213
-# @summary Verify that deserialization allows an incoming class descriptor
-#          representing a class in the unnamed package to be resolved to a
-#          local class with the same name in a named package, and vice-versa.
-
-if [ "${TESTJAVA}" = "" ]
-then
-    echo "TESTJAVA not set.  Test cannot execute.  Failed."
-exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
-    COMPILEJAVA="${TESTJAVA}"
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
-    TESTSRC="."
-fi
-
-set -ex
-
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \
-    ${TESTSRC}/A.java ${TESTSRC}/Test.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test
--- a/jdk/test/java/lang/Class/forName/modules/TestDriver.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/Class/forName/modules/TestDriver.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,8 @@
 import java.util.Arrays;
 import java.util.stream.Stream;
 
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.*;
 
 import org.testng.annotations.BeforeClass;
@@ -40,9 +41,10 @@
  * @test
  * @bug 8087335
  * @summary Tests for Class.forName(Module,String)
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build TestDriver CompilerUtils jdk.testlibrary.ProcessTools jdk.testlibrary.FileUtils TestMain TestLayer
+ * @build jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.ProcessTools
+ *        TestDriver TestMain TestLayer
  * @run testng TestDriver
  */
 
--- a/jdk/test/java/lang/Class/getResource/ResourcesTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/Class/getResource/ResourcesTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 import java.nio.file.Paths;
 
 import static jdk.testlibrary.ProcessTools.executeTestJava;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -32,9 +33,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build ResourcesTest CompilerUtils jdk.testlibrary.*
+ * @build ResourcesTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run testng ResourcesTest
  * @summary Driver for basic test of Class getResource and getResourceAsStream
  */
--- a/jdk/test/java/lang/ClassLoader/getResource/modules/ResourcesTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/ClassLoader/getResource/modules/ResourcesTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 import java.nio.file.Paths;
 
 import static jdk.testlibrary.ProcessTools.executeTestJava;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -33,9 +34,9 @@
 /**
  * @test
  * @bug 8087335
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build ResourcesTest CompilerUtils jdk.testlibrary.*
+ * @build ResourcesTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run testng ResourcesTest
  * @summary Driver for basic test of ClassLoader getResource and getResourceAsStream
  */
--- a/jdk/test/java/lang/Double/ParseHexFloatingPoint.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/Double/ParseHexFloatingPoint.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,7 @@
 
 /*
  * @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main ParseHexFloatingPoint
  * @bug 4826774 8078672
  * @summary Numerical tests for hexadecimal inputs to parse{Double, Float} (use -Dseed=X to set PRNG seed)
@@ -32,7 +31,7 @@
  * @key randomness
  */
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class ParseHexFloatingPoint {
     private ParseHexFloatingPoint(){}
--- a/jdk/test/java/lang/Integer/BitTwiddle.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/Integer/BitTwiddle.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,7 @@
 
 /*
  * @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main BitTwiddle
  * @bug     4495754 8078672
  * @summary Basic test for int bit twiddling (use -Dseed=X to set PRNG seed)
@@ -33,7 +32,7 @@
  */
 
 import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 import static java.lang.Integer.*;
 
 public class BitTwiddle {
--- a/jdk/test/java/lang/Long/BitTwiddle.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/Long/BitTwiddle.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,7 @@
 
 /*
  * @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main BitTwiddle
  * @bug     4495754 8078672
  * @summary Basic test for long bit twiddling (use -Dseed=X to set PRNG seed)
@@ -33,7 +32,7 @@
  */
 
 import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 import static java.lang.Long.*;
 
 public class BitTwiddle {
--- a/jdk/test/java/lang/Math/CubeRootTests.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/Math/CubeRootTests.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,7 @@
 
 /*
  * @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
  * @run main CubeRootTests
  * @bug 4347132 4939441 8078672
  * @summary Tests for {Math, StrictMath}.cbrt (use -Dseed=X to set PRNG seed)
@@ -32,7 +31,7 @@
  * @key randomness
  */
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class CubeRootTests {
     private CubeRootTests(){}
--- a/jdk/test/java/lang/Math/HypotTests.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/Math/HypotTests.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,7 @@
 
 /*
  * @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
  * @run main HypotTests
  * @bug 4851638 4939441 8078672
  * @summary Tests for {Math, StrictMath}.hypot (use -Dseed=X to set PRNG seed)
@@ -32,7 +31,7 @@
  * @key randomness
  */
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class HypotTests {
     private HypotTests(){}
--- a/jdk/test/java/lang/Math/IeeeRecommendedTests.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/Math/IeeeRecommendedTests.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,7 @@
 
 /*
  * @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
  * @run main IeeeRecommendedTests
  * @bug 4860891 4826732 4780454 4939441 4826652 8078672
  * @summary Tests for IEEE 754[R] recommended functions and similar methods (use -Dseed=X to set PRNG seed)
@@ -32,7 +31,7 @@
  * @key randomness
  */
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class IeeeRecommendedTests {
     private IeeeRecommendedTests(){}
--- a/jdk/test/java/lang/Math/Log1pTests.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/Math/Log1pTests.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,7 @@
 
 /*
  * @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
  * @run main Log1pTests
  * @bug 4851638 4939441 8078672
  * @summary Tests for {Math, StrictMath}.log1p (use -Dseed=X to set PRNG seed)
@@ -32,7 +31,7 @@
  * @key randomness
  */
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class Log1pTests {
     private Log1pTests(){}
--- a/jdk/test/java/lang/Math/MultiplicationTests.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/Math/MultiplicationTests.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,7 @@
 
 /*
  * @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main MultiplicationTests
  * @bug 5100935
  * @summary Tests for multiplication methods (use -Dseed=X to set PRNG seed)
@@ -32,7 +31,7 @@
  */
 
 import java.math.BigInteger;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class MultiplicationTests {
     private MultiplicationTests(){}
--- a/jdk/test/java/lang/ModuleLayer/LayerAndLoadersTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/ModuleLayer/LayerAndLoadersTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build LayerAndLoadersTest CompilerUtils ModuleUtils
+ * @build LayerAndLoadersTest jdk.test.lib.compiler.CompilerUtils ModuleUtils
  * @run testng LayerAndLoadersTest
  * @summary Tests for java.lang.ModuleLayer@defineModulesWithXXX methods
  */
@@ -48,6 +48,7 @@
 import java.util.ServiceLoader;
 import java.util.Set;
 import java.util.stream.Collectors;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/jdk/test/java/lang/ModuleTests/access/AccessTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/ModuleTests/access/AccessTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.executeTestJava;
 
 import org.testng.annotations.BeforeTest;
@@ -34,9 +35,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build AccessTest CompilerUtils jdk.testlibrary.*
+ * @build AccessTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run testng AccessTest
  * @summary Driver for test that checks access to access to types in
  *          exported and non-exported packages.
--- a/jdk/test/java/lang/StackTraceElement/WithClassLoaderName.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/StackTraceElement/WithClassLoaderName.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,7 +25,7 @@
  * @test
  * @bug 6479237
  * @summary Basic test StackTraceElement with class loader names
- * @library lib /lib/testlibrary
+ * @library lib /lib/testlibrary /test/lib
  * @modules jdk.compiler
  * @build m1/* WithClassLoaderName
  * @run main/othervm m1/com.app.Main
@@ -39,6 +39,8 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+import jdk.test.lib.compiler.CompilerUtils;
+
 import com.app.Utils;
 
 public class WithClassLoaderName {
--- a/jdk/test/java/lang/StackWalker/StackWalkTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/StackWalker/StackWalkTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,14 +31,13 @@
 import java.util.Set;
 import java.util.TreeSet;
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /**
  * @test
  * @bug 8140450
  * @summary Stack Walk Test (use -Dseed=X to set PRNG seed)
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @compile StackRecorderUtil.java
  * @run main/othervm StackWalkTest
  * @run main/othervm/java.security.policy=stackwalktest.policy StackWalkTest
--- a/jdk/test/java/lang/StrictMath/CubeRootTests.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/StrictMath/CubeRootTests.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,7 @@
  * @test
  * @bug 4347132 8136799
  * @key randomness
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
  * @build Tests
  * @build FdlibmTranslit
  * @build CubeRootTests
@@ -35,7 +34,7 @@
  * @author Joseph D. Darcy
  */
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /**
  * The tests in ../Math/CubeRootTests.java test properties that should
--- a/jdk/test/java/lang/StrictMath/ExpTests.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/StrictMath/ExpTests.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,7 @@
  * @test
  * @bug 8139688
  * @key randomness
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
  * @build Tests
  * @build FdlibmTranslit
  * @build ExpTests
@@ -34,7 +33,7 @@
  * @summary Tests specifically for StrictMath.exp
  */
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /**
  * The role of this test is to verify that the FDLIBM exp algorithm is
--- a/jdk/test/java/lang/StrictMath/HypotTests.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/StrictMath/HypotTests.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,7 @@
  * @bug 4851638
  * @key randomness
  * @summary Tests for StrictMath.hypot
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
  * @build Tests
  * @build FdlibmTranslit
  * @build HypotTests
@@ -35,7 +34,7 @@
  * @author Joseph D. Darcy
  */
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /**
  * The tests in ../Math/HypotTests.java test properties that should
--- a/jdk/test/java/lang/String/CompactString/SerializationTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/String/CompactString/SerializationTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,13 @@
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import static jdk.testlibrary.SerializationUtils.*;
+import static jdk.test.lib.util.SerializationUtils.*;
 import static org.testng.Assert.assertEquals;
 
 /*
  * @test
  * @bug 8077559
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SerializationUtils
+ * @library /test/lib
  * @summary Tests Compact String. This one is testing String serialization
  *          among -XX:+CompactStrings/-XX:-CompactStrings/LegacyString
  * @run testng/othervm -XX:+CompactStrings SerializationTest
--- a/jdk/test/java/lang/String/LiteralReplace.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/String/LiteralReplace.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,7 @@
 
 /* @test
  * @bug 8058779 8054307
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
  * @run testng LiteralReplace
  * @summary Basic tests of String.replace(CharSequence, CharSequence)
  * @key randomness
@@ -37,7 +36,7 @@
 import java.util.regex.Pattern;
 import java.util.Random;
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 import org.testng.annotations.Test;
 import org.testng.annotations.DataProvider;
--- a/jdk/test/java/lang/StringBuffer/CompactStringBufferSerialization.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/StringBuffer/CompactStringBufferSerialization.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,14 +26,13 @@
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import static jdk.testlibrary.SerializationUtils.*;
+import static jdk.test.lib.util.SerializationUtils.*;
 import static org.testng.Assert.*;
 
 /*
  * @test
  * @bug 8077559
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SerializationUtils
+ * @library /test/lib
  * @summary Tests Compact String. This one is testing StringBuffer serialization
  *          among -XX:+CompactStrings/-XX:-CompactStrings/LegacyStringBuffer
  * @run testng/othervm -XX:+CompactStrings CompactStringBufferSerialization
--- a/jdk/test/java/lang/StringBuilder/CompactStringBuilderSerialization.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/StringBuilder/CompactStringBuilderSerialization.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,14 +26,13 @@
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import static jdk.testlibrary.SerializationUtils.*;
+import static jdk.test.lib.util.SerializationUtils.*;
 import static org.testng.Assert.*;
 
 /*
  * @test
  * @bug 8077559
- * @library /lib/testlibrary
- * @build jdk.testlibrary.SerializationUtils
+ * @library /test/lib
  * @summary Tests Compact String. This one is testing StringBuilder serialization
  *          among -XX:+CompactStrings/-XX:-CompactStrings/LegacyStringBuilder
  * @run testng/othervm -XX:+CompactStrings CompactStringBuilderSerialization
--- a/jdk/test/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/System/LoggerFinder/LoggerFinderAPI/LoggerFinderAPI.java	Wed Jul 05 23:37:13 2017 +0200
@@ -28,17 +28,18 @@
 import java.lang.System.Logger;
 import java.lang.System.Logger.Level;
 import java.lang.System.LoggerFinder;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.Locale;
+import java.util.Map;
 import java.util.Objects;
 import java.util.ResourceBundle;
-import java.util.concurrent.ConcurrentHashMap;
 // Can't use testng because testng requires java.logging
 //import org.testng.annotations.Test;
 
 /**
  * @test
- * @bug 8177835
+ * @bug 8177835 8179222
  * @summary Checks that the DefaultLoggerFinder and LoggingProviderImpl
  *          implementations of the System.LoggerFinder conform to the
  *          LoggerFinder specification, in particular with respect to
@@ -60,6 +61,8 @@
     static final String JDK_FORMAT_PROP_KEY = "jdk.system.logger.format";
     static final String JUL_FORMAT_PROP_KEY =
         "java.util.logging.SimpleFormatter.format";
+    static final String MESSAGE = "{0} with {1}: PASSED";
+    static final String LOCALIZED = "[localized] ";
 
     static class RecordStream extends OutputStream {
         static final Object LOCK = new Object[0];
@@ -106,15 +109,28 @@
     }
 
     public static class MyResourceBundle extends ResourceBundle {
-        final ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
+        final Map<String, String> map = Map.of(MESSAGE, LOCALIZED + MESSAGE);
         @Override
         protected Object handleGetObject(String string) {
-            return map.computeIfAbsent(string, s -> "[localized] " + s);
+            return map.get(string);
         }
 
         @Override
         public Enumeration<String> getKeys() {
-            return map.keys();
+            return Collections.enumeration(map.keySet());
+        }
+
+    }
+
+    public static class EmptyResourceBundle extends ResourceBundle {
+        @Override
+        protected Object handleGetObject(String string) {
+            return null;
+        }
+
+        @Override
+        public Enumeration<String> getKeys() {
+            return Collections.emptyEnumeration();
         }
 
     }
@@ -129,17 +145,23 @@
 
         LoggerFinderAPI apiTest = new LoggerFinderAPI();
         for (Object[] params : getLoggerDataProvider()) {
+            @SuppressWarnings("unchecked")
+            Class<? extends Throwable> throwableClass  =
+                    Throwable.class.getClass().cast(params[3]);
             apiTest.testGetLogger((String)params[0],
                                   (String)params[1],
                                   (Module)params[2],
-                                  Throwable.class.getClass().cast(params[3]));
+                                  throwableClass);
         }
         for (Object[] params : getLocalizedLoggerDataProvider()) {
+            @SuppressWarnings("unchecked")
+            Class<? extends Throwable> throwableClass =
+                    Throwable.class.getClass().cast(params[4]);
             apiTest.testGetLocalizedLogger((String)params[0],
                                   (String)params[1],
                                   (ResourceBundle)params[2],
                                   (Module)params[3],
-                                  Throwable.class.getClass().cast(params[4]));
+                                  throwableClass);
         }
     }
 
@@ -158,15 +180,16 @@
             // Make sure we don't fail if tests are run in parallel
             synchronized(RecordStream.LOCK) {
                 LOG_STREAM.startRecording();
+                byte[] logged = null;
                 try {
                     logger.log(Level.INFO, "{0} with {1}: PASSED",
                                "LoggerFinder.getLogger",
                                desc);
                 } finally {
-                    byte[] logged = LOG_STREAM.stopRecording();
-                    check(logged, "testGetLogger", desc, null,
-                          "LoggerFinder.getLogger");
+                    logged = LOG_STREAM.stopRecording();
                 }
+                check(logged, "testGetLogger", desc, null,
+                      "LoggerFinder.getLogger");
             }
         } catch (Throwable x) {
             if (thrown != null && thrown.isInstance(x)) {
@@ -192,15 +215,16 @@
             // Make sure we don't fail if tests are run in parallel
             synchronized(RecordStream.LOCK) {
                 LOG_STREAM.startRecording();
+                byte[] logged = null;
                 try {
-                    logger.log(Level.INFO, "{0} with {1}: PASSED",
+                    logger.log(Level.INFO, MESSAGE,
                               "LoggerFinder.getLocalizedLogger",
                               desc);
                 } finally {
-                    byte[] logged = LOG_STREAM.stopRecording();
-                    check(logged, "testGetLocalizedLogger", desc, bundle,
-                          "LoggerFinder.getLocalizedLogger");
+                   logged = LOG_STREAM.stopRecording();
                 }
+                check(logged, "testGetLocalizedLogger", desc, bundle,
+                      "LoggerFinder.getLocalizedLogger");
             }
         } catch (Throwable x) {
             if (thrown != null && thrown.isInstance(x)) {
@@ -213,9 +237,11 @@
     private void check(byte[] logged, String test, String desc,
                        ResourceBundle bundle, String meth) {
         String msg = new String(logged);
+        String localizedPrefix =
+                ((bundle==null || bundle==EMPTY_BUNDLE)?"":LOCALIZED);
         String expected = String.format(TEST_FORMAT, null,
                 "LoggerFinderAPI " + test, null, Level.INFO.name(),
-                (bundle==null?"":"[localized] ") + meth + " with " + desc + ": PASSED",
+                localizedPrefix + meth + " with " + desc + ": PASSED",
                 "");
         if (!Objects.equals(msg, expected)) {
             throw new AssertionError("Expected log message not found: "
@@ -227,6 +253,7 @@
 
     static final Module MODULE = LoggerFinderAPI.class.getModule();
     static final ResourceBundle BUNDLE = new MyResourceBundle();
+    static final ResourceBundle EMPTY_BUNDLE = new EmptyResourceBundle();
     static final Object[][] GET_LOGGER = {
         {"null name", null, MODULE , NullPointerException.class},
         {"null module", "foo", null, NullPointerException.class},
@@ -236,12 +263,15 @@
     static final Object[][] GET_LOCALIZED_LOGGER = {
         {"null name", null, BUNDLE, MODULE , NullPointerException.class},
         {"null module", "foo", BUNDLE, null, NullPointerException.class},
-        {"null name and module", null, BUNDLE, null, NullPointerException.class},
-        {"non null name and module", "foo", BUNDLE, MODULE, null},
+        {"null name and module, non null bundle", null, BUNDLE, null, NullPointerException.class},
+        {"non null name, module, and bundle", "foo", BUNDLE, MODULE, null},
         {"null name and bundle", null, null, MODULE , NullPointerException.class},
         {"null module and bundle", "foo", null, null, NullPointerException.class},
         {"null name and module and bundle", null, null, null, NullPointerException.class},
         {"non null name and module, null bundle", "foo", null, MODULE, null},
+        // tests that MissingResourceBundle is not propagated to the caller of
+        // logger.log() if the key is not found in the resource bundle
+        {"non null name, module, and empty bundle", "foo", EMPTY_BUNDLE, MODULE, null},
     };
     public static Object[][] getLoggerDataProvider() {
         return GET_LOGGER;
--- a/jdk/test/java/lang/System/LoggerFinder/modules/Base.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/System/LoggerFinder/modules/Base.java	Wed Jul 05 23:37:13 2017 +0200
@@ -33,6 +33,7 @@
 import java.util.stream.Stream;
 
 import jdk.testlibrary.JDKToolFinder;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import static jdk.testlibrary.ProcessTools.executeCommand;
 
--- a/jdk/test/java/lang/System/LoggerFinder/modules/JDKLoggerForImageTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/System/LoggerFinder/modules/JDKLoggerForImageTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -45,8 +45,8 @@
  *               patched system module, or Xbootclasspath
  *          This test does not require existence of java.logging module,
  *          but require jdk.compiler module
- * @library /lib/testlibrary
- * @build Base CompilerUtils jdk.testlibrary.*
+ * @library /lib/testlibrary /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run main/othervm JDKLoggerForImageTest
  */
 
--- a/jdk/test/java/lang/System/LoggerFinder/modules/JDKLoggerForJDKTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/System/LoggerFinder/modules/JDKLoggerForJDKTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -45,8 +45,8 @@
  *            2. clients are in named/unnamed module,
  *               patched system module, or Xbootclasspath
  *          This test DOES require existence of java.logging module
- * @library /lib/testlibrary
- * @build Base CompilerUtils jdk.testlibrary.*
+ * @library /lib/testlibrary /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run main/othervm JDKLoggerForJDKTest
  */
 
--- a/jdk/test/java/lang/System/LoggerFinder/modules/LoggerInImageTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/System/LoggerFinder/modules/LoggerInImageTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -45,8 +45,8 @@
  *               patched system module, or Xbootclasspath
  *          This test does not require existence of java.logging module,
  *          but require jdk.compiler module
- * @library /lib/testlibrary
- * @build Base CompilerUtils jdk.testlibrary.*
+ * @library /lib/testlibrary /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run main/othervm LoggerInImageTest
  */
 
--- a/jdk/test/java/lang/System/LoggerFinder/modules/NamedLoggerForImageTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/System/LoggerFinder/modules/NamedLoggerForImageTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -45,8 +45,8 @@
  *               patched system module, or Xbootclasspath
  *          This test does not require existence of java.logging module,
  *          but require jdk.compiler module
- * @library /lib/testlibrary
- * @build Base CompilerUtils jdk.testlibrary.*
+ * @library /lib/testlibrary /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run main/othervm NamedLoggerForImageTest
  */
 
--- a/jdk/test/java/lang/System/LoggerFinder/modules/NamedLoggerForJDKTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/System/LoggerFinder/modules/NamedLoggerForJDKTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -45,8 +45,8 @@
  *               patched system module, or Xbootclasspath
  *          This test does not require existence of java.logging module,
  *          but require jdk.compiler module
- * @library /lib/testlibrary
- * @build Base CompilerUtils jdk.testlibrary.*
+ * @library /lib/testlibrary /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run main/othervm NamedLoggerForJDKTest
  */
 
--- a/jdk/test/java/lang/System/LoggerFinder/modules/UnnamedLoggerForImageTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/System/LoggerFinder/modules/UnnamedLoggerForImageTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -45,8 +45,8 @@
  *               patched system module, or Xbootclasspath
  *          This test does not require existence of java.logging module,
  *          but require jdk.compiler module
- * @library /lib/testlibrary
- * @build Base CompilerUtils jdk.testlibrary.*
+ * @library /lib/testlibrary /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run main/othervm UnnamedLoggerForImageTest
  */
 
--- a/jdk/test/java/lang/System/LoggerFinder/modules/UnnamedLoggerForJDKTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/System/LoggerFinder/modules/UnnamedLoggerForJDKTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -45,8 +45,8 @@
  *               patched system module, or Xbootclasspath
  *          This test does not require existence of java.logging module,
  *          but require jdk.compiler module
- * @library /lib/testlibrary
- * @build Base CompilerUtils jdk.testlibrary.*
+ * @library /lib/testlibrary /test/lib
+ * @build Base jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run main/othervm UnnamedLoggerForJDKTest
  */
 
--- a/jdk/test/java/lang/Thread/ThreadStateController.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/Thread/ThreadStateController.java	Wed Jul 05 23:37:13 2017 +0200
@@ -27,7 +27,7 @@
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.LockSupport;
 
-import jdk.testlibrary.LockFreeLogManager;
+import jdk.test.lib.LockFreeLogger;
 import jdk.testlibrary.Utils;
 
 /**
@@ -100,7 +100,7 @@
     private final AtomicInteger iterations = new AtomicInteger();
     private final AtomicInteger interrupted = new AtomicInteger();
 
-    private final LockFreeLogManager logManager = new LockFreeLogManager();
+    private final LockFreeLogger logger = new LockFreeLogger();
 
     @Override
     public void run() {
@@ -349,7 +349,7 @@
     }
 
     private void log(String msg, Object ... params) {
-        logManager.log(msg, params);
+        logger.log(msg, params);
     }
 
     /**
@@ -361,6 +361,6 @@
     public String getLog() throws InterruptedException {
         this.join();
 
-        return logManager.toString();
+        return logger.toString();
     }
 }
--- a/jdk/test/java/lang/Thread/ThreadStateTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/Thread/ThreadStateTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -31,6 +31,7 @@
  *
  * @author  Mandy Chung
  * @library /lib/testlibrary
+ * @library /test/lib
  * @build jdk.testlibrary.*
  * @build ThreadStateTest ThreadStateController
  * @run main/othervm -Xmixed ThreadStateTest
--- a/jdk/test/java/lang/annotation/AnnotationType/AnnotationTypeRuntimeAssumptionTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/annotation/AnnotationType/AnnotationTypeRuntimeAssumptionTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,6 @@
  * @test
  * @summary Test consistent parsing of ex-RUNTIME annotations that
  *          were changed and separately compiled to have CLASS retention
- * @library /lib/testlibrary
- * @build jdk.testlibrary.IOUtils
  * @run main AnnotationTypeRuntimeAssumptionTest
  */
 
@@ -35,8 +33,6 @@
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 
-import jdk.testlibrary.IOUtils;
-
 import static java.lang.annotation.RetentionPolicy.CLASS;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
@@ -140,7 +136,7 @@
                 String altPath = altName.replace('.', '/').concat(".class");
                 try (InputStream is = getResourceAsStream(altPath)) {
                     if (is != null) {
-                        byte[] bytes = IOUtils.readFully(is);
+                        byte[] bytes = is.readAllBytes();
                         // patch class bytes to contain original name
                         for (int i = 0; i < bytes.length - 2; i++) {
                             if (bytes[i] == '_' &&
@@ -163,7 +159,7 @@
                 String path = name.replace('.', '/').concat(".class");
                 try (InputStream is = getResourceAsStream(path)) {
                     if (is != null) {
-                        byte[] bytes = IOUtils.readFully(is);
+                        byte[] bytes = is.readAllBytes();
                         return defineClass(name, bytes, 0, bytes.length);
                     }
                     else {
--- a/jdk/test/java/lang/invoke/ExplicitCastArgumentsTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/invoke/ExplicitCastArgumentsTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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
@@ -21,7 +21,9 @@
  * questions.
  */
 
-import com.oracle.testlibrary.jsr292.Helper;
+import sun.invoke.util.Wrapper;
+import test.java.lang.invoke.lib.Helper;
+
 import java.io.File;
 import java.io.Serializable;
 import java.lang.invoke.MethodHandle;
@@ -31,13 +33,12 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Random;
-import sun.invoke.util.Wrapper;
 
 /*
  * @test
  * @bug 8060483 8066746
  * @key randomness
- * @library /lib/testlibrary /lib/testlibrary/jsr292
+ * @library /lib/testlibrary /java/lang/invoke/common
  * @modules java.base/sun.invoke.util
  * @summary unit tests for MethodHandles.explicitCastArguments()
  * @run main ExplicitCastArgumentsTest
@@ -249,21 +250,27 @@
             for (Class parent : parents) {
                 for (int j = 0; j < children.length; j++) {
                     // Child type to parent type non-null conversion, shoud succeed
-                    testConversion(mode, children[j], parent, childInst[j], childInst[j], false, null);
+                    testConversion(mode, children[j], parent, childInst[j],
+                            childInst[j], false, null);
                     // Child type to parent type null conversion, shoud succeed
-                    testConversion(mode, children[j], parent, null, null, false, null);
+                    testConversion(mode, children[j], parent, null,
+                            null, false, null);
                     // Parent type to child type non-null conversion with parent
                     // type instance, should fail
-                    testConversion(mode, parent, children[j], testSuperObj, null, true, ClassCastException.class);
+                    testConversion(mode, parent, children[j], testSuperObj,
+                            null, true, ClassCastException.class);
                     // Parent type to child type non-null conversion with child
                     // type instance, should succeed
-                    testConversion(mode, parent, children[j], childInst[j], childInst[j], false, null);
+                    testConversion(mode, parent, children[j], childInst[j],
+                            childInst[j], false, null);
                     // Parent type to child type null conversion, should succeed
-                    testConversion(mode, parent, children[j], null, null, false, null);
+                    testConversion(mode, parent, children[j], null,
+                            null, false, null);
                 }
                 // Parent type to child type non-null conversion with sibling
                 // type instance, should fail
-                testConversion(mode, parent, testSubClass1, testObj02, null, true, ClassCastException.class);
+                testConversion(mode, parent, testSubClass1, testObj02,
+                        null, true, ClassCastException.class);
             }
             // Sibling type non-null conversion, should fail
             testConversion(mode, testSubClass1,
--- a/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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
@@ -28,11 +28,15 @@
  * @ignore 8078602
  * @summary Test verifies that lambda forms are garbage collected
  * @author kshefov
- * @library /lib/testlibrary/jsr292 /lib/testlibrary
+ * @library /lib/testlibrary /java/lang/invoke/common
  * @build TestMethods
  * @build LambdaFormTestCase
  * @build LFGarbageCollectedTest
- * @run main/othervm -Xmx64m -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+HeapDumpOnOutOfMemoryError -DHEAP_DUMP=false LFGarbageCollectedTest
+ * @run main/othervm -Xmx64m
+ *                   -XX:SoftRefLRUPolicyMSPerMB=0
+ *                   -XX:+HeapDumpOnOutOfMemoryError
+ *                   -DHEAP_DUMP=false
+ *                   LFGarbageCollectedTest
  */
 
 import java.lang.invoke.MethodHandle;
@@ -82,9 +86,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;
             }
 
--- a/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -27,7 +27,7 @@
  * @key randomness
  * @summary Test verifies that lambda forms are cached when run with multiple threads
  * @author kshefov
- * @library /lib/testlibrary/jsr292 /lib/testlibrary
+ * @library /lib/testlibrary /java/lang/invoke/common
  * @modules java.base/java.lang.invoke:open
  *          java.base/java.lang.ref:open
  *          java.management
@@ -38,16 +38,16 @@
  * @run main/othervm LFMultiThreadCachingTest
  */
 
+import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
+
 import java.lang.invoke.MethodHandle;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.concurrent.BrokenBarrierException;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.CyclicBarrier;
-import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
 
 /**
  * Multiple threaded lambda forms caching test class.
@@ -57,13 +57,16 @@
     private static final TestMethods.Kind[] KINDS;
 
     static {
-        EnumSet<TestMethods.Kind> set = EnumSet.complementOf(EnumSet.of(TestMethods.Kind.EXCEPT));
+        EnumSet<TestMethods.Kind> set
+                = EnumSet.complementOf(EnumSet.of(TestMethods.Kind.EXCEPT));
         KINDS = set.toArray(new TestMethods.Kind[set.size()]);
         if (KINDS.length < 2) {
-            throw new Error("TESTBUG: KINDS.length[" + KINDS.length + "] should be at least 2");
+            throw new Error("TESTBUG: KINDS.length[" + KINDS.length
+                    + "] should be at least 2");
         }
     }
-    private static final int CORES = Math.max(KINDS.length, Runtime.getRuntime().availableProcessors());
+    private static final int CORES
+            = Math.max(KINDS.length, Runtime.getRuntime().availableProcessors());
 
     /**
      * Constructor a for multiple threaded lambda forms caching test case.
@@ -144,6 +147,7 @@
      * @param args Accepts no arguments.
      */
     public static void main(String[] args) {
-        LambdaFormTestCase.runTests(LFMultiThreadCachingTest::new, EnumSet.allOf(TestMethods.class));
+        LambdaFormTestCase.runTests(LFMultiThreadCachingTest::new,
+                                    EnumSet.allOf(TestMethods.class));
     }
 }
--- a/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -27,7 +27,7 @@
  * @key randomness
  * @summary Test verifies that lambda forms are cached when run with single thread
  * @author kshefov
- * @library /lib/testlibrary/jsr292 /lib/testlibrary
+ * @library /lib/testlibrary /java/lang/invoke/common
  * @modules java.base/java.lang.ref:open
  *          java.base/java.lang.invoke:open
  *          java.management
@@ -77,6 +77,7 @@
      * @param args Accepts no arguments.
      */
     public static void main(String[] args) {
-        LambdaFormTestCase.runTests(LFSingleThreadCachingTest::new, EnumSet.allOf(TestMethods.class));
+        LambdaFormTestCase.runTests(LFSingleThreadCachingTest::new,
+                                    EnumSet.allOf(TestMethods.class));
     }
 }
--- a/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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
@@ -21,8 +21,11 @@
  * questions.
  */
 
-import com.oracle.testlibrary.jsr292.Helper;
-import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
+import jdk.testlibrary.TimeLimitedRunner;
+import jdk.testlibrary.Utils;
+import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
+import test.java.lang.invoke.lib.Helper;
+
 import java.lang.invoke.MethodHandle;
 import java.lang.management.GarbageCollectorMXBean;
 import java.lang.management.ManagementFactory;
@@ -32,8 +35,6 @@
 import java.util.Collection;
 import java.util.List;
 import java.util.function.Function;
-import jdk.testlibrary.Utils;
-import jdk.testlibrary.TimeLimitedRunner;
 
 /**
  * Lambda forms caching test case class. Contains all necessary test routines to
@@ -44,14 +45,15 @@
  */
 public abstract class LambdaFormTestCase {
 
-    private static final long TIMEOUT = Helper.IS_THOROUGH ? 0L : (long) (Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT) * 0.9);
+    private static final long TIMEOUT = Helper.IS_THOROUGH ?
+            0L : (long) (Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT) * 0.9);
 
     /**
      * Reflection link to {@code j.l.i.MethodHandle.internalForm} method. It is
      * 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 +66,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);
@@ -92,7 +94,8 @@
         long failCounter;
         boolean passed;
 
-        TestRun(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) {
+        TestRun(Function<TestMethods, LambdaFormTestCase> ctor,
+                Collection<TestMethods> testMethods) {
             this.ctor = ctor;
             this.testMethods = testMethods;
             long testCaseNum = testMethods.size();
@@ -175,10 +178,12 @@
      * object.
      * @param testMethods list of test methods
      */
-    public static void runTests(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) {
+    public static void runTests(Function<TestMethods, LambdaFormTestCase> ctor,
+                                Collection<TestMethods> testMethods) {
         LambdaFormTestCase.TestRun run
                 = new LambdaFormTestCase.TestRun(ctor, testMethods);
-        TimeLimitedRunner runner = new TimeLimitedRunner(TIMEOUT, 4.0d, run::doIteration);
+        TimeLimitedRunner runner
+                = new TimeLimitedRunner(TIMEOUT, 4.0d, run::doIteration);
         try {
             runner.call();
         } catch (Exception ex) {
--- a/jdk/test/java/lang/invoke/LFCaching/TestMethods.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/invoke/LFCaching/TestMethods.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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
@@ -21,7 +21,8 @@
  * questions.
  */
 
-import com.oracle.testlibrary.jsr292.Helper;
+import test.java.lang.invoke.lib.Helper;
+
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
@@ -41,462 +42,472 @@
 public enum TestMethods {
 
     FOLD_ARGUMENTS("foldArguments") {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    // Arity after reducing because of long and double take 2 slots.
-                    int realArity = mtTarget.parameterCount();
-                    int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
-                    data.put("modifierMHArgNum", modifierMHArgNum);
-                    Class<?> combinerReturnType;
-                    if (realArity == 0) {
-                        combinerReturnType = void.class;
-                    } else {
-                        combinerReturnType = Helper.RNG.nextBoolean() ? void.class : mtTarget.parameterType(0);
-                    }
-                    data.put("combinerReturnType", combinerReturnType);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            // Arity after reducing because of long and double take 2 slots.
+            int realArity = mtTarget.parameterCount();
+            int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
+            data.put("modifierMHArgNum", modifierMHArgNum);
+            Class<?> combinerReturnType;
+            if (realArity == 0) {
+                combinerReturnType = void.class;
+            } else {
+                combinerReturnType = Helper.RNG.nextBoolean() ?
+                        void.class : mtTarget.parameterType(0);
+            }
+            data.put("combinerReturnType", combinerReturnType);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    Class<?> combinerReturnType = (Class) data.get("combinerReturnType");
-                    int modifierMHArgNum = (int) data.get("modifierMHArgNum");
-                    MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
-                            mtTarget.parameterList(), kind);
-                    Class<?> rType = mtTarget.returnType();
-                    int combListStart = (combinerReturnType == void.class) ? 0 : 1;
-                    if (modifierMHArgNum < combListStart) {
-                        modifierMHArgNum = combListStart;
-                    }
-                    MethodHandle combiner = TestMethods.methodHandleGenerator(combinerReturnType,
-                            mtTarget.parameterList().subList(combListStart,
-                                    modifierMHArgNum), kind);
-                    return MethodHandles.foldArguments(target, combiner);
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
+                throws NoSuchMethodException, IllegalAccessException {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            Class<?> combinerReturnType = (Class) data.get("combinerReturnType");
+            int modifierMHArgNum = (int) data.get("modifierMHArgNum");
+            MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
+                    mtTarget.parameterList(), kind);
+            Class<?> rType = mtTarget.returnType();
+            int combListStart = (combinerReturnType == void.class) ? 0 : 1;
+            if (modifierMHArgNum < combListStart) {
+                modifierMHArgNum = combListStart;
+            }
+            MethodHandle combiner = TestMethods.methodHandleGenerator(combinerReturnType,
+                    mtTarget.parameterList().subList(combListStart,
+                            modifierMHArgNum), kind);
+            return MethodHandles.foldArguments(target, combiner);
+        }
+    },
     DROP_ARGUMENTS("dropArguments") {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    // Arity after reducing because of long and double take 2 slots.
-                    int realArity = mtTarget.parameterCount();
-                    int dropArgsPos = Helper.RNG.nextInt(realArity + 1);
-                    data.put("dropArgsPos", dropArgsPos);
-                    MethodType mtDropArgs = TestMethods.randomMethodTypeGenerator(
-                            Helper.RNG.nextInt(super.maxArity - realArity));
-                    data.put("mtDropArgs", mtDropArgs);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            // Arity after reducing because of long and double take 2 slots.
+            int realArity = mtTarget.parameterCount();
+            int dropArgsPos = Helper.RNG.nextInt(realArity + 1);
+            data.put("dropArgsPos", dropArgsPos);
+            MethodType mtDropArgs = TestMethods.randomMethodTypeGenerator(
+                    Helper.RNG.nextInt(super.maxArity - realArity));
+            data.put("mtDropArgs", mtDropArgs);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    MethodType mtDropArgs = (MethodType) data.get("mtDropArgs");
-                    int dropArgsPos = (int) data.get("dropArgsPos");
-                    MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
-                            mtTarget.parameterList(), kind);
-                    int mtTgtSlotsCount = TestMethods.argSlotsCount(mtTarget);
-                    int mtDASlotsCount = TestMethods.argSlotsCount(mtDropArgs);
-                    List<Class<?>> fakeParList;
-                    if (mtTgtSlotsCount + mtDASlotsCount > super.maxArity - 1) {
-                        fakeParList = TestMethods.reduceArgListToSlotsCount(mtDropArgs.parameterList(),
-                                super.maxArity - mtTgtSlotsCount - 1);
-                    } else {
-                        fakeParList = mtDropArgs.parameterList();
-                    }
-                    return MethodHandles.dropArguments(target, dropArgsPos, fakeParList);
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
+                throws NoSuchMethodException, IllegalAccessException {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            MethodType mtDropArgs = (MethodType) data.get("mtDropArgs");
+            int dropArgsPos = (int) data.get("dropArgsPos");
+            MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
+                    mtTarget.parameterList(), kind);
+            int mtTgtSlotsCount = TestMethods.argSlotsCount(mtTarget);
+            int mtDASlotsCount = TestMethods.argSlotsCount(mtDropArgs);
+            List<Class<?>> fakeParList;
+            if (mtTgtSlotsCount + mtDASlotsCount > super.maxArity - 1) {
+                fakeParList = TestMethods.reduceArgListToSlotsCount(mtDropArgs.parameterList(),
+                        super.maxArity - mtTgtSlotsCount - 1);
+            } else {
+                fakeParList = mtDropArgs.parameterList();
+            }
+            return MethodHandles.dropArguments(target, dropArgsPos, fakeParList);
+        }
+    },
     EXPLICIT_CAST_ARGUMENTS("explicitCastArguments", Helper.MAX_ARITY / 2) {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    // Arity after reducing because of long and double take 2 slots.
-                    int realArity = mtTarget.parameterCount();
-                    MethodType mtExcplCastArgs = TestMethods.randomMethodTypeGenerator(realArity);
-                    if (mtTarget.returnType() == void.class) {
-                        mtExcplCastArgs = MethodType.methodType(void.class,
-                                mtExcplCastArgs.parameterArray());
-                    }
-                    if (mtExcplCastArgs.returnType() == void.class) {
-                        mtExcplCastArgs = MethodType.methodType(mtTarget.returnType(),
-                                mtExcplCastArgs.parameterArray());
-                    }
-                    data.put("mtExcplCastArgs", mtExcplCastArgs);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            // Arity after reducing because of long and double take 2 slots.
+            int realArity = mtTarget.parameterCount();
+            MethodType mtExcplCastArgs = TestMethods.randomMethodTypeGenerator(realArity);
+            if (mtTarget.returnType() == void.class) {
+                mtExcplCastArgs = MethodType.methodType(void.class,
+                        mtExcplCastArgs.parameterArray());
+            }
+            if (mtExcplCastArgs.returnType() == void.class) {
+                mtExcplCastArgs = MethodType.methodType(mtTarget.returnType(),
+                        mtExcplCastArgs.parameterArray());
+            }
+            data.put("mtExcplCastArgs", mtExcplCastArgs);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    MethodType mtExcplCastArgs = (MethodType) data.get("mtExcplCastArgs");
-                    MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
-                            mtTarget.parameterList(), kind);
-                    return MethodHandles.explicitCastArguments(target, mtExcplCastArgs);
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
+                throws NoSuchMethodException, IllegalAccessException {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            MethodType mtExcplCastArgs = (MethodType) data.get("mtExcplCastArgs");
+            MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
+                    mtTarget.parameterList(), kind);
+            return MethodHandles.explicitCastArguments(target, mtExcplCastArgs);
+        }
+    },
     FILTER_ARGUMENTS("filterArguments", Helper.MAX_ARITY / 2) {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    // Arity after reducing because of long and double take 2 slots.
-                    int realArity = mtTarget.parameterCount();
-                    int filterArgsPos = Helper.RNG.nextInt(realArity + 1);
-                    data.put("filterArgsPos", filterArgsPos);
-                    int filtersArgsArrayLength = Helper.RNG.nextInt(realArity + 1 - filterArgsPos);
-                    data.put("filtersArgsArrayLength", filtersArgsArrayLength);
-                    MethodType mtFilter = TestMethods.randomMethodTypeGenerator(filtersArgsArrayLength);
-                    data.put("mtFilter", mtFilter);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            // Arity after reducing because of long and double take 2 slots.
+            int realArity = mtTarget.parameterCount();
+            int filterArgsPos = Helper.RNG.nextInt(realArity + 1);
+            data.put("filterArgsPos", filterArgsPos);
+            int filtersArgsArrayLength = Helper.RNG.nextInt(realArity + 1 - filterArgsPos);
+            data.put("filtersArgsArrayLength", filtersArgsArrayLength);
+            MethodType mtFilter = TestMethods.randomMethodTypeGenerator(filtersArgsArrayLength);
+            data.put("mtFilter", mtFilter);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    MethodType mtFilter = (MethodType) data.get("mtFilter");
-                    int filterArgsPos = (int) data.get("filterArgsPos");
-                    int filtersArgsArrayLength = (int) data.get("filtersArgsArrayLength");
-                    MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
-                            mtTarget.parameterList(), kind);
-                    MethodHandle[] filters = new MethodHandle[filtersArgsArrayLength];
-                    for (int i = 0; i < filtersArgsArrayLength; i++) {
-                        filters[i] = TestMethods.filterGenerator(mtFilter.parameterType(i),
-                                mtTarget.parameterType(filterArgsPos + i), kind);
-                    }
-                    return MethodHandles.filterArguments(target, filterArgsPos, filters);
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
+                throws NoSuchMethodException, IllegalAccessException {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            MethodType mtFilter = (MethodType) data.get("mtFilter");
+            int filterArgsPos = (int) data.get("filterArgsPos");
+            int filtersArgsArrayLength = (int) data.get("filtersArgsArrayLength");
+            MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
+                    mtTarget.parameterList(), kind);
+            MethodHandle[] filters = new MethodHandle[filtersArgsArrayLength];
+            for (int i = 0; i < filtersArgsArrayLength; i++) {
+                filters[i] = TestMethods.filterGenerator(mtFilter.parameterType(i),
+                        mtTarget.parameterType(filterArgsPos + i), kind);
+            }
+            return MethodHandles.filterArguments(target, filterArgsPos, filters);
+        }
+    },
     FILTER_RETURN_VALUE("filterReturnValue") {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    // Arity after reducing because of long and double take 2 slots.
-                    int realArity = mtTarget.parameterCount();
-                    int filterArgsPos = Helper.RNG.nextInt(realArity + 1);
-                    int filtersArgsArrayLength = Helper.RNG.nextInt(realArity + 1 - filterArgsPos);
-                    MethodType mtFilter = TestMethods.randomMethodTypeGenerator(filtersArgsArrayLength);
-                    data.put("mtFilter", mtFilter);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            // Arity after reducing because of long and double take 2 slots.
+            int realArity = mtTarget.parameterCount();
+            int filterArgsPos = Helper.RNG.nextInt(realArity + 1);
+            int filtersArgsArrayLength = Helper.RNG.nextInt(realArity + 1 - filterArgsPos);
+            MethodType mtFilter = TestMethods.randomMethodTypeGenerator(filtersArgsArrayLength);
+            data.put("mtFilter", mtFilter);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    MethodType mtFilter = (MethodType) data.get("mtFilter");
-                    MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
-                            mtTarget.parameterList(), kind);
-                    MethodHandle filter = TestMethods.filterGenerator(mtTarget.returnType(),
-                            mtFilter.returnType(), kind);
-                    return MethodHandles.filterReturnValue(target, filter);
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
+                throws NoSuchMethodException, IllegalAccessException {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            MethodType mtFilter = (MethodType) data.get("mtFilter");
+            MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
+                    mtTarget.parameterList(), kind);
+            MethodHandle filter = TestMethods.filterGenerator(mtTarget.returnType(),
+                    mtFilter.returnType(), kind);
+            return MethodHandles.filterReturnValue(target, filter);
+        }
+    },
     INSERT_ARGUMENTS("insertArguments", Helper.MAX_ARITY - 3) {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    // Arity after reducing because of long and double take 2 slots.
-                    int realArity = mtTarget.parameterCount();
-                    int insertArgsPos = Helper.RNG.nextInt(realArity + 1);
-                    data.put("insertArgsPos", insertArgsPos);
-                    int insertArgsArrayLength = Helper.RNG.nextInt(realArity + 1 - insertArgsPos);
-                    MethodType mtInsertArgs = MethodType.methodType(void.class, mtTarget.parameterList()
-                            .subList(insertArgsPos, insertArgsPos + insertArgsArrayLength));
-                    data.put("mtInsertArgs", mtInsertArgs);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            // Arity after reducing because of long and double take 2 slots.
+            int realArity = mtTarget.parameterCount();
+            int insertArgsPos = Helper.RNG.nextInt(realArity + 1);
+            data.put("insertArgsPos", insertArgsPos);
+            int insertArgsArrayLength = Helper.RNG.nextInt(realArity + 1 - insertArgsPos);
+            MethodType mtInsertArgs = MethodType.methodType(void.class, mtTarget.parameterList()
+                    .subList(insertArgsPos, insertArgsPos + insertArgsArrayLength));
+            data.put("mtInsertArgs", mtInsertArgs);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    MethodType mtInsertArgs = (MethodType) data.get("mtInsertArgs");
-                    int insertArgsPos = (int) data.get("insertArgsPos");
-                    MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
-                            mtTarget.parameterList(), kind);
-                    Object[] insertList = Helper.randomArgs(mtInsertArgs.parameterList());
-                    return MethodHandles.insertArguments(target, insertArgsPos, insertList);
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
+                throws NoSuchMethodException, IllegalAccessException {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            MethodType mtInsertArgs = (MethodType) data.get("mtInsertArgs");
+            int insertArgsPos = (int) data.get("insertArgsPos");
+            MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
+                    mtTarget.parameterList(), kind);
+            Object[] insertList = Helper.randomArgs(mtInsertArgs.parameterList());
+            return MethodHandles.insertArguments(target, insertArgsPos, insertList);
+        }
+    },
     PERMUTE_ARGUMENTS("permuteArguments", Helper.MAX_ARITY / 2) {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    // Arity after reducing because of long and double take 2 slots.
-                    int realArity = mtTarget.parameterCount();
-                    int[] permuteArgsReorderArray = new int[realArity];
-                    int mtPermuteArgsNum = Helper.RNG.nextInt(Helper.MAX_ARITY);
-                    mtPermuteArgsNum = mtPermuteArgsNum == 0 ? 1 : mtPermuteArgsNum;
-                    MethodType mtPermuteArgs = TestMethods.randomMethodTypeGenerator(mtPermuteArgsNum);
-                    mtTarget = mtTarget.changeReturnType(mtPermuteArgs.returnType());
-                    for (int i = 0; i < realArity; i++) {
-                        int mtPermuteArgsParNum = Helper.RNG.nextInt(mtPermuteArgs.parameterCount());
-                        permuteArgsReorderArray[i] = mtPermuteArgsParNum;
-                        mtTarget = mtTarget.changeParameterType(
-                                i, mtPermuteArgs.parameterType(mtPermuteArgsParNum));
-                    }
-                    data.put("mtTarget", mtTarget);
-                    data.put("permuteArgsReorderArray", permuteArgsReorderArray);
-                    data.put("mtPermuteArgs", mtPermuteArgs);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            // Arity after reducing because of long and double take 2 slots.
+            int realArity = mtTarget.parameterCount();
+            int[] permuteArgsReorderArray = new int[realArity];
+            int mtPermuteArgsNum = Helper.RNG.nextInt(Helper.MAX_ARITY);
+            mtPermuteArgsNum = mtPermuteArgsNum == 0 ? 1 : mtPermuteArgsNum;
+            MethodType mtPermuteArgs = TestMethods.randomMethodTypeGenerator(mtPermuteArgsNum);
+            mtTarget = mtTarget.changeReturnType(mtPermuteArgs.returnType());
+            for (int i = 0; i < realArity; i++) {
+                int mtPermuteArgsParNum = Helper.RNG.nextInt(mtPermuteArgs.parameterCount());
+                permuteArgsReorderArray[i] = mtPermuteArgsParNum;
+                mtTarget = mtTarget.changeParameterType(
+                        i, mtPermuteArgs.parameterType(mtPermuteArgsParNum));
+            }
+            data.put("mtTarget", mtTarget);
+            data.put("permuteArgsReorderArray", permuteArgsReorderArray);
+            data.put("mtPermuteArgs", mtPermuteArgs);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    MethodType mtPermuteArgs = (MethodType) data.get("mtPermuteArgs");
-                    int[] permuteArgsReorderArray = (int[]) data.get("permuteArgsReorderArray");
-                    MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
-                            mtTarget.parameterList(), kind);
-                    return MethodHandles.permuteArguments(target, mtPermuteArgs, permuteArgsReorderArray);
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
+                throws NoSuchMethodException, IllegalAccessException {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            MethodType mtPermuteArgs = (MethodType) data.get("mtPermuteArgs");
+            int[] permuteArgsReorderArray = (int[]) data.get("permuteArgsReorderArray");
+            MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
+                    mtTarget.parameterList(), kind);
+            return MethodHandles.permuteArguments(target, mtPermuteArgs, permuteArgsReorderArray);
+        }
+    },
     THROW_EXCEPTION("throwException") {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    Class<?> rType = mtTarget.returnType();
-                    return MethodHandles.throwException(rType, Exception.class
-                    );
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            Class<?> rType = mtTarget.returnType();
+            return MethodHandles.throwException(rType, Exception.class
+            );
+        }
+    },
     GUARD_WITH_TEST("guardWithTest") {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    // Arity after reducing because of long and double take 2 slots.
-                    int realArity = mtTarget.parameterCount();
-                    int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
-                    data.put("modifierMHArgNum", modifierMHArgNum);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            // Arity after reducing because of long and double take 2 slots.
+            int realArity = mtTarget.parameterCount();
+            int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
+            data.put("modifierMHArgNum", modifierMHArgNum);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    int modifierMHArgNum = (int) data.get("modifierMHArgNum");
-                    TestMethods.Kind targetKind;
-                    TestMethods.Kind fallbackKind;
-                    if (kind.equals(TestMethods.Kind.ONE)) {
-                        targetKind = TestMethods.Kind.ONE;
-                        fallbackKind = TestMethods.Kind.TWO;
-                    } else {
-                        targetKind = TestMethods.Kind.TWO;
-                        fallbackKind = TestMethods.Kind.ONE;
-                    }
-                    MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
-                            mtTarget.parameterList(), targetKind);
-                    MethodHandle fallback = TestMethods.methodHandleGenerator(mtTarget.returnType(),
-                            mtTarget.parameterList(), fallbackKind);
-                    MethodHandle test = TestMethods.methodHandleGenerator(boolean.class,
-                            mtTarget.parameterList().subList(0, modifierMHArgNum), kind);
-                    return MethodHandles.guardWithTest(test, target, fallback);
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
+                throws NoSuchMethodException, IllegalAccessException {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            int modifierMHArgNum = (int) data.get("modifierMHArgNum");
+            TestMethods.Kind targetKind;
+            TestMethods.Kind fallbackKind;
+            if (kind.equals(TestMethods.Kind.ONE)) {
+                targetKind = TestMethods.Kind.ONE;
+                fallbackKind = TestMethods.Kind.TWO;
+            } else {
+                targetKind = TestMethods.Kind.TWO;
+                fallbackKind = TestMethods.Kind.ONE;
+            }
+            MethodHandle target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
+                    mtTarget.parameterList(), targetKind);
+            MethodHandle fallback = TestMethods.methodHandleGenerator(mtTarget.returnType(),
+                    mtTarget.parameterList(), fallbackKind);
+            MethodHandle test = TestMethods.methodHandleGenerator(boolean.class,
+                    mtTarget.parameterList().subList(0, modifierMHArgNum), kind);
+            return MethodHandles.guardWithTest(test, target, fallback);
+        }
+    },
     CATCH_EXCEPTION("catchException") {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    // Arity after reducing because of long and double take 2 slots.
-                    int realArity = mtTarget.parameterCount();
-                    int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
-                    data.put("modifierMHArgNum", modifierMHArgNum);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            // Arity after reducing because of long and double take 2 slots.
+            int realArity = mtTarget.parameterCount();
+            int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
+            data.put("modifierMHArgNum", modifierMHArgNum);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    int modifierMHArgNum = (int) data.get("modifierMHArgNum");
-                    MethodHandle target;
-                    if (kind.equals(TestMethods.Kind.ONE)) {
-                        target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
-                                mtTarget.parameterList(), TestMethods.Kind.ONE);
-                    } else {
-                        target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
-                                mtTarget.parameterList(), TestMethods.Kind.EXCEPT);
-                    }
-                    List<Class<?>> handlerParamList = new ArrayList<>(mtTarget.parameterCount() + 1);
-                    handlerParamList.add(Exception.class);
-                    handlerParamList.addAll(mtTarget.parameterList().subList(0, modifierMHArgNum));
-                    MethodHandle handler = TestMethods.methodHandleGenerator(
-                            mtTarget.returnType(), handlerParamList, TestMethods.Kind.TWO);
-                    return MethodHandles.catchException(target, Exception.class, handler);
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
+                throws NoSuchMethodException, IllegalAccessException {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            int modifierMHArgNum = (int) data.get("modifierMHArgNum");
+            MethodHandle target;
+            if (kind.equals(TestMethods.Kind.ONE)) {
+                target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
+                        mtTarget.parameterList(), TestMethods.Kind.ONE);
+            } else {
+                target = TestMethods.methodHandleGenerator(mtTarget.returnType(),
+                        mtTarget.parameterList(), TestMethods.Kind.EXCEPT);
+            }
+            List<Class<?>> handlerParamList = new ArrayList<>(mtTarget.parameterCount() + 1);
+            handlerParamList.add(Exception.class);
+            handlerParamList.addAll(mtTarget.parameterList().subList(0, modifierMHArgNum));
+            MethodHandle handler = TestMethods.methodHandleGenerator(
+                    mtTarget.returnType(), handlerParamList, TestMethods.Kind.TWO);
+            return MethodHandles.catchException(target, Exception.class, handler);
+        }
+    },
     INVOKER("invoker", Helper.MAX_ARITY - 1) {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    return MethodHandles.invoker(mtTarget);
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            return MethodHandles.invoker(mtTarget);
+        }
+    },
     EXACT_INVOKER("exactInvoker", Helper.MAX_ARITY - 1) {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    return MethodHandles.exactInvoker(mtTarget);
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            return MethodHandles.exactInvoker(mtTarget);
+        }
+    },
     SPREAD_INVOKER("spreadInvoker", Helper.MAX_ARITY - 1) {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    // Arity after reducing because of long and double take 2 slots.
-                    int realArity = mtTarget.parameterCount();
-                    int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
-                    data.put("modifierMHArgNum", modifierMHArgNum);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            // Arity after reducing because of long and double take 2 slots.
+            int realArity = mtTarget.parameterCount();
+            int modifierMHArgNum = Helper.RNG.nextInt(realArity + 1);
+            data.put("modifierMHArgNum", modifierMHArgNum);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    int modifierMHArgNum = (int) data.get("modifierMHArgNum");
-                    return MethodHandles.spreadInvoker(mtTarget, modifierMHArgNum);
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            int modifierMHArgNum = (int) data.get("modifierMHArgNum");
+            return MethodHandles.spreadInvoker(mtTarget, modifierMHArgNum);
+        }
+    },
     ARRAY_ELEMENT_GETTER("arrayElementGetter") {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    Class<?> rType = mtTarget.returnType();
-                    if (rType == void.class) {
-                        rType = Object.class;
-                    }
-                    return MethodHandles.arrayElementGetter(Array.newInstance(rType, 2).getClass());
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            Class<?> rType = mtTarget.returnType();
+            if (rType == void.class) {
+                rType = Object.class;
+            }
+            return MethodHandles.arrayElementGetter(Array.newInstance(rType, 2).getClass());
+        }
+    },
     ARRAY_ELEMENT_SETTER("arrayElementSetter") {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    Class<?> rType = mtTarget.returnType();
-                    if (rType == void.class) {
-                        rType = Object.class;
-                    }
-                    return MethodHandles.arrayElementSetter(Array.newInstance(rType, 2).getClass());
-                }
-            },
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            Class<?> rType = mtTarget.returnType();
+            if (rType == void.class) {
+                rType = Object.class;
+            }
+            return MethodHandles.arrayElementSetter(Array.newInstance(rType, 2).getClass());
+        }
+    },
     CONSTANT("constant") {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    return data;
-                }
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    Class<?> rType = mtTarget.returnType();
-                    if (rType == void.class) {
-                        rType = Object.class;
-                    }
-                    if (rType.equals(boolean.class)) {
-                        // There should be the same return values because for default values there are special "zero" forms
-                        return MethodHandles.constant(rType, true);
-                    } else {
-                        return MethodHandles.constant(rType, kind.getValue(rType));
-                    }
-                }
-            },
-    IDENTITY("identity") {
-                @Override
-                public Map<String, Object> getTestCaseData() {
-                    Map<String, Object> data = new HashMap<>();
-                    int desiredArity = Helper.RNG.nextInt(super.maxArity);
-                    MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
-                    data.put("mtTarget", mtTarget);
-                    return data;
-                }
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            Class<?> rType = mtTarget.returnType();
+            if (rType == void.class) {
+                rType = Object.class;
+            }
+            if (rType.equals(boolean.class)) {
+                // There should be the same return values because for default values there are special "zero" forms
+                return MethodHandles.constant(rType, true);
+            } else {
+                return MethodHandles.constant(rType, kind.getValue(rType));
+            }
+        }
+    },
+IDENTITY("identity") {
+        @Override
+        public Map<String, Object> getTestCaseData() {
+            Map<String, Object> data = new HashMap<>();
+            int desiredArity = Helper.RNG.nextInt(super.maxArity);
+            MethodType mtTarget = TestMethods.randomMethodTypeGenerator(desiredArity);
+            data.put("mtTarget", mtTarget);
+            return data;
+        }
 
-                @Override
-                protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
-                    MethodType mtTarget = (MethodType) data.get("mtTarget");
-                    Class<?> rType = mtTarget.returnType();
-                    if (rType == void.class) {
-                        rType = Object.class;
-                    }
-                    return MethodHandles.identity(rType);
-                }
-            };
+        @Override
+        protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) {
+            MethodType mtTarget = (MethodType) data.get("mtTarget");
+            Class<?> rType = mtTarget.returnType();
+            if (rType == void.class) {
+                rType = Object.class;
+            }
+            return MethodHandles.identity(rType);
+        }
+    };
 
     /**
      * Test method's name.
@@ -514,8 +525,10 @@
         this(name, Helper.MAX_ARITY);
     }
 
-    protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind) throws NoSuchMethodException, IllegalAccessException {
-        throw new UnsupportedOperationException("TESTBUG: getMH method is not implemented for test method " + this);
+    protected MethodHandle getMH(Map<String, Object> data, TestMethods.Kind kind)
+            throws NoSuchMethodException, IllegalAccessException {
+        throw new UnsupportedOperationException(
+                "TESTBUG: getMH method is not implemented for test method " + this);
     }
 
     /**
@@ -575,13 +588,15 @@
             return Helper.castToWrapper(value, cl);
         }
 
-        private MethodHandle getBasicMH(Class<?> rType) throws NoSuchMethodException, IllegalAccessException {
+        private MethodHandle getBasicMH(Class<?> rType)
+                throws NoSuchMethodException, IllegalAccessException {
             MethodHandle result = null;
             switch (this) {
                 case ONE:
                 case TWO:
                     if (rType.equals(void.class)) {
-                        result = MethodHandles.lookup().findVirtual(Kind.class, "returnVoid", MethodType.methodType(void.class));
+                        result = MethodHandles.lookup().findVirtual(Kind.class,
+                                "returnVoid", MethodType.methodType(void.class));
                         result = MethodHandles.insertArguments(result, 0, this);
                     } else {
                         result = MethodHandles.constant(rType, getValue(rType));
--- a/jdk/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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
@@ -20,25 +20,30 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
+
 package test.java.lang.invoke.MethodHandles;
 
-import com.oracle.testlibrary.jsr292.Helper;
-import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
 import jdk.testlibrary.Asserts;
 import jdk.testlibrary.TimeLimitedRunner;
 import jdk.testlibrary.Utils;
+import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
+import test.java.lang.invoke.lib.Helper;
 
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
 import java.lang.reflect.Array;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
 import java.util.function.BiFunction;
 import java.util.function.Function;
 import java.util.function.Supplier;
 
 /* @test
- * @library /lib/testlibrary/jsr292 /lib/testlibrary/
+ * @library /lib/testlibrary /java/lang/invoke/common
  * @compile CatchExceptionTest.java
  * @run main/othervm -esa test.java.lang.invoke.MethodHandles.CatchExceptionTest
  * @key intermittent randomness
@@ -68,8 +73,8 @@
     private int dropped;
     private MethodHandle thrower;
 
-    public CatchExceptionTest(TestCase testCase, final boolean isVararg, final int argsCount,
-            final int catchDrops) {
+    public CatchExceptionTest(TestCase testCase, final boolean isVararg,
+                              final int argsCount, final int catchDrops) {
         this.testCase = testCase;
         this.dropped = catchDrops;
         MethodHandle thrower = testCase.thrower;
@@ -353,8 +358,8 @@
                 new ClassCastException("testing"),
                 new java.io.IOException("testing"),
                 new LinkageError("testing")};
-        List<Supplier<TestCase>> list = new ArrayList<>(constructors.length *
-                throwables.length * ThrowMode.values().length);
+        List<Supplier<TestCase>> list = new ArrayList<>(constructors.length
+                * throwables.length * ThrowMode.values().length);
         //noinspection unchecked
         for (PartialConstructor f : constructors) {
             for (ThrowMode mode : ThrowMode.values()) {
--- a/jdk/test/java/lang/invoke/MethodHandlesTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/invoke/MethodHandlesTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
  * 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,23 +23,46 @@
 
 /* @test
  * @summary unit tests for java.lang.invoke.MethodHandles
- * @library /lib/testlibrary /lib/testlibrary/jsr292
+ * @library /lib/testlibrary /java/lang/invoke/common
  * @compile MethodHandlesTest.java remote/RemoteExample.java
- * @run junit/othervm/timeout=2500 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -esa test.java.lang.invoke.MethodHandlesTest
+ * @run junit/othervm/timeout=2500 -XX:+IgnoreUnrecognizedVMOptions
+ *                                 -XX:-VerifyDependencies
+ *                                 -esa
+ *                                 test.java.lang.invoke.MethodHandlesTest
  */
 
 package test.java.lang.invoke;
 
+import org.junit.*;
+import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
 import test.java.lang.invoke.remote.RemoteExample;
-import java.lang.invoke.*;
-import static java.lang.invoke.MethodType.methodType;
+
+import java.lang.invoke.CallSite;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandleProxies;
+import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodHandles.Lookup;
-import java.lang.reflect.*;
-import java.util.*;
-import org.junit.*;
+import java.lang.invoke.MethodType;
+import java.lang.invoke.MutableCallSite;
+import java.lang.invoke.WrongMethodTypeException;
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.UndeclaredThrowableException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Formatter;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static java.lang.invoke.MethodType.methodType;
 import static org.junit.Assert.*;
-import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
-
 
 /**
  *
--- a/jdk/test/java/lang/invoke/PermuteArgsTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/invoke/PermuteArgsTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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,9 +23,10 @@
 
 /* @test
  * @summary unit tests for method handles which permute their arguments
- * @library /lib/testlibrary/jsr292 /lib/testlibrary
+ * @library /lib/testlibrary /java/lang/invoke/common
  * @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -ea -esa -DPermuteArgsTest.MAX_ARITY=8 test.java.lang.invoke.PermuteArgsTest
  */
+
 /* Examples of manual runs:
  * java -DPermuteArgsTest.{DRY_RUN=true,MAX_ARITY=253} test.java.lang.invoke.PermuteArgsTest
  * java -DPermuteArgsTest.{VERBOSE=true,MAX_ARITY=5} test.java.lang.invoke.PermuteArgsTest
@@ -34,17 +35,23 @@
 
 package test.java.lang.invoke;
 
-import org.testng.*;
-import org.testng.annotations.*;
-
-import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
+import org.testng.annotations.Test;
+import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
 
-import java.util.*;
-import java.lang.reflect.*;
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodType;
+import java.lang.invoke.WrongMethodTypeException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
 
-import java.lang.invoke.*;
-import static java.lang.invoke.MethodHandles.*;
-import static java.lang.invoke.MethodType.*;
+import static java.lang.invoke.MethodHandles.Lookup;
+import static java.lang.invoke.MethodHandles.lookup;
+import static java.lang.invoke.MethodHandles.permuteArguments;
+import static java.lang.invoke.MethodType.methodType;
 
 public class PermuteArgsTest {
     private static final Class<?> CLASS = PermuteArgsTest.class;
@@ -205,7 +212,8 @@
             throw new IllegalArgumentException("cannot convert to type "+mt1+" from "+mh, ex);
         }
     }
-    static MethodHandle findTestMH(String name, int[] perm) throws ReflectiveOperationException {
+    static MethodHandle findTestMH(String name, int[] perm)
+            throws ReflectiveOperationException {
         int arity = perm.length;
         Lookup lookup = lookup();
         for (Method m : lookup.lookupClass().getDeclaredMethods()) {
@@ -259,7 +267,8 @@
         }
     }
 
-    static void testPermutations(MethodHandle mh, int[] perm, int start, int end, Set<String> done) throws Throwable {
+    static void testPermutations(MethodHandle mh, int[] perm, int start, int end,
+                                 Set<String> done) throws Throwable {
         if (end - start <= 1)  return;
         for (int j = 0; j <= 1; j++) {
             testRotations(mh, perm, start, end, done);
@@ -283,7 +292,8 @@
         }
     }
 
-    static void testRotations(MethodHandle mh, int[] perm, int start, int end, Set<String> done) throws Throwable {
+    static void testRotations(MethodHandle mh, int[] perm, int start, int end,
+                              Set<String> done) throws Throwable {
         Object[] args = junkArgs(mh.type().parameterArray());
         for (int i = start; i < end; i++) {
             if (done.add(Arrays.toString(perm)))
@@ -292,9 +302,11 @@
         }
     }
 
-    static void testOnePermutation(MethodHandle mh, int[] perm, Object[] args) throws Throwable {
+    static void testOnePermutation(MethodHandle mh, int[] perm, Object[] args)
+            throws Throwable {
         MethodType mt = mh.type();
-        MethodType pmt = methodType(mt.returnType(), unpermuteArgs(perm, mt.parameterArray(), Class[].class));
+        MethodType pmt = methodType(mt.returnType(),
+                unpermuteArgs(perm, mt.parameterArray(), Class[].class));
         if (VERBOSE)
             System.out.println(Arrays.toString(perm));
         testCases += 1;
--- a/jdk/test/java/lang/invoke/TestCatchExceptionWithVarargs.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/invoke/TestCatchExceptionWithVarargs.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,14 +24,18 @@
 /*
  * @test
  * @bug 8019184
- * @library /lib/testlibrary /lib/testlibrary/jsr292
+ * @library /lib/testlibrary /java/lang/invoke/common
  * @summary MethodHandles.catchException() fails when methods have 8 args + varargs
  * @run main TestCatchExceptionWithVarargs
  */
 
-import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
-import java.util.*;
-import java.lang.invoke.*;
+import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.util.LinkedList;
+import java.util.List;
 
 public class TestCatchExceptionWithVarargs {
 
@@ -48,14 +52,16 @@
 
     public static Object target(Object... a) throws Exception {
         if (a[0] != firstArg) {
-            throw new AssertionError("first argument different than expected: " + a[0] + " != " + firstArg);
+            throw new AssertionError("first argument different than expected: "
+                    + a[0] + " != " + firstArg);
         }
         throw new MyException();
     }
 
     public static Object handler(Object... a) {
         if (a[0] != firstArg) {
-            throw new AssertionError("first argument different than expected: " + a[0] + " != " + firstArg);
+            throw new AssertionError("first argument different than expected: "
+                    + a[0] + " != " + firstArg);
         }
         return a[0];
     }
@@ -83,20 +89,27 @@
         for (int i = 1; i < MAX_MH_ARITY - 1; i++) {
             ptypes.add(0, Object.class);
 
-            MethodHandle targetWithArgs = target.asType(MethodType.methodType(Object.class, ptypes));
-            MethodHandle handlerWithArgs = handler.asType(MethodType.methodType(Object.class, ptypes));
-            handlerWithArgs = MethodHandles.dropArguments(handlerWithArgs, 0, MyException.class);
+            MethodHandle targetWithArgs = target.asType(
+                    MethodType.methodType(Object.class, ptypes));
+            MethodHandle handlerWithArgs = handler.asType(
+                    MethodType.methodType(Object.class, ptypes));
+            handlerWithArgs = MethodHandles.dropArguments(
+                    handlerWithArgs, 0, MyException.class);
 
-            MethodHandle gwc1 = MethodHandles.catchException(targetWithArgs, MyException.class, handlerWithArgs);
+            MethodHandle gwc1 = MethodHandles.catchException(
+                    targetWithArgs, MyException.class, handlerWithArgs);
 
             // The next line throws an IllegalArgumentException if there is a bug.
-            MethodHandle gwc2 = MethodHandles.catchException(gwc1, MyException.class, handlerWithArgs);
+            MethodHandle gwc2 = MethodHandles.catchException(
+                    gwc1, MyException.class, handlerWithArgs);
 
             // This is only to verify that the method handles can actually be invoked and do the right thing.
             firstArg = new Object();
-            Object o = gwc2.asSpreader(Object[].class, ptypes.size() - 1).invoke(firstArg, new Object[i]);
+            Object o = gwc2.asSpreader(Object[].class, ptypes.size() - 1)
+                           .invoke(firstArg, new Object[i]);
             if (o != firstArg) {
-                throw new AssertionError("return value different than expected: " + o + " != " + firstArg);
+                throw new AssertionError("return value different than expected: "
+                        + o + " != " + firstArg);
             }
         }
     }
--- a/jdk/test/java/lang/invoke/VarargsArrayTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/invoke/VarargsArrayTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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
@@ -21,20 +21,20 @@
  * questions.
  */
 
+import sun.invoke.util.Wrapper;
+import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;
 
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandleHelper;
 import java.lang.invoke.MethodType;
-import sun.invoke.util.Wrapper;
 import java.util.Arrays;
 import java.util.Collections;
-import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
 
 /* @test
  * @summary unit tests for varargs array methods: MethodHandleInfo.varargsArray(int),
  *          MethodHandleInfo.varargsArray(Class,int) & MethodHandleInfo.varargsList(int)
  * @modules java.base/sun.invoke.util
- * @library /lib/testlibrary /lib/testlibrary/jsr292
+ * @library /lib/testlibrary /java/lang/invoke/common
  * @compile/module=java.base java/lang/invoke/MethodHandleHelper.java
  * @run main/bootclasspath VarargsArrayTest
  * @run main/bootclasspath/othervm -DVarargsArrayTest.MAX_ARITY=255 -DVarargsArrayTest.START_ARITY=250
@@ -46,9 +46,12 @@
  */
 public class VarargsArrayTest {
     private static final Class<?> CLASS = VarargsArrayTest.class;
-    private static final int MAX_ARITY = Integer.getInteger(CLASS.getSimpleName()+".MAX_ARITY", 40);
-    private static final int START_ARITY = Integer.getInteger(CLASS.getSimpleName()+".START_ARITY", 0);
-    private static final boolean EXHAUSTIVE = Boolean.getBoolean(CLASS.getSimpleName()+".EXHAUSTIVE");
+    private static final int MAX_ARITY = Integer.getInteger(
+            CLASS.getSimpleName()+".MAX_ARITY", 40);
+    private static final int START_ARITY = Integer.getInteger(
+            CLASS.getSimpleName()+".START_ARITY", 0);
+    private static final boolean EXHAUSTIVE = Boolean.getBoolean(
+            CLASS.getSimpleName()+".EXHAUSTIVE");
 
     public static void main(String[] args) throws Throwable {
         CodeCacheOverflowProcessor.runMHTest(VarargsArrayTest::test);
@@ -211,7 +214,8 @@
             }
             return;
         }
-        throw new AssertionError(Arrays.deepToString(arr1) + " != " + Arrays.deepToString(arr2));
+        throw new AssertionError(Arrays.deepToString(arr1)
+                + " != " + Arrays.deepToString(arr2));
     }
 
     public static void assertEquals(Object o1, Object o2) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/common/test/java/lang/invoke/lib/CodeCacheOverflowProcessor.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package test.java.lang.invoke.lib;
+
+import jdk.testlibrary.Utils;
+
+/**
+ * Helper class used to catch and process VirtualMachineError with message "Out
+ * of space in CodeCache". Some JSR292 tests run out of code cache size, so code
+ * cache overflows and VME is thrown. This VME is considered as non-critical in
+ * some JSR292 tests, so it should be processed to prevent test failure.
+ */
+public class CodeCacheOverflowProcessor {
+
+    /**
+     * Checks if an instance of Throwable is caused by VirtualMachineError with
+     * message "Out of space in CodeCache". May be used as filter in method
+     * {@code jdk.testlibrary.Utils.filterException}.
+     *
+     * @param t - Throwable to check.
+     * @return true if Throwable is caused by VME, false otherwise.
+     */
+    public static Boolean isThrowableCausedByVME(Throwable t) {
+        Throwable causeOfT = t;
+        do {
+            if (causeOfT instanceof VirtualMachineError
+                    && causeOfT.getMessage().matches(".*[Oo]ut of space"
+                            + " in CodeCache.*")) {
+                return true;
+            }
+            causeOfT = causeOfT != null ? causeOfT.getCause() : null;
+        } while (causeOfT != null && causeOfT != t);
+        return false;
+    }
+
+    /**
+     * Checks if the given test throws an exception caused by
+     * VirtualMachineError with message "Out of space in CodeCache", and, if VME
+     * takes place, processes it so that no exception is thrown, and prints its
+     * stack trace. If test throws exception not caused by VME, this method just
+     * re-throws this exception.
+     *
+     * @param test - test to check for and process VirtualMachineError.
+     * @return - an exception caused by VME or null
+     *           if test has thrown no exception.
+     * @throws Throwable - if test has thrown an exception
+     *                     that is not caused by VME.
+     */
+    public static Throwable runMHTest(Utils.ThrowingRunnable test) throws Throwable {
+        Throwable t = Utils.filterException(test::run,
+                CodeCacheOverflowProcessor::isThrowableCausedByVME);
+        if (t != null) {
+            System.err.printf("%nNon-critical exception caught becuse of"
+                    + " code cache size is not enough to run all test cases.%n%n");
+        }
+        return t;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/invoke/common/test/java/lang/invoke/lib/Helper.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,351 @@
+/*
+ * 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
+ * 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 test.java.lang.invoke.lib;
+
+import jdk.testlibrary.Asserts;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Random;
+
+public class Helper {
+    /** Flag for verbose output, true if {@code -Dverbose} specified */
+    public static final boolean IS_VERBOSE
+            = System.getProperty("verbose") != null;
+    /**
+     * Flag for thorough testing -- all test will be executed,
+     * true if {@code -Dthorough} specified. */
+    public static final boolean IS_THOROUGH
+            = System.getProperty("thorough") != null;
+    /** Random number generator w/ initial seed equal to {@code -Dseed} */
+    public static final Random RNG;
+
+    static {
+        String str = System.getProperty("seed");
+        long seed = str != null ? Long.parseLong(str) : new Random().nextLong();
+        RNG = new Random(seed);
+        System.out.printf("-Dseed=%d%n", seed);
+    }
+
+    public static final long TEST_LIMIT;
+    static {
+        String str = System.getProperty("testLimit");
+        TEST_LIMIT = str != null ? Long.parseUnsignedLong(str) : 2000L;
+        System.out.printf("-DtestLimit=%d%n", TEST_LIMIT);
+    }
+
+    public static final int MAX_ARITY = 254;
+    public static final String MISSING_ARG = "missingArg";
+    public static final String MISSING_ARG_2 = "missingArg#2";
+
+    private static final int
+            // first int value
+            ONE_MILLION = (1000 * 1000),
+            // scale factor to reach upper 32 bits
+            TEN_BILLION = (10 * 1000 * 1000 * 1000),
+            // <<1 makes space for sign bit;
+            INITIAL_ARG_VAL = ONE_MILLION << 1;
+
+    public static final MethodHandle AS_LIST;
+
+    static {
+        try {
+            AS_LIST = MethodHandles.lookup().findStatic(
+                    Arrays.class, "asList",
+                    MethodType.methodType(List.class, Object[].class));
+        } catch (NoSuchMethodException | IllegalAccessException ex) {
+            throw new Error(ex);
+        }
+    }
+
+    public static boolean isDoubleCost(Class<?> aClass) {
+        return aClass == double.class || aClass == long.class;
+    }
+
+    private static List<List<Object>> calledLog = new ArrayList<>();
+    private static long nextArgVal;
+
+    public static void assertCalled(String name, Object... args) {
+        assertCalled(0, name, args);
+    }
+
+    public static void assertCalled(int lag, String name, Object... args) {
+        Object expected = logEntry(name, args);
+        Object actual = getCalled(lag);
+        Asserts.assertEQ(expected, actual, "method call w/ lag = " + lag);
+    }
+
+    public static Object called(String name, Object... args) {
+        List<Object> entry = logEntry(name, args);
+        calledLog.add(entry);
+        return entry;
+    }
+
+    private static List<Object> logEntry(String name, Object... args) {
+        return Arrays.asList(name, Arrays.asList(args));
+    }
+
+    public static void clear() {
+        calledLog.clear();
+    }
+
+    public static List<Object> getCalled(int lag) {
+        int size = calledLog.size();
+        return size <= lag ? null : calledLog.get(size - lag - 1);
+    }
+
+    public static List<Class<?>> randomClasses(Class<?>[] classes, int size) {
+        List<Class<?>> result = new ArrayList<>(size);
+        for (int i = 0; i < size; ++i) {
+            result.add(classes[RNG.nextInt(classes.length)]);
+        }
+        return result;
+    }
+
+    public static List<Class<?>> getParams(List<Class<?>> classes,
+            boolean isVararg, int argsCount) {
+        boolean unmodifiable = true;
+        List<Class<?>> result = classes.subList(0,
+                Math.min(argsCount, (MAX_ARITY / 2) - 1));
+        int extra = 0;
+        if (argsCount >= MAX_ARITY / 2) {
+            result = new ArrayList<>(result);
+            unmodifiable = false;
+            extra = (int) result.stream().filter(Helper::isDoubleCost).count();
+            int i = result.size();
+            while (result.size() + extra < argsCount) {
+                Class<?> aClass = classes.get(i);
+                if (Helper.isDoubleCost(aClass)) {
+                    ++extra;
+                    if (result.size() + extra >= argsCount) {
+                        break;
+                    }
+                }
+                result.add(aClass);
+            }
+        }
+        if (isVararg && result.size() > 0) {
+            if (unmodifiable) {
+                result = new ArrayList<>(result);
+            }
+            int last = result.size() - 1;
+            Class<?> aClass = result.get(last);
+            aClass = Array.newInstance(aClass, 2).getClass();
+            result.set(last, aClass);
+        }
+        return result;
+    }
+
+    public static MethodHandle addTrailingArgs(MethodHandle target, int nargs,
+            List<Class<?>> classes) {
+        int targetLen = target.type().parameterCount();
+        int extra = (nargs - targetLen);
+        if (extra <= 0) {
+            return target;
+        }
+        List<Class<?>> fakeArgs = new ArrayList<>(extra);
+        for (int i = 0; i < extra; ++i) {
+            fakeArgs.add(classes.get(i % classes.size()));
+        }
+        return MethodHandles.dropArguments(target, targetLen, fakeArgs);
+    }
+
+    public static MethodHandle varargsList(int arity) {
+        return AS_LIST.asCollector(Object[].class, arity);
+    }
+
+    private static long nextArg(boolean moreBits) {
+        long val = nextArgVal++;
+        long sign = -(val & 1); // alternate signs
+        val >>= 1;
+        if (moreBits)
+        // Guarantee some bits in the high word.
+        // In any case keep the decimal representation simple-looking,
+        // with lots of zeroes, so as not to make the printed decimal
+        // strings unnecessarily noisy.
+        {
+            val += (val % ONE_MILLION) * TEN_BILLION;
+        }
+        return val ^ sign;
+    }
+
+    private static int nextArg() {
+        // Produce a 32-bit result something like ONE_MILLION+(smallint).
+        // Example: 1_000_042.
+        return (int) nextArg(false);
+    }
+
+    private static long nextArg(Class<?> kind) {
+        if (kind == long.class || kind == Long.class ||
+                kind == double.class || kind == Double.class)
+        // produce a 64-bit result something like
+        // ((TEN_BILLION+1) * (ONE_MILLION+(smallint)))
+        // Example: 10_000_420_001_000_042.
+        {
+            return nextArg(true);
+        }
+        return (long) nextArg();
+    }
+
+    private static Object randomArg(Class<?> param) {
+        Object wrap = castToWrapperOrNull(nextArg(param), param);
+        if (wrap != null) {
+            return wrap;
+        }
+
+        if (param.isInterface()) {
+            for (Class<?> c : param.getClasses()) {
+                if (param.isAssignableFrom(c) && !c.isInterface()) {
+                    param = c;
+                    break;
+                }
+            }
+        }
+        if (param.isArray()) {
+            Class<?> ctype = param.getComponentType();
+            Object arg = Array.newInstance(ctype, 2);
+            Array.set(arg, 0, randomArg(ctype));
+            return arg;
+        }
+        if (param.isInterface() && param.isAssignableFrom(List.class)) {
+            return Arrays.asList("#" + nextArg());
+        }
+        if (param.isInterface() || param.isAssignableFrom(String.class)) {
+            return "#" + nextArg();
+        }
+
+        try {
+            return param.newInstance();
+        } catch (InstantiationException | IllegalAccessException ex) {
+        }
+        return null;  // random class not Object, String, Integer, etc.
+    }
+
+    public static Object[] randomArgs(Class<?>... params) {
+        Object[] args = new Object[params.length];
+        for (int i = 0; i < args.length; i++) {
+            args[i] = randomArg(params[i]);
+        }
+        return args;
+    }
+
+    public static Object[] randomArgs(int nargs, Class<?> param) {
+        Object[] args = new Object[nargs];
+        for (int i = 0; i < args.length; i++) {
+            args[i] = randomArg(param);
+        }
+        return args;
+    }
+
+    public static Object[] randomArgs(int nargs, Class<?>... params) {
+        Object[] args = new Object[nargs];
+        for (int i = 0; i < args.length; i++) {
+            Class<?> param = params[i % params.length];
+            args[i] = randomArg(param);
+        }
+        return args;
+    }
+
+    public static Object[] randomArgs(List<Class<?>> params) {
+        return randomArgs(params.toArray(new Class<?>[params.size()]));
+    }
+
+    public static Object castToWrapper(Object value, Class<?> dst) {
+        Object wrap = null;
+        if (value instanceof Number) {
+            wrap = castToWrapperOrNull(((Number) value).longValue(), dst);
+        }
+        if (value instanceof Character) {
+            wrap = castToWrapperOrNull((char) (Character) value, dst);
+        }
+        if (wrap != null) {
+            return wrap;
+        }
+        return dst.cast(value);
+    }
+
+    @SuppressWarnings("cast")
+    // primitive cast to (long) is part of the pattern
+    private static Object castToWrapperOrNull(long value, Class<?> dst) {
+        if (dst == int.class || dst == Integer.class) {
+            return (int) (value);
+        }
+        if (dst == long.class || dst == Long.class) {
+            return (long) (value);
+        }
+        if (dst == char.class || dst == Character.class) {
+            return (char) (value);
+        }
+        if (dst == short.class || dst == Short.class) {
+            return (short) (value);
+        }
+        if (dst == float.class || dst == Float.class) {
+            return (float) (value);
+        }
+        if (dst == double.class || dst == Double.class) {
+            return (double) (value);
+        }
+        if (dst == byte.class || dst == Byte.class) {
+            return (byte) (value);
+        }
+        if (dst == boolean.class || dst == Boolean.class) {
+            return ((value % 29) & 1) == 0;
+        }
+        return null;
+    }
+
+    /**
+     * Routine used to obtain a randomly generated method type.
+     *
+     * @param arity Arity of returned method type.
+     * @return MethodType generated randomly.
+     */
+    public static MethodType randomMethodTypeGenerator(int arity) {
+        final Class<?>[] CLASSES = {
+            Object.class,
+            int.class,
+            boolean.class,
+            byte.class,
+            short.class,
+            char.class,
+            long.class,
+            float.class,
+            double.class
+        };
+        if (arity > MAX_ARITY) {
+            throw new IllegalArgumentException(
+                    String.format("Arity should not exceed %d!", MAX_ARITY));
+        }
+        List<Class<?>> list = randomClasses(CLASSES, arity);
+        list = getParams(list, false, arity);
+        int i = RNG.nextInt(CLASSES.length + 1);
+        Class<?> rtype = i == CLASSES.length ? void.class : CLASSES[i];
+        return MethodType.methodType(rtype, list);
+    }
+}
--- a/jdk/test/java/lang/invoke/lambda/LambdaClassLoaderSerialization.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/invoke/lambda/LambdaClassLoaderSerialization.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,6 @@
  * @test
  * @bug 8004970
  * @summary Lambda serialization in the presence of class loaders
- * @library /lib/testlibrary
- * @build jdk.testlibrary.IOUtils
  * @run main LambdaClassLoaderSerialization
  * @author Peter Levart
  */
@@ -38,9 +36,6 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.Serializable;
-import java.util.Arrays;
-
-import jdk.testlibrary.IOUtils;
 
 public class LambdaClassLoaderSerialization {
 
@@ -130,7 +125,7 @@
             String path = name.replace('.', '/').concat(".class");
             try (InputStream is = getResourceAsStream(path)) {
                 if (is != null) {
-                    byte[] bytes = IOUtils.readFully(is);
+                    byte[] bytes = is.readAllBytes();
                     return defineClass(name, bytes, 0, bytes.length);
                 } else {
                     throw new ClassNotFoundException(name);
--- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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/
  *
--- a/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh	Wed Jul 05 23:37:13 2017 +0200
@@ -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.
--- a/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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
--- a/jdk/test/java/lang/management/ThreadMXBean/Locks.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/management/ThreadMXBean/Locks.java	Wed Jul 05 23:37:13 2017 +0200
@@ -29,17 +29,17 @@
  * @author  Mandy Chung
  * @author  Jaroslav Bachorik
  *
- * @library /lib/testlibrary
+ * @library /test/lib
  *
- * @build jdk.testlibrary.*
  * @run main/othervm Locks
  */
 import java.lang.management.*;
 import java.util.Arrays;
+import java.util.Objects;
 import java.util.Optional;
 import java.util.concurrent.Phaser;
 import java.util.function.Predicate;
-import jdk.testlibrary.LockFreeLogManager;
+import jdk.test.lib.LockFreeLogger;
 
 public class Locks {
 
@@ -47,7 +47,7 @@
     private static final Object OBJB = new Object();
     private static final EnhancedWaiter OBJC = new EnhancedWaiter();
     private static final ThreadMXBean TM = ManagementFactory.getThreadMXBean();
-    private static final LockFreeLogManager LOGGER = new LockFreeLogManager();
+    private static final LockFreeLogger LOGGER = new LockFreeLogger();
 
     private static String getLockName(Object lock) {
         if (lock == null) return null;
@@ -60,12 +60,12 @@
         if (t == null) {
             return;
         }
-        Optional<ThreadInfo> result = Arrays.asList(
-                TM.getThreadInfo(TM.getAllThreadIds(), true, true)).
-                stream().
-                filter(tInfo -> (tInfo != null && tInfo.getLockOwnerName() != null)
-                        ? tInfo.getLockOwnerName().equals(t.getName()) : false).
-                findAny();
+        String name = t.getName();
+        Optional<ThreadInfo> result = Arrays.stream(
+                TM.getThreadInfo(TM.getAllThreadIds(), true, true))
+                                            .filter(Objects::nonNull)
+                                            .filter(i -> name.equals(i.getLockOwnerName()))
+                                            .findAny();
         if (result.isPresent()) {
             throw new RuntimeException("Thread " + t.getName() + " is not "
                     + "supposed to be hold any lock. Currently owning lock : "
--- a/jdk/test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -31,6 +31,7 @@
  *
  * @library ../../Thread
  * @library /lib/testlibrary
+ * @library /test/lib
  *
  * @build jdk.testlibrary.*
  * @build ThreadMXBeanStateTest ThreadStateController
--- a/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/module/ModuleReader/ModuleReaderTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,10 +23,10 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules java.base/jdk.internal.module
  *          jdk.compiler
- * @build ModuleReaderTest CompilerUtils JarUtils
+ * @build ModuleReaderTest jdk.test.lib.compiler.CompilerUtils JarUtils
  * @run testng ModuleReaderTest
  * @summary Basic tests for java.lang.module.ModuleReader
  */
@@ -53,6 +53,7 @@
 import java.util.spi.ToolProvider;
 
 import jdk.internal.module.ModulePath;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/jdk/test/java/lang/module/MultiReleaseJarTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/module/MultiReleaseJarTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/jdk/test/java/lang/reflect/Method/InterfaceStatic/StaticInterfaceMethodInWayOfDefault.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/reflect/Method/InterfaceStatic/StaticInterfaceMethodInWayOfDefault.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,19 +27,14 @@
  * @summary Test that a static method on an interface doesn't hide a default
  *          method with the same name and signature in a separate compilation
  *          scenario.
- * @library /lib/testlibrary
- * @build jdk.testlibrary.IOUtils
  * @run main StaticInterfaceMethodInWayOfDefault
  */
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.concurrent.Callable;
 
-import jdk.testlibrary.IOUtils;
-
 public class StaticInterfaceMethodInWayOfDefault {
     public interface A_v1 {
     }
@@ -147,7 +142,7 @@
                 String altPath = altName.replace('.', '/').concat(".class");
                 try (InputStream is = getResourceAsStream(altPath)) {
                     if (is != null) {
-                        byte[] bytes = IOUtils.readFully(is);
+                        byte[] bytes = is.readAllBytes();
                         // patch class bytes to contain original name
                         for (int i = 0; i < bytes.length - 2; i++) {
                             if (bytes[i] == '_' &&
@@ -170,7 +165,7 @@
                 String path = name.replace('.', '/').concat(".class");
                 try (InputStream is = getResourceAsStream(path)) {
                     if (is != null) {
-                        byte[] bytes = IOUtils.readFully(is);
+                        byte[] bytes = is.readAllBytes();
                         return defineClass(name, bytes, 0, bytes.length);
                     }
                     else {
--- a/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyClassAccessTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.executeTestJava;
 
 import org.testng.annotations.BeforeTest;
@@ -37,9 +38,10 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build ProxyClassAccessTest q.NP CompilerUtils jdk.testlibrary.*
+ * @build ProxyClassAccessTest q.NP jdk.testlibrary.*
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng ProxyClassAccessTest
  * @summary Driver for testing proxy class doesn't have access to
  *          types referenced by proxy interfaces
--- a/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyLayerTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 import java.nio.file.Paths;
 import java.util.Arrays;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.executeTestJava;
 
 import org.testng.annotations.BeforeTest;
@@ -37,9 +38,10 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build ProxyTest CompilerUtils jdk.testlibrary.ProcessTools
+ * @build ProxyTest jdk.testlibrary.ProcessTools
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng ProxyLayerTest
  * @summary Test proxies to implement interfaces in a layer
  */
--- a/jdk/test/java/lang/reflect/Proxy/ProxyTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/lang/reflect/Proxy/ProxyTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.executeTestJava;
 
 import org.testng.annotations.BeforeTest;
@@ -34,9 +35,10 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build ProxyTest q.U CompilerUtils jdk.testlibrary.*
+ * @build ProxyTest q.U jdk.testlibrary.*
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng ProxyTest
  * @summary Driver for testing proxies accessing interfaces in named modules
  */
--- a/jdk/test/java/math/BigDecimal/StringConstructor.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/math/BigDecimal/StringConstructor.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, 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
@@ -23,8 +23,7 @@
 
 /*
  * @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main StringConstructor
  * @bug 4103117 4331084 4488017 4490929 6255285 6268365 8074460 8078672
  * @summary Tests the BigDecimal string constructor (use -Dseed=X to set PRNG seed).
@@ -33,7 +32,7 @@
 
 import java.math.*;
 import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class StringConstructor {
 
--- a/jdk/test/java/math/BigInteger/BigIntegerTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/math/BigInteger/BigIntegerTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,7 @@
 
 /*
  * @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main BigIntegerTest
  * @bug 4181191 4161971 4227146 4194389 4823171 4624738 4812225 4837946 4026465 8074460 8078672 8032027
  * @summary tests methods in BigInteger (use -Dseed=X to set PRNG seed)
@@ -47,7 +46,7 @@
 import java.util.stream.IntStream;
 import java.util.stream.LongStream;
 import java.util.stream.Stream;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /**
  * This is a simple test class created to ensure that the results
--- a/jdk/test/java/math/BigInteger/ModPow65537.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/math/BigInteger/ModPow65537.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,7 @@
 
 /*
  * @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main ModPow65537
  * @bug 4891312 8074460 8078672
  * @summary verify that modPow() not broken by the special case for 65537 (use -Dseed=X to set PRNG seed)
@@ -37,7 +36,7 @@
 import java.security.*;
 import java.security.spec.*;
 import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class ModPow65537 {
 
--- a/jdk/test/java/math/BigInteger/PrimeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/math/BigInteger/PrimeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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
@@ -25,8 +25,7 @@
 
 /*
  * @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main PrimeTest
  * @bug 8026236 8074460 8078672
  * @summary test primality verification methods in BigInteger (use -Dseed=X to set PRNG seed)
@@ -40,7 +39,7 @@
 import java.util.Set;
 import java.util.SplittableRandom;
 import java.util.TreeSet;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 import static java.util.stream.Collectors.toCollection;
 import static java.util.stream.Collectors.toList;
 
--- a/jdk/test/java/math/BigInteger/SymmetricRangeTests.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/math/BigInteger/SymmetricRangeTests.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,7 @@
 /*
  * @test
  * @ignore This test has huge memory requirements
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main/timeout=180/othervm -Xmx8g SymmetricRangeTests
  * @bug 6910473 8021204 8021203 9005933 8074460 8078672
  * @summary Test range of BigInteger values (use -Dseed=X to set PRNG seed)
@@ -40,7 +39,7 @@
 import java.util.Arrays;
 import java.math.BigInteger;
 import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class SymmetricRangeTests {
 
--- a/jdk/test/java/net/Inet6Address/B6206527.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/Inet6Address/B6206527.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,14 +25,13 @@
  * @test 1.1 05/01/05
  * @bug 6206527
  * @summary "cannot assign address" when binding ServerSocket on Suse 9
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run main B6206527
  */
 
 import java.net.*;
 import java.util.*;
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 
 public class B6206527 {
 
--- a/jdk/test/java/net/Inet6Address/B6558853.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/Inet6Address/B6558853.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,8 +25,7 @@
  * @test
  * @bug 6558853
  * @summary  getHostAddress() on connections using IPv6 link-local addrs should have zone id
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run main B6558853
  */
 
@@ -35,7 +34,7 @@
 import java.io.OutputStream;
 import java.net.*;
 import java.util.Optional;
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 
 public class B6558853 implements Runnable {
     private InetAddress addr = null;
--- a/jdk/test/java/net/InetAddress/CheckJNI.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/InetAddress/CheckJNI.java	Wed Jul 05 23:37:13 2017 +0200
@@ -22,17 +22,16 @@
  */
 
 /* @test
-   @bug 4889870 4890033
-   @summary java -Xcheck:jni failing in net code on Solaris / [Datagram]Socket.getLocalAddress() failure
-   @library /lib/testlibrary
-   @build jdk.testlibrary.NetworkConfiguration
-   @run main/othervm -Xcheck:jni CheckJNI
-*/
+ * @bug 4889870 4890033
+ * @summary java -Xcheck:jni failing in net code on Solaris / [Datagram]Socket.getLocalAddress() failure
+ * @library /test/lib
+ * @run main/othervm -Xcheck:jni CheckJNI
+ */
 
 import java.net.*;
 import java.util.*;
 import java.util.stream.Collectors;
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 
 public class CheckJNI {
     static Socket s;
--- a/jdk/test/java/net/MulticastSocket/JoinLeave.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/MulticastSocket/JoinLeave.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,8 +25,7 @@
  * @test
  * @bug 4091811 4148753 4102731
  * @summary Test java.net.MulticastSocket joinGroup and leaveGroup
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run main JoinLeave
  */
 
@@ -35,7 +34,7 @@
 import java.net.InetAddress;
 import java.net.MulticastSocket;
 import java.net.NetworkInterface;
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 
 public class JoinLeave {
 
--- a/jdk/test/java/net/MulticastSocket/SetLoopbackMode.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/MulticastSocket/SetLoopbackMode.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,9 +25,14 @@
  * @test
  * @bug 4686717
  * @summary Test MulticastSocket.setLoopbackMode
+ * @library /test/lib
+ * @run main/othervm SetLoopbackMode
  */
+
 import java.net.*;
 import java.io.IOException;
+import java.util.Enumeration;
+import jdk.test.lib.NetworkConfiguration;
 
 public class SetLoopbackMode {
 
@@ -85,8 +90,13 @@
         return PASSED;
     }
 
+    private static boolean canUseIPv6(NetworkConfiguration nc) {
+        return nc.ip6MulticastInterfaces().toArray().length > 0;
+    }
+
     public static void main (String args[]) throws Exception {
         int failures = 0;
+        NetworkConfiguration nc = NetworkConfiguration.probe();
 
         MulticastSocket mc = new MulticastSocket();
         InetAddress grp = InetAddress.getByName("224.80.80.80");
@@ -97,11 +107,12 @@
          * to workaround Linux IPv6 bug whereby !IPV6_MULTICAST_LOOP
          * doesn't prevent loopback of IPv4 multicast packets.
          */
-        InetAddress lb = InetAddress.getByName("::1");
-        if (NetworkInterface.getByInetAddress(lb) != null) {
+
+        if (canUseIPv6(nc)) {
             grp = InetAddress.getByName("ff01::1");
         }
 
+        //mc.setNetworkInterface(NetworkInterface.getByInetAddress(lb));
         System.out.println("\nTest will use multicast group: " + grp);
         mc.joinGroup(grp);
 
--- a/jdk/test/java/net/MulticastSocket/Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/MulticastSocket/Test.java	Wed Jul 05 23:37:13 2017 +0200
@@ -35,6 +35,10 @@
     static int count = 0;
     static int failures = 0;
 
+    static boolean isSolaris = System.getProperty("os.name")
+        .toLowerCase()
+        .startsWith("sunos");
+
     void doTest(String address) throws Exception {
         boolean failed = false;
 
@@ -123,6 +127,14 @@
         }
     }
 
+    static boolean isValidIpv6Address(InetAddress addr) {
+        if (! (addr instanceof Inet6Address))
+            return false;
+        if (!isSolaris)
+            return true;
+        return !(addr.isAnyLocalAddress() || addr.isLoopbackAddress());
+    }
+
     void allTests() throws Exception {
 
         /*
@@ -146,7 +158,7 @@
             while (addrs.hasMoreElements()) {
                 InetAddress ia = (InetAddress)addrs.nextElement();
 
-                if (ia instanceof Inet6Address) {
+                if (isValidIpv6Address(ia)) {
                     has_ipv6 = true;
                     if (ia.isLinkLocalAddress()) has_linklocaladdress = true;
                     if (ia.isSiteLocalAddress()) has_siteaddress = true;
--- a/jdk/test/java/net/NetworkConfigurationProbe.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/NetworkConfigurationProbe.java	Wed Jul 05 23:37:13 2017 +0200
@@ -24,15 +24,14 @@
 /**
  * @test
  * @summary NOT A TEST. Captures the network interface configuration.
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run main NetworkConfigurationProbe
  */
 
 import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.NetworkInterface;
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 import static java.util.stream.Collectors.joining;
 import static java.lang.System.out;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/NetworkInterface/NetworkInterfaceRetrievalTests.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8179559
+ */
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.Enumeration;
+
+public class NetworkInterfaceRetrievalTests {
+    public static void main(String[] args) throws Exception {
+        int checkFailureCount = 0;
+
+        try {
+            Enumeration<NetworkInterface> en = NetworkInterface
+                    .getNetworkInterfaces();
+            while (en.hasMoreElements()) {
+                NetworkInterface ni = en.nextElement();
+                Enumeration<InetAddress> addrs = ni.getInetAddresses();
+                System.out.println("############ Checking network interface + "
+                        + ni + " #############");
+                while (addrs.hasMoreElements()) {
+                    InetAddress addr = addrs.nextElement();
+                    System.out.println("************ Checking address  + "
+                            + addr + " *************");
+                    NetworkInterface addrNetIf = NetworkInterface
+                            .getByInetAddress(addr);
+                    if (addrNetIf.equals(ni)) {
+                        System.out.println("Retreived net if " + addrNetIf
+                                + " equal to owning net if " + ni);
+                    } else {
+                        System.out.println("Retreived net if " + addrNetIf
+                                + "NOT  equal to owning net if " + ni
+                                + "***********");
+                        checkFailureCount++;
+                    }
+
+                }
+            }
+
+        } catch (Exception ex) {
+
+        }
+
+        if (checkFailureCount > 0) {
+            throw new RuntimeException(
+                    "NetworkInterface lookup by address didn't match owner network interface");
+        }
+    }
+}
--- a/jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/NetworkInterface/NetworkInterfaceStreamTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 /* @test
  * @bug 8081678 8131155
  * @summary Tests for stream returning methods
- * @library ../../util/stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.stream.OpTestCase
  * @run testng/othervm NetworkInterfaceStreamTest
  * @run testng/othervm -Djava.net.preferIPv4Stack=true NetworkInterfaceStreamTest
--- a/jdk/test/java/net/Socket/LinkLocal.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/Socket/LinkLocal.java	Wed Jul 05 23:37:13 2017 +0200
@@ -26,11 +26,11 @@
  * @bug 4469866
  * @summary Connecting to a link-local IPv6 address should not
  *          causes a SocketException to be thrown.
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run main LinkLocal
  */
-import jdk.testlibrary.NetworkConfiguration;
+
+import jdk.test.lib.NetworkConfiguration;
 
 import java.net.*;
 import java.util.List;
--- a/jdk/test/java/net/Socket/OldSocketImpl.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-#
-# Copyright (c) 2006, 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.
-#
-
-# @test
-# @bug 6449565
-# @run shell/timeout=140 OldSocketImpl.sh
-# @summary Pre-1.4 SocketImpl no longer supported
-
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | AIX )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-# no need to compile the test. It is already compiled
-# with 1.3 and in OldStyleImpl.jar
-
-# run
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTSRC}${FS}OldSocketImpl.jar OldSocketImpl
-result=$?
-if [ "$result" -ne "0" ]; then
-    exit 1
-fi
-
-# no failures, exit.
-exit 0
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/Socket/OldSocketImplTestDriver.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import jdk.test.lib.process.ProcessTools;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * @test
+ * @bug 6449565
+ * @library /test/lib
+ * @build jdk.test.lib.process.ProcessTools
+ * @run main OldSocketImplTestDriver
+ * @summary Test driver for OdlSocketImpl
+ */
+public class OldSocketImplTestDriver {
+    public static void main(String[] args) throws Throwable {
+        Path jar = Paths.get(System.getProperty("test.src"),
+                "OldSocketImpl.jar");
+        ProcessTools.executeTestJava("-cp", jar.toString(), "OldSocketImpl")
+                    .outputTo(System.out)
+                    .errorTo(System.out)
+                    .shouldHaveExitValue(0);
+    }
+}
--- a/jdk/test/java/net/SocketPermission/SocketPermissionTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/SocketPermission/SocketPermissionTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,8 +25,7 @@
  * @test
  * @bug 8047031
  * @summary SocketPermission tests for legacy socket types
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run testng/othervm SocketPermissionTest
  */
 
@@ -55,7 +54,7 @@
 
 import static org.testng.Assert.*;
 
-import static jdk.testlibrary.NetworkConfiguration.probe;
+import static jdk.test.lib.NetworkConfiguration.probe;
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 public class SocketPermissionTest {
--- a/jdk/test/java/net/URL/B5086147.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/URL/B5086147.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 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
@@ -24,12 +24,13 @@
 /**
  * @test
  * @bug 5086147
- * @run shell B5086147.sh
+ * @requires (os.family == "windows")
+ * @run main B5086147
  * @summary File,URI,URL conversions are strange for UNC path
  */
 
-import java.net.*;
-import java.io.*;
+import java.io.File;
+import java.net.URI;
 
 public class B5086147 {
     public static final void main( String[] aaParamters ) throws Exception{
--- a/jdk/test/java/net/URL/B5086147.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-#! /bin/sh
-
-#
-# Copyright (c) 2005, 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.
-#
-
-
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | AIX )
-    exit 0
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}${FS}B5086147.java
-
-failures=0
-
-echo ''
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} B5086147
-if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
-
-if [ "$failures" != "0" ]; then
-    echo $failures tests failed
-    exit 1;
-fi
--- a/jdk/test/java/net/URLClassLoader/B5077773.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.*;
-import java.net.*;
-
-public class B5077773 {
-
-    public static void main(String[] args) throws Exception {
-        URLClassLoader loader =  new URLClassLoader (new URL[] {new URL("file:foo.jar")});
-        /* This test will fail if the file below is removed from rt.jar */
-        InputStream is = loader.getResourceAsStream ("javax/swing/text/rtf/charsets/mac.txt");
-        if (is == null) {
-            System.out.println ("could not find mac.txt");
-            return;
-        }
-        int c=0;
-        while ((is.read()) != -1) {
-            c++;
-        }
-        if (c == 26) /* size of bad file */  {
-            throw new RuntimeException ("Wrong mac.txt file was loaded");
-        }
-    }
-}
--- a/jdk/test/java/net/URLClassLoader/B5077773.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-#! /bin/sh
-
-#
-# Copyright (c) 2004, 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.
-#
-
-# @test
-# @author Michael McMahon
-# @bug 5077773
-# @summary Change in behaviour w.r.t jdk1.4.2 when loading resourcebundles
-#
-# ${TESTJAVA} is pointing to the jre
-#
-# set platform-dependent variables
-
-OS=`uname -s`
-case "$OS" in
-  SunOS | Darwin | AIX )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-cp ${TESTSRC}${FS}foo.jar .
-
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \
-    ${TESTSRC}${FS}B5077773.java
-
-WD=`pwd`
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} B5077773
-
--- a/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
  * 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,24 +26,35 @@
  * @bug 4167874
  * @modules java.logging
  *          jdk.httpserver
+ *          jdk.compiler
  * @library ../../../../com/sun/net/httpserver
- * @library /lib/testlibrary
- * @build FileServerHandler jdk.testlibrary.FileUtils
- * @run shell build.sh
+ *          /lib/testlibrary
+ *          /test/lib
+ * @build FileServerHandler JarUtils jdk.test.lib.compiler.CompilerUtils
  * @run main/othervm CloseTest
  * @summary URL-downloaded jar files can consume all available file descriptors
  */
 
 import java.io.File;
+import java.io.IOException;
 import java.lang.reflect.Method;
 import java.net.URLClassLoader;
 import java.net.InetSocketAddress;
 import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import jdk.test.lib.compiler.CompilerUtils;
+
 import com.sun.net.httpserver.HttpContext;
 import com.sun.net.httpserver.HttpServer;
 
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
 public class CloseTest extends Common {
-
+    private static final String WORK_DIR = System.getProperty("user.dir")
+            + "/";
 //
 // needs two jar files test1.jar and test2.jar with following structure
 //
@@ -54,39 +65,31 @@
 //
 // and a directory hierarchy with the same structure/contents
 
-    public static void main (String args[]) throws Exception {
+    public static void main(String args[]) throws Exception {
+        setup();
 
-        String workdir = System.getProperty("test.classes");
-        if (workdir == null) {
-            workdir = args[0];
-        }
-        if (!workdir.endsWith("/")) {
-            workdir = workdir+"/";
-        }
+        startHttpServer(WORK_DIR + "serverRoot/");
 
-        startHttpServer (workdir+"serverRoot/");
-
-        String testjar = workdir + "test.jar";
-        copyFile (workdir+"test1.jar", testjar);
-        test (testjar, 1);
+        String testjar = WORK_DIR + "test.jar";
+        copyFile(WORK_DIR + "test1.jar", testjar);
+        test(testjar, 1);
 
         // repeat test with different implementation
         // of test.jar (whose TestClass.getValue() returns 2
-
-        copyFile (workdir+"test2.jar", testjar);
-        test (testjar, 2);
+        copyFile(WORK_DIR + "test2.jar", testjar);
+        test(testjar, 2);
 
         // repeat test using a directory of files
-        String testdir=workdir+"testdir/";
-        rm_minus_rf (new File(testdir));
-        copyDir (workdir+"test1/", testdir);
-        test (testdir, 1);
+        String testdir = WORK_DIR + "testdir/";
+        rm_minus_rf(new File(testdir));
+        copyDir(WORK_DIR + "test1/", testdir);
+        test(testdir, 1);
 
-        testdir=workdir+"testdir/";
-        rm_minus_rf (new File(testdir));
-        copyDir (workdir+"test2/", testdir);
-        test (testdir, 2);
-        getHttpServer().stop (3);
+        testdir = WORK_DIR + "testdir/";
+        rm_minus_rf(new File(testdir));
+        copyDir(WORK_DIR + "test2/", testdir);
+        test(testdir, 2);
+        getHttpServer().stop(3);
     }
 
     // create a loader on jarfile (or directory), plus a http loader
@@ -98,47 +101,48 @@
     // check existing classes can be loaded
     // check boot classes can be loaded
 
-    static void test (String name, int expectedValue) throws Exception {
-        URL url = new URL ("file", null, name);
+    static void test(String name, int expectedValue) throws Exception {
+
+        URL url = new URL("file", null, name);
         URL url2 = getServerURL();
-        System.out.println ("Doing tests with URL: " + url + " and " + url2);
+        System.out.println("Doing tests with URL: " + url + " and " + url2);
         URL[] urls = new URL[2];
-        urls[0] =  url;
-        urls[1] =  url2;
-        URLClassLoader loader = new URLClassLoader (urls);
-        Class testclass = loadClass ("com.foo.TestClass", loader, true);
-        Class class2 = loadClass ("Test", loader, true); // from http
+        urls[0] = url;
+        urls[1] = url2;
+        URLClassLoader loader = new URLClassLoader(urls);
+        Class testclass = loadClass("com.foo.TestClass", loader, true);
+        Class class2 = loadClass("Test", loader, true); // from http
         class2.newInstance();
         Object test = testclass.newInstance();
         Method method = testclass.getDeclaredMethods()[0]; // int getValue();
-        int res = (Integer) method.invoke (test);
+        int res = (Integer) method.invoke(test);
 
         if (res != expectedValue) {
-            throw new RuntimeException ("wrong value from getValue() ["+res+
-                        "/"+expectedValue+"]");
+            throw new RuntimeException("wrong value from getValue() [" + res +
+                    "/" + expectedValue + "]");
         }
 
         // should find /resource1
-        URL u1 = loader.findResource ("com/foo/Resource1");
+        URL u1 = loader.findResource("com/foo/Resource1");
         if (u1 == null) {
-            throw new RuntimeException ("can't find com/foo/Resource1 in test1.jar");
+            throw new RuntimeException("can't find com/foo/Resource1 in test1.jar");
         }
-        loader.close ();
+        loader.close();
 
         // should NOT find /resource2 even though it is in jar
-        URL u2 = loader.findResource ("com/foo/Resource2");
+        URL u2 = loader.findResource("com/foo/Resource2");
         if (u2 != null) {
-            throw new RuntimeException ("com/foo/Resource2 unexpected in test1.jar");
+            throw new RuntimeException("com/foo/Resource2 unexpected in test1.jar");
         }
 
         // load tests
-        loadClass ("com.foo.TestClass1", loader, false);
-        loadClass ("com.foo.TestClass", loader, true);
-        loadClass ("java.util.ArrayList", loader, true);
+        loadClass("com.foo.TestClass1", loader, false);
+        loadClass("com.foo.TestClass", loader, true);
+        loadClass("java.util.ArrayList", loader, true);
 
         // now check we can delete the path
-        rm_minus_rf (new File(name));
-        System.out.println (" ... OK");
+        rm_minus_rf(new File(name));
+        System.out.println(" ... OK");
     }
 
     static HttpServer httpServer;
@@ -147,17 +151,54 @@
         return httpServer;
     }
 
-    static URL getServerURL () throws Exception {
+    static URL getServerURL() throws Exception {
         int port = httpServer.getAddress().getPort();
-        String s = "http://127.0.0.1:"+port+"/";
+        String s = "http://127.0.0.1:" + port + "/";
         return new URL(s);
     }
 
-    static void startHttpServer (String docroot) throws Exception {
-        httpServer = HttpServer.create (new InetSocketAddress(0), 10);
-        HttpContext ctx = httpServer.createContext (
+    static void startHttpServer(String docroot) throws Exception {
+        httpServer = HttpServer.create(new InetSocketAddress(0), 10);
+        HttpContext ctx = httpServer.createContext(
                 "/", new FileServerHandler(docroot)
         );
         httpServer.start();
     }
+
+    /**
+     * Prepare jars files for the tests
+     */
+    private static void setup () throws IOException {
+        String[] tests = new String[]{"test1", "test2"};
+        Path workDir = Paths.get(WORK_DIR);
+        Path testSrc = Paths.get(System.getProperty("test.src"));
+        for (String test : tests) {
+            Path testSrcDir =  testSrc.resolve(test);
+            Path testTargetDir = workDir.resolve(test);
+            // Compile sources for corresponding test
+            CompilerUtils.compile(testSrcDir, testTargetDir);
+            // Copy all resources
+            Path packages = Paths.get("com", "foo");
+            Path copySrcDir = testSrcDir.resolve(packages);
+            Path copyTargetDir = testTargetDir.resolve(packages);
+            Files.createDirectories(copyTargetDir);
+            Path res1 = Paths.get("Resource1");
+            Path res2 = Paths.get("Resource2");
+            Files.copy(copySrcDir.resolve(res1), copyTargetDir.resolve(res1),
+                       REPLACE_EXISTING);
+            Files.copy(copySrcDir.resolve(res2), copyTargetDir.resolve(res2),
+                       REPLACE_EXISTING);
+            // Create jar
+            JarUtils.createJarFile(workDir.resolve(test + ".jar"), testTargetDir);
+        }
+
+        // Copy and compile server test class
+        Path serverRoot = Paths.get("serverRoot");
+        Path targetDir = workDir.resolve(serverRoot);
+        Path file = Paths.get("Test.java");
+        Files.createDirectories(targetDir);
+        Files.copy(testSrc.resolve(serverRoot).resolve(file),
+                   targetDir.resolve(file), REPLACE_EXISTING);
+        CompilerUtils.compile(targetDir, targetDir);
+    }
 }
--- a/jdk/test/java/net/URLClassLoader/closetest/Common.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/URLClassLoader/closetest/Common.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 import java.io.*;
 import java.net.*;
 import java.nio.file.Files;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 import static java.nio.file.StandardCopyOption.*;
 
 public class Common {
--- a/jdk/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,16 +24,26 @@
 /**
  * @test
  * @bug 6899919
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
- * @run shell build2.sh
+ * @library /lib/testlibrary /test/lib
+ * @modules jdk.compiler
+ * @build JarUtils jdk.test.lib.compiler.CompilerUtils
  * @run main/othervm GetResourceAsStream
  */
 
-import java.io.*;
-import java.net.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.nio.file.StandardOpenOption;
+import jdk.test.lib.compiler.CompilerUtils;
 
 public class GetResourceAsStream extends Common {
+    private static  final String WORK_DIR = System.getProperty("user.dir");
 
 /*
  * We simply test various scenarios with class/resource files
@@ -42,35 +52,30 @@
  * on Windows. It will still run correctly on other platforms
  */
     public static void main (String args[]) throws Exception {
-
-        String workdir = System.getProperty("test.classes");
-        if (workdir == null) {
-            workdir = args[0];
-        }
+        setup();
 
         /* the jar we copy for each test */
-        File srcfile = new File (workdir, "foo.jar");
+        File srcfile = new File(WORK_DIR, "foo.jar");
 
         /* the jar we use for the test */
-        File testfile = new File (workdir, "test.jar");
+        File testfile = new File(WORK_DIR, "test.jar");
 
-        copyFile (srcfile, testfile);
-        test (testfile, false, false);
+        copyFile(srcfile, testfile);
+        test(testfile, false, false);
 
-        copyFile (srcfile, testfile);
-        test (testfile, true, false);
+        copyFile(srcfile, testfile);
+        test(testfile, true, false);
 
-        copyFile (srcfile, testfile);
-        test (testfile, true, true);
+        copyFile(srcfile, testfile);
+        test(testfile, true, true);
 
         // repeat test using a directory of files
 
-        File testdir= new File (workdir, "testdir");
-        File srcdir= new File (workdir, "test3");
+        File testdir = new File(WORK_DIR, "testdir");
+        File srcdir = new File(WORK_DIR, "test3");
 
-        copyDir (srcdir, testdir);
-        test (testdir, true, false);
-
+        copyDir(srcdir, testdir);
+        test(testdir, true, false);
     }
 
     // create a loader on jarfile (or directory)
@@ -82,7 +87,7 @@
     static void test (File file, boolean loadclass, boolean readall)
         throws Exception
     {
-        URL[] urls = new URL[] {file.toURL()};
+        URL[] urls = new URL[] {file.toURI().toURL()};
         System.out.println ("Doing tests with URL: " + urls[0]);
         URLClassLoader loader = new URLClassLoader (urls);
         if (loadclass) {
@@ -97,7 +102,7 @@
 
         loader.close ();
 
-        // shouuld not find bye.txt now
+        // should not find bye.txt now
         InputStream s1 = loader.getResourceAsStream("bye.txt");
         if (s1 != null) {
             throw new RuntimeException ("closed loader returned resource");
@@ -107,4 +112,26 @@
         rm_minus_rf (file);
         System.out.println (" ... OK");
     }
+
+    /**
+     * Prepare jars files for the tests
+     */
+    private static void setup () throws IOException {
+        Path classes = Paths.get(WORK_DIR);
+        Path testSrc = Paths.get(System.getProperty("test.src"),
+                "test1", "com", "foo", "TestClass.java");
+        Path targetDir = classes.resolve("test3");
+        Path testTarget = targetDir.resolve("TestClass.java");
+        Files.createDirectories(targetDir);
+        Files.copy(testSrc, testTarget, StandardCopyOption.REPLACE_EXISTING);
+        // Compile sources for corresponding test
+        CompilerUtils.compile(targetDir, targetDir);
+        // Prepare txt files
+        Files.write(targetDir.resolve("hello.txt"), "Hello world".getBytes(),
+                    StandardOpenOption.CREATE);
+        Files.write(targetDir.resolve("bye.txt"), "Bye world".getBytes(),
+                    StandardOpenOption.CREATE);
+        // Create jar
+        JarUtils.createJarFile(classes.resolve("foo.jar"), targetDir);
+    }
 }
--- a/jdk/test/java/net/URLClassLoader/closetest/build.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-#!/bin/sh
-# 
-# Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
-# 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.
-# 
-#
-#
-# This script builds the test files for the test
-# but not the actual test sources themselves.
-#
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-
-if [ "${COMPILEJAVA}" = "" ]; then
-  COMPILEJAVA="${TESTJAVA}"
-fi
-echo "COMPILEJAVA=${COMPILEJAVA}"
-
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-JAVAC="${COMPILEJAVA}/bin/javac"
-JAR="${COMPILEJAVA}/bin/jar"
-
-rm -rf ${TESTCLASSES}/test1
-rm -rf ${TESTCLASSES}/test2
-rm -rf ${TESTCLASSES}/serverRoot
-mkdir -p ${TESTCLASSES}/test1/com/foo
-mkdir -p ${TESTCLASSES}/test2/com/foo
-mkdir -p ${TESTCLASSES}/serverRoot
-
-cd ${TESTSRC}/test1/com/foo
-cp * ${TESTCLASSES}/test1/com/foo
-cd ${TESTCLASSES}/test1
-${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} com/foo/*.java
-${JAR} ${TESTTOOLVMOPTS} cvf ../test1.jar com/foo/*.class com/foo/Resource*
-
-cd ${TESTSRC}/test2/com/foo
-cp * ${TESTCLASSES}/test2/com/foo
-cd ${TESTCLASSES}/test2
-${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} com/foo/*.java
-${JAR} ${TESTTOOLVMOPTS} cvf ../test2.jar com/foo/*.class com/foo/Resource*
-
-cp ${TESTSRC}/serverRoot/Test.java ${TESTCLASSES}/serverRoot
-cd ${TESTCLASSES}/serverRoot
-${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} Test.java
--- a/jdk/test/java/net/URLClassLoader/closetest/build2.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-#!/bin/sh
-#
-#  Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
-#  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-#  This code is free software; you can redistribute it and/or modify it
-#  under the terms of the GNU General Public License version 2 only, as
-#  published by the Free Software Foundation.
-#
-#  This code is distributed in the hope that it will be useful, but WITHOUT
-#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-#  version 2 for more details (a copy is included in the LICENSE file that
-#  accompanied this code).
-#
-#  You should have received a copy of the GNU General Public License version
-#  2 along with this work; if not, write to the Free Software Foundation,
-#  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-#  Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-#  or visit www.oracle.com if you need additional information or have any
-#  questions.
-#
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-JAVAC="${TESTJAVA}/bin/javac"
-JAR="${TESTJAVA}/bin/jar"
-
-rm -rf ${TESTCLASSES}/test3
-mkdir -p ${TESTCLASSES}/test3
-
-echo "Hello world" > ${TESTCLASSES}/test3/hello.txt
-echo "Bye world" > ${TESTCLASSES}/test3/bye.txt
-cp ${TESTSRC}/test1/com/foo/TestClass.java ${TESTCLASSES}/test3
-cd ${TESTCLASSES}/test3
-${JAVAC} -d . TestClass.java
-
-${JAR} cvf foo.jar hello.txt bye.txt com/foo/TestClass.class
-rm -f ../foo.jar
-mv foo.jar ..
--- a/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,8 @@
  * @test
  * @bug 8153665
  * @summary Test two URLClassLoader define Package object of the same name
- * @library /lib/testlibrary
- * @build CompilerUtils
+ * @library /test/lib
+ * @build jdk.test.lib.compiler.CompilerUtils
  * @modules jdk.compiler
  * @run testng SplitPackage
  */
@@ -38,6 +38,7 @@
 import java.nio.file.Paths;
 import java.nio.file.StandardCopyOption;
 import java.util.jar.Manifest;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/URLClassLoader/getresourceasstream/TestDriver.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,108 @@
+/*
+ * 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 5103449
+ * @summary REGRESSION: getResourceAsStream is broken in JDK1.5.0-rc
+ * @library /test/lib
+ * @build jdk.test.lib.JDKToolFinder
+ *        jdk.test.lib.process.ProcessTools
+ *        Test
+ * @run main/othervm TestDriver
+ */
+
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
+public class TestDriver {
+    private static final String ARCHIVE_NAME = "test.jar";
+    private static final String TEST_NAME = "Test";
+    private static final String POLICY_FILE = "policy";
+    public static void main(String[] args)
+            throws Throwable {
+
+        Path userDir = Paths.get(System.getProperty("user.dir"));
+        String java = JDKToolFinder.getTestJDKTool("java");
+        String basename = userDir.getFileName().toString();
+        setup(userDir);
+        ProcessBuilder[] tests = new ProcessBuilder[]{
+                new ProcessBuilder(
+                        java, TEST_NAME, "./" + ARCHIVE_NAME
+                ),
+                new ProcessBuilder(
+                        java, "-cp", ".",
+                        "-Djava.security.policy=file:./policy",
+                        "-Djava.security.manager",
+                        TEST_NAME, "./" + ARCHIVE_NAME
+                ),
+                new ProcessBuilder(
+                        java, "-cp", ".",
+                        "-Djava.security.policy=file:./policy",
+                        "-Djava.security.manager",
+                        TEST_NAME, "./" + ARCHIVE_NAME
+                ),
+                new ProcessBuilder(
+                        java, "-cp", "..",
+                        "-Djava.security.policy=file:../policy",
+                        "-Djava.security.manager",
+                        TEST_NAME, "../" + ARCHIVE_NAME
+                ).directory(userDir.resolve("tmp").toFile()),
+                new ProcessBuilder(
+                        java, "-cp", basename,
+                        "-Djava.security.policy=file:" + basename + "/policy",
+                        "-Djava.security.manager",
+                        TEST_NAME, basename + "/" + ARCHIVE_NAME
+                ).directory(userDir.resolve("..").toFile())};
+        for (ProcessBuilder test : tests) {
+            runTest(test);
+        }
+    }
+
+    private static void setup(Path userDir) throws IOException {
+        Path src = Paths.get(System.getProperty("test.src"));
+        Path testJar = src.resolve(ARCHIVE_NAME);
+        Path policy = src.resolve(POLICY_FILE);
+        Path testClass = Paths.get(System.getProperty("test.classes"),
+                                   TEST_NAME + ".class");
+        Files.copy(testJar, userDir.resolve(ARCHIVE_NAME), REPLACE_EXISTING);
+        Files.copy(policy, userDir.resolve(POLICY_FILE), REPLACE_EXISTING);
+        Files.copy(testClass, userDir.resolve(TEST_NAME + ".class"),
+                   REPLACE_EXISTING);
+        Files.createDirectories(userDir.resolve("tmp"));
+    }
+
+    private static void runTest(ProcessBuilder pb) throws Exception {
+        System.out.println("Testing with command: [" + pb.command() + "]");
+        ProcessTools.executeProcess(pb)
+                    .outputTo(System.out)
+                    .errorTo(System.err)
+                    .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/URLClassLoader/getresourceasstream/policy	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+grant {
+    permission java.lang.RuntimePermission "createClassLoader";
+};
--- a/jdk/test/java/net/URLClassLoader/getresourceasstream/test.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-set -x
-# @test
-# @bug 5103449
-# @run shell test.sh
-# @summary REGRESSION: getResourceAsStream is broken in JDK1.5.0-rc
-#      
-
-
-cat << POLICY > policy
-grant {
-    permission java.lang.RuntimePermission "createClassLoader";
-};
-POLICY
-
-checkExit () {
-    if [ $? != 0 ]; then
-	exit $1;
-    fi
-}
-
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Test.java
-cp ${TESTSRC}/test.jar .
-
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test ./test.jar
-checkExit 1
-
-# try with security manager
-
-${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.security.policy=file:./policy \
-		-Djava.security.manager Test ./test.jar
-checkExit 2
-
-mkdir tmp
-cd tmp
-${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.security.policy=file:../policy \
-		-cp .. -Djava.security.manager Test ../test.jar
-checkExit 3
-
-cd ..
-THISDIR=$(basename $(pwd))
-cd ..
-${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.security.policy=file:$THISDIR/policy \
-		-cp $THISDIR -Djava.security.manager Test $THISDIR/test.jar
-checkExit 4
-
-exit 0
--- a/jdk/test/java/net/URLClassLoader/sealing/CheckSealed.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/URLClassLoader/sealing/CheckSealed.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 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
@@ -21,13 +21,6 @@
  * questions.
  */
 
-/*
- * @test
- * @bug 4244970
- * @summary Test to see if sealing violation is detected correctly
- * @run shell checksealed.sh
- *
- */
 public class CheckSealed {
 
     public static void main(String[] argv) throws Exception {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/URLClassLoader/sealing/CheckSealedTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,89 @@
+/*
+ * 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 4244970
+ * @summary Test to see if sealing violation is detected correctly
+ * @library /test/lib
+ * @build jdk.test.lib.JDKToolFinder
+ *        jdk.test.lib.process.OutputAnalyzer
+ * @run main CheckSealedTest
+ */
+
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
+public class CheckSealedTest {
+    private static final String ARCHIVE_NAME = "b.jar";
+    private static final String TEST_NAME = "CheckSealed";
+    public static void main(String[] args)
+            throws Throwable {
+
+        String baseDir = System.getProperty("user.dir") + File.separator;
+        String javac = JDKToolFinder.getTestJDKTool("javac");
+        String java = JDKToolFinder.getTestJDKTool("java");
+
+        setup(baseDir);
+        String srcDir = System.getProperty("test.src");
+        String cp = srcDir + File.separator + "a" + File.pathSeparator
+                + srcDir + File.separator + "b.jar" + File.pathSeparator
+                + ".";
+        List<String[]> allCMDs = List.of(
+                // Compile command
+                new String[]{
+                        javac, "-cp", cp, "-d", ".",
+                        srcDir + File.separator + TEST_NAME + ".java"
+                },
+                // Run test the first time
+                new String[]{
+                        java, "-cp", cp, TEST_NAME, "1"
+                },
+                // Run test the second time
+                new String[]{
+                        java, "-cp", cp, TEST_NAME, "2"
+                }
+        );
+
+        for (String[] cmd : allCMDs) {
+            ProcessTools.executeCommand(cmd)
+                        .outputTo(System.out)
+                        .errorTo(System.out)
+                        .shouldHaveExitValue(0);
+        }
+    }
+
+    private static void setup(String baseDir) throws IOException {
+        Path testJar = Paths.get(System.getProperty("test.src"), ARCHIVE_NAME);
+        Files.copy(testJar, Paths.get(baseDir, ARCHIVE_NAME), REPLACE_EXISTING);
+    }
+}
--- a/jdk/test/java/net/URLClassLoader/sealing/checksealed.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-#! /bin/sh
-
-#
-# 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.
-#
-# 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.
-#
-
-#
-
-OS=`uname -s`
-case "$OS" in
-  SunOS | Darwin | AIX )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-
-if [ x"$TESTJAVA" = x ]; then TESTJAVA=$1; fi
-if [ x"$COMPILEJAVA" = x ]; then COMPILEJAVA=$1; fi
-if [ x"$TESTSRC" = x ]; then TESTSRC=.; fi
-
-CLASSPATH=".${PS}${TESTSRC}${FS}a${PS}${TESTSRC}${FS}b.jar"
-
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -classpath "${CLASSPATH}" -d . \
-    ${TESTSRC}${FS}CheckSealed.java
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp "${CLASSPATH}" CheckSealed 1
-if [ $? != 0 ]; then exit 1; fi
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp "${CLASSPATH}" CheckSealed 2
-if [ $? != 0 ]; then exit 1; fi
--- a/jdk/test/java/net/URLConnection/6212146/Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/URLConnection/6212146/Test.java	Wed Jul 05 23:37:13 2017 +0200
@@ -21,49 +21,43 @@
  * questions.
  */
 
-import java.net.*;
-import java.io.*;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.file.Paths;
 
 public class Test {
 
     public static void main(String[] args)
          throws Exception {
-      String BASE_DIR = args[0];
-      String ARCHIVE_NAME = args[1];
-      String lProperty = System.getProperty( "do.iterations", "5000" );
-      int lRepetitions = new Integer( lProperty ).intValue();
-      System.out.println ( "Start creating copys of the archive, " + lRepetitions + " times" );
-      for( int i = 0; i < lRepetitions; i++ ) {
-         // Copy the given jar file and add a prefix
-         copyFile( BASE_DIR, ARCHIVE_NAME, i);
+        String baseDir = args[0];
+        String archiveName = args[1];
+        String lProperty = System.getProperty("do.iterations", "5000");
+        int lRepetitions = Integer.valueOf(lProperty);
+        System.out.println("Start creating copys of the archive, "
+                + lRepetitions + " times");
+        for (int i = 0; i < lRepetitions; i++) {
+            // Copy the given jar file and add a prefix
+            copyFile(baseDir, archiveName, i);
+        }
+        System.out.println("Start opening the archives archive, "
+                + lRepetitions + " times");
+        System.out.println("First URL is jar:" + Paths.get(baseDir,
+                0 + archiveName).toUri() + "!/foo/Test.class");
+        for (int i = 0; i < lRepetitions; i++) {
+            // Create URL
+            String lURLPath = "jar:" + Paths.get(baseDir, i
+                    + archiveName).toUri() + "!/foo/Test.class";
+            URL lURL = new URL(lURLPath);
+            // Open URL Connection
+            try {
+                URLConnection lConnection = lURL.openConnection();
+                lConnection.getInputStream();
+            } catch (java.io.FileNotFoundException fnfe) {
+                // Ignore this one because we expect this one
+            } catch (java.util.zip.ZipException ze) {
+                throw new RuntimeException("Test failed: " + ze.getMessage());
+            }
       }
-      System.out.println ( "Start opening the archives archive, " + lRepetitions + " times" );
-      System.out.println ( "First URL is jar:file://" + BASE_DIR + "1" + ARCHIVE_NAME + "!/foo/Test.class");
-      for( int i = 0; i < lRepetitions; i++ ) {
-         // Create ULR
-         String lURLPath = "jar:file://" + BASE_DIR + i + ARCHIVE_NAME + "!/foo/Test.class";
-         URL lURL = new URL( lURLPath );
-         // Open URL Connection
-         try {
-            URLConnection lConnection = lURL.openConnection();
-            lConnection.getInputStream();
-         } catch( java.io.FileNotFoundException fnfe ) {
-            // Ignore this one because we expect this one
-         } catch( java.util.zip.ZipException ze ) {
-            throw new RuntimeException ("Test failed: " + ze.getMessage());
-         }
-      }
-      //System.out.println ( "Done testing, waiting 20 seconds for checking" );
-      //System.out.println ( "Cleaning up");
-      //for( int i = 0; i < lRepetitions; i++ ) {
-         // Copy the given jar file and add a prefix
-         //deleteFile( BASE_DIR, i, ARCHIVE_NAME);
-      ////}
-   }
-
-   private static void deleteFile (String BASE_DIR, int pIndex, String pArchiveName) {
-         java.io.File file = new java.io.File (BASE_DIR, pIndex + pArchiveName );
-         file.delete ();
    }
 
    private static void copyFile( String pBaseDir, String pArchiveName, int pIndex) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/URLConnection/6212146/TestDriver.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6212146
+ * @summary URLConnection.connect() fails on JAR Entry it creates
+ * file handler leak
+ * @library /test/lib
+ * @build jdk.test.lib.JDKToolFinder
+ *        jdk.test.lib.process.ProcessTools
+ *        Test
+ * @run main/othervm TestDriver
+ */
+
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
+public class TestDriver {
+    private static final String BASE_DIR = System.getProperty("user.dir")
+            +  "/jars/";
+    private static final String ARCHIVE_NAME = "test.jar";
+    private static final String CMD_ULIMIT = "ulimit -n 300;";
+
+    public static void main(String[] args)
+            throws Throwable {
+        setup(BASE_DIR);
+        String testCMD = CMD_ULIMIT + JDKToolFinder.getTestJDKTool("java")
+                + " Test " + BASE_DIR + " " + ARCHIVE_NAME;
+        boolean isWindows = System.getProperty("os.name").startsWith("Windows");
+        if (isWindows) {
+            testCMD = testCMD.replace("\\", "/");
+        }
+        ProcessTools.executeCommand("sh", "-c", testCMD)
+                    .outputTo(System.out)
+                    .errorTo(System.err)
+                    .shouldHaveExitValue(0);
+    }
+
+    private static void setup(String baseDir) throws IOException {
+        Path testJar = Paths.get(System.getProperty("test.src"), ARCHIVE_NAME);
+        Path targetDir = Paths.get(baseDir);
+        Files.createDirectories(targetDir);
+        Files.copy(testJar, targetDir.resolve(ARCHIVE_NAME), REPLACE_EXISTING);
+    }
+}
--- a/jdk/test/java/net/URLConnection/6212146/test.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2006, 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.
-#
-
-#
-#  @test
-#  @run shell/timeout=380 test.sh
-#  @bug 6212146
-#  @summary URLConnection.connect() fails on JAR Entry it creates file handler leak
-#
-# set platform-dependent variables
-
-OS=`uname -s`
-case "$OS" in
-  SunOS | Darwin | AIX )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-if [ -d jars ]; then
-    rm -rf jars
-fi
-
-mkdir jars
-
-cp ${TESTSRC}${FS}test.jar  jars
-
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}${FS}Test.java
-
-WD=`pwd`
-ulimit -H -n 300
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} Test ${WD}/jars/ test.jar
-result=$?
-rm -rf jars
-exit $?
--- a/jdk/test/java/net/URLConnection/UNCTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/URLConnection/UNCTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 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
@@ -21,7 +21,16 @@
  * questions.
  */
 
-import java.net.*;
+/**
+ * @test
+ * @bug 4401485
+ * @requires (os.family == "windows")
+ * @summary  Check that URL.openConnection() doesn't open connection to UNC
+ * @run main UNCTest file://jdk/LOCAL-JAVA/jdk1.4/win/README.txt
+ */
+
+import java.net.URL;
+import java.net.URLConnection;
 
 public class UNCTest {
     public static void main(String args[]) throws Exception {
--- a/jdk/test/java/net/URLConnection/UNCTest.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2001, 2002, Oracle and/or its affiliates. All rights reserved.
-# 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 4401485
-# @run shell UNCTest.sh
-# @summary Check that URL.openConnection() doesn't open connection
-#          to UNC.
-
-UNC="file://jdk/LOCAL-JAVA/jdk1.4/win/README.txt"
-
-OS=`uname -s`
-case "$OS" in
-    Windows_95 | Windows_98 | Windows_NT )
-	${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}\\UNCTest.java
-	${TESTJAVA}/bin/java ${TESTVMOPTS} UNCTest ${UNC}
-	exit
-        ;;
-
-    * )
-        echo "This test is not intended for this OS - passing test"
-	exit 0
-        ;;
-esac
--- a/jdk/test/java/net/httpclient/RequestBodyTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/httpclient/RequestBodyTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
  * @modules jdk.incubator.httpclient
  *          java.logging
  *          jdk.httpserver
- * @library /lib/testlibrary/
+ * @library /lib/testlibrary/ /test/lib
  * @compile ../../../com/sun/net/httpserver/LogFilter.java
  * @compile ../../../com/sun/net/httpserver/FileServerHandler.java
  * @build LightWeightHttpServer
@@ -52,7 +52,7 @@
 import java.util.concurrent.Executors;
 import java.util.function.Supplier;
 import javax.net.ssl.SSLContext;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 import static java.nio.charset.StandardCharsets.*;
 import static java.nio.file.StandardOpenOption.*;
 import static jdk.incubator.http.HttpRequest.BodyProcessor.*;
--- a/jdk/test/java/net/ipv6tests/B6521014.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/ipv6tests/B6521014.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,15 +25,14 @@
  * @test
  * @bug 6521014 6543428
  * @summary IOException thrown when Socket tries to bind to an local IPv6 address on SuSE Linux
- * @library /lib/testlibrary
- * @build jdk.testlibrary.NetworkConfiguration
+ * @library /test/lib
  * @run main B6521014
  */
 
 import java.net.*;
 import java.io.*;
 import java.util.*;
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 
 /*
  *
--- a/jdk/test/java/net/spi/URLStreamHandlerProvider/Basic.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/net/spi/URLStreamHandlerProvider/Basic.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@
 import javax.tools.StandardJavaFileManager;
 import javax.tools.StandardLocation;
 import javax.tools.ToolProvider;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 import jdk.testlibrary.JDKToolFinder;
 import static java.lang.String.format;
 import static java.util.Arrays.asList;
@@ -55,8 +55,8 @@
  * @bug 8064924
  * @modules jdk.compiler
  * @summary Basic test for URLStreamHandlerProvider
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
+ * @library /lib/testlibrary /test/lib
+ * @build jdk.testlibrary.JDKToolFinder
  * @compile Basic.java Child.java
  * @run main Basic
  */
--- a/jdk/test/java/nio/Buffer/LimitDirectMemory.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/Buffer/LimitDirectMemory.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,6 +21,35 @@
  * questions.
  */
 
+/*
+ * @test
+ * @bug 4627316 6743526
+ * @summary Test option to limit direct memory allocation
+ * @requires (os.arch == "x86_64") | (os.arch == "amd64") | (os.arch == "sparcv9")
+ * @library /test/lib
+ *
+ * @summary Test: memory is properly limited using multiple buffers
+ * @run main/othervm -XX:MaxDirectMemorySize=10 LimitDirectMemory true 10 1
+ * @run main/othervm -XX:MaxDirectMemorySize=1k LimitDirectMemory true 1k 100
+ * @run main/othervm -XX:MaxDirectMemorySize=10m LimitDirectMemory true 10m 10m
+ *
+ * @summary Test: We can increase the amount of available memory
+ * @run main/othervm -XX:MaxDirectMemorySize=65M LimitDirectMemory false 64M 65M
+ *
+ * @summary Test: Exactly the default amount of memory is available
+ * @run main/othervm LimitDirectMemory false 10 1
+ * @run main/othervm -Xmx64m LimitDirectMemory false 0 DEFAULT
+ * @run main/othervm -Xmx64m LimitDirectMemory true 0 DEFAULT+1
+ *
+ * @summary Test: We should be able to eliminate direct memory allocation entirely
+ * @run main/othervm -XX:MaxDirectMemorySize=0 LimitDirectMemory true 0 1
+ *
+ * @summary Test: Setting the system property should not work so we should be able
+ *                to allocate the default amount
+ * @run main/othervm -Dsun.nio.MaxDirectMemorySize=1K -Xmx64m
+ *                   LimitDirectMemory false DEFAULT-1 DEFAULT/2
+ */
+
 import java.nio.ByteBuffer;
 import java.util.Properties;
 
@@ -28,8 +57,13 @@
     private static final int K = 1024;
 
     public static void main(String [] args) throws Exception {
-        if (args.length < 2)
-            throw new RuntimeException();
+        if (args.length < 2) {
+            throw new IllegalArgumentException("Usage: "
+                    + "java LimitDirectMemory"
+                    + " <OOME_expected(true|false)>"
+                    + " <fill_direct_memory>"
+                    + " <size_per_buffer>");
+        }
         boolean throwp = parseThrow(args[0]);
         int size = parseSize(args[1]);
         int incr = (args.length > 2 ? parseSize(args[2]) : size);
--- a/jdk/test/java/nio/Buffer/LimitDirectMemory.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,93 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
-# 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 4627316 6743526
-# @summary Test option to limit direct memory allocation
-#
-# @requires (os.arch == "x86_64") | (os.arch == "amd64") | (os.arch == "sparcv9")
-# @build LimitDirectMemory
-# @run shell LimitDirectMemory.sh
-
-TMP1=tmp_$$
-
-runTest() {
-  echo "Testing: $*"
-  ${TESTJAVA}/bin/java ${TESTVMOPTS} $*
-  if [ $? -eq 0 ]
-  then echo "--- passed as expected"
-  else
-    echo "--- failed"
-    exit 1
-  fi
-}
-
-
-launchFail() {
-  echo "Testing: -XX:MaxDirectMemorySize=$* -cp ${TESTCLASSES} \
-     LimitDirectMemory true DEFAULT DEFAULT+1M"
-  ${TESTJAVA}/bin/java ${TESTVMOPTS} -XX:MaxDirectMemorySize=$* -cp ${TESTCLASSES} \
-     LimitDirectMemory true DEFAULT DEFAULT+1M > ${TMP1} 2>&1
-  cat ${TMP1}
-  cat ${TMP1} | grep -s "Unrecognized VM option: \'MaxDirectMemorySize="
-  if [ $? -ne 0 ]
-    then echo "--- failed as expected"
-  else
-    echo "--- failed"
-    exit 1
-  fi
-}
-
-# $java LimitDirectMemory throwp fill_direct_memory size_per_buffer
-
-# Memory is properly limited using multiple buffers.
-runTest -XX:MaxDirectMemorySize=10 -cp ${TESTCLASSES} LimitDirectMemory true 10 1
-runTest -XX:MaxDirectMemorySize=1k -cp ${TESTCLASSES} LimitDirectMemory true 1k 100
-runTest -XX:MaxDirectMemorySize=10m -cp ${TESTCLASSES} LimitDirectMemory true 10m 10m
-
-# We can increase the amount of available memory.
-runTest -XX:MaxDirectMemorySize=65M -cp ${TESTCLASSES} \
-  LimitDirectMemory false 64M 65M
-
-# Exactly the default amount of memory is available.
-runTest -cp ${TESTCLASSES} LimitDirectMemory false 10 1
-runTest -Xmx64m -cp ${TESTCLASSES} LimitDirectMemory false 0 DEFAULT
-runTest -Xmx64m -cp ${TESTCLASSES} LimitDirectMemory true 0 DEFAULT+1
-
-# We should be able to eliminate direct memory allocation entirely.
-runTest -XX:MaxDirectMemorySize=0 -cp ${TESTCLASSES} LimitDirectMemory true 0 1
-
-# Setting the system property should not work so we should be able to allocate
-# the default amount.
-runTest -Dsun.nio.MaxDirectMemorySize=1K -Xmx64m -cp ${TESTCLASSES} \
-  LimitDirectMemory false DEFAULT-1 DEFAULT/2
-
-# Various bad values fail to launch the VM.
-launchFail foo
-launchFail 10kmt
-launchFail -1
-
-# Clean-up
-rm ${TMP1}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/Buffer/LimitDirectMemoryNegativeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,57 @@
+/*
+ * 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 4627316 6743526
+ * @summary Test option to limit direct memory allocation,
+ *          various bad values fail to launch the VM
+ * @requires (os.arch == "x86_64") | (os.arch == "amd64") | (os.arch == "sparcv9")
+ * @library /test/lib
+ *
+ * @run main LimitDirectMemoryNegativeTest foo
+ * @run main LimitDirectMemoryNegativeTest 10kmt
+ * @run main LimitDirectMemoryNegativeTest -1
+ */
+
+import jdk.test.lib.process.ProcessTools;
+
+public class LimitDirectMemoryNegativeTest {
+
+    private static final String ERR = "Improperly specified VM option 'MaxDirectMemorySize=";
+
+    public static void main(String[] args) throws Exception {
+        if (args.length != 1) {
+            throw new IllegalArgumentException("missing size argument");
+        }
+
+        int exitCode = ProcessTools.executeTestJava(
+                                    "-XX:MaxDirectMemorySize=" + args[0],
+                                    LimitDirectMemoryNegativeTest.class.getName())
+                                   .shouldContain(ERR + args[0])
+                                   .getExitValue();
+        if (exitCode != 1) {
+            throw new RuntimeException("Unexpected exit code: " + exitCode);
+        }
+    }
+}
--- a/jdk/test/java/nio/ByteOrder/NativeOrder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/ByteOrder/NativeOrder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -32,12 +32,19 @@
 
     public static void main(String[] args) throws Exception {
         ByteOrder bo = ByteOrder.nativeOrder();
-        System.err.println(bo);
+        System.err.println("ByteOrder.nativeOrder:" + bo);
         String arch = System.getProperty("os.arch");
+        System.err.println("os.arch:" + arch);
         if (((arch.equals("i386") && (bo != ByteOrder.LITTLE_ENDIAN))) ||
+            ((arch.equals("amd64") && (bo != ByteOrder.LITTLE_ENDIAN))) ||
+            ((arch.equals("x86_64") && (bo != ByteOrder.LITTLE_ENDIAN))) ||
+            ((arch.equals("ppc64") && (bo != ByteOrder.BIG_ENDIAN))) ||
+            ((arch.equals("ppc64le") && (bo != ByteOrder.LITTLE_ENDIAN))) ||
+            ((arch.equals("s390x") && (bo != ByteOrder.BIG_ENDIAN))) ||
             ((arch.equals("sparc") && (bo != ByteOrder.BIG_ENDIAN)))) {
             throw new Exception("Wrong byte order");
         }
+        System.err.println("test is OK");
     }
 
 }
--- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,21 @@
  * questions.
  */
 
-import java.nio.channels.AsynchronousChannelGroup;
-import java.util.concurrent.*;
+/*
+ * @test
+ * @bug 4607272
+ * @summary tests tasks can be submitted to a channel group's thread pool.
+ * @library /lib/testlibrary bootlib
+ * @build JarUtils PrivilegedThreadFactory Attack
+ * @run driver SetupJar
+ * @run main/othervm -Xbootclasspath/a:privileged.jar AsExecutor
+ */
 
-/**
- * Test that arbitrary tasks can be submitted to a channel group's thread pool.
- */
+import java.nio.channels.AsynchronousChannelGroup;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
 
 public class AsExecutor {
 
--- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Attack.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.net.*;
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * A task that attempts to attack the current host.
- */
-
-public class Attack implements Runnable {
-    private final CountDownLatch latch = new CountDownLatch(1);
-    private volatile boolean failedDueToSecurityException;
-
-    public void Attack() {
-        // check class is on boot class path
-        if (Attack.class.getClassLoader() != null)
-            throw new RuntimeException("Attack class not on boot class path");
-    }
-
-    @Override
-    public void run() {
-        try {
-            new Socket("127.0.0.1", 9999).close();
-            throw new RuntimeException("Connected (not expected)");
-        } catch (IOException e) {
-            throw new RuntimeException("IOException (not expected)");
-        } catch (SecurityException e) {
-            failedDueToSecurityException = true;
-        } finally {
-            latch.countDown();
-        }
-    }
-
-    public void waitUntilDone() throws InterruptedException {
-        latch.await();
-    }
-
-    public boolean failedDueToSecurityException() {
-        return failedDueToSecurityException;
-    }
-}
--- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/PrivilegedThreadFactory.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.util.concurrent.ThreadFactory;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-/**
- * The "privileged" ThreadFactory used by the AsExecutor test.
- */
-
-public class PrivilegedThreadFactory implements ThreadFactory {
-    public void PrivilegedThreadPoolFactory() {
-        // check class is on boot class path
-        if (PrivilegedThreadFactory.class.getClassLoader() != null)
-            throw new RuntimeException("PrivilegedThreadFactory class not on boot class path");
-    }
-
-    @Override
-    public Thread newThread(final Runnable r) {
-        return AccessController.doPrivileged(new PrivilegedAction<Thread>() {
-            @Override
-            public Thread run() {
-                Thread t = new Thread(r);
-                t.setDaemon(true);
-                return t;
-            }
-        });
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/SetupJar.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class SetupJar {
+
+    public static void main(String args[]) throws Exception {
+        Path classes = Paths.get(System.getProperty("test.classes", ""));
+        JarUtils.createJarFile(Paths.get("privileged.jar"),
+                               classes.resolve("bootlib"));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/bootlib/Attack.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.IOException;
+import java.net.Socket;
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * A task that attempts to attack the current host.
+ */
+
+public class Attack implements Runnable {
+    private final CountDownLatch latch = new CountDownLatch(1);
+    private volatile boolean failedDueToSecurityException;
+
+    public void Attack() {
+        // check class is on boot class path
+        if (Attack.class.getClassLoader() != null)
+            throw new RuntimeException("Attack class not on boot class path");
+    }
+
+    @Override
+    public void run() {
+        try {
+            new Socket("127.0.0.1", 9999).close();
+            throw new RuntimeException("Connected (not expected)");
+        } catch (IOException e) {
+            throw new RuntimeException("IOException (not expected)");
+        } catch (SecurityException e) {
+            failedDueToSecurityException = true;
+        } finally {
+            latch.countDown();
+        }
+    }
+
+    public void waitUntilDone() throws InterruptedException {
+        latch.await();
+    }
+
+    public boolean failedDueToSecurityException() {
+        return failedDueToSecurityException;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/bootlib/PrivilegedThreadFactory.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.concurrent.ThreadFactory;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * The "privileged" ThreadFactory used by the AsExecutor test.
+ */
+
+public class PrivilegedThreadFactory implements ThreadFactory {
+    public void PrivilegedThreadPoolFactory() {
+        // check class is on boot class path
+        if (PrivilegedThreadFactory.class.getClassLoader() != null)
+            throw new RuntimeException("PrivilegedThreadFactory class not on boot class path");
+    }
+
+    @Override
+    public Thread newThread(final Runnable r) {
+        return AccessController.doPrivileged(new PrivilegedAction<Thread>() {
+            @Override
+            public Thread run() {
+                Thread t = new Thread(r);
+                t.setDaemon(true);
+                return t;
+            }
+        });
+    }
+}
--- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +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.
-#
-# 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 4607272
-# @summary Unit test for AsynchronousChannelGrou#execute
-# @build AsExecutor PrivilegedThreadFactory Attack
-# @run shell run_any_task.sh
-
-# if TESTJAVA isn't set then we assume an interactive run.
-
-if [ -z "$TESTJAVA" ]; then
-    TESTSRC=.
-    TESTCLASSES=.
-    JAVA=java
-    JAR=jar
-else
-    JAVA="${TESTJAVA}/bin/java"
-    JAR="${TESTJAVA}/bin/jar"
-fi
-
-echo "Creating JAR file ..."
-$JAR -cf "${TESTCLASSES}/Privileged.jar" \
-    -C "${TESTCLASSES}" PrivilegedThreadFactory.class \
-    -C "${TESTCLASSES}" PrivilegedThreadFactory\$1.class \
-    -C "${TESTCLASSES}" Attack.class
-
-echo "Running test ..."
-$JAVA ${TESTVMOPTS} \
-      -Xbootclasspath/a:"${TESTCLASSES}/Privileged.jar" \
-      -classpath "${TESTCLASSES}" \
-      AsExecutor
--- a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java	Wed Jul 05 23:37:13 2017 +0200
@@ -24,8 +24,7 @@
 /* @test
  * @bug 4607272 6842687 6878369 6944810 7023403
  * @summary Unit test for AsynchronousSocketChannel(use -Dseed=X to set PRNG seed)
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main Basic -skipSlowConnectTest
  * @key randomness intermittent
  */
@@ -40,7 +39,7 @@
 import java.util.Set;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class Basic {
     private static final Random RAND = RandomFactory.getRandom();
--- a/jdk/test/java/nio/channels/DatagramChannel/BasicMulticastTests.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/channels/DatagramChannel/BasicMulticastTests.java	Wed Jul 05 23:37:13 2017 +0200
@@ -24,7 +24,8 @@
 /* @test
  * @bug 4527345
  * @summary Unit test for DatagramChannel's multicast support
- * @build BasicMulticastTests NetworkConfiguration
+ * @library /test/lib
+ * @build BasicMulticastTests
  * @run main BasicMulticastTests
  */
 
@@ -34,6 +35,8 @@
 import java.util.*;
 import java.io.IOException;
 
+import jdk.test.lib.NetworkConfiguration;
+
 public class BasicMulticastTests {
 
     /**
@@ -204,14 +207,14 @@
 
         NetworkConfiguration config = NetworkConfiguration.probe();
 
-        NetworkInterface nif = config.ip4Interfaces().iterator().next();
+        NetworkInterface nif = config.ip4MulticastInterfaces().iterator().next();
         InetAddress anySource = config.ip4Addresses(nif).iterator().next();
         membershipKeyTests(nif, ip4Group, anySource);
         exceptionTests(nif);
 
         // re-run the membership key tests with IPv6 if available
 
-        Iterator<NetworkInterface> iter = config.ip6Interfaces().iterator();
+        Iterator<NetworkInterface> iter = config.ip6MulticastInterfaces().iterator();
         if (iter.hasNext()) {
             nif = iter.next();
             anySource = config.ip6Addresses(nif).iterator().next();
--- a/jdk/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/channels/DatagramChannel/MulticastSendReceiveTests.java	Wed Jul 05 23:37:13 2017 +0200
@@ -24,7 +24,8 @@
 /* @test
  * @bug 4527345 7026376 6633549
  * @summary Unit test for DatagramChannel's multicast support
- * @build MulticastSendReceiveTests NetworkConfiguration
+ * @library /test/lib
+ * @build MulticastSendReceiveTests
  * @run main MulticastSendReceiveTests
  * @run main/othervm -Djava.net.preferIPv4Stack=true MulticastSendReceiveTests
  * @key randomness
@@ -36,6 +37,9 @@
 import static java.net.StandardProtocolFamily.*;
 import java.util.*;
 import java.io.IOException;
+import java.util.stream.Collectors;
+
+import jdk.test.lib.NetworkConfiguration;
 
 public class MulticastSendReceiveTests {
 
@@ -238,14 +242,15 @@
         // multicast groups used for the test
         InetAddress ip4Group = InetAddress.getByName("225.4.5.6");
         InetAddress ip6Group = InetAddress.getByName("ff02::a");
-
-        for (NetworkInterface nif: config.ip4Interfaces()) {
+        for (NetworkInterface nif: config.ip4MulticastInterfaces()
+                                         .collect(Collectors.toList())) {
             InetAddress source = config.ip4Addresses(nif).iterator().next();
             test(INET,   nif, ip4Group, source);
             test(UNSPEC, nif, ip4Group, source);
         }
 
-        for (NetworkInterface nif: config.ip6Interfaces()) {
+        for (NetworkInterface nif: config.ip6MulticastInterfaces()
+                                         .collect(Collectors.toList())) {
             InetAddress source = config.ip6Addresses(nif).iterator().next();
             test(INET6,  nif, ip6Group, source);
             test(UNSPEC, nif, ip6Group, source);
--- a/jdk/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-/*
- * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.net.*;
-import java.util.*;
-import java.io.IOException;
-
-/**
- * Helper class for multicasting tests.
- */
-
-class NetworkConfiguration {
-
-    private Map<NetworkInterface,List<InetAddress>> ip4Interfaces;
-    private Map<NetworkInterface,List<InetAddress>> ip6Interfaces;
-
-    private NetworkConfiguration(Map<NetworkInterface,List<InetAddress>> ip4Interfaces,
-                                 Map<NetworkInterface,List<InetAddress>> ip6Interfaces)
-    {
-        this.ip4Interfaces = ip4Interfaces;
-        this.ip6Interfaces = ip6Interfaces;
-    }
-
-    Iterable<NetworkInterface> ip4Interfaces() {
-        return ip4Interfaces.keySet();
-    }
-
-    Iterable<NetworkInterface> ip6Interfaces() {
-        return ip6Interfaces.keySet();
-    }
-
-    Iterable<InetAddress> ip4Addresses(NetworkInterface nif) {
-        return ip4Interfaces.get(nif);
-    }
-
-    Iterable<InetAddress> ip6Addresses(NetworkInterface nif) {
-        return ip6Interfaces.get(nif);
-    }
-
-    private static final boolean isMacOs =
-            System.getProperty("os.name").equals("Mac OS X");
-
-    static NetworkConfiguration probe() throws IOException {
-        Map<NetworkInterface,List<InetAddress>> ip4Interfaces =
-            new HashMap<NetworkInterface,List<InetAddress>>();
-        Map<NetworkInterface,List<InetAddress>> ip6Interfaces =
-            new HashMap<NetworkInterface,List<InetAddress>>();
-
-        // find the interfaces that support IPv4 and IPv6
-        List<NetworkInterface> nifs = Collections
-            .list(NetworkInterface.getNetworkInterfaces());
-        for (NetworkInterface nif: nifs) {
-            // ignore intertaces that are down or don't support multicast
-            if (!nif.isUp() || !nif.supportsMulticast() || nif.isLoopback()
-                || (isMacOs && nif.getName().contains("awdl")))
-                continue;
-
-            List<InetAddress> addrs = Collections.list(nif.getInetAddresses());
-            for (InetAddress addr: addrs) {
-                if (!addr.isAnyLocalAddress()) {
-                    if (addr instanceof Inet4Address) {
-                        List<InetAddress> list = ip4Interfaces.get(nif);
-                        if (list == null) {
-                            list = new LinkedList<InetAddress>();
-                        }
-                        list.add(addr);
-                        ip4Interfaces.put(nif, list);
-                    } else if (addr instanceof Inet6Address) {
-                        List<InetAddress> list = ip6Interfaces.get(nif);
-                        if (list == null) {
-                            list = new LinkedList<InetAddress>();
-                        }
-                        list.add(addr);
-                        ip6Interfaces.put(nif, list);
-                    }
-                }
-            }
-        }
-        return new NetworkConfiguration(ip4Interfaces, ip6Interfaces);
-    }
-}
--- a/jdk/test/java/nio/channels/DatagramChannel/Promiscuous.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/channels/DatagramChannel/Promiscuous.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,7 +25,8 @@
  * @bug 8014377
  * @summary Test for interference when two sockets are bound to the same
  *   port but joined to different multicast groups
- * @build Promiscuous  NetworkConfiguration
+ * @library /test/lib
+ * @build Promiscuous
  * @run main Promiscuous
  * @run main/othervm -Djava.net.preferIPv4Stack=true Promiscuous
  * @key randomness
@@ -37,6 +38,9 @@
 import static java.net.StandardProtocolFamily.*;
 import java.util.*;
 import java.io.IOException;
+import java.util.stream.Collectors;
+
+import jdk.test.lib.NetworkConfiguration;
 
 public class Promiscuous {
 
@@ -208,7 +212,8 @@
         InetAddress ip4Group1 = InetAddress.getByName("225.4.5.6");
         InetAddress ip4Group2 = InetAddress.getByName("225.4.6.6");
 
-        for (NetworkInterface nif: config.ip4Interfaces()) {
+        for (NetworkInterface nif: config.ip4MulticastInterfaces()
+                                         .collect(Collectors.toList())) {
             InetAddress source = config.ip4Addresses(nif).iterator().next();
             test(INET, nif, ip4Group1, ip4Group2);
 
--- a/jdk/test/java/nio/channels/FileChannel/Transfer.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/channels/FileChannel/Transfer.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,8 +25,7 @@
  * @bug 4434723 4482726 4559072 4795550 5081340 5103988 6984545
  * @summary Test FileChannel.transferFrom and transferTo (use -Dseed=X to set PRNG seed)
  * @library ..
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run testng/timeout=300 Transfer
  * @key randomness
  */
@@ -51,7 +50,7 @@
 import java.util.Random;
 import java.util.concurrent.TimeUnit;
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 import org.testng.annotations.Test;
 
--- a/jdk/test/java/nio/channels/Selector/LotsOfUpdates.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/channels/Selector/LotsOfUpdates.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,8 +21,10 @@
  * questions.
  */
 
-import java.nio.channels.*;
 import java.io.IOException;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.SocketChannel;
 
 public class LotsOfUpdates {
     public static void main(String[] args) throws IOException {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/channels/Selector/LotsOfUpdatesTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6824477
+ * @summary Selector.select can fail with IOException "Invalid argument" on
+ *     Solaris if maximum number of file descriptors is less than 10000
+ * @requires (os.family != "windows")
+ * @library /test/lib
+ * @build LotsOfUpdates
+ * @run main LotsOfUpdatesTest
+ */
+
+import jdk.test.lib.process.ProcessTools;
+
+public class LotsOfUpdatesTest {
+
+    //hard limit needs to be less than 10000 for this bug
+    private static final String ULIMIT_SET_CMD = "ulimit -n 2048";
+
+    private static final String JAVA_CMD = ProcessTools.getCommandLine(
+            ProcessTools.createJavaProcessBuilder(LotsOfUpdates.class.getName()));
+
+    public static void main(String[] args) throws Throwable {
+        ProcessTools.executeCommand("sh", "-c", ULIMIT_SET_CMD + " && " + JAVA_CMD)
+                    .shouldHaveExitValue(0);
+    }
+}
--- a/jdk/test/java/nio/channels/Selector/lots_of_updates.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-#
-# Copyright (c) 2009, 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.
-#
-
-# @test
-# @bug 6824477
-# @summary Selector.select can fail with IOException "Invalid argument" on
-#     Solaris if maximum number of file descriptors is less than 10000
-# @build LotsOfUpdates
-# @run shell lots_of_updates.sh
-
-OS=`uname -s`
-case "$OS" in
-    Windows_* | CYGWIN* )
-        echo "ulimit not on Windows"
-        exit 0
-        ;;
-    * )
-        CLASSPATH=${TESTCLASSES}:${TESTSRC}
-        ;;
-esac
-export CLASSPATH
-
-# hard limit needs to be less than 10000 for this bug
-NOFILES=`ulimit -n -H`
-if [ "$NOFILES" = "unlimited" ] || [ $NOFILES -ge 10000 ]; then
-    ulimit -n 2048
-fi
-
-${TESTJAVA}/bin/java ${TESTVMOPTS} LotsOfUpdates
--- a/jdk/test/java/nio/channels/SocketChannel/Open.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/channels/SocketChannel/Open.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2007, 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
@@ -21,16 +21,11 @@
  * questions.
  */
 
-/* @test
- * @bug 4614065
- * @summary Test SocketChannel gc after running out of fds
- * @build Open
- * @run shell Open.sh
- */
-
-import java.net.*;
-import java.nio.*;
-import java.nio.channels.*;
+import java.net.SocketException;
+import java.nio.channels.DatagramChannel;
+import java.nio.channels.Pipe;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
 import java.nio.channels.spi.SelectorProvider;
 
 public class Open {
--- a/jdk/test/java/nio/channels/SocketChannel/Open.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-#! /bin/sh
-
-#
-# Copyright (c) 2002, 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.
-#
-
-#
-
-    OS=`uname -s`
-    case "$OS" in
-        SunOS )
-            ulimit -n 100
-            $TESTJAVA/bin/java ${TESTVMOPTS} -classpath $TESTCLASSES Open ;;
-        * )
-            echo "unrecognized system: $OS" ;;
-    esac
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/channels/SocketChannel/OpenSocketChannelTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * 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 4614065
+ * @summary Test SocketChannel gc after running out of fds
+ * @requires (os.family == "solaris")
+ * @library /test/lib
+ * @build Open
+ * @run main OpenSocketChannelTest
+ */
+
+import jdk.test.lib.process.ProcessTools;
+
+public class OpenSocketChannelTest {
+
+    //hard limit needs to be small for this bug
+    private static final String ULIMIT_SET_CMD = "ulimit -n 100";
+
+    private static final String JAVA_CMD = ProcessTools.getCommandLine(
+            ProcessTools.createJavaProcessBuilder(Open.class.getName()));
+
+    public static void main(String[] args) throws Throwable {
+        ProcessTools.executeCommand("sh", "-c", ULIMIT_SET_CMD + " && " + JAVA_CMD)
+                    .shouldHaveExitValue(0);
+    }
+}
--- a/jdk/test/java/nio/channels/SocketChannel/VectorIO.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/channels/SocketChannel/VectorIO.java	Wed Jul 05 23:37:13 2017 +0200
@@ -23,8 +23,7 @@
 
 /* @test
  * @summary Test socketchannel vector IO (use -Dseed=X to set PRNG seed)
- * @library .. /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library .. /test/lib
  * @run main VectorIO
  * @key randomness
  */
@@ -34,7 +33,7 @@
 import java.nio.*;
 import java.nio.channels.*;
 import java.util.*;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class VectorIO {
 
--- a/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh	Wed Jul 05 23:37:13 2017 +0200
@@ -47,12 +47,7 @@
     TESTCLASSES=`pwd`
     JAVA=java
     which $JAVA
-    ${JAVA} -d64 -version > /dev/null 2<&1
-    if [ $? = 1 ]; then
 	${JAVA} -version
-    else
-	${JAVA} -d64 -version
-    fi
 else
     JAVA="${TESTJAVA}/bin/java"
 fi
--- a/jdk/test/java/nio/file/FileStore/Basic.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/file/FileStore/Basic.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,9 +25,7 @@
  * @bug 4313887 6873621 6979526 7006126 7020517
  * @summary Unit test for java.nio.file.FileStore
  * @key intermittent
- * @library ..
- * @library .. /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library .. /test/lib
  * @run main Basic
  */
 
@@ -35,8 +33,8 @@
 import java.nio.file.attribute.*;
 import java.io.File;
 import java.io.IOException;
-import java.util.*;
-import jdk.testlibrary.FileUtils;
+
+import jdk.test.lib.util.FileUtils;
 
 
 public class Basic {
--- a/jdk/test/java/nio/file/FileSystem/Basic.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/file/FileSystem/Basic.java	Wed Jul 05 23:37:13 2017 +0200
@@ -24,8 +24,7 @@
 /* @test
  * @bug 4313887 6838333 8132497
  * @summary Unit test for java.nio.file.FileSystem
- * @library .. /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library .. /test/lib
  * @run main/othervm Basic
  */
 
@@ -41,7 +40,7 @@
 import java.nio.file.Paths;
 import java.nio.file.ProviderNotFoundException;
 import java.util.HashMap;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 
 /**
  * Simple sanity checks for java.nio.file.FileSystem
--- a/jdk/test/java/nio/file/Files/CopyAndMove.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/file/Files/CopyAndMove.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,8 @@
 /* @test
  * @bug 4313887 6838333 6917021 7006126 6950237 8006645
  * @summary Unit test for java.nio.file.Files copy and move methods (use -Dseed=X to set PRNG seed)
- * @library .. /lib/testlibrary/
- * @build jdk.testlibrary.* CopyAndMove PassThroughFileSystem
+ * @library .. /test/lib
+ * @build CopyAndMove PassThroughFileSystem
  * @run main/othervm CopyAndMove
  * @key randomness
  */
@@ -39,7 +39,7 @@
 import java.io.*;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class CopyAndMove {
     static final Random rand = RandomFactory.getRandom();
--- a/jdk/test/java/nio/file/Files/DeleteOnClose.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/file/Files/DeleteOnClose.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,20 +21,53 @@
  * questions.
  */
 
-import java.nio.file.*;
-import static java.nio.file.StandardOpenOption.*;
-import java.io.*;
-import java.util.*;
+/*
+ * @test
+ * @bug 4313887
+ * @summary Unit test for DELETE_ON_CLOSE open option
+ * @library /test/lib ..
+ */
+
+import java.io.IOException;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.OpenOption;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.SecureDirectoryStream;
+import java.util.HashSet;
+import java.util.Set;
+
+import jdk.test.lib.process.ProcessTools;
+
+import static java.nio.file.StandardOpenOption.READ;
+import static java.nio.file.StandardOpenOption.WRITE;
+import static java.nio.file.StandardOpenOption.DELETE_ON_CLOSE;
 
 public class DeleteOnClose {
 
-    public static void main(String[] args) throws IOException {
-        // open file but do not close it. Its existance will be checked by
-        // the calling script.
-        Files.newByteChannel(Paths.get(args[0]), READ, WRITE, DELETE_ON_CLOSE);
+    public static void main(String[] args) throws Exception {
+        if (args.length == 0) {
+            Path file = Files.createTempFile("blah", "tmp");
+            ProcessTools.executeTestJava(DeleteOnClose.class.getName(),
+                                         file.toAbsolutePath().toString())
+                        .shouldHaveExitValue(0);
+            runTest(file);
+        } else {
+            // open file but do not close it. Its existance will be checked by
+            // the caller.
+            Files.newByteChannel(Paths.get(args[0]), READ, WRITE, DELETE_ON_CLOSE);
+        }
+    }
+
+    public static void runTest(Path path) throws Exception {
+        // check temporary file has been deleted after jvm termination
+        if (Files.exists(path)) {
+            throw new RuntimeException("Temporary file was not deleted");
+        }
 
         // check temporary file has been deleted after closing it
-        Path file = Files.createTempFile("blah", "tmp");
+        Path file = Files.createTempFile("blep", "tmp");
         Files.newByteChannel(file, READ, WRITE, DELETE_ON_CLOSE).close();
         if (Files.exists(file))
             throw new RuntimeException("Temporary file was not deleted");
--- a/jdk/test/java/nio/file/Files/StreamLinesTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/file/Files/StreamLinesTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,8 @@
 
 /* @test
  * @bug 8072773
- * @library /lib/testlibrary/ ../../../util/stream/bootlib
+ * @library /test/lib /lib/testlibrary/bootlib
  * @build java.base/java.util.stream.OpTestCase
- * @build jdk.testlibrary.RandomFactory
  * @run testng/othervm StreamLinesTest
  * @summary Tests streams returned from Files.lines, primarily focused on
  *          testing the file-channel-based stream stream with supported
@@ -54,7 +53,7 @@
 import java.util.stream.OpTestCase;
 import java.util.stream.Stream;
 import java.util.stream.TestData;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class StreamLinesTest extends OpTestCase {
 
--- a/jdk/test/java/nio/file/Files/delete_on_close.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +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.
-#
-# 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 4313887
-# @summary Unit test for DELETE_ON_CLOSE open option
-# @library ..
-# @build DeleteOnClose
-# @run shell delete_on_close.sh
-
-# if TESTJAVA isn't set then we assume an interactive run.
-
-if [ -z "$TESTJAVA" ]; then
-    TESTSRC=.
-    TESTCLASSES=.
-    JAVA=java
-else
-    JAVA="${TESTJAVA}/bin/java"
-fi
-
-OS=`uname -s`
-case "$OS" in
-    Windows_* | CYGWIN* )
-        CLASSPATH="${TESTCLASSES};${TESTSRC}"
-        ;;
-    * )
-        CLASSPATH=${TESTCLASSES}:${TESTSRC}
-        ;;
-esac
-export CLASSPATH
-
-TMPFILE="$$.tmp"
-touch $TMPFILE
-$JAVA ${TESTVMOPTS} DeleteOnClose $TMPFILE 2>&1
-if [ $? != 0 ]; then exit 1; fi
-if [ -f $TMPFILE ]; then
-    echo "$TMPFILE was not deleted"
-    exit 1
-fi
-
-exit 0
--- a/jdk/test/java/nio/file/WatchService/LotsOfEvents.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/nio/file/WatchService/LotsOfEvents.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,8 +25,7 @@
  * @bug 6907760 6929532
  * @summary Tests WatchService behavior when lots of events are pending (use -Dseed=X to set PRNG seed)
  * @library ..
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main/timeout=180 LotsOfEvents
  * @key randomness
  */
@@ -37,7 +36,7 @@
 import static java.nio.file.StandardWatchEventKinds.*;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class LotsOfEvents {
 
--- a/jdk/test/java/rmi/module/ModuleTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/rmi/module/ModuleTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @build jdk.testlibrary.ProcessTools
- *        ModuleTest CompilerUtils JarUtils
+ *        ModuleTest jdk.test.lib.compiler.CompilerUtils JarUtils
  * @run testng ModuleTest
  * @summary Basic tests for using rmi in module world
  */
@@ -36,6 +36,7 @@
 
 import java.io.File;
 import java.nio.file.Paths;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/jdk/test/java/security/AccessController/DoPrivAccompliceTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/security/AccessController/DoPrivAccompliceTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,76 +23,90 @@
  * questions.
  */
 
-import java.io.File;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.util.JarUtils;
+
 import java.io.FileWriter;
 import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 
 /*
  * @test
  * @bug 8048362
- * @compile ../../../lib/testlibrary/JavaToolUtils.java
- *                             DoPrivAccomplice.java DoPrivTest.java
  * @summary Tests the doPrivileged with accomplice Generate two jars
  * (DoPrivTest.jar and DoPrivAccomplice.jar) and grant permission to
- * DoPrivAccmplice.jar for reading user.home property from a PrivilagedAction.
- * Run DoPrivTest.jar and try to access user.home property using
+ * DoPrivAccmplice.jar for reading user.name property from a PrivilagedAction.
+ * Run DoPrivTest.jar and try to access user.name property using
  * DoPrivAccmplice.jar.
- * @modules jdk.compiler
+ *
+ * @library /test/lib
+ *
  * @run main/othervm DoPrivAccompliceTest
  */
 
 public class DoPrivAccompliceTest {
+    private static final String ACTION_SOURCE = DoPrivAccomplice.class.getName();
+    private static final String TEST_SOURCE = DoPrivTest.class.getName();
 
-    private static final String PWD = System.getProperty("test.classes", "./");
-    private static final String ACTION_SOURCE = "DoPrivAccomplice";
-    private static final String TEST_SOURCE = "DoPrivTest";
-
-    public static void createPolicyFile(URI codebaseURL) throws IOException {
-        String codebase = codebaseURL.toString();
+    private static void createPolicyFile(Path jarFile, Path policy) {
+        String codebase = jarFile.toFile().toURI().toString();
         String quotes = "\"";
         StringBuilder policyFile = new StringBuilder();
-        policyFile.append("grant codeBase ").append(quotes).
-                append(codebase).append(quotes).append("{\n").
-                append("permission java.util.PropertyPermission ").
-                append(quotes).append("user.name").append(quotes).
-                append(",").append(quotes).append("read").append(quotes).
-                append(";\n};");
-        try (FileWriter writer = new FileWriter(new File(PWD, "java.policy"))) {
+        policyFile.append("grant codeBase ")
+                  .append(quotes).append(codebase).append(quotes)
+                  .append("{\n")
+                  .append("permission java.util.PropertyPermission ")
+                  .append(quotes).append("user.name").append(quotes)
+                  .append(",")
+                  .append(quotes).append("read").append(quotes)
+                  .append(";\n};");
+        try (FileWriter writer = new FileWriter(policy.toFile())) {
             writer.write(policyFile.toString());
-            writer.close();
         } catch (IOException e) {
-            System.err.println("Error while creating policy file");
-            throw e;
+            throw new Error("Error while creating policy file " + policy, e);
         }
     }
 
     public static void main(String[] args) throws Exception {
-        final File class1 = new File(PWD, ACTION_SOURCE + ".class");
-        final File class2 = new File(PWD, TEST_SOURCE + ".class");
-        final File jarFile1 = new File(PWD, ACTION_SOURCE + ".jar");
-        final File jarFile2 = new File(PWD, TEST_SOURCE + ".jar");
-        System.out.println("Compilation successfull");
-        JavaToolUtils.createJar(jarFile1, Arrays.asList(new File[]{class1}));
+        // copy class files to pwd
+        ClassFileInstaller.main(ACTION_SOURCE, TEST_SOURCE);
+        Path pwd = Paths.get(".");
+        Path jarFile1 = pwd.resolve(ACTION_SOURCE + ".jar").toAbsolutePath();
+        Path jarFile2 = pwd.resolve(TEST_SOURCE + ".jar").toAbsolutePath();
+        Path policy = pwd.resolve("java.policy").toAbsolutePath();
+
+        JarUtils.createJar(jarFile1.toString(), ACTION_SOURCE + ".class");
         System.out.println("Created jar file " + jarFile1);
-        JavaToolUtils.createJar(jarFile2, Arrays.asList(new File[]{class2}));
+        JarUtils.createJar(jarFile2.toString(), TEST_SOURCE + ".class");
         System.out.println("Created jar file " + jarFile2);
-        createPolicyFile(jarFile1.toURI());
+
 
-        List<String> commands = new ArrayList<>();
-        final String pathSepartor = System.getProperty("path.separator");
-        commands.add("-Djava.security.manager");
-        commands.add("-Djava.security.policy=" + PWD + "/java.policy");
-        commands.add("-classpath");
-        commands.add(PWD + "/" + TEST_SOURCE + ".jar" + pathSepartor
-                + PWD + "/" + ACTION_SOURCE + ".jar");
-        commands.add(TEST_SOURCE);
-        if (JavaToolUtils.runJava(commands) == 0) {
-            System.out.println("Test PASSES");
-        }
+        String pathSepartor = System.getProperty("path.separator");
+        String[] commands = {
+                "-Djava.security.manager",
+                "-Djava.security.policy=" + policy,
+                "-classpath", jarFile1 + pathSepartor + jarFile2,
+                TEST_SOURCE
+        };
+
+        String userName = System.getProperty("user.name");
+
+        createPolicyFile(jarFile1, policy);
+        System.out.println("Created policy for " + jarFile1);
+        ProcessTools.executeTestJava(commands)
+                    .shouldHaveExitValue(0)
+                    .shouldContain(userName)
+                    .stderrShouldBeEmpty();
+
+        createPolicyFile(jarFile2, policy);
+        System.out.println("Created policy for " + jarFile2);
+        ProcessTools.executeTestJava(commands)
+                    .shouldNotHaveExitValue(0)
+                    .shouldNotContain(userName)
+                    .stderrShouldContain("java.security.AccessControlException");
+
+        System.out.println("Test PASSES");
     }
-
 }
--- a/jdk/test/java/security/KeyStore/PKCS12/EntryProtectionTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/security/KeyStore/PKCS12/EntryProtectionTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 import java.util.List;
 import java.util.Random;
 import javax.crypto.spec.PBEParameterSpec;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 import static java.lang.System.out;
 import java.util.Arrays;
 
@@ -40,7 +40,7 @@
  * @summary Test for feature 'support stronger entry protection'. An entry is
  * stored to keystore with different PasswordProtection objects which are
  * specified by different PBE algorithms (use -Dseed=X to set PRNG seed)
- * @library /lib/testlibrary ../
+ * @library /test/lib /lib/testlibrary ../
  * @key randomness
  */
 public class EntryProtectionTest {
--- a/jdk/test/java/security/MessageDigest/TestDigestIOStream.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/security/MessageDigest/TestDigestIOStream.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +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
@@ -32,7 +31,7 @@
 import java.security.Security;
 import java.util.Arrays;
 import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 import static java.lang.System.out;
 
 /**
@@ -41,7 +40,7 @@
  * @summary MessageDigest tests with DigestIOStream
  * @author Kevin Liu
  * @key randomness
- * @library /lib/testlibrary
+ * @library /test/lib
  * @run main/timeout=180 TestDigestIOStream
  */
 
--- a/jdk/test/java/security/MessageDigest/TestSameLength.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/security/MessageDigest/TestSameLength.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +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
@@ -27,7 +26,7 @@
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.security.Security;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /**
  * @test
@@ -36,7 +35,7 @@
  *          algorithm/dataLen/(update,digest methods).
  * @author Kevin Liu
  * @key randomness
- * @library /lib/testlibrary
+ * @library /test/lib
  */
 
 public class TestSameLength {
--- a/jdk/test/java/security/MessageDigest/TestSameValue.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/security/MessageDigest/TestSameValue.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +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
@@ -28,7 +27,7 @@
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.security.Security;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /**
  * @test
@@ -37,7 +36,7 @@
  *          with various update/digest methods.
  * @author Kevin Liu
  * @key randomness
- * @library /lib/testlibrary
+ * @library /test/lib
  */
 
 public class TestSameValue {
--- a/jdk/test/java/security/PermissionCollection/PermissionCollectionStreamTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/security/PermissionCollection/PermissionCollectionStreamTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 /* @test
  * @bug 8081678
  * @summary Tests for stream returning methods
- * @library ../../util/stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.stream.OpTestCase
  * @run testng/othervm PermissionCollectionStreamTest
  */
--- a/jdk/test/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,13 +27,13 @@
 import java.nio.file.Paths;
 import java.security.AccessController;
 import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8050402
  * @summary Check policy is extensible with user defined permissions
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @compile TVJar/TVPermission.java
  * @run main ExtensiblePolicyWithJarTest
  */
--- a/jdk/test/java/security/Provider/ProviderVersionCheck.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/security/Provider/ProviderVersionCheck.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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;
--- a/jdk/test/java/security/Provider/SecurityProviderModularTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/security/Provider/SecurityProviderModularTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,6 +33,7 @@
 import java.lang.module.ModuleDescriptor;
 import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.compiler.CompilerUtils;
 import org.testng.annotations.BeforeTest;
 
 /**
@@ -40,8 +41,9 @@
  * @bug 8130360
  * @library /lib/testlibrary
  * @library /java/security/modules
+ * @library /test/lib
  * @modules java.base/jdk.internal.module
- * @build CompilerUtils JarUtils
+ * @build jdk.test.lib.compiler.CompilerUtils JarUtils
  * @summary Test custom security provider module with all possible modular
  *          condition. The test includes different combination of security
  *          client/provider modules interaction with or without service
--- a/jdk/test/java/security/Signature/Offsets.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/security/Signature/Offsets.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 import java.security.PublicKey;
 import java.security.Signature;
 import java.security.SignatureException;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /*
  * @test
@@ -41,7 +41,7 @@
  *          get random set of clear text data to sign. After the signature
  *          generation, the test tries to verify signature with the above API
  *          and passing in different signature offset (0, 33, 66, 99).
- * @library /lib/testlibrary
+ * @library /test/lib
  * @run main Offsets SUN NONEwithDSA
  * @run main Offsets SUN SHA1withDSA
  * @run main Offsets SUN SHA224withDSA
--- a/jdk/test/java/security/cert/PKIXRevocationChecker/OcspUnauthorized.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/security/cert/PKIXRevocationChecker/OcspUnauthorized.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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");
+            }
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/cert/X509CRL/VerifyDefault.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/security/cert/X509Certificate/VerifyDefault.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
+    }
+}
--- a/jdk/test/java/security/testlibrary/CertUtils.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/security/testlibrary/CertUtils.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/text/Format/DecimalFormat/Bug6609740.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+/*
+ * @test
+ * @bug 6609740
+ * @summary Checks the formatting and parsing of a number based
+ *          on the positive and negative sub-patterns, also
+ *          checks few invalid number patterns
+ */
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Locale;
+
+public class Bug6609740 {
+
+    public static void main(String[] args) {
+
+        double dNumber = -3456.349347;
+        String fOutput = "(3,456.35)";
+        String[] validCases = {"#,##0.0#;(#,##0.0#)", "#,##0.0#;(#)",
+            "#,##0.0#;(#,##0)"};
+
+        // formatting with the valid cases
+        NumberFormat nf = NumberFormat.getInstance(Locale.US);
+        for (String pattern : validCases) {
+            formatOnPattern(nf, pattern, dNumber, fOutput);
+        }
+
+        // parsing with the valid cases
+        String parseString = "(3,456.35)";
+        Number pOutput = -3456.35;
+        for (String pattern : validCases) {
+            parseOnPattern(nf, pattern, parseString, pOutput);
+        }
+
+        // should throw parse exception
+        String[] invalidParseCases = {"#,##0.0#;0", "#,##0.0#;()"};
+        for (String pattern : invalidParseCases) {
+            if (nf instanceof DecimalFormat) {
+                ((DecimalFormat) nf).applyPattern(pattern);
+            }
+
+            try {
+                nf.parse(parseString);
+            } catch (ParseException ex) {
+                continue;
+            }
+            throw new RuntimeException("[FAILED: Should throw"
+                    + " ParseException for pattern: "
+                    + pattern + " and input: " + parseString + "]");
+        }
+
+        // should throw exception on invalid patterns
+        // invalid patterns: no positive subpattern, zero after non-zero in
+        // the decimal part i.e. 0#0, multiple decimal separators,
+        // multiple percent, malformed pattern
+        String[] invalidPatterns = {";(#,##0.0#)", "#,##0.0#0;(#)",
+            "#,##0.0.#", "#,##0%%", ".#,##0"};
+        for (String pattern : invalidPatterns) {
+            if (nf instanceof DecimalFormat) {
+                try {
+                    ((DecimalFormat) nf).applyPattern(pattern);
+                } catch (IllegalArgumentException ex) {
+                    continue;
+                }
+                throw new RuntimeException("[FAILED: Should throw"
+                        + " IllegalArgumentException for invalid pattern: "
+                        + pattern + "]");
+            }
+        }
+    }
+
+    private static void formatOnPattern(NumberFormat nf, String pattern,
+            double number, String expected) {
+
+        if (nf instanceof DecimalFormat) {
+            ((DecimalFormat) nf).applyPattern(pattern);
+        }
+
+        String formatted = nf.format(number);
+        if (!formatted.equals(expected)) {
+            throw new RuntimeException("[FAILED: Unable to format the number"
+                    + " based on the pattern: '" + pattern + "', Expected : '"
+                    + expected + "', Found: '" + formatted + "']");
+        }
+    }
+
+    private static void parseOnPattern(NumberFormat nf, String pattern,
+            String parseString, Number expected) {
+
+        if (nf instanceof DecimalFormat) {
+            ((DecimalFormat) nf).applyPattern(pattern);
+        }
+
+        try {
+            Number output = nf.parse(parseString);
+            if (expected.doubleValue() != output.doubleValue()) {
+                throw new RuntimeException("[FAILED: Unable to parse the number"
+                        + " based on the pattern: '" + pattern + "', Expected : '"
+                        + expected + "', Found: '" + output + "']");
+            }
+        } catch (ParseException ex) {
+            throw new RuntimeException("[FAILED: Unable to parse the pattern:"
+                    + " '" + pattern + "']", ex);
+        }
+    }
+
+}
--- a/jdk/test/java/util/Arrays/Big.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/Arrays/Big.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 
 // A proper regression test for 5045582 requires too much memory.
 // If you have a really big machine, run like this:
-// java -d64 -Xms25g -Xmx25g Big 30
+// java -Xms25g -Xmx25g Big 30
 
 import java.util.*;
 
@@ -68,7 +68,7 @@
         }
 
         // To test Object arrays larger than 1<<30, you need 13GB. Run like:
-        // java -d64 -Xms13g -Xmx13g Big 30 2
+        // java -Xms13g -Xmx13g Big 30 2
         if ((tasks & 0x2) != 0) {
             System.out.println("Integer[]");
             System.gc();
--- a/jdk/test/java/util/Base64/TestBase64.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/Base64/TestBase64.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,7 @@
  * @test 4235519 8004212 8005394 8007298 8006295 8006315 8006530 8007379 8008925
  *       8014217 8025003 8026330 8028397 8129544 8165243
  * @summary tests java.util.Base64
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main TestBase64
  * @key randomness
  */
@@ -43,7 +42,7 @@
 import java.util.List;
 import java.util.Random;
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class TestBase64 {
 
--- a/jdk/test/java/util/BitSet/stream/BitSetStreamTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/BitSet/stream/BitSetStreamTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -50,7 +50,7 @@
  * @summary test BitSet stream
  * @bug 8012645 8076442
  * @requires os.maxMemory >= 2g
- * @library ../../stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.SpliteratorTestHelper
  *        java.base/java.util.SpliteratorOfIntDataBuilder
  * @run testng/othervm -Xms512m -Xmx1024m BitSetStreamTest
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Calendar/Bug8176847.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,52 @@
+/*
+ * 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 8176847
+ * @summary Make sure that style value of '3' throws IllegalArgumentException
+ *          in Calendar.getDisplayName(s) methods.
+ */
+
+import java.util.Calendar;
+import java.util.Locale;
+
+public class Bug8176847 {
+    public static void main(String[] args) {
+        Calendar c = new Calendar.Builder().build();
+
+        try {
+            c.getDisplayName(Calendar.MONTH, 3, Locale.US);
+            throw new RuntimeException("IllegalArgumentException was not thrown");
+        } catch (IllegalArgumentException iae) {
+            // success
+        }
+
+        try {
+            c.getDisplayNames(Calendar.MONTH, 3, Locale.US);
+            throw new RuntimeException("IllegalArgumentException was not thrown");
+        } catch (IllegalArgumentException iae) {
+            // success
+        }
+    }
+}
--- a/jdk/test/java/util/List/SubList.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/List/SubList.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,7 @@
 /*
  * @test
  * @bug 8079136
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run testng SubList
  * @summary Basic functionality of sublists
  * @key randomness
@@ -46,7 +45,7 @@
 import org.testng.annotations.Test;
 import org.testng.annotations.DataProvider;
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 
 public class SubList extends org.testng.Assert {
--- a/jdk/test/java/util/Locale/LocaleEnhanceTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/Locale/LocaleEnhanceTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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
@@ -44,7 +44,7 @@
 /**
  * @test
  * @bug 6875847 6992272 7002320 7015500 7023613 7032820 7033504 7004603
- *    7044019 8008577
+ *    7044019 8008577 8176853
  * @summary test API changes to Locale
  * @library /java/text/testlib
  * @modules jdk.localedata
@@ -1032,6 +1032,7 @@
 
         // null attribute throws NPE
         new BuilderNPE("null attribute") { public void call() { b.addUnicodeLocaleAttribute(null); }};
+        new BuilderNPE("null attribute removal") { public void call() { b.removeUnicodeLocaleAttribute(null); }};
 
         // illformed attribute throws IllformedLocaleException
         new BuilderILE("invalid attribute") { public void call() { b.addUnicodeLocaleAttribute("ca"); }};
--- a/jdk/test/java/util/ResourceBundle/modules/cache/CacheTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/ResourceBundle/modules/cache/CacheTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,9 +24,9 @@
 /**
  * @test
  * @bug 8170772
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build CacheTest CompilerUtils jdk.testlibrary.*
+ * @build CacheTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run testng CacheTest
  */
 
@@ -37,12 +37,12 @@
 
 import jdk.testlibrary.OutputAnalyzer;
 import static jdk.testlibrary.ProcessTools.*;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
-
 @Test
 public class CacheTest {
 
--- a/jdk/test/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/ResourceBundle/modules/casesensitive/CaseInsensitiveNameClash.java	Wed Jul 05 23:37:13 2017 +0200
@@ -24,9 +24,10 @@
 /*
  * @test
  * @bug 8177980
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build CompilerUtils jdk.testlibrary.ProcessTools CaseInsensitiveNameClash
+ * @build jdk.test.lib.compiler.CompilerUtils
+ *        jdk.testlibrary.ProcessTools CaseInsensitiveNameClash
  * @run testng CaseInsensitiveNameClash
  */
 
@@ -34,6 +35,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import jdk.testlibrary.ProcessTools;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/jdk/test/java/util/ResourceBundle/modules/security/TestPermission.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/ResourceBundle/modules/security/TestPermission.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.executeTestJava;
 
 import org.testng.annotations.BeforeTest;
@@ -34,9 +35,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build TestPermission CompilerUtils jdk.testlibrary.*
+ * @build TestPermission jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run testng TestPermission
  * @summary Driver for testing ResourceBundle::getBundle(String, Module)
  */
--- a/jdk/test/java/util/Scanner/ScannerStreamTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/Scanner/ScannerStreamTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -47,7 +47,7 @@
  * @test
  * @bug 8072722 8150488
  * @summary Tests of stream support in java.util.Scanner
- * @library ../stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.stream.OpTestCase
  * @run testng/othervm ScannerStreamTest
  */
--- a/jdk/test/java/util/ServiceLoader/modules/BadProvidersTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/ServiceLoader/modules/BadProvidersTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build CompilerUtils
+ * @build jdk.test.lib.compiler.CompilerUtils
  * @run testng/othervm BadProvidersTest
  * @summary Basic test of ServiceLoader with bad provider and bad provider
  *          factories deployed on the module path
@@ -44,6 +44,8 @@
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import jdk.test.lib.compiler.CompilerUtils;
+
 import org.testng.annotations.Test;
 import org.testng.annotations.DataProvider;
 import static org.testng.Assert.*;
--- a/jdk/test/java/util/Spliterator/SpliteratorCollisions.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/Spliterator/SpliteratorCollisions.java	Wed Jul 05 23:37:13 2017 +0200
@@ -24,7 +24,7 @@
 /**
  * @test
  * @bug 8005698
- * @library ../stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.SpliteratorTestHelper
  * @run testng SpliteratorCollisions
  * @summary Spliterator traversing and splitting hash maps containing colliding hashes
--- a/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/Spliterator/SpliteratorTraversingAndSplittingTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -24,7 +24,7 @@
 /**
  * @test
  * @summary Spliterator traversing and splitting tests
- * @library ../stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.SpliteratorOfIntDataBuilder
  *        java.base/java.util.SpliteratorTestHelper
  * @run testng SpliteratorTraversingAndSplittingTest
--- a/jdk/test/java/util/WeakHashMap/GCDuringIteration.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/WeakHashMap/GCDuringIteration.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,7 @@
 /*
  * @test
  * @bug 6499848
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
  * @run main GCDuringIteration
  * @summary Check that iterators work properly in the presence of
  *          concurrent finalization and removal of elements.
@@ -43,7 +42,7 @@
 import java.util.WeakHashMap;
 import java.util.concurrent.CountDownLatch;
 import java.util.function.BooleanSupplier;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class GCDuringIteration {
 
--- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,7 @@
  * @test
  * @bug 6450200
  * @summary Test proper handling of pool state changes
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
  * @run main/othervm ConfigChanges
  * @key randomness
  * @author Martin Buchholz
@@ -45,7 +44,7 @@
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.function.Supplier;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class ConfigChanges {
     static final ThreadGroup tg = new ThreadGroup("pool");
--- a/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ArrayDeque8Test.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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) {
--- a/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ArrayDequeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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) {
--- a/jdk/test/java/util/concurrent/tck/ArrayListTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ArrayListTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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) {
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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));
     }
--- a/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/AtomicReferenceTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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());
     }
 
--- a/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/CompletableFutureTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
--- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMap8Test.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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,
--- a/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentHashMapTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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));
--- a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedDequeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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)
--- a/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentLinkedQueueTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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)
--- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSetTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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());
--- a/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ConcurrentSkipListSubSetTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
--- a/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/CopyOnWriteArrayListTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -44,7 +44,6 @@
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import junit.framework.Test;
-import junit.framework.TestSuite;
 
 public class CopyOnWriteArrayListTest extends JSR166TestCase {
 
--- a/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/CountedCompleter8Test.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
--- a/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/CountedCompleterTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
--- a/jdk/test/java/util/concurrent/tck/ExchangerTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ExchangerTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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));
             }});
 
--- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionService9Test.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
--- a/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ExecutorCompletionServiceTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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());
--- a/jdk/test/java/util/concurrent/tck/ExecutorsTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ExecutorsTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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();
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool8Test.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPool9Test.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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());
     }
 
--- a/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinPoolTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
--- a/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ForkJoinTask8Test.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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();
--- a/jdk/test/java/util/concurrent/tck/JSR166TestCase.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/JSR166TestCase.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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; }
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingDeque8Test.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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) {
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingDequeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueue8Test.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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) {
--- a/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/LinkedBlockingQueueTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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());
--- a/jdk/test/java/util/concurrent/tck/LinkedListTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/LinkedListTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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)
--- a/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/LinkedTransferQueueTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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());
             }});
 
--- a/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/PriorityBlockingQueueTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
--- a/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/PriorityQueueTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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)
--- a/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/RecursiveActionTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
--- a/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/RecursiveTaskTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
--- a/jdk/test/java/util/concurrent/tck/StampedLockTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/StampedLockTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
--- a/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/SubmissionPublisherTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
--- a/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/SynchronousQueueTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -596,7 +596,7 @@
                 fail("timed out");
             Thread.yield();
         }
-        assertTrue(l.size() == 1);
+        assertEquals(1, l.size());
         assertSame(one, l.get(0));
         awaitTermination(t);
     }
--- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorSubclassTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
         }
     }
 
--- a/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ThreadPoolExecutorTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
         }
     }
 
--- a/jdk/test/java/util/concurrent/tck/ThreadTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/ThreadTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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
--- a/jdk/test/java/util/concurrent/tck/TreeSetTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/TreeSetTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
--- a/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/TreeSubSetTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
--- a/jdk/test/java/util/concurrent/tck/VectorTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/concurrent/tck/VectorTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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) {
--- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,9 +26,8 @@
  * @bug 8132734 8144062 8165723
  * @summary Test the extended API and the aliasing additions in JarFile that
  *          support multi-release jar files
- * @library /lib/testlibrary/java/util/jar /lib/testlibrary/
+ * @library /lib/testlibrary/java/util/jar /test/lib
  * @build Compiler JarBuilder CreateMultiReleaseTestJars
- * @build jdk.testlibrary.RandomFactory
  * @run testng MultiReleaseJarAPI
  */
 
@@ -45,7 +44,7 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 import org.testng.Assert;
 import org.testng.annotations.AfterClass;
--- a/jdk/test/java/util/logging/FileHandlerMaxLocksTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/logging/FileHandlerMaxLocksTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,7 @@
  *  "java.util.logging.FileHandler.maxLocks" which will be present in
  *  "logging.properties" file with default value of 100. This property can be
  *  overriden by specifying this property in the custom config file.
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library /test/lib
  * @author rpatil
  * @run main/othervm FileHandlerMaxLocksTest
  */
@@ -40,7 +39,7 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.FileHandler;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 
 public class FileHandlerMaxLocksTest {
 
--- a/jdk/test/java/util/logging/modules/GetResourceBundleTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/logging/modules/GetResourceBundleTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,15 +30,17 @@
 
 import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
 import static jdk.testlibrary.ProcessTools.*;
+import jdk.test.lib.compiler.CompilerUtils;
 import static org.testng.Assert.*;
 
 /**
  * @test
  * @bug 8129126 8136802 8137316 8137317 8136804 8139350
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
  *          java.logging
- * @build GetResourceBundleTest CompilerUtils jdk.testlibrary.ProcessTools
+ * @build GetResourceBundleTest jdk.testlibrary.ProcessTools
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng GetResourceBundleTest
  * @summary Tests Logger.getLogger + logger.getResourceBundle in an named/unnamed module,
  *          resources are in named and unnamed modules respectively.
--- a/jdk/test/java/util/regex/PatternStreamTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/regex/PatternStreamTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8016846 8024341 8071479 8145006
  * @summary Unit tests stream and lambda-based methods on Pattern and Matcher
- * @library ../stream/bootlib
+ * @library /lib/testlibrary/bootlib
  * @build java.base/java.util.stream.OpTestCase
  * @run testng/othervm PatternStreamTest
  */
--- a/jdk/test/java/util/regex/RegExTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/regex/RegExTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, 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
@@ -37,8 +37,7 @@
  * 6328855 6192895 6345469 6988218 6693451 7006761 8140212 8143282 8158482
  * 8176029
  *
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main RegExTest
  * @key randomness
  */
@@ -52,7 +51,7 @@
 import java.util.*;
 import java.nio.CharBuffer;
 import java.util.function.Predicate;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /**
  * This is a test class created to check the operation of
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/SpliteratorOfIntDataBuilder.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.util;
-
-import java.util.function.Supplier;
-
-public class SpliteratorOfIntDataBuilder {
-        List<Object[]> data;
-
-        List<Integer> exp;
-
-        public SpliteratorOfIntDataBuilder(List<Object[]> data, List<Integer> exp) {
-            this.data = data;
-            this.exp = exp;
-        }
-
-        public void add(String description, List<Integer> expected, Supplier<Spliterator.OfInt> s) {
-            description = joiner(description).toString();
-            data.add(new Object[]{description, expected, s});
-        }
-
-        public void add(String description, Supplier<Spliterator.OfInt> s) {
-            add(description, exp, s);
-        }
-
-        StringBuilder joiner(String description) {
-            return new StringBuilder(description).
-                    append(" {").
-                    append("size=").append(exp.size()).
-                    append("}");
-        }
-    }
-
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/SpliteratorTestHelper.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,754 +0,0 @@
-/*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util;
-
-import java.util.function.*;
-import java.util.stream.LambdaTestHelpers;
-
-import static org.testng.Assert.*;
-
-/**
- * Assertion methods for spliterators, to be called from other tests
- */
-public class SpliteratorTestHelper {
-
-    public interface ContentAsserter<T> {
-        void assertContents(Collection<T> actual, Collection<T> expected, boolean isOrdered);
-    }
-
-    private static ContentAsserter<Object> DEFAULT_CONTENT_ASSERTER
-            = SpliteratorTestHelper::assertContents;
-
-    @SuppressWarnings("unchecked")
-    private static <T> ContentAsserter<T> defaultContentAsserter() {
-        return (ContentAsserter<T>) DEFAULT_CONTENT_ASSERTER;
-    }
-
-    public static void testSpliterator(Supplier<Spliterator<Integer>> supplier) {
-        testSpliterator(supplier, defaultContentAsserter());
-    }
-
-    public static void testSpliterator(Supplier<Spliterator<Integer>> supplier,
-                                       ContentAsserter<Integer> asserter) {
-        testSpliterator(supplier, (Consumer<Integer> b) -> b, asserter);
-    }
-
-    public static void testIntSpliterator(Supplier<Spliterator.OfInt> supplier) {
-        testIntSpliterator(supplier, defaultContentAsserter());
-    }
-
-    public static void testIntSpliterator(Supplier<Spliterator.OfInt> supplier,
-                                          ContentAsserter<Integer> asserter) {
-        testSpliterator(supplier, intBoxingConsumer(), asserter);
-    }
-
-    public static void testLongSpliterator(Supplier<Spliterator.OfLong> supplier) {
-        testLongSpliterator(supplier, defaultContentAsserter());
-    }
-
-    public static void testLongSpliterator(Supplier<Spliterator.OfLong> supplier,
-                                           ContentAsserter<Long> asserter) {
-        testSpliterator(supplier, longBoxingConsumer(), asserter);
-    }
-
-    public static void testDoubleSpliterator(Supplier<Spliterator.OfDouble> supplier) {
-        testDoubleSpliterator(supplier, defaultContentAsserter());
-    }
-
-    public static void testDoubleSpliterator(Supplier<Spliterator.OfDouble> supplier,
-                                             ContentAsserter<Double> asserter) {
-        testSpliterator(supplier, doubleBoxingConsumer(), asserter);
-    }
-
-    public static UnaryOperator<Consumer<Integer>> intBoxingConsumer() {
-        class BoxingAdapter implements Consumer<Integer>, IntConsumer {
-            private final Consumer<Integer> b;
-
-            BoxingAdapter(Consumer<Integer> b) {
-                this.b = b;
-            }
-
-            @Override
-            public void accept(Integer value) {
-                throw new IllegalStateException();
-            }
-
-            @Override
-            public void accept(int value) {
-                b.accept(value);
-            }
-        }
-
-        return b -> new BoxingAdapter(b);
-    }
-
-    public static UnaryOperator<Consumer<Long>> longBoxingConsumer() {
-        class BoxingAdapter implements Consumer<Long>, LongConsumer {
-            private final Consumer<Long> b;
-
-            BoxingAdapter(Consumer<Long> b) {
-                this.b = b;
-            }
-
-            @Override
-            public void accept(Long value) {
-                throw new IllegalStateException();
-            }
-
-            @Override
-            public void accept(long value) {
-                b.accept(value);
-            }
-        }
-
-        return b -> new BoxingAdapter(b);
-    }
-
-    public static UnaryOperator<Consumer<Double>> doubleBoxingConsumer() {
-        class BoxingAdapter implements Consumer<Double>, DoubleConsumer {
-            private final Consumer<Double> b;
-
-            BoxingAdapter(Consumer<Double> b) {
-                this.b = b;
-            }
-
-            @Override
-            public void accept(Double value) {
-                throw new IllegalStateException();
-            }
-
-            @Override
-            public void accept(double value) {
-                b.accept(value);
-            }
-        }
-
-        return b -> new BoxingAdapter(b);
-    }
-
-    public static <T, S extends Spliterator<T>> void testSpliterator(Supplier<S> supplier,
-                                                              UnaryOperator<Consumer<T>> boxingAdapter,
-                                                              ContentAsserter<T> asserter) {
-        ArrayList<T> fromForEach = new ArrayList<>();
-        Spliterator<T> spliterator = supplier.get();
-        Consumer<T> addToFromForEach = boxingAdapter.apply(fromForEach::add);
-        spliterator.forEachRemaining(addToFromForEach);
-
-        Collection<T> exp = Collections.unmodifiableList(fromForEach);
-
-        testNullPointerException(supplier);
-        testForEach(exp, supplier, boxingAdapter, asserter);
-        testTryAdvance(exp, supplier, boxingAdapter, asserter);
-        testMixedTryAdvanceForEach(exp, supplier, boxingAdapter, asserter);
-        testMixedTraverseAndSplit(exp, supplier, boxingAdapter, asserter);
-        testSplitAfterFullTraversal(supplier, boxingAdapter);
-        testSplitOnce(exp, supplier, boxingAdapter, asserter);
-        testSplitSixDeep(exp, supplier, boxingAdapter, asserter);
-        testSplitUntilNull(exp, supplier, boxingAdapter, asserter);
-    }
-
-    public static <T, S extends Spliterator<T>> void testForEach(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testForEach(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    public static <T, S extends Spliterator<T>> void testTryAdvance(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testTryAdvance(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    public static <T, S extends Spliterator<T>> void testMixedTryAdvanceForEach(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testMixedTryAdvanceForEach(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    public static <T, S extends Spliterator<T>> void testMixedTraverseAndSplit(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testMixedTraverseAndSplit(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    public static <T, S extends Spliterator<T>> void testSplitOnce(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testSplitOnce(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    public static <T, S extends Spliterator<T>> void testSplitSixDeep(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testSplitSixDeep(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    public static <T, S extends Spliterator<T>> void testSplitUntilNull(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        testSplitUntilNull(exp, supplier, boxingAdapter, defaultContentAsserter());
-    }
-
-    private static <T, S extends Spliterator<T>> void testNullPointerException(Supplier<S> s) {
-        S sp = s.get();
-        // Have to check instances and use casts to avoid tripwire messages and
-        // directly test the primitive methods
-        if (sp instanceof Spliterator.OfInt) {
-            Spliterator.OfInt psp = (Spliterator.OfInt) sp;
-            assertThrowsNPE(() -> psp.forEachRemaining((IntConsumer) null));
-            assertThrowsNPE(() -> psp.tryAdvance((IntConsumer) null));
-        }
-        else if (sp instanceof Spliterator.OfLong) {
-            Spliterator.OfLong psp = (Spliterator.OfLong) sp;
-            assertThrowsNPE(() -> psp.forEachRemaining((LongConsumer) null));
-            assertThrowsNPE(() -> psp.tryAdvance((LongConsumer) null));
-        }
-        else if (sp instanceof Spliterator.OfDouble) {
-            Spliterator.OfDouble psp = (Spliterator.OfDouble) sp;
-            assertThrowsNPE(() -> psp.forEachRemaining((DoubleConsumer) null));
-            assertThrowsNPE(() -> psp.tryAdvance((DoubleConsumer) null));
-        }
-        else {
-            assertThrowsNPE(() -> sp.forEachRemaining(null));
-            assertThrowsNPE(() -> sp.tryAdvance(null));
-        }
-    }
-
-    private static <T, S extends Spliterator<T>> void testForEach(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        S spliterator = supplier.get();
-        long sizeIfKnown = spliterator.getExactSizeIfKnown();
-        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
-
-        ArrayList<T> fromForEach = new ArrayList<>();
-        spliterator = supplier.get();
-        Consumer<T> addToFromForEach = boxingAdapter.apply(fromForEach::add);
-        spliterator.forEachRemaining(addToFromForEach);
-
-        // Assert that forEach now produces no elements
-        spliterator.forEachRemaining(boxingAdapter.apply(
-                e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
-        // Assert that tryAdvance now produce no elements
-        spliterator.tryAdvance(boxingAdapter.apply(
-                e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
-
-        // assert that size, tryAdvance, and forEach are consistent
-        if (sizeIfKnown >= 0) {
-            assertEquals(sizeIfKnown, exp.size());
-        }
-        if (exp.contains(null)) {
-            assertTrue(fromForEach.contains(null));
-        }
-        assertEquals(fromForEach.size(), exp.size());
-
-        asserter.assertContents(fromForEach, exp, isOrdered);
-    }
-
-    private static <T, S extends Spliterator<T>> void testTryAdvance(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        S spliterator = supplier.get();
-        long sizeIfKnown = spliterator.getExactSizeIfKnown();
-        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
-
-        spliterator = supplier.get();
-        ArrayList<T> fromTryAdvance = new ArrayList<>();
-        Consumer<T> addToFromTryAdvance = boxingAdapter.apply(fromTryAdvance::add);
-        while (spliterator.tryAdvance(addToFromTryAdvance)) { }
-
-        // Assert that forEach now produces no elements
-        spliterator.forEachRemaining(boxingAdapter.apply(
-                e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
-        // Assert that tryAdvance now produce no elements
-        spliterator.tryAdvance(boxingAdapter.apply(
-                e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
-
-        // assert that size, tryAdvance, and forEach are consistent
-        if (sizeIfKnown >= 0) {
-            assertEquals(sizeIfKnown, exp.size());
-        }
-        assertEquals(fromTryAdvance.size(), exp.size());
-
-        asserter.assertContents(fromTryAdvance, exp, isOrdered);
-    }
-
-    private static <T, S extends Spliterator<T>> void testMixedTryAdvanceForEach(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        S spliterator = supplier.get();
-        long sizeIfKnown = spliterator.getExactSizeIfKnown();
-        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
-
-        // tryAdvance first few elements, then forEach rest
-        ArrayList<T> dest = new ArrayList<>();
-        spliterator = supplier.get();
-        Consumer<T> addToDest = boxingAdapter.apply(dest::add);
-        for (int i = 0; i < 10 && spliterator.tryAdvance(addToDest); i++) { }
-        spliterator.forEachRemaining(addToDest);
-
-        // Assert that forEach now produces no elements
-        spliterator.forEachRemaining(boxingAdapter.apply(
-                e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
-        // Assert that tryAdvance now produce no elements
-        spliterator.tryAdvance(boxingAdapter.apply(
-                e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
-
-        if (sizeIfKnown >= 0) {
-            assertEquals(sizeIfKnown, dest.size());
-        }
-        assertEquals(dest.size(), exp.size());
-
-        asserter.assertContents(dest, exp, isOrdered);
-    }
-
-    private static <T, S extends Spliterator<T>> void testMixedTraverseAndSplit(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        S spliterator = supplier.get();
-        long sizeIfKnown = spliterator.getExactSizeIfKnown();
-        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
-
-        // tryAdvance first few elements, then forEach rest
-        ArrayList<T> dest = new ArrayList<>();
-        spliterator = supplier.get();
-        Consumer<T> b = boxingAdapter.apply(dest::add);
-
-        Spliterator<T> spl1, spl2, spl3;
-        spliterator.tryAdvance(b);
-        spl2 = spliterator.trySplit();
-        if (spl2 != null) {
-            spl2.tryAdvance(b);
-            spl1 = spl2.trySplit();
-            if (spl1 != null) {
-                spl1.tryAdvance(b);
-                spl1.forEachRemaining(b);
-            }
-            spl2.tryAdvance(b);
-            spl2.forEachRemaining(b);
-        }
-        spliterator.tryAdvance(b);
-        spl3 = spliterator.trySplit();
-        if (spl3 != null) {
-            spl3.tryAdvance(b);
-            spl3.forEachRemaining(b);
-        }
-        spliterator.tryAdvance(b);
-        spliterator.forEachRemaining(b);
-
-        if (sizeIfKnown >= 0) {
-            assertEquals(sizeIfKnown, dest.size());
-        }
-        assertEquals(dest.size(), exp.size());
-
-        asserter.assertContents(dest, exp, isOrdered);
-    }
-
-    public static <T, S extends Spliterator<T>> void testSplitAfterFullTraversal(
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter) {
-        // Full traversal using tryAdvance
-        Spliterator<T> spliterator = supplier.get();
-        while (spliterator.tryAdvance(boxingAdapter.apply(e -> { }))) { }
-        Spliterator<T> split = spliterator.trySplit();
-        assertNull(split);
-
-        // Full traversal using forEach
-        spliterator = supplier.get();
-        spliterator.forEachRemaining(boxingAdapter.apply(e -> { }));
-        split = spliterator.trySplit();
-        assertNull(split);
-
-        // Full traversal using tryAdvance then forEach
-        spliterator = supplier.get();
-        spliterator.tryAdvance(boxingAdapter.apply(e -> { }));
-        spliterator.forEachRemaining(boxingAdapter.apply(e -> { }));
-        split = spliterator.trySplit();
-        assertNull(split);
-    }
-
-    private static <T, S extends Spliterator<T>> void testSplitOnce(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        S spliterator = supplier.get();
-        long sizeIfKnown = spliterator.getExactSizeIfKnown();
-        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
-
-        ArrayList<T> fromSplit = new ArrayList<>();
-        Spliterator<T> s1 = supplier.get();
-        Spliterator<T> s2 = s1.trySplit();
-        long s1Size = s1.getExactSizeIfKnown();
-        long s2Size = (s2 != null) ? s2.getExactSizeIfKnown() : 0;
-        Consumer<T> addToFromSplit = boxingAdapter.apply(fromSplit::add);
-        if (s2 != null)
-            s2.forEachRemaining(addToFromSplit);
-        s1.forEachRemaining(addToFromSplit);
-
-        if (sizeIfKnown >= 0) {
-            assertEquals(sizeIfKnown, fromSplit.size());
-            if (s1Size >= 0 && s2Size >= 0)
-                assertEquals(sizeIfKnown, s1Size + s2Size);
-        }
-
-        asserter.assertContents(fromSplit, exp, isOrdered);
-    }
-
-    private static <T, S extends Spliterator<T>> void testSplitSixDeep(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        S spliterator = supplier.get();
-        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
-
-        for (int depth=0; depth < 6; depth++) {
-            List<T> dest = new ArrayList<>();
-            spliterator = supplier.get();
-
-            assertSpliterator(spliterator);
-
-            // verify splitting with forEach
-            splitSixDeepVisitor(depth, 0, dest, spliterator, boxingAdapter, spliterator.characteristics(), false);
-            asserter.assertContents(dest, exp, isOrdered);
-
-            // verify splitting with tryAdvance
-            dest.clear();
-            spliterator = supplier.get();
-            splitSixDeepVisitor(depth, 0, dest, spliterator, boxingAdapter, spliterator.characteristics(), true);
-            asserter.assertContents(dest, exp, isOrdered);
-        }
-    }
-
-    private static <T, S extends Spliterator<T>>
-    void splitSixDeepVisitor(int depth, int curLevel,
-                             List<T> dest, S spliterator, UnaryOperator<Consumer<T>> boxingAdapter,
-                             int rootCharacteristics, boolean useTryAdvance) {
-        if (curLevel < depth) {
-            long beforeSize = spliterator.getExactSizeIfKnown();
-            Spliterator<T> split = spliterator.trySplit();
-            if (split != null) {
-                assertSpliterator(split, rootCharacteristics);
-                assertSpliterator(spliterator, rootCharacteristics);
-
-                if ((rootCharacteristics & Spliterator.SUBSIZED) != 0 &&
-                    (rootCharacteristics & Spliterator.SIZED) != 0) {
-                    assertEquals(beforeSize, split.estimateSize() + spliterator.estimateSize());
-                }
-                splitSixDeepVisitor(depth, curLevel + 1, dest, split, boxingAdapter, rootCharacteristics, useTryAdvance);
-            }
-            splitSixDeepVisitor(depth, curLevel + 1, dest, spliterator, boxingAdapter, rootCharacteristics, useTryAdvance);
-        }
-        else {
-            long sizeIfKnown = spliterator.getExactSizeIfKnown();
-            if (useTryAdvance) {
-                Consumer<T> addToDest = boxingAdapter.apply(dest::add);
-                int count = 0;
-                while (spliterator.tryAdvance(addToDest)) {
-                    ++count;
-                }
-
-                if (sizeIfKnown >= 0)
-                    assertEquals(sizeIfKnown, count);
-
-                // Assert that forEach now produces no elements
-                spliterator.forEachRemaining(boxingAdapter.apply(
-                        e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
-
-                Spliterator<T> split = spliterator.trySplit();
-                assertNull(split);
-            }
-            else {
-                List<T> leafDest = new ArrayList<>();
-                Consumer<T> addToLeafDest = boxingAdapter.apply(leafDest::add);
-                spliterator.forEachRemaining(addToLeafDest);
-
-                if (sizeIfKnown >= 0)
-                    assertEquals(sizeIfKnown, leafDest.size());
-
-                // Assert that forEach now produces no elements
-                spliterator.tryAdvance(boxingAdapter.apply(
-                        e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
-
-                Spliterator<T> split = spliterator.trySplit();
-                assertNull(split);
-
-                dest.addAll(leafDest);
-            }
-        }
-    }
-
-    private static <T, S extends Spliterator<T>> void testSplitUntilNull(
-            Collection<T> exp,
-            Supplier<S> supplier,
-            UnaryOperator<Consumer<T>> boxingAdapter,
-            ContentAsserter<T> asserter) {
-        Spliterator<T> s = supplier.get();
-        boolean isOrdered = s.hasCharacteristics(Spliterator.ORDERED);
-        assertSpliterator(s);
-
-        List<T> splits = new ArrayList<>();
-        Consumer<T> c = boxingAdapter.apply(splits::add);
-
-        testSplitUntilNull(new SplitNode<T>(c, s));
-        asserter.assertContents(splits, exp, isOrdered);
-    }
-
-    private static class SplitNode<T> {
-        // Constant for every node
-        final Consumer<T> c;
-        final int rootCharacteristics;
-
-        final Spliterator<T> s;
-
-        SplitNode(Consumer<T> c, Spliterator<T> s) {
-            this(c, s.characteristics(), s);
-        }
-
-        private SplitNode(Consumer<T> c, int rootCharacteristics, Spliterator<T> s) {
-            this.c = c;
-            this.rootCharacteristics = rootCharacteristics;
-            this.s = s;
-        }
-
-        SplitNode<T> fromSplit(Spliterator<T> split) {
-            return new SplitNode<>(c, rootCharacteristics, split);
-        }
-    }
-
-    /**
-     * Set the maximum stack capacity to 0.25MB. This should be more than enough to detect a bad spliterator
-     * while not unduly disrupting test infrastructure given the test data sizes that are used are small.
-     * Note that j.u.c.ForkJoinPool sets the max queue size to 64M (1 << 26).
-     */
-    private static final int MAXIMUM_STACK_CAPACITY = 1 << 18; // 0.25MB
-
-    private static <T> void testSplitUntilNull(SplitNode<T> e) {
-        // Use an explicit stack to avoid a StackOverflowException when testing a Spliterator
-        // that when repeatedly split produces a right-balanced (and maybe degenerate) tree, or
-        // for a spliterator that is badly behaved.
-        Deque<SplitNode<T>> stack = new ArrayDeque<>();
-        stack.push(e);
-
-        int iteration = 0;
-        while (!stack.isEmpty()) {
-            assertTrue(iteration++ < MAXIMUM_STACK_CAPACITY, "Exceeded maximum stack modification count of 1 << 18");
-
-            e = stack.pop();
-            Spliterator<T> parentAndRightSplit = e.s;
-
-            long parentEstimateSize = parentAndRightSplit.estimateSize();
-            assertTrue(parentEstimateSize >= 0,
-                       String.format("Split size estimate %d < 0", parentEstimateSize));
-
-            long parentSize = parentAndRightSplit.getExactSizeIfKnown();
-            Spliterator<T> leftSplit = parentAndRightSplit.trySplit();
-            if (leftSplit == null) {
-                parentAndRightSplit.forEachRemaining(e.c);
-                continue;
-            }
-
-            assertSpliterator(leftSplit, e.rootCharacteristics);
-            assertSpliterator(parentAndRightSplit, e.rootCharacteristics);
-
-            if (parentEstimateSize != Long.MAX_VALUE && leftSplit.estimateSize() > 0
-                && parentAndRightSplit.estimateSize() > 0) {
-                assertTrue(leftSplit.estimateSize() < parentEstimateSize,
-                           String.format("Left split size estimate %d >= parent split size estimate %d",
-                                         leftSplit.estimateSize(), parentEstimateSize));
-                assertTrue(parentAndRightSplit.estimateSize() < parentEstimateSize,
-                           String.format("Right split size estimate %d >= parent split size estimate %d",
-                                         leftSplit.estimateSize(), parentEstimateSize));
-            }
-            else {
-                assertTrue(leftSplit.estimateSize() <= parentEstimateSize,
-                           String.format("Left split size estimate %d > parent split size estimate %d",
-                                         leftSplit.estimateSize(), parentEstimateSize));
-                assertTrue(parentAndRightSplit.estimateSize() <= parentEstimateSize,
-                           String.format("Right split size estimate %d > parent split size estimate %d",
-                                         leftSplit.estimateSize(), parentEstimateSize));
-            }
-
-            long leftSize = leftSplit.getExactSizeIfKnown();
-            long rightSize = parentAndRightSplit.getExactSizeIfKnown();
-            if (parentSize >= 0 && leftSize >= 0 && rightSize >= 0)
-                assertEquals(parentSize, leftSize + rightSize,
-                             String.format("exact left split size %d + exact right split size %d != parent exact split size %d",
-                                           leftSize, rightSize, parentSize));
-
-            // Add right side to stack first so left side is popped off first
-            stack.push(e.fromSplit(parentAndRightSplit));
-            stack.push(e.fromSplit(leftSplit));
-        }
-    }
-
-    private static void assertSpliterator(Spliterator<?> s, int rootCharacteristics) {
-        if ((rootCharacteristics & Spliterator.SUBSIZED) != 0) {
-            assertTrue(s.hasCharacteristics(Spliterator.SUBSIZED),
-                       "Child split is not SUBSIZED when root split is SUBSIZED");
-        }
-        assertSpliterator(s);
-    }
-
-    private static void assertSpliterator(Spliterator<?> s) {
-        if (s.hasCharacteristics(Spliterator.SUBSIZED)) {
-            assertTrue(s.hasCharacteristics(Spliterator.SIZED));
-        }
-        if (s.hasCharacteristics(Spliterator.SIZED)) {
-            assertTrue(s.estimateSize() != Long.MAX_VALUE);
-            assertTrue(s.getExactSizeIfKnown() >= 0);
-        }
-        try {
-            s.getComparator();
-            assertTrue(s.hasCharacteristics(Spliterator.SORTED));
-        } catch (IllegalStateException e) {
-            assertFalse(s.hasCharacteristics(Spliterator.SORTED));
-        }
-    }
-
-    private static<T> void assertContents(Collection<T> actual, Collection<T> expected, boolean isOrdered) {
-        if (isOrdered) {
-            assertEquals(actual, expected);
-        }
-        else {
-            LambdaTestHelpers.assertContentsUnordered(actual, expected);
-        }
-    }
-
-    public static void assertThrowsNPE(ThrowingRunnable r) {
-        assertThrows(NullPointerException.class, r);
-    }
-
-    public static<U> void mixedTraverseAndSplit(Consumer<U> b, Spliterator<U> splTop) {
-        Spliterator<U> spl1, spl2, spl3;
-        splTop.tryAdvance(b);
-        spl2 = splTop.trySplit();
-        if (spl2 != null) {
-            spl2.tryAdvance(b);
-            spl1 = spl2.trySplit();
-            if (spl1 != null) {
-                spl1.tryAdvance(b);
-                spl1.forEachRemaining(b);
-            }
-            spl2.tryAdvance(b);
-            spl2.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        spl3 = splTop.trySplit();
-        if (spl3 != null) {
-            spl3.tryAdvance(b);
-            spl3.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        splTop.forEachRemaining(b);
-    }
-
-    public static void mixedTraverseAndSplit(IntConsumer b, Spliterator.OfInt splTop) {
-        Spliterator.OfInt spl1, spl2, spl3;
-        splTop.tryAdvance(b);
-        spl2 = splTop.trySplit();
-        if (spl2 != null) {
-            spl2.tryAdvance(b);
-            spl1 = spl2.trySplit();
-            if (spl1 != null) {
-                spl1.tryAdvance(b);
-                spl1.forEachRemaining(b);
-            }
-            spl2.tryAdvance(b);
-            spl2.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        spl3 = splTop.trySplit();
-        if (spl3 != null) {
-            spl3.tryAdvance(b);
-            spl3.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        splTop.forEachRemaining(b);
-    }
-
-    public static void mixedTraverseAndSplit(LongConsumer b, Spliterator.OfLong splTop) {
-        Spliterator.OfLong spl1, spl2, spl3;
-        splTop.tryAdvance(b);
-        spl2 = splTop.trySplit();
-        if (spl2 != null) {
-            spl2.tryAdvance(b);
-            spl1 = spl2.trySplit();
-            if (spl1 != null) {
-                spl1.tryAdvance(b);
-                spl1.forEachRemaining(b);
-            }
-            spl2.tryAdvance(b);
-            spl2.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        spl3 = splTop.trySplit();
-        if (spl3 != null) {
-            spl3.tryAdvance(b);
-            spl3.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        splTop.forEachRemaining(b);
-    }
-
-    public static void mixedTraverseAndSplit(DoubleConsumer b, Spliterator.OfDouble splTop) {
-        Spliterator.OfDouble spl1, spl2, spl3;
-        splTop.tryAdvance(b);
-        spl2 = splTop.trySplit();
-        if (spl2 != null) {
-            spl2.tryAdvance(b);
-            spl1 = spl2.trySplit();
-            if (spl1 != null) {
-                spl1.tryAdvance(b);
-                spl1.forEachRemaining(b);
-            }
-            spl2.tryAdvance(b);
-            spl2.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        spl3 = splTop.trySplit();
-        if (spl3 != null) {
-            spl3.tryAdvance(b);
-            spl3.forEachRemaining(b);
-        }
-        splTop.tryAdvance(b);
-        splTop.forEachRemaining(b);
-    }
-
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/CollectorOps.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import org.testng.Assert;
-
-import java.util.Spliterator;
-import java.util.function.IntFunction;
-
-/** Test helper class for java.util.stream test framework */
-public final class CollectorOps {
-    private CollectorOps() { }
-
-    public static <E_IN> StatefulTestOp<E_IN> collector() {
-        return new StatefulCollector<>(0, StreamShape.REFERENCE);
-    }
-
-    /* Utility classes for collecting output of intermediate pipeline stages */
-    public static class StatefulCollector<E_IN> implements StatefulTestOp<E_IN> {
-        private final int opFlags;
-        private final StreamShape inputShape;
-
-        public StatefulCollector(int opFlags, StreamShape inputShape) {
-            this.opFlags = opFlags;
-            this.inputShape = inputShape;
-        }
-
-        @Override
-        public StreamShape inputShape() {
-            return inputShape;
-        }
-
-        @Override
-        public StreamShape outputShape() {
-            return inputShape;
-        }
-
-        @Override
-        public int opGetFlags() {
-            return opFlags;
-        }
-
-        @Override
-        public Sink<E_IN> opWrapSink(int flags, boolean parallel, Sink<E_IN> sink) {
-            return sink;
-        }
-
-        @Override
-        public <P_IN> Node<E_IN> opEvaluateParallel(PipelineHelper<E_IN> helper,
-                                                    Spliterator<P_IN> spliterator,
-                                                    IntFunction<E_IN[]> generator) {
-            return helper.evaluate(spliterator, false, generator);
-        }
-    }
-
-    public static class TestParallelSizedOp<T> extends StatefulCollector<T> {
-        public TestParallelSizedOp() {
-            this(StreamShape.REFERENCE);
-        }
-
-        protected TestParallelSizedOp(StreamShape shape) {
-            super(0, shape);
-        }
-
-        @Override
-        public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
-                                                 Spliterator<P_IN> spliterator,
-                                                 IntFunction<T[]> generator) {
-            int flags = helper.getStreamAndOpFlags();
-
-            Assert.assertTrue(StreamOpFlag.SIZED.isKnown(flags));
-            return super.opEvaluateParallel(helper, spliterator, generator);
-        }
-
-        public static class OfInt extends TestParallelSizedOp<Integer> {
-            public OfInt() {
-                super(StreamShape.INT_VALUE);
-            }
-        }
-
-        public static class OfLong extends TestParallelSizedOp<Long> {
-            public OfLong() {
-                super(StreamShape.LONG_VALUE);
-            }
-        }
-
-        public static class OfDouble extends TestParallelSizedOp<Double> {
-            public OfDouble() {
-                super(StreamShape.DOUBLE_VALUE);
-            }
-        }
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DefaultMethodStreams.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,984 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Comparator;
-import java.util.DoubleSummaryStatistics;
-import java.util.IntSummaryStatistics;
-import java.util.Iterator;
-import java.util.LongSummaryStatistics;
-import java.util.Optional;
-import java.util.OptionalDouble;
-import java.util.OptionalInt;
-import java.util.OptionalLong;
-import java.util.PrimitiveIterator;
-import java.util.Set;
-import java.util.Spliterator;
-import java.util.function.BiConsumer;
-import java.util.function.BiFunction;
-import java.util.function.BinaryOperator;
-import java.util.function.Consumer;
-import java.util.function.DoubleBinaryOperator;
-import java.util.function.DoubleConsumer;
-import java.util.function.DoubleFunction;
-import java.util.function.DoublePredicate;
-import java.util.function.DoubleToIntFunction;
-import java.util.function.DoubleToLongFunction;
-import java.util.function.DoubleUnaryOperator;
-import java.util.function.Function;
-import java.util.function.IntBinaryOperator;
-import java.util.function.IntConsumer;
-import java.util.function.IntFunction;
-import java.util.function.IntPredicate;
-import java.util.function.IntToDoubleFunction;
-import java.util.function.IntToLongFunction;
-import java.util.function.IntUnaryOperator;
-import java.util.function.LongBinaryOperator;
-import java.util.function.LongConsumer;
-import java.util.function.LongFunction;
-import java.util.function.LongPredicate;
-import java.util.function.LongToDoubleFunction;
-import java.util.function.LongToIntFunction;
-import java.util.function.LongUnaryOperator;
-import java.util.function.ObjDoubleConsumer;
-import java.util.function.ObjIntConsumer;
-import java.util.function.ObjLongConsumer;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-import java.util.function.ToDoubleFunction;
-
-import java.util.function.ToIntFunction;
-import java.util.function.ToLongFunction;
-
-import static java.util.stream.Collectors.*;
-
-public final class DefaultMethodStreams {
-
-    static {
-        // Verify that default methods are not overridden
-        verify(DefaultMethodRefStream.class);
-        verify(DefaultMethodIntStream.class);
-        verify(DefaultMethodLongStream.class);
-        verify(DefaultMethodDoubleStream.class);
-    }
-
-    static void verify(Class<?> del) {
-        // Find the stream interface
-        Class<?> s = Stream.of(del.getInterfaces())
-                .filter(c -> BaseStream.class.isAssignableFrom(c))
-                .findFirst().get();
-
-        // Get all default methods on the stream class
-        Set<String> dms = Stream.of(s.getMethods())
-                .filter(m -> !Modifier.isStatic(m.getModifiers()))
-                .filter(m -> !m.isBridge())
-                .filter(Method::isDefault)
-                .map(Method::getName)
-                .collect(toSet());
-
-        // Get all methods on the delegating class
-        Set<String> ims = Stream.of(del.getMethods())
-                .filter(m -> !Modifier.isStatic(m.getModifiers()))
-                .filter(m -> m.getDeclaringClass() == del)
-                .map(Method::getName)
-                .collect(toSet());
-
-        if (ims.stream().anyMatch(dms::contains)) {
-            throw new AssertionError(String.format("%s overrides default methods of %s\n", del, s));
-        }
-    }
-
-    /**
-     * Creates a stream that for the next operation either delegates to
-     * a default method on {@link Stream}, if present for that operation,
-     * otherwise delegates to an underlying stream.
-     *
-     * @param s the underlying stream to be delegated to for non-default
-     * methods.
-     * @param <T> the type of the stream elements
-     * @return the delegating stream
-     */
-    public static <T> Stream<T> delegateTo(Stream<T> s) {
-        return new DefaultMethodRefStream<>(s);
-    }
-
-    /**
-     * Creates a stream that for the next operation either delegates to
-     * a default method on {@link IntStream}, if present for that operation,
-     * otherwise delegates to an underlying stream.
-     *
-     * @param s the underlying stream to be delegated to for non-default
-     * methods.
-     * @return the delegating stream
-     */
-    public static IntStream delegateTo(IntStream s) {
-        return new DefaultMethodIntStream(s);
-    }
-
-    /**
-     * Creates a stream that for the next operation either delegates to
-     * a default method on {@link LongStream}, if present for that operation,
-     * otherwise delegates to an underlying stream.
-     *
-     * @param s the underlying stream to be delegated to for non-default
-     * methods.
-     * @return the delegating stream
-     */
-    public static LongStream delegateTo(LongStream s) {
-        return new DefaultMethodLongStream(s);
-    }
-
-    /**
-     * Creates a stream that for the next operation either delegates to
-     * a default method on {@link DoubleStream}, if present for that operation,
-     * otherwise delegates to an underlying stream.
-     *
-     * @param s the underlying stream to be delegated to for non-default
-     * methods.
-     * @return the delegating stream
-     */
-    public static DoubleStream delegateTo(DoubleStream s) {
-        return new DefaultMethodDoubleStream(s);
-    }
-
-    /**
-     * A stream that delegates the next operation to a default method, if
-     * present, or to the same operation of an underlying stream.
-     *
-     * @param <T> the type of the stream elements
-     */
-    static final class DefaultMethodRefStream<T> implements Stream<T> {
-        final Stream<T> s;
-
-        DefaultMethodRefStream(Stream<T> s) {
-            this.s = s;
-        }
-
-
-        // Delegating non-default methods
-
-        @Override
-        public Stream<T> filter(Predicate<? super T> predicate) {
-            return s.filter(predicate);
-        }
-
-        @Override
-        public <R> Stream<R> map(Function<? super T, ? extends R> mapper) {
-            return s.map(mapper);
-        }
-
-        @Override
-        public IntStream mapToInt(ToIntFunction<? super T> mapper) {
-            return s.mapToInt(mapper);
-        }
-
-        @Override
-        public LongStream mapToLong(ToLongFunction<? super T> mapper) {
-            return s.mapToLong(mapper);
-        }
-
-        @Override
-        public DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper) {
-            return s.mapToDouble(mapper);
-        }
-
-        @Override
-        public <R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper) {
-            return s.flatMap(mapper);
-        }
-
-        @Override
-        public IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper) {
-            return s.flatMapToInt(mapper);
-        }
-
-        @Override
-        public LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper) {
-            return s.flatMapToLong(mapper);
-        }
-
-        @Override
-        public DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper) {
-            return s.flatMapToDouble(mapper);
-        }
-
-        @Override
-        public Stream<T> distinct() {
-            return s.distinct();
-        }
-
-        @Override
-        public Stream<T> sorted() {
-            return s.sorted();
-        }
-
-        @Override
-        public Stream<T> sorted(Comparator<? super T> comparator) {
-            return s.sorted(comparator);
-        }
-
-        @Override
-        public Stream<T> peek(Consumer<? super T> action) {
-            return s.peek(action);
-        }
-
-        @Override
-        public Stream<T> limit(long maxSize) {
-            return s.limit(maxSize);
-        }
-
-        @Override
-        public Stream<T> skip(long n) {
-            return s.skip(n);
-        }
-
-        @Override
-        public void forEach(Consumer<? super T> action) {
-            s.forEach(action);
-        }
-
-        @Override
-        public void forEachOrdered(Consumer<? super T> action) {
-            s.forEachOrdered(action);
-        }
-
-        @Override
-        public Object[] toArray() {
-            return s.toArray();
-        }
-
-        @Override
-        public <A> A[] toArray(IntFunction<A[]> generator) {
-            return s.toArray(generator);
-        }
-
-        @Override
-        public T reduce(T identity, BinaryOperator<T> accumulator) {
-            return s.reduce(identity, accumulator);
-        }
-
-        @Override
-        public Optional<T> reduce(BinaryOperator<T> accumulator) {
-            return s.reduce(accumulator);
-        }
-
-        @Override
-        public <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) {
-            return s.reduce(identity, accumulator, combiner);
-        }
-
-        @Override
-        public <R> R collect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner) {
-            return s.collect(supplier, accumulator, combiner);
-        }
-
-        @Override
-        public <R, A> R collect(Collector<? super T, A, R> collector) {
-            return s.collect(collector);
-        }
-
-        @Override
-        public Optional<T> min(Comparator<? super T> comparator) {
-            return s.min(comparator);
-        }
-
-        @Override
-        public Optional<T> max(Comparator<? super T> comparator) {
-            return s.max(comparator);
-        }
-
-        @Override
-        public long count() {
-            return s.count();
-        }
-
-        @Override
-        public boolean anyMatch(Predicate<? super T> predicate) {
-            return s.anyMatch(predicate);
-        }
-
-        @Override
-        public boolean allMatch(Predicate<? super T> predicate) {
-            return s.allMatch(predicate);
-        }
-
-        @Override
-        public boolean noneMatch(Predicate<? super T> predicate) {
-            return s.noneMatch(predicate);
-        }
-
-        @Override
-        public Optional<T> findFirst() {
-            return s.findFirst();
-        }
-
-        @Override
-        public Optional<T> findAny() {
-            return s.findAny();
-        }
-
-        @Override
-        public Iterator<T> iterator() {
-            return s.iterator();
-        }
-
-        @Override
-        public Spliterator<T> spliterator() {
-            return s.spliterator();
-        }
-
-        @Override
-        public boolean isParallel() {
-            return s.isParallel();
-        }
-
-        @Override
-        public Stream<T> sequential() {
-            return s.sequential();
-        }
-
-        @Override
-        public Stream<T> parallel() {
-            return s.parallel();
-        }
-
-        @Override
-        public Stream<T> unordered() {
-            return s.unordered();
-        }
-
-        @Override
-        public Stream<T> onClose(Runnable closeHandler) {
-            return s.onClose(closeHandler);
-        }
-
-        @Override
-        public void close() {
-            s.close();
-        }
-    }
-
-    static final class DefaultMethodIntStream implements IntStream {
-        final IntStream s;
-
-        public DefaultMethodIntStream(IntStream s) {
-            this.s = s;
-        }
-
-
-        // Delegating non-default methods
-
-        @Override
-        public IntStream filter(IntPredicate predicate) {
-            return s.filter(predicate);
-        }
-
-        @Override
-        public IntStream map(IntUnaryOperator mapper) {
-            return s.map(mapper);
-        }
-
-        @Override
-        public <U> Stream<U> mapToObj(IntFunction<? extends U> mapper) {
-            return s.mapToObj(mapper);
-        }
-
-        @Override
-        public LongStream mapToLong(IntToLongFunction mapper) {
-            return s.mapToLong(mapper);
-        }
-
-        @Override
-        public DoubleStream mapToDouble(IntToDoubleFunction mapper) {
-            return s.mapToDouble(mapper);
-        }
-
-        @Override
-        public IntStream flatMap(IntFunction<? extends IntStream> mapper) {
-            return s.flatMap(mapper);
-        }
-
-        @Override
-        public IntStream distinct() {
-            return s.distinct();
-        }
-
-        @Override
-        public IntStream sorted() {
-            return s.sorted();
-        }
-
-        @Override
-        public IntStream peek(IntConsumer action) {
-            return s.peek(action);
-        }
-
-        @Override
-        public IntStream limit(long maxSize) {
-            return s.limit(maxSize);
-        }
-
-        @Override
-        public IntStream skip(long n) {
-            return s.skip(n);
-        }
-
-        @Override
-        public void forEach(IntConsumer action) {
-            s.forEach(action);
-        }
-
-        @Override
-        public void forEachOrdered(IntConsumer action) {
-            s.forEachOrdered(action);
-        }
-
-        @Override
-        public int[] toArray() {
-            return s.toArray();
-        }
-
-        @Override
-        public int reduce(int identity, IntBinaryOperator op) {
-            return s.reduce(identity, op);
-        }
-
-        @Override
-        public OptionalInt reduce(IntBinaryOperator op) {
-            return s.reduce(op);
-        }
-
-        @Override
-        public <R> R collect(Supplier<R> supplier, ObjIntConsumer<R> accumulator, BiConsumer<R, R> combiner) {
-            return s.collect(supplier, accumulator, combiner);
-        }
-
-        @Override
-        public int sum() {
-            return s.sum();
-        }
-
-        @Override
-        public OptionalInt min() {
-            return s.min();
-        }
-
-        @Override
-        public OptionalInt max() {
-            return s.max();
-        }
-
-        @Override
-        public long count() {
-            return s.count();
-        }
-
-        @Override
-        public OptionalDouble average() {
-            return s.average();
-        }
-
-        @Override
-        public IntSummaryStatistics summaryStatistics() {
-            return s.summaryStatistics();
-        }
-
-        @Override
-        public boolean anyMatch(IntPredicate predicate) {
-            return s.anyMatch(predicate);
-        }
-
-        @Override
-        public boolean allMatch(IntPredicate predicate) {
-            return s.allMatch(predicate);
-        }
-
-        @Override
-        public boolean noneMatch(IntPredicate predicate) {
-            return s.noneMatch(predicate);
-        }
-
-        @Override
-        public OptionalInt findFirst() {
-            return s.findFirst();
-        }
-
-        @Override
-        public OptionalInt findAny() {
-            return s.findAny();
-        }
-
-        @Override
-        public LongStream asLongStream() {
-            return s.asLongStream();
-        }
-
-        @Override
-        public DoubleStream asDoubleStream() {
-            return s.asDoubleStream();
-        }
-
-        @Override
-        public Stream<Integer> boxed() {
-            return s.boxed();
-        }
-
-        @Override
-        public IntStream sequential() {
-            return s.sequential();
-        }
-
-        @Override
-        public IntStream parallel() {
-            return s.parallel();
-        }
-
-        @Override
-        public PrimitiveIterator.OfInt iterator() {
-            return s.iterator();
-        }
-
-        @Override
-        public Spliterator.OfInt spliterator() {
-            return s.spliterator();
-        }
-
-        @Override
-        public boolean isParallel() {
-            return s.isParallel();
-        }
-
-        @Override
-        public IntStream unordered() {
-            return s.unordered();
-        }
-
-        @Override
-        public IntStream onClose(Runnable closeHandler) {
-            return s.onClose(closeHandler);
-        }
-
-        @Override
-        public void close() {
-            s.close();
-        }
-    }
-
-    static final class DefaultMethodLongStream implements LongStream {
-        final LongStream s;
-
-        public DefaultMethodLongStream(LongStream s) {
-            this.s = s;
-        }
-
-
-        // Delegating non-default methods
-
-        @Override
-        public void forEach(LongConsumer action) {
-            s.forEach(action);
-        }
-
-        @Override
-        public LongStream filter(LongPredicate predicate) {
-            return s.filter(predicate);
-        }
-
-        @Override
-        public LongStream map(LongUnaryOperator mapper) {
-            return s.map(mapper);
-        }
-
-        @Override
-        public <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
-            return s.mapToObj(mapper);
-        }
-
-        @Override
-        public IntStream mapToInt(LongToIntFunction mapper) {
-            return s.mapToInt(mapper);
-        }
-
-        @Override
-        public DoubleStream mapToDouble(LongToDoubleFunction mapper) {
-            return s.mapToDouble(mapper);
-        }
-
-        @Override
-        public LongStream flatMap(LongFunction<? extends LongStream> mapper) {
-            return s.flatMap(mapper);
-        }
-
-        @Override
-        public LongStream distinct() {
-            return s.distinct();
-        }
-
-        @Override
-        public LongStream sorted() {
-            return s.sorted();
-        }
-
-        @Override
-        public LongStream peek(LongConsumer action) {
-            return s.peek(action);
-        }
-
-        @Override
-        public LongStream limit(long maxSize) {
-            return s.limit(maxSize);
-        }
-
-        @Override
-        public LongStream skip(long n) {
-            return s.skip(n);
-        }
-
-        @Override
-        public void forEachOrdered(LongConsumer action) {
-            s.forEachOrdered(action);
-        }
-
-        @Override
-        public long[] toArray() {
-            return s.toArray();
-        }
-
-        @Override
-        public long reduce(long identity, LongBinaryOperator op) {
-            return s.reduce(identity, op);
-        }
-
-        @Override
-        public OptionalLong reduce(LongBinaryOperator op) {
-            return s.reduce(op);
-        }
-
-        @Override
-        public <R> R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R, R> combiner) {
-            return s.collect(supplier, accumulator, combiner);
-        }
-
-        @Override
-        public long sum() {
-            return s.sum();
-        }
-
-        @Override
-        public OptionalLong min() {
-            return s.min();
-        }
-
-        @Override
-        public OptionalLong max() {
-            return s.max();
-        }
-
-        @Override
-        public long count() {
-            return s.count();
-        }
-
-        @Override
-        public OptionalDouble average() {
-            return s.average();
-        }
-
-        @Override
-        public LongSummaryStatistics summaryStatistics() {
-            return s.summaryStatistics();
-        }
-
-        @Override
-        public boolean anyMatch(LongPredicate predicate) {
-            return s.anyMatch(predicate);
-        }
-
-        @Override
-        public boolean allMatch(LongPredicate predicate) {
-            return s.allMatch(predicate);
-        }
-
-        @Override
-        public boolean noneMatch(LongPredicate predicate) {
-            return s.noneMatch(predicate);
-        }
-
-        @Override
-        public OptionalLong findFirst() {
-            return s.findFirst();
-        }
-
-        @Override
-        public OptionalLong findAny() {
-            return s.findAny();
-        }
-
-        @Override
-        public DoubleStream asDoubleStream() {
-            return s.asDoubleStream();
-        }
-
-        @Override
-        public Stream<Long> boxed() {
-            return s.boxed();
-        }
-
-        @Override
-        public LongStream sequential() {
-            return s.sequential();
-        }
-
-        @Override
-        public LongStream parallel() {
-            return s.parallel();
-        }
-
-        @Override
-        public PrimitiveIterator.OfLong iterator() {
-            return s.iterator();
-        }
-
-        @Override
-        public Spliterator.OfLong spliterator() {
-            return s.spliterator();
-        }
-
-        @Override
-        public boolean isParallel() {
-            return s.isParallel();
-        }
-
-        @Override
-        public LongStream unordered() {
-            return s.unordered();
-        }
-
-        @Override
-        public LongStream onClose(Runnable closeHandler) {
-            return s.onClose(closeHandler);
-        }
-
-        @Override
-        public void close() {
-            s.close();
-        }
-    }
-
-    static final class DefaultMethodDoubleStream implements DoubleStream {
-        final DoubleStream s;
-
-        public DefaultMethodDoubleStream(DoubleStream s) {
-            this.s = s;
-        }
-
-        @Override
-        public DoubleStream filter(DoublePredicate predicate) {
-            return s.filter(predicate);
-        }
-
-        @Override
-        public DoubleStream map(DoubleUnaryOperator mapper) {
-            return s.map(mapper);
-        }
-
-        @Override
-        public <U> Stream<U> mapToObj(DoubleFunction<? extends U> mapper) {
-            return s.mapToObj(mapper);
-        }
-
-        @Override
-        public IntStream mapToInt(DoubleToIntFunction mapper) {
-            return s.mapToInt(mapper);
-        }
-
-        @Override
-        public LongStream mapToLong(DoubleToLongFunction mapper) {
-            return s.mapToLong(mapper);
-        }
-
-        @Override
-        public DoubleStream flatMap(DoubleFunction<? extends DoubleStream> mapper) {
-            return s.flatMap(mapper);
-        }
-
-        @Override
-        public DoubleStream distinct() {
-            return s.distinct();
-        }
-
-        @Override
-        public DoubleStream sorted() {
-            return s.sorted();
-        }
-
-        @Override
-        public DoubleStream peek(DoubleConsumer action) {
-            return s.peek(action);
-        }
-
-        @Override
-        public DoubleStream limit(long maxSize) {
-            return s.limit(maxSize);
-        }
-
-        @Override
-        public DoubleStream skip(long n) {
-            return s.skip(n);
-        }
-
-        @Override
-        public void forEach(DoubleConsumer action) {
-            s.forEach(action);
-        }
-
-        @Override
-        public void forEachOrdered(DoubleConsumer action) {
-            s.forEachOrdered(action);
-        }
-
-        @Override
-        public double[] toArray() {
-            return s.toArray();
-        }
-
-        @Override
-        public double reduce(double identity, DoubleBinaryOperator op) {
-            return s.reduce(identity, op);
-        }
-
-        @Override
-        public OptionalDouble reduce(DoubleBinaryOperator op) {
-            return s.reduce(op);
-        }
-
-        @Override
-        public <R> R collect(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R, R> combiner) {
-            return s.collect(supplier, accumulator, combiner);
-        }
-
-        @Override
-        public double sum() {
-            return s.sum();
-        }
-
-        @Override
-        public OptionalDouble min() {
-            return s.min();
-        }
-
-        @Override
-        public OptionalDouble max() {
-            return s.max();
-        }
-
-        @Override
-        public long count() {
-            return s.count();
-        }
-
-        @Override
-        public OptionalDouble average() {
-            return s.average();
-        }
-
-        @Override
-        public DoubleSummaryStatistics summaryStatistics() {
-            return s.summaryStatistics();
-        }
-
-        @Override
-        public boolean anyMatch(DoublePredicate predicate) {
-            return s.anyMatch(predicate);
-        }
-
-        @Override
-        public boolean allMatch(DoublePredicate predicate) {
-            return s.allMatch(predicate);
-        }
-
-        @Override
-        public boolean noneMatch(DoublePredicate predicate) {
-            return s.noneMatch(predicate);
-        }
-
-        @Override
-        public OptionalDouble findFirst() {
-            return s.findFirst();
-        }
-
-        @Override
-        public OptionalDouble findAny() {
-            return s.findAny();
-        }
-
-        @Override
-        public Stream<Double> boxed() {
-            return s.boxed();
-        }
-
-        @Override
-        public DoubleStream sequential() {
-            return s.sequential();
-        }
-
-        @Override
-        public DoubleStream parallel() {
-            return s.parallel();
-        }
-
-        @Override
-        public PrimitiveIterator.OfDouble iterator() {
-            return s.iterator();
-        }
-
-        @Override
-        public Spliterator.OfDouble spliterator() {
-            return s.spliterator();
-        }
-
-        @Override
-        public boolean isParallel() {
-            return s.isParallel();
-        }
-
-        @Override
-        public DoubleStream unordered() {
-            return s.unordered();
-        }
-
-        @Override
-        public DoubleStream onClose(Runnable closeHandler) {
-            return s.onClose(closeHandler);
-        }
-
-        @Override
-        public void close() {
-            s.close();
-        }
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DoubleStreamTestDataProvider.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import org.testng.annotations.DataProvider;
-
-import java.util.*;
-import java.util.Spliterators;
-import java.util.function.Supplier;
-
-/** TestNG DataProvider for double-valued streams */
-public class DoubleStreamTestDataProvider {
-    private static final double[] to0 = new double[0];
-    private static final double[] to1 = new double[1];
-    private static final double[] to10 = new double[10];
-    private static final double[] to100 = new double[100];
-    private static final double[] to1000 = new double[1000];
-    private static final double[] reversed = new double[100];
-    private static final double[] ones = new double[100];
-    private static final double[] twice = new double[200];
-    private static final double[] pseudoRandom;
-
-    private static final Object[][] testData;
-    private static final Object[][] testSmallData;
-    private static final Object[][] spliteratorTestData;
-
-    static {
-        double[][] arrays = {to0, to1, to10, to100, to1000};
-        for (double[] arr : arrays) {
-            for (int i = 0; i < arr.length; i++) {
-                arr[i] = i;
-            }
-        }
-        for (int i = 0; i < reversed.length; i++) {
-            reversed[i] = reversed.length - i;
-        }
-        for (int i = 0; i < ones.length; i++) {
-            ones[i] = 1;
-        }
-        System.arraycopy(to100, 0, twice, 0, to100.length);
-        System.arraycopy(to100, 0, twice, to100.length, to100.length);
-        pseudoRandom = new double[LambdaTestHelpers.LONG_STRING.length()];
-        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
-            pseudoRandom[i] = (double) LambdaTestHelpers.LONG_STRING.charAt(i);
-        }
-    }
-
-    static final Object[][] arrays = {
-            {"empty", to0},
-            {"0..1", to1},
-            {"0..10", to10},
-            {"0..100", to100},
-            {"0..1000", to1000},
-            {"100x[1]", ones},
-            {"2x[0..100]", twice},
-            {"reverse 0..100", reversed},
-            {"pseudorandom", pseudoRandom}
-    };
-
-    static {
-        {
-            List<Object[]> listSmall = new ArrayList<>();
-            List<Object[]> list1000 = new ArrayList<>();
-            List<Object[]> list = null;
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final double[] doubles = (double[]) data[1];
-
-                list = doubles.length >= 1000 ? list1000 : listSmall;
-
-                list.add(new Object[]{"array:" + name,
-                        TestData.Factory.ofArray("array:" + name, doubles)});
-
-                SpinedBuffer.OfDouble isl = new SpinedBuffer.OfDouble();
-                for (double i : doubles) {
-                    isl.accept(i);
-                }
-                list.add(new Object[]{"SpinedList:" + name,
-                        TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
-            }
-            testSmallData = listSmall.toArray(new Object[0][]);
-            list1000.addAll(listSmall);
-            testData = list1000.toArray(new Object[0][]);
-        }
-
-        {
-            List<Object[]> spliterators = new ArrayList<>();
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final double[] doubles = (double[]) data[1];
-
-                SpinedBuffer.OfDouble isl = new SpinedBuffer.OfDouble();
-                for (double i : doubles) {
-                    isl.accept(i);
-                }
-
-                spliterators.add(splitDescr("Arrays.s(array):" + name,
-                                            () -> Arrays.spliterator(doubles)));
-                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
-                                            () -> Arrays.spliterator(doubles, 0, doubles.length / 2)));
-
-                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
-                                            () -> isl.spliterator()));
-
-                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
-                                            () -> Spliterators.spliterator(isl.iterator(), doubles.length, 0)));
-                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
-                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
-                spliterators.add(splitDescr("DoubleStream.iterate(0,x->x<l;x->x+1):" + name,
-                                            () -> DoubleStream.iterate(0.0, x -> x < doubles.length, x -> x + 1.0)
-                                                              .spliterator()));
-                // Need more!
-            }
-            spliteratorTestData = spliterators.toArray(new Object[0][]);
-        }
-
-    }
-
-    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfDouble> s) {
-        return new Object[] { description, s };
-    }
-
-    // Return an array of ( String name, DoubleStreamTestData )
-    @DataProvider(name = "DoubleStreamTestData")
-    public static Object[][] makeDoubleStreamTestData() {
-        return testData;
-    }
-
-    @DataProvider(name = "DoubleStreamTestData.small")
-    public static Object[][] makeSmallDoubleStreamTestData() {
-        return testSmallData;
-    }
-
-    // returns an array of (String name, Supplier<PrimitiveSpliterator<Double>>)
-    @DataProvider(name = "DoubleSpliterator")
-    public static Object[][] spliteratorProvider() {
-        return spliteratorTestData;
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/DoubleStreamTestScenario.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.PrimitiveIterator;
-import java.util.Set;
-import java.util.Spliterator;
-import java.util.SpliteratorTestHelper;
-import java.util.function.Consumer;
-import java.util.function.DoubleConsumer;
-import java.util.function.Function;
-
-/**
- * Test scenarios for double streams.
- *
- * Each scenario is provided with a data source, a function that maps a fresh
- * stream (as provided by the data source) to a new stream, and a sink to
- * receive results.  Each scenario describes a different way of computing the
- * stream contents.  The test driver will ensure that all scenarios produce
- * the same output (modulo allowable differences in ordering).
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public enum DoubleStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
-
-    STREAM_FOR_EACH(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            DoubleStream s = m.apply(source);
-            if (s.isParallel()) {
-                s = s.sequential();
-            }
-            s.forEach(b);
-        }
-    },
-
-    STREAM_TO_ARRAY(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            for (double t : m.apply(source).toArray()) {
-                b.accept(t);
-            }
-        }
-    },
-
-    STREAM_ITERATOR(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            for (PrimitiveIterator.OfDouble seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
-                b.accept(seqIter.nextDouble());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            for (Spliterator.OfDouble spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
-    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR_FOREACH(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            m.apply(source).sequential().forEach(b);
-        }
-    },
-
-    // Wrap as parallel stream + forEachOrdered
-    PAR_STREAM_FOR_EACH_ORDERED(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            // @@@ Want to explicitly select ordered equalator
-            m.apply(source).forEachOrdered(b);
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            for (Spliterator.OfDouble spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR_FOREACH(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    PAR_STREAM_TO_ARRAY(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            for (double t : m.apply(source).toArray())
-                b.accept(t);
-        }
-    },
-
-    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
-    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            DoubleStream s = m.apply(source);
-            Spliterator.OfDouble sp = s.spliterator();
-            DoubleStream ss = StreamSupport.doubleStream(() -> sp,
-                                                         StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
-                                                         | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
-            for (double t : ss.toArray())
-                b.accept(t);
-        }
-    },
-
-    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            DoubleStream pipe2 = m.apply(pipe1);
-
-            for (double t : pipe2.toArray())
-                b.accept(t);
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing
-    PAR_STREAM_FOR_EACH(true, false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            m.apply(source).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
-    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            m.apply(pipe1).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-    ;
-
-    // The set of scenarios that clean the SIZED flag
-    public static final Set<DoubleStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
-            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
-
-    private boolean isParallel;
-
-    private final boolean isOrdered;
-
-    DoubleStreamTestScenario(boolean isParallel) {
-        this(isParallel, true);
-    }
-
-    DoubleStreamTestScenario(boolean isParallel, boolean isOrdered) {
-        this.isParallel = isParallel;
-        this.isOrdered = isOrdered;
-    }
-
-    public StreamShape getShape() {
-        return StreamShape.DOUBLE_VALUE;
-    }
-
-    public boolean isParallel() {
-        return isParallel;
-    }
-
-    public boolean isOrdered() {
-        return isOrdered;
-    }
-
-    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
-        try (S_IN source = getStream(data)) {
-            run(data, source, (DoubleConsumer) b, (Function<S_IN, DoubleStream>) m);
-        }
-    }
-
-    abstract <T, S_IN extends BaseStream<T, S_IN>>
-    void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m);
-
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/FlagDeclaringOp.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-/**
- * An operation that injects or clears flags but otherwise performs no operation on elements.
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public class FlagDeclaringOp<T> implements StatelessTestOp<T, T> {
-    private final int flags;
-    private final StreamShape shape;
-
-    public FlagDeclaringOp(int flags) {
-        this(flags, StreamShape.REFERENCE);
-    }
-
-    public FlagDeclaringOp(int flags, StreamShape shape) {
-        this.flags = flags;
-        this.shape = shape;
-    }
-
-    @Override
-    public StreamShape outputShape() {
-        return shape;
-    }
-
-    @Override
-    public StreamShape inputShape() {
-        return shape;
-    }
-
-    @Override
-    public int opGetFlags() {
-        return flags;
-    }
-
-    @Override
-    public Sink<T> opWrapSink(int flags, boolean parallel, Sink sink) {
-        return sink;
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntStreamTestDataProvider.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import org.testng.annotations.DataProvider;
-
-import java.util.*;
-import java.util.Spliterators;
-import java.util.function.Supplier;
-
-/** TestNG DataProvider for int-valued streams */
-public class IntStreamTestDataProvider {
-    private static final int[] to0 = new int[0];
-    private static final int[] to1 = new int[1];
-    private static final int[] to10 = new int[10];
-    private static final int[] to100 = new int[100];
-    private static final int[] to1000 = new int[1000];
-    private static final int[] reversed = new int[100];
-    private static final int[] ones = new int[100];
-    private static final int[] twice = new int[200];
-    private static final int[] pseudoRandom;
-
-    private static final Object[][] testData;
-    private static final Object[][] testSmallData;
-    private static final Object[][] spliteratorTestData;
-
-    static {
-        int[][] arrays = {to0, to1, to10, to100, to1000};
-        for (int[] arr : arrays) {
-            for (int i = 0; i < arr.length; i++) {
-                arr[i] = i;
-            }
-        }
-        for (int i = 0; i < reversed.length; i++) {
-            reversed[i] = reversed.length - i;
-        }
-        for (int i = 0; i < ones.length; i++) {
-            ones[i] = 1;
-        }
-        System.arraycopy(to100, 0, twice, 0, to100.length);
-        System.arraycopy(to100, 0, twice, to100.length, to100.length);
-        pseudoRandom = new int[LambdaTestHelpers.LONG_STRING.length()];
-        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
-            pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
-        }
-    }
-
-    static final Object[][] arrays = {
-            {"empty", to0},
-            {"0..1", to1},
-            {"0..10", to10},
-            {"0..100", to100},
-            {"0..1000", to1000},
-            {"100x[1]", ones},
-            {"2x[0..100]", twice},
-            {"reverse 0..100", reversed},
-            {"pseudorandom", pseudoRandom}
-    };
-
-    static {
-        {
-            List<Object[]> listSmall = new ArrayList<>();
-            List<Object[]> list1000 = new ArrayList<>();
-            List<Object[]> list = null;
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final int[] ints = (int[]) data[1];
-
-                list = ints.length >= 1000 ? list1000 : listSmall;
-
-                list.add(new Object[]{"array:" +
-                                      name, TestData.Factory.ofArray("array:" + name, ints)});
-
-                SpinedBuffer.OfInt isl = new SpinedBuffer.OfInt();
-                for (int i : ints) {
-                    isl.accept(i);
-                }
-                list.add(new Object[]{"SpinedList:" + name,
-                         TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
-
-                list.add(streamDataDescr("IntStream.intRange(0,l): " + ints.length,
-                                         () -> IntStream.range(0, ints.length)));
-                list.add(streamDataDescr("IntStream.rangeClosed(0,l): " + ints.length,
-                                         () -> IntStream.rangeClosed(0, ints.length)));
-            }
-            testSmallData = listSmall.toArray(new Object[0][]);
-            list1000.addAll(listSmall);
-            testData = list1000.toArray(new Object[0][]);
-        }
-
-        {
-            List<Object[]> spliterators = new ArrayList<>();
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final int[] ints = (int[]) data[1];
-
-                SpinedBuffer.OfInt isl = new SpinedBuffer.OfInt();
-                for (int i : ints) {
-                    isl.accept(i);
-                }
-
-                spliterators.add(splitDescr("Arrays.s(array):" + name,
-                                            () -> Arrays.spliterator(ints)));
-                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
-                                            () -> Arrays.spliterator(ints, 0, ints.length / 2)));
-
-                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
-                                            () -> isl.spliterator()));
-
-                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
-                                            () -> Spliterators.spliterator(isl.iterator(), ints.length, 0)));
-                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
-                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
-
-                spliterators.add(splitDescr("IntStream.intRange(0,l):" + name,
-                                            () -> IntStream.range(0, ints.length).spliterator()));
-                spliterators.add(splitDescr("IntStream.intRangeClosed(0,l):" + name,
-                                            () -> IntStream.rangeClosed(0, ints.length).spliterator()));
-                spliterators.add(splitDescr("IntStream.iterate(0,x->x<l,x->x+1): " + name,
-                                            () -> IntStream.iterate(0, x -> x < ints.length, x -> x + 1).spliterator()));
-                // Need more!
-            }
-            spliteratorTestData = spliterators.toArray(new Object[0][]);
-        }
-
-    }
-
-    static <T> Object[] streamDataDescr(String description, Supplier<IntStream> s) {
-        return new Object[] { description, TestData.Factory.ofIntSupplier(description, s) };
-    }
-
-    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfInt> s) {
-        return new Object[] { description, s };
-    }
-
-    // Return an array of ( String name, IntStreamTestData )
-    @DataProvider(name = "IntStreamTestData")
-    public static Object[][] makeIntStreamTestData() {
-        return testData;
-    }
-
-    @DataProvider(name = "IntStreamTestData.small")
-    public static Object[][] makeSmallIntStreamTestData() {
-        return testSmallData;
-    }
-
-    // returns an array of (String name, Supplier<PrimitiveSpliterator<Integer>>)
-    @DataProvider(name = "IntSpliterator")
-    public static Object[][] spliteratorProvider() {
-        return spliteratorTestData;
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntStreamTestScenario.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,234 +0,0 @@
-/*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.PrimitiveIterator;
-import java.util.Set;
-import java.util.Spliterator;
-import java.util.SpliteratorTestHelper;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.function.IntConsumer;
-
-/**
- * Test scenarios for int streams.
- *
- * Each scenario is provided with a data source, a function that maps a fresh
- * stream (as provided by the data source) to a new stream, and a sink to
- * receive results.  Each scenario describes a different way of computing the
- * stream contents.  The test driver will ensure that all scenarios produce
- * the same output (modulo allowable differences in ordering).
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public enum IntStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
-
-    STREAM_FOR_EACH(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            IntStream s = m.apply(source);
-            if (s.isParallel()) {
-                s = s.sequential();
-            }
-            s.forEach(b);
-        }
-    },
-
-    STREAM_TO_ARRAY(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            for (int t : m.apply(source).toArray()) {
-                b.accept(t);
-            }
-        }
-    },
-
-    STREAM_ITERATOR(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            for (PrimitiveIterator.OfInt seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
-                b.accept(seqIter.nextInt());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            for (Spliterator.OfInt spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
-    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR_FOREACH(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            m.apply(source).sequential().forEach(b);
-        }
-    },
-
-    // Wrap as parallel stream + forEachOrdered
-    PAR_STREAM_FOR_EACH_ORDERED(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            // @@@ Want to explicitly select ordered equalator
-            m.apply(source).forEachOrdered(b);
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            for (Spliterator.OfInt spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR_FOREACH(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    PAR_STREAM_TO_ARRAY(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            for (int t : m.apply(source).toArray())
-                b.accept(t);
-        }
-    },
-
-    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
-    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            IntStream s = m.apply(source);
-            Spliterator.OfInt sp = s.spliterator();
-            IntStream ss = StreamSupport.intStream(() -> sp,
-                                                   StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
-                                                   | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED),
-                                                   true);
-            for (int t : ss.toArray())
-                b.accept(t);
-        }
-    },
-
-    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            IntStream pipe2 = m.apply(pipe1);
-
-            for (int t : pipe2.toArray())
-                b.accept(t);
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing
-    PAR_STREAM_FOR_EACH(true, false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            m.apply(source).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
-    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            m.apply(pipe1).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-    ;
-
-    // The set of scenarios that clean the SIZED flag
-    public static final Set<IntStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
-            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
-
-    private final boolean isParallel;
-
-    private final boolean isOrdered;
-
-    IntStreamTestScenario(boolean isParallel) {
-        this(isParallel, true);
-    }
-
-    IntStreamTestScenario(boolean isParallel, boolean isOrdered) {
-        this.isParallel = isParallel;
-        this.isOrdered = isOrdered;
-    }
-
-    public StreamShape getShape() {
-        return StreamShape.INT_VALUE;
-    }
-
-    public boolean isParallel() {
-        return isParallel;
-    }
-
-    public boolean isOrdered() {
-        return isOrdered;
-    }
-
-    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
-        try (S_IN source = getStream(data)) {
-            run(data, source, (IntConsumer) b, (Function<S_IN, IntStream>) m);
-        }
-    }
-
-    abstract <T, S_IN extends BaseStream<T, S_IN>>
-    void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m);
-
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/IntermediateTestOp.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-/**
- * A base type for test operations
- */
-interface IntermediateTestOp<E_IN, E_OUT> {
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public static<T> AbstractPipeline chain(AbstractPipeline upstream,
-                                            IntermediateTestOp<?, T> op) {
-        if (op instanceof StatelessTestOp)
-            return StatelessTestOp.chain(upstream, (StatelessTestOp) op);
-
-        if (op instanceof StatefulTestOp)
-            return StatefulTestOp.chain(upstream, (StatefulTestOp) op);
-
-        throw new IllegalStateException("Unknown test op type: " + op.getClass().getName());
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LambdaTestHelpers.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,473 +0,0 @@
-/*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.*;
-import java.util.function.BiConsumer;
-import java.util.function.BiPredicate;
-import java.util.function.BinaryOperator;
-import java.util.function.Consumer;
-import java.util.function.DoubleBinaryOperator;
-import java.util.function.DoubleConsumer;
-import java.util.function.DoublePredicate;
-import java.util.function.Function;
-import java.util.function.IntBinaryOperator;
-import java.util.function.IntConsumer;
-import java.util.function.IntFunction;
-import java.util.function.IntPredicate;
-import java.util.function.IntUnaryOperator;
-import java.util.function.LongBinaryOperator;
-import java.util.function.LongConsumer;
-import java.util.function.LongPredicate;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-import java.util.function.ToDoubleFunction;
-import java.util.function.ToIntFunction;
-import java.util.function.ToLongFunction;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.assertFalse;
-
-/**
- * LambdaTestHelpers -- assertion methods and useful objects for lambda test cases
- */
-public class LambdaTestHelpers {
-    public static final String LONG_STRING = "When in the Course of human events it becomes necessary for one people to dissolve the political bands which have connected them with another and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.";
-
-    @SuppressWarnings("rawtypes")
-    public static final Consumer bEmpty = x -> {  };
-    @SuppressWarnings("rawtypes")
-    public static final IntConsumer bIntEmpty = x -> {  };
-    @SuppressWarnings("rawtypes")
-    public static final BiConsumer bBiEmpty = (x,y) -> { };
-    @SuppressWarnings("rawtypes")
-    public static final Consumer bHashCode = x -> { Objects.hashCode(x); };
-    @SuppressWarnings("rawtypes")
-    public static final BiConsumer bBiHashCode = (x,y) -> { Objects.hash(x, y); };
-    public static final Function<Integer, Integer> mZero = x -> 0;
-    public static final Function<Integer, Integer> mId = x -> x;
-    public static final Function<Integer, Integer> mDoubler = x -> x * 2;
-    public static final Function<Integer, Stream<Integer>> mfId = e -> Collections.singletonList(e).stream();
-    public static final Function<Integer, Stream<Integer>> mfNull = e -> Collections.<Integer>emptyList().stream();
-    public static final Function<Integer, Stream<Integer>> mfLt = e -> {
-        List<Integer> l = new ArrayList<>();
-        for (int i=0; i<e; i++)
-            l.add(i);
-        return l.stream();
-    };
-    public static final ToIntFunction<Integer> imDoubler = x -> x * 2;
-    public static final ToLongFunction<Long> lmDoubler = x -> x * 2;
-    public static final ToDoubleFunction<Double> dmDoubler = x -> x * 2;
-    public static final Predicate<Integer> pFalse = x -> false;
-    public static final Predicate<Integer> pTrue = x -> true;
-    public static final Predicate<Integer> pEven = x -> 0 == x % 2;
-    public static final Predicate<Integer> pOdd = x -> 1 == x % 2;
-    public static final IntPredicate ipFalse = x -> false;
-    public static final IntPredicate ipTrue = x -> true;
-    public static final IntPredicate ipEven = x -> 0 == x % 2;
-    public static final IntPredicate ipOdd = x -> 1 == x % 2;
-    public static final LongPredicate lpFalse = x -> false;
-    public static final LongPredicate lpTrue = x -> true;
-    public static final LongPredicate lpEven = x -> 0 == x % 2;
-    public static final LongPredicate lpOdd = x -> 1 == x % 2;
-    public static final DoublePredicate dpFalse = x -> false;
-    public static final DoublePredicate dpTrue = x -> true;
-    public static final DoublePredicate dpEven = x -> 0 == ((long) x) % 2;
-    public static final DoublePredicate dpOdd = x -> 1 == ((long) x) % 2;
-    public static final BinaryOperator<Integer> rPlus = (x, y) -> x+y;
-    public static final BinaryOperator<Integer> rMax = (x, y) -> Math.max(x, y);
-    public static final BinaryOperator<Integer> rMin = (x, y) -> Math.min(x,y);
-    public static final IntBinaryOperator irPlus = (x, y) -> x+y;
-    public static final IntBinaryOperator irMax = (x, y) -> Math.max(x, y);
-    public static final IntBinaryOperator irMin = (x, y) -> Math.min(x,y);
-    public static final IntUnaryOperator irDoubler = x -> x * 2;
-    public static final LongBinaryOperator lrPlus = (x, y) -> x+y;
-    public static final DoubleBinaryOperator drPlus = (x, y) -> x+y;
-    public static final Comparator<Integer> cInteger = (a, b) -> Integer.compare(a, b);
-    public static final BiPredicate<?, ?> bipFalse = (x, y) -> false;
-    public static final BiPredicate<?, ?> bipTrue = (x, y) -> true;
-    public static final BiPredicate<Integer, Integer> bipBothEven = (x, y) -> 0 == (x % 2 + y % 2);
-    public static final BiPredicate<Integer, Integer> bipBothOdd = (x, y) -> 2 == (x % 2 + y % 2);
-    public static final BiPredicate<?, ?> bipSameString = (x, y) -> String.valueOf(x).equals(String.valueOf(y));
-
-    public static final IntFunction<Integer[]> integerArrayGenerator = s -> new Integer[s];
-
-    public static final IntFunction<Object[]> objectArrayGenerator = s -> new Object[s];
-
-    public static final Function<String, Stream<Character>> flattenChars = string -> {
-        List<Character> l = new ArrayList<>();
-        for (int i=0; i<string.length(); i++)
-            l.add(string.charAt(i));
-        return l.stream();
-    };
-
-    public static final Function<String, IntStream> flattenInt
-            = string -> IntStream.range(0, string.length()).map(string::charAt);
-
-    public static <T, R> Function<T, R> forPredicate(Predicate<? super T> predicate, R forTrue, R forFalse) {
-        Objects.requireNonNull(predicate);
-
-        return t -> predicate.test(t) ? forTrue : forFalse;
-    }
-
-    public static <T> Function<T, T> identity() {
-        return t -> t;
-    }
-
-    public static<V, T, R> Function<V, R> compose(Function<? super T, ? extends R> after, Function<? super V, ? extends T> before) {
-        Objects.requireNonNull(before);
-        return (V v) -> after.apply(before.apply(v));
-    }
-
-    public static List<Integer> empty() {
-        ArrayList<Integer> list = new ArrayList<>();
-        list.add(null);
-        return list;
-    }
-
-    public static List<Integer> countTo(int n) {
-        return range(1, n);
-    }
-
-    public static List<Integer> range(int l, int u) {
-        ArrayList<Integer> list = new ArrayList<>(u - l + 1);
-        for (int i=l; i<=u; i++) {
-            list.add(i);
-        }
-        return list;
-    }
-
-    public static List<Integer> repeat(int value, int n) {
-        ArrayList<Integer> list = new ArrayList<>(n);
-        for (int i=1; i<=n; i++) {
-            list.add(value);
-        }
-        return list;
-    }
-
-    public static List<Double> asDoubles(List<Integer> integers) {
-        ArrayList<Double> list = new ArrayList<>();
-        for (Integer i : integers) {
-            list.add((double) i);
-        }
-        return list;
-    }
-
-    public static List<Long> asLongs(List<Integer> integers) {
-        ArrayList<Long> list = new ArrayList<>();
-        for (Integer i : integers) {
-            list.add((long) i);
-        }
-        return list;
-    }
-
-    public static void assertCountSum(Stream<? super Integer> it, int count, int sum) {
-        assertCountSum(it.iterator(), count, sum);
-    }
-
-    public static void assertCountSum(Iterable<? super Integer> it, int count, int sum) {
-        assertCountSum(it.iterator(), count, sum);
-    }
-
-    public static void assertCountSum(Iterator<? super Integer> it, int count, int sum) {
-        int c = 0;
-        int s = 0;
-        while (it.hasNext()) {
-            int i = (Integer) it.next();
-            c++;
-            s += i;
-        }
-
-        assertEquals(c, count);
-        assertEquals(s, sum);
-    }
-
-    public static void assertConcat(Iterator<Character> it, String result) {
-        StringBuilder sb = new StringBuilder();
-        while (it.hasNext()) {
-            sb.append(it.next());
-        }
-
-        assertEquals(result, sb.toString());
-    }
-
-    public static<T extends Comparable<? super T>> void assertSorted(Iterator<T> i) {
-        i = toBoxedList(i).iterator();
-
-        if (!i.hasNext())
-            return;
-        T last = i.next();
-        while (i.hasNext()) {
-            T t = i.next();
-            assertTrue(last.compareTo(t) <= 0);
-            assertTrue(t.compareTo(last) >= 0);
-            last = t;
-        }
-    }
-
-    public static<T> void assertSorted(Iterator<T> i, Comparator<? super T> comp) {
-        if (i instanceof PrimitiveIterator.OfInt
-                || i instanceof PrimitiveIterator.OfDouble
-                || i instanceof PrimitiveIterator.OfLong) {
-            i = toBoxedList(i).iterator();
-        }
-
-        if (!i.hasNext())
-            return;
-        T last = i.next();
-        while (i.hasNext()) {
-            T t = i.next();
-            assertTrue(comp.compare(last, t) <= 0);
-            assertTrue(comp.compare(t, last) >= 0);
-            last = t;
-        }
-    }
-
-    public static<T extends Comparable<? super T>> void assertSorted(Iterable<T> iter) {
-        assertSorted(iter.iterator());
-    }
-
-    public static<T> void assertSorted(Iterable<T> iter, Comparator<? super T> comp) {
-        assertSorted(iter.iterator(), comp);
-    }
-
-    public static <T> void assertUnique(Iterable<T> iter) {
-        assertUnique(iter.iterator());
-    }
-
-    public static<T> void assertUnique(Iterator<T> iter) {
-        if (!iter.hasNext()) {
-            return;
-        }
-
-        if (iter instanceof PrimitiveIterator.OfInt
-            || iter instanceof PrimitiveIterator.OfDouble
-            || iter instanceof PrimitiveIterator.OfLong) {
-            iter = toBoxedList(iter).iterator();
-        }
-
-        Set<T> uniq = new HashSet<>();
-        while(iter.hasNext()) {
-            T each = iter.next();
-            assertTrue(!uniq.contains(each), "Not unique");
-            uniq.add(each);
-        }
-    }
-
-    public static<T> void assertContents(Iterable<T> actual, Iterable<T> expected) {
-        if (actual instanceof Collection && expected instanceof Collection) {
-            assertEquals(actual, expected);
-        } else {
-            assertContents(actual.iterator(), expected.iterator());
-        }
-    }
-
-    public static<T> void assertContents(Iterator<T> actual, Iterator<T> expected) {
-        assertEquals(toBoxedList(actual), toBoxedList(expected));
-    }
-
-    @SafeVarargs
-    @SuppressWarnings("varargs")
-    public static<T> void assertContents(Iterator<T> actual, T... expected) {
-        assertContents(actual, Arrays.asList(expected).iterator());
-    }
-
-    /**
-     * The all consuming consumer (rampant capitalist) that can accepting a reference or any primitive value.
-     */
-    private static interface OmnivorousConsumer<T>
-            extends Consumer<T>, IntConsumer, LongConsumer, DoubleConsumer { }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public static<T> Consumer<T> toBoxingConsumer(Consumer<? super T> c) {
-        return (Consumer<T>) new OmnivorousConsumer() {
-            @Override
-            public void accept(Object t) {
-                c.accept((T) t);
-            }
-
-            @Override
-            public void accept(int t) {
-                accept((Object) t);
-            }
-
-            @Override
-            public void accept(long t) {
-                accept((Object) t);
-            }
-
-            @Override
-            public void accept(double t) {
-                accept((Object) t);
-            }
-        };
-    }
-
-    /**
-     * Convert an iterator to a list using forEach with an implementation of
-     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
-     *
-     * This ensures equality comparisons for test results do not trip
-     * the boxing trip-wires.
-     */
-    private static<T> List<T> toBoxedList(Iterator<T> it) {
-        List<T> l = new ArrayList<>();
-        it.forEachRemaining(toBoxingConsumer(l::add));
-        return l;
-    }
-
-    /**
-     * Convert a spliterator to a list using forEach with an implementation of
-     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
-     *
-     * This ensures equality comparisons for test results do not trip
-     * the boxing trip-wires.
-     */
-    public static<T> List<T> toBoxedList(Spliterator<T> sp) {
-        List<T> l = new ArrayList<>();
-        sp.forEachRemaining(toBoxingConsumer(l::add));
-        return l;
-    }
-
-    /**
-     * Convert an iterator to a multi-set, represented as a Map, using forEach with an implementation of
-     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
-     *
-     * This ensures equality comparisons for test results do not trip
-     * the boxing trip-wires.
-     */
-    @SuppressWarnings("unchecked")
-    private static<T> Map<T, Integer> toBoxedMultiset(Iterator<T> it) {
-        Map<Object, Integer> result = new HashMap<>();
-
-        it.forEachRemaining(toBoxingConsumer(o -> {
-                if (result.containsKey(o))
-                    result.put(o, result.get(o) + 1);
-                else
-                    result.put(o, 1);
-            }));
-
-        return (Map<T, Integer>) result;
-    }
-
-    @SuppressWarnings("unchecked")
-    public static<T> Map<T, Integer> toBoxedMultiset(Spliterator<T> it) {
-        Map<Object, Integer> result = new HashMap<>();
-
-        it.forEachRemaining(toBoxingConsumer(o -> {
-                if (result.containsKey(o))
-                    result.put(o, result.get(o) + 1);
-                else
-                    result.put(o, 1);
-            }));
-
-        return (Map<T, Integer>) result;
-    }
-
-    @SuppressWarnings("unchecked")
-    public static void assertContentsEqual(Object a, Object b) {
-        if (a instanceof Iterable && b instanceof Iterable)
-            assertContents((Iterable) a, (Iterable) b);
-        else
-            assertEquals(a, b);
-    }
-
-    public static<T> void assertContentsUnordered(Iterable<T> actual, Iterable<T> expected) {
-        assertContentsUnordered(actual.iterator(), expected.iterator());
-    }
-
-    public static<T> void assertContentsUnordered(Iterator<T> actual, Iterator<T> expected) {
-        assertEquals(toBoxedMultiset(actual), toBoxedMultiset(expected));
-    }
-
-    public static<T> void assertContains(Optional<T> actual, Iterator<T> it) {
-        actual.ifPresentOrElse(r -> {
-            boolean contained = false;
-            while (!contained && it.hasNext()) {
-                contained = Objects.equals(r, it.next());
-            }
-            assertTrue(contained, "Not found: "+r);
-        }, () -> assertFalse(it.hasNext()));
-    }
-
-    public static void launderAssertion(Runnable r, Supplier<String> additionalInfo) {
-        try {
-            r.run();
-        }
-        catch (AssertionError ae) {
-            AssertionError cloned = new AssertionError(ae.getMessage() + String.format("%n%s", additionalInfo.get()));
-            cloned.setStackTrace(ae.getStackTrace());
-            if (ae.getCause() != null)
-                cloned.initCause(ae.getCause());
-            throw cloned;
-        }
-    }
-
-    public static <T, S extends BaseStream<T, S>>
-    List<Function<S, S>> permuteStreamFunctions(List<Function<S, S>> opFunctions) {
-        List<List<Function<S, S>>> opFunctionPermutations = perm(opFunctions);
-
-        List<Function<S, S>> appliedFunctions = new ArrayList<>();
-        for (List<Function<S, S>> fs : opFunctionPermutations) {
-            Function<S, S> applied = s -> {
-                for (Function<S, S> f : fs) {
-                    s = f.apply(s);
-                }
-                return s;
-            };
-            appliedFunctions.add(applied);
-        }
-
-        return appliedFunctions;
-    }
-
-    private static <T> List<T> sub(List<T> l, int index) {
-        List<T> subL = new ArrayList<>(l);
-        subL.remove(index);
-        return subL;
-    }
-
-    public static <T> List<List<T>> perm(List<T> l) {
-        List<List<T>> result = new ArrayList<>();
-        for (int i = 0; i < l.size(); i++) {
-            for (List<T> perm : perm(sub(l, i))) {
-                perm.add(0, l.get(i));
-                result.add(perm);
-            }
-        }
-        result.add(new ArrayList<T>());
-
-        return result;
-    }
-
-    public static String flagsToString(int flags) {
-        StringJoiner sj = new StringJoiner(", ", "StreamOpFlag[", "]");
-        if (StreamOpFlag.DISTINCT.isKnown(flags)) sj.add("IS_DISTINCT");
-        if (StreamOpFlag.ORDERED.isKnown(flags)) sj.add("IS_ORDERED");
-        if (StreamOpFlag.SIZED.isKnown(flags)) sj.add("IS_SIZED");
-        if (StreamOpFlag.SORTED.isKnown(flags)) sj.add("IS_SORTED");
-        if (StreamOpFlag.SHORT_CIRCUIT.isKnown(flags)) sj.add("IS_SHORT_CIRCUIT");
-        return sj.toString();
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LambdaTestMode.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-/**
- * Runtime modes of test execution.
- */
-public enum LambdaTestMode {
-    /**
-     * Execution mode with no particular runtime constraints.
-     */
-    NORMAL,
-
-    /**
-     * Execution mode where tests are executed for testing lambda serialization
-     * and deserialization.
-     *
-     * <p>This mode may be queried by tests or data supplied by data
-     * providers, which cannot otherwise be assigned to the test group
-     * <em>serialization-hostile</em>, to not execute or declare
-     * serialization-hostile code or data.
-     *
-     * <p>This mode is enabled if the boolean system property
-     * {@code org.openjdk.java.util.stream.sand.mode} is declared with a
-     * {@code true} value.
-     */
-    SERIALIZATION;
-
-    /**
-     * {@code true} if tests are executed in the mode for testing lambda
-     * Serialization ANd Deserialization (SAND).
-     */
-    private static final boolean IS_LAMBDA_SERIALIZATION_MODE =
-            Boolean.getBoolean("org.openjdk.java.util.stream.sand.mode");
-
-    /**
-     *
-     * @return the mode of test execution.
-     */
-    public static LambdaTestMode getMode() {
-        return IS_LAMBDA_SERIALIZATION_MODE ? SERIALIZATION : NORMAL;
-    }
-
-    /**
-     *
-     * @return {@code true} if normal test mode.
-     */
-    public static boolean isNormalMode() {
-        return getMode() == NORMAL;
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LoggingTestCase.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.testng.Assert;
-import org.testng.ITestResult;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- * LoggingTestCase
- *
- */
-@Test
-public class LoggingTestCase extends Assert {
-    private Map<String, Object> context = new HashMap<>();
-
-    @BeforeMethod
-    public void before() {
-        context.clear();
-    }
-
-    @AfterMethod
-    public void after(ITestResult result) {
-        if (!result.isSuccess()) {
-            List<Object> list = new ArrayList<>();
-            Collections.addAll(list, result.getParameters());
-            list.add(context.toString());
-            result.setParameters(list.toArray(new Object[list.size()]));
-        }
-    }
-
-    protected void setContext(String key, Object value) {
-        context.put(key, value);
-    }
-
-    protected void clearContext(String key) {
-        context.remove(key);
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LongStreamTestDataProvider.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-/*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import org.testng.annotations.DataProvider;
-
-import java.util.*;
-import java.util.Spliterators;
-import java.util.function.Supplier;
-
-/** TestNG DataProvider for long-valued streams */
-public class LongStreamTestDataProvider {
-    private static final long[] to0 = new long[0];
-    private static final long[] to1 = new long[1];
-    private static final long[] to10 = new long[10];
-    private static final long[] to100 = new long[100];
-    private static final long[] to1000 = new long[1000];
-    private static final long[] reversed = new long[100];
-    private static final long[] ones = new long[100];
-    private static final long[] twice = new long[200];
-    private static final long[] pseudoRandom;
-
-    private static final Object[][] testData;
-    private static final Object[][] testSmallData;
-    private static final Object[][] spliteratorTestData;
-
-    static {
-        long[][] arrays = {to0, to1, to10, to100, to1000};
-        for (long[] arr : arrays) {
-            for (int i = 0; i < arr.length; i++) {
-                arr[i] = i;
-            }
-        }
-        for (int i = 0; i < reversed.length; i++) {
-            reversed[i] = reversed.length - i;
-        }
-        for (int i = 0; i < ones.length; i++) {
-            ones[i] = 1;
-        }
-        System.arraycopy(to100, 0, twice, 0, to100.length);
-        System.arraycopy(to100, 0, twice, to100.length, to100.length);
-        pseudoRandom = new long[LambdaTestHelpers.LONG_STRING.length()];
-        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
-            pseudoRandom[i] = (long) LambdaTestHelpers.LONG_STRING.charAt(i);
-        }
-    }
-
-    static final Object[][] arrays = {
-            {"empty", to0},
-            {"0..1", to1},
-            {"0..10", to10},
-            {"0..100", to100},
-            {"0..1000", to1000},
-            {"100x[1]", ones},
-            {"2x[0..100]", twice},
-            {"reverse 0..100", reversed},
-            {"pseudorandom", pseudoRandom}
-    };
-
-    static {
-        {
-            List<Object[]> listSmall = new ArrayList<>();
-            List<Object[]> list1000 = new ArrayList<>();
-            List<Object[]> list = null;
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final long[] longs = (long[]) data[1];
-
-                list = longs.length >= 1000 ? list1000 : listSmall;
-
-                list.add(new Object[]{"array:" + name,
-                        TestData.Factory.ofArray("array:" + name, longs)});
-
-                SpinedBuffer.OfLong isl = new SpinedBuffer.OfLong();
-                for (long i : longs) {
-                    isl.accept(i);
-                }
-                list.add(new Object[]{"SpinedList:" + name,
-                        TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
-
-                list.add(streamDataDescr("LongStream.longRange(0,l): " + longs.length,
-                                         () -> LongStream.range(0, longs.length)));
-                list.add(streamDataDescr("LongStream.longRangeClosed(0,l): " + longs.length,
-                                         () -> LongStream.rangeClosed(0, longs.length)));
-            }
-            testSmallData = listSmall.toArray(new Object[0][]);
-            list1000.addAll(listSmall);
-            testData = list1000.toArray(new Object[0][]);
-        }
-
-        {
-            List<Object[]> spliterators = new ArrayList<>();
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final long[] longs = (long[]) data[1];
-
-                SpinedBuffer.OfLong isl = new SpinedBuffer.OfLong();
-                for (long i : longs) {
-                    isl.accept(i);
-                }
-
-                spliterators.add(splitDescr("Arrays.s(array):" + name,
-                                            () -> Arrays.spliterator(longs)));
-                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
-                                            () -> Arrays.spliterator(longs, 0, longs.length / 2)));
-
-                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
-                                            () -> isl.spliterator()));
-
-                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
-                                            () -> Spliterators.spliterator(isl.iterator(), longs.length, 0)));
-                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
-                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
-
-                spliterators.add(splitDescr("LongStream.longRange(0,l):" + name,
-                                            () -> LongStream.range(0, longs.length).spliterator()));
-                spliterators.add(splitDescr("LongStream.longRangeClosed(0,l):" + name,
-                                            () -> LongStream.rangeClosed(0, longs.length).spliterator()));
-                spliterators.add(splitDescr("LongStream.iterate(0,x->x<l;x->x+1):" + name,
-                                            () -> LongStream.iterate(0L, x -> x < longs.length, x -> x + 1L)
-                                                            .spliterator()));
-                // Need more!
-            }
-            spliteratorTestData = spliterators.toArray(new Object[0][]);
-        }
-
-    }
-
-    static <T> Object[] streamDataDescr(String description, Supplier<LongStream> s) {
-        return new Object[] { description, TestData.Factory.ofLongSupplier(description, s) };
-    }
-
-    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfLong> s) {
-        return new Object[] { description, s };
-    }
-
-    // Return an array of ( String name, LongStreamTestData )
-    @DataProvider(name = "LongStreamTestData")
-    public static Object[][] makeLongStreamTestData() {
-        return testData;
-    }
-
-    @DataProvider(name = "LongStreamTestData.small")
-    public static Object[][] makeSmallLongStreamTestData() {
-        return testSmallData;
-    }
-
-    // returns an array of (String name, Supplier<PrimitiveSpliterator<Long>>)
-    @DataProvider(name = "LongSpliterator")
-    public static Object[][] spliteratorProvider() {
-        return spliteratorTestData;
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/LongStreamTestScenario.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.PrimitiveIterator;
-import java.util.Set;
-import java.util.Spliterator;
-import java.util.SpliteratorTestHelper;
-import java.util.function.Consumer;
-import java.util.function.Function;
-import java.util.function.LongConsumer;
-
-/**
- * Test scenarios for long streams.
- *
- * Each scenario is provided with a data source, a function that maps a fresh
- * stream (as provided by the data source) to a new stream, and a sink to
- * receive results.  Each scenario describes a different way of computing the
- * stream contents.  The test driver will ensure that all scenarios produce
- * the same output (modulo allowable differences in ordering).
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public enum LongStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
-
-    STREAM_FOR_EACH(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            LongStream s = m.apply(source);
-            if (s.isParallel()) {
-                s = s.sequential();
-            }
-            s.forEach(b);
-        }
-    },
-
-    STREAM_TO_ARRAY(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            for (long t : m.apply(source).toArray()) {
-                b.accept(t);
-            }
-        }
-    },
-
-    STREAM_ITERATOR(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            for (PrimitiveIterator.OfLong seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
-                b.accept(seqIter.nextLong());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            for (Spliterator.OfLong spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
-    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR_FOREACH(false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            m.apply(source).sequential().forEach(b);
-        }
-    },
-
-    // Wrap as parallel stream + forEachOrdered
-    PAR_STREAM_FOR_EACH_ORDERED(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            // @@@ Want to explicitly select ordered equalator
-            m.apply(source).forEachOrdered(b);
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            for (Spliterator.OfLong spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR_FOREACH(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    PAR_STREAM_TO_ARRAY(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            for (long t : m.apply(source).toArray())
-                b.accept(t);
-        }
-    },
-
-    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
-    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            LongStream s = m.apply(source);
-            Spliterator.OfLong sp = s.spliterator();
-            LongStream ss = StreamSupport.longStream(() -> sp,
-                                                     StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
-                                                     | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
-            for (long t : ss.toArray())
-                b.accept(t);
-        }
-    },
-
-    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            LongStream pipe2 = m.apply(pipe1);
-
-            for (long t : pipe2.toArray())
-                b.accept(t);
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing
-    PAR_STREAM_FOR_EACH(true, false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            m.apply(source).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
-    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
-        <T, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            m.apply(pipe1).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-    ;
-
-    // The set of scenarios that clean the SIZED flag
-    public static final Set<LongStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
-            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
-
-    private boolean isParallel;
-
-    private final boolean isOrdered;
-
-    LongStreamTestScenario(boolean isParallel) {
-        this(isParallel, true);
-    }
-
-    LongStreamTestScenario(boolean isParallel, boolean isOrdered) {
-        this.isParallel = isParallel;
-        this.isOrdered = isOrdered;
-    }
-
-    public StreamShape getShape() {
-        return StreamShape.LONG_VALUE;
-    }
-
-    public boolean isParallel() {
-        return isParallel;
-    }
-
-    public boolean isOrdered() {
-        return isOrdered;
-    }
-
-    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
-        try (S_IN source = getStream(data)) {
-            run(data, source, (LongConsumer) b, (Function<S_IN, LongStream>) m);
-        }
-    }
-
-    abstract <T, S_IN extends BaseStream<T, S_IN>>
-    void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m);
-
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/OpTestCase.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,682 +0,0 @@
-/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumMap;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.Spliterator;
-import java.util.function.BiConsumer;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
-import org.testng.annotations.Test;
-
-/**
- * Base class for streams test cases.  Provides 'exercise' methods for taking
- * lambdas that construct and modify streams, and evaluates them in different
- * ways and asserts that they produce equivalent results.
- */
-@Test
-public abstract class OpTestCase extends LoggingTestCase {
-
-    private final Map<StreamShape, Set<? extends BaseStreamTestScenario>> testScenarios;
-
-    protected OpTestCase() {
-        testScenarios = new EnumMap<>(StreamShape.class);
-        testScenarios.put(StreamShape.REFERENCE, Collections.unmodifiableSet(EnumSet.allOf(StreamTestScenario.class)));
-        testScenarios.put(StreamShape.INT_VALUE, Collections.unmodifiableSet(EnumSet.allOf(IntStreamTestScenario.class)));
-        testScenarios.put(StreamShape.LONG_VALUE, Collections.unmodifiableSet(EnumSet.allOf(LongStreamTestScenario.class)));
-        testScenarios.put(StreamShape.DOUBLE_VALUE, Collections.unmodifiableSet(EnumSet.allOf(DoubleStreamTestScenario.class)));
-    }
-
-    @SuppressWarnings("rawtypes")
-    public static int getStreamFlags(BaseStream s) {
-        return ((AbstractPipeline) s).getStreamFlags();
-    }
-
-    /**
-     * An asserter for results produced when exercising of stream or terminal
-     * tests.
-     *
-     * @param <R> the type of result to assert on
-     */
-    public interface ResultAsserter<R> {
-        /**
-         * Assert a result produced when exercising of stream or terminal
-         * test.
-         *
-         * @param actual the actual result
-         * @param expected the expected result
-         * @param isOrdered true if the pipeline is ordered
-         * @param isParallel true if the pipeline is parallel
-         */
-        void assertResult(R actual, R expected, boolean isOrdered, boolean isParallel);
-    }
-
-    // Exercise stream operations
-
-    public interface BaseStreamTestScenario {
-        StreamShape getShape();
-
-        boolean isParallel();
-
-        boolean isOrdered();
-
-        default <T, S_IN extends BaseStream<T, S_IN>>
-        S_IN getStream(TestData<T, S_IN> data) {
-            return isParallel()
-                   ? data.parallelStream()
-                   : data.stream();
-        }
-
-        <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-        void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m);
-    }
-
-    protected <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    Collection<U> exerciseOps(TestData<T, S_IN> data, Function<S_IN, S_OUT> m) {
-        return withData(data).stream(m).exercise();
-    }
-
-    // Run multiple versions of exercise(), returning the result of the first, and asserting that others return the same result
-    // If the first version is s -> s.foo(), can be used with s -> s.mapToInt(i -> i).foo().mapToObj(i -> i) to test all shape variants
-    @SafeVarargs
-    protected final<T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    Collection<U> exerciseOpsMulti(TestData<T, S_IN> data,
-                                   Function<S_IN, S_OUT>... ms) {
-        Collection<U> result = null;
-        for (Function<S_IN, S_OUT> m : ms) {
-            if (result == null)
-                result = withData(data).stream(m).exercise();
-            else {
-                Collection<U> r2 = withData(data).stream(m).exercise();
-                assertEquals(result, r2);
-            }
-        }
-        return result;
-    }
-
-    // Run multiple versions of exercise() for an Integer stream, returning the result of the first, and asserting that others return the same result
-    // Automates the conversion between Stream<Integer> and {Int,Long,Double}Stream and back, so client sites look like you are passing the same
-    // lambda four times, but in fact they are four different lambdas since they are transforming four different kinds of streams
-    protected final
-    Collection<Integer> exerciseOpsInt(TestData.OfRef<Integer> data,
-                                       Function<Stream<Integer>, Stream<Integer>> mRef,
-                                       Function<IntStream, IntStream> mInt,
-                                       Function<LongStream, LongStream> mLong,
-                                       Function<DoubleStream, DoubleStream> mDouble) {
-        @SuppressWarnings({ "rawtypes", "unchecked" })
-        Function<Stream<Integer>, Stream<Integer>>[] ms = new Function[4];
-        ms[0] = mRef;
-        ms[1] = s -> mInt.apply(s.mapToInt(e -> e)).mapToObj(e -> e);
-        ms[2] = s -> mLong.apply(s.mapToLong(e -> e)).mapToObj(e -> (int) e);
-        ms[3] = s -> mDouble.apply(s.mapToDouble(e -> e)).mapToObj(e -> (int) e);
-        return exerciseOpsMulti(data, ms);
-    }
-
-    // Run multiple versions of exercise() with multiple terminal operations for all kinds of stream, , and asserting against the expected result
-    // If the first version is s -> s.foo(), can be used with s -> s.mapToInt(i -> i).foo().mapToObj(i -> i) to test all shape variants
-    protected final<T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    void exerciseTerminalOpsMulti(TestData<T, S_IN> data,
-                                  R expected,
-                                  Map<String, Function<S_IN, S_OUT>> streams,
-                                  Map<String, Function<S_OUT, R>> terminals) {
-        for (Map.Entry<String, Function<S_IN, S_OUT>> se : streams.entrySet()) {
-            setContext("Intermediate stream", se.getKey());
-            for (Map.Entry<String, Function<S_OUT, R>> te : terminals.entrySet()) {
-                setContext("Terminal stream", te.getKey());
-                withData(data)
-                        .terminal(se.getValue(), te.getValue())
-                        .expectedResult(expected)
-                        .exercise();
-
-            }
-        }
-    }
-
-    // Run multiple versions of exercise() with multiple terminal operation for all kinds of stream, and asserting against the expected result
-    // Automates the conversion between Stream<Integer> and {Int,Long,Double}Stream and back, so client sites look like you are passing the same
-    // lambda four times, but in fact they are four different lambdas since they are transforming four different kinds of streams
-    protected final
-    void exerciseTerminalOpsInt(TestData<Integer, Stream<Integer>> data,
-                                Collection<Integer> expected,
-                                String desc,
-                                Function<Stream<Integer>, Stream<Integer>> mRef,
-                                Function<IntStream, IntStream> mInt,
-                                Function<LongStream, LongStream> mLong,
-                                Function<DoubleStream, DoubleStream> mDouble,
-                                Map<String, Function<Stream<Integer>, Collection<Integer>>> terminals) {
-
-        Map<String, Function<Stream<Integer>, Stream<Integer>>> m = new HashMap<>();
-        m.put("Ref " + desc, mRef);
-        m.put("Int " + desc, s -> mInt.apply(s.mapToInt(e -> e)).mapToObj(e -> e));
-        m.put("Long " + desc, s -> mLong.apply(s.mapToLong(e -> e)).mapToObj(e -> (int) e));
-        m.put("Double " + desc, s -> mDouble.apply(s.mapToDouble(e -> e)).mapToObj(e -> (int) e));
-
-        exerciseTerminalOpsMulti(data, expected, m, terminals);
-    }
-
-
-    protected <T, U, S_OUT extends BaseStream<U, S_OUT>>
-    Collection<U> exerciseOps(Collection<T> data, Function<Stream<T>, S_OUT> m) {
-        TestData.OfRef<T> data1 = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
-        return withData(data1).stream(m).exercise();
-    }
-
-    protected <T, U, S_OUT extends BaseStream<U, S_OUT>, I extends Iterable<U>>
-    Collection<U> exerciseOps(Collection<T> data, Function<Stream<T>, S_OUT> m, I expected) {
-        TestData.OfRef<T> data1 = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
-        return withData(data1).stream(m).expectedResult(expected).exercise();
-    }
-
-    @SuppressWarnings("unchecked")
-    protected <U, S_OUT extends BaseStream<U, S_OUT>>
-    Collection<U> exerciseOps(int[] data, Function<IntStream, S_OUT> m) {
-        return withData(TestData.Factory.ofArray("int array", data)).stream(m).exercise();
-    }
-
-    protected Collection<Integer> exerciseOps(int[] data, Function<IntStream, IntStream> m, int[] expected) {
-        TestData.OfInt data1 = TestData.Factory.ofArray("int array", data);
-        return withData(data1).stream(m).expectedResult(expected).exercise();
-    }
-
-    protected <T, S_IN extends BaseStream<T, S_IN>> DataStreamBuilder<T, S_IN> withData(TestData<T, S_IN> data) {
-        Objects.requireNonNull(data);
-        return new DataStreamBuilder<>(data);
-    }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public class DataStreamBuilder<T, S_IN extends BaseStream<T, S_IN>> {
-        final TestData<T, S_IN> data;
-
-        private DataStreamBuilder(TestData<T, S_IN> data) {
-            this.data = Objects.requireNonNull(data);
-        }
-
-        public <U, S_OUT extends BaseStream<U, S_OUT>>
-        ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> ops(IntermediateTestOp... ops) {
-            return new ExerciseDataStreamBuilder<>(data, (S_IN s) -> (S_OUT) chain(s, ops));
-        }
-
-        public <U, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT>
-        stream(Function<S_IN, S_OUT> m) {
-            return new ExerciseDataStreamBuilder<>(data, m);
-        }
-
-        public <U, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT>
-        stream(Function<S_IN, S_OUT> m, IntermediateTestOp<U, U> additionalOp) {
-            return new ExerciseDataStreamBuilder<>(data, s -> (S_OUT) chain(m.apply(s), additionalOp));
-        }
-
-        public <R> ExerciseDataTerminalBuilder<T, T, R, S_IN, S_IN>
-        terminal(Function<S_IN, R> terminalF) {
-            return new ExerciseDataTerminalBuilder<>(data, s -> s, terminalF);
-        }
-
-        public <U, R, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT>
-        terminal(Function<S_IN, S_OUT> streamF, Function<S_OUT, R> terminalF) {
-            return new ExerciseDataTerminalBuilder<>(data, streamF, terminalF);
-        }
-    }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public class ExerciseDataStreamBuilder<T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> {
-        final TestData<T, S_IN> data;
-        final Function<S_IN, S_OUT> m;
-        final StreamShape shape;
-
-        Set<BaseStreamTestScenario> testSet = new HashSet<>();
-
-        Collection<U> refResult;
-
-        Consumer<TestData<T, S_IN>> before = LambdaTestHelpers.bEmpty;
-
-        Consumer<TestData<T, S_IN>> after = LambdaTestHelpers.bEmpty;
-
-        ResultAsserter<Iterable<U>> resultAsserter = (act, exp, ord, par) -> {
-            if (par & !ord) {
-                LambdaTestHelpers.assertContentsUnordered(act, exp);
-            }
-            else {
-                LambdaTestHelpers.assertContentsEqual(act, exp);
-            }
-        };
-
-        private ExerciseDataStreamBuilder(TestData<T, S_IN> data, Function<S_IN, S_OUT> m) {
-            this.data = data;
-
-            this.m = Objects.requireNonNull(m);
-
-            this.shape = ((AbstractPipeline<?, U, ?>) m.apply(data.stream())).getOutputShape();
-
-            // Have to initiate from the output shape of the last stream
-            // This means the stream mapper is required first rather than last
-            testSet.addAll(testScenarios.get(shape));
-        }
-
-        //
-
-        public <I extends Iterable<U>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(I expectedResult) {
-            List<U> l = new ArrayList<>();
-            expectedResult.forEach(l::add);
-            refResult = l;
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(int[] expectedResult) {
-            List l = new ArrayList();
-            for (int anExpectedResult : expectedResult) {
-                l.add(anExpectedResult);
-            }
-            refResult = l;
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(long[] expectedResult) {
-            List l = new ArrayList();
-            for (long anExpectedResult : expectedResult) {
-                l.add(anExpectedResult);
-            }
-            refResult = l;
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(double[] expectedResult) {
-            List l = new ArrayList();
-            for (double anExpectedResult : expectedResult) {
-                l.add(anExpectedResult);
-            }
-            refResult = l;
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> before(Consumer<TestData<T, S_IN>> before) {
-            this.before = Objects.requireNonNull(before);
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> after(Consumer<TestData<T, S_IN>> after) {
-            this.after = Objects.requireNonNull(after);
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> without(BaseStreamTestScenario... tests) {
-            return without(Arrays.asList(tests));
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> without(Collection<? extends BaseStreamTestScenario> tests) {
-            for (BaseStreamTestScenario ts : tests) {
-                if (ts.getShape() == shape) {
-                    testSet.remove(ts);
-                }
-            }
-
-            if (testSet.isEmpty()) {
-                throw new IllegalStateException("Test scenario set is empty");
-            }
-
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> with(BaseStreamTestScenario... tests) {
-            return with(Arrays.asList(tests));
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> with(Collection<? extends BaseStreamTestScenario> tests) {
-            testSet = new HashSet<>();
-
-            for (BaseStreamTestScenario ts : tests) {
-                if (ts.getShape() == shape) {
-                    testSet.add(ts);
-                }
-            }
-
-            if (testSet.isEmpty()) {
-                throw new IllegalStateException("Test scenario set is empty");
-            }
-
-            return this;
-        }
-
-        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> resultAsserter(ResultAsserter<Iterable<U>> resultAsserter) {
-            this.resultAsserter = resultAsserter;
-            return this;
-        }
-
-        // Build method
-
-        public Collection<U> exercise() {
-            final boolean isStreamOrdered;
-            if (refResult == null) {
-                // Induce the reference result
-                before.accept(data);
-                try (S_OUT sOut = m.apply(data.stream())) {
-                    isStreamOrdered = StreamOpFlag.ORDERED.isKnown(((AbstractPipeline) sOut).getStreamFlags());
-                    Node<U> refNodeResult = ((AbstractPipeline<?, U, ?>) sOut).evaluateToArrayNode(size -> (U[]) new Object[size]);
-                    refResult = LambdaTestHelpers.toBoxedList(refNodeResult.spliterator());
-                }
-                after.accept(data);
-            }
-            else {
-                try (S_OUT sOut = m.apply(data.stream())) {
-                    isStreamOrdered = StreamOpFlag.ORDERED.isKnown(((AbstractPipeline) sOut).getStreamFlags());
-                }
-            }
-
-            List<Error> errors = new ArrayList<>();
-            for (BaseStreamTestScenario test : testSet) {
-                try {
-                    before.accept(data);
-
-                    List<U> result = new ArrayList<>();
-                    test.run(data, LambdaTestHelpers.<U>toBoxingConsumer(result::add), m);
-
-                    Runnable asserter = () -> resultAsserter.assertResult(result, refResult, isStreamOrdered && test.isOrdered(), test.isParallel());
-
-                    if (refResult.size() > 1000) {
-                        LambdaTestHelpers.launderAssertion(
-                                asserter,
-                                () -> String.format("%n%s: [actual size=%d] != [expected size=%d]", test, result.size(), refResult.size()));
-                    }
-                    else {
-                        LambdaTestHelpers.launderAssertion(
-                                asserter,
-                                () -> String.format("%n%s: [actual] %s != [expected] %s", test, result, refResult));
-                    }
-
-                    after.accept(data);
-                } catch (Throwable t) {
-                    errors.add(new Error(String.format("%s: %s", test, t), t));
-                }
-            }
-
-            if (!errors.isEmpty()) {
-                StringBuilder sb = new StringBuilder();
-                int i = 1;
-                for (Error t : errors) {
-                    sb.append(i++).append(": ");
-                    if (t instanceof AssertionError) {
-                        sb.append(t).append("\n");
-                    }
-                    else {
-                        StringWriter sw = new StringWriter();
-                        PrintWriter pw = new PrintWriter(sw);
-
-                        t.getCause().printStackTrace(pw);
-                        pw.flush();
-                        sb.append(t).append("\n").append(sw);
-                    }
-                }
-                sb.append("--");
-
-                fail(String.format("%d failure(s) for test data: %s\n%s", i - 1, data.toString(), sb));
-            }
-
-            return refResult;
-        }
-    }
-
-    // Exercise terminal operations
-
-    interface BaseTerminalTestScenario<U, R, S_OUT extends BaseStream<U, S_OUT>> {
-        boolean requiresSingleStageSource();
-
-        boolean requiresParallelSource();
-
-        default R run(Function<S_OUT, R> terminalF, S_OUT source, StreamShape shape) {
-            return terminalF.apply(source);
-        }
-    }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    enum TerminalTestScenario implements BaseTerminalTestScenario {
-        SINGLE_SEQUENTIAL(true, false),
-
-        SINGLE_SEQUENTIAL_SHORT_CIRCUIT(true, false) {
-            @Override
-            public Object run(Function terminalF, BaseStream source, StreamShape shape) {
-                source = (BaseStream) chain(source, new ShortCircuitOp(shape));
-                return terminalF.apply(source);
-            }
-        },
-
-        SINGLE_PARALLEL(true, true),
-
-        ALL_SEQUENTIAL(false, false),
-
-        ALL_SEQUENTIAL_SHORT_CIRCUIT(false, false) {
-            @Override
-            public Object run(Function terminalF, BaseStream source, StreamShape shape) {
-                source = (BaseStream) chain(source, new ShortCircuitOp(shape));
-                return terminalF.apply(source);
-            }
-        },
-
-        ALL_PARALLEL(false, true),
-
-        ALL_PARALLEL_SEQUENTIAL(false, false) {
-            @Override
-            public Object run(Function terminalF, BaseStream source, StreamShape shape) {
-                return terminalF.apply(source.sequential());
-            }
-        },
-        ;
-
-        private final boolean requiresSingleStageSource;
-        private final boolean isParallel;
-
-        TerminalTestScenario(boolean requiresSingleStageSource, boolean isParallel) {
-            this.requiresSingleStageSource = requiresSingleStageSource;
-            this.isParallel = isParallel;
-        }
-
-        @Override
-        public boolean requiresSingleStageSource() {
-            return requiresSingleStageSource;
-        }
-
-        @Override
-        public boolean requiresParallelSource() {
-            return isParallel;
-        }
-
-    }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public class ExerciseDataTerminalBuilder<T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> {
-        final TestData<T, S_IN> data;
-        final Function<S_IN, S_OUT> streamF;
-        final Function<S_OUT, R> terminalF;
-
-        R refResult;
-
-        ResultAsserter<R> resultAsserter = (act, exp, ord, par) -> LambdaTestHelpers.assertContentsEqual(act, exp);
-
-        private ExerciseDataTerminalBuilder(TestData<T, S_IN> data, Function<S_IN, S_OUT> streamF, Function<S_OUT, R> terminalF) {
-            this.data = data;
-            this.streamF = Objects.requireNonNull(streamF);
-            this.terminalF = Objects.requireNonNull(terminalF);
-        }
-
-        //
-
-        public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> expectedResult(R expectedResult) {
-            this.refResult = expectedResult;
-            return this;
-        }
-
-        public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> equalator(BiConsumer<R, R> equalityAsserter) {
-            resultAsserter = (act, exp, ord, par) -> equalityAsserter.accept(act, exp);
-            return this;
-        }
-
-        public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> resultAsserter(ResultAsserter<R> resultAsserter) {
-            this.resultAsserter = resultAsserter;
-            return this;
-        }
-
-        // Build method
-
-        public R exercise() {
-            boolean isOrdered;
-            StreamShape shape;
-            Node<U> node;
-            try (S_OUT out = streamF.apply(data.stream()).sequential()) {
-                AbstractPipeline ap = (AbstractPipeline) out;
-                isOrdered = StreamOpFlag.ORDERED.isKnown(ap.getStreamFlags());
-                shape = ap.getOutputShape();
-                // Sequentially collect the output that will be input to the terminal op
-                node = ap.evaluateToArrayNode(size -> (U[]) new Object[size]);
-            }
-
-            EnumSet<TerminalTestScenario> tests = EnumSet.allOf(TerminalTestScenario.class);
-            if (refResult == null) {
-                // Induce the reference result
-                S_OUT source = (S_OUT) createPipeline(shape, node.spliterator(),
-                                                      StreamOpFlag.IS_ORDERED | StreamOpFlag.IS_SIZED,
-                                                      false);
-
-                refResult = (R) TerminalTestScenario.SINGLE_SEQUENTIAL.run(terminalF, source, shape);
-                tests.remove(TerminalTestScenario.SINGLE_SEQUENTIAL);
-            }
-
-            for (BaseTerminalTestScenario test : tests) {
-                S_OUT source;
-                if (test.requiresSingleStageSource()) {
-                    source = (S_OUT) createPipeline(shape, node.spliterator(),
-                                                    StreamOpFlag.IS_ORDERED | StreamOpFlag.IS_SIZED,
-                                                    test.requiresParallelSource());
-                }
-                else {
-                    source = streamF.apply(test.requiresParallelSource()
-                                           ? data.parallelStream() : data.stream());
-                }
-
-                R result;
-                try (source) {
-                    result = (R) test.run(terminalF, source, shape);
-                }
-                LambdaTestHelpers.launderAssertion(
-                        () -> resultAsserter.assertResult(result, refResult, isOrdered, test.requiresParallelSource()),
-                        () -> String.format("%s: %s != %s", test, refResult, result));
-            }
-
-            return refResult;
-        }
-
-        AbstractPipeline createPipeline(StreamShape shape, Spliterator s, int flags, boolean parallel) {
-            switch (shape) {
-                case REFERENCE:    return new ReferencePipeline.Head<>(s, flags, parallel);
-                case INT_VALUE:    return new IntPipeline.Head(s, flags, parallel);
-                case LONG_VALUE:   return new LongPipeline.Head(s, flags, parallel);
-                case DOUBLE_VALUE: return new DoublePipeline.Head(s, flags, parallel);
-                default: throw new IllegalStateException("Unknown shape: " + shape);
-            }
-        }
-    }
-
-    protected <T, R> R exerciseTerminalOps(Collection<T> data, Function<Stream<T>, R> m, R expected) {
-        TestData.OfRef<T> data1
-                = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
-        return withData(data1).terminal(m).expectedResult(expected).exercise();
-    }
-
-    protected <T, R, S_IN extends BaseStream<T, S_IN>> R
-    exerciseTerminalOps(TestData<T, S_IN> data,
-                        Function<S_IN, R> terminalF) {
-        return withData(data).terminal(terminalF).exercise();
-    }
-
-    protected <T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> R
-    exerciseTerminalOps(TestData<T, S_IN> data,
-                        Function<S_IN, S_OUT> streamF,
-                        Function<S_OUT, R> terminalF) {
-        return withData(data).terminal(streamF, terminalF).exercise();
-    }
-
-    //
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    private static <T> AbstractPipeline<?, T, ?> chain(AbstractPipeline upstream, IntermediateTestOp<?, T> op) {
-        return (AbstractPipeline<?, T, ?>) IntermediateTestOp.chain(upstream, op);
-    }
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    private static AbstractPipeline<?, ?, ?> chain(AbstractPipeline pipe, IntermediateTestOp... ops) {
-        for (IntermediateTestOp op : ops)
-            pipe = chain(pipe, op);
-        return pipe;
-    }
-
-    @SuppressWarnings("rawtypes")
-    private static <T> AbstractPipeline<?, T, ?> chain(BaseStream pipe, IntermediateTestOp<?, T> op) {
-        return chain((AbstractPipeline) pipe, op);
-    }
-
-    @SuppressWarnings("rawtypes")
-    public static AbstractPipeline<?, ?, ?> chain(BaseStream pipe, IntermediateTestOp... ops) {
-        return chain((AbstractPipeline) pipe, ops);
-    }
-
-    // Test data
-
-    static class ShortCircuitOp<T> implements StatelessTestOp<T,T> {
-        private final StreamShape shape;
-
-        ShortCircuitOp(StreamShape shape) {
-            this.shape = shape;
-        }
-
-        @Override
-        public Sink<T> opWrapSink(int flags, boolean parallel, Sink<T> sink) {
-            return sink;
-        }
-
-        @Override
-        public int opGetFlags() {
-            return StreamOpFlag.IS_SHORT_CIRCUIT;
-        }
-
-        @Override
-        public StreamShape outputShape() {
-            return shape;
-        }
-
-        @Override
-        public StreamShape inputShape() {
-            return shape;
-        }
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StatefulTestOp.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.Spliterator;
-import java.util.function.IntFunction;
-
-/**
- * The base type for a stateful test operation.
- */
-interface StatefulTestOp<E> extends IntermediateTestOp<E, E> {
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public static<T> AbstractPipeline chain(AbstractPipeline upstream,
-                                            StatefulTestOp op) {
-        switch (op.outputShape()) {
-            case REFERENCE:
-                return new ReferencePipeline.StatefulOp<Object, T>(upstream, op.inputShape(), op.opGetFlags()) {
-                    @Override
-                    Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-
-                    @Override
-                    <P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper,
-                                                                 Spliterator<P_IN> spliterator) {
-                        return op.opEvaluateParallelLazy(helper, spliterator);
-                    }
-
-                    @Override
-                    <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
-                                                      Spliterator<P_IN> spliterator,
-                                                      IntFunction<T[]> generator) {
-                        return op.opEvaluateParallel(helper, spliterator, generator);
-                    }
-                };
-            case INT_VALUE:
-                return new IntPipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
-                    @Override
-                    Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-
-                    @Override
-                    <P_IN> Spliterator<Integer> opEvaluateParallelLazy(PipelineHelper<Integer> helper,
-                                                                 Spliterator<P_IN> spliterator) {
-                        return op.opEvaluateParallelLazy(helper, spliterator);
-                    }
-
-                    @Override
-                    <P_IN> Node<Integer> opEvaluateParallel(PipelineHelper<Integer> helper,
-                                                            Spliterator<P_IN> spliterator,
-                                                            IntFunction<Integer[]> generator) {
-                        return (Node<Integer>) op.opEvaluateParallel(helper, spliterator, generator);
-                    }
-                };
-            case LONG_VALUE:
-                return new LongPipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
-                    @Override
-                    Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-
-                    @Override
-                    <P_IN> Spliterator<Long> opEvaluateParallelLazy(PipelineHelper<Long> helper,
-                                                                 Spliterator<P_IN> spliterator) {
-                        return op.opEvaluateParallelLazy(helper, spliterator);
-                    }
-
-                    @Override
-                    <P_IN> Node<Long> opEvaluateParallel(PipelineHelper<Long> helper,
-                                                         Spliterator<P_IN> spliterator,
-                                                         IntFunction<Long[]> generator) {
-                        return (Node<Long>) op.opEvaluateParallel(helper, spliterator, generator);
-                    }
-                };
-            case DOUBLE_VALUE:
-                return new DoublePipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
-                    @Override
-                    Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-
-                    @Override
-                    <P_IN> Spliterator<Double> opEvaluateParallelLazy(PipelineHelper<Double> helper,
-                                                                    Spliterator<P_IN> spliterator) {
-                        return op.opEvaluateParallelLazy(helper, spliterator);
-                    }
-
-                    @Override
-                    <P_IN> Node<Double> opEvaluateParallel(PipelineHelper<Double> helper,
-                                                           Spliterator<P_IN> spliterator,
-                                                           IntFunction<Double[]> generator) {
-                        return (Node<Double>) op.opEvaluateParallel(helper, spliterator, generator);
-                    }
-                };
-            default: throw new IllegalStateException(op.outputShape().toString());
-        }
-    }
-
-    default StreamShape inputShape() { return StreamShape.REFERENCE; }
-
-    default StreamShape outputShape() { return StreamShape.REFERENCE; }
-
-    default int opGetFlags() { return 0; }
-
-    Sink<E> opWrapSink(int flags, boolean parallel, Sink<E> sink);
-
-    @SuppressWarnings("unchecked")
-    default <P_IN> Spliterator<E> opEvaluateParallelLazy(PipelineHelper<E> helper,
-                                                         Spliterator<P_IN> spliterator) {
-        return opEvaluateParallel(helper, spliterator, i -> (E[]) new Object[i]).spliterator();
-    }
-
-    <P_IN> Node<E> opEvaluateParallel(PipelineHelper<E> helper,
-                                      Spliterator<P_IN> spliterator,
-                                      IntFunction<E[]> generator);
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StatelessTestOp.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-/**
- * The base type of a stateless test operation
- */
-interface StatelessTestOp<E_IN, E_OUT> extends IntermediateTestOp<E_IN, E_OUT> {
-
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public static<T> AbstractPipeline chain(AbstractPipeline upstream,
-                                            StatelessTestOp<?, T> op) {
-        int flags = op.opGetFlags();
-        switch (op.outputShape()) {
-            case REFERENCE:
-                return new ReferencePipeline.StatelessOp<Object, T>(upstream, op.inputShape(), flags) {
-                    public Sink opWrapSink(int flags, Sink<T> sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-                };
-            case INT_VALUE:
-                return new IntPipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
-                    public Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-                };
-            case LONG_VALUE:
-                return new LongPipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
-                    @Override
-                    Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-                };
-            case DOUBLE_VALUE:
-                return new DoublePipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
-                    @Override
-                    Sink opWrapSink(int flags, Sink sink) {
-                        return op.opWrapSink(flags, isParallel(), sink);
-                    }
-                };
-            default: throw new IllegalStateException(op.outputShape().toString());
-        }
-    }
-
-    default StreamShape inputShape() { return StreamShape.REFERENCE; }
-
-    default StreamShape outputShape() { return StreamShape.REFERENCE; }
-
-    default int opGetFlags() { return 0; }
-
-    Sink<E_IN> opWrapSink(int flags, boolean parallel, Sink<E_OUT> sink);
-}
-
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamOpFlagTestHelper.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.EnumSet;
-
-public class StreamOpFlagTestHelper {
-
-    /** EnumSet containing stream flags */
-    private static final EnumSet<StreamOpFlag> allStreamFlags;
-
-    static {
-        allStreamFlags = EnumSet.allOf(StreamOpFlag.class);
-        for (StreamOpFlag f : EnumSet.allOf(StreamOpFlag.class))
-            if (!f.isStreamFlag())
-                allStreamFlags.remove(f);
-    }
-
-
-    static EnumSet<StreamOpFlag> allStreamFlags() {
-        // EnumSet is mutable
-        return allStreamFlags.clone();
-    }
-
-    public static boolean isStreamOrdered(Stream<?> s) {
-        return StreamOpFlag.ORDERED.isKnown(OpTestCase.getStreamFlags(s));
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamTestDataProvider.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,228 +0,0 @@
-/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import org.testng.annotations.DataProvider;
-
-import java.util.*;
-import java.util.Spliterators;
-import java.util.function.Supplier;
-
-/**
- * StreamTestDataProvider
- *
- * @author Brian Goetz
- */
-/** TestNG DataProvider for ref-valued streams */
-public class StreamTestDataProvider {
-    private static final Integer[] to0 = new Integer[0];
-    private static final Integer[] to1 = new Integer[1];
-    private static final Integer[] to10 = new Integer[10];
-    private static final Integer[] to100 = new Integer[100];
-    private static final Integer[] to1000 = new Integer[1000];
-    private static final Integer[] reversed = new Integer[100];
-    private static final Integer[] ones = new Integer[100];
-    private static final Integer[] twice = new Integer[200];
-    private static final Integer[] pseudoRandom;
-
-    private static final Object[][] testData;
-    private static final Object[][] testSmallData;
-    private static final Object[][] testMiniData;
-    private static final Object[][] withNullTestData;
-    private static final Object[][] spliteratorTestData;
-
-    static {
-        Integer[][] arrays = {to0, to1, to10, to100, to1000};
-        for (Integer[] arr : arrays) {
-            for (int i = 0; i < arr.length; i++) {
-                arr[i] = i;
-            }
-        }
-        for (int i = 0; i < reversed.length; i++) {
-            reversed[i] = reversed.length - i;
-        }
-        for (int i = 0; i < ones.length; i++) {
-            ones[i] = 1;
-        }
-        System.arraycopy(to100, 0, twice, 0, to100.length);
-        System.arraycopy(to100, 0, twice, to100.length, to100.length);
-        pseudoRandom = new Integer[LambdaTestHelpers.LONG_STRING.length()];
-        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
-            pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
-        }
-    }
-
-    static final Object[][] arrays = {
-            {"empty", to0},
-            {"0..1", to1},
-            {"0..10", to10},
-            {"0..100", to100},
-            {"0..1000", to1000},
-            {"100x[1]", ones},
-            {"2x[0..100]", twice},
-            {"reverse 0..100", reversed},
-            {"pseudorandom", pseudoRandom}
-    };
-
-    static {
-        {
-            List<Object[]> listMini = new ArrayList<>();
-            List<Object[]> listSmall = new ArrayList<>();
-            List<Object[]> list1000 = new ArrayList<>();
-            List<Object[]> list = null;
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final Integer[] ints = (Integer[])data[1];
-                final List<Integer> intsAsList = Arrays.asList(ints);
-
-                list = ints.length >= 1000 ? list1000 : (ints.length >= 100 ? listSmall : listMini);
-
-                list.add(arrayDataDescr("array:" + name, ints));
-                list.add(collectionDataDescr("ArrayList.asList:" + name, intsAsList));
-                list.add(collectionDataDescr("ArrayList:" + name, new ArrayList<>(intsAsList)));
-                list.add(streamDataDescr("DelegatingStream(ArrayList):" + name,
-                                         () -> new ArrayList<>(intsAsList).stream()));
-                List<Integer> aList = new ArrayList<>(intsAsList);
-                if (LambdaTestMode.isNormalMode()) {
-                    // Only include sub-lists for normal test execution mode
-                    // This data is serialization-hostile since the state of the
-                    // deserialized sub-list will be out of sync with the
-                    // enclosing list.
-                    list.add(collectionDataDescr("ArrayList.Sublist:" + name,
-                                                 (ints.length) <= 1 ? aList.subList(0, 0) : aList.subList(1, ints.length / 2)));
-                }
-                list.add(collectionDataDescr("LinkedList:" + name, new LinkedList<>(intsAsList)));
-                list.add(collectionDataDescr("HashSet:" + name, new HashSet<>(intsAsList)));
-                list.add(collectionDataDescr("LinkedHashSet:" + name, new LinkedHashSet<>(intsAsList)));
-                list.add(collectionDataDescr("TreeSet:" + name, new TreeSet<>(intsAsList)));
-                SpinedBuffer<Integer> spinedBuffer = new SpinedBuffer<>();
-                intsAsList.forEach(spinedBuffer);
-                list.add(sbDataDescr("SpinedBuffer:" + name, spinedBuffer));
-
-                // @@@ Add more
-            }
-            testMiniData = listMini.toArray(new Object[0][]);
-            listSmall.addAll(listMini);
-            testSmallData = listSmall.toArray(new Object[0][]);
-            list1000.addAll(listSmall);
-            testData = list1000.toArray(new Object[0][]);
-        }
-
-        // Simple combination of numbers and null values, probably excessive but may catch
-        // errors for initialization/termination/sequence
-        // @@@ This is separate from the other data for now until nulls are consistently supported by
-        // all operations
-        {
-            List<Object[]> list = new ArrayList<>();
-            int size = 5;
-            for (int i = 0; i < (1 << size) - 2; i++) {
-                Integer[] content = new Integer[size];
-                for (int e = 0; e < size; e++) {
-                    content[e] = (i & (1 << e)) > 0 ? e + 1 : null;
-                }
-
-                // ORDERED
-                list.add(arrayDataDescr("array:" + i, content));
-                // not ORDERED, DISTINCT
-                list.add(collectionDataDescr("HashSet:" + i, new HashSet<>(Arrays.asList(content))));
-            }
-
-            withNullTestData = list.toArray(new Object[0][]);
-        }
-
-        {
-            List<Object[]> spliterators = new ArrayList<>();
-            for (Object[] data : arrays) {
-                final Object name = data[0];
-                final Integer[] ints = (Integer[])data[1];
-
-                spliterators.add(splitDescr("Arrays.s(array):" + name,
-                                            () -> Arrays.spliterator(ints)));
-                spliterators.add(splitDescr("arrays.s(array,o,l):" + name,
-                                            () -> Arrays.spliterator(ints, 0, ints.length/2)));
-                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
-                                            () -> {
-                                                SpinedBuffer<Integer> sb = new SpinedBuffer<>();
-                                                for (Integer i : ints)
-                                                    sb.accept(i);
-                                                return sb.spliterator();
-                                            }));
-                spliterators.add(splitDescr("Iterators.s(Arrays.s(array).iterator(), size):" + name,
-                                            () -> Spliterators.spliterator(Arrays.asList(ints).iterator(), ints.length, 0)));
-                spliterators.add(splitDescr("Iterators.s(Arrays.s(array).iterator()):" + name,
-                                            () -> Spliterators.spliteratorUnknownSize(Arrays.asList(ints).iterator(), 0)));
-                spliterators.add(splitDescr("Stream.iterate(0,x->x<l,x->x+1): " + name,
-                                            () -> Stream.iterate(0, x -> x < ints.length, x -> x + 1).spliterator()));
-                // @@@ Add map and collection spliterators when spliterator() is exposed on Collection or Iterable
-            }
-            spliteratorTestData = spliterators.toArray(new Object[0][]);
-        }
-    }
-
-    static <T> Object[] arrayDataDescr(String description, T[] data) {
-        return new Object[] { description, TestData.Factory.ofArray(description, data)};
-    }
-
-    static <T> Object[] streamDataDescr(String description, Supplier<Stream<T>> supplier) {
-        return new Object[] { description, TestData.Factory.ofSupplier(description, supplier)};
-    }
-
-    static <T> Object[] collectionDataDescr(String description, Collection<T> data) {
-        return new Object[] { description, TestData.Factory.ofCollection(description, data)};
-    }
-
-    static <T> Object[] sbDataDescr(String description, SpinedBuffer<T> data) {
-        return new Object[] { description, TestData.Factory.ofSpinedBuffer(description, data)};
-    }
-
-    static <T> Object[] splitDescr(String description, Supplier<Spliterator<T>> ss) {
-        return new Object[] { description, ss };
-    }
-
-    // Return an array of ( String name, StreamTestData<Integer> )
-    @DataProvider(name = "StreamTestData<Integer>")
-    public static Object[][] makeStreamTestData() {
-        return testData;
-    }
-
-    @DataProvider(name = "StreamTestData<Integer>.small")
-    public static Object[][] makeSmallStreamTestData() {
-        return testSmallData;
-    }
-
-    @DataProvider(name = "StreamTestData<Integer>.mini")
-    public static Object[][] makeMiniStreamTestData() {
-        return testMiniData;
-    }
-
-    @DataProvider(name = "withNull:StreamTestData<Integer>")
-    public static Object[][] makeStreamWithNullTestData() {
-        return withNullTestData;
-    }
-
-    // returns an array of (String name, Supplier<Spliterator<Integer>>)
-    @DataProvider(name = "Spliterator<Integer>")
-    public static Object[][] spliteratorProvider() {
-        return spliteratorTestData;
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/StreamTestScenario.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,279 +0,0 @@
-/*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.Spliterator;
-import java.util.SpliteratorTestHelper;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
-/**
- * Test scenarios for reference streams.
- *
- * Each scenario is provided with a data source, a function that maps a fresh
- * stream (as provided by the data source) to a new stream, and a sink to
- * receive results.  Each scenario describes a different way of computing the
- * stream contents.  The test driver will ensure that all scenarios produce
- * the same output (modulo allowable differences in ordering).
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public enum StreamTestScenario implements OpTestCase.BaseStreamTestScenario {
-
-    STREAM_FOR_EACH(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            Stream<U> s = m.apply(source);
-            if (s.isParallel()) {
-                s = s.sequential();
-            }
-            s.forEach(b);
-        }
-    },
-
-    // Collec to list
-    STREAM_COLLECT(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (U t : m.apply(source).collect(Collectors.toList())) {
-                b.accept(t);
-            }
-        }
-    },
-
-    // To array
-    STREAM_TO_ARRAY(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (Object t : m.apply(source).toArray()) {
-                b.accept((U) t);
-            }
-        }
-    },
-
-    // Wrap as stream, and iterate in pull mode
-    STREAM_ITERATOR(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (Iterator<U> seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
-                b.accept(seqIter.next());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (Spliterator<U> spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
-    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate in pull mode
-    STREAM_SPLITERATOR_FOREACH(false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    // Wrap as parallel stream + sequential
-    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            m.apply(source).sequential().forEach(b);
-        }
-    },
-
-    // Wrap as parallel stream + forEachOrdered
-    PAR_STREAM_FOR_EACH_ORDERED(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            // @@@ Want to explicitly select ordered equalator
-            m.apply(source).forEachOrdered(b);
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (Spliterator<U> spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
-            }
-        }
-    },
-
-    // Wrap as stream, and spliterate then iterate sequentially
-    PAR_STREAM_SPLITERATOR_FOREACH(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            m.apply(source).spliterator().forEachRemaining(b);
-        }
-    },
-
-    // Wrap as parallel stream + toArray
-    PAR_STREAM_TO_ARRAY(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (Object t : m.apply(source).toArray())
-                b.accept((U) t);
-        }
-    },
-
-    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
-    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            Stream<U> s = m.apply(source);
-            Spliterator<U> sp = s.spliterator();
-            Stream<U> ss = StreamSupport.stream(() -> sp,
-                                                StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
-                                                | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
-            for (Object t : ss.toArray())
-                b.accept((U) t);
-        }
-    },
-
-    // Wrap as parallel stream + toArray and clear SIZED flag
-    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            Stream<U> pipe2 = m.apply(pipe1);
-
-            for (Object t : pipe2.toArray())
-                b.accept((U) t);
-        }
-    },
-
-    // Wrap as parallel + collect to list
-    PAR_STREAM_COLLECT_TO_LIST(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (U u : m.apply(source).collect(Collectors.toList()))
-                b.accept(u);
-        }
-    },
-
-    // Wrap sequential as parallel, + collect to list
-    STREAM_TO_PAR_STREAM_COLLECT_TO_LIST(true) {
-        public <T, S_IN extends BaseStream<T, S_IN>>
-        S_IN getStream(TestData<T, S_IN> data) {
-            return data.stream().parallel();
-        }
-
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (U u : m.apply(source).collect(Collectors.toList()))
-                b.accept(u);
-        }
-    },
-
-    // Wrap parallel as sequential,, + collect
-    PAR_STREAM_TO_STREAM_COLLECT_TO_LIST(true) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            for (U u : m.apply(source).collect(Collectors.toList()))
-                b.accept(u);
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing
-    PAR_STREAM_FOR_EACH(true, false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            m.apply(source).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-
-    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
-    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
-        <T, U, S_IN extends BaseStream<T, S_IN>>
-        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
-            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
-                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
-            m.apply(pipe1).forEach(e -> {
-                synchronized (data) {
-                    b.accept(e);
-                }
-            });
-        }
-    },
-    ;
-
-    // The set of scenarios that clean the SIZED flag
-    public static final Set<StreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
-            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
-
-    private final boolean isParallel;
-
-    private final boolean isOrdered;
-
-    StreamTestScenario(boolean isParallel) {
-        this(isParallel, true);
-    }
-
-    StreamTestScenario(boolean isParallel, boolean isOrdered) {
-        this.isParallel = isParallel;
-        this.isOrdered = isOrdered;
-    }
-
-    public StreamShape getShape() {
-        return StreamShape.REFERENCE;
-    }
-
-    public boolean isParallel() {
-        return isParallel;
-    }
-
-    public boolean isOrdered() {
-        return isOrdered;
-    }
-
-    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
-    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
-        try (S_IN source = getStream(data)) {
-            run(data, source, b, (Function<S_IN, Stream<U>>) m);
-        }
-    }
-
-    abstract <T, U, S_IN extends BaseStream<T, S_IN>>
-    void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m);
-
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/TestData.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,355 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.PrimitiveIterator;
-import java.util.Spliterator;
-import java.util.Spliterators;
-import java.util.function.DoubleConsumer;
-import java.util.function.Function;
-import java.util.function.IntConsumer;
-import java.util.function.LongConsumer;
-import java.util.function.Supplier;
-import java.util.function.ToIntFunction;
-
-/** Describes a test data set for use in stream tests */
-public interface TestData<T, S extends BaseStream<T, S>>
-        extends Iterable<T> {
-
-    default int size() {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    default Iterator<T> iterator() {
-        return Spliterators.iterator(spliterator());
-    }
-
-    Spliterator<T> spliterator();
-
-    default boolean isOrdered() {
-        return spliterator().hasCharacteristics(Spliterator.ORDERED);
-    }
-
-    StreamShape getShape();
-
-    default <A extends Collection<? super T>> A into(A target) {
-        spliterator().forEachRemaining(target::add);
-        return target;
-    }
-
-    S stream();
-
-    S parallelStream();
-
-    public interface OfRef<T> extends TestData<T, Stream<T>> { }
-
-    public interface OfInt extends TestData<Integer, IntStream> { }
-
-    public interface OfLong extends TestData<Long, LongStream> { }
-
-    public interface OfDouble extends TestData<Double, DoubleStream> { }
-
-    // @@@ Temporary garbage class to avoid triggering bugs with lambdas in static methods in interfaces
-    public static class Factory {
-        public static <T> OfRef<T> ofArray(String name, T[] array) {
-            return new AbstractTestData.RefTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
-                                                      Arrays::spliterator, a -> a.length);
-        }
-
-        public static <T> OfRef<T> ofCollection(String name, Collection<T> collection) {
-            return new AbstractTestData.RefTestData<>(name, collection, Collection::stream, Collection::parallelStream,
-                                                      Collection::spliterator, Collection::size);
-        }
-
-        public static <T> OfRef<T> ofSpinedBuffer(String name, SpinedBuffer<T> buffer) {
-            return new AbstractTestData.RefTestData<>(name, buffer,
-                                                      b -> StreamSupport.stream(b.spliterator(), false),
-                                                      b -> StreamSupport.stream(b.spliterator(), true),
-                                                      SpinedBuffer::spliterator,
-                                                      b -> (int) b.count());
-        }
-
-        public static <T> OfRef<T> ofSupplier(String name, Supplier<Stream<T>> supplier) {
-            return new AbstractTestData.RefTestData<>(name, supplier,
-                                                      Supplier::get,
-                                                      s -> s.get().parallel(),
-                                                      s -> s.get().spliterator(),
-                                                      s -> (int) s.get().spliterator().getExactSizeIfKnown());
-        }
-
-        public static <T> OfRef<T> ofRefNode(String name, Node<T> node) {
-            return new AbstractTestData.RefTestData<>(name, node,
-                                                      n -> StreamSupport.stream(n::spliterator, Spliterator.SIZED | Spliterator.ORDERED, false),
-                                                      n -> StreamSupport.stream(n::spliterator, Spliterator.SIZED | Spliterator.ORDERED, true),
-                                                      Node::spliterator,
-                                                      n -> (int) n.count());
-        }
-
-        // int factories
-        public static <T> OfInt ofArray(String name, int[] array) {
-            return new AbstractTestData.IntTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
-                                                      Arrays::spliterator, a -> a.length);
-        }
-
-        public static OfInt ofSpinedBuffer(String name, SpinedBuffer.OfInt buffer) {
-            return new AbstractTestData.IntTestData<>(name, buffer,
-                                                      b -> StreamSupport.intStream(b.spliterator(), false),
-                                                      b -> StreamSupport.intStream(b.spliterator(), true),
-                                                      SpinedBuffer.OfInt::spliterator,
-                                                      b -> (int) b.count());
-        }
-
-        public static OfInt ofIntSupplier(String name, Supplier<IntStream> supplier) {
-            return new AbstractTestData.IntTestData<>(name, supplier,
-                                                      Supplier::get,
-                                                      s -> s.get().parallel(),
-                                                      s -> s.get().spliterator(),
-                                                      s -> (int) s.get().spliterator().getExactSizeIfKnown());
-        }
-
-        public static OfInt ofNode(String name, Node.OfInt node) {
-            int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
-            return new AbstractTestData.IntTestData<>(name, node,
-                                                      n -> StreamSupport.intStream(n::spliterator, characteristics, false),
-                                                      n -> StreamSupport.intStream(n::spliterator, characteristics, true),
-                                                      Node.OfInt::spliterator,
-                                                      n -> (int) n.count());
-        }
-
-        // long factories
-        public static <T> OfLong ofArray(String name, long[] array) {
-            return new AbstractTestData.LongTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
-                                                       Arrays::spliterator, a -> a.length);
-        }
-
-        public static OfLong ofSpinedBuffer(String name, SpinedBuffer.OfLong buffer) {
-            return new AbstractTestData.LongTestData<>(name, buffer,
-                                                      b -> StreamSupport.longStream(b.spliterator(), false),
-                                                      b -> StreamSupport.longStream(b.spliterator(), true),
-                                                      SpinedBuffer.OfLong::spliterator,
-                                                      b -> (int) b.count());
-        }
-
-        public static OfLong ofLongSupplier(String name, Supplier<LongStream> supplier) {
-            return new AbstractTestData.LongTestData<>(name, supplier,
-                                                      Supplier::get,
-                                                      s -> s.get().parallel(),
-                                                      s -> s.get().spliterator(),
-                                                      s -> (int) s.get().spliterator().getExactSizeIfKnown());
-        }
-
-        public static OfLong ofNode(String name, Node.OfLong node) {
-            int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
-            return new AbstractTestData.LongTestData<>(name, node,
-                                                      n -> StreamSupport.longStream(n::spliterator, characteristics, false),
-                                                      n -> StreamSupport.longStream(n::spliterator, characteristics, true),
-                                                      Node.OfLong::spliterator,
-                                                      n -> (int) n.count());
-        }
-
-        // double factories
-        public static <T> OfDouble ofArray(String name, double[] array) {
-            return new AbstractTestData.DoubleTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
-                                                         Arrays::spliterator, a -> a.length);
-        }
-
-        public static OfDouble ofSpinedBuffer(String name, SpinedBuffer.OfDouble buffer) {
-            return new AbstractTestData.DoubleTestData<>(name, buffer,
-                                                         b -> StreamSupport.doubleStream(b.spliterator(), false),
-                                                         b -> StreamSupport.doubleStream(b.spliterator(), true),
-                                                         SpinedBuffer.OfDouble::spliterator,
-                                                         b -> (int) b.count());
-        }
-
-        public static OfDouble ofDoubleSupplier(String name, Supplier<DoubleStream> supplier) {
-            return new AbstractTestData.DoubleTestData<>(name, supplier,
-                                                         Supplier::get,
-                                                         s -> s.get().parallel(),
-                                                         s -> s.get().spliterator(),
-                                                         s -> (int) s.get().spliterator().getExactSizeIfKnown());
-        }
-
-        public static OfDouble ofNode(String name, Node.OfDouble node) {
-            int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
-            return new AbstractTestData.DoubleTestData<>(name, node,
-                                                         n -> StreamSupport.doubleStream(n::spliterator, characteristics, false),
-                                                         n -> StreamSupport.doubleStream(n::spliterator, characteristics, true),
-                                                         Node.OfDouble::spliterator,
-                                                         n -> (int) n.count());
-        }
-    }
-
-
-    abstract class AbstractTestData<T, S extends BaseStream<T, S>,
-            T_STATE,
-                                    T_SPLITR extends Spliterator<T>>
-            implements TestData<T, S> {
-        private final String name;
-        private final StreamShape shape;
-        protected final T_STATE state;
-        private final ToIntFunction<T_STATE> sizeFn;
-        private final Function<T_STATE, S> streamFn;
-        private final Function<T_STATE, S> parStreamFn;
-        private final Function<T_STATE, T_SPLITR> splitrFn;
-
-        AbstractTestData(String name,
-                         StreamShape shape,
-                         T_STATE state,
-                         Function<T_STATE, S> streamFn,
-                         Function<T_STATE, S> parStreamFn,
-                         Function<T_STATE, T_SPLITR> splitrFn,
-                         ToIntFunction<T_STATE> sizeFn) {
-            this.name = name;
-            this.shape = shape;
-            this.state = state;
-            this.streamFn = streamFn;
-            this.parStreamFn = parStreamFn;
-            this.splitrFn = splitrFn;
-            this.sizeFn = sizeFn;
-        }
-
-        @Override
-        public StreamShape getShape() {
-            return shape;
-        }
-
-        @Override
-        public String toString() {
-            return getClass().getSimpleName() + "[" + name + "]";
-        }
-
-        @Override
-        public int size() {
-            return sizeFn.applyAsInt(state);
-        }
-
-        @Override
-        public T_SPLITR spliterator() {
-            return splitrFn.apply(state);
-        }
-
-        @Override
-        public S stream() {
-            return streamFn.apply(state);
-        }
-
-        @Override
-        public S parallelStream() {
-            return parStreamFn.apply(state);
-        }
-
-        public static class RefTestData<T, I>
-                extends AbstractTestData<T, Stream<T>, I, Spliterator<T>>
-                implements TestData.OfRef<T> {
-
-            protected RefTestData(String name,
-                                  I state,
-                                  Function<I, Stream<T>> streamFn,
-                                  Function<I, Stream<T>> parStreamFn,
-                                  Function<I, Spliterator<T>> splitrFn,
-                                  ToIntFunction<I> sizeFn) {
-                super(name, StreamShape.REFERENCE, state, streamFn, parStreamFn, splitrFn, sizeFn);
-            }
-
-        }
-
-        static class IntTestData<I>
-                extends AbstractTestData<Integer, IntStream, I, Spliterator.OfInt>
-                implements TestData.OfInt {
-
-            protected IntTestData(String name,
-                                  I state,
-                                  Function<I, IntStream> streamFn,
-                                  Function<I, IntStream> parStreamFn,
-                                  Function<I, Spliterator.OfInt> splitrFn,
-                                  ToIntFunction<I> sizeFn) {
-                super(name, StreamShape.INT_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
-            }
-
-            @Override
-            public PrimitiveIterator.OfInt iterator() {
-                return Spliterators.iterator(spliterator());
-            }
-
-            @Override
-            public <A extends Collection<? super Integer>> A into(A target) {
-                spliterator().forEachRemaining((IntConsumer) target::add);
-                return target;
-            }
-        }
-
-        static class LongTestData<I>
-                extends AbstractTestData<Long, LongStream, I, Spliterator.OfLong>
-                implements TestData.OfLong {
-
-            protected LongTestData(String name,
-                                   I state,
-                                   Function<I, LongStream> streamFn,
-                                   Function<I, LongStream> parStreamFn,
-                                   Function<I, Spliterator.OfLong> splitrFn,
-                                   ToIntFunction<I> sizeFn) {
-                super(name, StreamShape.LONG_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
-            }
-
-            @Override
-            public PrimitiveIterator.OfLong iterator() {
-                return Spliterators.iterator(spliterator());
-            }
-
-            @Override
-            public <A extends Collection<? super Long>> A into(A target) {
-                spliterator().forEachRemaining((LongConsumer) target::add);
-                return target;
-            }
-        }
-
-        static class DoubleTestData<I>
-                extends AbstractTestData<Double, DoubleStream, I, Spliterator.OfDouble>
-                implements OfDouble {
-
-            protected DoubleTestData(String name,
-                                     I state,
-                                     Function<I, DoubleStream> streamFn,
-                                     Function<I, DoubleStream> parStreamFn,
-                                     Function<I, Spliterator.OfDouble> splitrFn,
-                                     ToIntFunction<I> sizeFn) {
-                super(name, StreamShape.DOUBLE_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
-            }
-
-            @Override
-            public PrimitiveIterator.OfDouble iterator() {
-                return Spliterators.iterator(spliterator());
-            }
-
-            @Override
-            public <A extends Collection<? super Double>> A into(A target) {
-                spliterator().forEachRemaining((DoubleConsumer) target::add);
-                return target;
-            }
-        }
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/TestFlagExpectedOp.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import org.testng.Assert;
-
-import java.util.EnumSet;
-
-class TestFlagExpectedOp<T> extends FlagDeclaringOp<T> {
-
-    static class Builder<T> {
-        final int flags;
-        StreamShape shape = StreamShape.REFERENCE;
-
-        EnumSet<StreamOpFlag> known = EnumSet.noneOf(StreamOpFlag.class);
-        EnumSet<StreamOpFlag> preserve = EnumSet.noneOf(StreamOpFlag.class);
-        EnumSet<StreamOpFlag> notKnown = EnumSet.noneOf(StreamOpFlag.class);
-
-        Builder(int flags) {
-            this.flags = flags;
-        }
-
-        Builder<T> known(EnumSet<StreamOpFlag> known) {
-            this.known = known;
-            return this;
-        }
-
-        Builder<T> preserve(EnumSet<StreamOpFlag> preserve) {
-            this.preserve = preserve;
-            return this;
-        }
-
-        Builder<T> notKnown(EnumSet<StreamOpFlag> notKnown) {
-            this.notKnown = notKnown;
-            return this;
-        }
-
-        Builder<T> shape(StreamShape shape) {
-            this.shape = shape;
-            return this;
-        }
-
-        TestFlagExpectedOp<T> build() {
-            return new TestFlagExpectedOp<>(flags, known, preserve, notKnown, shape);
-        }
-    }
-
-    final EnumSet<StreamOpFlag> known;
-    final EnumSet<StreamOpFlag> preserve;
-    final EnumSet<StreamOpFlag> notKnown;
-    final StreamShape shape;
-
-    TestFlagExpectedOp(int flags,
-                       EnumSet<StreamOpFlag> known,
-                       EnumSet<StreamOpFlag> preserve,
-                       EnumSet<StreamOpFlag> notKnown) {
-        this(flags, known, preserve, notKnown, StreamShape.REFERENCE);
-    }
-
-    TestFlagExpectedOp(int flags,
-                       EnumSet<StreamOpFlag> known,
-                       EnumSet<StreamOpFlag> preserve,
-                       EnumSet<StreamOpFlag> notKnown,
-                       StreamShape shape) {
-        super(flags);
-        this.known = known;
-        this.preserve = preserve;
-        this.notKnown = notKnown;
-        this.shape = shape;
-    }
-
-    @Override
-    public StreamShape outputShape() {
-        return shape;
-    }
-
-    @Override
-    public StreamShape inputShape() {
-        return shape;
-    }
-
-    @Override
-    @SuppressWarnings({"rawtypes", "unchecked"})
-    public Sink<T> opWrapSink(int flags, boolean parallel, Sink upstream) {
-        assertFlags(flags);
-        return upstream;
-    }
-
-    private void assertFlags(int flags) {
-        for (StreamOpFlag f : known) {
-            Assert.assertTrue(f.isKnown(flags),
-                              String.format("Flag %s is not known, but should be known.", f.toString()));
-        }
-
-        for (StreamOpFlag f : preserve) {
-            Assert.assertTrue(f.isPreserved(flags),
-                              String.format("Flag %s is not preserved, but should be preserved.", f.toString()));
-        }
-
-        for (StreamOpFlag f : notKnown) {
-            Assert.assertFalse(f.isKnown(flags),
-                               String.format("Flag %s is known, but should be not known.", f.toString()));
-        }
-    }
-}
--- a/jdk/test/java/util/stream/bootlib/java.base/java/util/stream/ThrowableHelper.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util.stream;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-public final class ThrowableHelper {
-
-    public static void checkException(Class<? extends Exception> ce, Runnable r) {
-        Exception caught = null;
-        try {
-            r.run();
-        } catch (Exception e) {
-            caught = e;
-        }
-
-        assertNotNull(caught);
-        assertTrue(ce.isInstance(caught));
-    }
-
-    public static void checkNPE(Runnable r) {
-        checkException(NullPointerException.class, r);
-    }
-
-    public static void checkISE(Runnable r) {
-        checkException(IllegalStateException.class, r);
-    }
-}
--- a/jdk/test/java/util/stream/boottest/TEST.properties	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/stream/boottest/TEST.properties	Wed Jul 05 23:37:13 2017 +0200
@@ -1,4 +1,4 @@
 # This file identifies root(s) of the test-ng hierarchy.
 
 TestNG.dirs = .
-lib.dirs = /java/util/stream/bootlib
+lib.dirs = /lib/testlibrary/bootlib
--- a/jdk/test/java/util/stream/test/TEST.properties	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/stream/test/TEST.properties	Wed Jul 05 23:37:13 2017 +0200
@@ -2,7 +2,7 @@
 
 TestNG.dirs = .
 
-lib.dirs = /java/util/stream/bootlib
+lib.dirs = /lib/testlibrary/bootlib
 
 # Tests that must run in othervm mode
 othervm.dirs= /java/util/stream
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/NullArgsTestCase.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package org.openjdk.tests.java.util;
-
-import org.testng.annotations.Test;
-
-import java.util.Arrays;
-import java.util.function.Consumer;
-
-import static org.testng.Assert.fail;
-
-/**
- * NullArgsTestCase -- Given a Consumer&ltObject[]&gt, and an Object[] array of args, call the block with the args,
- * assert success, and then call the consumer N times, each time setting one of the args to null, and assert that
- * all these throw NPE.
- *
- * Typically this would be combined with a DataProvider that serves up combinations of things to be tested, as in
- * IteratorsNullTest.
- */
-public abstract class NullArgsTestCase {
-    public final String name;
-    public final Consumer<Object[]> sink;
-    public final Object[] args;
-
-    protected NullArgsTestCase(String name, Consumer<Object[]> sink, Object[] args) {
-        this.name = name;
-        this.sink = sink;
-        this.args = args;
-    }
-
-    @Test
-    public void goodNonNull() {
-        sink.accept(args);
-    }
-
-    @Test
-    public void throwWithNull() {
-        for (int i=0; i<args.length; i++) {
-            Object[] temp = Arrays.copyOf(args, args.length);
-            temp[i] = null;
-            try {
-                sink.accept(temp);
-                fail(String.format("Expected NullPointerException for argument %d of test case %s", i, name));
-            }
-            catch (NullPointerException e) {
-                // Success
-            }
-        }
-    }
-}
--- a/jdk/test/java/util/zip/InflaterInputStream/TestAvailable.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/zip/InflaterInputStream/TestAvailable.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,8 +22,7 @@
  */
 
 /* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main TestAvailable
  * @bug 7031075 8161426
  * @summary Make sure that available() method behaves as expected.
@@ -33,7 +32,7 @@
 import java.io.*;
 import java.util.Random;
 import java.util.zip.*;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class TestAvailable {
 
--- a/jdk/test/java/util/zip/ZipFile/MultiThreadedReadTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/zip/ZipFile/MultiThreadedReadTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,7 @@
 /* @test
  * @bug 8038491
  * @summary Crash in ZipFile.read() when ZipFileInputStream is shared between threads
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library /test/lib
  * @run main MultiThreadedReadTest
  * @key randomness
  */
@@ -38,7 +37,7 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 import java.util.zip.ZipOutputStream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 
 public class MultiThreadedReadTest extends Thread {
 
--- a/jdk/test/java/util/zip/ZipFile/ReadLongZipFileName.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/zip/ZipFile/ReadLongZipFileName.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,15 +24,14 @@
 /**
  * @test
  * @bug 6374379
- * @library ../../../../lib/testlibrary
+ * @library /test/lib
  * @summary Verify that we can read zip file names > 255 chars long
  */
 
 import java.io.*;
 import java.util.jar.*;
-import java.util.zip.*;
 import java.util.Stack;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 
 public class ReadLongZipFileName {
     private static String entryName = "testFile.txt";;
--- a/jdk/test/java/util/zip/ZipFile/ZipEntryFreeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/java/util/zip/ZipFile/ZipEntryFreeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,7 @@
 /* @test
  * @bug 6907252
  * @summary ZipFileInputStream Not Thread-Safe
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main ZipEntryFreeTest
  */
 
@@ -35,7 +34,7 @@
 import java.util.Timer;
 import java.util.TimerTask;
 import java.util.zip.*;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 
 public class ZipEntryFreeTest extends Thread {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/crypto/Cipher/ExampleVectors/CheckExampleVectors.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
+            }
+        }
+
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/crypto/Cipher/ExampleVectors/NIST_800_38A_vectors.txt	Wed Jul 05 23:37:13 2017 +0200
@@ -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==
+
--- a/jdk/test/javax/imageio/plugins/tiff/MultiPageTest/MultiPageTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/imageio/plugins/tiff/MultiPageTest/MultiPageTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,8 +23,7 @@
 
 /**
  * @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  *
  * @bug     8145776
  * @author  a.stepanov
@@ -47,7 +46,7 @@
 import javax.imageio.*;
 import javax.imageio.stream.*;
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 
 public class MultiPageTest {
--- a/jdk/test/javax/management/MBeanServer/NotifDeadlockTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/management/MBeanServer/NotifDeadlockTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,7 +77,6 @@
         }
     }
     static MBeanServer mbs;
-    static boolean timedOut;
 
     /* This listener registers or unregisters the MBean called on2
        when triggered.  */
@@ -110,83 +109,48 @@
                 };
                 t.start();
                 try {
-                    t.join(2000);
+                    t.join();
                 } catch (InterruptedException e) {
                     e.printStackTrace(); // should not happen
                 }
-                if (t.isAlive()) {
-                    System.out.println("FAILURE: Wait timed out: " +
-                                       "probable deadlock");
-                    timedOut = true;
-                }
             }
         }
     }
 
     public static void main(String[] args) throws Exception {
-        boolean success = true;
 
         System.out.println("Test 1: in register notif, unregister an MBean");
-        timedOut = false;
         mbs = MBeanServerFactory.createMBeanServer();
         mbs.createMBean("javax.management.timer.Timer", on2);
         mbs.addNotificationListener(delName, new XListener(false), null, null);
         mbs.createMBean("javax.management.timer.Timer", on1);
         MBeanServerFactory.releaseMBeanServer(mbs);
-        if (timedOut) {
-            success = false;
-            Thread.sleep(500);
-            // wait for the spawned thread to complete its work, probably
-        }
         System.out.println("Test 1 completed");
 
         System.out.println("Test 2: in unregister notif, unregister an MBean");
-        timedOut = false;
         mbs = MBeanServerFactory.createMBeanServer();
         mbs.createMBean("javax.management.timer.Timer", on1);
         mbs.createMBean("javax.management.timer.Timer", on2);
         mbs.addNotificationListener(delName, new XListener(false), null, null);
         mbs.unregisterMBean(on1);
         MBeanServerFactory.releaseMBeanServer(mbs);
-        if (timedOut) {
-            success = false;
-            Thread.sleep(500);
-            // wait for the spawned thread to complete its work, probably
-        }
         System.out.println("Test 2 completed");
 
         System.out.println("Test 3: in register notif, register an MBean");
-        timedOut = false;
         mbs = MBeanServerFactory.createMBeanServer();
         mbs.addNotificationListener(delName, new XListener(true), null, null);
         mbs.createMBean("javax.management.timer.Timer", on1);
         MBeanServerFactory.releaseMBeanServer(mbs);
-        if (timedOut) {
-            success = false;
-            Thread.sleep(500);
-            // wait for the spawned thread to complete its work, probably
-        }
         System.out.println("Test 3 completed");
 
         System.out.println("Test 4: in unregister notif, register an MBean");
-        timedOut = false;
         mbs = MBeanServerFactory.createMBeanServer();
         mbs.createMBean("javax.management.timer.Timer", on1);
         mbs.addNotificationListener(delName, new XListener(true), null, null);
         mbs.unregisterMBean(on1);
         MBeanServerFactory.releaseMBeanServer(mbs);
-        if (timedOut) {
-            success = false;
-            Thread.sleep(500);
-            // wait for the spawned thread to complete its work, probably
-        }
         System.out.println("Test 4 completed");
 
-        if (success)
-            System.out.println("Test passed");
-        else {
-            System.out.println("TEST FAILED: at least one subcase failed");
-            System.exit(1);
-        }
+        System.out.println("Test passed");
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/management/remote/mandatory/notif/NoPermToRemoveTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+ /*
+ * @test
+ * @bug 6515161
+ * @summary checks the behaviour of  mbeanServerConnection.removeNotificationListener
+ * operation when there is a exception thrown during removal
+ * @modules java.management
+ * @run main NoPermToRemoveTest
+ */
+
+import java.lang.management.ManagementFactory;
+import java.security.AllPermission;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanPermission;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
+import javax.management.Notification;
+import javax.management.NotificationBroadcasterSupport;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXConnectorServer;
+import javax.management.remote.JMXConnectorServerFactory;
+import javax.management.remote.JMXServiceURL;
+
+public class NoPermToRemoveTest {
+    public static void main(String[] args) throws Exception {
+        Policy.setPolicy(new NoRemovePolicy());
+        System.setSecurityManager(new SecurityManager());
+
+        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///");
+        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+        ObjectName name = new ObjectName("foo:type=Sender");
+        mbs.registerMBean(new Sender(), name);
+        JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(
+                url, null, mbs);
+        cs.start();
+        try {
+            JMXServiceURL addr = cs.getAddress();
+            JMXConnector cc = JMXConnectorFactory.connect(addr);
+            MBeanServerConnection mbsc = cc.getMBeanServerConnection();
+            SnoopListener listener = new SnoopListener();
+            mbsc.addNotificationListener(name, listener, null, null);
+            mbsc.invoke(name, "send", null, null);
+            if (!listener.waitForNotification(60))
+                throw new Exception("Did not receive expected notification");
+
+            try {
+                mbsc.removeNotificationListener(name, listener);
+                throw new Exception("RemoveNL did not get SecurityException");
+            } catch (SecurityException e) {
+                System.out.println("removeNL got expected exception: " + e);
+            }
+            mbsc.invoke(name, "send", null, null);
+            if (!listener.waitForNotification(60)) {
+                int listenerCount =
+                        (Integer) mbsc.getAttribute(name, "ListenerCount");
+                System.out.println("Listener count: " + listenerCount);
+                if (listenerCount != 0)
+                    throw new Exception("TEST FAILED");
+                    /* We did not receive the notification, but the MBean still
+                     * has a listener coming from the connector server, which
+                     * means the connector server still thinks there is a
+                     * listener.  If we retained the listener after the failing
+                     * removeNL that would be OK, and if the listener were
+                     * dropped by both client and server that would be OK too,
+                     * but the inconsistency is not OK.
+                     */
+            }
+            cc.close();
+        } finally {
+            cs.stop();
+        }
+    }
+
+    private static class SnoopListener implements NotificationListener {
+        private Semaphore sema = new Semaphore(0);
+
+        public void handleNotification(Notification notification, Object handback) {
+            System.out.println("Listener got: " + notification);
+            sema.release();
+        }
+
+        boolean waitForNotification(int seconds) throws InterruptedException {
+            return sema.tryAcquire(seconds, TimeUnit.SECONDS);
+        }
+    }
+
+    private static class NoRemovePolicy extends Policy {
+        public PermissionCollection getPermissions(CodeSource codesource) {
+            PermissionCollection pc = new Permissions();
+            pc.add(new AllPermission());
+            return pc;
+        }
+
+        public void refresh() {
+        }
+
+        public boolean implies(ProtectionDomain domain, Permission permission) {
+            if (!(permission instanceof MBeanPermission))
+                return true;
+            MBeanPermission jmxp = (MBeanPermission) permission;
+            if (jmxp.getActions().contains("removeNotificationListener")) {
+                System.out.println("DENIED");
+                return false;
+            }
+            return true;
+        }
+    }
+
+    public static interface SenderMBean {
+        public void send();
+        public int getListenerCount();
+    }
+
+    public static class Sender extends NotificationBroadcasterSupport
+            implements SenderMBean {
+        private AtomicInteger listenerCount = new AtomicInteger();
+
+        public void send() {
+            System.out.println("Sending notif");
+            sendNotification(new Notification("type", this, 0L));
+        }
+
+        public synchronized int getListenerCount() {
+            return listenerCount.get();
+        }
+
+        public void removeNotificationListener(
+                NotificationListener listener,
+                NotificationFilter filter,
+                Object handback) throws ListenerNotFoundException {
+            System.out.println("Sender.removeNL(3)");
+            super.removeNotificationListener(listener, filter, handback);
+            listenerCount.decrementAndGet();
+        }
+
+        public void addNotificationListener(
+                NotificationListener listener,
+                NotificationFilter filter,
+                Object handback) {
+            System.out.println("Sender.addNL(3)");
+            super.addNotificationListener(listener, filter, handback);
+            listenerCount.incrementAndGet();
+        }
+
+        public void removeNotificationListener(NotificationListener listener)
+        throws ListenerNotFoundException {
+            System.out.println("Sender.removeNL(1)");
+            super.removeNotificationListener(listener);
+            listenerCount.decrementAndGet();
+        }
+    }
+}
--- a/jdk/test/javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
  * @bug 8043758
  * @summary Testing DTLS incorrect app data packages unwrapping.
  * @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
  * @modules java.security.jgss
  *          jdk.security.auth
  *          java.security.jgss/sun.security.krb5:+open
@@ -49,7 +49,7 @@
 import javax.net.ssl.SSLEngineResult;
 import javax.net.ssl.SSLException;
 import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /**
  * Testing DTLS incorrect app data packages unwrapping. Incorrect application
--- a/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithCipherChangeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithCipherChangeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
  * @summary Testing DTLS engines re-handshaking with cipher change. New cipher
  *          is taken randomly from the supporetd ciphers list.
  * @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
  * @modules java.security.jgss
  *          java.security.jgss/sun.security.krb5:+open
  *          java.security.jgss/sun.security.krb5.internal:+open
--- a/jdk/test/javax/net/ssl/DTLS/DTLSSequenceNumberTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/net/ssl/DTLS/DTLSSequenceNumberTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
  * @summary Testing DTLS records sequence number property support in application
  *          data exchange.
  * @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
  * @modules java.security.jgss
  *          jdk.security.auth
  *          java.security.jgss/sun.security.krb5:+open
@@ -51,7 +51,7 @@
 import javax.net.ssl.SSLEngineResult;
 import javax.net.ssl.SSLException;
 import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /**
  * Testing DTLS records sequence number property support in application data
--- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
  * @bug 8043758
  * @summary Testing DTLS incorrect app data packages unwrapping.
  * @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon /javax/net/ssl/DTLS
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon /javax/net/ssl/DTLS
  * @modules java.security.jgss
  *          jdk.security.auth
  *          java.security.jgss/sun.security.krb5:+open
--- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithCipherChangeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithCipherChangeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
  * @summary Testing DTLS engines re-handshaking with cipher change. New cipher
  *          is taken randomly from the supporetd ciphers list.
  * @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
  * @modules java.security.jgss
  *          java.security.jgss/sun.security.krb5:+open
  *          java.security.jgss/sun.security.krb5.internal:+open
--- a/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/net/ssl/Stapling/SSLSocketWithStapling.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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();
--- a/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithCipherChangeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithCipherChangeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
  * @summary Testing TLS engines re-handshaking with cipher change. New cipher
  *          is taken randomly from the supporetd ciphers list.
  * @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
  * @modules java.security.jgss
  *          java.security.jgss/sun.security.krb5:+open
  *          java.security.jgss/sun.security.krb5.internal:+open
--- a/jdk/test/javax/net/ssl/TLSCommon/RehandshakeWithCipherChangeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/net/ssl/TLSCommon/RehandshakeWithCipherChangeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
 import javax.net.ssl.SSLEngineResult;
 import javax.net.ssl.SSLException;
 import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 /**
  * Testing SSLEngines re-handshaking with cipher change. New cipher is taken
--- a/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithCipherChangeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithCipherChangeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
  * @summary Testing TLS engines re-handshaking with cipher change. New cipher
  *          is taken randomly from the supporetd ciphers list.
  * @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
  * @modules java.security.jgss
  *          java.security.jgss/sun.security.krb5:+open
  *          java.security.jgss/sun.security.krb5.internal:+open
--- a/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithCipherChangeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithCipherChangeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
  * @summary Testing TLS engines re-handshaking with cipher change. New cipher
  *          is taken randomly from the supporetd ciphers list.
  * @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
  * @modules java.security.jgss
  *          java.security.jgss/sun.security.krb5:+open
  *          java.security.jgss/sun.security.krb5.internal:+open
--- a/jdk/test/javax/security/auth/login/modules/JaasModularClientTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/security/auth/login/modules/JaasModularClientTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,14 +32,15 @@
 import java.util.ArrayList;
 import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.OutputAnalyzer;
+import jdk.test.lib.compiler.CompilerUtils;
 import org.testng.annotations.BeforeTest;
 
 /**
  * @test
  * @bug 8078813
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @library /java/security/modules
- * @build CompilerUtils JarUtils
+ * @build jdk.test.lib.compiler.CompilerUtils JarUtils
  * @summary Test custom JAAS module with all possible modular option. The test
  *          includes different combination of JAAS client/login modules
  *          interaction with or without service description.
--- a/jdk/test/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/security/auth/login/modules/JaasModularDefaultHandlerTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 import java.io.IOException;
 import java.lang.module.ModuleDescriptor;
 import java.util.ArrayList;
+import jdk.test.lib.compiler.CompilerUtils;
 import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.OutputAnalyzer;
 import org.testng.annotations.BeforeTest;
@@ -37,9 +38,9 @@
 /**
  * @test
  * @bug 8151654
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @library /java/security/modules
- * @build CompilerUtils JarUtils
+ * @build jdk.test.lib.compiler.CompilerUtils JarUtils
  * @summary Test custom JAAS callback handler with all possible modular option.
  * @run testng JaasModularDefaultHandlerTest
  */
--- a/jdk/test/javax/swing/ToolTipManager/7123767/bug7123767.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/javax/swing/ToolTipManager/7123767/bug7123767.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,8 +38,7 @@
  * @key      randomness
  *
  * @modules  java.desktop/sun.awt
- * @library  /lib/testlibrary/
- * @build    jdk.testlibrary.*
+ * @library  /test/lib
  *
  * @run      main/timeout=300 bug7123767
  */
@@ -55,7 +54,7 @@
 import java.util.Collections;
 import java.util.Random;
 
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 
 public class bug7123767 extends JFrame {
--- a/jdk/test/jdk/internal/jline/extra/HistoryTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/jdk/internal/jline/extra/HistoryTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -23,6 +23,7 @@
 
 /*
  * @test
+ * @bug 8178821
  * @summary Test Completion
  * @modules jdk.internal.le/jdk.internal.jline
  *          jdk.internal.le/jdk.internal.jline.console
@@ -152,6 +153,15 @@
         complete.set(true);  history.add("}");
 
         previousSnippetAndAssert(history, "void test() { /*after full*/");
+        nextSnippetAndAssert(history, "");
+
+        assertFalse(history.nextSnippet());
+
+        while (history.previousSnippet())
+            ;
+
+        while (history.nextSnippet())
+            ;
     }
 
     private void previousAndAssert(EditingHistory history, String expected) {
--- a/jdk/test/jdk/internal/util/jar/TestVersionedStream.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/jdk/internal/util/jar/TestVersionedStream.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,9 +25,8 @@
  * @test
  * @bug 8163798
  * @summary basic tests for multi-release jar versioned streams
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules jdk.jartool/sun.tools.jar java.base/jdk.internal.util.jar
- * @build jdk.testlibrary.FileUtils
  * @run testng TestVersionedStream
  */
 
@@ -57,7 +56,7 @@
 import java.util.stream.Stream;
 import java.util.zip.ZipFile;
 
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 
 public class TestVersionedStream {
     private final Path userdir;
--- a/jdk/test/jdk/modules/incubator/DefaultImage.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/jdk/modules/incubator/DefaultImage.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,13 @@
  * @test
  * @bug 8170859
  * @summary Ensure no incubator modules are resolved by default in the image
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build CompilerUtils
+ * @build jdk.test.lib.compiler.CompilerUtils
  * @run testng DefaultImage
  */
 
 import java.io.ByteArrayOutputStream;
-import java.io.IOException;
 import java.io.PrintStream;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleFinder;
@@ -42,6 +41,7 @@
 import java.nio.file.Paths;
 import java.util.function.Consumer;
 import java.util.stream.Stream;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/jdk/test/jdk/modules/incubator/ImageModules.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/jdk/modules/incubator/ImageModules.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,10 +25,10 @@
  * @test
  * @bug 8170859
  * @summary Basic test for incubator modules in jmods and images
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @key intermittent
  * @modules jdk.compiler jdk.jartool jdk.jlink
- * @build CompilerUtils
+ * @build jdk.test.lib.compiler.CompilerUtils
  * @run testng/othervm ImageModules
  */
 
@@ -39,14 +39,14 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.function.Consumer;
 import java.util.spi.ToolProvider;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.compiler.CompilerUtils;
+import jdk.test.lib.util.FileUtils;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
--- a/jdk/test/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/jdk/modules/scenarios/automaticmodules/RunWithAutomaticModules.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build RunWithAutomaticModules CompilerUtils JarUtils
+ * @build RunWithAutomaticModules jdk.test.lib.compiler.CompilerUtils JarUtils
  *        jdk.testlibrary.ProcessTools
  * @run testng RunWithAutomaticModules
  * @summary Runs tests that make use of automatic modules
@@ -35,6 +35,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.*;
 
 import org.testng.annotations.Test;
--- a/jdk/test/jdk/modules/scenarios/container/ContainerTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/jdk/modules/scenarios/container/ContainerTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,12 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.jartool/sun.tools.jar
  *          jdk.compiler
  *          jdk.zipfs
  *          java.se
- * @build ContainerTest CompilerUtils jdk.testlibrary.*
+ * @build ContainerTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run testng ContainerTest
  * @summary Starts a simple container that uses dynamic configurations
  *          and launches two applications in the same VM
@@ -38,6 +38,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
--- a/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,10 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build OverlappingPackagesTest CompilerUtils jdk.testlibrary.*
+ * @build OverlappingPackagesTest jdk.testlibrary.*
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng OverlappingPackagesTest
  * @summary Basic test to ensure that startup fails if two or more modules
  *          in the boot Layer have the same package
@@ -36,6 +37,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
--- a/jdk/test/jdk/security/jarsigner/Spec.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/jdk/security/jarsigner/Spec.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 8056174
  * @summary Make sure JarSigner impl conforms to spec
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.base/sun.security.tools.keytool
  *          java.base/sun.security.provider.certpath
  *          jdk.jartool
@@ -35,7 +35,7 @@
 import com.sun.jarsigner.ContentSigner;
 import com.sun.jarsigner.ContentSignerParameters;
 import jdk.security.jarsigner.JarSigner;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 import sun.security.provider.certpath.X509CertPath;
 
 import java.io.File;
--- a/jdk/test/lib/testlibrary/CompilerUtils.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import javax.tools.JavaCompiler;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
-import javax.tools.ToolProvider;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * This class consists exclusively of static utility methods for invoking the
- * java compiler.
- */
-
-public final class CompilerUtils {
-    private CompilerUtils() { }
-
-    /**
-     * Compile all the java sources in {@code <source>/**} to
-     * {@code <destination>/**}. The destination directory will be created if
-     * it doesn't exist.
-     *
-     * All warnings/errors emitted by the compiler are output to System.out/err.
-     *
-     * @return true if the compilation is successful
-     *
-     * @throws IOException
-     *         if there is an I/O error scanning the source tree or
-     *         creating the destination directory
-     * @throws UnsupportedOperationException
-     *         if there is no system java compiler
-     */
-    public static boolean compile(Path source, Path destination, String ... options)
-        throws IOException
-    {
-        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
-        if (compiler == null) {
-            // no compiler available
-            throw new UnsupportedOperationException("Unable to get system java compiler. " +
-                "Perhaps, jdk.compiler module is not available.");
-        }
-        StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
-
-        List<Path> sources
-            = Files.find(source, Integer.MAX_VALUE,
-                (file, attrs) -> (file.toString().endsWith(".java")))
-                .collect(Collectors.toList());
-
-        Files.createDirectories(destination);
-        jfm.setLocation(StandardLocation.CLASS_PATH, Collections.EMPTY_LIST);
-        jfm.setLocationFromPaths(StandardLocation.CLASS_OUTPUT,
-                                 Arrays.asList(destination));
-
-        List<String> opts = Arrays.asList(options);
-        JavaCompiler.CompilationTask task
-            = compiler.getTask(null, jfm, null, opts, null,
-                jfm.getJavaFileObjectsFromPaths(sources));
-
-        return task.call();
-    }
-}
--- a/jdk/test/lib/testlibrary/JavaToolUtils.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  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.
- */
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.file.Files;
-import java.util.List;
-import java.util.Objects;
-import java.util.concurrent.TimeUnit;
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
-
-/**
- * Utils class for compiling , creating jar file and executing a java command
- *
- * @author Raghu Nair
- */
-
-public class JavaToolUtils {
-
-    public static final long DEFAULT_WAIT_TIME = 10000;
-
-    private JavaToolUtils() {
-    }
-
-    /**
-     * Takes a list of files and compile these files into the working directory.
-     *
-     * @param files
-     * @throws IOException
-     */
-    public static void compileFiles(List<File> files) throws IOException {
-        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
-        try (StandardJavaFileManager fileManager = compiler.
-                getStandardFileManager(null, null, null)) {
-            Iterable<? extends JavaFileObject> compilationUnit
-                    = fileManager.getJavaFileObjectsFromFiles(files);
-            compiler.getTask(null, fileManager, null, null, null,
-                    compilationUnit).call();
-        }
-    }
-
-    /**
-     * Create a jar file using the list of files provided.
-     *
-     * @param jar
-     * @param files
-     * @throws IOException
-     */
-    public static void createJar(File jar, List<File> files)
-            throws IOException {
-        Manifest manifest = new Manifest();
-        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION,
-                "1.0");
-        try (JarOutputStream target = new JarOutputStream(
-                new FileOutputStream(jar), manifest)) {
-            for (File file : files) {
-                add(file, target);
-            }
-        }
-    }
-
-    private static void add(File source, JarOutputStream target)
-            throws IOException {
-        Objects.requireNonNull(source, "source cannot be null");
-        Objects.requireNonNull(target, "target cannot be null");
-        // not tested against directories and from different path.
-        String name = source.getName();
-        if (source.isDirectory()) {
-            if (!name.isEmpty()) {
-                if (!name.endsWith("/")) {
-                    name += "/";
-                }
-                JarEntry entry = new JarEntry(name);
-                entry.setTime(source.lastModified());
-                target.putNextEntry(entry);
-                target.closeEntry();
-            }
-            for (File nestedFile : source.listFiles()) {
-                add(nestedFile, target);
-            }
-            return;
-        }
-        System.out.println("Adding entry " + name);
-        JarEntry entry = new JarEntry(name);
-        entry.setTime(source.lastModified());
-        target.putNextEntry(entry);
-        Files.copy(source.toPath(), target);
-        target.closeEntry();
-    }
-
-    /**
-     * Runs java command with provided arguments. Caller should not pass java
-     * command in the argument list.
-     *
-     * @param commands
-     * @param waitTime time to wait for the command to exit in milli seconds
-     * @return
-     * @throws Exception
-     */
-    public static int runJava(List<String> commands,long waitTime)
-            throws Exception {
-        String java = System.getProperty("java.home") + "/bin/java";
-        commands.add(0, java);
-        String command = commands.toString().replace(",", " ");
-        System.out.println("Executing the following command \n" + command);
-        ProcessBuilder processBuilder = new ProcessBuilder(commands);
-        final Process process = processBuilder.start();
-        BufferedReader errorStream = new BufferedReader(
-                new InputStreamReader(process.getErrorStream()));
-        BufferedReader outStream = new BufferedReader(
-                new InputStreamReader(process.getInputStream()));
-        String errorLine;
-        StringBuilder errors = new StringBuilder();
-        String outLines;
-        while ((errorLine = errorStream.readLine()) != null) {
-            errors.append(errorLine).append("\n");
-        }
-        while ((outLines = outStream.readLine()) != null) {
-            System.out.println(outLines);
-        }
-        errorLine = errors.toString();
-        System.err.println(errorLine);
-        process.waitFor(waitTime, TimeUnit.MILLISECONDS);
-        int exitStatus = process.exitValue();
-        if (exitStatus != 0 && errorLine != null && errorLine.isEmpty()) {
-            throw new RuntimeException(errorLine);
-        }
-        return exitStatus;
-    }
-
-    /**
-     * Runs java command with provided arguments. Caller should not pass java
-     * command in the argument list.
-     *
-     * @param commands
-     * @return
-     * @throws Exception
-     */
-    public static int runJava(List<String> commands) throws Exception {
-        return runJava(commands, DEFAULT_WAIT_TIME);
-    }
-
-    /**
-     * Run any command
-     * @param commands
-     * @return
-     * @throws Exception
-     */
-    public static int runCommand(List<String> commands) throws Exception {
-        String command = commands.toString().replace(",", " ");
-        System.out.println("Executing the following command \n" + command);
-        ProcessBuilder processBuilder = new ProcessBuilder(commands);
-        final Process process = processBuilder.start();
-        BufferedReader errorStream = new BufferedReader(
-                new InputStreamReader(process.getErrorStream()));
-        BufferedReader outStream = new BufferedReader(
-                new InputStreamReader(process.getInputStream()));
-        String errorLine;
-        StringBuilder errors = new StringBuilder();
-        String outLines;
-        while ((errorLine = errorStream.readLine()) != null) {
-            errors.append(errorLine).append("\n");
-        }
-        while ((outLines = outStream.readLine()) != null) {
-            System.out.println(outLines);
-        }
-        errorLine = errors.toString();
-        System.err.println(errorLine);
-        int exitStatus = process.exitValue();
-        if (exitStatus != 0 && errorLine != null && errorLine.isEmpty()) {
-            throw new RuntimeException(errorLine);
-        }
-        return exitStatus;
-    }
-
-
-}
--- a/jdk/test/lib/testlibrary/ModuleInfoMaker.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +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.
- */
-
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Arrays;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Stream;
-
-import static org.testng.Assert.assertTrue;
-
-/**
- * Utility class for creating test modules.
- */
-public class ModuleInfoMaker {
-    private static String MODULE_INFO_JAVA = "module-info.java";
-    private static Pattern MODULE_PATTERN =
-        Pattern.compile("module\\s+((?:\\w+\\.)*)");
-    private static Pattern PACKAGE_PATTERN =
-                       Pattern.compile("package\\s+(((?:\\w+\\.)*)(?:\\w+))");
-    private static Pattern CLASS_PATTERN =
-          Pattern.compile("(?:public\\s+)?(?:class|enum|interface)\\s+(\\w+)");
-
-    private final Path dir;
-    public ModuleInfoMaker(Path dir) {
-        this.dir = dir;
-    }
-
-    /**
-     * Create java source files of the given module
-     */
-    public void writeJavaFiles(String module, String moduleInfoJava, String... contents)
-        throws IOException
-    {
-        Path msrc = dir.resolve(module);
-        new JavaSource(moduleInfoJava).write(msrc);
-        for (String c : contents) {
-            new JavaSource(c).write(msrc);
-        }
-    }
-
-    /**
-     * Compile the module to the given destination.
-     */
-    public void compile(String module, Path dest, String... options)
-        throws IOException
-    {
-        Path msrc = dir.resolve(module);
-        Stream<String> args =
-            Stream.concat(Arrays.stream(options),
-                          Stream.of("--module-source-path",
-                                    dir.toString()));
-        assertTrue(CompilerUtils.compile(msrc, dest, args.toArray(String[]::new)),
-                   "Fail to compile " + module);
-    }
-
-    static class JavaSource {
-        final String source;
-        JavaSource(String source) {
-            this.source = source;
-        }
-
-        /**
-         * Writes the source code to a file in a specified directory.
-         * @param dir the directory
-         * @throws IOException if there is a problem writing the file
-         */
-        public void write(Path dir) throws IOException {
-            Path file = dir.resolve(getJavaFileNameFromSource(source));
-            Files.createDirectories(file.getParent());
-            try (BufferedWriter out = Files.newBufferedWriter(file)) {
-                out.write(source.replace("\n", System.lineSeparator()));
-            }
-        }
-
-        /**
-         * Extracts the Java file name from the class declaration.
-         * This method is intended for simple files and uses regular expressions,
-         * so comments matching the pattern can make the method fail.
-         */
-        static String getJavaFileNameFromSource(String source) {
-            String packageName = null;
-
-            Matcher matcher = MODULE_PATTERN.matcher(source);
-            if (matcher.find())
-                return MODULE_INFO_JAVA;
-
-            matcher = PACKAGE_PATTERN.matcher(source);
-            if (matcher.find())
-                packageName = matcher.group(1).replace(".", "/");
-
-            matcher = CLASS_PATTERN.matcher(source);
-            if (matcher.find()) {
-                String className = matcher.group(1) + ".java";
-                return (packageName == null) ? className : packageName + "/" + className;
-            } else if (packageName != null) {
-                return packageName + "/package-info.java";
-            } else {
-                throw new Error("Could not extract the java class " +
-                    "name from the provided source");
-            }
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/SpliteratorOfIntDataBuilder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.util;
+
+import java.util.function.Supplier;
+
+public class SpliteratorOfIntDataBuilder {
+        List<Object[]> data;
+
+        List<Integer> exp;
+
+        public SpliteratorOfIntDataBuilder(List<Object[]> data, List<Integer> exp) {
+            this.data = data;
+            this.exp = exp;
+        }
+
+        public void add(String description, List<Integer> expected, Supplier<Spliterator.OfInt> s) {
+            description = joiner(description).toString();
+            data.add(new Object[]{description, expected, s});
+        }
+
+        public void add(String description, Supplier<Spliterator.OfInt> s) {
+            add(description, exp, s);
+        }
+
+        StringBuilder joiner(String description) {
+            return new StringBuilder(description).
+                    append(" {").
+                    append("size=").append(exp.size()).
+                    append("}");
+        }
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/SpliteratorTestHelper.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,754 @@
+/*
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util;
+
+import java.util.function.*;
+import java.util.stream.LambdaTestHelpers;
+
+import static org.testng.Assert.*;
+
+/**
+ * Assertion methods for spliterators, to be called from other tests
+ */
+public class SpliteratorTestHelper {
+
+    public interface ContentAsserter<T> {
+        void assertContents(Collection<T> actual, Collection<T> expected, boolean isOrdered);
+    }
+
+    private static ContentAsserter<Object> DEFAULT_CONTENT_ASSERTER
+            = SpliteratorTestHelper::assertContents;
+
+    @SuppressWarnings("unchecked")
+    private static <T> ContentAsserter<T> defaultContentAsserter() {
+        return (ContentAsserter<T>) DEFAULT_CONTENT_ASSERTER;
+    }
+
+    public static void testSpliterator(Supplier<Spliterator<Integer>> supplier) {
+        testSpliterator(supplier, defaultContentAsserter());
+    }
+
+    public static void testSpliterator(Supplier<Spliterator<Integer>> supplier,
+                                       ContentAsserter<Integer> asserter) {
+        testSpliterator(supplier, (Consumer<Integer> b) -> b, asserter);
+    }
+
+    public static void testIntSpliterator(Supplier<Spliterator.OfInt> supplier) {
+        testIntSpliterator(supplier, defaultContentAsserter());
+    }
+
+    public static void testIntSpliterator(Supplier<Spliterator.OfInt> supplier,
+                                          ContentAsserter<Integer> asserter) {
+        testSpliterator(supplier, intBoxingConsumer(), asserter);
+    }
+
+    public static void testLongSpliterator(Supplier<Spliterator.OfLong> supplier) {
+        testLongSpliterator(supplier, defaultContentAsserter());
+    }
+
+    public static void testLongSpliterator(Supplier<Spliterator.OfLong> supplier,
+                                           ContentAsserter<Long> asserter) {
+        testSpliterator(supplier, longBoxingConsumer(), asserter);
+    }
+
+    public static void testDoubleSpliterator(Supplier<Spliterator.OfDouble> supplier) {
+        testDoubleSpliterator(supplier, defaultContentAsserter());
+    }
+
+    public static void testDoubleSpliterator(Supplier<Spliterator.OfDouble> supplier,
+                                             ContentAsserter<Double> asserter) {
+        testSpliterator(supplier, doubleBoxingConsumer(), asserter);
+    }
+
+    public static UnaryOperator<Consumer<Integer>> intBoxingConsumer() {
+        class BoxingAdapter implements Consumer<Integer>, IntConsumer {
+            private final Consumer<Integer> b;
+
+            BoxingAdapter(Consumer<Integer> b) {
+                this.b = b;
+            }
+
+            @Override
+            public void accept(Integer value) {
+                throw new IllegalStateException();
+            }
+
+            @Override
+            public void accept(int value) {
+                b.accept(value);
+            }
+        }
+
+        return b -> new BoxingAdapter(b);
+    }
+
+    public static UnaryOperator<Consumer<Long>> longBoxingConsumer() {
+        class BoxingAdapter implements Consumer<Long>, LongConsumer {
+            private final Consumer<Long> b;
+
+            BoxingAdapter(Consumer<Long> b) {
+                this.b = b;
+            }
+
+            @Override
+            public void accept(Long value) {
+                throw new IllegalStateException();
+            }
+
+            @Override
+            public void accept(long value) {
+                b.accept(value);
+            }
+        }
+
+        return b -> new BoxingAdapter(b);
+    }
+
+    public static UnaryOperator<Consumer<Double>> doubleBoxingConsumer() {
+        class BoxingAdapter implements Consumer<Double>, DoubleConsumer {
+            private final Consumer<Double> b;
+
+            BoxingAdapter(Consumer<Double> b) {
+                this.b = b;
+            }
+
+            @Override
+            public void accept(Double value) {
+                throw new IllegalStateException();
+            }
+
+            @Override
+            public void accept(double value) {
+                b.accept(value);
+            }
+        }
+
+        return b -> new BoxingAdapter(b);
+    }
+
+    public static <T, S extends Spliterator<T>> void testSpliterator(Supplier<S> supplier,
+                                                              UnaryOperator<Consumer<T>> boxingAdapter,
+                                                              ContentAsserter<T> asserter) {
+        ArrayList<T> fromForEach = new ArrayList<>();
+        Spliterator<T> spliterator = supplier.get();
+        Consumer<T> addToFromForEach = boxingAdapter.apply(fromForEach::add);
+        spliterator.forEachRemaining(addToFromForEach);
+
+        Collection<T> exp = Collections.unmodifiableList(fromForEach);
+
+        testNullPointerException(supplier);
+        testForEach(exp, supplier, boxingAdapter, asserter);
+        testTryAdvance(exp, supplier, boxingAdapter, asserter);
+        testMixedTryAdvanceForEach(exp, supplier, boxingAdapter, asserter);
+        testMixedTraverseAndSplit(exp, supplier, boxingAdapter, asserter);
+        testSplitAfterFullTraversal(supplier, boxingAdapter);
+        testSplitOnce(exp, supplier, boxingAdapter, asserter);
+        testSplitSixDeep(exp, supplier, boxingAdapter, asserter);
+        testSplitUntilNull(exp, supplier, boxingAdapter, asserter);
+    }
+
+    public static <T, S extends Spliterator<T>> void testForEach(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testForEach(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    public static <T, S extends Spliterator<T>> void testTryAdvance(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testTryAdvance(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    public static <T, S extends Spliterator<T>> void testMixedTryAdvanceForEach(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testMixedTryAdvanceForEach(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    public static <T, S extends Spliterator<T>> void testMixedTraverseAndSplit(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testMixedTraverseAndSplit(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    public static <T, S extends Spliterator<T>> void testSplitOnce(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testSplitOnce(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    public static <T, S extends Spliterator<T>> void testSplitSixDeep(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testSplitSixDeep(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    public static <T, S extends Spliterator<T>> void testSplitUntilNull(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        testSplitUntilNull(exp, supplier, boxingAdapter, defaultContentAsserter());
+    }
+
+    private static <T, S extends Spliterator<T>> void testNullPointerException(Supplier<S> s) {
+        S sp = s.get();
+        // Have to check instances and use casts to avoid tripwire messages and
+        // directly test the primitive methods
+        if (sp instanceof Spliterator.OfInt) {
+            Spliterator.OfInt psp = (Spliterator.OfInt) sp;
+            assertThrowsNPE(() -> psp.forEachRemaining((IntConsumer) null));
+            assertThrowsNPE(() -> psp.tryAdvance((IntConsumer) null));
+        }
+        else if (sp instanceof Spliterator.OfLong) {
+            Spliterator.OfLong psp = (Spliterator.OfLong) sp;
+            assertThrowsNPE(() -> psp.forEachRemaining((LongConsumer) null));
+            assertThrowsNPE(() -> psp.tryAdvance((LongConsumer) null));
+        }
+        else if (sp instanceof Spliterator.OfDouble) {
+            Spliterator.OfDouble psp = (Spliterator.OfDouble) sp;
+            assertThrowsNPE(() -> psp.forEachRemaining((DoubleConsumer) null));
+            assertThrowsNPE(() -> psp.tryAdvance((DoubleConsumer) null));
+        }
+        else {
+            assertThrowsNPE(() -> sp.forEachRemaining(null));
+            assertThrowsNPE(() -> sp.tryAdvance(null));
+        }
+    }
+
+    private static <T, S extends Spliterator<T>> void testForEach(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        S spliterator = supplier.get();
+        long sizeIfKnown = spliterator.getExactSizeIfKnown();
+        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+        ArrayList<T> fromForEach = new ArrayList<>();
+        spliterator = supplier.get();
+        Consumer<T> addToFromForEach = boxingAdapter.apply(fromForEach::add);
+        spliterator.forEachRemaining(addToFromForEach);
+
+        // Assert that forEach now produces no elements
+        spliterator.forEachRemaining(boxingAdapter.apply(
+                e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
+        // Assert that tryAdvance now produce no elements
+        spliterator.tryAdvance(boxingAdapter.apply(
+                e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
+
+        // assert that size, tryAdvance, and forEach are consistent
+        if (sizeIfKnown >= 0) {
+            assertEquals(sizeIfKnown, exp.size());
+        }
+        if (exp.contains(null)) {
+            assertTrue(fromForEach.contains(null));
+        }
+        assertEquals(fromForEach.size(), exp.size());
+
+        asserter.assertContents(fromForEach, exp, isOrdered);
+    }
+
+    private static <T, S extends Spliterator<T>> void testTryAdvance(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        S spliterator = supplier.get();
+        long sizeIfKnown = spliterator.getExactSizeIfKnown();
+        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+        spliterator = supplier.get();
+        ArrayList<T> fromTryAdvance = new ArrayList<>();
+        Consumer<T> addToFromTryAdvance = boxingAdapter.apply(fromTryAdvance::add);
+        while (spliterator.tryAdvance(addToFromTryAdvance)) { }
+
+        // Assert that forEach now produces no elements
+        spliterator.forEachRemaining(boxingAdapter.apply(
+                e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
+        // Assert that tryAdvance now produce no elements
+        spliterator.tryAdvance(boxingAdapter.apply(
+                e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
+
+        // assert that size, tryAdvance, and forEach are consistent
+        if (sizeIfKnown >= 0) {
+            assertEquals(sizeIfKnown, exp.size());
+        }
+        assertEquals(fromTryAdvance.size(), exp.size());
+
+        asserter.assertContents(fromTryAdvance, exp, isOrdered);
+    }
+
+    private static <T, S extends Spliterator<T>> void testMixedTryAdvanceForEach(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        S spliterator = supplier.get();
+        long sizeIfKnown = spliterator.getExactSizeIfKnown();
+        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+        // tryAdvance first few elements, then forEach rest
+        ArrayList<T> dest = new ArrayList<>();
+        spliterator = supplier.get();
+        Consumer<T> addToDest = boxingAdapter.apply(dest::add);
+        for (int i = 0; i < 10 && spliterator.tryAdvance(addToDest); i++) { }
+        spliterator.forEachRemaining(addToDest);
+
+        // Assert that forEach now produces no elements
+        spliterator.forEachRemaining(boxingAdapter.apply(
+                e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
+        // Assert that tryAdvance now produce no elements
+        spliterator.tryAdvance(boxingAdapter.apply(
+                e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
+
+        if (sizeIfKnown >= 0) {
+            assertEquals(sizeIfKnown, dest.size());
+        }
+        assertEquals(dest.size(), exp.size());
+
+        asserter.assertContents(dest, exp, isOrdered);
+    }
+
+    private static <T, S extends Spliterator<T>> void testMixedTraverseAndSplit(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        S spliterator = supplier.get();
+        long sizeIfKnown = spliterator.getExactSizeIfKnown();
+        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+        // tryAdvance first few elements, then forEach rest
+        ArrayList<T> dest = new ArrayList<>();
+        spliterator = supplier.get();
+        Consumer<T> b = boxingAdapter.apply(dest::add);
+
+        Spliterator<T> spl1, spl2, spl3;
+        spliterator.tryAdvance(b);
+        spl2 = spliterator.trySplit();
+        if (spl2 != null) {
+            spl2.tryAdvance(b);
+            spl1 = spl2.trySplit();
+            if (spl1 != null) {
+                spl1.tryAdvance(b);
+                spl1.forEachRemaining(b);
+            }
+            spl2.tryAdvance(b);
+            spl2.forEachRemaining(b);
+        }
+        spliterator.tryAdvance(b);
+        spl3 = spliterator.trySplit();
+        if (spl3 != null) {
+            spl3.tryAdvance(b);
+            spl3.forEachRemaining(b);
+        }
+        spliterator.tryAdvance(b);
+        spliterator.forEachRemaining(b);
+
+        if (sizeIfKnown >= 0) {
+            assertEquals(sizeIfKnown, dest.size());
+        }
+        assertEquals(dest.size(), exp.size());
+
+        asserter.assertContents(dest, exp, isOrdered);
+    }
+
+    public static <T, S extends Spliterator<T>> void testSplitAfterFullTraversal(
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter) {
+        // Full traversal using tryAdvance
+        Spliterator<T> spliterator = supplier.get();
+        while (spliterator.tryAdvance(boxingAdapter.apply(e -> { }))) { }
+        Spliterator<T> split = spliterator.trySplit();
+        assertNull(split);
+
+        // Full traversal using forEach
+        spliterator = supplier.get();
+        spliterator.forEachRemaining(boxingAdapter.apply(e -> { }));
+        split = spliterator.trySplit();
+        assertNull(split);
+
+        // Full traversal using tryAdvance then forEach
+        spliterator = supplier.get();
+        spliterator.tryAdvance(boxingAdapter.apply(e -> { }));
+        spliterator.forEachRemaining(boxingAdapter.apply(e -> { }));
+        split = spliterator.trySplit();
+        assertNull(split);
+    }
+
+    private static <T, S extends Spliterator<T>> void testSplitOnce(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        S spliterator = supplier.get();
+        long sizeIfKnown = spliterator.getExactSizeIfKnown();
+        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+        ArrayList<T> fromSplit = new ArrayList<>();
+        Spliterator<T> s1 = supplier.get();
+        Spliterator<T> s2 = s1.trySplit();
+        long s1Size = s1.getExactSizeIfKnown();
+        long s2Size = (s2 != null) ? s2.getExactSizeIfKnown() : 0;
+        Consumer<T> addToFromSplit = boxingAdapter.apply(fromSplit::add);
+        if (s2 != null)
+            s2.forEachRemaining(addToFromSplit);
+        s1.forEachRemaining(addToFromSplit);
+
+        if (sizeIfKnown >= 0) {
+            assertEquals(sizeIfKnown, fromSplit.size());
+            if (s1Size >= 0 && s2Size >= 0)
+                assertEquals(sizeIfKnown, s1Size + s2Size);
+        }
+
+        asserter.assertContents(fromSplit, exp, isOrdered);
+    }
+
+    private static <T, S extends Spliterator<T>> void testSplitSixDeep(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        S spliterator = supplier.get();
+        boolean isOrdered = spliterator.hasCharacteristics(Spliterator.ORDERED);
+
+        for (int depth=0; depth < 6; depth++) {
+            List<T> dest = new ArrayList<>();
+            spliterator = supplier.get();
+
+            assertSpliterator(spliterator);
+
+            // verify splitting with forEach
+            splitSixDeepVisitor(depth, 0, dest, spliterator, boxingAdapter, spliterator.characteristics(), false);
+            asserter.assertContents(dest, exp, isOrdered);
+
+            // verify splitting with tryAdvance
+            dest.clear();
+            spliterator = supplier.get();
+            splitSixDeepVisitor(depth, 0, dest, spliterator, boxingAdapter, spliterator.characteristics(), true);
+            asserter.assertContents(dest, exp, isOrdered);
+        }
+    }
+
+    private static <T, S extends Spliterator<T>>
+    void splitSixDeepVisitor(int depth, int curLevel,
+                             List<T> dest, S spliterator, UnaryOperator<Consumer<T>> boxingAdapter,
+                             int rootCharacteristics, boolean useTryAdvance) {
+        if (curLevel < depth) {
+            long beforeSize = spliterator.getExactSizeIfKnown();
+            Spliterator<T> split = spliterator.trySplit();
+            if (split != null) {
+                assertSpliterator(split, rootCharacteristics);
+                assertSpliterator(spliterator, rootCharacteristics);
+
+                if ((rootCharacteristics & Spliterator.SUBSIZED) != 0 &&
+                    (rootCharacteristics & Spliterator.SIZED) != 0) {
+                    assertEquals(beforeSize, split.estimateSize() + spliterator.estimateSize());
+                }
+                splitSixDeepVisitor(depth, curLevel + 1, dest, split, boxingAdapter, rootCharacteristics, useTryAdvance);
+            }
+            splitSixDeepVisitor(depth, curLevel + 1, dest, spliterator, boxingAdapter, rootCharacteristics, useTryAdvance);
+        }
+        else {
+            long sizeIfKnown = spliterator.getExactSizeIfKnown();
+            if (useTryAdvance) {
+                Consumer<T> addToDest = boxingAdapter.apply(dest::add);
+                int count = 0;
+                while (spliterator.tryAdvance(addToDest)) {
+                    ++count;
+                }
+
+                if (sizeIfKnown >= 0)
+                    assertEquals(sizeIfKnown, count);
+
+                // Assert that forEach now produces no elements
+                spliterator.forEachRemaining(boxingAdapter.apply(
+                        e -> fail("Spliterator.forEach produced an element after spliterator exhausted: " + e)));
+
+                Spliterator<T> split = spliterator.trySplit();
+                assertNull(split);
+            }
+            else {
+                List<T> leafDest = new ArrayList<>();
+                Consumer<T> addToLeafDest = boxingAdapter.apply(leafDest::add);
+                spliterator.forEachRemaining(addToLeafDest);
+
+                if (sizeIfKnown >= 0)
+                    assertEquals(sizeIfKnown, leafDest.size());
+
+                // Assert that forEach now produces no elements
+                spliterator.tryAdvance(boxingAdapter.apply(
+                        e -> fail("Spliterator.tryAdvance produced an element after spliterator exhausted: " + e)));
+
+                Spliterator<T> split = spliterator.trySplit();
+                assertNull(split);
+
+                dest.addAll(leafDest);
+            }
+        }
+    }
+
+    private static <T, S extends Spliterator<T>> void testSplitUntilNull(
+            Collection<T> exp,
+            Supplier<S> supplier,
+            UnaryOperator<Consumer<T>> boxingAdapter,
+            ContentAsserter<T> asserter) {
+        Spliterator<T> s = supplier.get();
+        boolean isOrdered = s.hasCharacteristics(Spliterator.ORDERED);
+        assertSpliterator(s);
+
+        List<T> splits = new ArrayList<>();
+        Consumer<T> c = boxingAdapter.apply(splits::add);
+
+        testSplitUntilNull(new SplitNode<T>(c, s));
+        asserter.assertContents(splits, exp, isOrdered);
+    }
+
+    private static class SplitNode<T> {
+        // Constant for every node
+        final Consumer<T> c;
+        final int rootCharacteristics;
+
+        final Spliterator<T> s;
+
+        SplitNode(Consumer<T> c, Spliterator<T> s) {
+            this(c, s.characteristics(), s);
+        }
+
+        private SplitNode(Consumer<T> c, int rootCharacteristics, Spliterator<T> s) {
+            this.c = c;
+            this.rootCharacteristics = rootCharacteristics;
+            this.s = s;
+        }
+
+        SplitNode<T> fromSplit(Spliterator<T> split) {
+            return new SplitNode<>(c, rootCharacteristics, split);
+        }
+    }
+
+    /**
+     * Set the maximum stack capacity to 0.25MB. This should be more than enough to detect a bad spliterator
+     * while not unduly disrupting test infrastructure given the test data sizes that are used are small.
+     * Note that j.u.c.ForkJoinPool sets the max queue size to 64M (1 << 26).
+     */
+    private static final int MAXIMUM_STACK_CAPACITY = 1 << 18; // 0.25MB
+
+    private static <T> void testSplitUntilNull(SplitNode<T> e) {
+        // Use an explicit stack to avoid a StackOverflowException when testing a Spliterator
+        // that when repeatedly split produces a right-balanced (and maybe degenerate) tree, or
+        // for a spliterator that is badly behaved.
+        Deque<SplitNode<T>> stack = new ArrayDeque<>();
+        stack.push(e);
+
+        int iteration = 0;
+        while (!stack.isEmpty()) {
+            assertTrue(iteration++ < MAXIMUM_STACK_CAPACITY, "Exceeded maximum stack modification count of 1 << 18");
+
+            e = stack.pop();
+            Spliterator<T> parentAndRightSplit = e.s;
+
+            long parentEstimateSize = parentAndRightSplit.estimateSize();
+            assertTrue(parentEstimateSize >= 0,
+                       String.format("Split size estimate %d < 0", parentEstimateSize));
+
+            long parentSize = parentAndRightSplit.getExactSizeIfKnown();
+            Spliterator<T> leftSplit = parentAndRightSplit.trySplit();
+            if (leftSplit == null) {
+                parentAndRightSplit.forEachRemaining(e.c);
+                continue;
+            }
+
+            assertSpliterator(leftSplit, e.rootCharacteristics);
+            assertSpliterator(parentAndRightSplit, e.rootCharacteristics);
+
+            if (parentEstimateSize != Long.MAX_VALUE && leftSplit.estimateSize() > 0
+                && parentAndRightSplit.estimateSize() > 0) {
+                assertTrue(leftSplit.estimateSize() < parentEstimateSize,
+                           String.format("Left split size estimate %d >= parent split size estimate %d",
+                                         leftSplit.estimateSize(), parentEstimateSize));
+                assertTrue(parentAndRightSplit.estimateSize() < parentEstimateSize,
+                           String.format("Right split size estimate %d >= parent split size estimate %d",
+                                         leftSplit.estimateSize(), parentEstimateSize));
+            }
+            else {
+                assertTrue(leftSplit.estimateSize() <= parentEstimateSize,
+                           String.format("Left split size estimate %d > parent split size estimate %d",
+                                         leftSplit.estimateSize(), parentEstimateSize));
+                assertTrue(parentAndRightSplit.estimateSize() <= parentEstimateSize,
+                           String.format("Right split size estimate %d > parent split size estimate %d",
+                                         leftSplit.estimateSize(), parentEstimateSize));
+            }
+
+            long leftSize = leftSplit.getExactSizeIfKnown();
+            long rightSize = parentAndRightSplit.getExactSizeIfKnown();
+            if (parentSize >= 0 && leftSize >= 0 && rightSize >= 0)
+                assertEquals(parentSize, leftSize + rightSize,
+                             String.format("exact left split size %d + exact right split size %d != parent exact split size %d",
+                                           leftSize, rightSize, parentSize));
+
+            // Add right side to stack first so left side is popped off first
+            stack.push(e.fromSplit(parentAndRightSplit));
+            stack.push(e.fromSplit(leftSplit));
+        }
+    }
+
+    private static void assertSpliterator(Spliterator<?> s, int rootCharacteristics) {
+        if ((rootCharacteristics & Spliterator.SUBSIZED) != 0) {
+            assertTrue(s.hasCharacteristics(Spliterator.SUBSIZED),
+                       "Child split is not SUBSIZED when root split is SUBSIZED");
+        }
+        assertSpliterator(s);
+    }
+
+    private static void assertSpliterator(Spliterator<?> s) {
+        if (s.hasCharacteristics(Spliterator.SUBSIZED)) {
+            assertTrue(s.hasCharacteristics(Spliterator.SIZED));
+        }
+        if (s.hasCharacteristics(Spliterator.SIZED)) {
+            assertTrue(s.estimateSize() != Long.MAX_VALUE);
+            assertTrue(s.getExactSizeIfKnown() >= 0);
+        }
+        try {
+            s.getComparator();
+            assertTrue(s.hasCharacteristics(Spliterator.SORTED));
+        } catch (IllegalStateException e) {
+            assertFalse(s.hasCharacteristics(Spliterator.SORTED));
+        }
+    }
+
+    private static<T> void assertContents(Collection<T> actual, Collection<T> expected, boolean isOrdered) {
+        if (isOrdered) {
+            assertEquals(actual, expected);
+        }
+        else {
+            LambdaTestHelpers.assertContentsUnordered(actual, expected);
+        }
+    }
+
+    public static void assertThrowsNPE(ThrowingRunnable r) {
+        assertThrows(NullPointerException.class, r);
+    }
+
+    public static<U> void mixedTraverseAndSplit(Consumer<U> b, Spliterator<U> splTop) {
+        Spliterator<U> spl1, spl2, spl3;
+        splTop.tryAdvance(b);
+        spl2 = splTop.trySplit();
+        if (spl2 != null) {
+            spl2.tryAdvance(b);
+            spl1 = spl2.trySplit();
+            if (spl1 != null) {
+                spl1.tryAdvance(b);
+                spl1.forEachRemaining(b);
+            }
+            spl2.tryAdvance(b);
+            spl2.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        spl3 = splTop.trySplit();
+        if (spl3 != null) {
+            spl3.tryAdvance(b);
+            spl3.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        splTop.forEachRemaining(b);
+    }
+
+    public static void mixedTraverseAndSplit(IntConsumer b, Spliterator.OfInt splTop) {
+        Spliterator.OfInt spl1, spl2, spl3;
+        splTop.tryAdvance(b);
+        spl2 = splTop.trySplit();
+        if (spl2 != null) {
+            spl2.tryAdvance(b);
+            spl1 = spl2.trySplit();
+            if (spl1 != null) {
+                spl1.tryAdvance(b);
+                spl1.forEachRemaining(b);
+            }
+            spl2.tryAdvance(b);
+            spl2.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        spl3 = splTop.trySplit();
+        if (spl3 != null) {
+            spl3.tryAdvance(b);
+            spl3.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        splTop.forEachRemaining(b);
+    }
+
+    public static void mixedTraverseAndSplit(LongConsumer b, Spliterator.OfLong splTop) {
+        Spliterator.OfLong spl1, spl2, spl3;
+        splTop.tryAdvance(b);
+        spl2 = splTop.trySplit();
+        if (spl2 != null) {
+            spl2.tryAdvance(b);
+            spl1 = spl2.trySplit();
+            if (spl1 != null) {
+                spl1.tryAdvance(b);
+                spl1.forEachRemaining(b);
+            }
+            spl2.tryAdvance(b);
+            spl2.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        spl3 = splTop.trySplit();
+        if (spl3 != null) {
+            spl3.tryAdvance(b);
+            spl3.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        splTop.forEachRemaining(b);
+    }
+
+    public static void mixedTraverseAndSplit(DoubleConsumer b, Spliterator.OfDouble splTop) {
+        Spliterator.OfDouble spl1, spl2, spl3;
+        splTop.tryAdvance(b);
+        spl2 = splTop.trySplit();
+        if (spl2 != null) {
+            spl2.tryAdvance(b);
+            spl1 = spl2.trySplit();
+            if (spl1 != null) {
+                spl1.tryAdvance(b);
+                spl1.forEachRemaining(b);
+            }
+            spl2.tryAdvance(b);
+            spl2.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        spl3 = splTop.trySplit();
+        if (spl3 != null) {
+            spl3.tryAdvance(b);
+            spl3.forEachRemaining(b);
+        }
+        splTop.tryAdvance(b);
+        splTop.forEachRemaining(b);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/CollectorOps.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import org.testng.Assert;
+
+import java.util.Spliterator;
+import java.util.function.IntFunction;
+
+/** Test helper class for java.util.stream test framework */
+public final class CollectorOps {
+    private CollectorOps() { }
+
+    public static <E_IN> StatefulTestOp<E_IN> collector() {
+        return new StatefulCollector<>(0, StreamShape.REFERENCE);
+    }
+
+    /* Utility classes for collecting output of intermediate pipeline stages */
+    public static class StatefulCollector<E_IN> implements StatefulTestOp<E_IN> {
+        private final int opFlags;
+        private final StreamShape inputShape;
+
+        public StatefulCollector(int opFlags, StreamShape inputShape) {
+            this.opFlags = opFlags;
+            this.inputShape = inputShape;
+        }
+
+        @Override
+        public StreamShape inputShape() {
+            return inputShape;
+        }
+
+        @Override
+        public StreamShape outputShape() {
+            return inputShape;
+        }
+
+        @Override
+        public int opGetFlags() {
+            return opFlags;
+        }
+
+        @Override
+        public Sink<E_IN> opWrapSink(int flags, boolean parallel, Sink<E_IN> sink) {
+            return sink;
+        }
+
+        @Override
+        public <P_IN> Node<E_IN> opEvaluateParallel(PipelineHelper<E_IN> helper,
+                                                    Spliterator<P_IN> spliterator,
+                                                    IntFunction<E_IN[]> generator) {
+            return helper.evaluate(spliterator, false, generator);
+        }
+    }
+
+    public static class TestParallelSizedOp<T> extends StatefulCollector<T> {
+        public TestParallelSizedOp() {
+            this(StreamShape.REFERENCE);
+        }
+
+        protected TestParallelSizedOp(StreamShape shape) {
+            super(0, shape);
+        }
+
+        @Override
+        public <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
+                                                 Spliterator<P_IN> spliterator,
+                                                 IntFunction<T[]> generator) {
+            int flags = helper.getStreamAndOpFlags();
+
+            Assert.assertTrue(StreamOpFlag.SIZED.isKnown(flags));
+            return super.opEvaluateParallel(helper, spliterator, generator);
+        }
+
+        public static class OfInt extends TestParallelSizedOp<Integer> {
+            public OfInt() {
+                super(StreamShape.INT_VALUE);
+            }
+        }
+
+        public static class OfLong extends TestParallelSizedOp<Long> {
+            public OfLong() {
+                super(StreamShape.LONG_VALUE);
+            }
+        }
+
+        public static class OfDouble extends TestParallelSizedOp<Double> {
+            public OfDouble() {
+                super(StreamShape.DOUBLE_VALUE);
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/DefaultMethodStreams.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,984 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Comparator;
+import java.util.DoubleSummaryStatistics;
+import java.util.IntSummaryStatistics;
+import java.util.Iterator;
+import java.util.LongSummaryStatistics;
+import java.util.Optional;
+import java.util.OptionalDouble;
+import java.util.OptionalInt;
+import java.util.OptionalLong;
+import java.util.PrimitiveIterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.function.BiConsumer;
+import java.util.function.BiFunction;
+import java.util.function.BinaryOperator;
+import java.util.function.Consumer;
+import java.util.function.DoubleBinaryOperator;
+import java.util.function.DoubleConsumer;
+import java.util.function.DoubleFunction;
+import java.util.function.DoublePredicate;
+import java.util.function.DoubleToIntFunction;
+import java.util.function.DoubleToLongFunction;
+import java.util.function.DoubleUnaryOperator;
+import java.util.function.Function;
+import java.util.function.IntBinaryOperator;
+import java.util.function.IntConsumer;
+import java.util.function.IntFunction;
+import java.util.function.IntPredicate;
+import java.util.function.IntToDoubleFunction;
+import java.util.function.IntToLongFunction;
+import java.util.function.IntUnaryOperator;
+import java.util.function.LongBinaryOperator;
+import java.util.function.LongConsumer;
+import java.util.function.LongFunction;
+import java.util.function.LongPredicate;
+import java.util.function.LongToDoubleFunction;
+import java.util.function.LongToIntFunction;
+import java.util.function.LongUnaryOperator;
+import java.util.function.ObjDoubleConsumer;
+import java.util.function.ObjIntConsumer;
+import java.util.function.ObjLongConsumer;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.function.ToDoubleFunction;
+
+import java.util.function.ToIntFunction;
+import java.util.function.ToLongFunction;
+
+import static java.util.stream.Collectors.*;
+
+public final class DefaultMethodStreams {
+
+    static {
+        // Verify that default methods are not overridden
+        verify(DefaultMethodRefStream.class);
+        verify(DefaultMethodIntStream.class);
+        verify(DefaultMethodLongStream.class);
+        verify(DefaultMethodDoubleStream.class);
+    }
+
+    static void verify(Class<?> del) {
+        // Find the stream interface
+        Class<?> s = Stream.of(del.getInterfaces())
+                .filter(c -> BaseStream.class.isAssignableFrom(c))
+                .findFirst().get();
+
+        // Get all default methods on the stream class
+        Set<String> dms = Stream.of(s.getMethods())
+                .filter(m -> !Modifier.isStatic(m.getModifiers()))
+                .filter(m -> !m.isBridge())
+                .filter(Method::isDefault)
+                .map(Method::getName)
+                .collect(toSet());
+
+        // Get all methods on the delegating class
+        Set<String> ims = Stream.of(del.getMethods())
+                .filter(m -> !Modifier.isStatic(m.getModifiers()))
+                .filter(m -> m.getDeclaringClass() == del)
+                .map(Method::getName)
+                .collect(toSet());
+
+        if (ims.stream().anyMatch(dms::contains)) {
+            throw new AssertionError(String.format("%s overrides default methods of %s\n", del, s));
+        }
+    }
+
+    /**
+     * Creates a stream that for the next operation either delegates to
+     * a default method on {@link Stream}, if present for that operation,
+     * otherwise delegates to an underlying stream.
+     *
+     * @param s the underlying stream to be delegated to for non-default
+     * methods.
+     * @param <T> the type of the stream elements
+     * @return the delegating stream
+     */
+    public static <T> Stream<T> delegateTo(Stream<T> s) {
+        return new DefaultMethodRefStream<>(s);
+    }
+
+    /**
+     * Creates a stream that for the next operation either delegates to
+     * a default method on {@link IntStream}, if present for that operation,
+     * otherwise delegates to an underlying stream.
+     *
+     * @param s the underlying stream to be delegated to for non-default
+     * methods.
+     * @return the delegating stream
+     */
+    public static IntStream delegateTo(IntStream s) {
+        return new DefaultMethodIntStream(s);
+    }
+
+    /**
+     * Creates a stream that for the next operation either delegates to
+     * a default method on {@link LongStream}, if present for that operation,
+     * otherwise delegates to an underlying stream.
+     *
+     * @param s the underlying stream to be delegated to for non-default
+     * methods.
+     * @return the delegating stream
+     */
+    public static LongStream delegateTo(LongStream s) {
+        return new DefaultMethodLongStream(s);
+    }
+
+    /**
+     * Creates a stream that for the next operation either delegates to
+     * a default method on {@link DoubleStream}, if present for that operation,
+     * otherwise delegates to an underlying stream.
+     *
+     * @param s the underlying stream to be delegated to for non-default
+     * methods.
+     * @return the delegating stream
+     */
+    public static DoubleStream delegateTo(DoubleStream s) {
+        return new DefaultMethodDoubleStream(s);
+    }
+
+    /**
+     * A stream that delegates the next operation to a default method, if
+     * present, or to the same operation of an underlying stream.
+     *
+     * @param <T> the type of the stream elements
+     */
+    static final class DefaultMethodRefStream<T> implements Stream<T> {
+        final Stream<T> s;
+
+        DefaultMethodRefStream(Stream<T> s) {
+            this.s = s;
+        }
+
+
+        // Delegating non-default methods
+
+        @Override
+        public Stream<T> filter(Predicate<? super T> predicate) {
+            return s.filter(predicate);
+        }
+
+        @Override
+        public <R> Stream<R> map(Function<? super T, ? extends R> mapper) {
+            return s.map(mapper);
+        }
+
+        @Override
+        public IntStream mapToInt(ToIntFunction<? super T> mapper) {
+            return s.mapToInt(mapper);
+        }
+
+        @Override
+        public LongStream mapToLong(ToLongFunction<? super T> mapper) {
+            return s.mapToLong(mapper);
+        }
+
+        @Override
+        public DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper) {
+            return s.mapToDouble(mapper);
+        }
+
+        @Override
+        public <R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper) {
+            return s.flatMap(mapper);
+        }
+
+        @Override
+        public IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper) {
+            return s.flatMapToInt(mapper);
+        }
+
+        @Override
+        public LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper) {
+            return s.flatMapToLong(mapper);
+        }
+
+        @Override
+        public DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper) {
+            return s.flatMapToDouble(mapper);
+        }
+
+        @Override
+        public Stream<T> distinct() {
+            return s.distinct();
+        }
+
+        @Override
+        public Stream<T> sorted() {
+            return s.sorted();
+        }
+
+        @Override
+        public Stream<T> sorted(Comparator<? super T> comparator) {
+            return s.sorted(comparator);
+        }
+
+        @Override
+        public Stream<T> peek(Consumer<? super T> action) {
+            return s.peek(action);
+        }
+
+        @Override
+        public Stream<T> limit(long maxSize) {
+            return s.limit(maxSize);
+        }
+
+        @Override
+        public Stream<T> skip(long n) {
+            return s.skip(n);
+        }
+
+        @Override
+        public void forEach(Consumer<? super T> action) {
+            s.forEach(action);
+        }
+
+        @Override
+        public void forEachOrdered(Consumer<? super T> action) {
+            s.forEachOrdered(action);
+        }
+
+        @Override
+        public Object[] toArray() {
+            return s.toArray();
+        }
+
+        @Override
+        public <A> A[] toArray(IntFunction<A[]> generator) {
+            return s.toArray(generator);
+        }
+
+        @Override
+        public T reduce(T identity, BinaryOperator<T> accumulator) {
+            return s.reduce(identity, accumulator);
+        }
+
+        @Override
+        public Optional<T> reduce(BinaryOperator<T> accumulator) {
+            return s.reduce(accumulator);
+        }
+
+        @Override
+        public <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) {
+            return s.reduce(identity, accumulator, combiner);
+        }
+
+        @Override
+        public <R> R collect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner) {
+            return s.collect(supplier, accumulator, combiner);
+        }
+
+        @Override
+        public <R, A> R collect(Collector<? super T, A, R> collector) {
+            return s.collect(collector);
+        }
+
+        @Override
+        public Optional<T> min(Comparator<? super T> comparator) {
+            return s.min(comparator);
+        }
+
+        @Override
+        public Optional<T> max(Comparator<? super T> comparator) {
+            return s.max(comparator);
+        }
+
+        @Override
+        public long count() {
+            return s.count();
+        }
+
+        @Override
+        public boolean anyMatch(Predicate<? super T> predicate) {
+            return s.anyMatch(predicate);
+        }
+
+        @Override
+        public boolean allMatch(Predicate<? super T> predicate) {
+            return s.allMatch(predicate);
+        }
+
+        @Override
+        public boolean noneMatch(Predicate<? super T> predicate) {
+            return s.noneMatch(predicate);
+        }
+
+        @Override
+        public Optional<T> findFirst() {
+            return s.findFirst();
+        }
+
+        @Override
+        public Optional<T> findAny() {
+            return s.findAny();
+        }
+
+        @Override
+        public Iterator<T> iterator() {
+            return s.iterator();
+        }
+
+        @Override
+        public Spliterator<T> spliterator() {
+            return s.spliterator();
+        }
+
+        @Override
+        public boolean isParallel() {
+            return s.isParallel();
+        }
+
+        @Override
+        public Stream<T> sequential() {
+            return s.sequential();
+        }
+
+        @Override
+        public Stream<T> parallel() {
+            return s.parallel();
+        }
+
+        @Override
+        public Stream<T> unordered() {
+            return s.unordered();
+        }
+
+        @Override
+        public Stream<T> onClose(Runnable closeHandler) {
+            return s.onClose(closeHandler);
+        }
+
+        @Override
+        public void close() {
+            s.close();
+        }
+    }
+
+    static final class DefaultMethodIntStream implements IntStream {
+        final IntStream s;
+
+        public DefaultMethodIntStream(IntStream s) {
+            this.s = s;
+        }
+
+
+        // Delegating non-default methods
+
+        @Override
+        public IntStream filter(IntPredicate predicate) {
+            return s.filter(predicate);
+        }
+
+        @Override
+        public IntStream map(IntUnaryOperator mapper) {
+            return s.map(mapper);
+        }
+
+        @Override
+        public <U> Stream<U> mapToObj(IntFunction<? extends U> mapper) {
+            return s.mapToObj(mapper);
+        }
+
+        @Override
+        public LongStream mapToLong(IntToLongFunction mapper) {
+            return s.mapToLong(mapper);
+        }
+
+        @Override
+        public DoubleStream mapToDouble(IntToDoubleFunction mapper) {
+            return s.mapToDouble(mapper);
+        }
+
+        @Override
+        public IntStream flatMap(IntFunction<? extends IntStream> mapper) {
+            return s.flatMap(mapper);
+        }
+
+        @Override
+        public IntStream distinct() {
+            return s.distinct();
+        }
+
+        @Override
+        public IntStream sorted() {
+            return s.sorted();
+        }
+
+        @Override
+        public IntStream peek(IntConsumer action) {
+            return s.peek(action);
+        }
+
+        @Override
+        public IntStream limit(long maxSize) {
+            return s.limit(maxSize);
+        }
+
+        @Override
+        public IntStream skip(long n) {
+            return s.skip(n);
+        }
+
+        @Override
+        public void forEach(IntConsumer action) {
+            s.forEach(action);
+        }
+
+        @Override
+        public void forEachOrdered(IntConsumer action) {
+            s.forEachOrdered(action);
+        }
+
+        @Override
+        public int[] toArray() {
+            return s.toArray();
+        }
+
+        @Override
+        public int reduce(int identity, IntBinaryOperator op) {
+            return s.reduce(identity, op);
+        }
+
+        @Override
+        public OptionalInt reduce(IntBinaryOperator op) {
+            return s.reduce(op);
+        }
+
+        @Override
+        public <R> R collect(Supplier<R> supplier, ObjIntConsumer<R> accumulator, BiConsumer<R, R> combiner) {
+            return s.collect(supplier, accumulator, combiner);
+        }
+
+        @Override
+        public int sum() {
+            return s.sum();
+        }
+
+        @Override
+        public OptionalInt min() {
+            return s.min();
+        }
+
+        @Override
+        public OptionalInt max() {
+            return s.max();
+        }
+
+        @Override
+        public long count() {
+            return s.count();
+        }
+
+        @Override
+        public OptionalDouble average() {
+            return s.average();
+        }
+
+        @Override
+        public IntSummaryStatistics summaryStatistics() {
+            return s.summaryStatistics();
+        }
+
+        @Override
+        public boolean anyMatch(IntPredicate predicate) {
+            return s.anyMatch(predicate);
+        }
+
+        @Override
+        public boolean allMatch(IntPredicate predicate) {
+            return s.allMatch(predicate);
+        }
+
+        @Override
+        public boolean noneMatch(IntPredicate predicate) {
+            return s.noneMatch(predicate);
+        }
+
+        @Override
+        public OptionalInt findFirst() {
+            return s.findFirst();
+        }
+
+        @Override
+        public OptionalInt findAny() {
+            return s.findAny();
+        }
+
+        @Override
+        public LongStream asLongStream() {
+            return s.asLongStream();
+        }
+
+        @Override
+        public DoubleStream asDoubleStream() {
+            return s.asDoubleStream();
+        }
+
+        @Override
+        public Stream<Integer> boxed() {
+            return s.boxed();
+        }
+
+        @Override
+        public IntStream sequential() {
+            return s.sequential();
+        }
+
+        @Override
+        public IntStream parallel() {
+            return s.parallel();
+        }
+
+        @Override
+        public PrimitiveIterator.OfInt iterator() {
+            return s.iterator();
+        }
+
+        @Override
+        public Spliterator.OfInt spliterator() {
+            return s.spliterator();
+        }
+
+        @Override
+        public boolean isParallel() {
+            return s.isParallel();
+        }
+
+        @Override
+        public IntStream unordered() {
+            return s.unordered();
+        }
+
+        @Override
+        public IntStream onClose(Runnable closeHandler) {
+            return s.onClose(closeHandler);
+        }
+
+        @Override
+        public void close() {
+            s.close();
+        }
+    }
+
+    static final class DefaultMethodLongStream implements LongStream {
+        final LongStream s;
+
+        public DefaultMethodLongStream(LongStream s) {
+            this.s = s;
+        }
+
+
+        // Delegating non-default methods
+
+        @Override
+        public void forEach(LongConsumer action) {
+            s.forEach(action);
+        }
+
+        @Override
+        public LongStream filter(LongPredicate predicate) {
+            return s.filter(predicate);
+        }
+
+        @Override
+        public LongStream map(LongUnaryOperator mapper) {
+            return s.map(mapper);
+        }
+
+        @Override
+        public <U> Stream<U> mapToObj(LongFunction<? extends U> mapper) {
+            return s.mapToObj(mapper);
+        }
+
+        @Override
+        public IntStream mapToInt(LongToIntFunction mapper) {
+            return s.mapToInt(mapper);
+        }
+
+        @Override
+        public DoubleStream mapToDouble(LongToDoubleFunction mapper) {
+            return s.mapToDouble(mapper);
+        }
+
+        @Override
+        public LongStream flatMap(LongFunction<? extends LongStream> mapper) {
+            return s.flatMap(mapper);
+        }
+
+        @Override
+        public LongStream distinct() {
+            return s.distinct();
+        }
+
+        @Override
+        public LongStream sorted() {
+            return s.sorted();
+        }
+
+        @Override
+        public LongStream peek(LongConsumer action) {
+            return s.peek(action);
+        }
+
+        @Override
+        public LongStream limit(long maxSize) {
+            return s.limit(maxSize);
+        }
+
+        @Override
+        public LongStream skip(long n) {
+            return s.skip(n);
+        }
+
+        @Override
+        public void forEachOrdered(LongConsumer action) {
+            s.forEachOrdered(action);
+        }
+
+        @Override
+        public long[] toArray() {
+            return s.toArray();
+        }
+
+        @Override
+        public long reduce(long identity, LongBinaryOperator op) {
+            return s.reduce(identity, op);
+        }
+
+        @Override
+        public OptionalLong reduce(LongBinaryOperator op) {
+            return s.reduce(op);
+        }
+
+        @Override
+        public <R> R collect(Supplier<R> supplier, ObjLongConsumer<R> accumulator, BiConsumer<R, R> combiner) {
+            return s.collect(supplier, accumulator, combiner);
+        }
+
+        @Override
+        public long sum() {
+            return s.sum();
+        }
+
+        @Override
+        public OptionalLong min() {
+            return s.min();
+        }
+
+        @Override
+        public OptionalLong max() {
+            return s.max();
+        }
+
+        @Override
+        public long count() {
+            return s.count();
+        }
+
+        @Override
+        public OptionalDouble average() {
+            return s.average();
+        }
+
+        @Override
+        public LongSummaryStatistics summaryStatistics() {
+            return s.summaryStatistics();
+        }
+
+        @Override
+        public boolean anyMatch(LongPredicate predicate) {
+            return s.anyMatch(predicate);
+        }
+
+        @Override
+        public boolean allMatch(LongPredicate predicate) {
+            return s.allMatch(predicate);
+        }
+
+        @Override
+        public boolean noneMatch(LongPredicate predicate) {
+            return s.noneMatch(predicate);
+        }
+
+        @Override
+        public OptionalLong findFirst() {
+            return s.findFirst();
+        }
+
+        @Override
+        public OptionalLong findAny() {
+            return s.findAny();
+        }
+
+        @Override
+        public DoubleStream asDoubleStream() {
+            return s.asDoubleStream();
+        }
+
+        @Override
+        public Stream<Long> boxed() {
+            return s.boxed();
+        }
+
+        @Override
+        public LongStream sequential() {
+            return s.sequential();
+        }
+
+        @Override
+        public LongStream parallel() {
+            return s.parallel();
+        }
+
+        @Override
+        public PrimitiveIterator.OfLong iterator() {
+            return s.iterator();
+        }
+
+        @Override
+        public Spliterator.OfLong spliterator() {
+            return s.spliterator();
+        }
+
+        @Override
+        public boolean isParallel() {
+            return s.isParallel();
+        }
+
+        @Override
+        public LongStream unordered() {
+            return s.unordered();
+        }
+
+        @Override
+        public LongStream onClose(Runnable closeHandler) {
+            return s.onClose(closeHandler);
+        }
+
+        @Override
+        public void close() {
+            s.close();
+        }
+    }
+
+    static final class DefaultMethodDoubleStream implements DoubleStream {
+        final DoubleStream s;
+
+        public DefaultMethodDoubleStream(DoubleStream s) {
+            this.s = s;
+        }
+
+        @Override
+        public DoubleStream filter(DoublePredicate predicate) {
+            return s.filter(predicate);
+        }
+
+        @Override
+        public DoubleStream map(DoubleUnaryOperator mapper) {
+            return s.map(mapper);
+        }
+
+        @Override
+        public <U> Stream<U> mapToObj(DoubleFunction<? extends U> mapper) {
+            return s.mapToObj(mapper);
+        }
+
+        @Override
+        public IntStream mapToInt(DoubleToIntFunction mapper) {
+            return s.mapToInt(mapper);
+        }
+
+        @Override
+        public LongStream mapToLong(DoubleToLongFunction mapper) {
+            return s.mapToLong(mapper);
+        }
+
+        @Override
+        public DoubleStream flatMap(DoubleFunction<? extends DoubleStream> mapper) {
+            return s.flatMap(mapper);
+        }
+
+        @Override
+        public DoubleStream distinct() {
+            return s.distinct();
+        }
+
+        @Override
+        public DoubleStream sorted() {
+            return s.sorted();
+        }
+
+        @Override
+        public DoubleStream peek(DoubleConsumer action) {
+            return s.peek(action);
+        }
+
+        @Override
+        public DoubleStream limit(long maxSize) {
+            return s.limit(maxSize);
+        }
+
+        @Override
+        public DoubleStream skip(long n) {
+            return s.skip(n);
+        }
+
+        @Override
+        public void forEach(DoubleConsumer action) {
+            s.forEach(action);
+        }
+
+        @Override
+        public void forEachOrdered(DoubleConsumer action) {
+            s.forEachOrdered(action);
+        }
+
+        @Override
+        public double[] toArray() {
+            return s.toArray();
+        }
+
+        @Override
+        public double reduce(double identity, DoubleBinaryOperator op) {
+            return s.reduce(identity, op);
+        }
+
+        @Override
+        public OptionalDouble reduce(DoubleBinaryOperator op) {
+            return s.reduce(op);
+        }
+
+        @Override
+        public <R> R collect(Supplier<R> supplier, ObjDoubleConsumer<R> accumulator, BiConsumer<R, R> combiner) {
+            return s.collect(supplier, accumulator, combiner);
+        }
+
+        @Override
+        public double sum() {
+            return s.sum();
+        }
+
+        @Override
+        public OptionalDouble min() {
+            return s.min();
+        }
+
+        @Override
+        public OptionalDouble max() {
+            return s.max();
+        }
+
+        @Override
+        public long count() {
+            return s.count();
+        }
+
+        @Override
+        public OptionalDouble average() {
+            return s.average();
+        }
+
+        @Override
+        public DoubleSummaryStatistics summaryStatistics() {
+            return s.summaryStatistics();
+        }
+
+        @Override
+        public boolean anyMatch(DoublePredicate predicate) {
+            return s.anyMatch(predicate);
+        }
+
+        @Override
+        public boolean allMatch(DoublePredicate predicate) {
+            return s.allMatch(predicate);
+        }
+
+        @Override
+        public boolean noneMatch(DoublePredicate predicate) {
+            return s.noneMatch(predicate);
+        }
+
+        @Override
+        public OptionalDouble findFirst() {
+            return s.findFirst();
+        }
+
+        @Override
+        public OptionalDouble findAny() {
+            return s.findAny();
+        }
+
+        @Override
+        public Stream<Double> boxed() {
+            return s.boxed();
+        }
+
+        @Override
+        public DoubleStream sequential() {
+            return s.sequential();
+        }
+
+        @Override
+        public DoubleStream parallel() {
+            return s.parallel();
+        }
+
+        @Override
+        public PrimitiveIterator.OfDouble iterator() {
+            return s.iterator();
+        }
+
+        @Override
+        public Spliterator.OfDouble spliterator() {
+            return s.spliterator();
+        }
+
+        @Override
+        public boolean isParallel() {
+            return s.isParallel();
+        }
+
+        @Override
+        public DoubleStream unordered() {
+            return s.unordered();
+        }
+
+        @Override
+        public DoubleStream onClose(Runnable closeHandler) {
+            return s.onClose(closeHandler);
+        }
+
+        @Override
+        public void close() {
+            s.close();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/DoubleStreamTestDataProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+
+/** TestNG DataProvider for double-valued streams */
+public class DoubleStreamTestDataProvider {
+    private static final double[] to0 = new double[0];
+    private static final double[] to1 = new double[1];
+    private static final double[] to10 = new double[10];
+    private static final double[] to100 = new double[100];
+    private static final double[] to1000 = new double[1000];
+    private static final double[] reversed = new double[100];
+    private static final double[] ones = new double[100];
+    private static final double[] twice = new double[200];
+    private static final double[] pseudoRandom;
+
+    private static final Object[][] testData;
+    private static final Object[][] testSmallData;
+    private static final Object[][] spliteratorTestData;
+
+    static {
+        double[][] arrays = {to0, to1, to10, to100, to1000};
+        for (double[] arr : arrays) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = i;
+            }
+        }
+        for (int i = 0; i < reversed.length; i++) {
+            reversed[i] = reversed.length - i;
+        }
+        for (int i = 0; i < ones.length; i++) {
+            ones[i] = 1;
+        }
+        System.arraycopy(to100, 0, twice, 0, to100.length);
+        System.arraycopy(to100, 0, twice, to100.length, to100.length);
+        pseudoRandom = new double[LambdaTestHelpers.LONG_STRING.length()];
+        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+            pseudoRandom[i] = (double) LambdaTestHelpers.LONG_STRING.charAt(i);
+        }
+    }
+
+    static final Object[][] arrays = {
+            {"empty", to0},
+            {"0..1", to1},
+            {"0..10", to10},
+            {"0..100", to100},
+            {"0..1000", to1000},
+            {"100x[1]", ones},
+            {"2x[0..100]", twice},
+            {"reverse 0..100", reversed},
+            {"pseudorandom", pseudoRandom}
+    };
+
+    static {
+        {
+            List<Object[]> listSmall = new ArrayList<>();
+            List<Object[]> list1000 = new ArrayList<>();
+            List<Object[]> list = null;
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final double[] doubles = (double[]) data[1];
+
+                list = doubles.length >= 1000 ? list1000 : listSmall;
+
+                list.add(new Object[]{"array:" + name,
+                        TestData.Factory.ofArray("array:" + name, doubles)});
+
+                SpinedBuffer.OfDouble isl = new SpinedBuffer.OfDouble();
+                for (double i : doubles) {
+                    isl.accept(i);
+                }
+                list.add(new Object[]{"SpinedList:" + name,
+                        TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
+            }
+            testSmallData = listSmall.toArray(new Object[0][]);
+            list1000.addAll(listSmall);
+            testData = list1000.toArray(new Object[0][]);
+        }
+
+        {
+            List<Object[]> spliterators = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final double[] doubles = (double[]) data[1];
+
+                SpinedBuffer.OfDouble isl = new SpinedBuffer.OfDouble();
+                for (double i : doubles) {
+                    isl.accept(i);
+                }
+
+                spliterators.add(splitDescr("Arrays.s(array):" + name,
+                                            () -> Arrays.spliterator(doubles)));
+                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
+                                            () -> Arrays.spliterator(doubles, 0, doubles.length / 2)));
+
+                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+                                            () -> isl.spliterator()));
+
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
+                                            () -> Spliterators.spliterator(isl.iterator(), doubles.length, 0)));
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
+                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
+                spliterators.add(splitDescr("DoubleStream.iterate(0,x->x<l;x->x+1):" + name,
+                                            () -> DoubleStream.iterate(0.0, x -> x < doubles.length, x -> x + 1.0)
+                                                              .spliterator()));
+                // Need more!
+            }
+            spliteratorTestData = spliterators.toArray(new Object[0][]);
+        }
+
+    }
+
+    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfDouble> s) {
+        return new Object[] { description, s };
+    }
+
+    // Return an array of ( String name, DoubleStreamTestData )
+    @DataProvider(name = "DoubleStreamTestData")
+    public static Object[][] makeDoubleStreamTestData() {
+        return testData;
+    }
+
+    @DataProvider(name = "DoubleStreamTestData.small")
+    public static Object[][] makeSmallDoubleStreamTestData() {
+        return testSmallData;
+    }
+
+    // returns an array of (String name, Supplier<PrimitiveSpliterator<Double>>)
+    @DataProvider(name = "DoubleSpliterator")
+    public static Object[][] spliteratorProvider() {
+        return spliteratorTestData;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/DoubleStreamTestScenario.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.PrimitiveIterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.SpliteratorTestHelper;
+import java.util.function.Consumer;
+import java.util.function.DoubleConsumer;
+import java.util.function.Function;
+
+/**
+ * Test scenarios for double streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results.  Each scenario describes a different way of computing the
+ * stream contents.  The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum DoubleStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+    STREAM_FOR_EACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            DoubleStream s = m.apply(source);
+            if (s.isParallel()) {
+                s = s.sequential();
+            }
+            s.forEach(b);
+        }
+    },
+
+    STREAM_TO_ARRAY(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (double t : m.apply(source).toArray()) {
+                b.accept(t);
+            }
+        }
+    },
+
+    STREAM_ITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (PrimitiveIterator.OfDouble seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
+                b.accept(seqIter.nextDouble());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (Spliterator.OfDouble spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR_FOREACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            m.apply(source).sequential().forEach(b);
+        }
+    },
+
+    // Wrap as parallel stream + forEachOrdered
+    PAR_STREAM_FOR_EACH_ORDERED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            // @@@ Want to explicitly select ordered equalator
+            m.apply(source).forEachOrdered(b);
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (Spliterator.OfDouble spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR_FOREACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            for (double t : m.apply(source).toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            DoubleStream s = m.apply(source);
+            Spliterator.OfDouble sp = s.spliterator();
+            DoubleStream ss = StreamSupport.doubleStream(() -> sp,
+                                                         StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+                                                         | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
+            for (double t : ss.toArray())
+                b.accept(t);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            DoubleStream pipe2 = m.apply(pipe1);
+
+            for (double t : pipe2.toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing
+    PAR_STREAM_FOR_EACH(true, false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            m.apply(source).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
+    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            m.apply(pipe1).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+    ;
+
+    // The set of scenarios that clean the SIZED flag
+    public static final Set<DoubleStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
+            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
+
+    private boolean isParallel;
+
+    private final boolean isOrdered;
+
+    DoubleStreamTestScenario(boolean isParallel) {
+        this(isParallel, true);
+    }
+
+    DoubleStreamTestScenario(boolean isParallel, boolean isOrdered) {
+        this.isParallel = isParallel;
+        this.isOrdered = isOrdered;
+    }
+
+    public StreamShape getShape() {
+        return StreamShape.DOUBLE_VALUE;
+    }
+
+    public boolean isParallel() {
+        return isParallel;
+    }
+
+    public boolean isOrdered() {
+        return isOrdered;
+    }
+
+    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+        try (S_IN source = getStream(data)) {
+            run(data, source, (DoubleConsumer) b, (Function<S_IN, DoubleStream>) m);
+        }
+    }
+
+    abstract <T, S_IN extends BaseStream<T, S_IN>>
+    void run(TestData<T, S_IN> data, S_IN source, DoubleConsumer b, Function<S_IN, DoubleStream> m);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/FlagDeclaringOp.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+/**
+ * An operation that injects or clears flags but otherwise performs no operation on elements.
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class FlagDeclaringOp<T> implements StatelessTestOp<T, T> {
+    private final int flags;
+    private final StreamShape shape;
+
+    public FlagDeclaringOp(int flags) {
+        this(flags, StreamShape.REFERENCE);
+    }
+
+    public FlagDeclaringOp(int flags, StreamShape shape) {
+        this.flags = flags;
+        this.shape = shape;
+    }
+
+    @Override
+    public StreamShape outputShape() {
+        return shape;
+    }
+
+    @Override
+    public StreamShape inputShape() {
+        return shape;
+    }
+
+    @Override
+    public int opGetFlags() {
+        return flags;
+    }
+
+    @Override
+    public Sink<T> opWrapSink(int flags, boolean parallel, Sink sink) {
+        return sink;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/IntStreamTestDataProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+
+/** TestNG DataProvider for int-valued streams */
+public class IntStreamTestDataProvider {
+    private static final int[] to0 = new int[0];
+    private static final int[] to1 = new int[1];
+    private static final int[] to10 = new int[10];
+    private static final int[] to100 = new int[100];
+    private static final int[] to1000 = new int[1000];
+    private static final int[] reversed = new int[100];
+    private static final int[] ones = new int[100];
+    private static final int[] twice = new int[200];
+    private static final int[] pseudoRandom;
+
+    private static final Object[][] testData;
+    private static final Object[][] testSmallData;
+    private static final Object[][] spliteratorTestData;
+
+    static {
+        int[][] arrays = {to0, to1, to10, to100, to1000};
+        for (int[] arr : arrays) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = i;
+            }
+        }
+        for (int i = 0; i < reversed.length; i++) {
+            reversed[i] = reversed.length - i;
+        }
+        for (int i = 0; i < ones.length; i++) {
+            ones[i] = 1;
+        }
+        System.arraycopy(to100, 0, twice, 0, to100.length);
+        System.arraycopy(to100, 0, twice, to100.length, to100.length);
+        pseudoRandom = new int[LambdaTestHelpers.LONG_STRING.length()];
+        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+            pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
+        }
+    }
+
+    static final Object[][] arrays = {
+            {"empty", to0},
+            {"0..1", to1},
+            {"0..10", to10},
+            {"0..100", to100},
+            {"0..1000", to1000},
+            {"100x[1]", ones},
+            {"2x[0..100]", twice},
+            {"reverse 0..100", reversed},
+            {"pseudorandom", pseudoRandom}
+    };
+
+    static {
+        {
+            List<Object[]> listSmall = new ArrayList<>();
+            List<Object[]> list1000 = new ArrayList<>();
+            List<Object[]> list = null;
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final int[] ints = (int[]) data[1];
+
+                list = ints.length >= 1000 ? list1000 : listSmall;
+
+                list.add(new Object[]{"array:" +
+                                      name, TestData.Factory.ofArray("array:" + name, ints)});
+
+                SpinedBuffer.OfInt isl = new SpinedBuffer.OfInt();
+                for (int i : ints) {
+                    isl.accept(i);
+                }
+                list.add(new Object[]{"SpinedList:" + name,
+                         TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
+
+                list.add(streamDataDescr("IntStream.intRange(0,l): " + ints.length,
+                                         () -> IntStream.range(0, ints.length)));
+                list.add(streamDataDescr("IntStream.rangeClosed(0,l): " + ints.length,
+                                         () -> IntStream.rangeClosed(0, ints.length)));
+            }
+            testSmallData = listSmall.toArray(new Object[0][]);
+            list1000.addAll(listSmall);
+            testData = list1000.toArray(new Object[0][]);
+        }
+
+        {
+            List<Object[]> spliterators = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final int[] ints = (int[]) data[1];
+
+                SpinedBuffer.OfInt isl = new SpinedBuffer.OfInt();
+                for (int i : ints) {
+                    isl.accept(i);
+                }
+
+                spliterators.add(splitDescr("Arrays.s(array):" + name,
+                                            () -> Arrays.spliterator(ints)));
+                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
+                                            () -> Arrays.spliterator(ints, 0, ints.length / 2)));
+
+                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+                                            () -> isl.spliterator()));
+
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
+                                            () -> Spliterators.spliterator(isl.iterator(), ints.length, 0)));
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
+                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
+
+                spliterators.add(splitDescr("IntStream.intRange(0,l):" + name,
+                                            () -> IntStream.range(0, ints.length).spliterator()));
+                spliterators.add(splitDescr("IntStream.intRangeClosed(0,l):" + name,
+                                            () -> IntStream.rangeClosed(0, ints.length).spliterator()));
+                spliterators.add(splitDescr("IntStream.iterate(0,x->x<l,x->x+1): " + name,
+                                            () -> IntStream.iterate(0, x -> x < ints.length, x -> x + 1).spliterator()));
+                // Need more!
+            }
+            spliteratorTestData = spliterators.toArray(new Object[0][]);
+        }
+
+    }
+
+    static <T> Object[] streamDataDescr(String description, Supplier<IntStream> s) {
+        return new Object[] { description, TestData.Factory.ofIntSupplier(description, s) };
+    }
+
+    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfInt> s) {
+        return new Object[] { description, s };
+    }
+
+    // Return an array of ( String name, IntStreamTestData )
+    @DataProvider(name = "IntStreamTestData")
+    public static Object[][] makeIntStreamTestData() {
+        return testData;
+    }
+
+    @DataProvider(name = "IntStreamTestData.small")
+    public static Object[][] makeSmallIntStreamTestData() {
+        return testSmallData;
+    }
+
+    // returns an array of (String name, Supplier<PrimitiveSpliterator<Integer>>)
+    @DataProvider(name = "IntSpliterator")
+    public static Object[][] spliteratorProvider() {
+        return spliteratorTestData;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/IntStreamTestScenario.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,234 @@
+/*
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.PrimitiveIterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.SpliteratorTestHelper;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.IntConsumer;
+
+/**
+ * Test scenarios for int streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results.  Each scenario describes a different way of computing the
+ * stream contents.  The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum IntStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+    STREAM_FOR_EACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            IntStream s = m.apply(source);
+            if (s.isParallel()) {
+                s = s.sequential();
+            }
+            s.forEach(b);
+        }
+    },
+
+    STREAM_TO_ARRAY(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (int t : m.apply(source).toArray()) {
+                b.accept(t);
+            }
+        }
+    },
+
+    STREAM_ITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (PrimitiveIterator.OfInt seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
+                b.accept(seqIter.nextInt());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (Spliterator.OfInt spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR_FOREACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            m.apply(source).sequential().forEach(b);
+        }
+    },
+
+    // Wrap as parallel stream + forEachOrdered
+    PAR_STREAM_FOR_EACH_ORDERED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            // @@@ Want to explicitly select ordered equalator
+            m.apply(source).forEachOrdered(b);
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (Spliterator.OfInt spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR_FOREACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            for (int t : m.apply(source).toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            IntStream s = m.apply(source);
+            Spliterator.OfInt sp = s.spliterator();
+            IntStream ss = StreamSupport.intStream(() -> sp,
+                                                   StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+                                                   | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED),
+                                                   true);
+            for (int t : ss.toArray())
+                b.accept(t);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            IntStream pipe2 = m.apply(pipe1);
+
+            for (int t : pipe2.toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing
+    PAR_STREAM_FOR_EACH(true, false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            m.apply(source).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
+    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            m.apply(pipe1).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+    ;
+
+    // The set of scenarios that clean the SIZED flag
+    public static final Set<IntStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
+            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
+
+    private final boolean isParallel;
+
+    private final boolean isOrdered;
+
+    IntStreamTestScenario(boolean isParallel) {
+        this(isParallel, true);
+    }
+
+    IntStreamTestScenario(boolean isParallel, boolean isOrdered) {
+        this.isParallel = isParallel;
+        this.isOrdered = isOrdered;
+    }
+
+    public StreamShape getShape() {
+        return StreamShape.INT_VALUE;
+    }
+
+    public boolean isParallel() {
+        return isParallel;
+    }
+
+    public boolean isOrdered() {
+        return isOrdered;
+    }
+
+    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+        try (S_IN source = getStream(data)) {
+            run(data, source, (IntConsumer) b, (Function<S_IN, IntStream>) m);
+        }
+    }
+
+    abstract <T, S_IN extends BaseStream<T, S_IN>>
+    void run(TestData<T, S_IN> data, S_IN source, IntConsumer b, Function<S_IN, IntStream> m);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/IntermediateTestOp.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+/**
+ * A base type for test operations
+ */
+interface IntermediateTestOp<E_IN, E_OUT> {
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static<T> AbstractPipeline chain(AbstractPipeline upstream,
+                                            IntermediateTestOp<?, T> op) {
+        if (op instanceof StatelessTestOp)
+            return StatelessTestOp.chain(upstream, (StatelessTestOp) op);
+
+        if (op instanceof StatefulTestOp)
+            return StatefulTestOp.chain(upstream, (StatefulTestOp) op);
+
+        throw new IllegalStateException("Unknown test op type: " + op.getClass().getName());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LambdaTestHelpers.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,473 @@
+/*
+ * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.*;
+import java.util.function.BiConsumer;
+import java.util.function.BiPredicate;
+import java.util.function.BinaryOperator;
+import java.util.function.Consumer;
+import java.util.function.DoubleBinaryOperator;
+import java.util.function.DoubleConsumer;
+import java.util.function.DoublePredicate;
+import java.util.function.Function;
+import java.util.function.IntBinaryOperator;
+import java.util.function.IntConsumer;
+import java.util.function.IntFunction;
+import java.util.function.IntPredicate;
+import java.util.function.IntUnaryOperator;
+import java.util.function.LongBinaryOperator;
+import java.util.function.LongConsumer;
+import java.util.function.LongPredicate;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.function.ToDoubleFunction;
+import java.util.function.ToIntFunction;
+import java.util.function.ToLongFunction;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.assertFalse;
+
+/**
+ * LambdaTestHelpers -- assertion methods and useful objects for lambda test cases
+ */
+public class LambdaTestHelpers {
+    public static final String LONG_STRING = "When in the Course of human events it becomes necessary for one people to dissolve the political bands which have connected them with another and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.";
+
+    @SuppressWarnings("rawtypes")
+    public static final Consumer bEmpty = x -> {  };
+    @SuppressWarnings("rawtypes")
+    public static final IntConsumer bIntEmpty = x -> {  };
+    @SuppressWarnings("rawtypes")
+    public static final BiConsumer bBiEmpty = (x,y) -> { };
+    @SuppressWarnings("rawtypes")
+    public static final Consumer bHashCode = x -> { Objects.hashCode(x); };
+    @SuppressWarnings("rawtypes")
+    public static final BiConsumer bBiHashCode = (x,y) -> { Objects.hash(x, y); };
+    public static final Function<Integer, Integer> mZero = x -> 0;
+    public static final Function<Integer, Integer> mId = x -> x;
+    public static final Function<Integer, Integer> mDoubler = x -> x * 2;
+    public static final Function<Integer, Stream<Integer>> mfId = e -> Collections.singletonList(e).stream();
+    public static final Function<Integer, Stream<Integer>> mfNull = e -> Collections.<Integer>emptyList().stream();
+    public static final Function<Integer, Stream<Integer>> mfLt = e -> {
+        List<Integer> l = new ArrayList<>();
+        for (int i=0; i<e; i++)
+            l.add(i);
+        return l.stream();
+    };
+    public static final ToIntFunction<Integer> imDoubler = x -> x * 2;
+    public static final ToLongFunction<Long> lmDoubler = x -> x * 2;
+    public static final ToDoubleFunction<Double> dmDoubler = x -> x * 2;
+    public static final Predicate<Integer> pFalse = x -> false;
+    public static final Predicate<Integer> pTrue = x -> true;
+    public static final Predicate<Integer> pEven = x -> 0 == x % 2;
+    public static final Predicate<Integer> pOdd = x -> 1 == x % 2;
+    public static final IntPredicate ipFalse = x -> false;
+    public static final IntPredicate ipTrue = x -> true;
+    public static final IntPredicate ipEven = x -> 0 == x % 2;
+    public static final IntPredicate ipOdd = x -> 1 == x % 2;
+    public static final LongPredicate lpFalse = x -> false;
+    public static final LongPredicate lpTrue = x -> true;
+    public static final LongPredicate lpEven = x -> 0 == x % 2;
+    public static final LongPredicate lpOdd = x -> 1 == x % 2;
+    public static final DoublePredicate dpFalse = x -> false;
+    public static final DoublePredicate dpTrue = x -> true;
+    public static final DoublePredicate dpEven = x -> 0 == ((long) x) % 2;
+    public static final DoublePredicate dpOdd = x -> 1 == ((long) x) % 2;
+    public static final BinaryOperator<Integer> rPlus = (x, y) -> x+y;
+    public static final BinaryOperator<Integer> rMax = (x, y) -> Math.max(x, y);
+    public static final BinaryOperator<Integer> rMin = (x, y) -> Math.min(x,y);
+    public static final IntBinaryOperator irPlus = (x, y) -> x+y;
+    public static final IntBinaryOperator irMax = (x, y) -> Math.max(x, y);
+    public static final IntBinaryOperator irMin = (x, y) -> Math.min(x,y);
+    public static final IntUnaryOperator irDoubler = x -> x * 2;
+    public static final LongBinaryOperator lrPlus = (x, y) -> x+y;
+    public static final DoubleBinaryOperator drPlus = (x, y) -> x+y;
+    public static final Comparator<Integer> cInteger = (a, b) -> Integer.compare(a, b);
+    public static final BiPredicate<?, ?> bipFalse = (x, y) -> false;
+    public static final BiPredicate<?, ?> bipTrue = (x, y) -> true;
+    public static final BiPredicate<Integer, Integer> bipBothEven = (x, y) -> 0 == (x % 2 + y % 2);
+    public static final BiPredicate<Integer, Integer> bipBothOdd = (x, y) -> 2 == (x % 2 + y % 2);
+    public static final BiPredicate<?, ?> bipSameString = (x, y) -> String.valueOf(x).equals(String.valueOf(y));
+
+    public static final IntFunction<Integer[]> integerArrayGenerator = s -> new Integer[s];
+
+    public static final IntFunction<Object[]> objectArrayGenerator = s -> new Object[s];
+
+    public static final Function<String, Stream<Character>> flattenChars = string -> {
+        List<Character> l = new ArrayList<>();
+        for (int i=0; i<string.length(); i++)
+            l.add(string.charAt(i));
+        return l.stream();
+    };
+
+    public static final Function<String, IntStream> flattenInt
+            = string -> IntStream.range(0, string.length()).map(string::charAt);
+
+    public static <T, R> Function<T, R> forPredicate(Predicate<? super T> predicate, R forTrue, R forFalse) {
+        Objects.requireNonNull(predicate);
+
+        return t -> predicate.test(t) ? forTrue : forFalse;
+    }
+
+    public static <T> Function<T, T> identity() {
+        return t -> t;
+    }
+
+    public static<V, T, R> Function<V, R> compose(Function<? super T, ? extends R> after, Function<? super V, ? extends T> before) {
+        Objects.requireNonNull(before);
+        return (V v) -> after.apply(before.apply(v));
+    }
+
+    public static List<Integer> empty() {
+        ArrayList<Integer> list = new ArrayList<>();
+        list.add(null);
+        return list;
+    }
+
+    public static List<Integer> countTo(int n) {
+        return range(1, n);
+    }
+
+    public static List<Integer> range(int l, int u) {
+        ArrayList<Integer> list = new ArrayList<>(u - l + 1);
+        for (int i=l; i<=u; i++) {
+            list.add(i);
+        }
+        return list;
+    }
+
+    public static List<Integer> repeat(int value, int n) {
+        ArrayList<Integer> list = new ArrayList<>(n);
+        for (int i=1; i<=n; i++) {
+            list.add(value);
+        }
+        return list;
+    }
+
+    public static List<Double> asDoubles(List<Integer> integers) {
+        ArrayList<Double> list = new ArrayList<>();
+        for (Integer i : integers) {
+            list.add((double) i);
+        }
+        return list;
+    }
+
+    public static List<Long> asLongs(List<Integer> integers) {
+        ArrayList<Long> list = new ArrayList<>();
+        for (Integer i : integers) {
+            list.add((long) i);
+        }
+        return list;
+    }
+
+    public static void assertCountSum(Stream<? super Integer> it, int count, int sum) {
+        assertCountSum(it.iterator(), count, sum);
+    }
+
+    public static void assertCountSum(Iterable<? super Integer> it, int count, int sum) {
+        assertCountSum(it.iterator(), count, sum);
+    }
+
+    public static void assertCountSum(Iterator<? super Integer> it, int count, int sum) {
+        int c = 0;
+        int s = 0;
+        while (it.hasNext()) {
+            int i = (Integer) it.next();
+            c++;
+            s += i;
+        }
+
+        assertEquals(c, count);
+        assertEquals(s, sum);
+    }
+
+    public static void assertConcat(Iterator<Character> it, String result) {
+        StringBuilder sb = new StringBuilder();
+        while (it.hasNext()) {
+            sb.append(it.next());
+        }
+
+        assertEquals(result, sb.toString());
+    }
+
+    public static<T extends Comparable<? super T>> void assertSorted(Iterator<T> i) {
+        i = toBoxedList(i).iterator();
+
+        if (!i.hasNext())
+            return;
+        T last = i.next();
+        while (i.hasNext()) {
+            T t = i.next();
+            assertTrue(last.compareTo(t) <= 0);
+            assertTrue(t.compareTo(last) >= 0);
+            last = t;
+        }
+    }
+
+    public static<T> void assertSorted(Iterator<T> i, Comparator<? super T> comp) {
+        if (i instanceof PrimitiveIterator.OfInt
+                || i instanceof PrimitiveIterator.OfDouble
+                || i instanceof PrimitiveIterator.OfLong) {
+            i = toBoxedList(i).iterator();
+        }
+
+        if (!i.hasNext())
+            return;
+        T last = i.next();
+        while (i.hasNext()) {
+            T t = i.next();
+            assertTrue(comp.compare(last, t) <= 0);
+            assertTrue(comp.compare(t, last) >= 0);
+            last = t;
+        }
+    }
+
+    public static<T extends Comparable<? super T>> void assertSorted(Iterable<T> iter) {
+        assertSorted(iter.iterator());
+    }
+
+    public static<T> void assertSorted(Iterable<T> iter, Comparator<? super T> comp) {
+        assertSorted(iter.iterator(), comp);
+    }
+
+    public static <T> void assertUnique(Iterable<T> iter) {
+        assertUnique(iter.iterator());
+    }
+
+    public static<T> void assertUnique(Iterator<T> iter) {
+        if (!iter.hasNext()) {
+            return;
+        }
+
+        if (iter instanceof PrimitiveIterator.OfInt
+            || iter instanceof PrimitiveIterator.OfDouble
+            || iter instanceof PrimitiveIterator.OfLong) {
+            iter = toBoxedList(iter).iterator();
+        }
+
+        Set<T> uniq = new HashSet<>();
+        while(iter.hasNext()) {
+            T each = iter.next();
+            assertTrue(!uniq.contains(each), "Not unique");
+            uniq.add(each);
+        }
+    }
+
+    public static<T> void assertContents(Iterable<T> actual, Iterable<T> expected) {
+        if (actual instanceof Collection && expected instanceof Collection) {
+            assertEquals(actual, expected);
+        } else {
+            assertContents(actual.iterator(), expected.iterator());
+        }
+    }
+
+    public static<T> void assertContents(Iterator<T> actual, Iterator<T> expected) {
+        assertEquals(toBoxedList(actual), toBoxedList(expected));
+    }
+
+    @SafeVarargs
+    @SuppressWarnings("varargs")
+    public static<T> void assertContents(Iterator<T> actual, T... expected) {
+        assertContents(actual, Arrays.asList(expected).iterator());
+    }
+
+    /**
+     * The all consuming consumer (rampant capitalist) that can accepting a reference or any primitive value.
+     */
+    private static interface OmnivorousConsumer<T>
+            extends Consumer<T>, IntConsumer, LongConsumer, DoubleConsumer { }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static<T> Consumer<T> toBoxingConsumer(Consumer<? super T> c) {
+        return (Consumer<T>) new OmnivorousConsumer() {
+            @Override
+            public void accept(Object t) {
+                c.accept((T) t);
+            }
+
+            @Override
+            public void accept(int t) {
+                accept((Object) t);
+            }
+
+            @Override
+            public void accept(long t) {
+                accept((Object) t);
+            }
+
+            @Override
+            public void accept(double t) {
+                accept((Object) t);
+            }
+        };
+    }
+
+    /**
+     * Convert an iterator to a list using forEach with an implementation of
+     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
+     *
+     * This ensures equality comparisons for test results do not trip
+     * the boxing trip-wires.
+     */
+    private static<T> List<T> toBoxedList(Iterator<T> it) {
+        List<T> l = new ArrayList<>();
+        it.forEachRemaining(toBoxingConsumer(l::add));
+        return l;
+    }
+
+    /**
+     * Convert a spliterator to a list using forEach with an implementation of
+     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
+     *
+     * This ensures equality comparisons for test results do not trip
+     * the boxing trip-wires.
+     */
+    public static<T> List<T> toBoxedList(Spliterator<T> sp) {
+        List<T> l = new ArrayList<>();
+        sp.forEachRemaining(toBoxingConsumer(l::add));
+        return l;
+    }
+
+    /**
+     * Convert an iterator to a multi-set, represented as a Map, using forEach with an implementation of
+     * {@link java.util.stream.LambdaTestHelpers.OmnivorousConsumer}.
+     *
+     * This ensures equality comparisons for test results do not trip
+     * the boxing trip-wires.
+     */
+    @SuppressWarnings("unchecked")
+    private static<T> Map<T, Integer> toBoxedMultiset(Iterator<T> it) {
+        Map<Object, Integer> result = new HashMap<>();
+
+        it.forEachRemaining(toBoxingConsumer(o -> {
+                if (result.containsKey(o))
+                    result.put(o, result.get(o) + 1);
+                else
+                    result.put(o, 1);
+            }));
+
+        return (Map<T, Integer>) result;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static<T> Map<T, Integer> toBoxedMultiset(Spliterator<T> it) {
+        Map<Object, Integer> result = new HashMap<>();
+
+        it.forEachRemaining(toBoxingConsumer(o -> {
+                if (result.containsKey(o))
+                    result.put(o, result.get(o) + 1);
+                else
+                    result.put(o, 1);
+            }));
+
+        return (Map<T, Integer>) result;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static void assertContentsEqual(Object a, Object b) {
+        if (a instanceof Iterable && b instanceof Iterable)
+            assertContents((Iterable) a, (Iterable) b);
+        else
+            assertEquals(a, b);
+    }
+
+    public static<T> void assertContentsUnordered(Iterable<T> actual, Iterable<T> expected) {
+        assertContentsUnordered(actual.iterator(), expected.iterator());
+    }
+
+    public static<T> void assertContentsUnordered(Iterator<T> actual, Iterator<T> expected) {
+        assertEquals(toBoxedMultiset(actual), toBoxedMultiset(expected));
+    }
+
+    public static<T> void assertContains(Optional<T> actual, Iterator<T> it) {
+        actual.ifPresentOrElse(r -> {
+            boolean contained = false;
+            while (!contained && it.hasNext()) {
+                contained = Objects.equals(r, it.next());
+            }
+            assertTrue(contained, "Not found: "+r);
+        }, () -> assertFalse(it.hasNext()));
+    }
+
+    public static void launderAssertion(Runnable r, Supplier<String> additionalInfo) {
+        try {
+            r.run();
+        }
+        catch (AssertionError ae) {
+            AssertionError cloned = new AssertionError(ae.getMessage() + String.format("%n%s", additionalInfo.get()));
+            cloned.setStackTrace(ae.getStackTrace());
+            if (ae.getCause() != null)
+                cloned.initCause(ae.getCause());
+            throw cloned;
+        }
+    }
+
+    public static <T, S extends BaseStream<T, S>>
+    List<Function<S, S>> permuteStreamFunctions(List<Function<S, S>> opFunctions) {
+        List<List<Function<S, S>>> opFunctionPermutations = perm(opFunctions);
+
+        List<Function<S, S>> appliedFunctions = new ArrayList<>();
+        for (List<Function<S, S>> fs : opFunctionPermutations) {
+            Function<S, S> applied = s -> {
+                for (Function<S, S> f : fs) {
+                    s = f.apply(s);
+                }
+                return s;
+            };
+            appliedFunctions.add(applied);
+        }
+
+        return appliedFunctions;
+    }
+
+    private static <T> List<T> sub(List<T> l, int index) {
+        List<T> subL = new ArrayList<>(l);
+        subL.remove(index);
+        return subL;
+    }
+
+    public static <T> List<List<T>> perm(List<T> l) {
+        List<List<T>> result = new ArrayList<>();
+        for (int i = 0; i < l.size(); i++) {
+            for (List<T> perm : perm(sub(l, i))) {
+                perm.add(0, l.get(i));
+                result.add(perm);
+            }
+        }
+        result.add(new ArrayList<T>());
+
+        return result;
+    }
+
+    public static String flagsToString(int flags) {
+        StringJoiner sj = new StringJoiner(", ", "StreamOpFlag[", "]");
+        if (StreamOpFlag.DISTINCT.isKnown(flags)) sj.add("IS_DISTINCT");
+        if (StreamOpFlag.ORDERED.isKnown(flags)) sj.add("IS_ORDERED");
+        if (StreamOpFlag.SIZED.isKnown(flags)) sj.add("IS_SIZED");
+        if (StreamOpFlag.SORTED.isKnown(flags)) sj.add("IS_SORTED");
+        if (StreamOpFlag.SHORT_CIRCUIT.isKnown(flags)) sj.add("IS_SHORT_CIRCUIT");
+        return sj.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LambdaTestMode.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+/**
+ * Runtime modes of test execution.
+ */
+public enum LambdaTestMode {
+    /**
+     * Execution mode with no particular runtime constraints.
+     */
+    NORMAL,
+
+    /**
+     * Execution mode where tests are executed for testing lambda serialization
+     * and deserialization.
+     *
+     * <p>This mode may be queried by tests or data supplied by data
+     * providers, which cannot otherwise be assigned to the test group
+     * <em>serialization-hostile</em>, to not execute or declare
+     * serialization-hostile code or data.
+     *
+     * <p>This mode is enabled if the boolean system property
+     * {@code org.openjdk.java.util.stream.sand.mode} is declared with a
+     * {@code true} value.
+     */
+    SERIALIZATION;
+
+    /**
+     * {@code true} if tests are executed in the mode for testing lambda
+     * Serialization ANd Deserialization (SAND).
+     */
+    private static final boolean IS_LAMBDA_SERIALIZATION_MODE =
+            Boolean.getBoolean("org.openjdk.java.util.stream.sand.mode");
+
+    /**
+     *
+     * @return the mode of test execution.
+     */
+    public static LambdaTestMode getMode() {
+        return IS_LAMBDA_SERIALIZATION_MODE ? SERIALIZATION : NORMAL;
+    }
+
+    /**
+     *
+     * @return {@code true} if normal test mode.
+     */
+    public static boolean isNormalMode() {
+        return getMode() == NORMAL;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LoggingTestCase.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.testng.Assert;
+import org.testng.ITestResult;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * LoggingTestCase
+ *
+ */
+@Test
+public class LoggingTestCase extends Assert {
+    private Map<String, Object> context = new HashMap<>();
+
+    @BeforeMethod
+    public void before() {
+        context.clear();
+    }
+
+    @AfterMethod
+    public void after(ITestResult result) {
+        if (!result.isSuccess()) {
+            List<Object> list = new ArrayList<>();
+            Collections.addAll(list, result.getParameters());
+            list.add(context.toString());
+            result.setParameters(list.toArray(new Object[list.size()]));
+        }
+    }
+
+    protected void setContext(String key, Object value) {
+        context.put(key, value);
+    }
+
+    protected void clearContext(String key) {
+        context.remove(key);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LongStreamTestDataProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,173 @@
+/*
+ * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+
+/** TestNG DataProvider for long-valued streams */
+public class LongStreamTestDataProvider {
+    private static final long[] to0 = new long[0];
+    private static final long[] to1 = new long[1];
+    private static final long[] to10 = new long[10];
+    private static final long[] to100 = new long[100];
+    private static final long[] to1000 = new long[1000];
+    private static final long[] reversed = new long[100];
+    private static final long[] ones = new long[100];
+    private static final long[] twice = new long[200];
+    private static final long[] pseudoRandom;
+
+    private static final Object[][] testData;
+    private static final Object[][] testSmallData;
+    private static final Object[][] spliteratorTestData;
+
+    static {
+        long[][] arrays = {to0, to1, to10, to100, to1000};
+        for (long[] arr : arrays) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = i;
+            }
+        }
+        for (int i = 0; i < reversed.length; i++) {
+            reversed[i] = reversed.length - i;
+        }
+        for (int i = 0; i < ones.length; i++) {
+            ones[i] = 1;
+        }
+        System.arraycopy(to100, 0, twice, 0, to100.length);
+        System.arraycopy(to100, 0, twice, to100.length, to100.length);
+        pseudoRandom = new long[LambdaTestHelpers.LONG_STRING.length()];
+        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+            pseudoRandom[i] = (long) LambdaTestHelpers.LONG_STRING.charAt(i);
+        }
+    }
+
+    static final Object[][] arrays = {
+            {"empty", to0},
+            {"0..1", to1},
+            {"0..10", to10},
+            {"0..100", to100},
+            {"0..1000", to1000},
+            {"100x[1]", ones},
+            {"2x[0..100]", twice},
+            {"reverse 0..100", reversed},
+            {"pseudorandom", pseudoRandom}
+    };
+
+    static {
+        {
+            List<Object[]> listSmall = new ArrayList<>();
+            List<Object[]> list1000 = new ArrayList<>();
+            List<Object[]> list = null;
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final long[] longs = (long[]) data[1];
+
+                list = longs.length >= 1000 ? list1000 : listSmall;
+
+                list.add(new Object[]{"array:" + name,
+                        TestData.Factory.ofArray("array:" + name, longs)});
+
+                SpinedBuffer.OfLong isl = new SpinedBuffer.OfLong();
+                for (long i : longs) {
+                    isl.accept(i);
+                }
+                list.add(new Object[]{"SpinedList:" + name,
+                        TestData.Factory.ofSpinedBuffer("SpinedList:" + name, isl)});
+
+                list.add(streamDataDescr("LongStream.longRange(0,l): " + longs.length,
+                                         () -> LongStream.range(0, longs.length)));
+                list.add(streamDataDescr("LongStream.longRangeClosed(0,l): " + longs.length,
+                                         () -> LongStream.rangeClosed(0, longs.length)));
+            }
+            testSmallData = listSmall.toArray(new Object[0][]);
+            list1000.addAll(listSmall);
+            testData = list1000.toArray(new Object[0][]);
+        }
+
+        {
+            List<Object[]> spliterators = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final long[] longs = (long[]) data[1];
+
+                SpinedBuffer.OfLong isl = new SpinedBuffer.OfLong();
+                for (long i : longs) {
+                    isl.accept(i);
+                }
+
+                spliterators.add(splitDescr("Arrays.s(array):" + name,
+                                            () -> Arrays.spliterator(longs)));
+                spliterators.add(splitDescr("Arrays.s(array,o,l):" + name,
+                                            () -> Arrays.spliterator(longs, 0, longs.length / 2)));
+
+                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+                                            () -> isl.spliterator()));
+
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator(), size):" + name,
+                                            () -> Spliterators.spliterator(isl.iterator(), longs.length, 0)));
+                spliterators.add(splitDescr("Primitives.s(SpinedBuffer.iterator()):" + name,
+                                            () -> Spliterators.spliteratorUnknownSize(isl.iterator(), 0)));
+
+                spliterators.add(splitDescr("LongStream.longRange(0,l):" + name,
+                                            () -> LongStream.range(0, longs.length).spliterator()));
+                spliterators.add(splitDescr("LongStream.longRangeClosed(0,l):" + name,
+                                            () -> LongStream.rangeClosed(0, longs.length).spliterator()));
+                spliterators.add(splitDescr("LongStream.iterate(0,x->x<l;x->x+1):" + name,
+                                            () -> LongStream.iterate(0L, x -> x < longs.length, x -> x + 1L)
+                                                            .spliterator()));
+                // Need more!
+            }
+            spliteratorTestData = spliterators.toArray(new Object[0][]);
+        }
+
+    }
+
+    static <T> Object[] streamDataDescr(String description, Supplier<LongStream> s) {
+        return new Object[] { description, TestData.Factory.ofLongSupplier(description, s) };
+    }
+
+    static <T> Object[] splitDescr(String description, Supplier<Spliterator.OfLong> s) {
+        return new Object[] { description, s };
+    }
+
+    // Return an array of ( String name, LongStreamTestData )
+    @DataProvider(name = "LongStreamTestData")
+    public static Object[][] makeLongStreamTestData() {
+        return testData;
+    }
+
+    @DataProvider(name = "LongStreamTestData.small")
+    public static Object[][] makeSmallLongStreamTestData() {
+        return testSmallData;
+    }
+
+    // returns an array of (String name, Supplier<PrimitiveSpliterator<Long>>)
+    @DataProvider(name = "LongSpliterator")
+    public static Object[][] spliteratorProvider() {
+        return spliteratorTestData;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/LongStreamTestScenario.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.PrimitiveIterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.SpliteratorTestHelper;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import java.util.function.LongConsumer;
+
+/**
+ * Test scenarios for long streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results.  Each scenario describes a different way of computing the
+ * stream contents.  The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum LongStreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+    STREAM_FOR_EACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            LongStream s = m.apply(source);
+            if (s.isParallel()) {
+                s = s.sequential();
+            }
+            s.forEach(b);
+        }
+    },
+
+    STREAM_TO_ARRAY(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (long t : m.apply(source).toArray()) {
+                b.accept(t);
+            }
+        }
+    },
+
+    STREAM_ITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (PrimitiveIterator.OfLong seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
+                b.accept(seqIter.nextLong());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (Spliterator.OfLong spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR_FOREACH(false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            m.apply(source).sequential().forEach(b);
+        }
+    },
+
+    // Wrap as parallel stream + forEachOrdered
+    PAR_STREAM_FOR_EACH_ORDERED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            // @@@ Want to explicitly select ordered equalator
+            m.apply(source).forEachOrdered(b);
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (Spliterator.OfLong spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR_FOREACH(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            for (long t : m.apply(source).toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            LongStream s = m.apply(source);
+            Spliterator.OfLong sp = s.spliterator();
+            LongStream ss = StreamSupport.longStream(() -> sp,
+                                                     StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+                                                     | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
+            for (long t : ss.toArray())
+                b.accept(t);
+        }
+    },
+
+    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            LongStream pipe2 = m.apply(pipe1);
+
+            for (long t : pipe2.toArray())
+                b.accept(t);
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing
+    PAR_STREAM_FOR_EACH(true, false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            m.apply(source).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
+    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
+        <T, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            m.apply(pipe1).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+    ;
+
+    // The set of scenarios that clean the SIZED flag
+    public static final Set<LongStreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
+            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
+
+    private boolean isParallel;
+
+    private final boolean isOrdered;
+
+    LongStreamTestScenario(boolean isParallel) {
+        this(isParallel, true);
+    }
+
+    LongStreamTestScenario(boolean isParallel, boolean isOrdered) {
+        this.isParallel = isParallel;
+        this.isOrdered = isOrdered;
+    }
+
+    public StreamShape getShape() {
+        return StreamShape.LONG_VALUE;
+    }
+
+    public boolean isParallel() {
+        return isParallel;
+    }
+
+    public boolean isOrdered() {
+        return isOrdered;
+    }
+
+    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+        try (S_IN source = getStream(data)) {
+            run(data, source, (LongConsumer) b, (Function<S_IN, LongStream>) m);
+        }
+    }
+
+    abstract <T, S_IN extends BaseStream<T, S_IN>>
+    void run(TestData<T, S_IN> data, S_IN source, LongConsumer b, Function<S_IN, LongStream> m);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/OpTestCase.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,682 @@
+/*
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.function.BiConsumer;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+import org.testng.annotations.Test;
+
+/**
+ * Base class for streams test cases.  Provides 'exercise' methods for taking
+ * lambdas that construct and modify streams, and evaluates them in different
+ * ways and asserts that they produce equivalent results.
+ */
+@Test
+public abstract class OpTestCase extends LoggingTestCase {
+
+    private final Map<StreamShape, Set<? extends BaseStreamTestScenario>> testScenarios;
+
+    protected OpTestCase() {
+        testScenarios = new EnumMap<>(StreamShape.class);
+        testScenarios.put(StreamShape.REFERENCE, Collections.unmodifiableSet(EnumSet.allOf(StreamTestScenario.class)));
+        testScenarios.put(StreamShape.INT_VALUE, Collections.unmodifiableSet(EnumSet.allOf(IntStreamTestScenario.class)));
+        testScenarios.put(StreamShape.LONG_VALUE, Collections.unmodifiableSet(EnumSet.allOf(LongStreamTestScenario.class)));
+        testScenarios.put(StreamShape.DOUBLE_VALUE, Collections.unmodifiableSet(EnumSet.allOf(DoubleStreamTestScenario.class)));
+    }
+
+    @SuppressWarnings("rawtypes")
+    public static int getStreamFlags(BaseStream s) {
+        return ((AbstractPipeline) s).getStreamFlags();
+    }
+
+    /**
+     * An asserter for results produced when exercising of stream or terminal
+     * tests.
+     *
+     * @param <R> the type of result to assert on
+     */
+    public interface ResultAsserter<R> {
+        /**
+         * Assert a result produced when exercising of stream or terminal
+         * test.
+         *
+         * @param actual the actual result
+         * @param expected the expected result
+         * @param isOrdered true if the pipeline is ordered
+         * @param isParallel true if the pipeline is parallel
+         */
+        void assertResult(R actual, R expected, boolean isOrdered, boolean isParallel);
+    }
+
+    // Exercise stream operations
+
+    public interface BaseStreamTestScenario {
+        StreamShape getShape();
+
+        boolean isParallel();
+
+        boolean isOrdered();
+
+        default <T, S_IN extends BaseStream<T, S_IN>>
+        S_IN getStream(TestData<T, S_IN> data) {
+            return isParallel()
+                   ? data.parallelStream()
+                   : data.stream();
+        }
+
+        <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+        void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m);
+    }
+
+    protected <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    Collection<U> exerciseOps(TestData<T, S_IN> data, Function<S_IN, S_OUT> m) {
+        return withData(data).stream(m).exercise();
+    }
+
+    // Run multiple versions of exercise(), returning the result of the first, and asserting that others return the same result
+    // If the first version is s -> s.foo(), can be used with s -> s.mapToInt(i -> i).foo().mapToObj(i -> i) to test all shape variants
+    @SafeVarargs
+    protected final<T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    Collection<U> exerciseOpsMulti(TestData<T, S_IN> data,
+                                   Function<S_IN, S_OUT>... ms) {
+        Collection<U> result = null;
+        for (Function<S_IN, S_OUT> m : ms) {
+            if (result == null)
+                result = withData(data).stream(m).exercise();
+            else {
+                Collection<U> r2 = withData(data).stream(m).exercise();
+                assertEquals(result, r2);
+            }
+        }
+        return result;
+    }
+
+    // Run multiple versions of exercise() for an Integer stream, returning the result of the first, and asserting that others return the same result
+    // Automates the conversion between Stream<Integer> and {Int,Long,Double}Stream and back, so client sites look like you are passing the same
+    // lambda four times, but in fact they are four different lambdas since they are transforming four different kinds of streams
+    protected final
+    Collection<Integer> exerciseOpsInt(TestData.OfRef<Integer> data,
+                                       Function<Stream<Integer>, Stream<Integer>> mRef,
+                                       Function<IntStream, IntStream> mInt,
+                                       Function<LongStream, LongStream> mLong,
+                                       Function<DoubleStream, DoubleStream> mDouble) {
+        @SuppressWarnings({ "rawtypes", "unchecked" })
+        Function<Stream<Integer>, Stream<Integer>>[] ms = new Function[4];
+        ms[0] = mRef;
+        ms[1] = s -> mInt.apply(s.mapToInt(e -> e)).mapToObj(e -> e);
+        ms[2] = s -> mLong.apply(s.mapToLong(e -> e)).mapToObj(e -> (int) e);
+        ms[3] = s -> mDouble.apply(s.mapToDouble(e -> e)).mapToObj(e -> (int) e);
+        return exerciseOpsMulti(data, ms);
+    }
+
+    // Run multiple versions of exercise() with multiple terminal operations for all kinds of stream, , and asserting against the expected result
+    // If the first version is s -> s.foo(), can be used with s -> s.mapToInt(i -> i).foo().mapToObj(i -> i) to test all shape variants
+    protected final<T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    void exerciseTerminalOpsMulti(TestData<T, S_IN> data,
+                                  R expected,
+                                  Map<String, Function<S_IN, S_OUT>> streams,
+                                  Map<String, Function<S_OUT, R>> terminals) {
+        for (Map.Entry<String, Function<S_IN, S_OUT>> se : streams.entrySet()) {
+            setContext("Intermediate stream", se.getKey());
+            for (Map.Entry<String, Function<S_OUT, R>> te : terminals.entrySet()) {
+                setContext("Terminal stream", te.getKey());
+                withData(data)
+                        .terminal(se.getValue(), te.getValue())
+                        .expectedResult(expected)
+                        .exercise();
+
+            }
+        }
+    }
+
+    // Run multiple versions of exercise() with multiple terminal operation for all kinds of stream, and asserting against the expected result
+    // Automates the conversion between Stream<Integer> and {Int,Long,Double}Stream and back, so client sites look like you are passing the same
+    // lambda four times, but in fact they are four different lambdas since they are transforming four different kinds of streams
+    protected final
+    void exerciseTerminalOpsInt(TestData<Integer, Stream<Integer>> data,
+                                Collection<Integer> expected,
+                                String desc,
+                                Function<Stream<Integer>, Stream<Integer>> mRef,
+                                Function<IntStream, IntStream> mInt,
+                                Function<LongStream, LongStream> mLong,
+                                Function<DoubleStream, DoubleStream> mDouble,
+                                Map<String, Function<Stream<Integer>, Collection<Integer>>> terminals) {
+
+        Map<String, Function<Stream<Integer>, Stream<Integer>>> m = new HashMap<>();
+        m.put("Ref " + desc, mRef);
+        m.put("Int " + desc, s -> mInt.apply(s.mapToInt(e -> e)).mapToObj(e -> e));
+        m.put("Long " + desc, s -> mLong.apply(s.mapToLong(e -> e)).mapToObj(e -> (int) e));
+        m.put("Double " + desc, s -> mDouble.apply(s.mapToDouble(e -> e)).mapToObj(e -> (int) e));
+
+        exerciseTerminalOpsMulti(data, expected, m, terminals);
+    }
+
+
+    protected <T, U, S_OUT extends BaseStream<U, S_OUT>>
+    Collection<U> exerciseOps(Collection<T> data, Function<Stream<T>, S_OUT> m) {
+        TestData.OfRef<T> data1 = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
+        return withData(data1).stream(m).exercise();
+    }
+
+    protected <T, U, S_OUT extends BaseStream<U, S_OUT>, I extends Iterable<U>>
+    Collection<U> exerciseOps(Collection<T> data, Function<Stream<T>, S_OUT> m, I expected) {
+        TestData.OfRef<T> data1 = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
+        return withData(data1).stream(m).expectedResult(expected).exercise();
+    }
+
+    @SuppressWarnings("unchecked")
+    protected <U, S_OUT extends BaseStream<U, S_OUT>>
+    Collection<U> exerciseOps(int[] data, Function<IntStream, S_OUT> m) {
+        return withData(TestData.Factory.ofArray("int array", data)).stream(m).exercise();
+    }
+
+    protected Collection<Integer> exerciseOps(int[] data, Function<IntStream, IntStream> m, int[] expected) {
+        TestData.OfInt data1 = TestData.Factory.ofArray("int array", data);
+        return withData(data1).stream(m).expectedResult(expected).exercise();
+    }
+
+    protected <T, S_IN extends BaseStream<T, S_IN>> DataStreamBuilder<T, S_IN> withData(TestData<T, S_IN> data) {
+        Objects.requireNonNull(data);
+        return new DataStreamBuilder<>(data);
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public class DataStreamBuilder<T, S_IN extends BaseStream<T, S_IN>> {
+        final TestData<T, S_IN> data;
+
+        private DataStreamBuilder(TestData<T, S_IN> data) {
+            this.data = Objects.requireNonNull(data);
+        }
+
+        public <U, S_OUT extends BaseStream<U, S_OUT>>
+        ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> ops(IntermediateTestOp... ops) {
+            return new ExerciseDataStreamBuilder<>(data, (S_IN s) -> (S_OUT) chain(s, ops));
+        }
+
+        public <U, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT>
+        stream(Function<S_IN, S_OUT> m) {
+            return new ExerciseDataStreamBuilder<>(data, m);
+        }
+
+        public <U, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT>
+        stream(Function<S_IN, S_OUT> m, IntermediateTestOp<U, U> additionalOp) {
+            return new ExerciseDataStreamBuilder<>(data, s -> (S_OUT) chain(m.apply(s), additionalOp));
+        }
+
+        public <R> ExerciseDataTerminalBuilder<T, T, R, S_IN, S_IN>
+        terminal(Function<S_IN, R> terminalF) {
+            return new ExerciseDataTerminalBuilder<>(data, s -> s, terminalF);
+        }
+
+        public <U, R, S_OUT extends BaseStream<U, S_OUT>> ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT>
+        terminal(Function<S_IN, S_OUT> streamF, Function<S_OUT, R> terminalF) {
+            return new ExerciseDataTerminalBuilder<>(data, streamF, terminalF);
+        }
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public class ExerciseDataStreamBuilder<T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> {
+        final TestData<T, S_IN> data;
+        final Function<S_IN, S_OUT> m;
+        final StreamShape shape;
+
+        Set<BaseStreamTestScenario> testSet = new HashSet<>();
+
+        Collection<U> refResult;
+
+        Consumer<TestData<T, S_IN>> before = LambdaTestHelpers.bEmpty;
+
+        Consumer<TestData<T, S_IN>> after = LambdaTestHelpers.bEmpty;
+
+        ResultAsserter<Iterable<U>> resultAsserter = (act, exp, ord, par) -> {
+            if (par & !ord) {
+                LambdaTestHelpers.assertContentsUnordered(act, exp);
+            }
+            else {
+                LambdaTestHelpers.assertContentsEqual(act, exp);
+            }
+        };
+
+        private ExerciseDataStreamBuilder(TestData<T, S_IN> data, Function<S_IN, S_OUT> m) {
+            this.data = data;
+
+            this.m = Objects.requireNonNull(m);
+
+            this.shape = ((AbstractPipeline<?, U, ?>) m.apply(data.stream())).getOutputShape();
+
+            // Have to initiate from the output shape of the last stream
+            // This means the stream mapper is required first rather than last
+            testSet.addAll(testScenarios.get(shape));
+        }
+
+        //
+
+        public <I extends Iterable<U>> ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(I expectedResult) {
+            List<U> l = new ArrayList<>();
+            expectedResult.forEach(l::add);
+            refResult = l;
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(int[] expectedResult) {
+            List l = new ArrayList();
+            for (int anExpectedResult : expectedResult) {
+                l.add(anExpectedResult);
+            }
+            refResult = l;
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(long[] expectedResult) {
+            List l = new ArrayList();
+            for (long anExpectedResult : expectedResult) {
+                l.add(anExpectedResult);
+            }
+            refResult = l;
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> expectedResult(double[] expectedResult) {
+            List l = new ArrayList();
+            for (double anExpectedResult : expectedResult) {
+                l.add(anExpectedResult);
+            }
+            refResult = l;
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> before(Consumer<TestData<T, S_IN>> before) {
+            this.before = Objects.requireNonNull(before);
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> after(Consumer<TestData<T, S_IN>> after) {
+            this.after = Objects.requireNonNull(after);
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> without(BaseStreamTestScenario... tests) {
+            return without(Arrays.asList(tests));
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> without(Collection<? extends BaseStreamTestScenario> tests) {
+            for (BaseStreamTestScenario ts : tests) {
+                if (ts.getShape() == shape) {
+                    testSet.remove(ts);
+                }
+            }
+
+            if (testSet.isEmpty()) {
+                throw new IllegalStateException("Test scenario set is empty");
+            }
+
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> with(BaseStreamTestScenario... tests) {
+            return with(Arrays.asList(tests));
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> with(Collection<? extends BaseStreamTestScenario> tests) {
+            testSet = new HashSet<>();
+
+            for (BaseStreamTestScenario ts : tests) {
+                if (ts.getShape() == shape) {
+                    testSet.add(ts);
+                }
+            }
+
+            if (testSet.isEmpty()) {
+                throw new IllegalStateException("Test scenario set is empty");
+            }
+
+            return this;
+        }
+
+        public ExerciseDataStreamBuilder<T, U, S_IN, S_OUT> resultAsserter(ResultAsserter<Iterable<U>> resultAsserter) {
+            this.resultAsserter = resultAsserter;
+            return this;
+        }
+
+        // Build method
+
+        public Collection<U> exercise() {
+            final boolean isStreamOrdered;
+            if (refResult == null) {
+                // Induce the reference result
+                before.accept(data);
+                try (S_OUT sOut = m.apply(data.stream())) {
+                    isStreamOrdered = StreamOpFlag.ORDERED.isKnown(((AbstractPipeline) sOut).getStreamFlags());
+                    Node<U> refNodeResult = ((AbstractPipeline<?, U, ?>) sOut).evaluateToArrayNode(size -> (U[]) new Object[size]);
+                    refResult = LambdaTestHelpers.toBoxedList(refNodeResult.spliterator());
+                }
+                after.accept(data);
+            }
+            else {
+                try (S_OUT sOut = m.apply(data.stream())) {
+                    isStreamOrdered = StreamOpFlag.ORDERED.isKnown(((AbstractPipeline) sOut).getStreamFlags());
+                }
+            }
+
+            List<Error> errors = new ArrayList<>();
+            for (BaseStreamTestScenario test : testSet) {
+                try {
+                    before.accept(data);
+
+                    List<U> result = new ArrayList<>();
+                    test.run(data, LambdaTestHelpers.<U>toBoxingConsumer(result::add), m);
+
+                    Runnable asserter = () -> resultAsserter.assertResult(result, refResult, isStreamOrdered && test.isOrdered(), test.isParallel());
+
+                    if (refResult.size() > 1000) {
+                        LambdaTestHelpers.launderAssertion(
+                                asserter,
+                                () -> String.format("%n%s: [actual size=%d] != [expected size=%d]", test, result.size(), refResult.size()));
+                    }
+                    else {
+                        LambdaTestHelpers.launderAssertion(
+                                asserter,
+                                () -> String.format("%n%s: [actual] %s != [expected] %s", test, result, refResult));
+                    }
+
+                    after.accept(data);
+                } catch (Throwable t) {
+                    errors.add(new Error(String.format("%s: %s", test, t), t));
+                }
+            }
+
+            if (!errors.isEmpty()) {
+                StringBuilder sb = new StringBuilder();
+                int i = 1;
+                for (Error t : errors) {
+                    sb.append(i++).append(": ");
+                    if (t instanceof AssertionError) {
+                        sb.append(t).append("\n");
+                    }
+                    else {
+                        StringWriter sw = new StringWriter();
+                        PrintWriter pw = new PrintWriter(sw);
+
+                        t.getCause().printStackTrace(pw);
+                        pw.flush();
+                        sb.append(t).append("\n").append(sw);
+                    }
+                }
+                sb.append("--");
+
+                fail(String.format("%d failure(s) for test data: %s\n%s", i - 1, data.toString(), sb));
+            }
+
+            return refResult;
+        }
+    }
+
+    // Exercise terminal operations
+
+    interface BaseTerminalTestScenario<U, R, S_OUT extends BaseStream<U, S_OUT>> {
+        boolean requiresSingleStageSource();
+
+        boolean requiresParallelSource();
+
+        default R run(Function<S_OUT, R> terminalF, S_OUT source, StreamShape shape) {
+            return terminalF.apply(source);
+        }
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    enum TerminalTestScenario implements BaseTerminalTestScenario {
+        SINGLE_SEQUENTIAL(true, false),
+
+        SINGLE_SEQUENTIAL_SHORT_CIRCUIT(true, false) {
+            @Override
+            public Object run(Function terminalF, BaseStream source, StreamShape shape) {
+                source = (BaseStream) chain(source, new ShortCircuitOp(shape));
+                return terminalF.apply(source);
+            }
+        },
+
+        SINGLE_PARALLEL(true, true),
+
+        ALL_SEQUENTIAL(false, false),
+
+        ALL_SEQUENTIAL_SHORT_CIRCUIT(false, false) {
+            @Override
+            public Object run(Function terminalF, BaseStream source, StreamShape shape) {
+                source = (BaseStream) chain(source, new ShortCircuitOp(shape));
+                return terminalF.apply(source);
+            }
+        },
+
+        ALL_PARALLEL(false, true),
+
+        ALL_PARALLEL_SEQUENTIAL(false, false) {
+            @Override
+            public Object run(Function terminalF, BaseStream source, StreamShape shape) {
+                return terminalF.apply(source.sequential());
+            }
+        },
+        ;
+
+        private final boolean requiresSingleStageSource;
+        private final boolean isParallel;
+
+        TerminalTestScenario(boolean requiresSingleStageSource, boolean isParallel) {
+            this.requiresSingleStageSource = requiresSingleStageSource;
+            this.isParallel = isParallel;
+        }
+
+        @Override
+        public boolean requiresSingleStageSource() {
+            return requiresSingleStageSource;
+        }
+
+        @Override
+        public boolean requiresParallelSource() {
+            return isParallel;
+        }
+
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public class ExerciseDataTerminalBuilder<T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> {
+        final TestData<T, S_IN> data;
+        final Function<S_IN, S_OUT> streamF;
+        final Function<S_OUT, R> terminalF;
+
+        R refResult;
+
+        ResultAsserter<R> resultAsserter = (act, exp, ord, par) -> LambdaTestHelpers.assertContentsEqual(act, exp);
+
+        private ExerciseDataTerminalBuilder(TestData<T, S_IN> data, Function<S_IN, S_OUT> streamF, Function<S_OUT, R> terminalF) {
+            this.data = data;
+            this.streamF = Objects.requireNonNull(streamF);
+            this.terminalF = Objects.requireNonNull(terminalF);
+        }
+
+        //
+
+        public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> expectedResult(R expectedResult) {
+            this.refResult = expectedResult;
+            return this;
+        }
+
+        public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> equalator(BiConsumer<R, R> equalityAsserter) {
+            resultAsserter = (act, exp, ord, par) -> equalityAsserter.accept(act, exp);
+            return this;
+        }
+
+        public ExerciseDataTerminalBuilder<T, U, R, S_IN, S_OUT> resultAsserter(ResultAsserter<R> resultAsserter) {
+            this.resultAsserter = resultAsserter;
+            return this;
+        }
+
+        // Build method
+
+        public R exercise() {
+            boolean isOrdered;
+            StreamShape shape;
+            Node<U> node;
+            try (S_OUT out = streamF.apply(data.stream()).sequential()) {
+                AbstractPipeline ap = (AbstractPipeline) out;
+                isOrdered = StreamOpFlag.ORDERED.isKnown(ap.getStreamFlags());
+                shape = ap.getOutputShape();
+                // Sequentially collect the output that will be input to the terminal op
+                node = ap.evaluateToArrayNode(size -> (U[]) new Object[size]);
+            }
+
+            EnumSet<TerminalTestScenario> tests = EnumSet.allOf(TerminalTestScenario.class);
+            if (refResult == null) {
+                // Induce the reference result
+                S_OUT source = (S_OUT) createPipeline(shape, node.spliterator(),
+                                                      StreamOpFlag.IS_ORDERED | StreamOpFlag.IS_SIZED,
+                                                      false);
+
+                refResult = (R) TerminalTestScenario.SINGLE_SEQUENTIAL.run(terminalF, source, shape);
+                tests.remove(TerminalTestScenario.SINGLE_SEQUENTIAL);
+            }
+
+            for (BaseTerminalTestScenario test : tests) {
+                S_OUT source;
+                if (test.requiresSingleStageSource()) {
+                    source = (S_OUT) createPipeline(shape, node.spliterator(),
+                                                    StreamOpFlag.IS_ORDERED | StreamOpFlag.IS_SIZED,
+                                                    test.requiresParallelSource());
+                }
+                else {
+                    source = streamF.apply(test.requiresParallelSource()
+                                           ? data.parallelStream() : data.stream());
+                }
+
+                R result;
+                try (source) {
+                    result = (R) test.run(terminalF, source, shape);
+                }
+                LambdaTestHelpers.launderAssertion(
+                        () -> resultAsserter.assertResult(result, refResult, isOrdered, test.requiresParallelSource()),
+                        () -> String.format("%s: %s != %s", test, refResult, result));
+            }
+
+            return refResult;
+        }
+
+        AbstractPipeline createPipeline(StreamShape shape, Spliterator s, int flags, boolean parallel) {
+            switch (shape) {
+                case REFERENCE:    return new ReferencePipeline.Head<>(s, flags, parallel);
+                case INT_VALUE:    return new IntPipeline.Head(s, flags, parallel);
+                case LONG_VALUE:   return new LongPipeline.Head(s, flags, parallel);
+                case DOUBLE_VALUE: return new DoublePipeline.Head(s, flags, parallel);
+                default: throw new IllegalStateException("Unknown shape: " + shape);
+            }
+        }
+    }
+
+    protected <T, R> R exerciseTerminalOps(Collection<T> data, Function<Stream<T>, R> m, R expected) {
+        TestData.OfRef<T> data1
+                = TestData.Factory.ofCollection("Collection of type " + data.getClass().getName(), data);
+        return withData(data1).terminal(m).expectedResult(expected).exercise();
+    }
+
+    protected <T, R, S_IN extends BaseStream<T, S_IN>> R
+    exerciseTerminalOps(TestData<T, S_IN> data,
+                        Function<S_IN, R> terminalF) {
+        return withData(data).terminal(terminalF).exercise();
+    }
+
+    protected <T, U, R, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>> R
+    exerciseTerminalOps(TestData<T, S_IN> data,
+                        Function<S_IN, S_OUT> streamF,
+                        Function<S_OUT, R> terminalF) {
+        return withData(data).terminal(streamF, terminalF).exercise();
+    }
+
+    //
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    private static <T> AbstractPipeline<?, T, ?> chain(AbstractPipeline upstream, IntermediateTestOp<?, T> op) {
+        return (AbstractPipeline<?, T, ?>) IntermediateTestOp.chain(upstream, op);
+    }
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    private static AbstractPipeline<?, ?, ?> chain(AbstractPipeline pipe, IntermediateTestOp... ops) {
+        for (IntermediateTestOp op : ops)
+            pipe = chain(pipe, op);
+        return pipe;
+    }
+
+    @SuppressWarnings("rawtypes")
+    private static <T> AbstractPipeline<?, T, ?> chain(BaseStream pipe, IntermediateTestOp<?, T> op) {
+        return chain((AbstractPipeline) pipe, op);
+    }
+
+    @SuppressWarnings("rawtypes")
+    public static AbstractPipeline<?, ?, ?> chain(BaseStream pipe, IntermediateTestOp... ops) {
+        return chain((AbstractPipeline) pipe, ops);
+    }
+
+    // Test data
+
+    static class ShortCircuitOp<T> implements StatelessTestOp<T,T> {
+        private final StreamShape shape;
+
+        ShortCircuitOp(StreamShape shape) {
+            this.shape = shape;
+        }
+
+        @Override
+        public Sink<T> opWrapSink(int flags, boolean parallel, Sink<T> sink) {
+            return sink;
+        }
+
+        @Override
+        public int opGetFlags() {
+            return StreamOpFlag.IS_SHORT_CIRCUIT;
+        }
+
+        @Override
+        public StreamShape outputShape() {
+            return shape;
+        }
+
+        @Override
+        public StreamShape inputShape() {
+            return shape;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StatefulTestOp.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.Spliterator;
+import java.util.function.IntFunction;
+
+/**
+ * The base type for a stateful test operation.
+ */
+interface StatefulTestOp<E> extends IntermediateTestOp<E, E> {
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static<T> AbstractPipeline chain(AbstractPipeline upstream,
+                                            StatefulTestOp op) {
+        switch (op.outputShape()) {
+            case REFERENCE:
+                return new ReferencePipeline.StatefulOp<Object, T>(upstream, op.inputShape(), op.opGetFlags()) {
+                    @Override
+                    Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+
+                    @Override
+                    <P_IN> Spliterator<T> opEvaluateParallelLazy(PipelineHelper<T> helper,
+                                                                 Spliterator<P_IN> spliterator) {
+                        return op.opEvaluateParallelLazy(helper, spliterator);
+                    }
+
+                    @Override
+                    <P_IN> Node<T> opEvaluateParallel(PipelineHelper<T> helper,
+                                                      Spliterator<P_IN> spliterator,
+                                                      IntFunction<T[]> generator) {
+                        return op.opEvaluateParallel(helper, spliterator, generator);
+                    }
+                };
+            case INT_VALUE:
+                return new IntPipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
+                    @Override
+                    Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+
+                    @Override
+                    <P_IN> Spliterator<Integer> opEvaluateParallelLazy(PipelineHelper<Integer> helper,
+                                                                 Spliterator<P_IN> spliterator) {
+                        return op.opEvaluateParallelLazy(helper, spliterator);
+                    }
+
+                    @Override
+                    <P_IN> Node<Integer> opEvaluateParallel(PipelineHelper<Integer> helper,
+                                                            Spliterator<P_IN> spliterator,
+                                                            IntFunction<Integer[]> generator) {
+                        return (Node<Integer>) op.opEvaluateParallel(helper, spliterator, generator);
+                    }
+                };
+            case LONG_VALUE:
+                return new LongPipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
+                    @Override
+                    Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+
+                    @Override
+                    <P_IN> Spliterator<Long> opEvaluateParallelLazy(PipelineHelper<Long> helper,
+                                                                 Spliterator<P_IN> spliterator) {
+                        return op.opEvaluateParallelLazy(helper, spliterator);
+                    }
+
+                    @Override
+                    <P_IN> Node<Long> opEvaluateParallel(PipelineHelper<Long> helper,
+                                                         Spliterator<P_IN> spliterator,
+                                                         IntFunction<Long[]> generator) {
+                        return (Node<Long>) op.opEvaluateParallel(helper, spliterator, generator);
+                    }
+                };
+            case DOUBLE_VALUE:
+                return new DoublePipeline.StatefulOp<Object>(upstream, op.inputShape(), op.opGetFlags()) {
+                    @Override
+                    Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+
+                    @Override
+                    <P_IN> Spliterator<Double> opEvaluateParallelLazy(PipelineHelper<Double> helper,
+                                                                    Spliterator<P_IN> spliterator) {
+                        return op.opEvaluateParallelLazy(helper, spliterator);
+                    }
+
+                    @Override
+                    <P_IN> Node<Double> opEvaluateParallel(PipelineHelper<Double> helper,
+                                                           Spliterator<P_IN> spliterator,
+                                                           IntFunction<Double[]> generator) {
+                        return (Node<Double>) op.opEvaluateParallel(helper, spliterator, generator);
+                    }
+                };
+            default: throw new IllegalStateException(op.outputShape().toString());
+        }
+    }
+
+    default StreamShape inputShape() { return StreamShape.REFERENCE; }
+
+    default StreamShape outputShape() { return StreamShape.REFERENCE; }
+
+    default int opGetFlags() { return 0; }
+
+    Sink<E> opWrapSink(int flags, boolean parallel, Sink<E> sink);
+
+    @SuppressWarnings("unchecked")
+    default <P_IN> Spliterator<E> opEvaluateParallelLazy(PipelineHelper<E> helper,
+                                                         Spliterator<P_IN> spliterator) {
+        return opEvaluateParallel(helper, spliterator, i -> (E[]) new Object[i]).spliterator();
+    }
+
+    <P_IN> Node<E> opEvaluateParallel(PipelineHelper<E> helper,
+                                      Spliterator<P_IN> spliterator,
+                                      IntFunction<E[]> generator);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StatelessTestOp.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+/**
+ * The base type of a stateless test operation
+ */
+interface StatelessTestOp<E_IN, E_OUT> extends IntermediateTestOp<E_IN, E_OUT> {
+
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public static<T> AbstractPipeline chain(AbstractPipeline upstream,
+                                            StatelessTestOp<?, T> op) {
+        int flags = op.opGetFlags();
+        switch (op.outputShape()) {
+            case REFERENCE:
+                return new ReferencePipeline.StatelessOp<Object, T>(upstream, op.inputShape(), flags) {
+                    public Sink opWrapSink(int flags, Sink<T> sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+                };
+            case INT_VALUE:
+                return new IntPipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
+                    public Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+                };
+            case LONG_VALUE:
+                return new LongPipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
+                    @Override
+                    Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+                };
+            case DOUBLE_VALUE:
+                return new DoublePipeline.StatelessOp<Object>(upstream, op.inputShape(), flags) {
+                    @Override
+                    Sink opWrapSink(int flags, Sink sink) {
+                        return op.opWrapSink(flags, isParallel(), sink);
+                    }
+                };
+            default: throw new IllegalStateException(op.outputShape().toString());
+        }
+    }
+
+    default StreamShape inputShape() { return StreamShape.REFERENCE; }
+
+    default StreamShape outputShape() { return StreamShape.REFERENCE; }
+
+    default int opGetFlags() { return 0; }
+
+    Sink<E_IN> opWrapSink(int flags, boolean parallel, Sink<E_OUT> sink);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StreamOpFlagTestHelper.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.EnumSet;
+
+public class StreamOpFlagTestHelper {
+
+    /** EnumSet containing stream flags */
+    private static final EnumSet<StreamOpFlag> allStreamFlags;
+
+    static {
+        allStreamFlags = EnumSet.allOf(StreamOpFlag.class);
+        for (StreamOpFlag f : EnumSet.allOf(StreamOpFlag.class))
+            if (!f.isStreamFlag())
+                allStreamFlags.remove(f);
+    }
+
+
+    static EnumSet<StreamOpFlag> allStreamFlags() {
+        // EnumSet is mutable
+        return allStreamFlags.clone();
+    }
+
+    public static boolean isStreamOrdered(Stream<?> s) {
+        return StreamOpFlag.ORDERED.isKnown(OpTestCase.getStreamFlags(s));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StreamTestDataProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import org.testng.annotations.DataProvider;
+
+import java.util.*;
+import java.util.Spliterators;
+import java.util.function.Supplier;
+
+/**
+ * StreamTestDataProvider
+ *
+ * @author Brian Goetz
+ */
+/** TestNG DataProvider for ref-valued streams */
+public class StreamTestDataProvider {
+    private static final Integer[] to0 = new Integer[0];
+    private static final Integer[] to1 = new Integer[1];
+    private static final Integer[] to10 = new Integer[10];
+    private static final Integer[] to100 = new Integer[100];
+    private static final Integer[] to1000 = new Integer[1000];
+    private static final Integer[] reversed = new Integer[100];
+    private static final Integer[] ones = new Integer[100];
+    private static final Integer[] twice = new Integer[200];
+    private static final Integer[] pseudoRandom;
+
+    private static final Object[][] testData;
+    private static final Object[][] testSmallData;
+    private static final Object[][] testMiniData;
+    private static final Object[][] withNullTestData;
+    private static final Object[][] spliteratorTestData;
+
+    static {
+        Integer[][] arrays = {to0, to1, to10, to100, to1000};
+        for (Integer[] arr : arrays) {
+            for (int i = 0; i < arr.length; i++) {
+                arr[i] = i;
+            }
+        }
+        for (int i = 0; i < reversed.length; i++) {
+            reversed[i] = reversed.length - i;
+        }
+        for (int i = 0; i < ones.length; i++) {
+            ones[i] = 1;
+        }
+        System.arraycopy(to100, 0, twice, 0, to100.length);
+        System.arraycopy(to100, 0, twice, to100.length, to100.length);
+        pseudoRandom = new Integer[LambdaTestHelpers.LONG_STRING.length()];
+        for (int i = 0; i < LambdaTestHelpers.LONG_STRING.length(); i++) {
+            pseudoRandom[i] = (int) LambdaTestHelpers.LONG_STRING.charAt(i);
+        }
+    }
+
+    static final Object[][] arrays = {
+            {"empty", to0},
+            {"0..1", to1},
+            {"0..10", to10},
+            {"0..100", to100},
+            {"0..1000", to1000},
+            {"100x[1]", ones},
+            {"2x[0..100]", twice},
+            {"reverse 0..100", reversed},
+            {"pseudorandom", pseudoRandom}
+    };
+
+    static {
+        {
+            List<Object[]> listMini = new ArrayList<>();
+            List<Object[]> listSmall = new ArrayList<>();
+            List<Object[]> list1000 = new ArrayList<>();
+            List<Object[]> list = null;
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final Integer[] ints = (Integer[])data[1];
+                final List<Integer> intsAsList = Arrays.asList(ints);
+
+                list = ints.length >= 1000 ? list1000 : (ints.length >= 100 ? listSmall : listMini);
+
+                list.add(arrayDataDescr("array:" + name, ints));
+                list.add(collectionDataDescr("ArrayList.asList:" + name, intsAsList));
+                list.add(collectionDataDescr("ArrayList:" + name, new ArrayList<>(intsAsList)));
+                list.add(streamDataDescr("DelegatingStream(ArrayList):" + name,
+                                         () -> new ArrayList<>(intsAsList).stream()));
+                List<Integer> aList = new ArrayList<>(intsAsList);
+                if (LambdaTestMode.isNormalMode()) {
+                    // Only include sub-lists for normal test execution mode
+                    // This data is serialization-hostile since the state of the
+                    // deserialized sub-list will be out of sync with the
+                    // enclosing list.
+                    list.add(collectionDataDescr("ArrayList.Sublist:" + name,
+                                                 (ints.length) <= 1 ? aList.subList(0, 0) : aList.subList(1, ints.length / 2)));
+                }
+                list.add(collectionDataDescr("LinkedList:" + name, new LinkedList<>(intsAsList)));
+                list.add(collectionDataDescr("HashSet:" + name, new HashSet<>(intsAsList)));
+                list.add(collectionDataDescr("LinkedHashSet:" + name, new LinkedHashSet<>(intsAsList)));
+                list.add(collectionDataDescr("TreeSet:" + name, new TreeSet<>(intsAsList)));
+                SpinedBuffer<Integer> spinedBuffer = new SpinedBuffer<>();
+                intsAsList.forEach(spinedBuffer);
+                list.add(sbDataDescr("SpinedBuffer:" + name, spinedBuffer));
+
+                // @@@ Add more
+            }
+            testMiniData = listMini.toArray(new Object[0][]);
+            listSmall.addAll(listMini);
+            testSmallData = listSmall.toArray(new Object[0][]);
+            list1000.addAll(listSmall);
+            testData = list1000.toArray(new Object[0][]);
+        }
+
+        // Simple combination of numbers and null values, probably excessive but may catch
+        // errors for initialization/termination/sequence
+        // @@@ This is separate from the other data for now until nulls are consistently supported by
+        // all operations
+        {
+            List<Object[]> list = new ArrayList<>();
+            int size = 5;
+            for (int i = 0; i < (1 << size) - 2; i++) {
+                Integer[] content = new Integer[size];
+                for (int e = 0; e < size; e++) {
+                    content[e] = (i & (1 << e)) > 0 ? e + 1 : null;
+                }
+
+                // ORDERED
+                list.add(arrayDataDescr("array:" + i, content));
+                // not ORDERED, DISTINCT
+                list.add(collectionDataDescr("HashSet:" + i, new HashSet<>(Arrays.asList(content))));
+            }
+
+            withNullTestData = list.toArray(new Object[0][]);
+        }
+
+        {
+            List<Object[]> spliterators = new ArrayList<>();
+            for (Object[] data : arrays) {
+                final Object name = data[0];
+                final Integer[] ints = (Integer[])data[1];
+
+                spliterators.add(splitDescr("Arrays.s(array):" + name,
+                                            () -> Arrays.spliterator(ints)));
+                spliterators.add(splitDescr("arrays.s(array,o,l):" + name,
+                                            () -> Arrays.spliterator(ints, 0, ints.length/2)));
+                spliterators.add(splitDescr("SpinedBuffer.s():" + name,
+                                            () -> {
+                                                SpinedBuffer<Integer> sb = new SpinedBuffer<>();
+                                                for (Integer i : ints)
+                                                    sb.accept(i);
+                                                return sb.spliterator();
+                                            }));
+                spliterators.add(splitDescr("Iterators.s(Arrays.s(array).iterator(), size):" + name,
+                                            () -> Spliterators.spliterator(Arrays.asList(ints).iterator(), ints.length, 0)));
+                spliterators.add(splitDescr("Iterators.s(Arrays.s(array).iterator()):" + name,
+                                            () -> Spliterators.spliteratorUnknownSize(Arrays.asList(ints).iterator(), 0)));
+                spliterators.add(splitDescr("Stream.iterate(0,x->x<l,x->x+1): " + name,
+                                            () -> Stream.iterate(0, x -> x < ints.length, x -> x + 1).spliterator()));
+                // @@@ Add map and collection spliterators when spliterator() is exposed on Collection or Iterable
+            }
+            spliteratorTestData = spliterators.toArray(new Object[0][]);
+        }
+    }
+
+    static <T> Object[] arrayDataDescr(String description, T[] data) {
+        return new Object[] { description, TestData.Factory.ofArray(description, data)};
+    }
+
+    static <T> Object[] streamDataDescr(String description, Supplier<Stream<T>> supplier) {
+        return new Object[] { description, TestData.Factory.ofSupplier(description, supplier)};
+    }
+
+    static <T> Object[] collectionDataDescr(String description, Collection<T> data) {
+        return new Object[] { description, TestData.Factory.ofCollection(description, data)};
+    }
+
+    static <T> Object[] sbDataDescr(String description, SpinedBuffer<T> data) {
+        return new Object[] { description, TestData.Factory.ofSpinedBuffer(description, data)};
+    }
+
+    static <T> Object[] splitDescr(String description, Supplier<Spliterator<T>> ss) {
+        return new Object[] { description, ss };
+    }
+
+    // Return an array of ( String name, StreamTestData<Integer> )
+    @DataProvider(name = "StreamTestData<Integer>")
+    public static Object[][] makeStreamTestData() {
+        return testData;
+    }
+
+    @DataProvider(name = "StreamTestData<Integer>.small")
+    public static Object[][] makeSmallStreamTestData() {
+        return testSmallData;
+    }
+
+    @DataProvider(name = "StreamTestData<Integer>.mini")
+    public static Object[][] makeMiniStreamTestData() {
+        return testMiniData;
+    }
+
+    @DataProvider(name = "withNull:StreamTestData<Integer>")
+    public static Object[][] makeStreamWithNullTestData() {
+        return withNullTestData;
+    }
+
+    // returns an array of (String name, Supplier<Spliterator<Integer>>)
+    @DataProvider(name = "Spliterator<Integer>")
+    public static Object[][] spliteratorProvider() {
+        return spliteratorTestData;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/StreamTestScenario.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.Spliterator;
+import java.util.SpliteratorTestHelper;
+import java.util.function.Consumer;
+import java.util.function.Function;
+
+/**
+ * Test scenarios for reference streams.
+ *
+ * Each scenario is provided with a data source, a function that maps a fresh
+ * stream (as provided by the data source) to a new stream, and a sink to
+ * receive results.  Each scenario describes a different way of computing the
+ * stream contents.  The test driver will ensure that all scenarios produce
+ * the same output (modulo allowable differences in ordering).
+ */
+@SuppressWarnings({"rawtypes", "unchecked"})
+public enum StreamTestScenario implements OpTestCase.BaseStreamTestScenario {
+
+    STREAM_FOR_EACH(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            Stream<U> s = m.apply(source);
+            if (s.isParallel()) {
+                s = s.sequential();
+            }
+            s.forEach(b);
+        }
+    },
+
+    // Collec to list
+    STREAM_COLLECT(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (U t : m.apply(source).collect(Collectors.toList())) {
+                b.accept(t);
+            }
+        }
+    },
+
+    // To array
+    STREAM_TO_ARRAY(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (Object t : m.apply(source).toArray()) {
+                b.accept((U) t);
+            }
+        }
+    },
+
+    // Wrap as stream, and iterate in pull mode
+    STREAM_ITERATOR(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (Iterator<U> seqIter = m.apply(source).iterator(); seqIter.hasNext(); )
+                b.accept(seqIter.next());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (Spliterator<U> spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, spliterate, then split a few times mixing advances with forEach
+    STREAM_SPLITERATOR_WITH_MIXED_TRAVERSE_AND_SPLIT(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            SpliteratorTestHelper.mixedTraverseAndSplit(b, m.apply(source).spliterator());
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate in pull mode
+    STREAM_SPLITERATOR_FOREACH(false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    // Wrap as parallel stream + sequential
+    PAR_STREAM_SEQUENTIAL_FOR_EACH(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            m.apply(source).sequential().forEach(b);
+        }
+    },
+
+    // Wrap as parallel stream + forEachOrdered
+    PAR_STREAM_FOR_EACH_ORDERED(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            // @@@ Want to explicitly select ordered equalator
+            m.apply(source).forEachOrdered(b);
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (Spliterator<U> spl = m.apply(source).spliterator(); spl.tryAdvance(b); ) {
+            }
+        }
+    },
+
+    // Wrap as stream, and spliterate then iterate sequentially
+    PAR_STREAM_SPLITERATOR_FOREACH(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            m.apply(source).spliterator().forEachRemaining(b);
+        }
+    },
+
+    // Wrap as parallel stream + toArray
+    PAR_STREAM_TO_ARRAY(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (Object t : m.apply(source).toArray())
+                b.accept((U) t);
+        }
+    },
+
+    // Wrap as parallel stream, get the spliterator, wrap as a stream + toArray
+    PAR_STREAM_SPLITERATOR_STREAM_TO_ARRAY(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            Stream<U> s = m.apply(source);
+            Spliterator<U> sp = s.spliterator();
+            Stream<U> ss = StreamSupport.stream(() -> sp,
+                                                StreamOpFlag.toCharacteristics(OpTestCase.getStreamFlags(s))
+                                                | (sp.getExactSizeIfKnown() < 0 ? 0 : Spliterator.SIZED), true);
+            for (Object t : ss.toArray())
+                b.accept((U) t);
+        }
+    },
+
+    // Wrap as parallel stream + toArray and clear SIZED flag
+    PAR_STREAM_TO_ARRAY_CLEAR_SIZED(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            Stream<U> pipe2 = m.apply(pipe1);
+
+            for (Object t : pipe2.toArray())
+                b.accept((U) t);
+        }
+    },
+
+    // Wrap as parallel + collect to list
+    PAR_STREAM_COLLECT_TO_LIST(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (U u : m.apply(source).collect(Collectors.toList()))
+                b.accept(u);
+        }
+    },
+
+    // Wrap sequential as parallel, + collect to list
+    STREAM_TO_PAR_STREAM_COLLECT_TO_LIST(true) {
+        public <T, S_IN extends BaseStream<T, S_IN>>
+        S_IN getStream(TestData<T, S_IN> data) {
+            return data.stream().parallel();
+        }
+
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (U u : m.apply(source).collect(Collectors.toList()))
+                b.accept(u);
+        }
+    },
+
+    // Wrap parallel as sequential,, + collect
+    PAR_STREAM_TO_STREAM_COLLECT_TO_LIST(true) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            for (U u : m.apply(source).collect(Collectors.toList()))
+                b.accept(u);
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing
+    PAR_STREAM_FOR_EACH(true, false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            m.apply(source).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+
+    // Wrap as parallel stream + forEach synchronizing and clear SIZED flag
+    PAR_STREAM_FOR_EACH_CLEAR_SIZED(true, false) {
+        <T, U, S_IN extends BaseStream<T, S_IN>>
+        void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m) {
+            S_IN pipe1 = (S_IN) OpTestCase.chain(source,
+                                                 new FlagDeclaringOp(StreamOpFlag.NOT_SIZED, data.getShape()));
+            m.apply(pipe1).forEach(e -> {
+                synchronized (data) {
+                    b.accept(e);
+                }
+            });
+        }
+    },
+    ;
+
+    // The set of scenarios that clean the SIZED flag
+    public static final Set<StreamTestScenario> CLEAR_SIZED_SCENARIOS = Collections.unmodifiableSet(
+            EnumSet.of(PAR_STREAM_TO_ARRAY_CLEAR_SIZED, PAR_STREAM_FOR_EACH_CLEAR_SIZED));
+
+    private final boolean isParallel;
+
+    private final boolean isOrdered;
+
+    StreamTestScenario(boolean isParallel) {
+        this(isParallel, true);
+    }
+
+    StreamTestScenario(boolean isParallel, boolean isOrdered) {
+        this.isParallel = isParallel;
+        this.isOrdered = isOrdered;
+    }
+
+    public StreamShape getShape() {
+        return StreamShape.REFERENCE;
+    }
+
+    public boolean isParallel() {
+        return isParallel;
+    }
+
+    public boolean isOrdered() {
+        return isOrdered;
+    }
+
+    public <T, U, S_IN extends BaseStream<T, S_IN>, S_OUT extends BaseStream<U, S_OUT>>
+    void run(TestData<T, S_IN> data, Consumer<U> b, Function<S_IN, S_OUT> m) {
+        try (S_IN source = getStream(data)) {
+            run(data, source, b, (Function<S_IN, Stream<U>>) m);
+        }
+    }
+
+    abstract <T, U, S_IN extends BaseStream<T, S_IN>>
+    void run(TestData<T, S_IN> data, S_IN source, Consumer<U> b, Function<S_IN, Stream<U>> m);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/TestData.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,355 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.PrimitiveIterator;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.function.DoubleConsumer;
+import java.util.function.Function;
+import java.util.function.IntConsumer;
+import java.util.function.LongConsumer;
+import java.util.function.Supplier;
+import java.util.function.ToIntFunction;
+
+/** Describes a test data set for use in stream tests */
+public interface TestData<T, S extends BaseStream<T, S>>
+        extends Iterable<T> {
+
+    default int size() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    default Iterator<T> iterator() {
+        return Spliterators.iterator(spliterator());
+    }
+
+    Spliterator<T> spliterator();
+
+    default boolean isOrdered() {
+        return spliterator().hasCharacteristics(Spliterator.ORDERED);
+    }
+
+    StreamShape getShape();
+
+    default <A extends Collection<? super T>> A into(A target) {
+        spliterator().forEachRemaining(target::add);
+        return target;
+    }
+
+    S stream();
+
+    S parallelStream();
+
+    public interface OfRef<T> extends TestData<T, Stream<T>> { }
+
+    public interface OfInt extends TestData<Integer, IntStream> { }
+
+    public interface OfLong extends TestData<Long, LongStream> { }
+
+    public interface OfDouble extends TestData<Double, DoubleStream> { }
+
+    // @@@ Temporary garbage class to avoid triggering bugs with lambdas in static methods in interfaces
+    public static class Factory {
+        public static <T> OfRef<T> ofArray(String name, T[] array) {
+            return new AbstractTestData.RefTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
+                                                      Arrays::spliterator, a -> a.length);
+        }
+
+        public static <T> OfRef<T> ofCollection(String name, Collection<T> collection) {
+            return new AbstractTestData.RefTestData<>(name, collection, Collection::stream, Collection::parallelStream,
+                                                      Collection::spliterator, Collection::size);
+        }
+
+        public static <T> OfRef<T> ofSpinedBuffer(String name, SpinedBuffer<T> buffer) {
+            return new AbstractTestData.RefTestData<>(name, buffer,
+                                                      b -> StreamSupport.stream(b.spliterator(), false),
+                                                      b -> StreamSupport.stream(b.spliterator(), true),
+                                                      SpinedBuffer::spliterator,
+                                                      b -> (int) b.count());
+        }
+
+        public static <T> OfRef<T> ofSupplier(String name, Supplier<Stream<T>> supplier) {
+            return new AbstractTestData.RefTestData<>(name, supplier,
+                                                      Supplier::get,
+                                                      s -> s.get().parallel(),
+                                                      s -> s.get().spliterator(),
+                                                      s -> (int) s.get().spliterator().getExactSizeIfKnown());
+        }
+
+        public static <T> OfRef<T> ofRefNode(String name, Node<T> node) {
+            return new AbstractTestData.RefTestData<>(name, node,
+                                                      n -> StreamSupport.stream(n::spliterator, Spliterator.SIZED | Spliterator.ORDERED, false),
+                                                      n -> StreamSupport.stream(n::spliterator, Spliterator.SIZED | Spliterator.ORDERED, true),
+                                                      Node::spliterator,
+                                                      n -> (int) n.count());
+        }
+
+        // int factories
+        public static <T> OfInt ofArray(String name, int[] array) {
+            return new AbstractTestData.IntTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
+                                                      Arrays::spliterator, a -> a.length);
+        }
+
+        public static OfInt ofSpinedBuffer(String name, SpinedBuffer.OfInt buffer) {
+            return new AbstractTestData.IntTestData<>(name, buffer,
+                                                      b -> StreamSupport.intStream(b.spliterator(), false),
+                                                      b -> StreamSupport.intStream(b.spliterator(), true),
+                                                      SpinedBuffer.OfInt::spliterator,
+                                                      b -> (int) b.count());
+        }
+
+        public static OfInt ofIntSupplier(String name, Supplier<IntStream> supplier) {
+            return new AbstractTestData.IntTestData<>(name, supplier,
+                                                      Supplier::get,
+                                                      s -> s.get().parallel(),
+                                                      s -> s.get().spliterator(),
+                                                      s -> (int) s.get().spliterator().getExactSizeIfKnown());
+        }
+
+        public static OfInt ofNode(String name, Node.OfInt node) {
+            int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
+            return new AbstractTestData.IntTestData<>(name, node,
+                                                      n -> StreamSupport.intStream(n::spliterator, characteristics, false),
+                                                      n -> StreamSupport.intStream(n::spliterator, characteristics, true),
+                                                      Node.OfInt::spliterator,
+                                                      n -> (int) n.count());
+        }
+
+        // long factories
+        public static <T> OfLong ofArray(String name, long[] array) {
+            return new AbstractTestData.LongTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
+                                                       Arrays::spliterator, a -> a.length);
+        }
+
+        public static OfLong ofSpinedBuffer(String name, SpinedBuffer.OfLong buffer) {
+            return new AbstractTestData.LongTestData<>(name, buffer,
+                                                      b -> StreamSupport.longStream(b.spliterator(), false),
+                                                      b -> StreamSupport.longStream(b.spliterator(), true),
+                                                      SpinedBuffer.OfLong::spliterator,
+                                                      b -> (int) b.count());
+        }
+
+        public static OfLong ofLongSupplier(String name, Supplier<LongStream> supplier) {
+            return new AbstractTestData.LongTestData<>(name, supplier,
+                                                      Supplier::get,
+                                                      s -> s.get().parallel(),
+                                                      s -> s.get().spliterator(),
+                                                      s -> (int) s.get().spliterator().getExactSizeIfKnown());
+        }
+
+        public static OfLong ofNode(String name, Node.OfLong node) {
+            int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
+            return new AbstractTestData.LongTestData<>(name, node,
+                                                      n -> StreamSupport.longStream(n::spliterator, characteristics, false),
+                                                      n -> StreamSupport.longStream(n::spliterator, characteristics, true),
+                                                      Node.OfLong::spliterator,
+                                                      n -> (int) n.count());
+        }
+
+        // double factories
+        public static <T> OfDouble ofArray(String name, double[] array) {
+            return new AbstractTestData.DoubleTestData<>(name, array, Arrays::stream, a -> Arrays.stream(a).parallel(),
+                                                         Arrays::spliterator, a -> a.length);
+        }
+
+        public static OfDouble ofSpinedBuffer(String name, SpinedBuffer.OfDouble buffer) {
+            return new AbstractTestData.DoubleTestData<>(name, buffer,
+                                                         b -> StreamSupport.doubleStream(b.spliterator(), false),
+                                                         b -> StreamSupport.doubleStream(b.spliterator(), true),
+                                                         SpinedBuffer.OfDouble::spliterator,
+                                                         b -> (int) b.count());
+        }
+
+        public static OfDouble ofDoubleSupplier(String name, Supplier<DoubleStream> supplier) {
+            return new AbstractTestData.DoubleTestData<>(name, supplier,
+                                                         Supplier::get,
+                                                         s -> s.get().parallel(),
+                                                         s -> s.get().spliterator(),
+                                                         s -> (int) s.get().spliterator().getExactSizeIfKnown());
+        }
+
+        public static OfDouble ofNode(String name, Node.OfDouble node) {
+            int characteristics = Spliterator.SIZED | Spliterator.ORDERED;
+            return new AbstractTestData.DoubleTestData<>(name, node,
+                                                         n -> StreamSupport.doubleStream(n::spliterator, characteristics, false),
+                                                         n -> StreamSupport.doubleStream(n::spliterator, characteristics, true),
+                                                         Node.OfDouble::spliterator,
+                                                         n -> (int) n.count());
+        }
+    }
+
+
+    abstract class AbstractTestData<T, S extends BaseStream<T, S>,
+            T_STATE,
+                                    T_SPLITR extends Spliterator<T>>
+            implements TestData<T, S> {
+        private final String name;
+        private final StreamShape shape;
+        protected final T_STATE state;
+        private final ToIntFunction<T_STATE> sizeFn;
+        private final Function<T_STATE, S> streamFn;
+        private final Function<T_STATE, S> parStreamFn;
+        private final Function<T_STATE, T_SPLITR> splitrFn;
+
+        AbstractTestData(String name,
+                         StreamShape shape,
+                         T_STATE state,
+                         Function<T_STATE, S> streamFn,
+                         Function<T_STATE, S> parStreamFn,
+                         Function<T_STATE, T_SPLITR> splitrFn,
+                         ToIntFunction<T_STATE> sizeFn) {
+            this.name = name;
+            this.shape = shape;
+            this.state = state;
+            this.streamFn = streamFn;
+            this.parStreamFn = parStreamFn;
+            this.splitrFn = splitrFn;
+            this.sizeFn = sizeFn;
+        }
+
+        @Override
+        public StreamShape getShape() {
+            return shape;
+        }
+
+        @Override
+        public String toString() {
+            return getClass().getSimpleName() + "[" + name + "]";
+        }
+
+        @Override
+        public int size() {
+            return sizeFn.applyAsInt(state);
+        }
+
+        @Override
+        public T_SPLITR spliterator() {
+            return splitrFn.apply(state);
+        }
+
+        @Override
+        public S stream() {
+            return streamFn.apply(state);
+        }
+
+        @Override
+        public S parallelStream() {
+            return parStreamFn.apply(state);
+        }
+
+        public static class RefTestData<T, I>
+                extends AbstractTestData<T, Stream<T>, I, Spliterator<T>>
+                implements TestData.OfRef<T> {
+
+            protected RefTestData(String name,
+                                  I state,
+                                  Function<I, Stream<T>> streamFn,
+                                  Function<I, Stream<T>> parStreamFn,
+                                  Function<I, Spliterator<T>> splitrFn,
+                                  ToIntFunction<I> sizeFn) {
+                super(name, StreamShape.REFERENCE, state, streamFn, parStreamFn, splitrFn, sizeFn);
+            }
+
+        }
+
+        static class IntTestData<I>
+                extends AbstractTestData<Integer, IntStream, I, Spliterator.OfInt>
+                implements TestData.OfInt {
+
+            protected IntTestData(String name,
+                                  I state,
+                                  Function<I, IntStream> streamFn,
+                                  Function<I, IntStream> parStreamFn,
+                                  Function<I, Spliterator.OfInt> splitrFn,
+                                  ToIntFunction<I> sizeFn) {
+                super(name, StreamShape.INT_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
+            }
+
+            @Override
+            public PrimitiveIterator.OfInt iterator() {
+                return Spliterators.iterator(spliterator());
+            }
+
+            @Override
+            public <A extends Collection<? super Integer>> A into(A target) {
+                spliterator().forEachRemaining((IntConsumer) target::add);
+                return target;
+            }
+        }
+
+        static class LongTestData<I>
+                extends AbstractTestData<Long, LongStream, I, Spliterator.OfLong>
+                implements TestData.OfLong {
+
+            protected LongTestData(String name,
+                                   I state,
+                                   Function<I, LongStream> streamFn,
+                                   Function<I, LongStream> parStreamFn,
+                                   Function<I, Spliterator.OfLong> splitrFn,
+                                   ToIntFunction<I> sizeFn) {
+                super(name, StreamShape.LONG_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
+            }
+
+            @Override
+            public PrimitiveIterator.OfLong iterator() {
+                return Spliterators.iterator(spliterator());
+            }
+
+            @Override
+            public <A extends Collection<? super Long>> A into(A target) {
+                spliterator().forEachRemaining((LongConsumer) target::add);
+                return target;
+            }
+        }
+
+        static class DoubleTestData<I>
+                extends AbstractTestData<Double, DoubleStream, I, Spliterator.OfDouble>
+                implements OfDouble {
+
+            protected DoubleTestData(String name,
+                                     I state,
+                                     Function<I, DoubleStream> streamFn,
+                                     Function<I, DoubleStream> parStreamFn,
+                                     Function<I, Spliterator.OfDouble> splitrFn,
+                                     ToIntFunction<I> sizeFn) {
+                super(name, StreamShape.DOUBLE_VALUE, state, streamFn, parStreamFn, splitrFn, sizeFn);
+            }
+
+            @Override
+            public PrimitiveIterator.OfDouble iterator() {
+                return Spliterators.iterator(spliterator());
+            }
+
+            @Override
+            public <A extends Collection<? super Double>> A into(A target) {
+                spliterator().forEachRemaining((DoubleConsumer) target::add);
+                return target;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/TestFlagExpectedOp.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import org.testng.Assert;
+
+import java.util.EnumSet;
+
+class TestFlagExpectedOp<T> extends FlagDeclaringOp<T> {
+
+    static class Builder<T> {
+        final int flags;
+        StreamShape shape = StreamShape.REFERENCE;
+
+        EnumSet<StreamOpFlag> known = EnumSet.noneOf(StreamOpFlag.class);
+        EnumSet<StreamOpFlag> preserve = EnumSet.noneOf(StreamOpFlag.class);
+        EnumSet<StreamOpFlag> notKnown = EnumSet.noneOf(StreamOpFlag.class);
+
+        Builder(int flags) {
+            this.flags = flags;
+        }
+
+        Builder<T> known(EnumSet<StreamOpFlag> known) {
+            this.known = known;
+            return this;
+        }
+
+        Builder<T> preserve(EnumSet<StreamOpFlag> preserve) {
+            this.preserve = preserve;
+            return this;
+        }
+
+        Builder<T> notKnown(EnumSet<StreamOpFlag> notKnown) {
+            this.notKnown = notKnown;
+            return this;
+        }
+
+        Builder<T> shape(StreamShape shape) {
+            this.shape = shape;
+            return this;
+        }
+
+        TestFlagExpectedOp<T> build() {
+            return new TestFlagExpectedOp<>(flags, known, preserve, notKnown, shape);
+        }
+    }
+
+    final EnumSet<StreamOpFlag> known;
+    final EnumSet<StreamOpFlag> preserve;
+    final EnumSet<StreamOpFlag> notKnown;
+    final StreamShape shape;
+
+    TestFlagExpectedOp(int flags,
+                       EnumSet<StreamOpFlag> known,
+                       EnumSet<StreamOpFlag> preserve,
+                       EnumSet<StreamOpFlag> notKnown) {
+        this(flags, known, preserve, notKnown, StreamShape.REFERENCE);
+    }
+
+    TestFlagExpectedOp(int flags,
+                       EnumSet<StreamOpFlag> known,
+                       EnumSet<StreamOpFlag> preserve,
+                       EnumSet<StreamOpFlag> notKnown,
+                       StreamShape shape) {
+        super(flags);
+        this.known = known;
+        this.preserve = preserve;
+        this.notKnown = notKnown;
+        this.shape = shape;
+    }
+
+    @Override
+    public StreamShape outputShape() {
+        return shape;
+    }
+
+    @Override
+    public StreamShape inputShape() {
+        return shape;
+    }
+
+    @Override
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    public Sink<T> opWrapSink(int flags, boolean parallel, Sink upstream) {
+        assertFlags(flags);
+        return upstream;
+    }
+
+    private void assertFlags(int flags) {
+        for (StreamOpFlag f : known) {
+            Assert.assertTrue(f.isKnown(flags),
+                              String.format("Flag %s is not known, but should be known.", f.toString()));
+        }
+
+        for (StreamOpFlag f : preserve) {
+            Assert.assertTrue(f.isPreserved(flags),
+                              String.format("Flag %s is not preserved, but should be preserved.", f.toString()));
+        }
+
+        for (StreamOpFlag f : notKnown) {
+            Assert.assertFalse(f.isKnown(flags),
+                               String.format("Flag %s is known, but should be not known.", f.toString()));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/bootlib/java.base/java/util/stream/ThrowableHelper.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.util.stream;
+
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+public final class ThrowableHelper {
+
+    public static void checkException(Class<? extends Exception> ce, Runnable r) {
+        Exception caught = null;
+        try {
+            r.run();
+        } catch (Exception e) {
+            caught = e;
+        }
+
+        assertNotNull(caught);
+        assertTrue(ce.isInstance(caught));
+    }
+
+    public static void checkNPE(Runnable r) {
+        checkException(NullPointerException.class, r);
+    }
+
+    public static void checkISE(Runnable r) {
+        checkException(IllegalStateException.class, r);
+    }
+}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/FileUtils.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,230 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.io.IOException;
-import java.nio.file.DirectoryNotEmptyException;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.NoSuchFileException;
-import java.nio.file.Path;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * Common library for various test file utility functions.
- */
-public final class FileUtils {
-
-    private static final boolean isWindows =
-                            System.getProperty("os.name").startsWith("Windows");
-    private static final int RETRY_DELETE_MILLIS = isWindows ? 500 : 0;
-    private static final int MAX_RETRY_DELETE_TIMES = isWindows ? 15 : 0;
-
-    /**
-     * Deletes a file, retrying if necessary.
-     *
-     * @param path  the file to delete
-     *
-     * @throws NoSuchFileException
-     *         if the file does not exist (optional specific exception)
-     * @throws DirectoryNotEmptyException
-     *         if the file is a directory and could not otherwise be deleted
-     *         because the directory is not empty (optional specific exception)
-     * @throws IOException
-     *         if an I/O error occurs
-     */
-    public static void deleteFileWithRetry(Path path)
-        throws IOException
-    {
-        try {
-            deleteFileWithRetry0(path);
-        } catch (InterruptedException x) {
-            throw new IOException("Interrupted while deleting.", x);
-        }
-    }
-
-    /**
-     * Deletes a file, retrying if necessary.
-     * No exception thrown if file doesn't exist.
-     *
-     * @param path  the file to delete
-     *
-     * @throws NoSuchFileException
-     *         if the file does not exist (optional specific exception)
-     * @throws DirectoryNotEmptyException
-     *         if the file is a directory and could not otherwise be deleted
-     *         because the directory is not empty (optional specific exception)
-     * @throws IOException
-     *         if an I/O error occurs
-     */
-    public static void deleteFileIfExistsWithRetry(Path path)
-        throws IOException
-    {
-        try {
-            if(Files.exists(path))
-                deleteFileWithRetry0(path);
-        } catch (InterruptedException x) {
-            throw new IOException("Interrupted while deleting.", x);
-        }
-    }
-
-    private static void deleteFileWithRetry0(Path path)
-        throws IOException, InterruptedException
-    {
-        int times = 0;
-        IOException ioe = null;
-        while (true) {
-            try {
-                Files.delete(path);
-                while (Files.exists(path)) {
-                    times++;
-                    if (times > MAX_RETRY_DELETE_TIMES)
-                        throw new IOException("File still exists after " + times + " waits.");
-                    Thread.sleep(RETRY_DELETE_MILLIS);
-                }
-                break;
-            } catch (NoSuchFileException | DirectoryNotEmptyException x) {
-                throw x;
-            } catch (IOException x) {
-                // Backoff/retry in case another process is accessing the file
-                times++;
-                if (ioe == null)
-                    ioe = x;
-                else
-                    ioe.addSuppressed(x);
-
-                if (times > MAX_RETRY_DELETE_TIMES)
-                    throw ioe;
-                Thread.sleep(RETRY_DELETE_MILLIS);
-            }
-        }
-    }
-
-    /**
-     * Deletes a directory and its subdirectories, retrying if necessary.
-     *
-     * @param dir  the directory to delete
-     *
-     * @throws  IOException
-     *          If an I/O error occurs. Any such exceptions are caught
-     *          internally. If only one is caught, then it is re-thrown.
-     *          If more than one exception is caught, then the second and
-     *          following exceptions are added as suppressed exceptions of the
-     *          first one caught, which is then re-thrown.
-     */
-    public static void deleteFileTreeWithRetry(Path dir)
-         throws IOException
-    {
-        IOException ioe = null;
-        final List<IOException> excs = deleteFileTreeUnchecked(dir);
-        if (!excs.isEmpty()) {
-            ioe = excs.remove(0);
-            for (IOException x : excs)
-                ioe.addSuppressed(x);
-        }
-        if (ioe != null)
-            throw ioe;
-    }
-
-    public static List<IOException> deleteFileTreeUnchecked(Path dir) {
-        final List<IOException> excs = new ArrayList<>();
-        try {
-            java.nio.file.Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
-                @Override
-                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
-                    try {
-                        deleteFileWithRetry0(file);
-                    } catch (IOException x) {
-                        excs.add(x);
-                    } catch (InterruptedException x) {
-                        excs.add(new IOException("Interrupted while deleting.", x));
-                        return FileVisitResult.TERMINATE;
-                    }
-                    return FileVisitResult.CONTINUE;
-                }
-                @Override
-                public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
-                    try {
-                        deleteFileWithRetry0(dir);
-                    } catch (IOException x) {
-                        excs.add(x);
-                    } catch (InterruptedException x) {
-                        excs.add(new IOException("Interrupted while deleting.", x));
-                        return FileVisitResult.TERMINATE;
-                    }
-                    return FileVisitResult.CONTINUE;
-                }
-                @Override
-                public FileVisitResult visitFileFailed(Path file, IOException exc) {
-                    excs.add(exc);
-                    return FileVisitResult.CONTINUE;
-                }
-            });
-        } catch (IOException x) {
-            excs.add(x);
-        }
-        return excs;
-    }
-
-    /**
-     * Checks whether all file systems are accessible. This is performed
-     * by checking free disk space on all mounted file systems via a
-     * separate, spawned process. File systems are considered to be
-     * accessible if this process completes successfully before a given
-     * fixed duration has elapsed.
-     *
-     * @implNote On Unix this executes the {@code df} command in a separate
-     * process and on Windows always returns {@code true}.
-     */
-    public static boolean areFileSystemsAccessible() throws IOException {
-        boolean areFileSystemsAccessible = true;
-        if (!isWindows) {
-            // try to check whether 'df' hangs
-            System.out.println("\n--- df output ---");
-            System.out.flush();
-            Process proc = new ProcessBuilder("df").inheritIO().start();
-            try {
-                proc.waitFor(90, TimeUnit.SECONDS);
-            } catch (InterruptedException ignored) {
-            }
-            try {
-                int exitValue = proc.exitValue();
-                if (exitValue != 0) {
-                    System.err.printf("df process exited with %d != 0%n",
-                        exitValue);
-                    areFileSystemsAccessible = false;
-                }
-            } catch (IllegalThreadStateException ignored) {
-                System.err.println("df command apparently hung");
-                areFileSystemsAccessible = false;
-            }
-        }
-        return areFileSystemsAccessible;
-    }
-}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/FilterClassLoader.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.testlibrary;
-
-import java.util.function.Predicate;
-/**
- * A classloader, which using target classloader in case provided condition
- * for class name is met, and using parent otherwise
- */
-public class FilterClassLoader extends ClassLoader {
-
-    private final ClassLoader target;
-    private final Predicate<String> condition;
-
-    public FilterClassLoader(ClassLoader target, ClassLoader parent,
-            Predicate<String> condition) {
-        super(parent);
-        this.condition = condition;
-        this.target = target;
-    }
-
-    @Override
-    public Class<?> loadClass(String name) throws ClassNotFoundException {
-        if (condition.test(name)) {
-            return target.loadClass(name);
-        }
-        return super.loadClass(name);
-    }
-}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/IOUtils.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-/**
- * Defines useful I/O methods.
- */
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-
-public final class IOUtils {
-
-    /*
-     * Prevent instantiation.
-     */
-    private IOUtils() {}
-
-    /**
-     * Read all bytes from <code>in</code>
-     * until EOF is detected.
-     * @param in input stream, must not be null
-     * @return bytes read
-     * @throws IOException Any IO error.
-     */
-    public static byte[] readFully(InputStream is) throws IOException {
-        byte[] output = {};
-        int pos = 0;
-        while (true) {
-            int bytesToRead;
-            if (pos >= output.length) { // Only expand when there's no room
-                bytesToRead = output.length + 1024;
-                if (output.length < pos + bytesToRead) {
-                    output = Arrays.copyOf(output, pos + bytesToRead);
-                }
-            } else {
-                bytesToRead = output.length - pos;
-            }
-            int cc = is.read(output, pos, bytesToRead);
-            if (cc < 0) {
-                if (output.length != pos) {
-                    output = Arrays.copyOf(output, pos);
-                }
-                break;
-            }
-            pos += cc;
-        }
-        return output;
-    }
-}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/JDKToolLauncher.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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()));
     }
 
     /**
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/JarUtils.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-
-/**
- * Common library for various test jar file utility functions.
- */
-public final class JarUtils {
-
-    /**
-     * Create jar file with specified files. If a specified file does not exist,
-     * a new jar entry will be created with the file name itself as the content.
-     */
-    public static void createJar(String dest, String... files)
-            throws IOException {
-        try (JarOutputStream jos = new JarOutputStream(
-                new FileOutputStream(dest), new Manifest())) {
-            for (String file : files) {
-                System.out.println(String.format("Adding %s to %s",
-                        file, dest));
-
-                // add an archive entry, and write a file
-                jos.putNextEntry(new JarEntry(file));
-                try (FileInputStream fis = new FileInputStream(file)) {
-                    fis.transferTo(jos);
-                } catch (FileNotFoundException e) {
-                    jos.write(file.getBytes());
-                }
-            }
-        }
-        System.out.println();
-    }
-
-    /**
-     * Add or remove specified files to existing jar file. If a specified file
-     * to be updated or added does not exist, the jar entry will be created
-     * with the file name itself as the content.
-     *
-     * @param src the original jar file name
-     * @param dest the new jar file name
-     * @param files the files to update. The list is broken into 2 groups
-     *              by a "-" string. The files before in the 1st group will
-     *              be either updated or added. The files in the 2nd group
-     *              will be removed. If no "-" exists, all files belong to
-     *              the 1st group.
-     */
-    public static void updateJar(String src, String dest, String... files)
-            throws IOException {
-        try (JarOutputStream jos = new JarOutputStream(
-                new FileOutputStream(dest))) {
-
-            // copy each old entry into destination unless the entry name
-            // is in the updated list
-            List<String> updatedFiles = new ArrayList<>();
-            try (JarFile srcJarFile = new JarFile(src)) {
-                Enumeration<JarEntry> entries = srcJarFile.entries();
-                while (entries.hasMoreElements()) {
-                    JarEntry entry = entries.nextElement();
-                    String name = entry.getName();
-                    boolean found = false;
-                    boolean update = true;
-                    for (String file : files) {
-                        if (file.equals("-")) {
-                            update = false;
-                        } else if (name.equals(file)) {
-                            updatedFiles.add(file);
-                            found = true;
-                            break;
-                        }
-                    }
-
-                    if (found) {
-                        if (update) {
-                            System.out.println(String.format("Updating %s with %s",
-                                    dest, name));
-                            jos.putNextEntry(new JarEntry(name));
-                            try (FileInputStream fis = new FileInputStream(name)) {
-                                fis.transferTo(jos);
-                            } catch (FileNotFoundException e) {
-                                jos.write(name.getBytes());
-                            }
-                        } else {
-                            System.out.println(String.format("Removing %s from %s",
-                                    name, dest));
-                        }
-                    } else {
-                        System.out.println(String.format("Copying %s to %s",
-                                name, dest));
-                        jos.putNextEntry(entry);
-                        srcJarFile.getInputStream(entry).transferTo(jos);
-                    }
-                }
-            }
-
-            // append new files
-            for (String file : files) {
-                if (file.equals("-")) {
-                    break;
-                }
-                if (!updatedFiles.contains(file)) {
-                    System.out.println(String.format("Adding %s with %s",
-                            dest, file));
-                    jos.putNextEntry(new JarEntry(file));
-                    try (FileInputStream fis = new FileInputStream(file)) {
-                        fis.transferTo(jos);
-                    } catch (FileNotFoundException e) {
-                        jos.write(file.getBytes());
-                    }
-                }
-            }
-        }
-        System.out.println();
-    }
-
-}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/LockFreeLogManager.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.util.Collection;
-import java.util.Formatter;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-
-/**
- * A log manager designed specifically to allow collecting ordered log messages
- * in a multi-threaded environment without involving any kind of locking.
- * <p>
- * It is particularly useful in situations when one needs to assert various
- * details about the tested thread state or the locks it hold while also wanting
- * to produce diagnostic log messages.
- * <p>
- * The log manager does not provide any guarantees about the completness of the
- * logs written from different threads - it is up to the caller to make sure
- * {@code toString()} method is called only when all the activity has ceased
- * and the per-thread logs contain all the necessary data.
- *
- * @author Jaroslav Bachorik
- **/
-public class LockFreeLogManager {
-    private final AtomicInteger logCntr = new AtomicInteger(0);
-    private final Collection<Map<Integer, String>> allRecords = new ConcurrentLinkedQueue<>();
-    private final ThreadLocal<Map<Integer, String>> records = new ThreadLocal<Map<Integer, String>>() {
-        @Override
-        protected Map<Integer, String> initialValue() {
-            Map<Integer, String> m = new ConcurrentHashMap<>();
-            allRecords.add(m);
-            return m;
-        }
-
-    };
-
-    /**
-     * Log a message
-     * @param format Message format
-     * @param params Message parameters
-     */
-    public void log(String format, Object ... params) {
-        int id = logCntr.getAndIncrement();
-        try (Formatter formatter = new Formatter()) {
-            records.get().put(id, formatter.format(format, params).toString());
-        }
-    }
-
-    /**
-     * Will generate an aggregated log of chronologically ordered messages.
-     * <p>
-     * Make sure that you call this method only when all the related threads
-     * have finished; otherwise you might get incomplete data.
-     *
-     * @return An aggregated log of chronologically ordered messages
-     */
-    @Override
-    public String toString() {
-        return allRecords.stream()
-            .flatMap(m->m.entrySet().stream())
-            .sorted((l, r)->l.getKey().compareTo(r.getKey()))
-            .map(e->e.getValue())
-            .collect(Collectors.joining());
-    }
-}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/NetworkConfiguration.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.io.PrintStream;
-import java.io.UncheckedIOException;
-import java.io.IOException;
-import java.net.Inet4Address;
-import java.net.Inet6Address;
-import java.net.InetAddress;
-import java.net.NetworkInterface;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.function.Predicate;
-import java.util.stream.Stream;
-import static java.net.NetworkInterface.getNetworkInterfaces;
-import static java.util.Collections.list;
-
-/**
- * Helper class for retrieving network interfaces and local addresses
- * suitable for testing.
- */
-public class NetworkConfiguration {
-
-    static final boolean isWindows =
-            System.getProperty("os.name").startsWith("Windows");
-    static final boolean isMacOS =
-            System.getProperty("os.name").contains("OS X");
-
-    private Map<NetworkInterface,List<Inet4Address>> ip4Interfaces;
-    private Map<NetworkInterface,List<Inet6Address>> ip6Interfaces;
-
-    private NetworkConfiguration(Map<NetworkInterface,List<Inet4Address>> ip4Interfaces,
-                                 Map<NetworkInterface,List<Inet6Address>> ip6Interfaces)
-    {
-        this.ip4Interfaces = ip4Interfaces;
-        this.ip6Interfaces = ip6Interfaces;
-    }
-
-    /**
-     * Returns a stream of interfaces suitable for functional tests.
-     */
-    public Stream<NetworkInterface> interfaces() {
-        return Stream.concat(ip4Interfaces(), ip6Interfaces())
-                     .distinct();
-    }
-
-    /**
-     * Returns a stream of interfaces suitable for IPv4 functional tests.
-     */
-    public Stream<NetworkInterface> ip4Interfaces() {
-        return ip4Interfaces.keySet().stream()
-                .filter(NetworkConfiguration::isNotExcludedInterface)
-                .filter(hasIp4Addresses);
-    }
-
-    /**
-     * Returns a stream of interfaces suitable for IPv6 functional tests.
-     */
-    public Stream<NetworkInterface> ip6Interfaces() {
-        return ip6Interfaces.keySet().stream()
-                .filter(NetworkConfiguration::isNotExcludedInterface)
-                .filter(hasIp6Addresses);
-    }
-
-    private static boolean isNotExcludedInterface(NetworkInterface nif) {
-        if (isMacOS && nif.getName().contains("awdl"))
-            return false;
-        String dName = nif.getDisplayName();
-        if (isWindows && dName != null && dName.contains("Teredo"))
-            return false;
-        return true;
-    }
-
-    private final Predicate<NetworkInterface> hasIp4Addresses = nif -> {
-        Optional<?> addr = ip4Interfaces.get(nif).stream()
-                .filter(a -> !a.isAnyLocalAddress())
-                .findAny();
-
-        return addr.isPresent();
-    };
-
-    private final Predicate<NetworkInterface> hasIp6Addresses = nif -> {
-        Optional<?> addr = ip6Interfaces.get(nif).stream()
-                .filter(a -> !a.isAnyLocalAddress())
-                .findAny();
-
-        return addr.isPresent();
-    };
-
-
-    /**
-     * Returns a stream of interfaces suitable for IPv4 multicast tests.
-     */
-    public Stream<NetworkInterface> ip4MulticastInterfaces() {
-        return ip4Interfaces().filter(supportsIp4Multicast);
-    }
-
-    /**
-     * Returns a stream of interfaces suitable for IPv6 multicast tests.
-     */
-    public Stream<NetworkInterface> ip6MulticastInterfaces() {
-        return ip6Interfaces().filter(supportsIp6Multicast);
-    }
-
-    private final Predicate<NetworkInterface> supportsIp4Multicast = nif -> {
-        try {
-            if (!nif.supportsMulticast() || nif.isLoopback())
-                return false;
-
-            Optional<?> addr = ip4Interfaces.get(nif).stream()
-                    .filter(a -> !a.isAnyLocalAddress())
-                    .findAny();
-
-            return addr.isPresent();
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
-    };
-
-    private final Predicate<NetworkInterface> supportsIp6Multicast = nif -> {
-        try {
-            if (!nif.supportsMulticast() || nif.isLoopback())
-                return false;
-
-            Optional<?> addr = ip6Interfaces.get(nif).stream()
-                    .filter(a -> !a.isAnyLocalAddress())
-                    .findAny();
-
-            return addr.isPresent();
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
-    };
-
-    /**
-     * Returns all addresses on all "functional" interfaces.
-     */
-    public Stream<InetAddress> addresses(NetworkInterface nif) {
-        return Stream.concat(ip4Interfaces.get(nif).stream(),
-                             ip6Interfaces.get(nif).stream());
-    }
-
-    /**
-     * Returns all IPv4 addresses on all "functional" interfaces.
-     */
-    public Stream<Inet4Address> ip4Addresses() {
-        return ip4Interfaces().flatMap(nif -> ip4Addresses(nif));
-    }
-
-    /**
-     * Returns all IPv6 addresses on all "functional" interfaces.
-     */
-    public Stream<Inet6Address> ip6Addresses() {
-        return ip6Interfaces().flatMap(nif -> ip6Addresses(nif));
-    }
-
-    /**
-     * Returns all IPv4 addresses the given interface.
-     */
-    public Stream<Inet4Address> ip4Addresses(NetworkInterface nif) {
-        return ip4Interfaces.get(nif).stream();
-    }
-
-    /**
-     * Returns all IPv6 addresses for the given interface.
-     */
-    public Stream<Inet6Address> ip6Addresses(NetworkInterface nif) {
-        return ip6Interfaces.get(nif).stream();
-    }
-
-    /**
-     * Return a NetworkConfiguration instance.
-     */
-    public static NetworkConfiguration probe() throws IOException {
-        Map<NetworkInterface, List<Inet4Address>> ip4Interfaces = new HashMap<>();
-        Map<NetworkInterface, List<Inet6Address>> ip6Interfaces = new HashMap<>();
-
-        List<NetworkInterface> nifs = list(getNetworkInterfaces());
-        for (NetworkInterface nif : nifs) {
-            // ignore interfaces that are down
-            if (!nif.isUp() || nif.isPointToPoint())
-                continue;
-
-            List<Inet4Address> ip4Addresses = new LinkedList<>();
-            List<Inet6Address> ip6Addresses = new LinkedList<>();
-            ip4Interfaces.put(nif, ip4Addresses);
-            ip6Interfaces.put(nif, ip6Addresses);
-            for (InetAddress addr : list(nif.getInetAddresses())) {
-                if (addr instanceof Inet4Address)
-                    ip4Addresses.add((Inet4Address)addr);
-                else if (addr instanceof Inet6Address)
-                    ip6Addresses.add((Inet6Address)addr);
-            }
-        }
-        return new NetworkConfiguration(ip4Interfaces, ip6Interfaces);
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        interfaces().forEach(nif -> sb.append(interfaceInformation(nif)));
-        return sb.toString();
-    }
-
-    /** Returns detailed information for the given interface. */
-    public static String interfaceInformation(NetworkInterface nif) {
-        StringBuilder sb = new StringBuilder();
-        try {
-            sb.append("Display name: " + nif.getDisplayName() + "\n");
-            sb.append("Name: " + nif.getName() + "\n");
-            for (InetAddress inetAddress : list(nif.getInetAddresses()))
-                sb.append("InetAddress: " + inetAddress + "\n");
-            sb.append("Up? " + nif.isUp() + "\n");
-            sb.append("Loopback? " + nif.isLoopback() + "\n");
-            sb.append("PointToPoint? " + nif.isPointToPoint() + "\n");
-            sb.append("Supports multicast? " + nif.supportsMulticast() + "\n");
-            sb.append("Virtual? " + nif.isVirtual() + "\n");
-            sb.append("Hardware address: " +
-                    Arrays.toString(nif.getHardwareAddress()) + "\n");
-            sb.append("MTU: " + nif.getMTU() + "\n");
-            sb.append("Index: " + nif.getIndex() + "\n");
-            sb.append("\n");
-            return sb.toString();
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
-    }
-
-    /** Prints all the system interface information to the give stream. */
-    public static void printSystemConfiguration(PrintStream out) {
-        try {
-            out.println("*** all system network interface configuration ***");
-            List<NetworkInterface> nifs = list(getNetworkInterfaces());
-            for (NetworkInterface nif : nifs)
-                out.print(interfaceInformation(nif));
-            out.println("*** end ***");
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
-    }
-}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/ParentLastURLClassLoader.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package jdk.testlibrary;
-
-import java.net.URL;
-import java.net.URLClassLoader;
-
-/**
- * An url classloader, which trying to load class from provided URL[] first,
- * and using parent classloader in case it failed
- */
-public class ParentLastURLClassLoader extends URLClassLoader {
-
-    public ParentLastURLClassLoader(URL urls[], ClassLoader parent) {
-        super(urls, parent);
-    }
-
-    @Override
-    public Class<?> loadClass(String name) throws ClassNotFoundException {
-        try {
-            Class<?> c = findClass(name);
-            if (c != null) {
-                return c;
-            }
-        } catch (ClassNotFoundException e) {
-            // ignore
-        }
-        return super.loadClass(name);
-    }
-}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/RandomFactory.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/RandomFactory.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,12 @@
  * Factory class which generates and prints to STDOUT a long-valued seed
  * for use in initializing a PRNG.  An instance of {@code Random} or
  * {@code SplittableRandom} may likewise be obtained.
+ *
+ * @deprecated  This class is deprecated. Use the one from
+ *              {@code <root>/test/lib/jdk/test/lib}
+ *
  */
+@Deprecated
 public class RandomFactory {
     /**
      * Attempt to obtain the seed from the value of the "seed" property.
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/SerializationUtils.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary;
-
-import java.io.*;
-
-/**
- * Common library for various test serialization utility functions.
- */
-public final class SerializationUtils {
-    /*
-     * Serialize an object into byte array.
-     */
-    public static byte[] serialize(Object obj) throws Exception {
-        try (ByteArrayOutputStream bs = new ByteArrayOutputStream();
-                ObjectOutputStream out = new ObjectOutputStream(bs);) {
-            out.writeObject(obj);
-            return bs.toByteArray();
-        }
-    }
-
-    /*
-     * Deserialize an object from byte array.
-     */
-    public static Object deserialize(byte[] ba) throws Exception {
-        try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(ba));) {
-            return in.readObject();
-        }
-    }
-}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/management/InputArguments.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary.management;
-
-import java.lang.management.RuntimeMXBean;
-import java.lang.management.ManagementFactory;
-import java.util.List;
-
-/**
- * This class provides access to the input arguments to the VM.
- */
-public class InputArguments {
-    private static final List<String> args;
-
-    static {
-        RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
-        args = runtimeMxBean.getInputArguments();
-    }
-
-    /**
-     * Returns true if {@code arg} is an input argument to the VM.
-     *
-     * This is useful for checking boolean flags such as -XX:+UseSerialGC or
-     * -XX:-UsePerfData.
-     *
-     * @param arg The name of the argument.
-     * @return {@code true} if the given argument is an input argument,
-     *         otherwise {@code false}.
-     */
-    public static boolean contains(String arg) {
-        return args.contains(arg);
-    }
-
-    /**
-     * Returns true if {@code prefix} is the start of an input argument to the
-     * VM.
-     *
-     * This is useful for checking if flags describing a quantity, such as
-     * -XX:+MaxMetaspaceSize=100m, is set without having to know the quantity.
-     * To check if the flag -XX:MaxMetaspaceSize is set, use
-     * {@code InputArguments.containsPrefix("-XX:MaxMetaspaceSize")}.
-     *
-     * @param prefix The start of the argument.
-     * @return {@code true} if the given argument is the start of an input
-     *         argument, otherwise {@code false}.
-     */
-    public static boolean hasArgStartingWith(String prefix) {
-        for (String arg : args) {
-            if (arg.startsWith(prefix)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Get the string containing input arguments passed to the VM
-     */
-    public static String getInputArguments() {
-        StringBuilder result = new StringBuilder();
-        for (String arg : args)
-            result.append(arg).append(' ');
-
-        return result.toString();
-    }
-
-}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/management/ThreadMXBeanTool.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.testlibrary.management;
-
-import java.lang.management.ManagementFactory;
-import java.lang.management.ThreadInfo;
-import java.lang.management.ThreadMXBean;
-import java.util.concurrent.TimeoutException;
-
-/**
- * A few utility methods to use ThreadMXBean.
- */
-public final class ThreadMXBeanTool {
-
-    /**
-     * Waits until {@link Thread} is in the certain {@link State}
-     * and blocking on {@code object}.
-     *
-     * @param state The thread state
-     * @param object The object to block on
-     */
-    public static void waitUntilBlockingOnObject(Thread thread, Thread.State state, Object object)
-        throws InterruptedException {
-        String want = object == null ? null : object.getClass().getName() + '@'
-                + Integer.toHexString(System.identityHashCode(object));
-        ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
-        while (thread.isAlive()) {
-            ThreadInfo ti = tmx.getThreadInfo(thread.getId());
-            if (ti.getThreadState() == state
-                    && (want == null || want.equals(ti.getLockName()))) {
-                return;
-            }
-            Thread.sleep(1);
-        }
-    }
-
-    /**
-     * Waits until {@link Thread} is in native.
-     */
-    public static void waitUntilInNative(Thread thread) throws InterruptedException {
-        ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
-        while (thread.isAlive()) {
-            ThreadInfo ti = tmx.getThreadInfo(thread.getId());
-            if (ti.isInNative()) {
-                return;
-            }
-            Thread.sleep(1);
-        }
-    }
-
-}
--- a/jdk/test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/CodeCacheOverflowProcessor.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.testlibrary.jsr292;
-
-import jdk.testlibrary.Utils;
-
-/**
- * Helper class used to catch and process VirtualMachineError with message "Out
- * of space in CodeCache". Some JSR292 tests run out of code cache size, so code
- * cache overflows and VME is thrown. This VME is considered as non-critical in
- * some JSR292 tests, so it should be processed to prevent test failure.
- */
-public class CodeCacheOverflowProcessor {
-
-    /**
-     * Checks if an instance of Throwable is caused by VirtualMachineError with
-     * message "Out of space in CodeCache". May be used as filter in method
-     * {@code jdk.testlibrary.Utils.filterException}.
-     *
-     * @param t - Throwable to check.
-     * @return true if Throwable is caused by VME, false otherwise.
-     */
-    public static Boolean isThrowableCausedByVME(Throwable t) {
-        Throwable causeOfT = t;
-        do {
-            if (causeOfT instanceof VirtualMachineError
-                    && causeOfT.getMessage().matches(".*[Oo]ut of space"
-                            + " in CodeCache.*")) {
-                return true;
-            }
-            causeOfT = causeOfT != null ? causeOfT.getCause() : null;
-        } while (causeOfT != null && causeOfT != t);
-        return false;
-    }
-
-    /**
-     * Checks if the given test throws an exception caused by
-     * VirtualMachineError with message "Out of space in CodeCache", and, if VME
-     * takes place, processes it so that no exception is thrown, and prints its
-     * stack trace. If test throws exception not caused by VME, this method just
-     * re-throws this exception.
-     *
-     * @param test - test to check for and process VirtualMachineError.
-     * @return - an exception caused by VME or null
-     *           if test has thrown no exception.
-     * @throws Throwable - if test has thrown an exception
-     *                     that is not caused by VME.
-     */
-    public static Throwable runMHTest(Utils.ThrowingRunnable test) throws Throwable {
-        Throwable t = Utils.filterException(test::run,
-                CodeCacheOverflowProcessor::isThrowableCausedByVME);
-        if (t != null) {
-            System.err.printf("%nNon-critical exception caught becuse of"
-                    + " code cache size is not enough to run all test cases.%n%n");
-        }
-        return t;
-    }
-}
--- a/jdk/test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/Helper.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,347 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.testlibrary.jsr292;
-
-import jdk.testlibrary.Asserts;
-
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodType;
-import java.lang.reflect.Array;
-import java.util.*;
-
-public class Helper {
-    /** Flag for verbose output, true if {@code -Dverbose} specified */
-    public static final boolean IS_VERBOSE
-            = System.getProperty("verbose") != null;
-    /**
-     * Flag for thorough testing -- all test will be executed,
-     * true if {@code -Dthorough} specified. */
-    public static final boolean IS_THOROUGH
-            = System.getProperty("thorough") != null;
-    /** Random number generator w/ initial seed equal to {@code -Dseed} */
-    public static final Random RNG;
-
-    static {
-        String str = System.getProperty("seed");
-        long seed = str != null ? Long.parseLong(str) : new Random().nextLong();
-        RNG = new Random(seed);
-        System.out.printf("-Dseed=%d%n", seed);
-    }
-
-    public static final long TEST_LIMIT;
-    static {
-        String str = System.getProperty("testLimit");
-        TEST_LIMIT = str != null ? Long.parseUnsignedLong(str) : 2000L;
-        System.out.printf("-DtestLimit=%d%n", TEST_LIMIT);
-    }
-
-    public static final int MAX_ARITY = 254;
-    public static final String MISSING_ARG = "missingArg";
-    public static final String MISSING_ARG_2 = "missingArg#2";
-
-    private static final int
-            // first int value
-            ONE_MILLION = (1000 * 1000),
-            // scale factor to reach upper 32 bits
-            TEN_BILLION = (10 * 1000 * 1000 * 1000),
-            // <<1 makes space for sign bit;
-            INITIAL_ARG_VAL = ONE_MILLION << 1;
-
-    public static final MethodHandle AS_LIST;
-
-    static {
-        try {
-            AS_LIST = MethodHandles.lookup().findStatic(
-                    Arrays.class, "asList",
-                    MethodType.methodType(List.class, Object[].class));
-        } catch (NoSuchMethodException | IllegalAccessException ex) {
-            throw new Error(ex);
-        }
-    }
-
-    public static boolean isDoubleCost(Class<?> aClass) {
-        return aClass == double.class || aClass == long.class;
-    }
-
-    private static List<List<Object>> calledLog = new ArrayList<>();
-    private static long nextArgVal;
-
-    public static void assertCalled(String name, Object... args) {
-        assertCalled(0, name, args);
-    }
-
-    public static void assertCalled(int lag, String name, Object... args) {
-        Object expected = logEntry(name, args);
-        Object actual = getCalled(lag);
-        Asserts.assertEQ(expected, actual, "method call w/ lag = " + lag);
-    }
-
-    public static Object called(String name, Object... args) {
-        List<Object> entry = logEntry(name, args);
-        calledLog.add(entry);
-        return entry;
-    }
-
-    private static List<Object> logEntry(String name, Object... args) {
-        return Arrays.asList(name, Arrays.asList(args));
-    }
-
-    public static void clear() {
-        calledLog.clear();
-    }
-
-    public static List<Object> getCalled(int lag) {
-        int size = calledLog.size();
-        return size <= lag ? null : calledLog.get(size - lag - 1);
-    }
-
-    public static List<Class<?>> randomClasses(Class<?>[] classes, int size) {
-        List<Class<?>> result = new ArrayList<>(size);
-        for (int i = 0; i < size; ++i) {
-            result.add(classes[RNG.nextInt(classes.length)]);
-        }
-        return result;
-    }
-
-    public static List<Class<?>> getParams(List<Class<?>> classes,
-            boolean isVararg, int argsCount) {
-        boolean unmodifiable = true;
-        List<Class<?>> result = classes.subList(0,
-                Math.min(argsCount, (MAX_ARITY / 2) - 1));
-        int extra = 0;
-        if (argsCount >= MAX_ARITY / 2) {
-            result = new ArrayList<>(result);
-            unmodifiable = false;
-            extra = (int) result.stream().filter(Helper::isDoubleCost).count();
-            int i = result.size();
-            while (result.size() + extra < argsCount) {
-                Class<?> aClass = classes.get(i);
-                if (Helper.isDoubleCost(aClass)) {
-                    ++extra;
-                    if (result.size() + extra >= argsCount) {
-                        break;
-                    }
-                }
-                result.add(aClass);
-            }
-        }
-        if (isVararg && result.size() > 0) {
-            if (unmodifiable) {
-                result = new ArrayList<>(result);
-            }
-            int last = result.size() - 1;
-            Class<?> aClass = result.get(last);
-            aClass = Array.newInstance(aClass, 2).getClass();
-            result.set(last, aClass);
-        }
-        return result;
-    }
-
-    public static MethodHandle addTrailingArgs(MethodHandle target, int nargs,
-            List<Class<?>> classes) {
-        int targetLen = target.type().parameterCount();
-        int extra = (nargs - targetLen);
-        if (extra <= 0) {
-            return target;
-        }
-        List<Class<?>> fakeArgs = new ArrayList<>(extra);
-        for (int i = 0; i < extra; ++i) {
-            fakeArgs.add(classes.get(i % classes.size()));
-        }
-        return MethodHandles.dropArguments(target, targetLen, fakeArgs);
-    }
-
-    public static MethodHandle varargsList(int arity) {
-        return AS_LIST.asCollector(Object[].class, arity);
-    }
-
-    private static long nextArg(boolean moreBits) {
-        long val = nextArgVal++;
-        long sign = -(val & 1); // alternate signs
-        val >>= 1;
-        if (moreBits)
-        // Guarantee some bits in the high word.
-        // In any case keep the decimal representation simple-looking,
-        // with lots of zeroes, so as not to make the printed decimal
-        // strings unnecessarily noisy.
-        {
-            val += (val % ONE_MILLION) * TEN_BILLION;
-        }
-        return val ^ sign;
-    }
-
-    private static int nextArg() {
-        // Produce a 32-bit result something like ONE_MILLION+(smallint).
-        // Example: 1_000_042.
-        return (int) nextArg(false);
-    }
-
-    private static long nextArg(Class<?> kind) {
-        if (kind == long.class || kind == Long.class ||
-                kind == double.class || kind == Double.class)
-        // produce a 64-bit result something like
-        // ((TEN_BILLION+1) * (ONE_MILLION+(smallint)))
-        // Example: 10_000_420_001_000_042.
-        {
-            return nextArg(true);
-        }
-        return (long) nextArg();
-    }
-
-    private static Object randomArg(Class<?> param) {
-        Object wrap = castToWrapperOrNull(nextArg(param), param);
-        if (wrap != null) {
-            return wrap;
-        }
-
-        if (param.isInterface()) {
-            for (Class<?> c : param.getClasses()) {
-                if (param.isAssignableFrom(c) && !c.isInterface()) {
-                    param = c;
-                    break;
-                }
-            }
-        }
-        if (param.isArray()) {
-            Class<?> ctype = param.getComponentType();
-            Object arg = Array.newInstance(ctype, 2);
-            Array.set(arg, 0, randomArg(ctype));
-            return arg;
-        }
-        if (param.isInterface() && param.isAssignableFrom(List.class)) {
-            return Arrays.asList("#" + nextArg());
-        }
-        if (param.isInterface() || param.isAssignableFrom(String.class)) {
-            return "#" + nextArg();
-        }
-
-        try {
-            return param.newInstance();
-        } catch (InstantiationException | IllegalAccessException ex) {
-        }
-        return null;  // random class not Object, String, Integer, etc.
-    }
-
-    public static Object[] randomArgs(Class<?>... params) {
-        Object[] args = new Object[params.length];
-        for (int i = 0; i < args.length; i++) {
-            args[i] = randomArg(params[i]);
-        }
-        return args;
-    }
-
-    public static Object[] randomArgs(int nargs, Class<?> param) {
-        Object[] args = new Object[nargs];
-        for (int i = 0; i < args.length; i++) {
-            args[i] = randomArg(param);
-        }
-        return args;
-    }
-
-    public static Object[] randomArgs(int nargs, Class<?>... params) {
-        Object[] args = new Object[nargs];
-        for (int i = 0; i < args.length; i++) {
-            Class<?> param = params[i % params.length];
-            args[i] = randomArg(param);
-        }
-        return args;
-    }
-
-    public static Object[] randomArgs(List<Class<?>> params) {
-        return randomArgs(params.toArray(new Class<?>[params.size()]));
-    }
-
-    public static Object castToWrapper(Object value, Class<?> dst) {
-        Object wrap = null;
-        if (value instanceof Number) {
-            wrap = castToWrapperOrNull(((Number) value).longValue(), dst);
-        }
-        if (value instanceof Character) {
-            wrap = castToWrapperOrNull((char) (Character) value, dst);
-        }
-        if (wrap != null) {
-            return wrap;
-        }
-        return dst.cast(value);
-    }
-
-    @SuppressWarnings("cast")
-    // primitive cast to (long) is part of the pattern
-    private static Object castToWrapperOrNull(long value, Class<?> dst) {
-        if (dst == int.class || dst == Integer.class) {
-            return (int) (value);
-        }
-        if (dst == long.class || dst == Long.class) {
-            return (long) (value);
-        }
-        if (dst == char.class || dst == Character.class) {
-            return (char) (value);
-        }
-        if (dst == short.class || dst == Short.class) {
-            return (short) (value);
-        }
-        if (dst == float.class || dst == Float.class) {
-            return (float) (value);
-        }
-        if (dst == double.class || dst == Double.class) {
-            return (double) (value);
-        }
-        if (dst == byte.class || dst == Byte.class) {
-            return (byte) (value);
-        }
-        if (dst == boolean.class || dst == Boolean.class) {
-            return ((value % 29) & 1) == 0;
-        }
-        return null;
-    }
-
-    /**
-     * Routine used to obtain a randomly generated method type.
-     *
-     * @param arity Arity of returned method type.
-     * @return MethodType generated randomly.
-     */
-    public static MethodType randomMethodTypeGenerator(int arity) {
-        final Class<?>[] CLASSES = {
-            Object.class,
-            int.class,
-            boolean.class,
-            byte.class,
-            short.class,
-            char.class,
-            long.class,
-            float.class,
-            double.class
-        };
-        if (arity > MAX_ARITY) {
-            throw new IllegalArgumentException(
-                    String.format("Arity should not exceed %d!", MAX_ARITY));
-        }
-        List<Class<?>> list = randomClasses(CLASSES, arity);
-        list = getParams(list, false, arity);
-        int i = RNG.nextInt(CLASSES.length + 1);
-        Class<?> rtype = i == CLASSES.length ? void.class : CLASSES[i];
-        return MethodType.methodType(rtype, list);
-    }
-}
--- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/B6216082.java	Wed Jul 05 23:37:13 2017 +0200
@@ -31,9 +31,9 @@
  * @bug 6216082
  * @summary  Redirect problem with HttpsURLConnection using a proxy
  * @modules java.base/sun.net.www
- * @library .. /lib/testlibrary
+ * @library .. /test/lib
  * @build HttpCallback TestHttpsServer ClosedChannelList
- *        HttpTransaction TunnelProxy jdk.testlibrary.NetworkConfiguration
+ *        HttpTransaction TunnelProxy
  * @key intermittent
  * @run main/othervm B6216082
  */
@@ -43,7 +43,7 @@
 import javax.net.ssl.*;
 import java.util.*;
 
-import jdk.testlibrary.NetworkConfiguration;
+import jdk.test.lib.NetworkConfiguration;
 
 public class B6216082 {
     static SimpleHttpTransaction httpTrans;
--- a/jdk/test/sun/net/www/protocol/jar/B5105410.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/net/www/protocol/jar/B5105410.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 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
@@ -21,23 +21,43 @@
  * questions.
  */
 
-import java.net.*;
-import java.io.*;
+/**
+ * @test
+ * @bug 5105410
+ * @run main/othervm B5105410
+ * @summary ZipFile$ZipFileInputStream doesn't close handle to zipfile
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
 
 public class B5105410 {
     public static void main (String[] args) throws Exception {
-        URL url = new URL ("jar:file:./foo2.jar!/bar.txt");
-        URLConnection urlc = url.openConnection ();
-        urlc.setUseCaches (false);
+        setup();
+        URL url = new URL("jar:file:./foo2.jar!/bar.txt");
+        URLConnection urlc = url.openConnection();
+        urlc.setUseCaches(false);
         InputStream is = urlc.getInputStream();
         is.read();
         is.close();
-        File file = new File ("foo2.jar");
-        if (!file.delete ()) {
-            throw new RuntimeException ("Could not delete foo2.jar");
+        File file = new File("foo2.jar");
+        if (!file.delete()) {
+            throw new RuntimeException("Could not delete foo2.jar");
         }
         if (file.exists()) {
-            throw new RuntimeException ("foo2.jar still exists");
+            throw new RuntimeException("foo2.jar still exists");
         }
     }
+
+    static void setup() throws IOException {
+        Files.copy(Paths.get(System.getProperty("test.src"), "foo2.jar"),
+                   Paths.get(".", "foo2.jar"), REPLACE_EXISTING);
+    }
 }
+
--- a/jdk/test/sun/net/www/protocol/jar/B5105410.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-#! /bin/sh
-
-#
-# Copyright (c) 2004, 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.
-#
-
-# @test
-# @author Michael McMahon
-# @bug 5105410
-# @summary ZipFile$ZipFileInputStream doesn't close handle to zipfile
-#
-
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | AIX )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-cp ${TESTSRC}${FS}foo2.jar .
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}${FS}B5105410.java
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} B5105410
-
--- a/jdk/test/sun/net/www/protocol/jar/B6449504.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/net/www/protocol/jar/B6449504.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,63 +24,72 @@
 /**
  * @test
  * @bug 6449504
- * @run shell copyin.sh bar.jar
- * @run main B6449504 caching
- * @run main B6449504 no_caching
+ * @run main/othervm B6449504 caching
+ * @run main/othervm B6449504 no_caching
  * @summary REGRESSION: ZipException throws when try to read a XML file
  */
 
-import java.io.*;
-import java.net.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
 
 public class B6449504 {
 
     public static void main (String[] args) throws Exception {
-
-        boolean caching = args[0].equals ("caching");
-
-        String dirname = System.getProperty ("test.classes");
-        File f = new File (dirname);
+        setup();
+        boolean caching = args[0].equals("caching");
+        String dirname = System.getProperty("test.classes");
+        File f = new File(dirname);
         dirname = f.toURI().toString();
 
-        String u = "jar:"+ dirname + "/bar.jar";
-        URL url = new URL (u+"!/DoesNotExist.txt");
-        System.out.println ("url = " + url);
+        String u = "jar:" + dirname + "/bar.jar";
+        URL url = new URL(u + "!/DoesNotExist.txt");
+        System.out.println("url = " + url);
         JarURLConnection j1 = (JarURLConnection)url.openConnection();
 
-        URL url2 = new URL (u+"!/test.txt");
-        System.out.println ("url2 = " + url2);
+        URL url2 = new URL(u + "!/test.txt");
+        System.out.println("url2 = " + url2);
         JarURLConnection j2 = (JarURLConnection)url2.openConnection();
 
-        j1.setUseCaches (caching);
-        j2.setUseCaches (caching);
+        j1.setUseCaches(caching);
+        j2.setUseCaches(caching);
 
         /* connecting to j2 opens the jar file but does not read it */
 
-        j2.connect ();
+        j2.connect();
 
         try {
             /* attempt to read a non-existing entry in the jar file
              * shows the bug, where the jar file is closed after the
              * attempt fails.
              */
-            InputStream is = j1.getInputStream ();
+            InputStream is = j1.getInputStream();
         } catch (IOException e) {
-            System.out.println ("Got expected exception from j1 ");
+            System.out.println("Got expected exception from j1 ");
         }
 
         /* If bug present, this will fail because we think the jar
          * is ready to be read, after the connect() above, but we
          * get a ZipException because it has been closed
          */
-        InputStream is = j2.getInputStream ();
-        readAndClose (is);
-        System.out.println ("OK");
+        InputStream is = j2.getInputStream();
+        readAndClose(is);
+        System.out.println("OK");
     }
 
-    static void readAndClose (InputStream is) throws IOException {
+    static void readAndClose(InputStream is) throws IOException {
         while (is.read() != -1) ;
         is.close();
     }
 
+    static void setup() throws IOException {
+        Files.copy(Paths.get(System.getProperty("test.src"), "bar.jar"),
+                   Paths.get(System.getProperty("test.classes"), "bar.jar"),
+                   StandardCopyOption.REPLACE_EXISTING);
+    }
 }
--- a/jdk/test/sun/net/www/protocol/jar/GetContentType.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/net/www/protocol/jar/GetContentType.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 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
@@ -21,18 +21,8 @@
  * questions.
  */
 
-/*
- * @test
- * @bug 4274624
- * @summary  Test JarURLConnection.getContentType would
- *           would return default "content/unknown"
- *
- * @build GetContentType
- * @run shell getcontenttype.sh
- */
-
+import java.io.InputStream;
 import java.net.URL;
-import java.io.InputStream;
 
 public class GetContentType {
     public static void main(String args[]) throws Exception {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/net/www/protocol/jar/GetContentTypeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,55 @@
+/*
+ * 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 4274624
+ * @library /test/lib
+ * @build GetContentType GetContentTypeTest
+ *        jdk.test.lib.JDKToolFinder
+ *        jdk.test.lib.process.*
+ * @run main/othervm GetContentTypeTest
+ * @summary Test JarURLConnection.getContentType would
+ *          would return default "content/unknown"
+ */
+
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
+
+import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class GetContentTypeTest {
+    public static void main(String[] args) throws Throwable {
+        Path resJar = Paths.get(System.getProperty("test.src"),
+                "resource.jar");
+        Path classes = Paths.get(System.getProperty("test.classes"));
+        ProcessTools.executeCommand(
+                JDKToolFinder.getTestJDKTool("java"),
+                "-cp", resJar + File.pathSeparator + classes, "GetContentType")
+                .outputTo(System.out)
+                .errorTo(System.out)
+                .shouldHaveExitValue(0);
+    }
+}
--- a/jdk/test/sun/net/www/protocol/jar/copyin.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-#!/bin/ksh
-
-#
-# Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-
-echo current directory is `pwd`
-set -x
-for i in $*; do
-    rm -f $TESTCLASSES/$i
-    cp $TESTSRC/$i $TESTCLASSES
-done
--- a/jdk/test/sun/net/www/protocol/jar/getcontenttype.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-#! /bin/sh
-
-#
-# Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
-# 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.
-#
-
-#
-
-if [ x"$TESTJAVA" = x ]; then 
-        TESTJAVA=$1 
-        shift 
-fi
-if [ x"$TESTCLASSES" = x ]; then TESTCLASSES=.; fi
-if [ x"$TESTSRC" = x ]; then TESTSRC=.; fi
-
-OS=`uname -s`;
-# Set classpath separator
-case "$OS" in
-        Windows* | CYGWIN* )
-        SEP=";"
-        FS="\\"
-        ;;
-
-        * )
-        SEP=":"
-        FS="/"
-        ;;
-esac
-
-# now start the test
-${TESTJAVA}/bin/java ${TESTVMOPTS} -cp ${TESTSRC}${FS}resource.jar${SEP}${TESTCLASSES} GetContentType
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/net/www/protocol/jar/jarbug/TestDriver.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,89 @@
+/*
+ * 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 4361044 4388202 4418643 4523159 4730642
+ * @library /test/lib
+ *          /lib/testlibrary
+ * @modules jdk.compiler
+ * @build src.test.src.TestDriver JarUtils
+ *        jdk.test.lib.compiler.CompilerUtils
+ *        jdk.test.lib.JDKToolFinder
+ *        jdk.test.lib.process.*
+ * @summary various resource and classloading bugs related to jar files
+ * @run main/othervm TestDriver
+ */
+
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.compiler.CompilerUtils;
+import jdk.test.lib.process.ProcessTools;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
+public class TestDriver {
+    public static void main(String[] args) throws Throwable {
+        Path srcDir = Paths.get(System.getProperty("test.src"));
+        Path targetDir = Paths.get(System.getProperty("user.dir"));
+        Path jar1SrcDir = srcDir.resolve("src").resolve("jar1");
+        Path jar1TargetDir =  targetDir.resolve("jar1");
+        Path ectJar1Dir = srcDir.resolve("etc").resolve("jar1");
+        Path jarFile = targetDir.resolve("jar1.jar");
+        Path[]  files= new Path[] {
+                Paths.get("res1.txt"), Paths.get("jar1", "bundle.properties")
+        };
+
+        // Copy files to target directory and change permission
+        for (Path file : files) {
+            Path dest = jar1TargetDir.resolve(file);
+            Files.createDirectories(dest.getParent());
+            Files.copy(ectJar1Dir.resolve(file), dest, REPLACE_EXISTING);
+        }
+
+        // Compile and build jar1.jar
+        ProcessTools.executeCommand("chmod", "-R", "u+w", "./jar1")
+                    .outputTo(System.out)
+                    .errorTo(System.out)
+                    .shouldHaveExitValue(0);
+        CompilerUtils.compile(jar1SrcDir, jar1TargetDir);
+        JarUtils.createJarFile(jarFile, jar1TargetDir);
+
+        // Compile test files
+        CompilerUtils.compile(srcDir.resolve("src").resolve("test"), targetDir);
+
+        // Run tests
+        String java = JDKToolFinder.getTestJDKTool("java");
+        String cp = targetDir.toString() + File.pathSeparator + jarFile;
+        String[] tests = new String[]{"TestBug4361044", "TestBug4523159"};
+        for (String test : tests) {
+            ProcessTools.executeCommand(java, "-cp", cp, test)
+                        .outputTo(System.out)
+                        .errorTo(System.out)
+                        .shouldHaveExitValue(0);
+        }
+    }
+}
--- a/jdk/test/sun/net/www/protocol/jar/jarbug/run.sh	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-#! /bin/sh
-
-#
-# Copyright (c) 2005, 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.
-#
-
-# @test
-# @bug 4361044 4388202 4418643 4523159 4730642
-# @summary various resource and classloading bugs related to jar files
-#set -x
-DEST=`pwd`
-
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | AIX )
-    PS=":"
-    FS="/"
-    CHMOD="${FS}bin${FS}chmod"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    CHMOD="chmod"
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    CHMOD="chmod"
-    #
-    # javac does not like /cygdrive produced by `pwd`.
-    #
-    DEST=`cygpath -d ${DEST}`
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-#
-# build jar1
-#
-mkdir -p ${DEST}${FS}jar1
-cd ${TESTSRC}${FS}etc${FS}jar1
-cp -r . ${DEST}${FS}jar1
-${CHMOD} -R u+w ${DEST}${FS}jar1
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${DEST}${FS}jar1 \
-    ${TESTSRC}${FS}src${FS}jar1${FS}LoadResourceBundle.java
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${DEST}${FS}jar1 \
-    ${TESTSRC}${FS}src${FS}jar1${FS}GetResource.java
-cd ${DEST}${FS}jar1
-${COMPILEJAVA}${FS}bin${FS}jar ${TESTTOOLVMOPTS} cfM jar1.jar jar1 res1.txt
-mv jar1.jar ..
-#
-# build the test sources and run them
-#
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${DEST} ${TESTSRC}${FS}src${FS}test${FS}*.java
-cd ${DEST}
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} RunAllTests
-result=$?
-if [ "$result" -ne "0" ]; then
-    exit 1
-fi
-rm -rf *
-exit 0
--- a/jdk/test/sun/net/www/protocol/jar/jarbug/src/test/RunAllTests.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-public class RunAllTests {
-        public static void main(String[] args) throws Exception {
-                String[] noArgs = new String[0];
-                TestBug4361044.main(noArgs);
-                TestBug4523159.main(noArgs);
-        }
-}
--- a/jdk/test/sun/net/www/protocol/jar/jarbug/src/test/TestBug4361044.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/net/www/protocol/jar/jarbug/src/test/TestBug4361044.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2007, 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
@@ -21,9 +21,9 @@
  * questions.
  */
 
-import java.io.*;
-import java.net.*;
-import java.util.jar.*;
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
 
 /*
  * ResourceBundle from jar not found if jar exists in path
@@ -38,40 +38,17 @@
 public class TestBug4361044 extends JarTest
 {
     public void run(String[] args) throws Exception {
-        if (args.length == 0 ) {  // execute the test in another vm.
-            System.out.println("Test: " + getClass().getName());
-            Process process = Runtime.getRuntime().exec(javaCmd + " TestBug4361044 -test");
-
-            BufferedReader isReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
-            BufferedReader esReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
-            Redirector outRedirector = new Redirector(isReader, System.out);
-            Redirector errRedirector = new Redirector(esReader, System.err);
-
-            (new Thread(outRedirector)).start();
-            (new Thread(errRedirector)).start();
-
-            process.waitFor();
-
-            // Delete any remaining files from the test
-            File testDir = new File(tmpdir + File.separator + getClass().getName());
-            deleteRecursively(testDir);
-
-            if (outRedirector.getHasReadData() || errRedirector.getHasReadData())
-                throw new RuntimeException("Failed: No output should have been received from the process");
-
-        } else {   // run the test.
-            File tmp = createTempDir();
-            try {
-                File dir = new File(tmp, "dir!name");
-                dir.mkdir();
-                File testFile = copyResource(dir, "jar1.jar");
-                URL[] urls = new URL[1];
-                urls[0] = new URL("jar:" + testFile.toURL() + "!/");
-                URLClassLoader loader = new URLClassLoader(urls);
-                loader.loadClass("jar1.LoadResourceBundle").newInstance();
-            } finally {
-                deleteRecursively(tmp);
-            }
+        File tmp = createTempDir();
+        try {
+            File dir = new File(tmp, "dir!name");
+            dir.mkdir();
+            File testFile = copyResource(dir, "jar1.jar");
+            URL[] urls = new URL[1];
+            urls[0] = new URL("jar:" + testFile.toURI().toURL() + "!/");
+            URLClassLoader loader = new URLClassLoader(urls);
+            loader.loadClass("jar1.LoadResourceBundle").newInstance();
+        } finally {
+            deleteRecursively(tmp);
         }
     }
 
--- a/jdk/test/sun/net/www/protocol/jar/jarbug/src/test/TestBug4523159.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/net/www/protocol/jar/jarbug/src/test/TestBug4523159.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2007, 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
@@ -21,9 +21,12 @@
  * questions.
  */
 
-import java.io.*;
-import java.net.*;
-import java.util.jar.*;
+import java.io.File;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
 
 /*
  * Issuing a getResourceAsStream() call will throw an exception if:
@@ -40,53 +43,30 @@
 public class TestBug4523159 extends JarTest
 {
     public void run(String[] args) throws Exception {
-        if (args.length == 0 ) {  // execute the test in another vm.
-            System.out.println("Test: " + getClass().getName());
-            Process process = Runtime.getRuntime().exec(javaCmd + " TestBug4523159 -test");
-
-            BufferedReader isReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
-            BufferedReader esReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
-            Redirector outRedirector = new Redirector(isReader, System.out);
-            Redirector errRedirector = new Redirector(esReader, System.err);
-
-            (new Thread(outRedirector)).start();
-            (new Thread(errRedirector)).start();
-
-            process.waitFor();
-
-            // Delete any remaining files from the test
-            File testDir = new File(tmpdir + File.separator + getClass().getName());
-            deleteRecursively(testDir);
-
-            if (outRedirector.getHasReadData() || errRedirector.getHasReadData())
-                throw new RuntimeException("Failed: No output should have been received from the process");
+        File tmp = createTempDir();
+        try {
+            File dir = new File(tmp, "dir!name");
+            dir.mkdir();
+            File testFile = copyResource(dir, "jar1.jar");
 
-        } else { // run the test.
-            File tmp = createTempDir();
-            try {
-                File dir = new File(tmp, "dir!name");
-                dir.mkdir();
-                File testFile = copyResource(dir, "jar1.jar");
+            // Case 1: direct access
+            URL url = new URL("jar:" + testFile.toURI().toURL() + "!/res1.txt");
+            JarURLConnection conn = (JarURLConnection) url.openConnection();
+            JarFile file = conn.getJarFile();
+            JarEntry entry = conn.getJarEntry();
+            byte[] buffer = readFully(file.getInputStream(entry));
+            String str = new String(buffer);
+            if (!str.equals("This is jar 1\n")) {
+                throw (new Exception("resource content invalid"));
+            }
 
-                // Case 1: direct access
-                URL url = new URL("jar:" + testFile.toURL() + "!/res1.txt");
-                JarURLConnection conn = (JarURLConnection) url.openConnection();
-                JarFile file = conn.getJarFile();
-                JarEntry entry = conn.getJarEntry();
-                byte[] buffer = readFully(file.getInputStream(entry));
-                String str = new String(buffer);
-                if (!str.equals("This is jar 1\n")) {
-                    throw(new Exception("resource content invalid"));
-                }
-
-                // Case 2: indirect access
-                URL[] urls = new URL[1];
-                urls[0] = new URL("jar:" + testFile.toURL() + "!/");
-                URLClassLoader loader = new URLClassLoader(urls);
-                loader.loadClass("jar1.GetResource").newInstance();
-            } finally {
-                deleteRecursively(tmp);
-            }
+            // Case 2: indirect access
+            URL[] urls = new URL[1];
+            urls[0] = new URL("jar:" + testFile.toURI().toURL()  + "!/");
+            URLClassLoader loader = new URLClassLoader(urls);
+            loader.loadClass("jar1.GetResource").newInstance();
+        } finally {
+            deleteRecursively(tmp);
         }
     }
 
--- a/jdk/test/sun/nio/cs/FindDecoderBugs.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/nio/cs/FindDecoderBugs.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,7 @@
  * @test
  * @bug 6380723
  * @summary Decode many byte sequences in many ways (use -Dseed=X to set PRNG seed)
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main/timeout=1800 FindDecoderBugs
  * @author Martin Buchholz
  * @key randomness
@@ -36,7 +35,7 @@
 import java.util.regex.*;
 import java.nio.*;
 import java.nio.charset.*;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class FindDecoderBugs {
 
--- a/jdk/test/sun/nio/cs/FindEncoderBugs.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/nio/cs/FindEncoderBugs.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,7 @@
  * @test
  * @bug 6233345 6381699 6381702 6381705 6381706
  * @summary Encode many char sequences in many ways
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @run main/timeout=1200 FindEncoderBugs
  * @author Martin Buchholz
  * @key randomness
@@ -36,7 +35,7 @@
 import java.util.regex.*;
 import java.nio.*;
 import java.nio.charset.*;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class FindEncoderBugs {
 
--- a/jdk/test/sun/security/ec/SignatureOffsets.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/ec/SignatureOffsets.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
  *          get random set of clear text data to sign. After the signature
  *          generation, the test tries to verify signature with the above API
  *          and passing in different signature offset (0, 33, 66, 99).
- * @library /lib/testlibrary
+ * @library /test/lib
  * @compile ../../../java/security/Signature/Offsets.java
  * @run main SignatureOffsets SunEC NONEwithECDSA
  * @run main SignatureOffsets SunEC SHA1withECDSA
--- a/jdk/test/sun/security/krb5/auto/KDC.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/krb5/auto/KDC.java	Wed Jul 05 23:37:13 2017 +0200
@@ -828,7 +828,9 @@
                 throw new KrbException(Krb5.KDC_ERR_SUMTYPE_NOSUPP); // TODO
             }
             Ticket t = new Ticket(
-                    service,
+                    System.getProperty("test.kdc.diff.sname") != null ?
+                        new PrincipalName("xx" + service.toString()) :
+                        service,
                     new EncryptedData(skey, enc.asn1Encode(), KeyUsage.KU_TICKET)
             );
             EncTGSRepPart enc_part = new EncTGSRepPart(
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/krb5/auto/TicketSName.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,58 @@
+/*
+ * 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 8178794
+ * @summary krb5 client should ignore sname in incoming tickets
+ * @compile -XDignore.symbol.file TicketSName.java
+ * @run main/othervm -Dtest.kdc.diff.sname TicketSName
+ */
+
+import sun.security.jgss.GSSUtil;
+import javax.security.auth.kerberos.KerberosTicket;
+
+public class TicketSName {
+
+    public static void main(String[] args) throws Exception {
+
+        new OneKDC(null).writeJAASConf();
+
+        Context c, s;
+        c = Context.fromJAAS("client");
+        s = Context.fromJAAS("server");
+
+        c.startAsClient(OneKDC.SERVER, GSSUtil.GSS_KRB5_MECH_OID);
+        s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
+
+        Context.handshake(c, s);
+
+        String expected = OneKDC.SERVER + "@" + OneKDC.REALM;
+        if (!c.s().getPrivateCredentials(KerberosTicket.class)
+                .stream()
+                .anyMatch(t -> t.getServer().toString().equals(expected))) {
+            c.status();
+            throw new Exception("no " + expected);
+        }
+    }
+}
--- a/jdk/test/sun/security/krb5/config/Include.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/krb5/config/Include.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/mscapi/KeyStoreEmptyCertChain.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8172244
+ * @summary Verify that no exception is thrown with empty cert chain
+ *    in MSCAPI.
+ * @requires os.family == "windows"
+ * @modules java.base/sun.security.tools.keytool java.base/sun.security.x509
+ * @run main/othervm --add-opens java.base/java.security=ALL-UNNAMED
+ *      KeyStoreEmptyCertChain
+ */
+
+import java.security.KeyStore;
+import java.security.cert.Certificate;
+import sun.security.x509.X500Name;
+import sun.security.tools.keytool.CertAndKeyGen;
+import java.security.KeyPairGenerator;
+import java.security.KeyPair;
+import java.security.PrivateKey;
+import java.security.KeyStoreSpi;
+import java.lang.reflect.*;
+
+public class KeyStoreEmptyCertChain {
+
+    public static void main(String[] args) {
+
+        try {
+
+            KeyStore keyStore = KeyStore.getInstance("Windows-MY", "SunMSCAPI");
+            keyStore.load(null, null);
+
+            // Generate a certificate to use for testing
+            CertAndKeyGen gen = new CertAndKeyGen("RSA", "SHA256withRSA");
+            gen.generate(2048);
+            Certificate cert =
+                gen.getSelfCertificate(new X500Name("CN=test"), 3600);
+            String alias = "JDK-8172244";
+            char[] password = "password".toCharArray();
+            KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA");
+
+            // generate a private key for the certificate
+            kpg.initialize(2048);
+            KeyPair keyPair = kpg.generateKeyPair();
+            PrivateKey privKey = keyPair.getPrivate();
+            // need to bypass checks to store the private key without the cert
+            Field spiField = KeyStore.class.getDeclaredField("keyStoreSpi");
+            spiField.setAccessible(true);
+            KeyStoreSpi spi = (KeyStoreSpi) spiField.get(keyStore);
+            spi.engineSetKeyEntry(alias, privKey, password, new Certificate[0]);
+            keyStore.store(null, null);
+
+            keyStore.getCertificateAlias(cert);
+            keyStore.deleteEntry(alias);
+            // test passes if no exception is thrown
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+}
--- a/jdk/test/sun/security/mscapi/SignatureOffsets.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/mscapi/SignatureOffsets.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
  *          get random set of clear text data to sign. After the signature
  *          generation, the test tries to verify signature with the above API
  *          and passing in different signature offset (0, 33, 66, 99).
- * @library /lib/testlibrary
+ * @library /test/lib
  * @compile ../../../java/security/Signature/Offsets.java
  * @requires os.family == "windows"
  * @run main SignatureOffsets SunMSCAPI NONEwithRSA
--- a/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java	Wed Jul 05 23:37:13 2017 +0200
@@ -27,8 +27,7 @@
  * @summary Verify that the RSA KeyPairGenerator works (use -Dseed=X to set PRNG seed)
  * @author Andreas Sterbenz
  * @library ..
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
  * @modules jdk.crypto.cryptoki
  * @run main/othervm -Djava.security.debug=sunpkcs11 TestKeyPairGenerator
  * @run main/othervm -Djava.security.debug=sunpkcs11 TestKeyPairGenerator
@@ -46,7 +45,7 @@
 import java.security.interfaces.RSAPrivateCrtKey;
 import java.security.interfaces.RSAPublicKey;
 import java.security.spec.RSAKeyGenParameterSpec;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
 
 public class TestKeyPairGenerator extends PKCS11Test {
 
--- a/jdk/test/sun/security/rsa/SignatureOffsets.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/rsa/SignatureOffsets.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
  *          get random set of clear text data to sign. After the signature
  *          generation, the test tries to verify signature with the above API
  *          and passing in different signature offset (0, 33, 66, 99).
- * @library /lib/testlibrary
+ * @library /test/lib
  * @compile ../../../java/security/Signature/Offsets.java
  * @run main SignatureOffsets SunRsaSign MD2withRSA
  * @run main SignatureOffsets SunRsaSign MD5withRSA
--- a/jdk/test/sun/security/ssl/DHKeyExchange/DHEKeySizing.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/ssl/DHKeyExchange/DHEKeySizing.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,33 +31,44 @@
  * @bug 6956398
  * @summary make ephemeral DH key match the length of the certificate key
  * @run main/othervm
+ *      DHEKeySizing TLS_DHE_RSA_WITH_AES_128_CBC_SHA  false 1639 267
+ * @run main/othervm -Djsse.enableFFDHE=false
  *      DHEKeySizing SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA true 1255 75
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=matched
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=matched
  *      DHEKeySizing SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA true 1255 75
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=legacy
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=legacy
  *      DHEKeySizing SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA true 1255 75
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=1024
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=1024
  *      DHEKeySizing SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA true 1255 75
  *
- * @run main/othervm
+ * @run main/othervm -Djsse.enableFFDHE=false
  *      DHEKeySizing SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA true 229 75
  *
- * @run main/othervm
+ * @run main/othervm -Djsse.enableFFDHE=false
  *      DHEKeySizing TLS_DHE_RSA_WITH_AES_128_CBC_SHA  false 1383 139
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=legacy
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=legacy
  *      DHEKeySizing TLS_DHE_RSA_WITH_AES_128_CBC_SHA  false 1319 107
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=matched
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=matched
  *      DHEKeySizing TLS_DHE_RSA_WITH_AES_128_CBC_SHA  false 1639 267
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=1024
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=1024
  *      DHEKeySizing TLS_DHE_RSA_WITH_AES_128_CBC_SHA  false 1383 139
  *
- * @run main/othervm
+ * @run main/othervm -Djsse.enableFFDHE=false
  *      DHEKeySizing SSL_DH_anon_WITH_RC4_128_MD5  false 357 139
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=legacy
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=legacy
  *      DHEKeySizing SSL_DH_anon_WITH_RC4_128_MD5  false 293 107
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=matched
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=matched
  *      DHEKeySizing SSL_DH_anon_WITH_RC4_128_MD5  false 357 139
- * @run main/othervm -Djdk.tls.ephemeralDHKeySize=1024
+ * @run main/othervm -Djsse.enableFFDHE=false
+ *      -Djdk.tls.ephemeralDHKeySize=1024
  *      DHEKeySizing SSL_DH_anon_WITH_RC4_128_MD5  false 357 139
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/ssl/DHKeyExchange/UseStrongDHSizes.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+//
+// SunJSSE does not support dynamic system properties, no way to re-use
+// system properties in samevm/agentvm mode.
+//
+
+/*
+ * @test
+ * @bug 8140436
+ * @modules jdk.crypto.ec
+ * @library /javax/net/ssl/templates
+ * @summary Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
+ * @run main/othervm UseStrongDHSizes 2048
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe2048 UseStrongDHSizes 2048
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe3072 UseStrongDHSizes 2048
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe4096 UseStrongDHSizes 2048
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe6144 UseStrongDHSizes 2048
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe8192 UseStrongDHSizes 2048
+ * @run main/othervm UseStrongDHSizes 3072
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe3072 UseStrongDHSizes 3072
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe4096 UseStrongDHSizes 3072
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe6144 UseStrongDHSizes 3072
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe8192 UseStrongDHSizes 3072
+ * @run main/othervm UseStrongDHSizes 4096
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe4096 UseStrongDHSizes 4096
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe6144 UseStrongDHSizes 4096
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe8192 UseStrongDHSizes 4096
+ * @run main/othervm UseStrongDHSizes 6144
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe6144 UseStrongDHSizes 6144
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe8192 UseStrongDHSizes 6144
+ * @run main/othervm UseStrongDHSizes 8192
+ * @run main/othervm -Djdk.tls.namedGroups=ffdhe8192 UseStrongDHSizes 8192
+ */
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.Security;
+import javax.net.ssl.SSLSocket;
+
+public class UseStrongDHSizes extends SSLSocketTemplate {
+    /*
+     * Run the test case.
+     */
+    public static void main(String[] args) throws Exception {
+        // reset the security property to make sure that the algorithms
+        // and keys used in this test are not disabled unexpectedly.
+        String constraint = "DH keySize < " + Integer.valueOf(args[0]);
+        Security.setProperty("jdk.tls.disabledAlgorithms", constraint);
+        Security.setProperty("jdk.certpath.disabledAlgorithms", "");
+
+        (new UseStrongDHSizes()).run();
+    }
+
+    @Override
+    protected void runServerApplication(SSLSocket socket) throws Exception {
+        String ciphers[] = {
+                "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
+                "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
+                "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
+                "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA"};
+
+        socket.setEnabledCipherSuites(ciphers);
+        socket.setWantClientAuth(true);
+
+        InputStream sslIS = socket.getInputStream();
+        OutputStream sslOS = socket.getOutputStream();
+
+        sslIS.read();
+        sslOS.write(85);
+        sslOS.flush();
+    }
+
+    @Override
+    protected void runClientApplication(SSLSocket socket) throws Exception {
+        String ciphers[] = {
+                "TLS_DHE_RSA_WITH_AES_128_CBC_SHA",
+                "TLS_DHE_DSS_WITH_AES_128_CBC_SHA",
+                "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
+                "SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA"};
+        socket.setEnabledCipherSuites(ciphers);
+        socket.setUseClientMode(true);
+
+        InputStream sslIS = socket.getInputStream();
+        OutputStream sslOS = socket.getOutputStream();
+
+        sslOS.write(280);
+        sslOS.flush();
+        sslIS.read();
+    }
+}
--- a/jdk/test/sun/security/ssl/rsa/SignatureOffsets.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/ssl/rsa/SignatureOffsets.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,7 @@
  *          get random set of clear text data to sign. After the signature
  *          generation, the test tries to verify signature with the above API
  *          and passing in different signature offset (0, 33, 66, 99).
- * @library /lib/testlibrary
+ * @library /test/lib
  * @compile ../../../../java/security/Signature/Offsets.java
  * @run main SignatureOffsets SunJSSE MD2withRSA
  * @run main SignatureOffsets SunJSSE MD5withRSA
--- a/jdk/test/sun/security/tools/jarsigner/AltProvider.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/AltProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,14 +25,15 @@
  * @test
  * @bug 4906940 8130302
  * @summary -providerPath, -providerClass, -addprovider, and -providerArg
- * @library /lib/testlibrary /test/lib
+ * @library /test/lib
  * @modules java.base/jdk.internal.misc
  */
 
 import jdk.test.lib.JDKToolLauncher;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import java.nio.file.*;
 
--- a/jdk/test/sun/security/tools/jarsigner/EntriesOrder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/EntriesOrder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,9 @@
  * @test
  * @bug 8031572
  * @summary jarsigner -verify exits with 0 when a jar file is not properly signed
- * @library /lib/testlibrary
  * @modules java.base/sun.security.tools.keytool
  *          jdk.jartool/sun.security.tools.jarsigner
  *          jdk.jartool/sun.tools.jar
- * @build jdk.testlibrary.IOUtils
  * @run main EntriesOrder
  */
 
@@ -45,8 +43,6 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
-import jdk.testlibrary.IOUtils;
-
 public class EntriesOrder {
 
     public static void main(String[] args) throws Exception {
@@ -114,7 +110,7 @@
                 Enumeration<JarEntry> jes = jf.entries();
                 while (jes.hasMoreElements()) {
                     JarEntry je = jes.nextElement();
-                    IOUtils.readFully(jf.getInputStream(je));
+                    jf.getInputStream(je).readAllBytes();
                     Certificate[] certs = je.getCertificates();
                     if (certs != null && certs.length > 0) {
                         cc++;
@@ -146,7 +142,7 @@
                 while (true) {
                     JarEntry je = jis.getNextJarEntry();
                     if (je == null) break;
-                    IOUtils.readFully(jis);
+                    jis.readAllBytes();
                     Certificate[] certs = je.getCertificates();
                     if (certs != null && certs.length > 0) {
                         cc++;
--- a/jdk/test/sun/security/tools/jarsigner/Options.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/Options.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,7 @@
  * @bug 8056174
  * @summary Make sure the jarsigner tool still works after it's modified to
  *          be based on JarSigner API
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.base/sun.security.tools.keytool
  *          jdk.jartool/sun.security.tools.jarsigner
  *          java.base/sun.security.pkcs
@@ -35,7 +35,7 @@
 
 import com.sun.jarsigner.ContentSigner;
 import com.sun.jarsigner.ContentSignerParameters;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 import sun.security.pkcs.PKCS7;
 
 import java.io.ByteArrayInputStream;
--- a/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@
 
 import jdk.test.lib.SecurityTools;
 import jdk.testlibrary.*;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 import sun.security.pkcs.ContentInfo;
 import sun.security.pkcs.PKCS7;
 import sun.security.pkcs.PKCS9Attribute;
@@ -557,7 +557,7 @@
     }
 
     static void prepare() throws Exception {
-        jdk.testlibrary.JarUtils.createJar("old.jar", "A");
+        JarUtils.createJar("old.jar", "A");
         Files.deleteIfExists(Paths.get("tsks"));
         keytool("-alias ca -genkeypair -ext bc -dname CN=CA");
         keytool("-alias old -genkeypair -dname CN=old");
--- a/jdk/test/sun/security/tools/jarsigner/TsacertOptionTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/TsacertOptionTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -22,7 +22,7 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
--- a/jdk/test/sun/security/tools/jarsigner/Warning.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/Warning.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
  */
 
 import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 import jdk.testlibrary.OutputAnalyzer;
 import jdk.testlibrary.ProcessTools;
 
@@ -34,7 +34,7 @@
  * @test
  * @bug 8024302 8026037 8130132
  * @summary warnings, errors and -strict
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  */
 public class Warning {
 
--- a/jdk/test/sun/security/tools/jarsigner/multiRelease/MVJarSigningTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/multiRelease/MVJarSigningTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
  * @bug 8047305 8075618
  * @summary Tests jarsigner tool and JarSigner API work with multi-release JAR files.
  * @library /test/lib
- * @library /lib/testlibrary
  * @run main MVJarSigningTest
  */
 
@@ -59,6 +58,7 @@
 import jdk.test.lib.JDKToolFinder;
 import jdk.test.lib.JDKToolLauncher;
 import jdk.test.lib.Utils;
+import jdk.test.lib.compiler.CompilerUtils;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
 
@@ -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
--- a/jdk/test/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,13 +22,13 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for aliasNotInStore warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
  * @run main AliasNotInStoreTest
  */
 public class AliasNotInStoreTest extends Test {
--- a/jdk/test/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,13 +22,13 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for badExtendedKeyUsage warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
  * @run main BadExtendedKeyUsageTest
  */
 public class BadExtendedKeyUsageTest extends Test {
--- a/jdk/test/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,13 +22,13 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for badKeyUsage warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
  * @ignore until 8026393 is fixed
  * @run main BadKeyUsageTest
  */
--- a/jdk/test/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 import java.nio.file.Files;
 import java.nio.file.Paths;
@@ -32,7 +32,7 @@
  * @test
  * @bug 8024302 8026037
  * @summary Test for badNetscapeCertType warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
  * @run main BadNetscapeCertTypeTest
  */
 public class BadNetscapeCertTypeTest extends Test {
--- a/jdk/test/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,13 +24,13 @@
 import java.io.File;
 import jdk.testlibrary.OutputAnalyzer;
 import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for chainNotValidated warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
  * @run main ChainNotValidatedTest
  */
 public class ChainNotValidatedTest extends Test {
--- a/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,13 +22,13 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for hasExpiredCert warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
  * @run main HasExpiredCertTest
  */
 public class HasExpiredCertTest extends Test {
--- a/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,13 +22,13 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for hasExpiringCert warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
  * @run main HasExpiringCertTest
  */
 public class HasExpiringCertTest extends Test {
--- a/jdk/test/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,13 +22,13 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for hasUnsignedEntry warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
  * @run main HasUnsignedEntryTest
  */
 public class HasUnsignedEntryTest extends Test {
--- a/jdk/test/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,13 +22,13 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Checks if jarsigner prints appropriate warnings
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
  * @run main MultipleWarningsTest
  */
 public class MultipleWarningsTest extends Test {
--- a/jdk/test/sun/security/tools/jarsigner/warnings/NoTimestampTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/NoTimestampTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,13 +23,13 @@
 
 import java.util.Date;
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Checks warnings if -tsa and -tsacert options are not specified
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
  * @run main NoTimestampTest
  */
 public class NoTimestampTest extends Test {
--- a/jdk/test/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,13 +22,13 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for notSignedByAlias warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
  * @run main NotSignedByAliasTest
  */
 public class NotSignedByAliasTest extends Test {
--- a/jdk/test/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,13 +22,13 @@
  */
 
 import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 /**
  * @test
  * @bug 8024302 8026037
  * @summary Test for notYetValidCert warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
  * @run main NotYetValidCertTest
  */
 public class NotYetValidCertTest extends Test {
--- a/jdk/test/sun/security/tools/keytool/ReadJar.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/security/tools/keytool/ReadJar.java	Wed Jul 05 23:37:13 2017 +0200
@@ -26,14 +26,13 @@
  * @bug 6890872 8168882
  * @summary keytool -printcert to recognize signed jar files
  * @library /test/lib
- * @library /lib/testlibrary
  */
 
 import java.nio.file.Files;
 import java.nio.file.Paths;
 import jdk.test.lib.SecurityTools;
 import jdk.test.lib.process.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
 
 public class ReadJar {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jhsdb/AlternateHashingTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8030750
+ * @summary Test alternate hashing of strings in Serviceability Agent.
+ * @library /test/lib
+ * @library /lib/testlibrary
+ * @compile AlternateHashingTest.java
+ * @run main/timeout=240 AlternateHashingTest
+ */
+
+import java.io.BufferedReader;
+import java.io.OutputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.Arrays;
+import jdk.testlibrary.JDKToolLauncher;
+import jdk.test.lib.apps.LingeredApp;
+import jdk.test.lib.Platform;
+
+public class AlternateHashingTest {
+
+    private static LingeredAppWithAltHashing theApp = null;
+
+    /**
+     *
+     * @param vmArgs  - tool arguments to launch jhsdb
+     * @return exit code of tool
+     */
+    public static void launch(String expectedMessage, String cmd) throws IOException {
+
+        System.out.println("Starting LingeredApp");
+        try {
+            theApp = new LingeredAppWithAltHashing();
+            LingeredApp.startApp(Arrays.asList("-Xmx256m"), theApp);
+
+            System.out.println("Starting clhsdb against " + theApp.getPid());
+            JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
+            launcher.addToolArg("clhsdb");
+            launcher.addToolArg("--pid=" + Long.toString(theApp.getPid()));
+
+            ProcessBuilder processBuilder = new ProcessBuilder(launcher.getCommand());
+            processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
+            Process toolProcess = processBuilder.start();
+
+            try (OutputStream out = toolProcess.getOutputStream()) {
+                out.write(cmd.getBytes());
+                out.write("quit\n".getBytes());
+            }
+
+            boolean result = false;
+            try (BufferedReader reader =
+                 new BufferedReader(new InputStreamReader(toolProcess.getInputStream()))) {
+                String line;
+
+                while ((line = reader.readLine()) != null) {
+                    line = line.trim();
+                    System.out.println(line);
+
+                    if (line.contains(expectedMessage)) {
+                        result = true;
+                        break;
+                    }
+                }
+            }
+
+            toolProcess.waitFor();
+
+            if (toolProcess.exitValue() != 0) {
+                throw new RuntimeException("FAILED CLHSDB terminated with non-zero exit code " + toolProcess.exitValue());
+            }
+
+            if (!result) {
+                throw new RuntimeException(cmd + " command output is missing the message " + expectedMessage);
+            }
+
+        } catch (Exception ex) {
+            throw new RuntimeException("Test ERROR " + ex, ex);
+        } finally {
+            LingeredApp.stopApp(theApp);
+        }
+    }
+
+
+    public static void testAltHashing() throws IOException {
+
+        launch("Stack in use by Java", "threads\n");
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        if (!Platform.shouldSAAttach()) {
+            // Silently skip the test if we don't have enough permissions to attach
+            System.err.println("Error! Insufficient permissions to attach - test skipped.");
+            return;
+        }
+
+
+        testAltHashing();
+
+        // The test throws RuntimeException on error.
+        // IOException is thrown if LingeredApp can't start because of some bad
+        // environment condition
+        System.out.println("Test PASSED");
+    }
+}
--- a/jdk/test/sun/tools/jhsdb/HeapDumpTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/sun/tools/jhsdb/HeapDumpTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,7 @@
 import jdk.testlibrary.ProcessTools;
 import jdk.test.lib.apps.LingeredApp;
 import jdk.test.lib.Platform;
+import jdk.test.lib.hprof.parser.HprofReader;
 
 public class HeapDumpTest {
 
@@ -93,6 +94,17 @@
         launch(expectedMessage, Arrays.asList(toolArgs));
     }
 
+    public static void printStackTraces(String file) throws IOException {
+        try {
+            String output = HprofReader.getStack(file, 0);
+            if (!output.contains("LingeredAppWithExtendedChars.main")) {
+                throw new RuntimeException("'LingeredAppWithExtendedChars.main' missing from stdout/stderr");
+            }
+        } catch (Exception ex) {
+            throw new RuntimeException("Test ERROR " + ex, ex);
+        }
+    }
+
     public static void testHeapDump() throws IOException {
         File dump = new File("jhsdb.jmap.heap." +
                              System.currentTimeMillis() + ".hprof");
@@ -106,6 +118,8 @@
         assertTrue(dump.exists() && dump.isFile(),
                    "Could not create dump file " + dump.getAbsolutePath());
 
+        printStackTraces(dump.getAbsolutePath());
+
         dump.delete();
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/tools/jhsdb/LingeredAppWithAltHashing.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import jdk.test.lib.apps.LingeredApp;
+
+public class LingeredAppWithAltHashing extends LingeredApp {
+
+    public static void main(String args[]) {
+        LingeredApp.main(args);
+    }
+
+    // Following strings generate the same hashcode
+
+    static final String str1 = "AaAaAaAaAaAaAa";
+    static final String str2 = "AaAaAaAaAaAaBB";
+    static final String str3 = "AaAaAaAaAaBBAa";
+    static final String str4 = "AaAaAaAaAaBBBB";
+    static final String str5 = "AaAaAaAaBBAaAa";
+    static final String str6 = "AaAaAaAaBBAaBB";
+    static final String str7 = "AaAaAaAaBBBBAa";
+    static final String str8 = "AaAaAaAaBBBBBB";
+    static final String str9 = "AaAaAaBBAaAaAa";
+    static final String str10 = "AaAaAaBBAaAaBB";
+    static final String str11 = "AaAaAaBBAaBBAa";
+    static final String str12 = "AaAaAaBBAaBBBB";
+    static final String str13 = "AaAaAaBBBBAaAa";
+    static final String str14 = "AaAaAaBBBBAaBB";
+    static final String str15 = "AaAaAaBBBBBBAa";
+    static final String str16 = "AaAaAaBBBBBBBB";
+    static final String str17 = "AaAaBBAaAaAaAa";
+    static final String str18 = "AaAaBBAaAaAaBB";
+    static final String str19 = "AaAaBBAaAaBBAa";
+    static final String str20 = "AaAaBBAaAaBBBB";
+    static final String str21 = "AaAaBBAaBBAaAa";
+    static final String str22 = "AaAaBBAaBBAaBB";
+    static final String str23 = "AaAaBBAaBBBBAa";
+    static final String str24 = "AaAaBBAaBBBBBB";
+    static final String str25 = "AaAaBBBBAaAaAa";
+    static final String str26 = "AaAaBBBBAaAaBB";
+    static final String str27 = "AaAaBBBBAaBBAa";
+    static final String str28 = "AaAaBBBBAaBBBB";
+    static final String str29 = "AaAaBBBBBBAaAa";
+    static final String str30 = "AaAaBBBBBBAaBB";
+    static final String str31 = "AaAaBBBBBBBBAa";
+    static final String str32 = "AaAaBBBBBBBBBB";
+    static final String str33 = "AaBBAaAaAaAaAa";
+    static final String str34 = "AaBBAaAaAaAaBB";
+    static final String str35 = "AaBBAaAaAaBBAa";
+    static final String str36 = "AaBBAaAaAaBBBB";
+    static final String str37 = "AaBBAaAaBBAaAa";
+    static final String str38 = "AaBBAaAaBBAaBB";
+    static final String str39 = "AaBBAaAaBBBBAa";
+    static final String str40 = "AaBBAaAaBBBBBB";
+    static final String str41 = "AaBBAaBBAaAaAa";
+    static final String str42 = "AaBBAaBBAaAaBB";
+    static final String str43 = "AaBBAaBBAaBBAa";
+    static final String str44 = "AaBBAaBBAaBBBB";
+    static final String str45 = "AaBBAaBBBBAaAa";
+    static final String str46 = "AaBBAaBBBBAaBB";
+    static final String str47 = "AaBBAaBBBBBBAa";
+    static final String str48 = "AaBBAaBBBBBBBB";
+    static final String str49 = "AaBBBBAaAaAaAa";
+    static final String str50 = "AaBBBBAaAaAaBB";
+    static final String str51 = "AaBBBBAaAaBBAa";
+    static final String str52 = "AaBBBBAaAaBBBB";
+    static final String str53 = "AaBBBBAaBBAaAa";
+    static final String str54 = "AaBBBBAaBBAaBB";
+    static final String str55 = "AaBBBBAaBBBBAa";
+    static final String str56 = "AaBBBBAaBBBBBB";
+    static final String str57 = "AaBBBBBBAaAaAa";
+    static final String str58 = "AaBBBBBBAaAaBB";
+    static final String str59 = "AaBBBBBBAaBBAa";
+    static final String str60 = "AaBBBBBBAaBBBB";
+    static final String str61 = "AaBBBBBBBBAaAa";
+    static final String str62 = "AaBBBBBBBBAaBB";
+    static final String str63 = "AaBBBBBBBBBBAa";
+    static final String str64 = "AaBBBBBBBBBBBB";
+    static final String str65 = "BBAaAaAaAaAaAa";
+    static final String str66 = "BBAaAaAaAaAaBB";
+    static final String str67 = "BBAaAaAaAaBBAa";
+    static final String str68 = "BBAaAaAaAaBBBB";
+    static final String str69 = "BBAaAaAaBBAaAa";
+    static final String str70 = "BBAaAaAaBBAaBB";
+    static final String str71 = "BBAaAaAaBBBBAa";
+    static final String str72 = "BBAaAaAaBBBBBB";
+    static final String str73 = "BBAaAaBBAaAaAa";
+    static final String str74 = "BBAaAaBBAaAaBB";
+    static final String str75 = "BBAaAaBBAaBBAa";
+    static final String str76 = "BBAaAaBBAaBBBB";
+    static final String str77 = "BBAaAaBBBBAaAa";
+    static final String str78 = "BBAaAaBBBBAaBB";
+    static final String str79 = "BBAaAaBBBBBBAa";
+    static final String str80 = "BBAaAaBBBBBBBB";
+    static final String str81 = "BBAaBBAaAaAaAa";
+    static final String str82 = "BBAaBBAaAaAaBB";
+    static final String str83 = "BBAaBBAaAaBBAa";
+    static final String str84 = "BBAaBBAaAaBBBB";
+    static final String str85 = "BBAaBBAaBBAaAa";
+    static final String str86 = "BBAaBBAaBBAaBB";
+    static final String str87 = "BBAaBBAaBBBBAa";
+    static final String str88 = "BBAaBBAaBBBBBB";
+    static final String str89 = "BBAaBBBBAaAaAa";
+    static final String str90 = "BBAaBBBBAaAaBB";
+    static final String str91 = "BBAaBBBBAaBBAa";
+    static final String str92 = "BBAaBBBBAaBBBB";
+    static final String str93 = "BBAaBBBBBBAaAa";
+    static final String str94 = "BBAaBBBBBBAaBB";
+    static final String str95 = "BBAaBBBBBBBBAa";
+    static final String str96 = "BBAaBBBBBBBBBB";
+    static final String str97 = "BBBBAaAaAaAaAa";
+    static final String str98 = "BBBBAaAaAaAaBB";
+    static final String str99 = "BBBBAaAaAaBBAa";
+    static final String str100 = "BBBBAaAaAaBBBB";
+    static final String str101 = "BBBBAaAaBBAaAa";
+    static final String str102 = "BBBBAaAaBBAaBB";
+    static final String str103 = "BBBBAaAaBBBBAa";
+    static final String str104 = "BBBBAaAaBBBBBB";
+    static final String str105 = "BBBBAaBBAaAaAa";
+    static final String str106 = "BBBBAaBBAaAaBB";
+    static final String str107 = "BBBBAaBBAaBBAa";
+    static final String str108 = "BBBBAaBBAaBBBB";
+    static final String str109 = "BBBBAaBBBBAaAa";
+    static final String str110 = "BBBBAaBBBBAaBB";
+    static final String str111 = "BBBBAaBBBBBBAa";
+    static final String str112 = "BBBBAaBBBBBBBB";
+    static final String str113 = "BBBBBBAaAaAaAa";
+    static final String str114 = "BBBBBBAaAaAaBB";
+    static final String str115 = "BBBBBBAaAaBBAa";
+    static final String str116 = "BBBBBBAaAaBBBB";
+    static final String str117 = "BBBBBBAaBBAaAa";
+    static final String str118 = "BBBBBBAaBBAaBB";
+    static final String str119 = "BBBBBBAaBBBBAa";
+    static final String str120 = "BBBBBBAaBBBBBB";
+    static final String str121 = "BBBBBBBBAaAaAa";
+    static final String str122 = "BBBBBBBBAaAaBB";
+    static final String str123 = "BBBBBBBBAaBBAa";
+    static final String str124 = "BBBBBBBBAaBBBB";
+    static final String str125 = "BBBBBBBBBBAaAa";
+    static final String str126 = "BBBBBBBBBBAaBB";
+    static final String str127 = "BBBBBBBBBBBBAa";
+    static final String str128 = "BBBBBBBBBBBBBB";
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/util/calendar/Bug8176160.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,55 @@
+/*
+ * 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 8176160
+ *@summary Make sure CalendarSystem.getEra(name) is consistent with getEras()
+ *@modules java.base/sun.util.calendar
+ *@run main/othervm Bug8176160
+ */
+
+import java.util.Arrays;
+import java.util.List;
+import sun.util.calendar.CalendarSystem;
+import sun.util.calendar.Era;
+
+public class Bug8176160 {
+
+    public static void main(String[] args) throws Exception {
+        List.of("gregorian", "japanese", "julian").stream()
+            .map(CalendarSystem::forName)
+            .forEach(cal -> {
+                Era[] eras = cal.getEras();
+                if (eras != null) {
+                    Arrays.stream(eras)
+                        .forEach(era -> {
+                            System.out.printf("cal: %s, era: %s\n", cal, era);
+                            if (cal.getEra(era.getName()) != era) {
+                                throw new RuntimeException("no match");
+                            }
+                        });
+                }
+            });
+    }
+}
--- a/jdk/test/tools/jar/InputFilesTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jar/InputFilesTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,9 +28,8 @@
  *          options with/without a --release option.  Some input files are
  *          duplicates that sometimes cause exceptions and other times do not,
  *          demonstrating identical behavior to JDK 8 jar tool.
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules jdk.jartool
- * @build jdk.testlibrary.FileUtils
  * @run testng InputFilesTest
  */
 
@@ -51,7 +50,7 @@
 import java.util.stream.Stream;
 import java.util.zip.ZipException;
 
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 
 public class InputFilesTest {
     private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
--- a/jdk/test/tools/jar/ReleaseBeforeFiles.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jar/ReleaseBeforeFiles.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,9 +27,8 @@
  * @summary test that both old style command line options and new gnu style
  *          command line options work with the --release option whether or
  *          not the --release option is preceded by a file name.
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules jdk.jartool/sun.tools.jar
- * @build jdk.testlibrary.FileUtils
  * @run testng ReleaseBeforeFiles
  */
 
@@ -46,7 +45,7 @@
 import java.util.Arrays;
 import java.util.stream.Stream;
 
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 
 public class ReleaseBeforeFiles {
     private Runnable onCompletion;
--- a/jdk/test/tools/jar/compat/CLICompatibility.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jar/compat/CLICompatibility.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
 import java.util.jar.JarOutputStream;
 import java.util.stream.Stream;
 
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 import jdk.testlibrary.JDKToolFinder;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -49,8 +49,8 @@
 /*
  * @test
  * @bug 8170952
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
+ * @library /lib/testlibrary /test/lib
+ * @build jdk.testlibrary.JDKToolFinder
  * @run testng CLICompatibility
  * @summary Basic test for compatibility of CLI options
  */
--- a/jdk/test/tools/jar/mmrjar/Basic.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jar/mmrjar/Basic.java	Wed Jul 05 23:37:13 2017 +0200
@@ -29,8 +29,7 @@
  * @modules java.base/jdk.internal.module
  *          jdk.compiler
  *          jdk.jartool
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library /test/lib
  * @run testng Basic
  */
 
@@ -57,7 +56,7 @@
 import java.util.zip.ZipFile;
 
 import jdk.internal.module.ModuleInfoExtender;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 
 public class Basic {
     private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
--- a/jdk/test/tools/jar/modularJar/Basic.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jar/modularJar/Basic.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,7 +25,6 @@
 import java.lang.module.ModuleDescriptor;
 import java.lang.reflect.Method;
 import java.nio.file.*;
-import java.nio.file.attribute.BasicFileAttributes;
 import java.util.*;
 import java.util.function.Consumer;
 import java.util.jar.JarEntry;
@@ -36,7 +35,7 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 import jdk.testlibrary.JDKToolFinder;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
@@ -48,10 +47,10 @@
 /*
  * @test
  * @bug 8167328 8171830 8165640 8174248 8176772
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
  *          jdk.jartool
- * @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
+ * @build jdk.testlibrary.JDKToolFinder
  * @compile Basic.java
  * @run testng Basic
  * @summary Tests for plain Modular jars & Multi-Release Modular jars
--- a/jdk/test/tools/jar/multiRelease/ApiValidatorTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jar/multiRelease/ApiValidatorTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -24,18 +24,16 @@
 /*
  * @test
  * @summary Tests for API validator.
- * @library /test/lib /lib/testlibrary
+ * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          jdk.compiler
  *          jdk.jartool
- * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils jdk.test.lib.process.*
- * @build jdk.testlibrary.FileUtils
  * @build MRTestBase
  * @run testng/timeout=1200 ApiValidatorTest
  */
 
 import jdk.test.lib.process.OutputAnalyzer;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.DataProvider;
@@ -421,4 +419,5 @@
 
         javac(classes, sourceFiles);
     }
-}
\ No newline at end of file
+}
+
--- a/jdk/test/tools/jar/multiRelease/Basic.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jar/multiRelease/Basic.java	Wed Jul 05 23:37:13 2017 +0200
@@ -23,19 +23,17 @@
 
 /*
  * @test
- * @library /test/lib /lib/testlibrary
+ * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          jdk.compiler
  *          jdk.jartool
- * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils jdk.test.lib.process.*
- * @build jdk.testlibrary.FileUtils
  * @build MRTestBase
  * @run testng Basic
  */
 
 import static org.testng.Assert.*;
 
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 import org.testng.annotations.*;
 
 import java.io.File;
--- a/jdk/test/tools/jar/multiRelease/RuntimeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jar/multiRelease/RuntimeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,12 +25,7 @@
  * @test
  * @summary Test Multi-Release jar usage in runtime
  * @library /test/lib
- * @library /lib/testlibrary
  * @modules jdk.compiler
- * @build jdk.test.lib.JDKToolFinder jdk.test.lib.JDKToolLauncher
- *        jdk.test.lib.process.OutputAnalyzer
- *        jdk.test.lib.process.ProcessTools
- *        CompilerUtils RuntimeTest
  * @run testng RuntimeTest
  */
 
@@ -41,6 +36,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.UncheckedIOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.URL;
@@ -51,7 +47,10 @@
 import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import org.testng.annotations.BeforeClass;
@@ -60,37 +59,53 @@
 
 import jdk.test.lib.JDKToolFinder;
 import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.compiler.CompilerUtils;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
 
 public class RuntimeTest {
     public static final int SUCCESS = 0;
-    private final String src = System.getProperty("test.src", ".");
-    private final String usr = System.getProperty("user.dir", ".");
+    private static final String src = System.getProperty("test.src", ".");
+    private static final String usr = System.getProperty("user.dir", ".");
+
+    private static final Path srcFileRoot = Paths.get(src, "data", "runtimetest");
+    private static final Path genFileRoot = Paths.get(usr, "data", "runtimetest");
+
+    private static final int OLD_RELEASE = 8;
+    private static final int CURRENT_RELEASE = Runtime.version().major();
+    private static final int FUTURE_RELEASE = CURRENT_RELEASE + 1;
+    private static final String MRJAR_BOTH_RELEASES = "MV_BOTH.jar";
+    private static final String MRJAR_CURRENT_RELEASE = "MV_ONLY_" + CURRENT_RELEASE + ".jar";
+    private static final String NON_MRJAR_OLD_RELEASE = "NON_MV.jar";
+
+    private static final int[] versions = { OLD_RELEASE, CURRENT_RELEASE, FUTURE_RELEASE };
 
     @DataProvider(name = "jarFiles")
     Object[][] jarFiles() {
-        return new Object[][] { { "MV_BOTH.jar", 9, 9, 9 },
-                { "MV_ONLY_9.jar", 9, 9, 9 },
-                { "NON_MV.jar", 8, 8, 8 } };
+        return new Object[][]{
+            { MRJAR_BOTH_RELEASES, CURRENT_RELEASE, CURRENT_RELEASE, CURRENT_RELEASE },
+            { MRJAR_CURRENT_RELEASE, CURRENT_RELEASE, CURRENT_RELEASE, CURRENT_RELEASE },
+            { NON_MRJAR_OLD_RELEASE, OLD_RELEASE, OLD_RELEASE, OLD_RELEASE }
+        };
     }
 
     @BeforeClass
     protected void setUpTest() throws Throwable {
+        createJarSourceFiles();
         compile();
         Path classes = Paths.get("classes");
-        jar("cfm", "MV_BOTH.jar", "manifest.txt",
-                "-C", classes.resolve("base").toString(), ".",
-                "--release", "9", "-C", classes.resolve("v9").toString(), ".",
-                "--release", "10", "-C", classes.resolve("v10").toString(), ".")
+        jar("cfm", MRJAR_BOTH_RELEASES, "manifest.txt",
+                "-C", classes.resolve("v" + OLD_RELEASE).toString(), ".",
+                "--release", "" + CURRENT_RELEASE, "-C", classes.resolve("v" + CURRENT_RELEASE).toString(), ".",
+                "--release", "" + FUTURE_RELEASE, "-C", classes.resolve("v" + FUTURE_RELEASE).toString(), ".")
                 .shouldHaveExitValue(0);
 
-        jar("cfm", "MV_ONLY_9.jar", "manifest.txt",
-                "-C", classes.resolve("base").toString(), ".",
-                "--release", "9", "-C", classes.resolve("v9").toString(), ".")
+        jar("cfm", MRJAR_CURRENT_RELEASE, "manifest.txt",
+                "-C", classes.resolve("v" + OLD_RELEASE).toString(), ".",
+                "--release", "" + CURRENT_RELEASE, "-C", classes.resolve("v" + CURRENT_RELEASE).toString(), ".")
                 .shouldHaveExitValue(0);
-        jar("cfm", "NON_MV.jar", "manifest.txt",
-                "-C", classes.resolve("base").toString(), ".")
+        jar("cfm", NON_MRJAR_OLD_RELEASE, "manifest.txt",
+                "-C", classes.resolve("v" + OLD_RELEASE).toString(), ".")
                 .shouldHaveExitValue(0);
     }
 
@@ -203,12 +218,37 @@
         return ProcessTools.executeCommand(launcher.getCommand());
     }
 
+    private static String platformPath(String p) {
+        return p.replace("/", File.separator);
+    }
+
+    private static void createJarSourceFiles() throws IOException {
+        for (int ver : versions) {
+            Files.find(srcFileRoot, 3, (file, attrs) -> (file.toString().endsWith(".template")))
+                 .map(srcFileRoot::relativize)
+                 .map(Path::toString)
+                 .map(p -> p.replace(".template", ""))
+                 .forEach(f -> {
+                     try {
+                         Path template = srcFileRoot.resolve(f + ".template");
+                         Path out = genFileRoot.resolve(platformPath("v" + ver + "/" + f));
+                         Files.createDirectories(out.getParent());
+                         List<String> lines = Files.lines(template)
+                                 .map(s -> s.replaceAll("\\$version", String.valueOf(ver)))
+                                 .collect(Collectors.toList());
+                         Files.write(out, lines);
+                     } catch (IOException x) {
+                         throw new UncheckedIOException(x);
+                     }
+                 });
+        }
+    }
+
     private void compile() throws Throwable {
-        String[] vers = { "base", "v9", "v10" };
-        for (String ver : vers) {
-            Path classes = Paths.get(usr, "classes", ver);
+        for (int ver : versions) {
+            Path classes = Paths.get(usr, "classes", "v" + ver);
             Files.createDirectories(classes);
-            Path source = Paths.get(src, "data", "runtimetest", ver);
+            Path source = genFileRoot.resolve("v" + ver);
             assertTrue(CompilerUtils.compile(source, classes));
             Files.copy(source.resolve("versionResource"),
                     classes.resolve("versionResource"),
@@ -217,10 +257,10 @@
 
         Path classes = Paths.get(usr, "classes", "test");
         Files.createDirectory(classes);
-        Path source = Paths.get(src, "data", "runtimetest", "test");
+        Path source = srcFileRoot.resolve("test");
         assertTrue(
-                CompilerUtils.compile(source, classes, "-cp", "classes/base/"));
-        Files.copy(Paths.get(src, "data", "runtimetest", "manifest.txt"),
+                CompilerUtils.compile(source, classes, "-cp", "classes/v" + OLD_RELEASE));
+        Files.copy(srcFileRoot.resolve("manifest.txt"),
                 Paths.get(usr, "manifest.txt"),
                 StandardCopyOption.REPLACE_EXISTING);
     }
--- a/jdk/test/tools/jar/multiRelease/data/runtimetest/base/testpackage/Helper.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +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.
- */
-
-package testpackage;
-
-public class Helper {
-
-    private static final int HELPER_VERSION = 8;
-
-    public static int getHelperVersion() {
-        return HELPER_VERSION;
-    }
-}
--- a/jdk/test/tools/jar/multiRelease/data/runtimetest/base/testpackage/Main.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +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.
- */
-
-package testpackage;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-public class Main {
-
-    private static final int MAIN_VERSION = 8;
-
-    public static void main(String[] args) {
-        System.out.println("Main version: " + getMainVersion());
-        System.out.println("Helpers version: " + getHelperVersion());
-        System.out.println("Resource version: " + getResourceVersion());
-    }
-
-    public static int getMainVersion() {
-        return MAIN_VERSION;
-    }
-
-    public static int getHelperVersion() {
-        return testpackage.Helper.getHelperVersion();
-    }
-
-    public static int getResourceVersion() {
-        ClassLoader cl = Main.class.getClassLoader();
-        InputStream ris = cl.getResourceAsStream("versionResource");
-        if (ris == null) {
-            throw new Error("Test issue: resource versionResource"
-                    + " cannot be loaded!");
-        }
-        try (BufferedReader br = new BufferedReader(new InputStreamReader(ris))) {
-            return Integer.parseInt(br.readLine());
-        } catch (IOException ioe) {
-            throw new Error("Unexpected issue", ioe);
-        }
-    }
-}
--- a/jdk/test/tools/jar/multiRelease/data/runtimetest/base/versionResource	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-8
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jar/multiRelease/data/runtimetest/testpackage/Helper.java.template	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,33 @@
+/*
+ * 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
+ * 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 testpackage;
+
+public class Helper {
+
+    private static final int HELPER_VERSION = $version;
+
+    public static int getHelperVersion() {
+        return HELPER_VERSION;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jar/multiRelease/data/runtimetest/testpackage/Main.java.template	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,62 @@
+/*
+ * 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
+ * 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 testpackage;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+public class Main {
+
+    private static final int MAIN_VERSION = $version;
+
+    public static void main(String[] args) {
+        System.out.println("Main version: " + getMainVersion());
+        System.out.println("Helpers version: " + getHelperVersion());
+        System.out.println("Resource version: " + getResourceVersion());
+    }
+
+    public static int getMainVersion() {
+        return MAIN_VERSION;
+    }
+
+    public static int getHelperVersion() {
+        return testpackage.Helper.getHelperVersion();
+    }
+
+    public static int getResourceVersion() {
+        ClassLoader cl = Main.class.getClassLoader();
+        InputStream ris = cl.getResourceAsStream("versionResource");
+        if (ris == null) {
+            throw new Error("Test issue: resource versionResource"
+                    + " cannot be loaded!");
+        }
+        try (BufferedReader br = new BufferedReader(new InputStreamReader(ris))) {
+            return Integer.parseInt(br.readLine());
+        } catch (IOException ioe) {
+            throw new Error("Unexpected issue", ioe);
+        }
+    }
+}
--- a/jdk/test/tools/jar/multiRelease/data/runtimetest/v10/testpackage/Helper.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +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.
- */
-
-package testpackage;
-
-public class Helper {
-
-    private static final int HELPER_VERSION = 10;
-
-    public static int getHelperVersion() {
-        return HELPER_VERSION;
-    }
-}
--- a/jdk/test/tools/jar/multiRelease/data/runtimetest/v10/testpackage/Main.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +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.
- */
-
-package testpackage;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-public class Main {
-
-    private static final int MAIN_VERSION = 10;
-
-    public static void main(String[] args) {
-        System.out.println("Main version: " + getMainVersion());
-        System.out.println("Helpers version: " + getHelperVersion());
-        System.out.println("Resource version: " + getResourceVersion());
-    }
-
-    public static int getMainVersion() {
-        return MAIN_VERSION;
-    }
-
-    public static int getHelperVersion() {
-        return testpackage.Helper.getHelperVersion();
-    }
-
-    public static int getResourceVersion() {
-        ClassLoader cl = Main.class.getClassLoader();
-        InputStream ris = cl.getResourceAsStream("versionResource");
-        if (ris == null) {
-            throw new Error("Test issue: resource versionResource"
-                    + " cannot be loaded!");
-        }
-        try (BufferedReader br = new BufferedReader(new InputStreamReader(ris))) {
-            return Integer.parseInt(br.readLine());
-        } catch (IOException ioe) {
-            throw new Error("Unexpected issue", ioe);
-        }
-    }
-}
--- a/jdk/test/tools/jar/multiRelease/data/runtimetest/v10/versionResource	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-10
--- a/jdk/test/tools/jar/multiRelease/data/runtimetest/v9/testpackage/Helper.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +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.
- */
-
-package testpackage;
-
-public class Helper {
-
-    private static final int HELPER_VERSION = 9;
-
-    public static int getHelperVersion() {
-        return HELPER_VERSION;
-    }
-}
--- a/jdk/test/tools/jar/multiRelease/data/runtimetest/v9/testpackage/Main.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +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.
- */
-
-package testpackage;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-public class Main {
-
-    private static final int MAIN_VERSION = 9;
-
-    public static void main(String[] args) {
-        System.out.println("Main version: " + getMainVersion());
-        System.out.println("Helpers version: " + getHelperVersion());
-        System.out.println("Resource version: " + getResourceVersion());
-    }
-
-    public static int getMainVersion() {
-        return MAIN_VERSION;
-    }
-
-    public static int getHelperVersion() {
-        return testpackage.Helper.getHelperVersion();
-    }
-
-    public static int getResourceVersion() {
-        ClassLoader cl = Main.class.getClassLoader();
-        InputStream ris = cl.getResourceAsStream("versionResource");
-        if (ris == null) {
-            throw new Error("Test issue: resource versionResource"
-                    + " cannot be loaded!");
-        }
-        try (BufferedReader br = new BufferedReader(new InputStreamReader(ris))) {
-            return Integer.parseInt(br.readLine());
-        } catch (IOException ioe) {
-            throw new Error("Unexpected issue", ioe);
-        }
-    }
-}
--- a/jdk/test/tools/jar/multiRelease/data/runtimetest/v9/versionResource	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/tools/jar/multiRelease/data/runtimetest/versionResource.template	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,1 @@
+$version
--- a/jdk/test/tools/jlink/basic/AllModulePath.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jlink/basic/AllModulePath.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,11 +24,11 @@
 /*
  * @test
  * @summary jlink test of --add-module ALL-MODULE-PATH
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
  * @build jdk.testlibrary.ProcessTools
  *        jdk.testlibrary.OutputAnalyzer
- *        CompilerUtils
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng AllModulePath
  */
 
@@ -48,6 +48,7 @@
 import java.util.stream.Stream;
 import java.util.spi.ToolProvider;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import jdk.testlibrary.ProcessTools;
 
 import org.testng.annotations.BeforeClass;
--- a/jdk/test/tools/jlink/basic/BasicTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jlink/basic/BasicTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,13 +25,13 @@
  * @test
  * @summary Basic test of jlink to create jmods and images
  * @author Andrei Eremeev
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules java.base/jdk.internal.module
  *          jdk.jlink
  *          jdk.compiler
  * @build jdk.testlibrary.ProcessTools
  *        jdk.testlibrary.OutputAnalyzer
- *        JarUtils CompilerUtils
+ *        JarUtils jdk.test.lib.compiler.CompilerUtils
  * @run main BasicTest
  */
 
@@ -45,6 +45,7 @@
 import java.util.List;
 import java.util.spi.ToolProvider;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import jdk.testlibrary.OutputAnalyzer;
 import jdk.testlibrary.ProcessTools;
 
--- a/jdk/test/tools/jlink/bindservices/BindServices.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jlink/bindservices/BindServices.java	Wed Jul 05 23:37:13 2017 +0200
@@ -33,6 +33,7 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
@@ -42,9 +43,10 @@
 /**
  * @test
  * @bug 8174826
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler jdk.jlink
- * @build BindServices CompilerUtils jdk.testlibrary.ProcessTools
+ * @build BindServices jdk.testlibrary.ProcessTools
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng BindServices
  */
 
--- a/jdk/test/tools/jlink/bindservices/SuggestProviders.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jlink/bindservices/SuggestProviders.java	Wed Jul 05 23:37:13 2017 +0200
@@ -32,6 +32,7 @@
 import java.util.spi.ToolProvider;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
@@ -40,9 +41,9 @@
 /**
  * @test
  * @bug 8174826
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.charsets jdk.compiler jdk.jlink
- * @build SuggestProviders CompilerUtils
+ * @build SuggestProviders jdk.test.lib.compiler.CompilerUtils
  * @run testng SuggestProviders
  */
 
--- a/jdk/test/tools/jlink/plugins/ExcludeJmodSectionPluginTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jlink/plugins/ExcludeJmodSectionPluginTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,10 @@
 /*
  * @test
  * @summary Test --no-man-pages and --no-header-files
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules jdk.compiler
  *          jdk.jlink
- * @build CompilerUtils
+ * @build jdk.test.lib.compiler.CompilerUtils
  * @run testng ExcludeJmodSectionPluginTest
  */
 
@@ -48,6 +48,7 @@
 import java.util.spi.ToolProvider;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/jdk/test/tools/jlink/plugins/LegalFilePluginTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jlink/plugins/LegalFilePluginTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,10 @@
  * @test
  * @bug 8169925
  * @summary Validate the license files deduplicated in the image
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules jdk.compiler
  *          jdk.jlink
- * @build CompilerUtils
+ * @build jdk.test.lib.compiler.CompilerUtils
  * @run testng LegalFilePluginTest
  */
 
@@ -53,6 +53,7 @@
 import java.util.spi.ToolProvider;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
+import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,8 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.compiler.CompilerUtils;
+import jdk.test.lib.util.FileUtils;
 import static jdk.testlibrary.ProcessTools.*;
 
 
@@ -39,9 +40,10 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler jdk.jlink
- * @build CompiledVersionTest CompilerUtils jdk.testlibrary.FileUtils jdk.testlibrary.ProcessTools
+ * @build CompiledVersionTest jdk.testlibrary.ProcessTools
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng CompiledVersionTest
  */
 
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -23,7 +23,6 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.lang.module.ModuleDescriptor;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -33,7 +32,8 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.compiler.CompilerUtils;
+import jdk.test.lib.util.FileUtils;
 
 import static jdk.testlibrary.ProcessTools.*;
 
@@ -44,11 +44,12 @@
 /**
  * @test
  * @bug 8142968 8173381 8174740
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler jdk.jlink
  * @modules java.base/jdk.internal.module
  * @modules java.base/jdk.internal.org.objectweb.asm
- * @build ModuleTargetHelper UserModuleTest CompilerUtils jdk.testlibrary.FileUtils jdk.testlibrary.ProcessTools
+ * @build ModuleTargetHelper UserModuleTest jdk.testlibrary.ProcessTools
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng UserModuleTest
  */
 
--- a/jdk/test/tools/jmod/JmodNegativeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jmod/JmodNegativeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,10 +23,10 @@
 
 /*
  * @test
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules jdk.compiler
  *          jdk.jlink
- * @build jdk.testlibrary.FileUtils CompilerUtils
+ * @build jdk.test.lib.compiler.CompilerUtils
  * @run testng JmodNegativeTest
  * @summary Negative tests for jmod
  */
@@ -41,7 +41,8 @@
 import java.util.function.Supplier;
 import java.util.spi.ToolProvider;
 import java.util.zip.ZipOutputStream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
+import jdk.test.lib.compiler.CompilerUtils;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
--- a/jdk/test/tools/jmod/JmodTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jmod/JmodTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,10 @@
  * @test
  * @bug 8142968 8166568 8166286 8170618 8168149
  * @summary Basic test for jmod
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules jdk.compiler
  *          jdk.jlink
- * @build jdk.testlibrary.FileUtils CompilerUtils
+ * @build jdk.test.lib.compiler.CompilerUtils
  * @run testng/othervm -Djava.io.tmpdir=. JmodTest
  */
 
@@ -40,9 +40,9 @@
 import java.util.function.Consumer;
 import java.util.regex.Pattern;
 import java.util.spi.ToolProvider;
-import java.util.stream.Collectors;
 import java.util.stream.Stream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.compiler.CompilerUtils;
+import jdk.test.lib.util.FileUtils;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
--- a/jdk/test/tools/jmod/hashes/HashesTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/jmod/hashes/HashesTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,13 +25,12 @@
  * @test
  * @bug 8160286
  * @summary Test the recording and checking of module hashes
- * @library /lib/testlibrary
+ * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          java.base/jdk.internal.module
  *          jdk.compiler
  *          jdk.jartool
  *          jdk.jlink
- * @build CompilerUtils ModuleInfoMaker
  * @run testng HashesTest
  */
 
@@ -62,6 +61,8 @@
 import jdk.internal.module.ModuleHashes;
 import jdk.internal.module.ModulePath;
 
+import jdk.test.lib.compiler.ModuleInfoMaker;
+
 import org.testng.annotations.Test;
 
 import static org.testng.Assert.*;
@@ -382,7 +383,7 @@
         makeModule(mn, null, deps);
     }
 
-    private void makeModule(String mn, ModuleDescriptor.Requires.Modifier mod,  String... deps)
+    private void makeModule(String mn, ModuleDescriptor.Requires.Modifier mod, String... deps)
         throws IOException
     {
         if (mod != null && mod != TRANSITIVE && mod != STATIC) {
@@ -390,23 +391,23 @@
         }
 
         StringBuilder sb = new StringBuilder();
-        sb.append("module " + mn + " {").append("\n");
-        Arrays.stream(deps).forEach(req -> {
-            sb.append("    requires ");
-            if (mod != null) {
-                sb.append(mod.toString().toLowerCase()).append(" ");
-            }
-            sb.append(req + ";\n");
-        });
+        sb.append("module ")
+          .append(mn)
+          .append(" {")
+          .append("\n");
+        Arrays.stream(deps)
+              .forEach(req -> {
+                  sb.append("    requires ");
+                  if (mod != null) {
+                      sb.append(mod.toString().toLowerCase())
+                        .append(" ");
+                  }
+                  sb.append(req)
+                    .append(";\n");
+              });
         sb.append("}\n");
         builder.writeJavaFiles(mn, sb.toString());
-
-        compileModule(mn, srcDir);
-    }
-
-    private void compileModule(String moduleName, Path src) throws IOException {
-        Path msrc = src.resolve(moduleName);
-        assertTrue(CompilerUtils.compile(msrc, mods, "--module-source-path", src.toString()));
+        builder.compile(mn, mods);
     }
 
     private void jmodHashModules(String moduleName, String hashModulesPattern) {
--- a/jdk/test/tools/launcher/ChangeDataModel.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/ChangeDataModel.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,104 +23,57 @@
 
 /**
  * @test
- * @bug 4894330 4810347 6277269 8029388
+ * @bug 4894330 4810347 6277269 8029388 8169646
  * @compile -XDignore.symbol.file ChangeDataModel.java
  * @run main ChangeDataModel
- * @summary Verify -d32 and -d64 options are accepted(rejected) on all platforms
+ * @summary Verify -d32, -d64 and -J prefixed data-model options are rejected on all platforms
  * @author Joseph D. Darcy, ksrini
  */
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
+
+import java.util.Arrays;
 
 public class ChangeDataModel extends TestHelper {
-    private static final File TestJar      = new File("test" + JAR_FILE_EXT);
-    private static final String OptionName = "Args";
-    private static final File TestOptionJar  = new File(OptionName + JAR_FILE_EXT);
-    private static final String OPT_PREFIX = "ARCH_OPT:";
 
-    static void createTestJar() throws Exception {
-        String[] code = {
-            "   public static void main(String argv[]) {",
-            "      System.out.println(\"" + OPT_PREFIX + "-d\" + System.getProperty(\"sun.arch.data.model\", \"none\"));",
-            "   }",};
-        createJar(TestJar, code);
-    }
     public static void main(String... args) throws Exception {
-        createTestJar();
-        createOptionsJar();
+        new ChangeDataModel().run(args);
+    }
 
-        // verify if data model flag for default data model is accepted, also
-        // verify if the complimentary data model is rejected.
-        if (is32Bit) {
-            checkAcceptance(javaCmd, "-d32");
-            checkRejection(javaCmd, "-d64");
-            checkOption(javaCmd, "-d64");
-        } else if (is64Bit) {
-            checkAcceptance(javaCmd, "-d64");
-            checkRejection(javaCmd, "-d32");
-            checkOption(javaCmd, "-d32");
-        } else {
-            throw new Error("unsupported data model");
-        }
+    @Test
+    public void check32bitRejection() throws Exception {
+        checkRejection("-d32");
+    }
+
+    @Test
+    public void check64bitRejection() throws Exception {
+        checkRejection("-d64");
     }
 
-    static void checkAcceptance(String cmd, String dmodel) {
-        TestResult tr = doExec(cmd, dmodel, "-jar", TestJar.getAbsolutePath());
-        if (!tr.contains(OPT_PREFIX + dmodel)) {
+    void checkRejection(String dmodel) throws Exception {
+        String expect = "Unrecognized option: " + dmodel;
+        String[] cmds1 = {
+            javaCmd,
+            dmodel,
+            "-version"
+        };
+        checkRejection(expect, cmds1);
+
+        String[] cmds2 = {
+            javacCmd,
+            "-J" + dmodel,
+            "-version"
+        };
+        checkRejection(expect, cmds2);
+    }
+
+
+    void checkRejection(String expect, String... cmds) throws Exception {
+        TestResult tr = doExec(cmds);
+        tr.checkNegative();
+        if (!tr.contains(expect)) {
             System.out.println(tr);
-            String message = "Data model flag " + dmodel +
-                    " not accepted or had improper effect.";
-            throw new RuntimeException(message);
+            String error = "did not get " + "\'" + expect + "\'" +
+                           "with options " + Arrays.asList(cmds);
+            throw new Exception(error);
         }
     }
-
-    static void checkRejection(String cmd, String dmodel) {
-        TestResult tr = doExec(cmd, dmodel, "-jar", TestJar.getAbsolutePath());
-        if (tr.contains(OPT_PREFIX + dmodel)) {
-            System.out.println(tr);
-            String message = "Data model flag " + dmodel + " was accepted.";
-            throw new RuntimeException(message);
-        }
-    }
-
-    static void checkOption(String cmd, String dmodel) throws Exception {
-        TestResult tr = doExec(cmd, "-jar", TestOptionJar.getAbsolutePath(), dmodel);
-        verifyOption(tr, dmodel);
-
-        tr = doExec(cmd, "-cp", ".", OptionName, dmodel);
-        verifyOption(tr, dmodel);
-    }
-
-    static void verifyOption(TestResult tr, String dmodel) {
-        if (!tr.contains(OPT_PREFIX + dmodel)) {
-            System.out.println(tr);
-            String message = "app argument: " + dmodel + " not found.";
-            throw new RuntimeException(message);
-        }
-        if (!tr.isOK()) {
-            System.out.println(tr);
-            String message = "app argument: " + dmodel + " interpreted ?";
-            throw new RuntimeException(message);
-        }
-    }
-
-    static void createOptionsJar() throws Exception {
-        List<String> code = new ArrayList<>();
-        code.add("public class Args {");
-        code.add("   public static void main(String argv[]) {");
-        code.add("       for (String x : argv)");
-        code.add("           System.out.println(\"" + OPT_PREFIX + "\" + x);");
-        code.add("   }");
-        code.add("}");
-        File optionsJava  = new File(OptionName + JAVA_FILE_EXT);
-        createFile(optionsJava, code);
-        File optionsClass = new File(OptionName + CLASS_FILE_EXT);
-
-        compile(optionsJava.getName());
-        createJar("cvfe",
-                  TestOptionJar.getName(),
-                  OptionName,
-                  optionsClass.getName());
-    }
 }
--- a/jdk/test/tools/launcher/LauncherMessageTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/LauncherMessageTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -24,16 +24,16 @@
 /**
  * @test
  * @bug 8167063
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library /test/lib
  * @run main LauncherMessageTest
  * @summary LauncherHelper should not throw JNI error for LinkageError
  */
+
 import java.io.File;
 import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.List;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
 
 public class LauncherMessageTest {
 
--- a/jdk/test/tools/launcher/Test7029048.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/Test7029048.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -193,7 +193,7 @@
             if (isSolaris) {
                 /*
                  * Case 3: set the appropriate LLP_XX flag,
-                 * java64 -d64, LLP_64 is relevant, LLP_32 is ignored
+                 * java64 LLP_64 is relevant, LLP_32 is ignored
                  */
                 env.clear();
                 env.put(LD_LIBRARY_PATH_64, dstServerDir.getAbsolutePath());
--- a/jdk/test/tools/launcher/modules/addexports/AddExportsTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/addexports/AddExportsTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build AddExportsTest CompilerUtils jdk.testlibrary.*
+ * @build AddExportsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run testng AddExportsTest
  * @summary Basic tests for java --add-exports
  */
@@ -34,6 +34,7 @@
 import java.nio.file.Paths;
 import java.util.stream.Stream;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import jdk.testlibrary.OutputAnalyzer;
 import static jdk.testlibrary.ProcessTools.*;
 
--- a/jdk/test/tools/launcher/modules/addexports/AddExportsTestWarningError.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/addexports/AddExportsTestWarningError.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,9 +25,8 @@
  * @test
  * @bug 8168836
  * @summary Basic argument validation for --add-exports
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build AddExportsTestWarningError CompilerUtils ModuleInfoMaker
  * @build jdk.testlibrary.*
  * @run testng AddExportsTestWarningError
  */
@@ -40,6 +39,7 @@
 import java.util.Arrays;
 import java.util.stream.Stream;
 
+import jdk.test.lib.compiler.ModuleInfoMaker;
 import jdk.testlibrary.OutputAnalyzer;
 import static jdk.testlibrary.ProcessTools.*;
 
@@ -48,7 +48,6 @@
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
-
 @Test
 public class AddExportsTestWarningError {
 
--- a/jdk/test/tools/launcher/modules/addmods/AddModsTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/addmods/AddModsTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -23,10 +23,10 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.jlink/jdk.tools.jmod
  *          jdk.compiler
- * @build AddModsTest CompilerUtils jdk.testlibrary.*
+ * @build AddModsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run testng AddModsTest
  * @summary Basic test for java --add-modules
  */
@@ -35,6 +35,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
--- a/jdk/test/tools/launcher/modules/addreads/AddReadsTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/addreads/AddReadsTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,10 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build AddReadsTest CompilerUtils JarUtils jdk.testlibrary.*
+ * @build AddReadsTest JarUtils jdk.testlibrary.*
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng AddReadsTest
  * @summary Basic tests for java --add-reads
  */
@@ -33,6 +34,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import jdk.testlibrary.OutputAnalyzer;
 import static jdk.testlibrary.ProcessTools.*;
 
--- a/jdk/test/tools/launcher/modules/addreads/AddReadsTestWarningError.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/addreads/AddReadsTestWarningError.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,9 +25,9 @@
  * @test
  * @bug 8168836
  * @summary  Basic argument validation for --add-reads
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build AddReadsTestWarningError CompilerUtils ModuleInfoMaker
+ * @build AddReadsTestWarningError
  * @build jdk.testlibrary.*
  * @run testng AddReadsTestWarningError
  */
@@ -40,6 +40,7 @@
 import java.util.Arrays;
 import java.util.stream.Stream;
 
+import jdk.test.lib.compiler.ModuleInfoMaker;
 import jdk.testlibrary.OutputAnalyzer;
 import static jdk.testlibrary.ProcessTools.*;
 
@@ -48,7 +49,6 @@
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
-
 @Test
 public class AddReadsTestWarningError {
 
--- a/jdk/test/tools/launcher/modules/basic/BasicTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/basic/BasicTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,11 +23,11 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
  *          jdk.jartool
  *          jdk.jlink
- * @build BasicTest CompilerUtils jdk.testlibrary.*
+ * @build BasicTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run testng BasicTest
  * @summary Basic test of starting an application as a module
  */
@@ -38,6 +38,7 @@
 import java.nio.file.Paths;
 import java.util.spi.ToolProvider;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import jdk.testlibrary.ProcessTools;
 
 import org.testng.annotations.BeforeTest;
--- a/jdk/test/tools/launcher/modules/classpath/JavaClassPathTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/classpath/JavaClassPathTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
 import java.util.Map;
 import java.util.spi.ToolProvider;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import jdk.testlibrary.OutputAnalyzer;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.DataProvider;
@@ -42,10 +43,10 @@
  * @test
  * @bug 8168205
  * @summary Test the default class path if -Djava.class.path is set
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
  *          jdk.jartool
- * @build CompilerUtils jdk.testlibrary.*
+ * @build jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run testng JavaClassPathTest
  */
 
--- a/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/dryrun/DryRunTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,10 +24,11 @@
 /**
  * @test
  * @bug 8159596
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
  *          jdk.jartool
- * @build DryRunTest CompilerUtils jdk.testlibrary.ProcessTools
+ * @build DryRunTest jdk.testlibrary.ProcessTools
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng DryRunTest
  * @summary Test java --dry-run
  */
@@ -39,13 +40,13 @@
 import java.nio.file.Paths;
 import java.util.spi.ToolProvider;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import jdk.testlibrary.ProcessTools;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
-
 @Test
 public class DryRunTest {
 
--- a/jdk/test/tools/launcher/modules/limitmods/LimitModsTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/limitmods/LimitModsTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules java.desktop java.logging jdk.compiler
- * @build LimitModsTest CompilerUtils jdk.testlibrary.*
+ * @build LimitModsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run testng LimitModsTest
  * @summary Basic tests for java --limit-modules
  */
@@ -33,13 +33,13 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
-
 @Test
 public class LimitModsTest {
 
--- a/jdk/test/tools/launcher/modules/listmods/ListModsTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/listmods/ListModsTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -23,9 +23,9 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules java.se
- * @build ListModsTest CompilerUtils jdk.testlibrary.*
+ * @build ListModsTest jdk.test.lib.compiler.CompilerUtils jdk.testlibrary.*
  * @run testng ListModsTest
  * @summary Basic test for java --list-modules
  */
@@ -33,6 +33,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import jdk.testlibrary.ProcessTools;
 import jdk.testlibrary.OutputAnalyzer;
 
--- a/jdk/test/tools/launcher/modules/patch/basic/PatchTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/patch/basic/PatchTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,10 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build PatchTest CompilerUtils JarUtils jdk.testlibrary.*
+ * @build PatchTest JarUtils jdk.testlibrary.*
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng PatchTest
  * @summary Basic test for --patch-module
  */
@@ -37,13 +38,13 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
-
 /**
  * Compiles and launches a test that uses --patch-module with two directories
  * of classes to override existing classes and add new classes to modules in
--- a/jdk/test/tools/launcher/modules/patch/basic/PatchTestWarningError.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/patch/basic/PatchTestWarningError.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,9 +25,10 @@
  * @test
  * @bug 8168836
  * @summary Basic argument validation for --patch-module
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build PatchTestWarningError CompilerUtils JarUtils jdk.testlibrary.*
+ * @build PatchTestWarningError JarUtils jdk.testlibrary.*
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng PatchTestWarningError
  */
 
@@ -38,6 +39,7 @@
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.*;
 
 import org.testng.annotations.BeforeTest;
--- a/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,9 +25,9 @@
  * @test
  * @bug 8157068 8177844
  * @summary Patch java.base and user module with ModuleHashes attribute
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build CompilerUtils
+ * @build jdk.test.lib.compiler.CompilerUtils
  * @run testng PatchSystemModules
  */
 
@@ -39,7 +39,8 @@
 import java.util.List;
 import java.util.stream.Stream;
 
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.compiler.CompilerUtils;
+import jdk.test.lib.util.FileUtils;
 import jdk.testlibrary.JDKToolFinder;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
--- a/jdk/test/tools/launcher/modules/upgrademodulepath/UpgradeModulePathTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/launcher/modules/upgrademodulepath/UpgradeModulePathTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,10 @@
 
 /**
  * @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
  * @modules jdk.compiler
- * @build UpgradeModulePathTest CompilerUtils jdk.testlibrary.*
+ * @build UpgradeModulePathTest jdk.testlibrary.*
+ *        jdk.test.lib.compiler.CompilerUtils
  * @run testng UpgradeModulePathTest
  * @summary Basic test for java --upgrade-module-path
  */
@@ -34,6 +35,7 @@
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+import jdk.test.lib.compiler.CompilerUtils;
 import static jdk.testlibrary.ProcessTools.executeTestJava;
 
 import org.testng.annotations.BeforeTest;
@@ -46,7 +48,6 @@
  * modue path.
  */
 
-
 @Test
 public class UpgradeModulePathTest {
 
--- a/jdk/test/tools/schemagen/MultiReleaseJarTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/schemagen/MultiReleaseJarTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,18 +25,18 @@
  * @test
  * @summary Test Multi-Release jar support in schemagen tool
  * @library /test/lib
- * @library /lib/testlibrary
  * @modules jdk.compiler java.xml.ws
  * @build jdk.test.lib.JDKToolFinder jdk.test.lib.JDKToolLauncher
  *        jdk.test.lib.process.OutputAnalyzer
  *        jdk.test.lib.process.ProcessTools
  *        jdk.test.lib.Utils
- *        CompilerUtils MultiReleaseJarTest
+ *        jdk.test.lib.compiler.CompilerUtils MultiReleaseJarTest
  * @run testng MultiReleaseJarTest
  */
 
 import jdk.test.lib.JDKToolLauncher;
 import jdk.test.lib.Utils;
+import jdk.test.lib.compiler.CompilerUtils;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
 import org.testng.annotations.BeforeClass;
@@ -114,4 +114,5 @@
                     "--add-modules", "java.xml.ws"));
         }
     }
-}
\ No newline at end of file
+}
+
--- a/jdk/test/tools/wsgen/MultiReleaseJarTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/jdk/test/tools/wsgen/MultiReleaseJarTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,18 +25,18 @@
  * @test
  * @summary Test Multi-Release jar support in wsgen tool
  * @library /test/lib
- * @library /lib/testlibrary
  * @modules jdk.compiler java.xml.ws
  * @build jdk.test.lib.JDKToolFinder jdk.test.lib.JDKToolLauncher
  *        jdk.test.lib.process.OutputAnalyzer
  *        jdk.test.lib.process.ProcessTools
  *        jdk.test.lib.Utils
- *        CompilerUtils MultiReleaseJarTest
+ *        jdk.test.lib.compiler.CompilerUtils MultiReleaseJarTest
  * @run testng MultiReleaseJarTest
  */
 
 import jdk.test.lib.JDKToolLauncher;
 import jdk.test.lib.Utils;
+import jdk.test.lib.compiler.CompilerUtils;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
 import org.testng.annotations.BeforeClass;
@@ -117,4 +117,5 @@
                     "--add-modules", "java.xml.ws"));
         }
     }
-}
\ No newline at end of file
+}
+
--- a/langtools/.hgtags	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/.hgtags	Wed Jul 05 23:37:13 2017 +0200
@@ -396,9 +396,11 @@
 4f348bd05341581df84ff1510d5b3a9b5b488367 jdk-9+151
 5b6f12de6f9167a582fa2c6ac54e69c591b09e68 jdk-9+152
 03f48cd283f5dd6b7153fd7e0cf2df8582b14391 jdk-9+153
+b670e95106f5327a29e2e2c4f18ee48a8d36e481 jdk-10+0
 6a9dd3d893b0a493a3e5d8d392815b5ee76a02d9 jdk-9+154
 dfcfdb2db85f1bb434209f56ca557ea6f9830aa8 jdk-9+155
 6f91e41163bc09e9b3ec72e8d1185f39296ee5d4 jdk-9+156
+ce999290d1c31bf8b28c51b1890268cc73cd4722 jdk-10+1
 162b521af7bb097019a8afaa44e1f8069ce274eb jdk-9+157
 4eb737a8d439f49a197e8000de26c6580cb4d57b jdk-9+158
 39449d2a6398fee779630f041c55c0466f5fd2c0 jdk-9+159
@@ -409,8 +411,18 @@
 c7f3df19667b093538c6eecb73dcb3fb531706b4 jdk-9+164
 98108b7d4cb6078773e2d27ad8471dc25d4d6124 jdk-9+165
 2a8b403a623320479705aad04ed8d78396661eb7 jdk-9+166
+657b68876fe39c6104c8a6350b746203edfd9da2 jdk-10+2
+e5689e13301ec65d8fba8ae7e581b1cb3bf5a391 jdk-10+3
+ef9180164e0847387519152d08bbcbcf9da0606d jdk-10+4
+6190dbeac954c5efd64201a8ab04d393330ff192 jdk-10+5
+2b33ceb2cee7ba561657ed69fcb14d6cf0543f3d jdk-10+6
 f260f1a2acf616509a4ee5a29bc7f2acca3853e3 jdk-9+167
 bc21e5ba6bf1538551093f57fa0f1a6571be05cc jdk-9+168
 0e522ff8b9f52a9d4929af9a6aa84110f4dcd81d jdk-9+169
 18355c879c69a33167f1862896738a7b9a4da729 jdk-9+170
+85581ae8a97f20fd2f817a71eb3cd7b04e492722 jdk-10+7
+6d9a33d72d0647f3981c9d9c636a6f1290689895 jdk-10+8
+a8e4d2286ebaf93c0f69fb4bbd399253f396db00 jdk-10+9
 aae59039c1f5701ae933c5eed30e75d6e3afaeee jdk-9+171
+48a87c3414d374e3a26ddb270318c9af10de4b32 jdk-10+10
+03669efa77f51852f5301623cad4a2e1bb4fb9f6 jdk-9+172
--- a/langtools/.jcheck/conf	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/.jcheck/conf	Wed Jul 05 23:37:13 2017 +0200
@@ -1,1 +1,1 @@
-project=jdk9
+project=jdk10
--- a/langtools/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
         }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1978,10 +1978,9 @@
                     }
                 } else if (checkNameClash((ClassSymbol)site.tsym, s1, s2) &&
                         !checkCommonOverriderIn(s1, s2, site)) {
-                    log.error(pos,
-                            "name.clash.same.erasure.no.override",
-                            s1, s1.location(),
-                            s2, s2.location());
+                    log.error(pos, Errors.NameClashSameErasureNoOverride(
+                            s1.name, types.memberType(site, s1).asMethodType().getParameterTypes(), s1.location(),
+                            s2.name, types.memberType(site, s2).asMethodType().getParameterTypes(), s2.location()));
                     return s2;
                 }
             }
@@ -2465,14 +2464,23 @@
                 if (!types.isSubSignature(sym.type, types.memberType(site, m2), allowStrictMethodClashCheck) &&
                         types.hasSameArgs(m2.erasure(types), m1.erasure(types))) {
                     sym.flags_field |= CLASH;
-                    String key = m1 == sym ?
-                            "name.clash.same.erasure.no.override" :
-                            "name.clash.same.erasure.no.override.1";
-                    log.error(pos,
-                            key,
-                            sym, sym.location(),
-                            m2, m2.location(),
-                            m1, m1.location());
+                    if (m1 == sym) {
+                        log.error(pos, Errors.NameClashSameErasureNoOverride(
+                            m1.name, types.memberType(site, m1).asMethodType().getParameterTypes(), m1.location(),
+                            m2.name, types.memberType(site, m2).asMethodType().getParameterTypes(), m2.location()));
+                    } else {
+                        ClassType ct = (ClassType)site;
+                        String kind = ct.isInterface() ? "interface" : "class";
+                        log.error(pos, Errors.NameClashSameErasureNoOverride1(
+                            kind,
+                            ct.tsym.name,
+                            m1.name,
+                            types.memberType(site, m1).asMethodType().getParameterTypes(),
+                            m1.location(),
+                            m2.name,
+                            types.memberType(site, m2).asMethodType().getParameterTypes(),
+                            m2.location()));
+                    }
                     return;
                 }
             }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstFold.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/ConstFold.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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.
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Env.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Env.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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();
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1755,23 +1755,6 @@
                 }
 
                 /**
-                 * Compute closure of a give node, by recursively walking
-                 * through all its dependencies (of given kinds)
-                 */
-                protected Set<Node> closure() {
-                    boolean progress = true;
-                    Set<Node> closure = new HashSet<>();
-                    closure.add(this);
-                    while (progress) {
-                        progress = false;
-                        for (Node n1 : new HashSet<>(closure)) {
-                            progress = closure.addAll(n1.deps);
-                        }
-                    }
-                    return closure;
-                }
-
-                /**
                  * Is this node a leaf? This means either the node has no dependencies,
                  * or it just has self-dependencies.
                  */
@@ -1906,10 +1889,13 @@
                     Type i = n_i.data.first();
                     for (Node n_j : nodes) {
                         Type j = n_j.data.first();
-                        UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
-                        if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
-                            //update i's bound dependencies
-                            n_i.addDependency(n_j);
+                        // don't compare a variable to itself
+                        if (i != j) {
+                            UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i);
+                            if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) {
+                                //update i's bound dependencies
+                                n_i.addDependency(n_j);
+                            }
                         }
                     }
                 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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);
     }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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());
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java	Wed Jul 05 23:37:13 2017 +0200
@@ -223,20 +223,11 @@
         private static final String XMODULES_PREFIX = "-Xmodule:";
 
     int depth = -1;
-    private void dprintln(String msg) {
-        for (int i = 0; i < depth; i++)
-            System.err.print("  ");
-        System.err.println(msg);
-    }
 
     public void addExtraAddModules(String... extras) {
         extraAddMods.addAll(Arrays.asList(extras));
     }
 
-    public void addExtraLimitModules(String... extras) {
-        extraLimitMods.addAll(Arrays.asList(extras));
-    }
-
     boolean inInitModules;
     public void initModules(List<JCCompilationUnit> trees) {
         Assert.check(!inInitModules);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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;
             }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, 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
@@ -30,6 +30,7 @@
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Attribute.TypeCompound;
 import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind;
@@ -377,21 +378,26 @@
                         MethodSymbol target = bridgeSpan == null ? null : bridgeSpan.snd;
                         if (target == null || !target.overrides(meth, origin, types, true, false)) {
                             // Bridge for other symbol pair was added
-                            log.error(pos, "name.clash.same.erasure.no.override",
-                                    other, other.location(origin.type, types),
-                                    meth, meth.location(origin.type, types));
+                            log.error(pos, Errors.NameClashSameErasureNoOverride(
+                                    other.name, types.memberType(origin.type, other).asMethodType().getParameterTypes(),
+                                    other.location(origin.type, types),
+                                    meth.name, types.memberType(origin.type, meth).asMethodType().getParameterTypes(),
+                                    meth.location(origin.type, types)));
                         }
                     }
                 }
             } else if (!bridge.overrides(meth, origin, types, true)) {
                 // Accidental binary override without source override.
+                // Don't diagnose the problem if it would already
+                // have been reported in the superclass
                 if (bridge.owner == origin ||
-                    types.asSuper(bridge.owner.type, meth.owner) == null)
-                    // Don't diagnose the problem if it would already
-                    // have been reported in the superclass
-                    log.error(pos, "name.clash.same.erasure.no.override",
-                              bridge, bridge.location(origin.type, types),
-                              meth,  meth.location(origin.type, types));
+                    types.asSuper(bridge.owner.type, meth.owner) == null) {
+                    log.error(pos, Errors.NameClashSameErasureNoOverride(
+                            bridge.name, types.memberType(origin.type, bridge).asMethodType().getParameterTypes(),
+                            bridge.location(origin.type, types),
+                            meth.name, types.memberType(origin.type, meth).asMethodType().getParameterTypes(),
+                            meth.location(origin.type, types)));
+                }
             }
         }
     }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java	Wed Jul 05 23:37:13 2017 +0200
@@ -25,6 +25,7 @@
 
 package com.sun.tools.javac.jvm;
 
+import com.sun.tools.javac.tree.TreeInfo.PosKind;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.List;
@@ -1399,12 +1400,16 @@
                                   catchallpc, 0);
                     startseg = env.info.gaps.next().intValue();
                 }
-                code.statBegin(TreeInfo.finalizerPos(env.tree));
+                code.statBegin(TreeInfo.finalizerPos(env.tree, PosKind.FIRST_STAT_POS));
                 code.markStatBegin();
 
                 Item excVar = makeTemp(syms.throwableType);
                 excVar.store();
                 genFinalizer(env);
+                code.resolvePending();
+                code.statBegin(TreeInfo.finalizerPos(env.tree, PosKind.END_POS));
+                code.markStatBegin();
+
                 excVar.load();
                 registerCatch(body.pos(), startseg,
                               env.info.gaps.next().intValue(),
@@ -1418,7 +1423,7 @@
                     code.resolve(env.info.cont);
 
                     // Mark statement line number
-                    code.statBegin(TreeInfo.finalizerPos(env.tree));
+                    code.statBegin(TreeInfo.finalizerPos(env.tree, PosKind.FIRST_STAT_POS));
                     code.markStatBegin();
 
                     // Save return address.
@@ -1577,14 +1582,18 @@
     }
 
     public void visitBreak(JCBreak tree) {
+        int tmpPos = code.pendingStatPos;
         Env<GenContext> targetEnv = unwind(tree.target, env);
+        code.pendingStatPos = tmpPos;
         Assert.check(code.state.stacksize == 0);
         targetEnv.info.addExit(code.branch(goto_));
         endFinalizerGaps(env, targetEnv);
     }
 
     public void visitContinue(JCContinue tree) {
+        int tmpPos = code.pendingStatPos;
         Env<GenContext> targetEnv = unwind(tree.target, env);
+        code.pendingStatPos = tmpPos;
         Assert.check(code.state.stacksize == 0);
         targetEnv.info.addCont(code.branch(goto_));
         endFinalizerGaps(env, targetEnv);
@@ -1885,7 +1894,7 @@
             case NULLCHK:
                 result = od.load();
                 code.emitop0(dup);
-                genNullCheck(tree.pos());
+                genNullCheck(tree);
                 break;
             default:
                 Assert.error();
@@ -1894,12 +1903,13 @@
     }
 
     /** Generate a null check from the object value at stack top. */
-    private void genNullCheck(DiagnosticPosition pos) {
+    private void genNullCheck(JCTree tree) {
+        code.statBegin(tree.pos);
         if (allowBetterNullChecks) {
-            callMethod(pos, syms.objectsType, names.requireNonNull,
+            callMethod(tree.pos(), syms.objectsType, names.requireNonNull,
                     List.of(syms.objectType), true);
         } else {
-            callMethod(pos, syms.objectType, names.getClass,
+            callMethod(tree.pos(), syms.objectType, names.getClass,
                     List.nil(), false);
         }
         code.emitop0(pop);
@@ -2078,7 +2088,7 @@
                 base.drop();
             } else {
                 base.load();
-                genNullCheck(tree.selected.pos());
+                genNullCheck(tree.selected);
             }
             result = items.
                 makeImmediateItem(sym.type, ((VarSymbol) sym).getConstValue());
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Profile.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Target.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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);
     }
-
 }
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/platform/JDKPlatformProvider.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,7 +66,7 @@
 
     @Override
     public PlatformDescription getPlatform(String platformName, String options) {
-        return new PlatformDescriptionImpl(platformName);
+        return new PlatformDescriptionImpl(platformName.equals("10") ? "9" : platformName);
     }
 
     private static final String[] symbolFileLocation = { "lib", "ct.sym" };
@@ -93,6 +93,10 @@
             } catch (IOException | ProviderNotFoundException ex) {
             }
         }
+
+        if (SUPPORTED_JAVA_PLATFORM_VERSIONS.contains("9")) {
+            SUPPORTED_JAVA_PLATFORM_VERSIONS.add("10");
+        }
     }
 
     private static String targetNumericVersion(Target target) {
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/PrintingProcessor.java	Wed Jul 05 23:37:13 2017 +0200
@@ -55,7 +55,7 @@
  * deletion without notice.</b>
  */
 @SupportedAnnotationTypes("*")
-@SupportedSourceVersion(SourceVersion.RELEASE_9)
+@SupportedSourceVersion(SourceVersion.RELEASE_10)
 public class PrintingProcessor extends AbstractProcessor {
     PrintWriter writer;
 
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Jul 05 23:37:13 2017 +0200
@@ -743,15 +743,15 @@
 compiler.err.name.clash.same.erasure=\
     name clash: {0} and {1} have the same erasure
 
-# 0: symbol, 1: symbol, 2: symbol, 3: symbol, 4: unused, 5: unused
+# 0: name, 1: list of type, 2: symbol, 3: name, 4: list of type, 5: symbol
 compiler.err.name.clash.same.erasure.no.override=\
-    name clash: {0} in {1} and {2} in {3} have the same erasure, yet neither overrides the other
-
-# 0: symbol, 1: symbol, 2: symbol, 3: symbol, 4: symbol, 5: symbol
+    name clash: {0}({1}) in {2} and {3}({4}) in {5} have the same erasure, yet neither overrides the other
+
+# 0: string, 1: name, 2: name, 3: list of type, 4: symbol, 5: name, 6: list of type, 7: symbol
 compiler.err.name.clash.same.erasure.no.override.1=\
-    name clash: {0} in {1} overrides a method whose erasure is the same as another method, yet neither overrides the other\n\
-    first method:  {2} in {3}\n\
-    second method: {4} in {5}
+    name clash: {0} {1} has two methods with the same erasure, yet neither overrides the other\n\
+    first method:  {2}({3}) in {4}\n\
+    second method: {5}({6}) in {7}
 
 # 0: symbol, 1: symbol, 2: symbol, 3: symbol
 compiler.err.name.clash.same.erasure.no.hide=\
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/javac.properties	Wed Jul 05 23:37:13 2017 +0200
@@ -376,6 +376,12 @@
     not a file: {0}
 javac.err.cannot.access.runtime.env=\
     cannot access runtime environment
+javac.err.two.class.loaders.1=\
+    javac is split between multiple class loaders: check your configuration
+javac.err.two.class.loaders.2=\
+    javac is split between multiple class loaders:\n\
+    one class comes from file: {0}\n\
+    while javac comes from {1}
 javac.err.bad.value.for.option=\
     bad value for {0} option: ''{1}''
 javac.err.no.value.for.option=\
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,6 +46,8 @@
 
 import javax.tools.JavaFileObject;
 
+import java.util.function.ToIntFunction;
+
 import static com.sun.tools.javac.tree.JCTree.JCOperatorExpression.OperandPos.LEFT;
 import static com.sun.tools.javac.tree.JCTree.JCOperatorExpression.OperandPos.RIGHT;
 
@@ -580,13 +582,29 @@
         };
     }
 
+    public enum PosKind {
+        START_POS(TreeInfo::getStartPos),
+        FIRST_STAT_POS(TreeInfo::firstStatPos),
+        END_POS(TreeInfo::endPos);
+
+        final ToIntFunction<JCTree> posFunc;
+
+        PosKind(ToIntFunction<JCTree> posFunc) {
+            this.posFunc = posFunc;
+        }
+
+        int toPos(JCTree tree) {
+            return posFunc.applyAsInt(tree);
+        }
+    }
+
     /** The position of the finalizer of given try/synchronized statement.
      */
-    public static int finalizerPos(JCTree tree) {
+    public static int finalizerPos(JCTree tree, PosKind posKind) {
         if (tree.hasTag(TRY)) {
             JCTry t = (JCTry) tree;
             Assert.checkNonNull(t.finalizer);
-            return firstStatPos(t.finalizer);
+            return posKind.toPos(t.finalizer);
         } else if (tree.hasTag(SYNCHRONIZED)) {
             return endPos(((JCSynchronized) tree).body);
         } else {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -79,7 +79,7 @@
      * @param path       Path to the file which is getting generated.
      * @param indexbuilder Unicode based Index from {@link IndexBuilder}
      */
-    protected AbstractIndexWriter(ConfigurationImpl configuration,
+    protected AbstractIndexWriter(HtmlConfiguration configuration,
                                   DocPath path,
                                   IndexBuilder indexbuilder) {
         super(configuration, path);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractMemberWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,7 +66,7 @@
  */
 public abstract class AbstractMemberWriter {
 
-    protected final ConfigurationImpl configuration;
+    protected final HtmlConfiguration configuration;
     protected final Utils utils;
     protected final SubWriterHolderWriter writer;
     protected final Contents contents;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -67,7 +67,7 @@
      * @param configuration  The current configuration
      * @param filename Name of the module index file to be generated.
      */
-    public AbstractModuleIndexWriter(ConfigurationImpl configuration,
+    public AbstractModuleIndexWriter(HtmlConfiguration configuration,
                                       DocPath filename) {
         super(configuration, filename);
         modules = configuration.modulePackages;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -64,7 +64,7 @@
      * @param configuration  The current configuration
      * @param filename Name of the package index file to be generated.
      */
-    public AbstractPackageIndexWriter(ConfigurationImpl configuration,
+    public AbstractPackageIndexWriter(HtmlConfiguration configuration,
                                       DocPath filename) {
         super(configuration, filename);
         packages = configuration.packages;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,7 +66,7 @@
      * @param filename   File to be generated.
      * @param classtree  Tree built by {@link ClassTree}.
      */
-    protected AbstractTreeWriter(ConfigurationImpl configuration,
+    protected AbstractTreeWriter(HtmlConfiguration configuration,
                                  DocPath filename, ClassTree classtree) {
         super(configuration, filename);
         this.classtree = classtree;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,7 +74,7 @@
      * @param filename       Path to the file which is getting generated.
      * @param indexbuilder   Unicode based Index from {@link IndexBuilder}
      */
-    public AllClassesFrameWriter(ConfigurationImpl configuration,
+    public AllClassesFrameWriter(HtmlConfiguration configuration,
                                  DocPath filename, IndexBuilder indexbuilder) {
         super(configuration, filename);
         this.indexbuilder = indexbuilder;
@@ -88,7 +88,7 @@
      * @param indexBuilder IndexBuilder object for all classes index.
      * @throws DocFileIOException
      */
-    public static void generate(ConfigurationImpl configuration,
+    public static void generate(HtmlConfiguration configuration,
             IndexBuilder indexBuilder) throws DocFileIOException {
         if (configuration.frames) {
             generate(configuration, indexBuilder, DocPaths.ALLCLASSES_FRAME, true);
@@ -98,8 +98,8 @@
         }
     }
 
-    private static void generate(ConfigurationImpl configuration, IndexBuilder indexBuilder,
-        DocPath fileName, boolean wantFrames) throws DocFileIOException {
+    private static void generate(HtmlConfiguration configuration, IndexBuilder indexBuilder,
+                                 DocPath fileName, boolean wantFrames) throws DocFileIOException {
         AllClassesFrameWriter allclassgen = new AllClassesFrameWriter(configuration,
                 fileName, indexBuilder);
         allclassgen.buildAllClassesFile(wantFrames);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -79,7 +79,7 @@
      * @param prevType the previous class that was documented.
      * @param nextType the next class being documented.
      */
-    public AnnotationTypeWriterImpl(ConfigurationImpl configuration,
+    public AnnotationTypeWriterImpl(HtmlConfiguration configuration,
             TypeElement annotationType, TypeMirror prevType, TypeMirror nextType) {
         super(configuration, DocPath.forClass(configuration.utils, annotationType));
         this.annotationType = annotationType;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -112,7 +112,7 @@
      *
      * @param filename the file to be generated.
      */
-    public ClassUseWriter(ConfigurationImpl configuration,
+    public ClassUseWriter(HtmlConfiguration configuration,
                           ClassUseMapper mapper, DocPath filename,
                           TypeElement typeElement) {
         super(configuration, filename);
@@ -177,7 +177,7 @@
      * @param classtree the class tree hierarchy
      * @throws DocFileIOException if there is an error while generating the documentation
      */
-    public static void generate(ConfigurationImpl configuration, ClassTree classtree) throws DocFileIOException  {
+    public static void generate(HtmlConfiguration configuration, ClassTree classtree) throws DocFileIOException  {
         ClassUseMapper mapper = new ClassUseMapper(configuration, classtree);
         for (TypeElement aClass : configuration.getIncludedTypeElements()) {
             // If -nodeprecated option is set and the containing package is marked
@@ -220,7 +220,7 @@
      *
      * @throws DocFileIOException if there is a problem while generating the documentation
      */
-    public static void generate(ConfigurationImpl configuration, ClassUseMapper mapper,
+    public static void generate(HtmlConfiguration configuration, ClassUseMapper mapper,
                                 TypeElement typeElement) throws DocFileIOException {
         ClassUseWriter clsgen;
         DocPath path = DocPath.forPackage(configuration.utils, typeElement)
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -89,8 +89,8 @@
      * @param nextClass the next class being documented.
      * @param classTree the class tree for the given class.
      */
-    public ClassWriterImpl(ConfigurationImpl configuration, TypeElement typeElement,
-            TypeElement prevClass, TypeElement nextClass, ClassTree classTree) {
+    public ClassWriterImpl(HtmlConfiguration configuration, TypeElement typeElement,
+                           TypeElement prevClass, TypeElement nextClass, ClassTree classTree) {
         super(configuration, DocPath.forClass(configuration.utils, typeElement));
         this.typeElement = typeElement;
         configuration.currentTypeElement = typeElement;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,790 +0,0 @@
-/*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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 jdk.javadoc.internal.doclets.formats.html;
-
-import java.net.*;
-import java.util.*;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-
-import com.sun.source.util.DocTreePath;
-import com.sun.tools.doclint.DocLint;
-
-import jdk.javadoc.doclet.Doclet;
-import jdk.javadoc.doclet.DocletEnvironment;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
-import jdk.javadoc.internal.doclets.formats.html.markup.HtmlVersion;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
-import jdk.javadoc.internal.doclets.toolkit.Content;
-import jdk.javadoc.internal.doclets.toolkit.Messages;
-import jdk.javadoc.internal.doclets.toolkit.Resources;
-import jdk.javadoc.internal.doclets.toolkit.WriterFactory;
-import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
-import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
-import jdk.javadoc.internal.doclets.toolkit.util.Utils;
-
-import static javax.tools.Diagnostic.Kind.*;
-
-/**
- * Configure the output based on the command line options.
- * <p>
- * Also determine the length of the command line option. For example,
- * for a option "-header" there will be a string argument associated, then the
- * the length of option "-header" is two. But for option "-nohelp" no argument
- * is needed so it's length is 1.
- * </p>
- * <p>
- * Also do the error checking on the options used. For example it is illegal to
- * use "-helpfile" option when already "-nohelp" option is used.
- * </p>
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- *
- * @author Robert Field.
- * @author Atul Dambalkar.
- * @author Jamie Ho
- * @author Bhavesh Patel (Modified)
- */
-public class ConfigurationImpl extends Configuration {
-
-    /**
-     * The build date.  Note: For now, we will use
-     * a version number instead of a date.
-     */
-    public static final String BUILD_DATE = System.getProperty("java.version");
-
-    /**
-     * Argument for command line option "-header".
-     */
-    public String header = "";
-
-    /**
-     * Argument for command line option "-packagesheader".
-     */
-    public String packagesheader = "";
-
-    /**
-     * Argument for command line option "-footer".
-     */
-    public String footer = "";
-
-    /**
-     * Argument for command line option "-doctitle".
-     */
-    public String doctitle = "";
-
-    /**
-     * Argument for command line option "-windowtitle".
-     */
-    public String windowtitle = "";
-
-    /**
-     * Argument for command line option "-top".
-     */
-    public String top = "";
-
-    /**
-     * Argument for command line option "-bottom".
-     */
-    public String bottom = "";
-
-    /**
-     * Argument for command line option "-helpfile".
-     */
-    public String helpfile = "";
-
-    /**
-     * Argument for command line option "-stylesheetfile".
-     */
-    public String stylesheetfile = "";
-
-    /**
-     * Argument for command line option "-Xdocrootparent".
-     */
-    public String docrootparent = "";
-
-    /**
-     * True if command line option "-nohelp" is used. Default value is false.
-     */
-    public boolean nohelp = false;
-
-    /**
-     * True if command line option "-splitindex" is used. Default value is
-     * false.
-     */
-    public boolean splitindex = false;
-
-    /**
-     * False if command line option "-noindex" is used. Default value is true.
-     */
-    public boolean createindex = true;
-
-    /**
-     * True if command line option "-use" is used. Default value is false.
-     */
-    public boolean classuse = false;
-
-    /**
-     * False if command line option "-notree" is used. Default value is true.
-     */
-    public boolean createtree = true;
-
-    /**
-     * True if command line option "-nodeprecated" is used. Default value is
-     * false.
-     */
-    public boolean nodeprecatedlist = false;
-
-    /**
-     * True if command line option "-nonavbar" is used. Default value is false.
-     */
-    public boolean nonavbar = false;
-
-    /**
-     * True if command line option "-nooverview" is used. Default value is
-     * false
-     */
-    private boolean nooverview = false;
-
-    /**
-     * The overview path specified with "-overview" flag.
-     */
-    public String overviewpath = null;
-
-    /**
-     * This is true if option "-overview" is used or option "-overview" is not
-     * used and number of packages is more than one.
-     */
-    public boolean createoverview = false;
-
-    /**
-     * Specifies whether or not frames should be generated.
-     * Defaults to true; can be set by --frames; can be set to false by --no-frames; last one wins.
-     */
-    public boolean frames = true;
-
-    /**
-     * This is the HTML version of the generated pages. HTML 4.01 is the default output version.
-     */
-    public HtmlVersion htmlVersion = HtmlVersion.HTML4;
-
-    /**
-     * Collected set of doclint options
-     */
-    public Map<Doclet.Option, String> doclintOpts = new LinkedHashMap<>();
-
-    public final Resources resources;
-
-    /**
-     * First file to appear in the right-hand frame in the generated
-     * documentation.
-     */
-    public DocPath topFile = DocPath.empty;
-
-    /**
-     * The TypeElement for the class file getting generated.
-     */
-    public TypeElement currentTypeElement = null;  // Set this TypeElement in the ClassWriter.
-
-    protected List<SearchIndexItem> memberSearchIndex = new ArrayList<>();
-
-    protected List<SearchIndexItem> moduleSearchIndex = new ArrayList<>();
-
-    protected List<SearchIndexItem> packageSearchIndex = new ArrayList<>();
-
-    protected List<SearchIndexItem> tagSearchIndex = new ArrayList<>();
-
-    protected List<SearchIndexItem> typeSearchIndex = new ArrayList<>();
-
-    protected Map<Character,List<SearchIndexItem>> tagSearchIndexMap = new HashMap<>();
-
-    protected Set<Character> tagSearchIndexKeys;
-
-    protected Contents contents;
-
-    protected Messages messages;
-
-    /**
-     * Constructor. Initializes resource for the
-     * {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}.
-     */
-    public ConfigurationImpl(Doclet doclet) {
-        super(doclet);
-        resources = new Resources(this,
-                Configuration.sharedResourceBundleName,
-                "jdk.javadoc.internal.doclets.formats.html.resources.standard");
-
-        messages = new Messages(this);
-        contents = new Contents(this);
-    }
-
-    private final String versionRBName = "jdk.javadoc.internal.tool.resources.version";
-    private ResourceBundle versionRB;
-
-    /**
-     * Return the build date for the doclet.
-     * @return the build date
-     */
-    @Override
-    public String getDocletSpecificBuildDate() {
-        if (versionRB == null) {
-            try {
-                versionRB = ResourceBundle.getBundle(versionRBName, getLocale());
-            } catch (MissingResourceException e) {
-                return BUILD_DATE;
-            }
-        }
-
-        try {
-            return versionRB.getString("release");
-        } catch (MissingResourceException e) {
-            return BUILD_DATE;
-        }
-    }
-
-    @Override
-    public Resources getResources() {
-        return resources;
-    }
-
-    @Override
-    public Messages getMessages() {
-        return messages;
-    }
-
-    protected boolean validateOptions() {
-        // check shared options
-        if (!generalValidOptions()) {
-            return false;
-        }
-        // check if helpfile exists
-        if (!helpfile.isEmpty()) {
-            DocFile help = DocFile.createFileForInput(this, helpfile);
-            if (!help.exists()) {
-                reporter.print(ERROR, getText("doclet.File_not_found", helpfile));
-                return false;
-            }
-        }
-
-        // In a more object-oriented world, this would be done by methods on the Option objects.
-        // Note that -windowtitle silently removes any and all HTML elements, and so does not need
-        // to be handled here.
-        utils.checkJavaScriptInOption("-header", header);
-        utils.checkJavaScriptInOption("-footer", footer);
-        utils.checkJavaScriptInOption("-top", top);
-        utils.checkJavaScriptInOption("-bottom", bottom);
-        utils.checkJavaScriptInOption("-doctitle", doctitle);
-        utils.checkJavaScriptInOption("-packagesheader", packagesheader);
-
-        return true;
-    }
-
-
-    @Override
-    public boolean finishOptionSettings() {
-        if (!validateOptions()) {
-            return false;
-        }
-        if (!getSpecifiedTypeElements().isEmpty()) {
-            Map<String, PackageElement> map = new HashMap<>();
-            PackageElement pkg;
-            for (TypeElement aClass : getIncludedTypeElements()) {
-                pkg = utils.containingPackage(aClass);
-                if (!map.containsKey(utils.getPackageName(pkg))) {
-                    map.put(utils.getPackageName(pkg), pkg);
-                }
-            }
-        }
-        setCreateOverview();
-        setTopFile(docEnv);
-        workArounds.initDocLint(doclintOpts.values(), tagletManager.getCustomTagNames(),
-                Utils.toLowerCase(htmlVersion.name()));
-        return true;
-    }
-
-    /**
-     * Return true if the generated output is HTML5.
-     */
-    public boolean isOutputHtml5() {
-        return htmlVersion == HtmlVersion.HTML5;
-    }
-
-    /**
-     * Return true if the tag is allowed for this specific version of HTML.
-     */
-    public boolean allowTag(HtmlTag htmlTag) {
-        return htmlTag.allowTag(this.htmlVersion);
-    }
-
-    /**
-     * Decide the page which will appear first in the right-hand frame. It will
-     * be "overview-summary.html" if "-overview" option is used or no
-     * "-overview" but the number of packages is more than one. It will be
-     * "package-summary.html" of the respective package if there is only one
-     * package to document. It will be a class page(first in the sorted order),
-     * if only classes are provided on the command line.
-     *
-     * @param docEnv the doclet environment
-     */
-    protected void setTopFile(DocletEnvironment docEnv) {
-        if (!checkForDeprecation(docEnv)) {
-            return;
-        }
-        if (createoverview) {
-            topFile = DocPaths.overviewSummary(frames);
-        } else {
-            if (showModules) {
-                topFile = DocPath.empty.resolve(DocPaths.moduleSummary(modules.first()));
-            } else if (packages.size() == 1 && packages.first().isUnnamed()) {
-                List<TypeElement> classes = new ArrayList<>(getIncludedTypeElements());
-                if (!classes.isEmpty()) {
-                    TypeElement te = getValidClass(classes);
-                    topFile = DocPath.forClass(utils, te);
-                }
-            } else if (!packages.isEmpty()) {
-                topFile = DocPath.forPackage(packages.first()).resolve(DocPaths.PACKAGE_SUMMARY);
-            }
-        }
-    }
-
-    protected TypeElement getValidClass(List<TypeElement> classes) {
-        if (!nodeprecated) {
-            return classes.get(0);
-        }
-        for (TypeElement te : classes) {
-            if (!utils.isDeprecated(te)) {
-                return te;
-            }
-        }
-        return null;
-    }
-
-    protected boolean checkForDeprecation(DocletEnvironment docEnv) {
-        for (TypeElement te : getIncludedTypeElements()) {
-            if (isGeneratedDoc(te)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * Generate "overview.html" page if option "-overview" is used or number of
-     * packages is more than one. Sets {@link #createoverview} field to true.
-     */
-    protected void setCreateOverview() {
-        if ((overviewpath != null || packages.size() > 1) && !nooverview) {
-            createoverview = true;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public WriterFactory getWriterFactory() {
-        return new WriterFactoryImpl(this);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public Locale getLocale() {
-        if (locale == null)
-            return Locale.getDefault();
-        return locale;
-    }
-
-    /**
-     * Return the path of the overview file or null if it does not exist.
-     *
-     * @return the path of the overview file or null if it does not exist.
-     */
-    @Override
-    public JavaFileObject getOverviewPath() {
-        if (overviewpath != null && getFileManager() instanceof StandardJavaFileManager) {
-            StandardJavaFileManager fm = (StandardJavaFileManager) getFileManager();
-            return fm.getJavaFileObjects(overviewpath).iterator().next();
-        }
-        return null;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public JavaFileManager getFileManager() {
-        return docEnv.getJavaFileManager();
-    }
-
-    @Override
-    public boolean showMessage(DocTreePath path, String key) {
-        return (path == null || workArounds.haveDocLint());
-    }
-
-    @Override
-    public boolean showMessage(Element e, String key) {
-        return (e == null || workArounds.haveDocLint());
-    }
-
-    @Override
-    public String getText(String key) {
-        return resources.getText(key);
-    }
-
-    @Override
-    public String getText(String key, String... args) {
-        return resources.getText(key, (Object[]) args);
-    }
-
-   /**
-     * {@inheritdoc}
-     */
-    @Override
-    public Content getContent(String key) {
-        return contents.getContent(key);
-    }
-
-    /**
-     * Get the configuration string as a content.
-     *
-     * @param key the key to look for in the configuration file
-     * @param o   string or content argument added to configuration text
-     * @return a content tree for the text
-     */
-    @Override
-    public Content getContent(String key, Object o) {
-        return contents.getContent(key, o);
-    }
-
-    /**
-     * Get the configuration string as a content.
-     *
-     * @param key the key to look for in the configuration file
-     * @param o1 resource argument
-     * @param o2 resource argument
-     * @return a content tree for the text
-     */
-    @Override
-    public Content getContent(String key, Object o1, Object o2) {
-        return contents.getContent(key, o1, o2);
-    }
-
-    /**
-     * Get the configuration string as a content.
-     *
-     * @param key the key to look for in the configuration file
-     * @param o0  string or content argument added to configuration text
-     * @param o1  string or content argument added to configuration text
-     * @param o2  string or content argument added to configuration text
-     * @return a content tree for the text
-     */
-    @Override
-    public Content getContent(String key, Object o0, Object o1, Object o2) {
-        return contents.getContent(key, o0, o1, o2);
-    }
-
-    protected void buildSearchTagIndex() {
-        for (SearchIndexItem sii : tagSearchIndex) {
-            String tagLabel = sii.getLabel();
-            Character unicode = (tagLabel.length() == 0)
-                    ? '*'
-                    : Character.toUpperCase(tagLabel.charAt(0));
-            List<SearchIndexItem> list = tagSearchIndexMap.get(unicode);
-            if (list == null) {
-                list = new ArrayList<>();
-                tagSearchIndexMap.put(unicode, list);
-            }
-            list.add(sii);
-        }
-        tagSearchIndexKeys = tagSearchIndexMap.keySet();
-    }
-
-    @Override
-    public Set<Doclet.Option> getSupportedOptions() {
-        Resources resources = getResources();
-        Doclet.Option[] options = {
-            new Option(resources, "-bottom", 1) {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    bottom = args.get(0);
-                    return true;
-                }
-            },
-            new Option(resources, "-charset", 1) {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    charset = args.get(0);
-                    return true;
-                }
-            },
-            new Option(resources, "-doctitle", 1) {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    doctitle = args.get(0);
-                    return true;
-                }
-            },
-            new Option(resources, "-footer", 1) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    footer = args.get(0);
-                    return true;
-                }
-            },
-            new Option(resources, "-header", 1) {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    header = args.get(0);
-                    return true;
-                }
-            },
-            new Option(resources, "-helpfile", 1) {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    if (nohelp == true) {
-                        reporter.print(ERROR, getText("doclet.Option_conflict",
-                                "-helpfile", "-nohelp"));
-                        return false;
-                    }
-                    if (!helpfile.isEmpty()) {
-                        reporter.print(ERROR, getText("doclet.Option_reuse",
-                                "-helpfile"));
-                        return false;
-                    }
-                    helpfile = args.get(0);
-                    return true;
-                }
-            },
-            new Option(resources, "-html4") {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    htmlVersion = HtmlVersion.HTML4;
-                    return true;
-                }
-            },
-            new Option(resources, "-html5") {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    htmlVersion = HtmlVersion.HTML5;
-                    return true;
-                }
-            },
-            new Option(resources, "-nohelp") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    nohelp = true;
-                    if (!helpfile.isEmpty()) {
-                        reporter.print(ERROR, getText("doclet.Option_conflict",
-                                "-nohelp", "-helpfile"));
-                        return false;
-                    }
-                    return true;
-                }
-            },
-            new Option(resources, "-nodeprecatedlist") {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    nodeprecatedlist = true;
-                    return true;
-                }
-            },
-            new Option(resources, "-noindex") {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    createindex = false;
-                    if (splitindex == true) {
-                        reporter.print(ERROR, getText("doclet.Option_conflict",
-                                "-noindex", "-splitindex"));
-                        return false;
-                    }
-                    return true;
-                }
-            },
-            new Option(resources, "-nonavbar") {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    nonavbar = true;
-                    return true;
-                }
-            },
-            new Hidden(resources, "-nooverview") {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    nooverview = true;
-                    if (overviewpath != null) {
-                        reporter.print(ERROR, getText("doclet.Option_conflict",
-                                "-nooverview", "-overview"));
-                        return false;
-                    }
-                    return true;
-                }
-            },
-            new Option(resources, "-notree") {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    createtree = false;
-                    return true;
-                }
-            },
-            new Option(resources, "-overview", 1) {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    overviewpath = args.get(0);
-                    if (nooverview == true) {
-                        reporter.print(ERROR, getText("doclet.Option_conflict",
-                                "-overview", "-nooverview"));
-                        return false;
-                    }
-                    return true;
-                }
-            },
-            new Option(resources, "--frames") {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    frames = true;
-                    return true;
-                }
-            },
-            new Option(resources, "--no-frames") {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    frames = false;
-                    return true;
-                }
-            },
-            new Hidden(resources, "-packagesheader", 1) {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    packagesheader = args.get(0);
-                    return true;
-                }
-            },
-            new Option(resources, "-splitindex") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    splitindex = true;
-                    if (createindex == false) {
-                        reporter.print(ERROR, getText("doclet.Option_conflict",
-                                "-splitindex", "-noindex"));
-                        return false;
-                    }
-                    return true;
-                }
-            },
-            new Option(resources, "-stylesheetfile", 1) {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    stylesheetfile = args.get(0);
-                    return true;
-                }
-            },
-            new Option(resources, "-top", 1) {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    top = args.get(0);
-                    return true;
-                }
-            },
-            new Option(resources, "-use") {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    classuse = true;
-                    return true;
-                }
-            },
-            new Option(resources, "-windowtitle", 1) {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    windowtitle = args.get(0).replaceAll("\\<.*?>", "");
-                    return true;
-                }
-            },
-            new XOption(resources, "-Xdoclint") {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    doclintOpts.put(this, DocLint.XMSGS_OPTION);
-                    return true;
-                }
-            },
-            new XOption(resources, "-Xdocrootparent", 1) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    docrootparent = args.get(0);
-                    try {
-                        URL ignored = new URL(docrootparent);
-                    } catch (MalformedURLException e) {
-                        reporter.print(ERROR, getText("doclet.MalformedURL", docrootparent));
-                        return false;
-                    }
-                    return true;
-                }
-            },
-            new XOption(resources, "doclet.usage.xdoclint-extended", "-Xdoclint:", 0) {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    String dopt = opt.replace("-Xdoclint:", DocLint.XMSGS_CUSTOM_PREFIX);
-                    doclintOpts.put(this, dopt);
-                    if (dopt.contains("/")) {
-                        reporter.print(ERROR, getText("doclet.Option_doclint_no_qualifiers"));
-                        return false;
-                    }
-                    if (!DocLint.isValidOption(dopt)) {
-                        reporter.print(ERROR, getText("doclet.Option_doclint_invalid_arg"));
-                        return false;
-                    }
-                    return true;
-                }
-            },
-            new XOption(resources, "doclet.usage.xdoclint-package", "-Xdoclint/package:", 0) {
-                @Override
-                public boolean process(String opt,  List<String> args) {
-                    String dopt = opt.replace("-Xdoclint/package:", DocLint.XCHECK_PACKAGE);
-                    doclintOpts.put(this, dopt);
-                    if (!DocLint.isValidOption(dopt)) {
-                        reporter.print(ERROR, getText("doclet.Option_doclint_package_invalid_arg"));
-                        return false;
-                    }
-                    return true;
-                }
-            }
-        };
-        Set<Doclet.Option> oset = new TreeSet<>();
-        oset.addAll(Arrays.asList(options));
-        oset.addAll(super.getSupportedOptions());
-        return oset;
-    }
-}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,7 @@
     /**
      * The configuration used in this run of the standard doclet.
      */
-    ConfigurationImpl configuration;
+    HtmlConfiguration configuration;
 
     /**
      * The current class being documented.
@@ -87,7 +87,7 @@
      * @param configuration the configuration used in this run
      *        of the standard doclet.
      */
-    public ConstantsSummaryWriterImpl(ConfigurationImpl configuration) {
+    public ConstantsSummaryWriterImpl(HtmlConfiguration configuration) {
         super(configuration, DocPaths.CONSTANT_VALUES);
         this.configuration = configuration;
         constantsTableSummary = configuration.getText("doclet.Constants_Table_Summary",
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/Contents.java	Wed Jul 05 23:37:13 2017 +0200
@@ -162,7 +162,7 @@
      * @param configuration the configuration in which to find the
      * resources used to look up resource keys, and other details.
      */
-    Contents(ConfigurationImpl configuration) {
+    Contents(HtmlConfiguration configuration) {
         this.resources = configuration.getResources();
 
         allClassesLabel = getNonBreakContent("doclet.All_Classes");
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -204,7 +204,7 @@
 
     private EnumMap<DeprElementKind, AbstractMemberWriter> writerMap;
 
-    private ConfigurationImpl configuration;
+    private HtmlConfiguration configuration;
 
     /**
      * Constructor.
@@ -213,7 +213,7 @@
      * @param filename the file to be generated
      */
 
-    public DeprecatedListWriter(ConfigurationImpl configuration, DocPath filename) {
+    public DeprecatedListWriter(HtmlConfiguration configuration, DocPath filename) {
         super(configuration, filename);
         this.configuration = configuration;
         NestedClassWriterImpl classW = new NestedClassWriterImpl(this);
@@ -260,7 +260,7 @@
      * @param configuration the current configuration of the doclet.
      * @throws DocFileIOException if there is a problem writing the deprecated list
      */
-    public static void generate(ConfigurationImpl configuration) throws DocFileIOException {
+    public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
         DocPath filename = DocPaths.DEPRECATED_LIST;
         DeprecatedListWriter depr = new DeprecatedListWriter(configuration, filename);
         depr.generateDeprecatedListFile(
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -67,7 +67,7 @@
      * @param configuration for this run
      * @param filename File to be generated.
      */
-    public FrameOutputWriter(ConfigurationImpl configuration, DocPath filename) {
+    public FrameOutputWriter(HtmlConfiguration configuration, DocPath filename) {
         super(configuration, filename);
         noOfPackages = configuration.packages.size();
     }
@@ -80,7 +80,7 @@
      * @param configuration the configuration for this doclet
      * @throws DocFileIOException if there is a problem generating the frame file
      */
-    public static void generate(ConfigurationImpl configuration) throws DocFileIOException {
+    public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
         FrameOutputWriter framegen = new FrameOutputWriter(configuration, DocPaths.INDEX);
         framegen.generateFrameFile();
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -55,7 +55,7 @@
      * Constructor to construct HelpWriter object.
      * @param filename File to be generated.
      */
-    public HelpWriter(ConfigurationImpl configuration,
+    public HelpWriter(HtmlConfiguration configuration,
                       DocPath filename) {
         super(configuration, filename);
     }
@@ -68,7 +68,7 @@
      *
      * @throws DocFileIOException if there is a problem while generating the documentation
      */
-    public static void generate(ConfigurationImpl configuration) throws DocFileIOException {
+    public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
         DocPath filename = DocPaths.HELP_DOC;
         HelpWriter helpgen = new HelpWriter(configuration, filename);
         helpgen.generateHelpFile();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,790 @@
+/*
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 jdk.javadoc.internal.doclets.formats.html;
+
+import java.net.*;
+import java.util.*;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+import com.sun.source.util.DocTreePath;
+import com.sun.tools.doclint.DocLint;
+
+import jdk.javadoc.doclet.Doclet;
+import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
+import jdk.javadoc.internal.doclets.formats.html.markup.HtmlVersion;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
+import jdk.javadoc.internal.doclets.toolkit.Content;
+import jdk.javadoc.internal.doclets.toolkit.Messages;
+import jdk.javadoc.internal.doclets.toolkit.Resources;
+import jdk.javadoc.internal.doclets.toolkit.WriterFactory;
+import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
+import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+
+import static javax.tools.Diagnostic.Kind.*;
+
+/**
+ * Configure the output based on the command line options.
+ * <p>
+ * Also determine the length of the command line option. For example,
+ * for a option "-header" there will be a string argument associated, then the
+ * the length of option "-header" is two. But for option "-nohelp" no argument
+ * is needed so it's length is 1.
+ * </p>
+ * <p>
+ * Also do the error checking on the options used. For example it is illegal to
+ * use "-helpfile" option when already "-nohelp" option is used.
+ * </p>
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ *
+ * @author Robert Field.
+ * @author Atul Dambalkar.
+ * @author Jamie Ho
+ * @author Bhavesh Patel (Modified)
+ */
+public class HtmlConfiguration extends BaseConfiguration {
+
+    /**
+     * The build date.  Note: For now, we will use
+     * a version number instead of a date.
+     */
+    public static final String BUILD_DATE = System.getProperty("java.version");
+
+    /**
+     * Argument for command line option "-header".
+     */
+    public String header = "";
+
+    /**
+     * Argument for command line option "-packagesheader".
+     */
+    public String packagesheader = "";
+
+    /**
+     * Argument for command line option "-footer".
+     */
+    public String footer = "";
+
+    /**
+     * Argument for command line option "-doctitle".
+     */
+    public String doctitle = "";
+
+    /**
+     * Argument for command line option "-windowtitle".
+     */
+    public String windowtitle = "";
+
+    /**
+     * Argument for command line option "-top".
+     */
+    public String top = "";
+
+    /**
+     * Argument for command line option "-bottom".
+     */
+    public String bottom = "";
+
+    /**
+     * Argument for command line option "-helpfile".
+     */
+    public String helpfile = "";
+
+    /**
+     * Argument for command line option "-stylesheetfile".
+     */
+    public String stylesheetfile = "";
+
+    /**
+     * Argument for command line option "-Xdocrootparent".
+     */
+    public String docrootparent = "";
+
+    /**
+     * True if command line option "-nohelp" is used. Default value is false.
+     */
+    public boolean nohelp = false;
+
+    /**
+     * True if command line option "-splitindex" is used. Default value is
+     * false.
+     */
+    public boolean splitindex = false;
+
+    /**
+     * False if command line option "-noindex" is used. Default value is true.
+     */
+    public boolean createindex = true;
+
+    /**
+     * True if command line option "-use" is used. Default value is false.
+     */
+    public boolean classuse = false;
+
+    /**
+     * False if command line option "-notree" is used. Default value is true.
+     */
+    public boolean createtree = true;
+
+    /**
+     * True if command line option "-nodeprecated" is used. Default value is
+     * false.
+     */
+    public boolean nodeprecatedlist = false;
+
+    /**
+     * True if command line option "-nonavbar" is used. Default value is false.
+     */
+    public boolean nonavbar = false;
+
+    /**
+     * True if command line option "-nooverview" is used. Default value is
+     * false
+     */
+    private boolean nooverview = false;
+
+    /**
+     * The overview path specified with "-overview" flag.
+     */
+    public String overviewpath = null;
+
+    /**
+     * This is true if option "-overview" is used or option "-overview" is not
+     * used and number of packages is more than one.
+     */
+    public boolean createoverview = false;
+
+    /**
+     * Specifies whether or not frames should be generated.
+     * Defaults to true; can be set by --frames; can be set to false by --no-frames; last one wins.
+     */
+    public boolean frames = true;
+
+    /**
+     * This is the HTML version of the generated pages. HTML 4.01 is the default output version.
+     */
+    public HtmlVersion htmlVersion = HtmlVersion.HTML4;
+
+    /**
+     * Collected set of doclint options
+     */
+    public Map<Doclet.Option, String> doclintOpts = new LinkedHashMap<>();
+
+    public final Resources resources;
+
+    /**
+     * First file to appear in the right-hand frame in the generated
+     * documentation.
+     */
+    public DocPath topFile = DocPath.empty;
+
+    /**
+     * The TypeElement for the class file getting generated.
+     */
+    public TypeElement currentTypeElement = null;  // Set this TypeElement in the ClassWriter.
+
+    protected List<SearchIndexItem> memberSearchIndex = new ArrayList<>();
+
+    protected List<SearchIndexItem> moduleSearchIndex = new ArrayList<>();
+
+    protected List<SearchIndexItem> packageSearchIndex = new ArrayList<>();
+
+    protected List<SearchIndexItem> tagSearchIndex = new ArrayList<>();
+
+    protected List<SearchIndexItem> typeSearchIndex = new ArrayList<>();
+
+    protected Map<Character,List<SearchIndexItem>> tagSearchIndexMap = new HashMap<>();
+
+    protected Set<Character> tagSearchIndexKeys;
+
+    protected Contents contents;
+
+    protected Messages messages;
+
+    /**
+     * Constructor. Initializes resource for the
+     * {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}.
+     */
+    public HtmlConfiguration(Doclet doclet) {
+        super(doclet);
+        resources = new Resources(this,
+                BaseConfiguration.sharedResourceBundleName,
+                "jdk.javadoc.internal.doclets.formats.html.resources.standard");
+
+        messages = new Messages(this);
+        contents = new Contents(this);
+    }
+
+    private final String versionRBName = "jdk.javadoc.internal.tool.resources.version";
+    private ResourceBundle versionRB;
+
+    /**
+     * Return the build date for the doclet.
+     * @return the build date
+     */
+    @Override
+    public String getDocletSpecificBuildDate() {
+        if (versionRB == null) {
+            try {
+                versionRB = ResourceBundle.getBundle(versionRBName, getLocale());
+            } catch (MissingResourceException e) {
+                return BUILD_DATE;
+            }
+        }
+
+        try {
+            return versionRB.getString("release");
+        } catch (MissingResourceException e) {
+            return BUILD_DATE;
+        }
+    }
+
+    @Override
+    public Resources getResources() {
+        return resources;
+    }
+
+    @Override
+    public Messages getMessages() {
+        return messages;
+    }
+
+    protected boolean validateOptions() {
+        // check shared options
+        if (!generalValidOptions()) {
+            return false;
+        }
+        // check if helpfile exists
+        if (!helpfile.isEmpty()) {
+            DocFile help = DocFile.createFileForInput(this, helpfile);
+            if (!help.exists()) {
+                reporter.print(ERROR, getText("doclet.File_not_found", helpfile));
+                return false;
+            }
+        }
+
+        // In a more object-oriented world, this would be done by methods on the Option objects.
+        // Note that -windowtitle silently removes any and all HTML elements, and so does not need
+        // to be handled here.
+        utils.checkJavaScriptInOption("-header", header);
+        utils.checkJavaScriptInOption("-footer", footer);
+        utils.checkJavaScriptInOption("-top", top);
+        utils.checkJavaScriptInOption("-bottom", bottom);
+        utils.checkJavaScriptInOption("-doctitle", doctitle);
+        utils.checkJavaScriptInOption("-packagesheader", packagesheader);
+
+        return true;
+    }
+
+
+    @Override
+    public boolean finishOptionSettings() {
+        if (!validateOptions()) {
+            return false;
+        }
+        if (!getSpecifiedTypeElements().isEmpty()) {
+            Map<String, PackageElement> map = new HashMap<>();
+            PackageElement pkg;
+            for (TypeElement aClass : getIncludedTypeElements()) {
+                pkg = utils.containingPackage(aClass);
+                if (!map.containsKey(utils.getPackageName(pkg))) {
+                    map.put(utils.getPackageName(pkg), pkg);
+                }
+            }
+        }
+        setCreateOverview();
+        setTopFile(docEnv);
+        workArounds.initDocLint(doclintOpts.values(), tagletManager.getCustomTagNames(),
+                Utils.toLowerCase(htmlVersion.name()));
+        return true;
+    }
+
+    /**
+     * Return true if the generated output is HTML5.
+     */
+    public boolean isOutputHtml5() {
+        return htmlVersion == HtmlVersion.HTML5;
+    }
+
+    /**
+     * Return true if the tag is allowed for this specific version of HTML.
+     */
+    public boolean allowTag(HtmlTag htmlTag) {
+        return htmlTag.allowTag(this.htmlVersion);
+    }
+
+    /**
+     * Decide the page which will appear first in the right-hand frame. It will
+     * be "overview-summary.html" if "-overview" option is used or no
+     * "-overview" but the number of packages is more than one. It will be
+     * "package-summary.html" of the respective package if there is only one
+     * package to document. It will be a class page(first in the sorted order),
+     * if only classes are provided on the command line.
+     *
+     * @param docEnv the doclet environment
+     */
+    protected void setTopFile(DocletEnvironment docEnv) {
+        if (!checkForDeprecation(docEnv)) {
+            return;
+        }
+        if (createoverview) {
+            topFile = DocPaths.overviewSummary(frames);
+        } else {
+            if (showModules) {
+                topFile = DocPath.empty.resolve(DocPaths.moduleSummary(modules.first()));
+            } else if (packages.size() == 1 && packages.first().isUnnamed()) {
+                List<TypeElement> classes = new ArrayList<>(getIncludedTypeElements());
+                if (!classes.isEmpty()) {
+                    TypeElement te = getValidClass(classes);
+                    topFile = DocPath.forClass(utils, te);
+                }
+            } else if (!packages.isEmpty()) {
+                topFile = DocPath.forPackage(packages.first()).resolve(DocPaths.PACKAGE_SUMMARY);
+            }
+        }
+    }
+
+    protected TypeElement getValidClass(List<TypeElement> classes) {
+        if (!nodeprecated) {
+            return classes.get(0);
+        }
+        for (TypeElement te : classes) {
+            if (!utils.isDeprecated(te)) {
+                return te;
+            }
+        }
+        return null;
+    }
+
+    protected boolean checkForDeprecation(DocletEnvironment docEnv) {
+        for (TypeElement te : getIncludedTypeElements()) {
+            if (isGeneratedDoc(te)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Generate "overview.html" page if option "-overview" is used or number of
+     * packages is more than one. Sets {@link #createoverview} field to true.
+     */
+    protected void setCreateOverview() {
+        if ((overviewpath != null || packages.size() > 1) && !nooverview) {
+            createoverview = true;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public WriterFactory getWriterFactory() {
+        return new WriterFactoryImpl(this);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Locale getLocale() {
+        if (locale == null)
+            return Locale.getDefault();
+        return locale;
+    }
+
+    /**
+     * Return the path of the overview file or null if it does not exist.
+     *
+     * @return the path of the overview file or null if it does not exist.
+     */
+    @Override
+    public JavaFileObject getOverviewPath() {
+        if (overviewpath != null && getFileManager() instanceof StandardJavaFileManager) {
+            StandardJavaFileManager fm = (StandardJavaFileManager) getFileManager();
+            return fm.getJavaFileObjects(overviewpath).iterator().next();
+        }
+        return null;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JavaFileManager getFileManager() {
+        return docEnv.getJavaFileManager();
+    }
+
+    @Override
+    public boolean showMessage(DocTreePath path, String key) {
+        return (path == null || workArounds.haveDocLint());
+    }
+
+    @Override
+    public boolean showMessage(Element e, String key) {
+        return (e == null || workArounds.haveDocLint());
+    }
+
+    @Override
+    public String getText(String key) {
+        return resources.getText(key);
+    }
+
+    @Override
+    public String getText(String key, String... args) {
+        return resources.getText(key, (Object[]) args);
+    }
+
+   /**
+     * {@inheritdoc}
+     */
+    @Override
+    public Content getContent(String key) {
+        return contents.getContent(key);
+    }
+
+    /**
+     * Get the configuration string as a content.
+     *
+     * @param key the key to look for in the configuration file
+     * @param o   string or content argument added to configuration text
+     * @return a content tree for the text
+     */
+    @Override
+    public Content getContent(String key, Object o) {
+        return contents.getContent(key, o);
+    }
+
+    /**
+     * Get the configuration string as a content.
+     *
+     * @param key the key to look for in the configuration file
+     * @param o1 resource argument
+     * @param o2 resource argument
+     * @return a content tree for the text
+     */
+    @Override
+    public Content getContent(String key, Object o1, Object o2) {
+        return contents.getContent(key, o1, o2);
+    }
+
+    /**
+     * Get the configuration string as a content.
+     *
+     * @param key the key to look for in the configuration file
+     * @param o0  string or content argument added to configuration text
+     * @param o1  string or content argument added to configuration text
+     * @param o2  string or content argument added to configuration text
+     * @return a content tree for the text
+     */
+    @Override
+    public Content getContent(String key, Object o0, Object o1, Object o2) {
+        return contents.getContent(key, o0, o1, o2);
+    }
+
+    protected void buildSearchTagIndex() {
+        for (SearchIndexItem sii : tagSearchIndex) {
+            String tagLabel = sii.getLabel();
+            Character unicode = (tagLabel.length() == 0)
+                    ? '*'
+                    : Character.toUpperCase(tagLabel.charAt(0));
+            List<SearchIndexItem> list = tagSearchIndexMap.get(unicode);
+            if (list == null) {
+                list = new ArrayList<>();
+                tagSearchIndexMap.put(unicode, list);
+            }
+            list.add(sii);
+        }
+        tagSearchIndexKeys = tagSearchIndexMap.keySet();
+    }
+
+    @Override
+    public Set<Doclet.Option> getSupportedOptions() {
+        Resources resources = getResources();
+        Doclet.Option[] options = {
+            new Option(resources, "-bottom", 1) {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    bottom = args.get(0);
+                    return true;
+                }
+            },
+            new Option(resources, "-charset", 1) {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    charset = args.get(0);
+                    return true;
+                }
+            },
+            new Option(resources, "-doctitle", 1) {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    doctitle = args.get(0);
+                    return true;
+                }
+            },
+            new Option(resources, "-footer", 1) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    footer = args.get(0);
+                    return true;
+                }
+            },
+            new Option(resources, "-header", 1) {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    header = args.get(0);
+                    return true;
+                }
+            },
+            new Option(resources, "-helpfile", 1) {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    if (nohelp == true) {
+                        reporter.print(ERROR, getText("doclet.Option_conflict",
+                                "-helpfile", "-nohelp"));
+                        return false;
+                    }
+                    if (!helpfile.isEmpty()) {
+                        reporter.print(ERROR, getText("doclet.Option_reuse",
+                                "-helpfile"));
+                        return false;
+                    }
+                    helpfile = args.get(0);
+                    return true;
+                }
+            },
+            new Option(resources, "-html4") {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    htmlVersion = HtmlVersion.HTML4;
+                    return true;
+                }
+            },
+            new Option(resources, "-html5") {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    htmlVersion = HtmlVersion.HTML5;
+                    return true;
+                }
+            },
+            new Option(resources, "-nohelp") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    nohelp = true;
+                    if (!helpfile.isEmpty()) {
+                        reporter.print(ERROR, getText("doclet.Option_conflict",
+                                "-nohelp", "-helpfile"));
+                        return false;
+                    }
+                    return true;
+                }
+            },
+            new Option(resources, "-nodeprecatedlist") {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    nodeprecatedlist = true;
+                    return true;
+                }
+            },
+            new Option(resources, "-noindex") {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    createindex = false;
+                    if (splitindex == true) {
+                        reporter.print(ERROR, getText("doclet.Option_conflict",
+                                "-noindex", "-splitindex"));
+                        return false;
+                    }
+                    return true;
+                }
+            },
+            new Option(resources, "-nonavbar") {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    nonavbar = true;
+                    return true;
+                }
+            },
+            new Hidden(resources, "-nooverview") {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    nooverview = true;
+                    if (overviewpath != null) {
+                        reporter.print(ERROR, getText("doclet.Option_conflict",
+                                "-nooverview", "-overview"));
+                        return false;
+                    }
+                    return true;
+                }
+            },
+            new Option(resources, "-notree") {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    createtree = false;
+                    return true;
+                }
+            },
+            new Option(resources, "-overview", 1) {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    overviewpath = args.get(0);
+                    if (nooverview == true) {
+                        reporter.print(ERROR, getText("doclet.Option_conflict",
+                                "-overview", "-nooverview"));
+                        return false;
+                    }
+                    return true;
+                }
+            },
+            new Option(resources, "--frames") {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    frames = true;
+                    return true;
+                }
+            },
+            new Option(resources, "--no-frames") {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    frames = false;
+                    return true;
+                }
+            },
+            new Hidden(resources, "-packagesheader", 1) {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    packagesheader = args.get(0);
+                    return true;
+                }
+            },
+            new Option(resources, "-splitindex") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    splitindex = true;
+                    if (createindex == false) {
+                        reporter.print(ERROR, getText("doclet.Option_conflict",
+                                "-splitindex", "-noindex"));
+                        return false;
+                    }
+                    return true;
+                }
+            },
+            new Option(resources, "-stylesheetfile", 1) {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    stylesheetfile = args.get(0);
+                    return true;
+                }
+            },
+            new Option(resources, "-top", 1) {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    top = args.get(0);
+                    return true;
+                }
+            },
+            new Option(resources, "-use") {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    classuse = true;
+                    return true;
+                }
+            },
+            new Option(resources, "-windowtitle", 1) {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    windowtitle = args.get(0).replaceAll("\\<.*?>", "");
+                    return true;
+                }
+            },
+            new XOption(resources, "-Xdoclint") {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    doclintOpts.put(this, DocLint.XMSGS_OPTION);
+                    return true;
+                }
+            },
+            new XOption(resources, "-Xdocrootparent", 1) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    docrootparent = args.get(0);
+                    try {
+                        URL ignored = new URL(docrootparent);
+                    } catch (MalformedURLException e) {
+                        reporter.print(ERROR, getText("doclet.MalformedURL", docrootparent));
+                        return false;
+                    }
+                    return true;
+                }
+            },
+            new XOption(resources, "doclet.usage.xdoclint-extended", "-Xdoclint:", 0) {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    String dopt = opt.replace("-Xdoclint:", DocLint.XMSGS_CUSTOM_PREFIX);
+                    doclintOpts.put(this, dopt);
+                    if (dopt.contains("/")) {
+                        reporter.print(ERROR, getText("doclet.Option_doclint_no_qualifiers"));
+                        return false;
+                    }
+                    if (!DocLint.isValidOption(dopt)) {
+                        reporter.print(ERROR, getText("doclet.Option_doclint_invalid_arg"));
+                        return false;
+                    }
+                    return true;
+                }
+            },
+            new XOption(resources, "doclet.usage.xdoclint-package", "-Xdoclint/package:", 0) {
+                @Override
+                public boolean process(String opt,  List<String> args) {
+                    String dopt = opt.replace("-Xdoclint/package:", DocLint.XCHECK_PACKAGE);
+                    doclintOpts.put(this, dopt);
+                    if (!DocLint.isValidOption(dopt)) {
+                        reporter.print(ERROR, getText("doclet.Option_doclint_package_invalid_arg"));
+                        return false;
+                    }
+                    return true;
+                }
+            }
+        };
+        Set<Doclet.Option> oset = new TreeSet<>();
+        oset.addAll(Arrays.asList(options));
+        oset.addAll(super.getSupportedOptions());
+        return oset;
+    }
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java	Wed Jul 05 23:37:13 2017 +0200
@@ -31,7 +31,6 @@
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 
-import jdk.javadoc.doclet.Doclet.Option;
 import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.doclet.Reporter;
 import jdk.javadoc.internal.doclets.toolkit.AbstractDoclet;
@@ -61,7 +60,7 @@
 public class HtmlDoclet extends AbstractDoclet {
 
     public HtmlDoclet() {
-        configuration = new ConfigurationImpl(this);
+        configuration = new HtmlConfiguration(this);
     }
 
     @Override // defined by Doclet
@@ -72,7 +71,7 @@
     /**
      * The global configuration information for this run.
      */
-    private final ConfigurationImpl configuration;
+    private final HtmlConfiguration configuration;
 
     private Messages messages;
 
@@ -95,7 +94,7 @@
      * @return the configuration
      */
     @Override // defined by AbstractDoclet
-    public ConfigurationImpl getConfiguration() {
+    public HtmlConfiguration getConfiguration() {
         return configuration;
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -77,7 +77,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
 import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter;
@@ -94,9 +94,7 @@
 import jdk.javadoc.internal.doclets.toolkit.util.ImplementedMethods;
 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
 
-import static com.sun.source.doctree.AttributeTree.ValueKind.*;
 import static com.sun.source.doctree.DocTree.Kind.*;
-import static jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocWriter.CONTENT_TYPE;
 import static jdk.javadoc.internal.doclets.toolkit.util.CommentHelper.SPACER;
 
 
@@ -141,7 +139,7 @@
     /**
      * The global configuration information for this run.
      */
-    public final ConfigurationImpl configuration;
+    public final HtmlConfiguration configuration;
 
     protected final Utils utils;
 
@@ -180,7 +178,7 @@
      *
      * @param path File to be generated.
      */
-    public HtmlDocletWriter(ConfigurationImpl configuration, DocPath path) {
+    public HtmlDocletWriter(HtmlConfiguration configuration, DocPath path) {
         super(configuration, path);
         this.configuration = configuration;
         this.contents = configuration.contents;
@@ -2601,7 +2599,7 @@
      * @return the configuration for this doclet.
      */
     @Override
-    public Configuration configuration() {
+    public BaseConfiguration configuration() {
         return configuration;
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,8 +39,6 @@
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 
-import static jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocWriter.CONTENT_TYPE;
-
 /**
  * Writes an index.html file that tries to redirect to an alternate page.
  * The redirect uses JavaSCript, if enabled, falling back on
@@ -50,7 +48,7 @@
  */
 public class IndexRedirectWriter extends HtmlDocletWriter {
 
-    public static void generate(ConfigurationImpl configuration)
+    public static void generate(HtmlConfiguration configuration)
             throws DocFileIOException {
         IndexRedirectWriter indexRedirect;
         DocPath filename = DocPaths.INDEX;
@@ -58,7 +56,7 @@
             indexRedirect.generateIndexFile();
     }
 
-    IndexRedirectWriter(ConfigurationImpl configuration, DocPath filename) {
+    IndexRedirectWriter(HtmlConfiguration configuration, DocPath filename) {
         super(configuration, filename);
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkFactoryImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,15 +33,13 @@
 import javax.lang.model.type.TypeMirror;
 
 import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
 import jdk.javadoc.internal.doclets.toolkit.util.Utils;
 import jdk.javadoc.internal.doclets.toolkit.util.links.LinkFactory;
 import jdk.javadoc.internal.doclets.toolkit.util.links.LinkInfo;
 
-import static jdk.javadoc.internal.doclets.formats.html.LinkInfoImpl.Kind.MEMBER_TYPE_PARAMS;
-
 /**
  * A factory that returns a link given the information about it.
  *
@@ -73,7 +71,7 @@
      */
     @Override
     protected Content getClassLink(LinkInfo linkInfo) {
-        Configuration configuration = m_writer.configuration;
+        BaseConfiguration configuration = m_writer.configuration;
         Utils utils = configuration.utils;
         LinkInfoImpl classLinkInfo = (LinkInfoImpl) linkInfo;
         boolean noLabel = linkInfo.label == null || linkInfo.label.isEmpty();
@@ -198,7 +196,7 @@
      * @return the tool tip for the appropriate class.
      */
     private String getClassToolTip(TypeElement typeElement, boolean isTypeLink) {
-        Configuration configuration = m_writer.configuration;
+        BaseConfiguration configuration = m_writer.configuration;
         Utils utils = configuration.utils;
         if (isTypeLink) {
             return configuration.getText("doclet.Href_Type_Param_Title",
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkInfoImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/LinkInfoImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -218,7 +218,7 @@
         RECEIVER_TYPE
     }
 
-    public final ConfigurationImpl configuration;
+    public final HtmlConfiguration configuration;
 
     /**
      * The location of the link.
@@ -247,7 +247,7 @@
      * @param context    the context of the link.
      * @param ee   the member to link to.
      */
-    public LinkInfoImpl(ConfigurationImpl configuration, Kind context, ExecutableElement ee) {
+    public LinkInfoImpl(HtmlConfiguration configuration, Kind context, ExecutableElement ee) {
         this.configuration = configuration;
         this.utils = configuration.utils;
         this.executableElement = ee;
@@ -269,7 +269,7 @@
      * @param context    the context of the link.
      * @param typeElement   the class to link to.
      */
-    public LinkInfoImpl(ConfigurationImpl configuration, Kind context, TypeElement typeElement) {
+    public LinkInfoImpl(HtmlConfiguration configuration, Kind context, TypeElement typeElement) {
         this.configuration = configuration;
         this.utils = configuration.utils;
         this.typeElement = typeElement;
@@ -283,7 +283,7 @@
      * @param context    the context of the link.
      * @param type       the class to link to.
      */
-    public LinkInfoImpl(ConfigurationImpl configuration, Kind context, TypeMirror type) {
+    public LinkInfoImpl(HtmlConfiguration configuration, Kind context, TypeMirror type) {
         this.configuration = configuration;
         this.utils = configuration.utils;
         this.type = type;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,6 @@
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.util.ElementFilter;
 
-import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
@@ -75,7 +74,7 @@
      * @param configuration the configuration of the doclet.
      * @param moduleElement moduleElement under consideration.
      */
-    public ModuleFrameWriter(ConfigurationImpl configuration, ModuleElement moduleElement) {
+    public ModuleFrameWriter(HtmlConfiguration configuration, ModuleElement moduleElement) {
         super(configuration, DocPaths.moduleTypeFrame(moduleElement));
         this.mdle = moduleElement;
         if (configuration.getSpecifiedPackageElements().isEmpty()) {
@@ -91,7 +90,7 @@
      * @param moduleElement The package for which "module_name-type-frame.html" is to be generated.
      * @throws DocFileIOException if there is a problem generating the module summary file
      */
-    public static void generate(ConfigurationImpl configuration, ModuleElement moduleElement)
+    public static void generate(HtmlConfiguration configuration, ModuleElement moduleElement)
             throws DocFileIOException {
         ModuleFrameWriter mdlgen = new ModuleFrameWriter(configuration, moduleElement);
         String mdlName = moduleElement.getQualifiedName().toString();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -63,7 +63,7 @@
      * @param configuration the configuration object
      * @param filename Name of the module index file to be generated.
      */
-    public ModuleIndexFrameWriter(ConfigurationImpl configuration,
+    public ModuleIndexFrameWriter(HtmlConfiguration configuration,
                                    DocPath filename) {
         super(configuration, filename);
     }
@@ -73,7 +73,7 @@
      * @throws DocFileIOException
      * @param configuration the configuration object
      */
-    public static void generate(ConfigurationImpl configuration) throws DocFileIOException {
+    public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
         DocPath filename = DocPaths.MODULE_OVERVIEW_FRAME;
         ModuleIndexFrameWriter modulegen = new ModuleIndexFrameWriter(configuration, filename);
         modulegen.buildModuleIndexFile("doclet.Window_Overview", false);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -77,7 +77,7 @@
      * @param configuration the configuration object
      * @param filename the name of the generated file
      */
-    public ModuleIndexWriter(ConfigurationImpl configuration, DocPath filename) {
+    public ModuleIndexWriter(HtmlConfiguration configuration, DocPath filename) {
         super(configuration, filename);
         groupModuleMap = configuration.group.groupModules(configuration.modules);
         groupList = configuration.group.getGroupList();
@@ -89,7 +89,7 @@
      * @param configuration the current configuration of the doclet.
      * @throws DocFileIOException if there is a problem generating the module index page
      */
-    public static void generate(ConfigurationImpl configuration) throws DocFileIOException {
+    public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
         DocPath filename = DocPaths.overviewSummary(configuration.frames);
         ModuleIndexWriter mdlgen = new ModuleIndexWriter(configuration, filename);
         mdlgen.buildModuleIndexFile("doclet.Window_Overview_Summary", true);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -65,7 +65,7 @@
      * @param configuration the configuration object
      * @param filename Name of the package index file to be generated.
      */
-    public ModulePackageIndexFrameWriter(ConfigurationImpl configuration, DocPath filename)  {
+    public ModulePackageIndexFrameWriter(HtmlConfiguration configuration, DocPath filename)  {
         super(configuration, filename);
     }
 
@@ -75,7 +75,7 @@
      * @param configuration the configuration object
      * @param mdle the module being documented
      */
-    public static void generate(ConfigurationImpl configuration, ModuleElement mdle) throws DocFileIOException {
+    public static void generate(HtmlConfiguration configuration, ModuleElement mdle) throws DocFileIOException {
         DocPath filename = DocPaths.moduleFrame(mdle);
         ModulePackageIndexFrameWriter modpackgen = new ModulePackageIndexFrameWriter(configuration, filename);
         modpackgen.buildModulePackagesIndexFile("doclet.Window_Overview", false, mdle);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -181,7 +181,7 @@
      * @param prevModule   Previous module in the sorted array.
      * @param nextModule   Next module in the sorted array.
      */
-    public ModuleWriterImpl(ConfigurationImpl configuration,
+    public ModuleWriterImpl(HtmlConfiguration configuration,
             ModuleElement mdle, ModuleElement prevModule, ModuleElement nextModule) {
         super(configuration, DocPaths.moduleSummary(mdle));
         this.prevModule = prevModule;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,13 +30,12 @@
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 
-import jdk.javadoc.doclet.DocletEnvironment;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
@@ -79,7 +78,7 @@
      * @param configuration the configuration of the doclet.
      * @param packageElement PackageElement under consideration.
      */
-    public PackageFrameWriter(ConfigurationImpl configuration, PackageElement packageElement) {
+    public PackageFrameWriter(HtmlConfiguration configuration, PackageElement packageElement) {
         super(configuration, DocPath.forPackage(packageElement).resolve(DocPaths.PACKAGE_FRAME));
         this.packageElement = packageElement;
         if (configuration.getSpecifiedPackageElements().isEmpty()) {
@@ -96,7 +95,7 @@
      * @param packageElement The package for which "pacakge-frame.html" is to be generated.
      * @throws DocFileIOException if there is a problem generating the package summary page
      */
-    public static void generate(ConfigurationImpl configuration, PackageElement packageElement)
+    public static void generate(HtmlConfiguration configuration, PackageElement packageElement)
             throws DocFileIOException {
         PackageFrameWriter packgen = new PackageFrameWriter(configuration, packageElement);
         String pkgName = configuration.utils.getPackageName(packageElement);
@@ -127,7 +126,7 @@
      * @param contentTree the content tree to which the listing will be added
      */
     protected void addClassListing(HtmlTree contentTree) {
-        Configuration config = configuration;
+        BaseConfiguration config = configuration;
         if (utils.isSpecified(packageElement)) {
             addClassKindListing(utils.getInterfaces(packageElement),
                 contents.interfaces, contentTree);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -60,7 +60,7 @@
      *
      * @param filename Name of the package index file to be generated.
      */
-    public PackageIndexFrameWriter(ConfigurationImpl configuration, DocPath filename) {
+    public PackageIndexFrameWriter(HtmlConfiguration configuration, DocPath filename) {
         super(configuration, filename);
     }
 
@@ -68,7 +68,7 @@
      * Generate the package index file named "overview-frame.html".
      * @throws DocFileIOException
      */
-    public static void generate(ConfigurationImpl configuration) throws DocFileIOException {
+    public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
         DocPath filename = DocPaths.OVERVIEW_FRAME;
         PackageIndexFrameWriter packgen = new PackageIndexFrameWriter(configuration, filename);
         packgen.buildPackageIndexFile("doclet.Window_Overview", false);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -83,7 +83,7 @@
      * @param filename the path of the page to be generated
      * @see Group
      */
-    public PackageIndexWriter(ConfigurationImpl configuration, DocPath filename) {
+    public PackageIndexWriter(HtmlConfiguration configuration, DocPath filename) {
         super(configuration, filename);
         groupPackageMap = configuration.group.groupPackages(packages);
         groupList = configuration.group.getGroupList();
@@ -95,7 +95,7 @@
      * @param configuration the current configuration of the doclet.
      * @throws DocFileIOException if there is a problem generating the package index page
      */
-    public static void generate(ConfigurationImpl configuration) throws DocFileIOException {
+    public static void generate(HtmlConfiguration configuration) throws DocFileIOException {
         DocPath filename = DocPaths.overviewSummary(configuration.frames);
         PackageIndexWriter packgen = new PackageIndexWriter(configuration, filename);
         packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -75,7 +75,7 @@
      * @param prev the previous package
      * @param next the next package
      */
-    public PackageTreeWriter(ConfigurationImpl configuration,
+    public PackageTreeWriter(HtmlConfiguration configuration,
                              DocPath path,
                              PackageElement packageElement,
                              PackageElement prev, PackageElement next) {
@@ -98,7 +98,7 @@
      * deprecated classe or interfaces.
      * @throws DocFileIOException if there is a problem generating the package tree page
      */
-    public static void generate(ConfigurationImpl configuration,
+    public static void generate(HtmlConfiguration configuration,
                                 PackageElement pkg, PackageElement prev,
                                 PackageElement next, boolean noDeprecated)
             throws DocFileIOException {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,7 +64,7 @@
      *
      * @param filename the file to be generated.
      */
-    public PackageUseWriter(ConfigurationImpl configuration,
+    public PackageUseWriter(HtmlConfiguration configuration,
                             ClassUseMapper mapper, DocPath filename,
                             PackageElement pkgElement) {
         super(configuration, DocPath.forPackage(pkgElement).resolve(filename));
@@ -99,7 +99,7 @@
      * @param pkgElement    the package being documented.
      * @throws DocFileIOException if there is a problem generating the package use page
      */
-    public static void generate(ConfigurationImpl configuration,
+    public static void generate(HtmlConfiguration configuration,
                                 ClassUseMapper mapper, PackageElement pkgElement)
             throws DocFileIOException {
         DocPath filename = DocPaths.PACKAGE_USE;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -99,7 +99,7 @@
      * @param prev          Previous package in the sorted array.
      * @param next            Next package in the sorted array.
      */
-    public PackageWriterImpl(ConfigurationImpl configuration,
+    public PackageWriterImpl(HtmlConfiguration configuration,
             PackageElement packageElement, PackageElement prev, PackageElement next) {
         super(configuration, DocPath
                 .forPackage(packageElement)
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,8 +36,6 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter;
-import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter.SerialFieldWriter;
-import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter.SerialMethodWriter;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
 import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
 
@@ -64,7 +62,7 @@
     /**
      * @param configuration the configuration data for the doclet
      */
-    public SerializedFormWriterImpl(ConfigurationImpl configuration) {
+    public SerializedFormWriterImpl(HtmlConfiguration configuration) {
         super(configuration, DocPaths.SERIALIZED_FORM);
         visibleClasses = configuration.getIncludedTypeElements();
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,7 +64,7 @@
      * @param filename     Name of the index file to be generated.
      * @param indexbuilder Unicode based Index from {@link IndexBuilder}
      */
-    public SingleIndexWriter(ConfigurationImpl configuration,
+    public SingleIndexWriter(HtmlConfiguration configuration,
                              DocPath filename,
                              IndexBuilder indexbuilder) {
         super(configuration, filename, indexbuilder);
@@ -77,7 +77,7 @@
      * @param indexbuilder IndexBuilder built by {@link IndexBuilder}
      * @throws DocFileIOException if there is a problem generating the index
      */
-    public static void generate(ConfigurationImpl configuration,
+    public static void generate(HtmlConfiguration configuration,
                                 IndexBuilder indexbuilder) throws DocFileIOException {
         DocPath filename = DocPaths.INDEX_ALL;
         SingleIndexWriter indexgen = new SingleIndexWriter(configuration,
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,7 +74,7 @@
      */
     private static final String NEW_LINE = DocletConstants.NL;
 
-    private final ConfigurationImpl configuration;
+    private final HtmlConfiguration configuration;
     private final Messages messages;
     private final Utils utils;
 
@@ -88,8 +88,8 @@
      */
     private DocPath relativePath = DocPath.empty;
 
-    private SourceToHTMLConverter(ConfigurationImpl configuration, DocletEnvironment rd,
-            DocPath outputdir) {
+    private SourceToHTMLConverter(HtmlConfiguration configuration, DocletEnvironment rd,
+                                  DocPath outputdir) {
         this.configuration  = configuration;
         this.messages = configuration.getMessages();
         this.utils = configuration.utils;
@@ -106,8 +106,8 @@
      * @throws DocFileIOException if there is a problem generating an output file
      * @throws SimpleDocletException if there is a problem reading a source file
      */
-    public static void convertRoot(ConfigurationImpl configuration, DocletEnvironment docEnv,
-            DocPath outputdir) throws DocFileIOException, SimpleDocletException {
+    public static void convertRoot(HtmlConfiguration configuration, DocletEnvironment docEnv,
+                                   DocPath outputdir) throws DocFileIOException, SimpleDocletException {
         new SourceToHTMLConverter(configuration, docEnv, outputdir).generate();
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -82,7 +82,7 @@
      * @param prev  the previous character that was indexed
      * @param next  the next character to be indexed
      */
-    public SplitIndexWriter(ConfigurationImpl configuration,
+    public SplitIndexWriter(HtmlConfiguration configuration,
                             DocPath path,
                             IndexBuilder indexbuilder,
                             Collection<Character> elements,
@@ -101,7 +101,7 @@
      * @param indexbuilder IndexBuilder built by {@link IndexBuilder}
      * @throws DocFileIOException if there is a problem generating the index files
      */
-    public static void generate(ConfigurationImpl configuration,
+    public static void generate(HtmlConfiguration configuration,
                                 IndexBuilder indexbuilder) throws DocFileIOException {
         DocPath path = DocPaths.INDEX_FILES;
         Set<Character> keys = new TreeSet<>(indexbuilder.getIndexMap().keySet());
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SubWriterHolderWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -66,7 +66,7 @@
      */
     protected HtmlTree mainTree = HtmlTree.MAIN();
 
-    public SubWriterHolderWriter(ConfigurationImpl configuration, DocPath filename) {
+    public SubWriterHolderWriter(HtmlConfiguration configuration, DocPath filename) {
         super(configuration, filename);
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,7 +42,7 @@
 import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
 import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
 import jdk.javadoc.internal.doclets.formats.html.markup.StringContent;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.builders.SerializedFormBuilder;
 import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter;
@@ -68,7 +68,7 @@
 public class TagletWriterImpl extends TagletWriter {
 
     private final HtmlDocletWriter htmlWriter;
-    private final ConfigurationImpl configuration;
+    private final HtmlConfiguration configuration;
     private final Utils utils;
 
     public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) {
@@ -438,7 +438,7 @@
     /**
      * {@inheritDoc}
      */
-    public Configuration configuration() {
+    public BaseConfiguration configuration() {
         return configuration;
     }
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -74,7 +74,7 @@
      * @param filename String filename
      * @param classtree the tree being built.
      */
-    public TreeWriter(ConfigurationImpl configuration, DocPath filename, ClassTree classtree) {
+    public TreeWriter(HtmlConfiguration configuration, DocPath filename, ClassTree classtree) {
         super(configuration, filename, classtree);
         packages = configuration.packages;
         classesOnly = packages.isEmpty();
@@ -88,7 +88,7 @@
      * @param classtree the class tree being documented.
      * @throws  DocFileIOException if there is a problem generating the overview tree page
      */
-    public static void generate(ConfigurationImpl configuration,
+    public static void generate(HtmlConfiguration configuration,
                                 ClassTree classtree) throws DocFileIOException {
         DocPath filename = DocPaths.OVERVIEW_TREE;
         TreeWriter treegen = new TreeWriter(configuration, filename, classtree);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/WriterFactoryImpl.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/WriterFactoryImpl.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,8 +45,6 @@
 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
 
-import static jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.Kind.*;
-
 /**
  * The factory that returns HTML writers.
  *
@@ -59,8 +57,8 @@
  */
 public class WriterFactoryImpl implements WriterFactory {
 
-    private final ConfigurationImpl configuration;
-    public WriterFactoryImpl(ConfigurationImpl configuration) {
+    private final HtmlConfiguration configuration;
+    public WriterFactoryImpl(HtmlConfiguration configuration) {
         this.configuration = configuration;
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,9 +31,9 @@
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 
-import jdk.javadoc.internal.doclets.formats.html.ConfigurationImpl;
+import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
 import jdk.javadoc.internal.doclets.formats.html.SectionName;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
@@ -69,7 +69,7 @@
      * @param configuration the configuration for this doclet
      * @param filename String file name.
      */
-    public HtmlDocWriter(Configuration configuration, DocPath filename) {
+    public HtmlDocWriter(BaseConfiguration configuration, DocPath filename) {
         super(configuration, filename);
         this.pathToRoot = filename.parent().invert();
         Messages messages = configuration.getMessages();
@@ -81,7 +81,7 @@
      * Accessor for configuration.
      * @return the configuration for this doclet
      */
-    public abstract Configuration configuration();
+    public abstract BaseConfiguration configuration();
 
     public Content getHyperLink(DocPath link, String label) {
         return getHyperLink(link, new StringContent(label), false, "", "", "");
@@ -318,7 +318,7 @@
      * @param body the body content tree to be added to the HTML document
      * @throws DocFileIOException if there is an error writing the frames document
      */
-    public void printFramesDocument(String title, ConfigurationImpl configuration,
+    public void printFramesDocument(String title, HtmlConfiguration configuration,
             HtmlTree body) throws DocFileIOException {
         Content htmlDocType = configuration.isOutputHtml5()
                 ? DocType.HTML5
@@ -347,7 +347,7 @@
      * @param configuration the configuration for this doclet
      * @return an HtmlTree for the lINK tag which provides the stylesheet location
      */
-    public HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) {
+    public HtmlTree getStyleSheetProperties(HtmlConfiguration configuration) {
         String stylesheetfile = configuration.stylesheetfile;
         DocPath stylesheet;
         if (stylesheetfile.isEmpty()) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -29,7 +29,7 @@
 import java.util.*;
 
 import jdk.javadoc.doclet.DocletEnvironment.ModuleMode;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.Resources;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
@@ -62,7 +62,7 @@
     /**
      * The configuration
      */
-    protected Configuration configuration;
+    protected BaseConfiguration configuration;
 
     /**
      * Header for table displaying modules and description.
@@ -120,7 +120,7 @@
      * @param path The directory path to be created for this file
      *             or null if none to be created.
      */
-    public HtmlWriter(Configuration configuration, DocPath path) {
+    public HtmlWriter(BaseConfiguration configuration, DocPath path) {
         docFile = DocFile.createFileForOutput(configuration, path);
         this.configuration = configuration;
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,7 +64,7 @@
     /**
      * The global configuration information for this run.
      */
-    private Configuration configuration;
+    private BaseConfiguration configuration;
 
     protected Messages messages;
 
@@ -181,7 +181,7 @@
      *
      * @return the configuration of the doclet.
      */
-    public abstract Configuration getConfiguration();
+    public abstract BaseConfiguration getConfiguration();
 
     /**
      * Start the generation of files. Call generate methods in the individual
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,1289 @@
+/*
+ * 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
+ * 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 jdk.javadoc.internal.doclets.toolkit;
+
+import java.io.*;
+import java.lang.ref.*;
+import java.util.*;
+
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.util.SimpleElementVisitor9;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+
+import com.sun.source.util.DocTreePath;
+import com.sun.tools.javac.util.DefinedBy;
+import com.sun.tools.javac.util.DefinedBy.Api;
+import jdk.javadoc.doclet.Doclet;
+import jdk.javadoc.doclet.DocletEnvironment;
+import jdk.javadoc.doclet.Reporter;
+import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory;
+import jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager;
+import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
+import jdk.javadoc.internal.doclets.toolkit.util.DocFileFactory;
+import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
+import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
+import jdk.javadoc.internal.doclets.toolkit.util.Extern;
+import jdk.javadoc.internal.doclets.toolkit.util.Group;
+import jdk.javadoc.internal.doclets.toolkit.util.MetaKeywords;
+import jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException;
+import jdk.javadoc.internal.doclets.toolkit.util.TypeElementCatalog;
+import jdk.javadoc.internal.doclets.toolkit.util.Utils;
+import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
+import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.GetterSetter;
+import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.Kind;
+
+import static javax.tools.Diagnostic.Kind.*;
+
+/**
+ * Configure the output based on the options. Doclets should sub-class
+ * BaseConfiguration, to configure and add their own options. This class contains
+ * all user options which are supported by the 1.1 doclet and the standard
+ * doclet.
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ *
+ * @author Robert Field.
+ * @author Atul Dambalkar.
+ * @author Jamie Ho
+ */
+public abstract class BaseConfiguration {
+    /**
+     * The doclet that created this configuration.
+     */
+    public final Doclet doclet;
+
+    /**
+     * The factory for builders.
+     */
+    protected BuilderFactory builderFactory;
+
+    /**
+     * The taglet manager.
+     */
+    public TagletManager tagletManager;
+
+    /**
+     * The path to the builder XML input file.
+     */
+    public String builderXMLPath;
+
+    /**
+     * The default path to the builder XML.
+     */
+    public static final String DEFAULT_BUILDER_XML = "resources/doclet.xml";
+
+    /**
+     * The path to Taglets
+     */
+    public String tagletpath = null;
+
+    /**
+     * This is true if option "-serialwarn" is used. Defualt value is false to
+     * suppress excessive warnings about serial tag.
+     */
+    public boolean serialwarn = false;
+
+    /**
+     * The specified amount of space between tab stops.
+     */
+    public int sourcetab;
+
+    public String tabSpaces;
+
+    /**
+     * True if we should generate browsable sources.
+     */
+    public boolean linksource = false;
+
+    /**
+     * True if command line option "-nosince" is used. Default value is
+     * false.
+     */
+    public boolean nosince = false;
+
+    /**
+     * True if we should recursively copy the doc-file subdirectories
+     */
+    public boolean copydocfilesubdirs = false;
+
+    /**
+     * Maintain backward compatibility with previous javadoc version
+     */
+    public boolean backwardCompatibility = true;
+
+    /**
+     * The META charset tag used for cross-platform viewing.
+     */
+    public String charset = "";
+
+    /**
+     * True if user wants to add member names as meta keywords.
+     * Set to false because meta keywords are ignored in general
+     * by most Internet search engines.
+     */
+    public boolean keywords = false;
+
+    /**
+     * The meta tag keywords instance.
+     */
+    public final MetaKeywords metakeywords;
+
+    /**
+     * The set of doc-file subdirectories to exclude
+     */
+    protected Set<String> excludedDocFileDirs;
+
+    /**
+     * The set of qualifiers to exclude
+     */
+    protected Set<String> excludedQualifiers;
+
+    /**
+     * The doclet environment.
+     */
+    public DocletEnvironment docEnv;
+
+    /**
+     * An utility class for commonly used helpers
+     */
+    public Utils utils;
+
+    /**
+     * All the temporary accessors to javac internals.
+     */
+    public WorkArounds workArounds;
+
+    /**
+     * Destination directory name, in which doclet will generate the entire
+     * documentation. Default is current directory.
+     */
+    public String destDirName = "";
+
+    /**
+     * Destination directory name, in which doclet will copy the doc-files to.
+     */
+    public String docFileDestDirName = "";
+
+    /**
+     * Encoding for this document. Default is default encoding for this
+     * platform.
+     */
+    public String docencoding = null;
+
+    /**
+     * True if user wants to suppress descriptions and tags.
+     */
+    public boolean nocomment = false;
+
+    /**
+     * Encoding for this document. Default is default encoding for this
+     * platform.
+     */
+    public String encoding = null;
+
+    /**
+     * Generate author specific information for all the classes if @author
+     * tag is used in the doc comment and if -author option is used.
+     * <code>showauthor</code> is set to true if -author option is used.
+     * Default is don't show author information.
+     */
+    public boolean showauthor = false;
+
+    /**
+     * Generate documentation for JavaFX getters and setters automatically
+     * by copying it from the appropriate property definition.
+     */
+    public boolean javafx = false;
+
+    /**
+     * Generate version specific information for the all the classes
+     * if @version tag is used in the doc comment and if -version option is
+     * used. <code>showversion</code> is set to true if -version option is
+     * used.Default is don't show version information.
+     */
+    public boolean showversion = false;
+
+    /**
+     * Allow JavaScript in doc comments.
+     */
+    private boolean allowScriptInComments = false;
+
+    /**
+     * Sourcepath from where to read the source files. Default is classpath.
+     *
+     */
+    public String sourcepath = "";
+
+    /**
+     * Generate modules documentation if more than one module is present.
+     */
+    public boolean showModules = false;
+
+    /**
+     * Don't generate deprecated API information at all, if -nodeprecated
+     * option is used. <code>nodepracted</code> is set to true if
+     * -nodeprecated option is used. Default is generate deprected API
+     * information.
+     */
+    public boolean nodeprecated = false;
+
+    /**
+     * The catalog of classes specified on the command-line
+     */
+    public TypeElementCatalog typeElementCatalog;
+
+    /**
+     * True if user wants to suppress time stamp in output.
+     * Default is false.
+     */
+    public boolean notimestamp= false;
+
+    /**
+     * The package grouping instance.
+     */
+    public final Group group = new Group(this);
+
+    /**
+     * The tracker of external package links.
+     */
+    public final Extern extern = new Extern(this);
+
+    public  Reporter reporter;
+
+    public Locale locale;
+
+    /**
+     * Suppress all messages
+     */
+    public boolean quiet = false;
+
+    private String urlForLink;
+
+    private String pkglistUrlForLink;
+
+    private String urlForLinkOffline;
+
+    private String pkglistUrlForLinkOffline;
+
+    public boolean dumpOnError = false;
+
+    private List<GroupContainer> groups;
+
+    private final Map<TypeElement, EnumMap<Kind, Reference<VisibleMemberMap>>> typeElementMemberCache;
+
+    public abstract Messages getMessages();
+    public abstract Resources getResources();
+
+    /**
+     * Return the build date for the doclet.
+     *
+     * @return the build date
+     */
+    public abstract String getDocletSpecificBuildDate();
+
+    /**
+     * This method should be defined in all those doclets (configurations),
+     * which want to derive themselves from this BaseConfiguration. This method
+     * can be used to finish up the options setup.
+     *
+     * @return true if successful and false otherwise
+     */
+
+    public abstract boolean finishOptionSettings();
+
+    public CommentUtils cmtUtils;
+
+    /**
+     * A sorted set of included packages.
+     */
+    public SortedSet<PackageElement> packages = null;
+
+    public OverviewElement overviewElement;
+
+    // The following three fields provide caches for use by all instances of VisibleMemberMap.
+    public final Map<TypeElement, List<Element>> propertiesCache = new HashMap<>();
+    public final Map<Element, Element> classPropertiesMap = new HashMap<>();
+    public final Map<Element, GetterSetter> getterSetterMap = new HashMap<>();
+
+    public DocFileFactory docFileFactory;
+
+    /**
+     * A sorted map, giving the (specified|included|other) packages for each module.
+     */
+    public SortedMap<ModuleElement, Set<PackageElement>> modulePackages;
+
+   /**
+    * The list of known modules, that should be documented.
+    */
+    public SortedSet<ModuleElement> modules;
+
+    protected static final String sharedResourceBundleName =
+            "jdk.javadoc.internal.doclets.toolkit.resources.doclets";
+    /**
+     * Constructs the configurations needed by the doclet.
+     * @param doclet the doclet that created this configuration
+     */
+    public BaseConfiguration(Doclet doclet) {
+        this.doclet = doclet;
+        excludedDocFileDirs = new HashSet<>();
+        excludedQualifiers = new HashSet<>();
+        setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
+        metakeywords = new MetaKeywords(this);
+        groups = new ArrayList<>(0);
+        typeElementMemberCache = new HashMap<>();
+    }
+
+    private boolean initialized = false;
+
+    protected void initConfiguration(DocletEnvironment docEnv) {
+        if (initialized) {
+            throw new IllegalStateException("configuration previously initialized");
+        }
+        initialized = true;
+        this.docEnv = docEnv;
+        overviewElement = new OverviewElement(docEnv);
+        Splitter specifiedSplitter = new Splitter(docEnv, false);
+        specifiedModuleElements = Collections.unmodifiableSet(specifiedSplitter.mset);
+        specifiedPackageElements = Collections.unmodifiableSet(specifiedSplitter.pset);
+        specifiedTypeElements = Collections.unmodifiableSet(specifiedSplitter.tset);
+
+        Splitter includedSplitter = new Splitter(docEnv, true);
+        includedModuleElements = Collections.unmodifiableSet(includedSplitter.mset);
+        includedPackageElements = Collections.unmodifiableSet(includedSplitter.pset);
+        includedTypeElements = Collections.unmodifiableSet(includedSplitter.tset);
+    }
+
+    /**
+     * Return the builder factory for this doclet.
+     *
+     * @return the builder factory for this doclet.
+     */
+    public BuilderFactory getBuilderFactory() {
+        if (builderFactory == null) {
+            builderFactory = new BuilderFactory(this);
+        }
+        return builderFactory;
+    }
+
+    public Reporter getReporter() {
+        return this.reporter;
+    }
+
+    private Set<ModuleElement> specifiedModuleElements;
+    public Set<ModuleElement> getSpecifiedModuleElements() {
+        return specifiedModuleElements;
+    }
+
+    private Set<PackageElement> specifiedPackageElements;
+    public Set<PackageElement> getSpecifiedPackageElements() {
+        return specifiedPackageElements;
+    }
+
+    private Set<TypeElement> specifiedTypeElements;
+    public Set<TypeElement> getSpecifiedTypeElements() {
+        return specifiedTypeElements;
+    }
+
+    private Set<ModuleElement> includedModuleElements;
+    public Set<ModuleElement> getIncludedModuleElements() {
+        return includedModuleElements;
+    }
+
+    private Set<PackageElement> includedPackageElements;
+    public Set<PackageElement> getIncludedPackageElements() {
+        return includedPackageElements;
+    }
+
+    private Set<TypeElement> includedTypeElements;
+    public Set<TypeElement> getIncludedTypeElements() {
+        return includedTypeElements;
+    }
+
+    private void initModules() {
+        // Build the modules structure used by the doclet
+        modules = new TreeSet<>(utils.makeModuleComparator());
+        modules.addAll(getSpecifiedModuleElements());
+
+        modulePackages = new TreeMap<>(utils.makeModuleComparator());
+        for (PackageElement p: packages) {
+            ModuleElement mdle = docEnv.getElementUtils().getModuleOf(p);
+            if (mdle != null && !mdle.isUnnamed()) {
+                Set<PackageElement> s = modulePackages
+                        .computeIfAbsent(mdle, m -> new TreeSet<>(utils.makePackageComparator()));
+                s.add(p);
+            }
+        }
+
+        for (PackageElement p: getIncludedPackageElements()) {
+            ModuleElement mdle = docEnv.getElementUtils().getModuleOf(p);
+            if (mdle != null && !mdle.isUnnamed()) {
+                Set<PackageElement> s = modulePackages
+                        .computeIfAbsent(mdle, m -> new TreeSet<>(utils.makePackageComparator()));
+                s.add(p);
+            }
+        }
+
+        // add entries for modules which may not have exported packages
+        modules.forEach((ModuleElement mdle) -> {
+            modulePackages.computeIfAbsent(mdle, m -> Collections.emptySet());
+        });
+
+        modules.addAll(modulePackages.keySet());
+        showModules = !modules.isEmpty();
+        for (Set<PackageElement> pkgs : modulePackages.values()) {
+            packages.addAll(pkgs);
+        }
+    }
+
+    private void initPackages() {
+        packages = new TreeSet<>(utils.makePackageComparator());
+        // add all the included packages
+        packages.addAll(includedPackageElements);
+    }
+
+    public Set<Doclet.Option> getSupportedOptions() {
+        Resources resources = getResources();
+        Doclet.Option[] options = {
+            new Option(resources, "-author") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    showauthor = true;
+                    return true;
+                }
+            },
+            new Option(resources, "-d", 1) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    destDirName = addTrailingFileSep(args.get(0));
+                    return true;
+                }
+            },
+            new Option(resources, "-docencoding", 1) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    docencoding = args.get(0);
+                    return true;
+                }
+            },
+            new Option(resources, "-docfilessubdirs") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    copydocfilesubdirs = true;
+                    return true;
+                }
+            },
+            new Hidden(resources, "-encoding", 1) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    encoding = args.get(0);
+                    return true;
+                }
+            },
+            new Option(resources, "-excludedocfilessubdir", 1) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    addToSet(excludedDocFileDirs, args.get(0));
+                    return true;
+                }
+            },
+            new Option(resources, "-group", 2) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    groups.add(new GroupContainer(args.get(0), args.get(1)));
+                    return true;
+                }
+            },
+            new Option(resources, "--javafx -javafx") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    javafx = true;
+                    return true;
+                }
+            },
+            new Option(resources, "-keywords") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    keywords = true;
+                    return true;
+                }
+            },
+            new Option(resources, "-link", 1) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    urlForLink = args.get(0);
+                    pkglistUrlForLink = urlForLink;
+                    return true;
+                }
+            },
+            new Option(resources, "-linksource") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    linksource = true;
+                    return true;
+                }
+            },
+            new Option(resources, "-linkoffline", 2) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    urlForLinkOffline = args.get(0);
+                    pkglistUrlForLinkOffline = args.get(1);
+                    return true;
+                }
+            },
+            new Option(resources, "-nocomment") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    nocomment = true;
+                    return true;
+                }
+            },
+            new Option(resources, "-nodeprecated") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    nodeprecated = true;
+                    return true;
+                }
+            },
+            new Option(resources, "-nosince") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    nosince = true;
+                    return true;
+                }
+            },
+            new Option(resources, "-notimestamp") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    notimestamp = true;
+                    return true;
+                }
+            },
+            new Option(resources, "-noqualifier", 1) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    addToSet(excludedQualifiers, args.get(0));
+                    return true;
+                }
+            },
+            new Hidden(resources, "-quiet") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    quiet = true;
+                    return true;
+                }
+            },
+            new Option(resources, "-serialwarn") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    serialwarn = true;
+                    return true;
+                }
+            },
+            new Option(resources, "-sourcetab", 1) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    linksource = true;
+                    try {
+                        setTabWidth(Integer.parseInt(args.get(0)));
+                    } catch (NumberFormatException e) {
+                             //Set to -1 so that warning will be printed
+                        //to indicate what is valid argument.
+                        sourcetab = -1;
+                    }
+                    if (sourcetab <= 0) {
+                        getMessages().warning("doclet.sourcetab_warning");
+                        setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
+                    }
+                    return true;
+                }
+            },
+            new Option(resources, "-tag", 1) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    ArrayList<String> list = new ArrayList<>();
+                    list.add(opt);
+                    list.add(args.get(0));
+                    customTagStrs.add(list);
+                    return true;
+                }
+            },
+             new Option(resources, "-taglet", 1) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    ArrayList<String> list = new ArrayList<>();
+                    list.add(opt);
+                    list.add(args.get(0));
+                    customTagStrs.add(list);
+                    return true;
+                }
+            },
+            new Option(resources, "-tagletpath", 1) {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    tagletpath = args.get(0);
+                    return true;
+                }
+            },
+            new Option(resources, "-version") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    showversion = true;
+                    return true;
+                }
+            },
+            new Hidden(resources, "--dump-on-error") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    dumpOnError = true;
+                    return true;
+                }
+            },
+            new Option(resources, "--allow-script-in-comments") {
+                @Override
+                public boolean process(String opt, List<String> args) {
+                    allowScriptInComments = true;
+                    return true;
+                }
+            }
+        };
+        Set<Doclet.Option> set = new TreeSet<>();
+        set.addAll(Arrays.asList(options));
+        return set;
+    }
+
+    final LinkedHashSet<List<String>> customTagStrs = new LinkedHashSet<>();
+
+    /*
+     * when this is called all the option have been set, this method,
+     * initializes certain components before anything else is started.
+     */
+    private void finishOptionSettings0() throws DocletException {
+        initDestDirectory();
+        if (urlForLink != null && pkglistUrlForLink != null)
+            extern.link(urlForLink, pkglistUrlForLink, reporter, false);
+        if (urlForLinkOffline != null && pkglistUrlForLinkOffline != null)
+            extern.link(urlForLinkOffline, pkglistUrlForLinkOffline, reporter, true);
+        if (docencoding == null) {
+            docencoding = encoding;
+        }
+        typeElementCatalog = new TypeElementCatalog(includedTypeElements, this);
+        initTagletManager(customTagStrs);
+        groups.stream().forEach((grp) -> {
+            if (showModules) {
+                group.checkModuleGroups(grp.value1, grp.value2);
+            } else {
+                group.checkPackageGroups(grp.value1, grp.value2);
+            }
+        });
+    }
+
+    /**
+     * Set the command line options supported by this configuration.
+     *
+     * @return true if the options are set successfully
+     * @throws DocletException if there is a problem while setting the options
+     */
+    public boolean setOptions() throws DocletException {
+        initPackages();
+        initModules();
+        finishOptionSettings0();
+        if (!finishOptionSettings())
+            return false;
+
+        return true;
+    }
+
+    private void initDestDirectory() throws DocletException {
+        if (!destDirName.isEmpty()) {
+            DocFile destDir = DocFile.createFileForDirectory(this, destDirName);
+            if (!destDir.exists()) {
+                //Create the output directory (in case it doesn't exist yet)
+                reporter.print(NOTE, getText("doclet.dest_dir_create", destDirName));
+                destDir.mkdirs();
+            } else if (!destDir.isDirectory()) {
+                throw new SimpleDocletException(getText(
+                        "doclet.destination_directory_not_directory_0",
+                        destDir.getPath()));
+            } else if (!destDir.canWrite()) {
+                throw new SimpleDocletException(getText(
+                        "doclet.destination_directory_not_writable_0",
+                        destDir.getPath()));
+            }
+        }
+        DocFileFactory.getFactory(this).setDestDir(destDirName);
+    }
+
+    /**
+     * Initialize the taglet manager.  The strings to initialize the simple custom tags should
+     * be in the following format:  "[tag name]:[location str]:[heading]".
+     *
+     * @param customTagStrs the set two dimensional arrays of strings.  These arrays contain
+     * either -tag or -taglet arguments.
+     */
+    private void initTagletManager(Set<List<String>> customTagStrs) {
+        tagletManager = tagletManager == null ?
+            new TagletManager(nosince, showversion, showauthor, javafx, this) :
+            tagletManager;
+        for (List<String> args : customTagStrs) {
+            if (args.get(0).equals("-taglet")) {
+                tagletManager.addCustomTag(args.get(1), getFileManager(), tagletpath);
+                continue;
+            }
+            List<String> tokens = tokenize(args.get(1), TagletManager.SIMPLE_TAGLET_OPT_SEPARATOR, 3);
+            if (tokens.size() == 1) {
+                String tagName = args.get(1);
+                if (tagletManager.isKnownCustomTag(tagName)) {
+                    //reorder a standard tag
+                    tagletManager.addNewSimpleCustomTag(tagName, null, "");
+                } else {
+                    //Create a simple tag with the heading that has the same name as the tag.
+                    StringBuilder heading = new StringBuilder(tagName + ":");
+                    heading.setCharAt(0, Character.toUpperCase(tagName.charAt(0)));
+                    tagletManager.addNewSimpleCustomTag(tagName, heading.toString(), "a");
+                }
+            } else if (tokens.size() == 2) {
+                //Add simple taglet without heading, probably to excluding it in the output.
+                tagletManager.addNewSimpleCustomTag(tokens.get(0), tokens.get(1), "");
+            } else if (tokens.size() >= 3) {
+                tagletManager.addNewSimpleCustomTag(tokens.get(0), tokens.get(2), tokens.get(1));
+            } else {
+                Messages messages = getMessages();
+                messages.error("doclet.Error_invalid_custom_tag_argument", args.get(1));
+            }
+        }
+    }
+
+    /**
+     * Given a string, return an array of tokens.  The separator can be escaped
+     * with the '\' character.  The '\' character may also be escaped by the
+     * '\' character.
+     *
+     * @param s         the string to tokenize.
+     * @param separator the separator char.
+     * @param maxTokens the maximum number of tokens returned.  If the
+     *                  max is reached, the remaining part of s is appended
+     *                  to the end of the last token.
+     *
+     * @return an array of tokens.
+     */
+    private List<String> tokenize(String s, char separator, int maxTokens) {
+        List<String> tokens = new ArrayList<>();
+        StringBuilder  token = new StringBuilder ();
+        boolean prevIsEscapeChar = false;
+        for (int i = 0; i < s.length(); i += Character.charCount(i)) {
+            int currentChar = s.codePointAt(i);
+            if (prevIsEscapeChar) {
+                // Case 1:  escaped character
+                token.appendCodePoint(currentChar);
+                prevIsEscapeChar = false;
+            } else if (currentChar == separator && tokens.size() < maxTokens-1) {
+                // Case 2:  separator
+                tokens.add(token.toString());
+                token = new StringBuilder();
+            } else if (currentChar == '\\') {
+                // Case 3:  escape character
+                prevIsEscapeChar = true;
+            } else {
+                // Case 4:  regular character
+                token.appendCodePoint(currentChar);
+            }
+        }
+        if (token.length() > 0) {
+            tokens.add(token.toString());
+        }
+        return tokens;
+    }
+
+    private void addToSet(Set<String> s, String str){
+        StringTokenizer st = new StringTokenizer(str, ":");
+        String current;
+        while(st.hasMoreTokens()){
+            current = st.nextToken();
+            s.add(current);
+        }
+    }
+
+    /**
+     * Add a trailing file separator, if not found. Remove superfluous
+     * file separators if any. Preserve the front double file separator for
+     * UNC paths.
+     *
+     * @param path Path under consideration.
+     * @return String Properly constructed path string.
+     */
+    public static String addTrailingFileSep(String path) {
+        String fs = System.getProperty("file.separator");
+        String dblfs = fs + fs;
+        int indexDblfs;
+        while ((indexDblfs = path.indexOf(dblfs, 1)) >= 0) {
+            path = path.substring(0, indexDblfs) +
+                path.substring(indexDblfs + fs.length());
+        }
+        if (!path.endsWith(fs))
+            path += fs;
+        return path;
+    }
+
+    /**
+     *
+     * This checks for the validity of the options used by the user.
+     * As of this writing, this checks only docencoding.
+     *
+     * @return true if all the options are valid.
+     */
+    public boolean generalValidOptions() {
+        if (docencoding != null) {
+            if (!checkOutputFileEncoding(docencoding)) {
+                return false;
+            }
+        }
+        if (docencoding == null && (encoding != null && !encoding.isEmpty())) {
+            if (!checkOutputFileEncoding(encoding)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Check the validity of the given Source or Output File encoding on this
+     * platform.
+     *
+     * @param docencoding output file encoding.
+     * @param reporter    used to report errors.
+     */
+    private boolean checkOutputFileEncoding(String docencoding) {
+        OutputStream ost= new ByteArrayOutputStream();
+        OutputStreamWriter osw = null;
+        try {
+            osw = new OutputStreamWriter(ost, docencoding);
+        } catch (UnsupportedEncodingException exc) {
+            reporter.print(ERROR, getText("doclet.Encoding_not_supported", docencoding));
+            return false;
+        } finally {
+            try {
+                if (osw != null) {
+                    osw.close();
+                }
+            } catch (IOException exc) {
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Return true if the given doc-file subdirectory should be excluded and
+     * false otherwise.
+     *
+     * @param docfilesubdir the doc-files subdirectory to check.
+     * @return true if the directory is excluded.
+     */
+    public boolean shouldExcludeDocFileDir(String docfilesubdir){
+        return excludedDocFileDirs.contains(docfilesubdir);
+    }
+
+    /**
+     * Return true if the given qualifier should be excluded and false otherwise.
+     *
+     * @param qualifier the qualifier to check.
+     * @return true if the qualifier should be excluded
+     */
+    public boolean shouldExcludeQualifier(String qualifier){
+        if (excludedQualifiers.contains("all") ||
+            excludedQualifiers.contains(qualifier) ||
+            excludedQualifiers.contains(qualifier + ".*")) {
+            return true;
+        } else {
+            int index = -1;
+            while ((index = qualifier.indexOf(".", index + 1)) != -1) {
+                if (excludedQualifiers.contains(qualifier.substring(0, index + 1) + "*")) {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
+    /**
+     * Return the qualified name of the Element if its qualifier is not excluded.
+     * Otherwise return the unqualified Element name.
+     *
+     * @param te the TypeElement to check.
+     * @return the class name
+     */
+    public String getClassName(TypeElement te) {
+        PackageElement pkg = utils.containingPackage(te);
+        return shouldExcludeQualifier(utils.getPackageName(pkg))
+                ? utils.getSimpleName(te)
+                : utils.getFullyQualifiedName(te);
+    }
+
+    /**
+     * Convenience method to obtain a resource from the doclet's
+     * {@link Resources resources}.
+     * Equivalent to <code>getResources.getText(key);</code>.
+     *
+     * @param key the key for the desired string
+     * @return the string for the given key
+     * @throws MissingResourceException if the key is not found in either
+     *  bundle.
+     */
+    public abstract String getText(String key);
+
+    /**
+     * Convenience method to obtain a resource from the doclet's
+     * {@link Resources resources}.
+     * Equivalent to <code>getResources.getText(key, args);</code>.
+     *
+     * @param key the key for the desired string
+     * @param args values to be substituted into the resulting string
+     * @return the string for the given key
+     * @throws MissingResourceException if the key is not found in either
+     *  bundle.
+     */
+    public abstract String getText(String key, String... args);
+
+    /**
+     * Convenience method to obtain a resource from the doclet's
+     * {@link Resources resources} as a {@code Content} object.
+     *
+     * @param key the key for the desired string
+     * @return a content tree for the text
+     */
+    public abstract Content getContent(String key);
+
+    /**
+     * Convenience method to obtain a resource from the doclet's
+     * {@link Resources resources} as a {@code Content} object.
+     *
+     * @param key the key for the desired string
+     * @param o   string or content argument added to configuration text
+     * @return a content tree for the text
+     */
+    public abstract Content getContent(String key, Object o);
+
+    /**
+     * Convenience method to obtain a resource from the doclet's
+     * {@link Resources resources} as a {@code Content} object.
+     *
+     * @param key the key for the desired string
+     * @param o1 resource argument
+     * @param o2 resource argument
+     * @return a content tree for the text
+     */
+    public abstract Content getContent(String key, Object o1, Object o2);
+
+    /**
+     * Get the configuration string as a content.
+     *
+     * @param key the key for the desired string
+     * @param o0  string or content argument added to configuration text
+     * @param o1  string or content argument added to configuration text
+     * @param o2  string or content argument added to configuration text
+     * @return a content tree for the text
+     */
+    public abstract Content getContent(String key, Object o0, Object o1, Object o2);
+
+    /**
+     * Return true if the TypeElement element is getting documented, depending upon
+     * -nodeprecated option and the deprecation information. Return true if
+     * -nodeprecated is not used. Return false if -nodeprecated is used and if
+     * either TypeElement element is deprecated or the containing package is deprecated.
+     *
+     * @param te the TypeElement for which the page generation is checked
+     * @return true if it is a generated doc.
+     */
+    public boolean isGeneratedDoc(TypeElement te) {
+        if (!nodeprecated) {
+            return true;
+        }
+        return !(utils.isDeprecated(te) || utils.isDeprecated(utils.containingPackage(te)));
+    }
+
+    /**
+     * Return the doclet specific instance of a writer factory.
+     *
+     * @return the {@link WriterFactory} for the doclet.
+     */
+    public abstract WriterFactory getWriterFactory();
+
+    /**
+     * Return the input stream to the builder XML.
+     *
+     * @return the input steam to the builder XML.
+     * @throws DocFileIOException when the given XML file cannot be found or opened.
+     */
+    public InputStream getBuilderXML() throws DocFileIOException {
+        return builderXMLPath == null ?
+            BaseConfiguration.class.getResourceAsStream(DEFAULT_BUILDER_XML) :
+            DocFile.createFileForInput(this, builderXMLPath).openInputStream();
+    }
+
+    /**
+     * Return the Locale for this document.
+     *
+     * @return the current locale
+     */
+    public abstract Locale getLocale();
+
+    /**
+     * Return the path of the overview file and null if it does not exist.
+     *
+     * @return the path of the overview file.
+     */
+    public abstract JavaFileObject getOverviewPath();
+
+    /**
+     * Return the current file manager.
+     *
+     * @return JavaFileManager
+     */
+    public abstract JavaFileManager getFileManager();
+
+    private void setTabWidth(int n) {
+        sourcetab = n;
+        tabSpaces = String.format("%" + n + "s", "");
+    }
+
+    public abstract boolean showMessage(DocTreePath path, String key);
+
+    public abstract boolean showMessage(Element e, String key);
+
+    public static abstract class Option implements Doclet.Option, Comparable<Option> {
+        private final String[] names;
+        private final String parameters;
+        private final String description;
+        private final int argCount;
+
+        protected Option(Resources resources, String name, int argCount) {
+            this(resources, null, name, argCount);
+        }
+
+        protected Option(Resources resources, String keyBase, String name, int argCount) {
+            this.names = name.trim().split("\\s+");
+            if (keyBase == null) {
+                keyBase = "doclet.usage." + names[0].toLowerCase().replaceAll("^-+", "");
+            }
+            String desc = getOptionsMessage(resources, keyBase + ".description");
+            if (desc.isEmpty()) {
+                this.description = "<MISSING KEY>";
+                this.parameters = "<MISSING KEY>";
+            } else {
+                this.description = desc;
+                this.parameters = getOptionsMessage(resources, keyBase + ".parameters");
+            }
+            this.argCount = argCount;
+        }
+
+        protected Option(Resources resources, String name) {
+            this(resources, name, 0);
+        }
+
+        private String getOptionsMessage(Resources resources, String key) {
+            try {
+                return resources.getText(key);
+            } catch (MissingResourceException ignore) {
+                return "";
+            }
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        @Override
+        public Option.Kind getKind() {
+            return Doclet.Option.Kind.STANDARD;
+        }
+
+        @Override
+        public List<String> getNames() {
+            return Arrays.asList(names);
+        }
+
+        @Override
+        public String getParameters() {
+            return parameters;
+        }
+
+        @Override
+        public String toString() {
+            return Arrays.toString(names);
+        }
+
+        @Override
+        public int getArgumentCount() {
+            return argCount;
+        }
+
+        public boolean matches(String option) {
+            for (String name : names) {
+                boolean matchCase = name.startsWith("--");
+                if (option.startsWith("--") && option.contains("=")) {
+                    return name.equals(option.substring(option.indexOf("=") + 1));
+                } else if (matchCase) {
+                    return name.equals(option);
+                }
+                return name.toLowerCase().equals(option.toLowerCase());
+            }
+            return false;
+        }
+
+        @Override
+        public int compareTo(Option that) {
+            return this.getNames().get(0).compareTo(that.getNames().get(0));
+        }
+    }
+
+    public abstract class XOption extends Option {
+
+        public XOption(Resources resources, String prefix, String name, int argCount) {
+            super(resources, prefix, name, argCount);
+        }
+
+        public XOption(Resources resources, String name, int argCount) {
+            super(resources, name, argCount);
+        }
+
+        public XOption(Resources resources, String name) {
+            this(resources, name, 0);
+        }
+
+        @Override
+        public Option.Kind getKind() {
+            return Doclet.Option.Kind.EXTENDED;
+        }
+    }
+
+    public abstract class Hidden extends Option {
+
+        public Hidden(Resources resources, String name, int argCount) {
+            super(resources, name, argCount);
+        }
+
+        public Hidden(Resources resources, String name) {
+            this(resources, name, 0);
+        }
+
+        @Override
+        public Option.Kind getKind() {
+            return Doclet.Option.Kind.OTHER;
+        }
+    }
+
+    /*
+     * Stores a pair of Strings.
+     */
+    protected static class GroupContainer {
+        final String value1;
+        final String value2;
+        public GroupContainer(String value1, String value2) {
+            this.value1 = value1;
+            this.value2 = value2;
+        }
+    }
+
+    /*
+     * Splits the elements in a collection to its individual
+     * collection.
+     */
+    static private class Splitter {
+
+        final Set<ModuleElement> mset = new LinkedHashSet<>();
+        final Set<PackageElement> pset = new LinkedHashSet<>();
+        final Set<TypeElement> tset = new LinkedHashSet<>();
+
+        Splitter(DocletEnvironment docEnv, boolean included) {
+
+            Set<? extends Element> inset = included
+                    ? docEnv.getIncludedElements()
+                    : docEnv.getSpecifiedElements();
+
+            for (Element e : inset) {
+                new SimpleElementVisitor9<Void, Void>() {
+                    @Override
+                    @DefinedBy(Api.LANGUAGE_MODEL)
+                    public Void visitModule(ModuleElement e, Void p) {
+                        mset.add(e);
+                        return null;
+                    }
+
+                    @Override
+                    @DefinedBy(Api.LANGUAGE_MODEL)
+                    public Void visitPackage(PackageElement e, Void p) {
+                        pset.add(e);
+                        return null;
+                    }
+
+                    @Override
+                    @DefinedBy(Api.LANGUAGE_MODEL)
+                    public Void visitType(TypeElement e, Void p) {
+                        tset.add(e);
+                        return null;
+                    }
+
+                    @Override
+                    @DefinedBy(Api.LANGUAGE_MODEL)
+                    protected Void defaultAction(Element e, Void p) {
+                        throw new AssertionError("unexpected element: " + e);
+                    }
+
+                }.visit(e);
+            }
+        }
+    }
+
+    /**
+     * Returns whether or not to allow JavaScript in comments.
+     * Default is off; can be set true from a command line option.
+     * @return the allowScriptInComments
+     */
+    public boolean isAllowScriptInComments() {
+        return allowScriptInComments;
+    }
+
+    public VisibleMemberMap getVisibleMemberMap(TypeElement te, VisibleMemberMap.Kind kind) {
+        EnumMap<Kind, Reference<VisibleMemberMap>> cacheMap = typeElementMemberCache
+                .computeIfAbsent(te, k -> new EnumMap<>(VisibleMemberMap.Kind.class));
+
+        Reference<VisibleMemberMap> vmapRef = cacheMap.get(kind);
+        // recompute, if referent has been garbage collected
+        VisibleMemberMap vMap = vmapRef == null ? null : vmapRef.get();
+        if (vMap == null) {
+            vMap = new VisibleMemberMap(te, kind, this);
+            cacheMap.put(kind, new SoftReference<>(vMap));
+        }
+        return vMap;
+    }
+}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/CommentUtils.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/CommentUtils.java	Wed Jul 05 23:37:13 2017 +0200
@@ -64,13 +64,13 @@
 
 public class CommentUtils {
 
-    final Configuration configuration;
+    final BaseConfiguration configuration;
     final DocTreeFactory treeFactory;
     final HashMap<Element, DocCommentDuo> dcTreesMap = new HashMap<>();
     final DocTrees trees;
     final Elements elementUtils;
 
-    protected CommentUtils(Configuration configuration) {
+    protected CommentUtils(BaseConfiguration configuration) {
         this.configuration = configuration;
         trees = configuration.docEnv.getDocTrees();
         treeFactory = trees.getDocTreeFactory();
@@ -110,7 +110,7 @@
         return (DocTree) text;
     }
 
-    public void setEnumValuesTree(Configuration config, Element e) {
+    public void setEnumValuesTree(BaseConfiguration config, Element e) {
         Utils utils = config.utils;
         String klassName = utils.getSimpleName(utils.getEnclosingTypeElement(e));
 
@@ -126,7 +126,7 @@
         dcTreesMap.put(e, new DocCommentDuo(null, docTree));
     }
 
-    public void setEnumValueOfTree(Configuration config, Element e) {
+    public void setEnumValueOfTree(BaseConfiguration config, Element e) {
 
         List<DocTree> fullBody = new ArrayList<>();
         fullBody.add(treeFactory.newTextTree(config.getText("doclet.enum_valueof_doc.fullbody")));
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java	Wed Jul 05 23:35:20 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1289 +0,0 @@
-/*
- * 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
- * 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 jdk.javadoc.internal.doclets.toolkit;
-
-import java.io.*;
-import java.lang.ref.*;
-import java.util.*;
-
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ModuleElement;
-import javax.lang.model.element.PackageElement;
-import javax.lang.model.element.TypeElement;
-import javax.lang.model.util.SimpleElementVisitor9;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-
-import com.sun.source.util.DocTreePath;
-import com.sun.tools.javac.util.DefinedBy;
-import com.sun.tools.javac.util.DefinedBy.Api;
-import jdk.javadoc.doclet.Doclet;
-import jdk.javadoc.doclet.DocletEnvironment;
-import jdk.javadoc.doclet.Reporter;
-import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory;
-import jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager;
-import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
-import jdk.javadoc.internal.doclets.toolkit.util.DocFileFactory;
-import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
-import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants;
-import jdk.javadoc.internal.doclets.toolkit.util.Extern;
-import jdk.javadoc.internal.doclets.toolkit.util.Group;
-import jdk.javadoc.internal.doclets.toolkit.util.MetaKeywords;
-import jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException;
-import jdk.javadoc.internal.doclets.toolkit.util.TypeElementCatalog;
-import jdk.javadoc.internal.doclets.toolkit.util.Utils;
-import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
-import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.GetterSetter;
-import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.Kind;
-
-import static javax.tools.Diagnostic.Kind.*;
-
-/**
- * Configure the output based on the options. Doclets should sub-class
- * Configuration, to configure and add their own options. This class contains
- * all user options which are supported by the 1.1 doclet and the standard
- * doclet.
- *
- *  <p><b>This is NOT part of any supported API.
- *  If you write code that depends on this, you do so at your own risk.
- *  This code and its internal interfaces are subject to change or
- *  deletion without notice.</b>
- *
- * @author Robert Field.
- * @author Atul Dambalkar.
- * @author Jamie Ho
- */
-public abstract class Configuration {
-    /**
-     * The doclet that created this configuration.
-     */
-    public final Doclet doclet;
-
-    /**
-     * The factory for builders.
-     */
-    protected BuilderFactory builderFactory;
-
-    /**
-     * The taglet manager.
-     */
-    public TagletManager tagletManager;
-
-    /**
-     * The path to the builder XML input file.
-     */
-    public String builderXMLPath;
-
-    /**
-     * The default path to the builder XML.
-     */
-    public static final String DEFAULT_BUILDER_XML = "resources/doclet.xml";
-
-    /**
-     * The path to Taglets
-     */
-    public String tagletpath = null;
-
-    /**
-     * This is true if option "-serialwarn" is used. Defualt value is false to
-     * suppress excessive warnings about serial tag.
-     */
-    public boolean serialwarn = false;
-
-    /**
-     * The specified amount of space between tab stops.
-     */
-    public int sourcetab;
-
-    public String tabSpaces;
-
-    /**
-     * True if we should generate browsable sources.
-     */
-    public boolean linksource = false;
-
-    /**
-     * True if command line option "-nosince" is used. Default value is
-     * false.
-     */
-    public boolean nosince = false;
-
-    /**
-     * True if we should recursively copy the doc-file subdirectories
-     */
-    public boolean copydocfilesubdirs = false;
-
-    /**
-     * Maintain backward compatibility with previous javadoc version
-     */
-    public boolean backwardCompatibility = true;
-
-    /**
-     * The META charset tag used for cross-platform viewing.
-     */
-    public String charset = "";
-
-    /**
-     * True if user wants to add member names as meta keywords.
-     * Set to false because meta keywords are ignored in general
-     * by most Internet search engines.
-     */
-    public boolean keywords = false;
-
-    /**
-     * The meta tag keywords instance.
-     */
-    public final MetaKeywords metakeywords;
-
-    /**
-     * The set of doc-file subdirectories to exclude
-     */
-    protected Set<String> excludedDocFileDirs;
-
-    /**
-     * The set of qualifiers to exclude
-     */
-    protected Set<String> excludedQualifiers;
-
-    /**
-     * The doclet environment.
-     */
-    public DocletEnvironment docEnv;
-
-    /**
-     * An utility class for commonly used helpers
-     */
-    public Utils utils;
-
-    /**
-     * All the temporary accessors to javac internals.
-     */
-    public WorkArounds workArounds;
-
-    /**
-     * Destination directory name, in which doclet will generate the entire
-     * documentation. Default is current directory.
-     */
-    public String destDirName = "";
-
-    /**
-     * Destination directory name, in which doclet will copy the doc-files to.
-     */
-    public String docFileDestDirName = "";
-
-    /**
-     * Encoding for this document. Default is default encoding for this
-     * platform.
-     */
-    public String docencoding = null;
-
-    /**
-     * True if user wants to suppress descriptions and tags.
-     */
-    public boolean nocomment = false;
-
-    /**
-     * Encoding for this document. Default is default encoding for this
-     * platform.
-     */
-    public String encoding = null;
-
-    /**
-     * Generate author specific information for all the classes if @author
-     * tag is used in the doc comment and if -author option is used.
-     * <code>showauthor</code> is set to true if -author option is used.
-     * Default is don't show author information.
-     */
-    public boolean showauthor = false;
-
-    /**
-     * Generate documentation for JavaFX getters and setters automatically
-     * by copying it from the appropriate property definition.
-     */
-    public boolean javafx = false;
-
-    /**
-     * Generate version specific information for the all the classes
-     * if @version tag is used in the doc comment and if -version option is
-     * used. <code>showversion</code> is set to true if -version option is
-     * used.Default is don't show version information.
-     */
-    public boolean showversion = false;
-
-    /**
-     * Allow JavaScript in doc comments.
-     */
-    private boolean allowScriptInComments = false;
-
-    /**
-     * Sourcepath from where to read the source files. Default is classpath.
-     *
-     */
-    public String sourcepath = "";
-
-    /**
-     * Generate modules documentation if more than one module is present.
-     */
-    public boolean showModules = false;
-
-    /**
-     * Don't generate deprecated API information at all, if -nodeprecated
-     * option is used. <code>nodepracted</code> is set to true if
-     * -nodeprecated option is used. Default is generate deprected API
-     * information.
-     */
-    public boolean nodeprecated = false;
-
-    /**
-     * The catalog of classes specified on the command-line
-     */
-    public TypeElementCatalog typeElementCatalog;
-
-    /**
-     * True if user wants to suppress time stamp in output.
-     * Default is false.
-     */
-    public boolean notimestamp= false;
-
-    /**
-     * The package grouping instance.
-     */
-    public final Group group = new Group(this);
-
-    /**
-     * The tracker of external package links.
-     */
-    public final Extern extern = new Extern(this);
-
-    public  Reporter reporter;
-
-    public Locale locale;
-
-    /**
-     * Suppress all messages
-     */
-    public boolean quiet = false;
-
-    private String urlForLink;
-
-    private String pkglistUrlForLink;
-
-    private String urlForLinkOffline;
-
-    private String pkglistUrlForLinkOffline;
-
-    public boolean dumpOnError = false;
-
-    private List<GroupContainer> groups;
-
-    private final Map<TypeElement, EnumMap<Kind, Reference<VisibleMemberMap>>> typeElementMemberCache;
-
-    public abstract Messages getMessages();
-    public abstract Resources getResources();
-
-    /**
-     * Return the build date for the doclet.
-     *
-     * @return the build date
-     */
-    public abstract String getDocletSpecificBuildDate();
-
-    /**
-     * This method should be defined in all those doclets (configurations),
-     * which want to derive themselves from this Configuration. This method
-     * can be used to finish up the options setup.
-     *
-     * @return true if successful and false otherwise
-     */
-
-    public abstract boolean finishOptionSettings();
-
-    public CommentUtils cmtUtils;
-
-    /**
-     * A sorted set of included packages.
-     */
-    public SortedSet<PackageElement> packages = null;
-
-    public OverviewElement overviewElement;
-
-    // The following three fields provide caches for use by all instances of VisibleMemberMap.
-    public final Map<TypeElement, List<Element>> propertiesCache = new HashMap<>();
-    public final Map<Element, Element> classPropertiesMap = new HashMap<>();
-    public final Map<Element, GetterSetter> getterSetterMap = new HashMap<>();
-
-    public DocFileFactory docFileFactory;
-
-    /**
-     * A sorted map, giving the (specified|included|other) packages for each module.
-     */
-    public SortedMap<ModuleElement, Set<PackageElement>> modulePackages;
-
-   /**
-    * The list of known modules, that should be documented.
-    */
-    public SortedSet<ModuleElement> modules;
-
-    protected static final String sharedResourceBundleName =
-            "jdk.javadoc.internal.doclets.toolkit.resources.doclets";
-    /**
-     * Constructs the configurations needed by the doclet.
-     * @param doclet the doclet that created this configuration
-     */
-    public Configuration(Doclet doclet) {
-        this.doclet = doclet;
-        excludedDocFileDirs = new HashSet<>();
-        excludedQualifiers = new HashSet<>();
-        setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
-        metakeywords = new MetaKeywords(this);
-        groups = new ArrayList<>(0);
-        typeElementMemberCache = new HashMap<>();
-    }
-
-    private boolean initialized = false;
-
-    protected void initConfiguration(DocletEnvironment docEnv) {
-        if (initialized) {
-            throw new IllegalStateException("configuration previously initialized");
-        }
-        initialized = true;
-        this.docEnv = docEnv;
-        overviewElement = new OverviewElement(docEnv);
-        Splitter specifiedSplitter = new Splitter(docEnv, false);
-        specifiedModuleElements = Collections.unmodifiableSet(specifiedSplitter.mset);
-        specifiedPackageElements = Collections.unmodifiableSet(specifiedSplitter.pset);
-        specifiedTypeElements = Collections.unmodifiableSet(specifiedSplitter.tset);
-
-        Splitter includedSplitter = new Splitter(docEnv, true);
-        includedModuleElements = Collections.unmodifiableSet(includedSplitter.mset);
-        includedPackageElements = Collections.unmodifiableSet(includedSplitter.pset);
-        includedTypeElements = Collections.unmodifiableSet(includedSplitter.tset);
-    }
-
-    /**
-     * Return the builder factory for this doclet.
-     *
-     * @return the builder factory for this doclet.
-     */
-    public BuilderFactory getBuilderFactory() {
-        if (builderFactory == null) {
-            builderFactory = new BuilderFactory(this);
-        }
-        return builderFactory;
-    }
-
-    public Reporter getReporter() {
-        return this.reporter;
-    }
-
-    private Set<ModuleElement> specifiedModuleElements;
-    public Set<ModuleElement> getSpecifiedModuleElements() {
-        return specifiedModuleElements;
-    }
-
-    private Set<PackageElement> specifiedPackageElements;
-    public Set<PackageElement> getSpecifiedPackageElements() {
-        return specifiedPackageElements;
-    }
-
-    private Set<TypeElement> specifiedTypeElements;
-    public Set<TypeElement> getSpecifiedTypeElements() {
-        return specifiedTypeElements;
-    }
-
-    private Set<ModuleElement> includedModuleElements;
-    public Set<ModuleElement> getIncludedModuleElements() {
-        return includedModuleElements;
-    }
-
-    private Set<PackageElement> includedPackageElements;
-    public Set<PackageElement> getIncludedPackageElements() {
-        return includedPackageElements;
-    }
-
-    private Set<TypeElement> includedTypeElements;
-    public Set<TypeElement> getIncludedTypeElements() {
-        return includedTypeElements;
-    }
-
-    private void initModules() {
-        // Build the modules structure used by the doclet
-        modules = new TreeSet<>(utils.makeModuleComparator());
-        modules.addAll(getSpecifiedModuleElements());
-
-        modulePackages = new TreeMap<>(utils.makeModuleComparator());
-        for (PackageElement p: packages) {
-            ModuleElement mdle = docEnv.getElementUtils().getModuleOf(p);
-            if (mdle != null && !mdle.isUnnamed()) {
-                Set<PackageElement> s = modulePackages
-                        .computeIfAbsent(mdle, m -> new TreeSet<>(utils.makePackageComparator()));
-                s.add(p);
-            }
-        }
-
-        for (PackageElement p: getIncludedPackageElements()) {
-            ModuleElement mdle = docEnv.getElementUtils().getModuleOf(p);
-            if (mdle != null && !mdle.isUnnamed()) {
-                Set<PackageElement> s = modulePackages
-                        .computeIfAbsent(mdle, m -> new TreeSet<>(utils.makePackageComparator()));
-                s.add(p);
-            }
-        }
-
-        // add entries for modules which may not have exported packages
-        modules.forEach((ModuleElement mdle) -> {
-            modulePackages.computeIfAbsent(mdle, m -> Collections.emptySet());
-        });
-
-        modules.addAll(modulePackages.keySet());
-        showModules = !modules.isEmpty();
-        for (Set<PackageElement> pkgs : modulePackages.values()) {
-            packages.addAll(pkgs);
-        }
-    }
-
-    private void initPackages() {
-        packages = new TreeSet<>(utils.makePackageComparator());
-        // add all the included packages
-        packages.addAll(includedPackageElements);
-    }
-
-    public Set<Doclet.Option> getSupportedOptions() {
-        Resources resources = getResources();
-        Doclet.Option[] options = {
-            new Option(resources, "-author") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    showauthor = true;
-                    return true;
-                }
-            },
-            new Option(resources, "-d", 1) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    destDirName = addTrailingFileSep(args.get(0));
-                    return true;
-                }
-            },
-            new Option(resources, "-docencoding", 1) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    docencoding = args.get(0);
-                    return true;
-                }
-            },
-            new Option(resources, "-docfilessubdirs") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    copydocfilesubdirs = true;
-                    return true;
-                }
-            },
-            new Hidden(resources, "-encoding", 1) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    encoding = args.get(0);
-                    return true;
-                }
-            },
-            new Option(resources, "-excludedocfilessubdir", 1) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    addToSet(excludedDocFileDirs, args.get(0));
-                    return true;
-                }
-            },
-            new Option(resources, "-group", 2) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    groups.add(new GroupContainer(args.get(0), args.get(1)));
-                    return true;
-                }
-            },
-            new Option(resources, "--javafx -javafx") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    javafx = true;
-                    return true;
-                }
-            },
-            new Option(resources, "-keywords") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    keywords = true;
-                    return true;
-                }
-            },
-            new Option(resources, "-link", 1) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    urlForLink = args.get(0);
-                    pkglistUrlForLink = urlForLink;
-                    return true;
-                }
-            },
-            new Option(resources, "-linksource") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    linksource = true;
-                    return true;
-                }
-            },
-            new Option(resources, "-linkoffline", 2) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    urlForLinkOffline = args.get(0);
-                    pkglistUrlForLinkOffline = args.get(1);
-                    return true;
-                }
-            },
-            new Option(resources, "-nocomment") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    nocomment = true;
-                    return true;
-                }
-            },
-            new Option(resources, "-nodeprecated") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    nodeprecated = true;
-                    return true;
-                }
-            },
-            new Option(resources, "-nosince") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    nosince = true;
-                    return true;
-                }
-            },
-            new Option(resources, "-notimestamp") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    notimestamp = true;
-                    return true;
-                }
-            },
-            new Option(resources, "-noqualifier", 1) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    addToSet(excludedQualifiers, args.get(0));
-                    return true;
-                }
-            },
-            new Hidden(resources, "-quiet") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    quiet = true;
-                    return true;
-                }
-            },
-            new Option(resources, "-serialwarn") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    serialwarn = true;
-                    return true;
-                }
-            },
-            new Option(resources, "-sourcetab", 1) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    linksource = true;
-                    try {
-                        setTabWidth(Integer.parseInt(args.get(0)));
-                    } catch (NumberFormatException e) {
-                             //Set to -1 so that warning will be printed
-                        //to indicate what is valid argument.
-                        sourcetab = -1;
-                    }
-                    if (sourcetab <= 0) {
-                        getMessages().warning("doclet.sourcetab_warning");
-                        setTabWidth(DocletConstants.DEFAULT_TAB_STOP_LENGTH);
-                    }
-                    return true;
-                }
-            },
-            new Option(resources, "-tag", 1) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    ArrayList<String> list = new ArrayList<>();
-                    list.add(opt);
-                    list.add(args.get(0));
-                    customTagStrs.add(list);
-                    return true;
-                }
-            },
-             new Option(resources, "-taglet", 1) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    ArrayList<String> list = new ArrayList<>();
-                    list.add(opt);
-                    list.add(args.get(0));
-                    customTagStrs.add(list);
-                    return true;
-                }
-            },
-            new Option(resources, "-tagletpath", 1) {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    tagletpath = args.get(0);
-                    return true;
-                }
-            },
-            new Option(resources, "-version") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    showversion = true;
-                    return true;
-                }
-            },
-            new Hidden(resources, "--dump-on-error") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    dumpOnError = true;
-                    return true;
-                }
-            },
-            new Option(resources, "--allow-script-in-comments") {
-                @Override
-                public boolean process(String opt, List<String> args) {
-                    allowScriptInComments = true;
-                    return true;
-                }
-            }
-        };
-        Set<Doclet.Option> set = new TreeSet<>();
-        set.addAll(Arrays.asList(options));
-        return set;
-    }
-
-    final LinkedHashSet<List<String>> customTagStrs = new LinkedHashSet<>();
-
-    /*
-     * when this is called all the option have been set, this method,
-     * initializes certain components before anything else is started.
-     */
-    private void finishOptionSettings0() throws DocletException {
-        initDestDirectory();
-        if (urlForLink != null && pkglistUrlForLink != null)
-            extern.link(urlForLink, pkglistUrlForLink, reporter, false);
-        if (urlForLinkOffline != null && pkglistUrlForLinkOffline != null)
-            extern.link(urlForLinkOffline, pkglistUrlForLinkOffline, reporter, true);
-        if (docencoding == null) {
-            docencoding = encoding;
-        }
-        typeElementCatalog = new TypeElementCatalog(includedTypeElements, this);
-        initTagletManager(customTagStrs);
-        groups.stream().forEach((grp) -> {
-            if (showModules) {
-                group.checkModuleGroups(grp.value1, grp.value2);
-            } else {
-                group.checkPackageGroups(grp.value1, grp.value2);
-            }
-        });
-    }
-
-    /**
-     * Set the command line options supported by this configuration.
-     *
-     * @return true if the options are set successfully
-     * @throws DocletException if there is a problem while setting the options
-     */
-    public boolean setOptions() throws DocletException {
-        initPackages();
-        initModules();
-        finishOptionSettings0();
-        if (!finishOptionSettings())
-            return false;
-
-        return true;
-    }
-
-    private void initDestDirectory() throws DocletException {
-        if (!destDirName.isEmpty()) {
-            DocFile destDir = DocFile.createFileForDirectory(this, destDirName);
-            if (!destDir.exists()) {
-                //Create the output directory (in case it doesn't exist yet)
-                reporter.print(NOTE, getText("doclet.dest_dir_create", destDirName));
-                destDir.mkdirs();
-            } else if (!destDir.isDirectory()) {
-                throw new SimpleDocletException(getText(
-                        "doclet.destination_directory_not_directory_0",
-                        destDir.getPath()));
-            } else if (!destDir.canWrite()) {
-                throw new SimpleDocletException(getText(
-                        "doclet.destination_directory_not_writable_0",
-                        destDir.getPath()));
-            }
-        }
-        DocFileFactory.getFactory(this).setDestDir(destDirName);
-    }
-
-    /**
-     * Initialize the taglet manager.  The strings to initialize the simple custom tags should
-     * be in the following format:  "[tag name]:[location str]:[heading]".
-     *
-     * @param customTagStrs the set two dimensional arrays of strings.  These arrays contain
-     * either -tag or -taglet arguments.
-     */
-    private void initTagletManager(Set<List<String>> customTagStrs) {
-        tagletManager = tagletManager == null ?
-            new TagletManager(nosince, showversion, showauthor, javafx, this) :
-            tagletManager;
-        for (List<String> args : customTagStrs) {
-            if (args.get(0).equals("-taglet")) {
-                tagletManager.addCustomTag(args.get(1), getFileManager(), tagletpath);
-                continue;
-            }
-            List<String> tokens = tokenize(args.get(1), TagletManager.SIMPLE_TAGLET_OPT_SEPARATOR, 3);
-            if (tokens.size() == 1) {
-                String tagName = args.get(1);
-                if (tagletManager.isKnownCustomTag(tagName)) {
-                    //reorder a standard tag
-                    tagletManager.addNewSimpleCustomTag(tagName, null, "");
-                } else {
-                    //Create a simple tag with the heading that has the same name as the tag.
-                    StringBuilder heading = new StringBuilder(tagName + ":");
-                    heading.setCharAt(0, Character.toUpperCase(tagName.charAt(0)));
-                    tagletManager.addNewSimpleCustomTag(tagName, heading.toString(), "a");
-                }
-            } else if (tokens.size() == 2) {
-                //Add simple taglet without heading, probably to excluding it in the output.
-                tagletManager.addNewSimpleCustomTag(tokens.get(0), tokens.get(1), "");
-            } else if (tokens.size() >= 3) {
-                tagletManager.addNewSimpleCustomTag(tokens.get(0), tokens.get(2), tokens.get(1));
-            } else {
-                Messages messages = getMessages();
-                messages.error("doclet.Error_invalid_custom_tag_argument", args.get(1));
-            }
-        }
-    }
-
-    /**
-     * Given a string, return an array of tokens.  The separator can be escaped
-     * with the '\' character.  The '\' character may also be escaped by the
-     * '\' character.
-     *
-     * @param s         the string to tokenize.
-     * @param separator the separator char.
-     * @param maxTokens the maximum number of tokens returned.  If the
-     *                  max is reached, the remaining part of s is appended
-     *                  to the end of the last token.
-     *
-     * @return an array of tokens.
-     */
-    private List<String> tokenize(String s, char separator, int maxTokens) {
-        List<String> tokens = new ArrayList<>();
-        StringBuilder  token = new StringBuilder ();
-        boolean prevIsEscapeChar = false;
-        for (int i = 0; i < s.length(); i += Character.charCount(i)) {
-            int currentChar = s.codePointAt(i);
-            if (prevIsEscapeChar) {
-                // Case 1:  escaped character
-                token.appendCodePoint(currentChar);
-                prevIsEscapeChar = false;
-            } else if (currentChar == separator && tokens.size() < maxTokens-1) {
-                // Case 2:  separator
-                tokens.add(token.toString());
-                token = new StringBuilder();
-            } else if (currentChar == '\\') {
-                // Case 3:  escape character
-                prevIsEscapeChar = true;
-            } else {
-                // Case 4:  regular character
-                token.appendCodePoint(currentChar);
-            }
-        }
-        if (token.length() > 0) {
-            tokens.add(token.toString());
-        }
-        return tokens;
-    }
-
-    private void addToSet(Set<String> s, String str){
-        StringTokenizer st = new StringTokenizer(str, ":");
-        String current;
-        while(st.hasMoreTokens()){
-            current = st.nextToken();
-            s.add(current);
-        }
-    }
-
-    /**
-     * Add a trailing file separator, if not found. Remove superfluous
-     * file separators if any. Preserve the front double file separator for
-     * UNC paths.
-     *
-     * @param path Path under consideration.
-     * @return String Properly constructed path string.
-     */
-    public static String addTrailingFileSep(String path) {
-        String fs = System.getProperty("file.separator");
-        String dblfs = fs + fs;
-        int indexDblfs;
-        while ((indexDblfs = path.indexOf(dblfs, 1)) >= 0) {
-            path = path.substring(0, indexDblfs) +
-                path.substring(indexDblfs + fs.length());
-        }
-        if (!path.endsWith(fs))
-            path += fs;
-        return path;
-    }
-
-    /**
-     *
-     * This checks for the validity of the options used by the user.
-     * As of this writing, this checks only docencoding.
-     *
-     * @return true if all the options are valid.
-     */
-    public boolean generalValidOptions() {
-        if (docencoding != null) {
-            if (!checkOutputFileEncoding(docencoding)) {
-                return false;
-            }
-        }
-        if (docencoding == null && (encoding != null && !encoding.isEmpty())) {
-            if (!checkOutputFileEncoding(encoding)) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Check the validity of the given Source or Output File encoding on this
-     * platform.
-     *
-     * @param docencoding output file encoding.
-     * @param reporter    used to report errors.
-     */
-    private boolean checkOutputFileEncoding(String docencoding) {
-        OutputStream ost= new ByteArrayOutputStream();
-        OutputStreamWriter osw = null;
-        try {
-            osw = new OutputStreamWriter(ost, docencoding);
-        } catch (UnsupportedEncodingException exc) {
-            reporter.print(ERROR, getText("doclet.Encoding_not_supported", docencoding));
-            return false;
-        } finally {
-            try {
-                if (osw != null) {
-                    osw.close();
-                }
-            } catch (IOException exc) {
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Return true if the given doc-file subdirectory should be excluded and
-     * false otherwise.
-     *
-     * @param docfilesubdir the doc-files subdirectory to check.
-     * @return true if the directory is excluded.
-     */
-    public boolean shouldExcludeDocFileDir(String docfilesubdir){
-        return excludedDocFileDirs.contains(docfilesubdir);
-    }
-
-    /**
-     * Return true if the given qualifier should be excluded and false otherwise.
-     *
-     * @param qualifier the qualifier to check.
-     * @return true if the qualifier should be excluded
-     */
-    public boolean shouldExcludeQualifier(String qualifier){
-        if (excludedQualifiers.contains("all") ||
-            excludedQualifiers.contains(qualifier) ||
-            excludedQualifiers.contains(qualifier + ".*")) {
-            return true;
-        } else {
-            int index = -1;
-            while ((index = qualifier.indexOf(".", index + 1)) != -1) {
-                if (excludedQualifiers.contains(qualifier.substring(0, index + 1) + "*")) {
-                    return true;
-                }
-            }
-            return false;
-        }
-    }
-
-    /**
-     * Return the qualified name of the Element if its qualifier is not excluded.
-     * Otherwise return the unqualified Element name.
-     *
-     * @param te the TypeElement to check.
-     * @return the class name
-     */
-    public String getClassName(TypeElement te) {
-        PackageElement pkg = utils.containingPackage(te);
-        return shouldExcludeQualifier(utils.getPackageName(pkg))
-                ? utils.getSimpleName(te)
-                : utils.getFullyQualifiedName(te);
-    }
-
-    /**
-     * Convenience method to obtain a resource from the doclet's
-     * {@link Resources resources}.
-     * Equivalent to <code>getResources.getText(key);</code>.
-     *
-     * @param key the key for the desired string
-     * @return the string for the given key
-     * @throws MissingResourceException if the key is not found in either
-     *  bundle.
-     */
-    public abstract String getText(String key);
-
-    /**
-     * Convenience method to obtain a resource from the doclet's
-     * {@link Resources resources}.
-     * Equivalent to <code>getResources.getText(key, args);</code>.
-     *
-     * @param key the key for the desired string
-     * @param args values to be substituted into the resulting string
-     * @return the string for the given key
-     * @throws MissingResourceException if the key is not found in either
-     *  bundle.
-     */
-    public abstract String getText(String key, String... args);
-
-    /**
-     * Convenience method to obtain a resource from the doclet's
-     * {@link Resources resources} as a {@code Content} object.
-     *
-     * @param key the key for the desired string
-     * @return a content tree for the text
-     */
-    public abstract Content getContent(String key);
-
-    /**
-     * Convenience method to obtain a resource from the doclet's
-     * {@link Resources resources} as a {@code Content} object.
-     *
-     * @param key the key for the desired string
-     * @param o   string or content argument added to configuration text
-     * @return a content tree for the text
-     */
-    public abstract Content getContent(String key, Object o);
-
-    /**
-     * Convenience method to obtain a resource from the doclet's
-     * {@link Resources resources} as a {@code Content} object.
-     *
-     * @param key the key for the desired string
-     * @param o1 resource argument
-     * @param o2 resource argument
-     * @return a content tree for the text
-     */
-    public abstract Content getContent(String key, Object o1, Object o2);
-
-    /**
-     * Get the configuration string as a content.
-     *
-     * @param key the key for the desired string
-     * @param o0  string or content argument added to configuration text
-     * @param o1  string or content argument added to configuration text
-     * @param o2  string or content argument added to configuration text
-     * @return a content tree for the text
-     */
-    public abstract Content getContent(String key, Object o0, Object o1, Object o2);
-
-    /**
-     * Return true if the TypeElement element is getting documented, depending upon
-     * -nodeprecated option and the deprecation information. Return true if
-     * -nodeprecated is not used. Return false if -nodeprecated is used and if
-     * either TypeElement element is deprecated or the containing package is deprecated.
-     *
-     * @param te the TypeElement for which the page generation is checked
-     * @return true if it is a generated doc.
-     */
-    public boolean isGeneratedDoc(TypeElement te) {
-        if (!nodeprecated) {
-            return true;
-        }
-        return !(utils.isDeprecated(te) || utils.isDeprecated(utils.containingPackage(te)));
-    }
-
-    /**
-     * Return the doclet specific instance of a writer factory.
-     *
-     * @return the {@link WriterFactory} for the doclet.
-     */
-    public abstract WriterFactory getWriterFactory();
-
-    /**
-     * Return the input stream to the builder XML.
-     *
-     * @return the input steam to the builder XML.
-     * @throws DocFileIOException when the given XML file cannot be found or opened.
-     */
-    public InputStream getBuilderXML() throws DocFileIOException {
-        return builderXMLPath == null ?
-            Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) :
-            DocFile.createFileForInput(this, builderXMLPath).openInputStream();
-    }
-
-    /**
-     * Return the Locale for this document.
-     *
-     * @return the current locale
-     */
-    public abstract Locale getLocale();
-
-    /**
-     * Return the path of the overview file and null if it does not exist.
-     *
-     * @return the path of the overview file.
-     */
-    public abstract JavaFileObject getOverviewPath();
-
-    /**
-     * Return the current file manager.
-     *
-     * @return JavaFileManager
-     */
-    public abstract JavaFileManager getFileManager();
-
-    private void setTabWidth(int n) {
-        sourcetab = n;
-        tabSpaces = String.format("%" + n + "s", "");
-    }
-
-    public abstract boolean showMessage(DocTreePath path, String key);
-
-    public abstract boolean showMessage(Element e, String key);
-
-    public static abstract class Option implements Doclet.Option, Comparable<Option> {
-        private final String[] names;
-        private final String parameters;
-        private final String description;
-        private final int argCount;
-
-        protected Option(Resources resources, String name, int argCount) {
-            this(resources, null, name, argCount);
-        }
-
-        protected Option(Resources resources, String keyBase, String name, int argCount) {
-            this.names = name.trim().split("\\s+");
-            if (keyBase == null) {
-                keyBase = "doclet.usage." + names[0].toLowerCase().replaceAll("^-+", "");
-            }
-            String desc = getOptionsMessage(resources, keyBase + ".description");
-            if (desc.isEmpty()) {
-                this.description = "<MISSING KEY>";
-                this.parameters = "<MISSING KEY>";
-            } else {
-                this.description = desc;
-                this.parameters = getOptionsMessage(resources, keyBase + ".parameters");
-            }
-            this.argCount = argCount;
-        }
-
-        protected Option(Resources resources, String name) {
-            this(resources, name, 0);
-        }
-
-        private String getOptionsMessage(Resources resources, String key) {
-            try {
-                return resources.getText(key);
-            } catch (MissingResourceException ignore) {
-                return "";
-            }
-        }
-
-        @Override
-        public String getDescription() {
-            return description;
-        }
-
-        @Override
-        public Option.Kind getKind() {
-            return Doclet.Option.Kind.STANDARD;
-        }
-
-        @Override
-        public List<String> getNames() {
-            return Arrays.asList(names);
-        }
-
-        @Override
-        public String getParameters() {
-            return parameters;
-        }
-
-        @Override
-        public String toString() {
-            return Arrays.toString(names);
-        }
-
-        @Override
-        public int getArgumentCount() {
-            return argCount;
-        }
-
-        public boolean matches(String option) {
-            for (String name : names) {
-                boolean matchCase = name.startsWith("--");
-                if (option.startsWith("--") && option.contains("=")) {
-                    return name.equals(option.substring(option.indexOf("=") + 1));
-                } else if (matchCase) {
-                    return name.equals(option);
-                }
-                return name.toLowerCase().equals(option.toLowerCase());
-            }
-            return false;
-        }
-
-        @Override
-        public int compareTo(Option that) {
-            return this.getNames().get(0).compareTo(that.getNames().get(0));
-        }
-    }
-
-    public abstract class XOption extends Option {
-
-        public XOption(Resources resources, String prefix, String name, int argCount) {
-            super(resources, prefix, name, argCount);
-        }
-
-        public XOption(Resources resources, String name, int argCount) {
-            super(resources, name, argCount);
-        }
-
-        public XOption(Resources resources, String name) {
-            this(resources, name, 0);
-        }
-
-        @Override
-        public Option.Kind getKind() {
-            return Doclet.Option.Kind.EXTENDED;
-        }
-    }
-
-    public abstract class Hidden extends Option {
-
-        public Hidden(Resources resources, String name, int argCount) {
-            super(resources, name, argCount);
-        }
-
-        public Hidden(Resources resources, String name) {
-            this(resources, name, 0);
-        }
-
-        @Override
-        public Option.Kind getKind() {
-            return Doclet.Option.Kind.OTHER;
-        }
-    }
-
-    /*
-     * Stores a pair of Strings.
-     */
-    protected static class GroupContainer {
-        final String value1;
-        final String value2;
-        public GroupContainer(String value1, String value2) {
-            this.value1 = value1;
-            this.value2 = value2;
-        }
-    }
-
-    /*
-     * Splits the elements in a collection to its individual
-     * collection.
-     */
-    static private class Splitter {
-
-        final Set<ModuleElement> mset = new LinkedHashSet<>();
-        final Set<PackageElement> pset = new LinkedHashSet<>();
-        final Set<TypeElement> tset = new LinkedHashSet<>();
-
-        Splitter(DocletEnvironment docEnv, boolean included) {
-
-            Set<? extends Element> inset = included
-                    ? docEnv.getIncludedElements()
-                    : docEnv.getSpecifiedElements();
-
-            for (Element e : inset) {
-                new SimpleElementVisitor9<Void, Void>() {
-                    @Override
-                    @DefinedBy(Api.LANGUAGE_MODEL)
-                    public Void visitModule(ModuleElement e, Void p) {
-                        mset.add(e);
-                        return null;
-                    }
-
-                    @Override
-                    @DefinedBy(Api.LANGUAGE_MODEL)
-                    public Void visitPackage(PackageElement e, Void p) {
-                        pset.add(e);
-                        return null;
-                    }
-
-                    @Override
-                    @DefinedBy(Api.LANGUAGE_MODEL)
-                    public Void visitType(TypeElement e, Void p) {
-                        tset.add(e);
-                        return null;
-                    }
-
-                    @Override
-                    @DefinedBy(Api.LANGUAGE_MODEL)
-                    protected Void defaultAction(Element e, Void p) {
-                        throw new AssertionError("unexpected element: " + e);
-                    }
-
-                }.visit(e);
-            }
-        }
-    }
-
-    /**
-     * Returns whether or not to allow JavaScript in comments.
-     * Default is off; can be set true from a command line option.
-     * @return the allowScriptInComments
-     */
-    public boolean isAllowScriptInComments() {
-        return allowScriptInComments;
-    }
-
-    public VisibleMemberMap getVisibleMemberMap(TypeElement te, VisibleMemberMap.Kind kind) {
-        EnumMap<Kind, Reference<VisibleMemberMap>> cacheMap = typeElementMemberCache
-                .computeIfAbsent(te, k -> new EnumMap<>(VisibleMemberMap.Kind.class));
-
-        Reference<VisibleMemberMap> vmapRef = cacheMap.get(kind);
-        // recompute, if referent has been garbage collected
-        VisibleMemberMap vMap = vmapRef == null ? null : vmapRef.get();
-        if (vMap == null) {
-            vMap = new VisibleMemberMap(te, kind, this);
-            cacheMap.put(kind, new SoftReference<>(vMap));
-        }
-        return vMap;
-    }
-}
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Messages.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Messages.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
  * Messages are reported to the doclet's {@link Reporter reporter}.
  */
 public class Messages {
-    private final Configuration configuration;
+    private final BaseConfiguration configuration;
     private final Resources resources;
     private Reporter reporter;
 
@@ -55,7 +55,7 @@
      *  the doclet's resources, reporter, and additional methods and state
      *  used to filter out messages, if any, which should be suppressed.
      */
-    public Messages(Configuration configuration) {
+    public Messages(BaseConfiguration configuration) {
         this.configuration = configuration;
         resources = configuration.getResources();
     }
@@ -155,7 +155,7 @@
     }
 
     // Lazy init the reporter for now, until we can fix/improve
-    // the init of ConfigurationImpl in HtmlDoclet (and similar.)
+    // the init of HtmlConfiguration in HtmlDoclet (and similar.)
     private void initReporter() {
         if (reporter == null) {
             reporter = configuration.reporter;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Resources.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Resources.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,7 +39,7 @@
  * HTML doclet.
  */
 public class Resources {
-    private final Configuration configuration;
+    private final BaseConfiguration configuration;
     private final String commonBundleName;
     private final String docletBundleName;
 
@@ -58,7 +58,7 @@
      * @param docletBundleName the name of the bundle containing the strings
      *  specific to a particular format
      */
-    public Resources(Configuration configuration, String commonBundleName, String docletBundleName) {
+    public Resources(BaseConfiguration configuration, String commonBundleName, String docletBundleName) {
         this.configuration = configuration;
         this.commonBundleName = commonBundleName;
         this.docletBundleName = docletBundleName;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WorkArounds.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WorkArounds.java	Wed Jul 05 23:37:13 2017 +0200
@@ -89,13 +89,13 @@
  */
 public class WorkArounds {
 
-    public final Configuration configuration;
+    public final BaseConfiguration configuration;
     public final ToolEnvironment toolEnv;
     public final Utils utils;
 
     private DocLint doclint;
 
-    public WorkArounds(Configuration configuration) {
+    public WorkArounds(BaseConfiguration configuration) {
         this.configuration = configuration;
         this.utils = this.configuration.utils;
         this.toolEnv = ((DocEnvImpl)this.configuration.docEnv).toolEnv;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractBuilder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractBuilder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 
 import javax.lang.model.element.PackageElement;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.DocletException;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
@@ -65,7 +65,7 @@
         /**
          * The configuration used in this run of the doclet.
          */
-        final Configuration configuration;
+        final BaseConfiguration configuration;
 
         /**
          * Keep track of which packages we have seen for
@@ -79,7 +79,7 @@
          */
         final LayoutParser layoutParser;
 
-        Context(Configuration configuration,
+        Context(BaseConfiguration configuration,
                 Set<PackageElement> containingPackagesSeen,
                 LayoutParser layoutParser) {
             this.configuration = configuration;
@@ -91,7 +91,7 @@
     /**
      * The configuration used in this run of the doclet.
      */
-    protected final Configuration configuration;
+    protected final BaseConfiguration configuration;
 
     protected final Messages messages;
     protected final Resources resources;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractMemberBuilder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractMemberBuilder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,6 @@
 
 import javax.lang.model.element.Element;
 
-import jdk.javadoc.internal.doclets.formats.html.ConfigurationImpl;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.DocletException;
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -31,7 +31,7 @@
 import javax.lang.model.element.TypeElement;
 
 import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeFieldWriter;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.DocletException;
 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
@@ -193,7 +193,7 @@
 
     /**
      * Build the comments for the member.  Do nothing if
-     * {@link Configuration#nocomment} is set to true.
+     * {@link BaseConfiguration#nocomment} is set to true.
      *
      * @param node the XML element that specifies which components to document
      * @param annotationDocTree the content tree to which the documentation will be added
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -31,7 +31,7 @@
 import javax.lang.model.element.TypeElement;
 
 import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.DocletException;
 import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap;
@@ -192,7 +192,7 @@
 
     /**
      * Build the comments for the member.  Do nothing if
-     * {@link Configuration#nocomment} is set to true.
+     * {@link BaseConfiguration#nocomment} is set to true.
      *
      * @param node the XML element that specifies which components to document
      * @param annotationDocTree the content tree to which the documentation will be added
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/BuilderFactory.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/BuilderFactory.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
 
 import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter;
 import jdk.javadoc.internal.doclets.toolkit.ClassWriter;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.PropertyWriter;
 import jdk.javadoc.internal.doclets.toolkit.WriterFactory;
 import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
@@ -56,7 +56,7 @@
     /**
      * The current configuration of the doclet.
      */
-    private final Configuration configuration;
+    private final BaseConfiguration configuration;
 
     /**
      * The factory to retrieve the required writers from.
@@ -70,7 +70,7 @@
      * @param configuration the configuration for the current doclet
      * being executed.
      */
-    public BuilderFactory (Configuration configuration) {
+    public BuilderFactory (BaseConfiguration configuration) {
         this.configuration = configuration;
         this.writerFactory = configuration.getWriterFactory();
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -31,7 +31,7 @@
 import javax.lang.model.element.ExecutableElement;
 import javax.lang.model.element.TypeElement;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.ConstructorWriter;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.DocletException;
@@ -192,7 +192,7 @@
 
     /**
      * Build the comments for the constructor.  Do nothing if
-     * {@link Configuration#nocomment} is set to true.
+     * {@link BaseConfiguration#nocomment} is set to true.
      *
      * @param node the XML element that specifies which components to document
      * @param constructorDocTree the content tree to which the documentation will be added
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -31,7 +31,7 @@
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.element.VariableElement;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.DocletException;
 import jdk.javadoc.internal.doclets.toolkit.EnumConstantWriter;
@@ -175,7 +175,7 @@
 
     /**
      * Build the comments for the enum constant.  Do nothing if
-     * {@link Configuration#nocomment} is set to true.
+     * {@link BaseConfiguration#nocomment} is set to true.
      *
      * @param node the XML element that specifies which components to document
      * @param enumConstantsTree the content tree to which the documentation will be added
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -31,7 +31,7 @@
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.element.VariableElement;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.DocletException;
 import jdk.javadoc.internal.doclets.toolkit.FieldWriter;
@@ -176,7 +176,7 @@
 
     /**
      * Build the comments for the field.  Do nothing if
-     * {@link Configuration#nocomment} is set to true.
+     * {@link BaseConfiguration#nocomment} is set to true.
      *
      * @param node the XML element that specifies which components to document
      * @param fieldDocTree the content tree to which the documentation will be added
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/LayoutParser.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/LayoutParser.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 
 import javax.xml.parsers.*;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
 import jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException;
 import org.xml.sax.*;
@@ -56,11 +56,11 @@
      */
     private final Map<String,XMLNode> xmlElementsMap;
     private XMLNode currentNode;
-    private final Configuration configuration;
+    private final BaseConfiguration configuration;
     private String currentRoot;
     private boolean isParsing;
 
-    private LayoutParser(Configuration configuration) {
+    private LayoutParser(BaseConfiguration configuration) {
         xmlElementsMap = new HashMap<>();
         this.configuration = configuration;
     }
@@ -71,7 +71,7 @@
      * @param configuration the current configuration of the doclet.
      * @return an instance of the BuilderXML.
      */
-    public static LayoutParser getInstance(Configuration configuration) {
+    public static LayoutParser getInstance(BaseConfiguration configuration) {
         return new LayoutParser(configuration);
     }
 
@@ -95,7 +95,7 @@
             } catch (IOException | ParserConfigurationException | SAXException e) {
                 String message = (configuration.builderXMLPath == null)
                         ? configuration.getResources().getText("doclet.exception.read.resource",
-                                Configuration.DEFAULT_BUILDER_XML, e)
+                                BaseConfiguration.DEFAULT_BUILDER_XML, e)
                         : configuration.getResources().getText("doclet.exception.read.file",
                                 configuration.builderXMLPath, e);
                 throw new SimpleDocletException(message, e);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -32,8 +32,7 @@
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.TypeMirror;
 
-import jdk.javadoc.internal.doclets.formats.html.ConfigurationImpl;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.DocletException;
 import jdk.javadoc.internal.doclets.toolkit.MethodWriter;
@@ -178,7 +177,7 @@
 
     /**
      * Build the comments for the method.  Do nothing if
-     * {@link Configuration#nocomment} is set to true.
+     * {@link BaseConfiguration#nocomment} is set to true.
      *
      * @param node the XML element that specifies which components to document
      * @param methodDocTree the content tree to which the documentation will be added
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -31,7 +31,7 @@
 import javax.lang.model.element.ExecutableElement;
 import javax.lang.model.element.TypeElement;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.DocletException;
 import jdk.javadoc.internal.doclets.toolkit.PropertyWriter;
@@ -177,7 +177,7 @@
 
     /**
      * Build the comments for the property.  Do nothing if
-     * {@link Configuration#nocomment} is set to true.
+     * {@link BaseConfiguration#nocomment} is set to true.
      *
      * @param node the XML element that specifies which components to document
      * @param propertyDocTree the content tree to which the documentation will be added
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/InheritDocTaglet.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/InheritDocTaglet.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
 import javax.lang.model.element.ExecutableElement;
 
 import com.sun.source.doctree.DocTree;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
@@ -135,7 +135,7 @@
     private Content retrieveInheritedDocumentation(TagletWriter writer,
             Element e, DocTree holderTag, boolean isFirstSentence) {
         Content replacement = writer.getOutputInstance();
-        Configuration configuration = writer.configuration();
+        BaseConfiguration configuration = writer.configuration();
         Messages messages = configuration.getMessages();
         Utils utils = configuration.utils;
         CommentHelper ch = utils.getCommentHelper(e);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java	Wed Jul 05 23:37:13 2017 +0200
@@ -42,7 +42,7 @@
 import com.sun.source.doctree.DocTree;
 import jdk.javadoc.doclet.Doclet;
 import jdk.javadoc.doclet.DocletEnvironment;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.Resources;
 
@@ -194,7 +194,7 @@
      */
     public TagletManager(boolean nosince, boolean showversion,
                          boolean showauthor, boolean javafx,
-                         Configuration configuration) {
+                         BaseConfiguration configuration) {
         overridenStandardTags = new HashSet<>();
         potentiallyConflictingTags = new HashSet<>();
         standardTags = new HashSet<>();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
 import javax.lang.model.type.TypeMirror;
 
 import com.sun.source.doctree.DocTree;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.taglets.Taglet.UnsupportedTagletOperationException;
 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
@@ -326,5 +326,5 @@
     /**
      * @return an instance of the configuration used for this doclet.
      */
-    public abstract Configuration configuration();
+    public abstract BaseConfiguration configuration();
 }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ValueTaglet.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/ValueTaglet.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
 import javax.lang.model.util.Elements;
 
 import com.sun.source.doctree.DocTree;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper;
@@ -133,7 +133,7 @@
      * return field that the value tag was used in. Return null if the name is null
      * or empty string and if the value tag is not used on a field.
      */
-    private VariableElement getVariableElement(Element holder, Configuration config, DocTree tag) {
+    private VariableElement getVariableElement(Element holder, BaseConfiguration config, DocTree tag) {
         Utils utils = config.utils;
         CommentHelper ch = utils.getCommentHelper(holder);
         String signature = ch.getReferencedSignature(tag);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassTree.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassTree.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
 import javax.lang.model.type.TypeMirror;
 
 import jdk.javadoc.doclet.DocletEnvironment;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
 
 /**
@@ -94,7 +94,7 @@
     */
     private final Map<TypeElement, SortedSet<TypeElement>> implementingClasses = new HashMap<>();
 
-    private final Configuration configuration;
+    private final BaseConfiguration configuration;
     private final Utils utils;
     private final Comparator<Element> comparator;
 
@@ -105,7 +105,7 @@
      * @param noDeprecated Don't add deprecated classes in the class tree, if
      * true.
      */
-    public ClassTree(Configuration configuration, boolean noDeprecated) {
+    public ClassTree(BaseConfiguration configuration, boolean noDeprecated) {
         this.configuration = configuration;
         this.utils = configuration.utils;
 
@@ -126,7 +126,7 @@
      * @param docEnv the DocletEnvironment.
      * @param configuration The current configuration of the doclet.
      */
-    public ClassTree(DocletEnvironment docEnv, Configuration configuration) {
+    public ClassTree(DocletEnvironment docEnv, BaseConfiguration configuration) {
         this.configuration = configuration;
         this.utils = configuration.utils;
         comparator = utils.makeClassUseComparator();
@@ -143,7 +143,7 @@
      * @param classesSet a set of classes
      * @param configuration The current configuration of the doclet.
      */
-    public ClassTree(SortedSet<TypeElement>classesSet, Configuration configuration) {
+    public ClassTree(SortedSet<TypeElement>classesSet, BaseConfiguration configuration) {
         this.configuration = configuration;
         this.utils = configuration.utils;
         comparator = utils.makeClassUseComparator();
@@ -203,7 +203,7 @@
      * @param typeElement for which sub class mapping is to be generated.
      * @param configuration the current configuration of the doclet.
      */
-    private void processType(TypeElement typeElement, Configuration configuration,
+    private void processType(TypeElement typeElement, BaseConfiguration configuration,
             Collection<TypeElement> bases, Map<TypeElement, SortedSet<TypeElement>> subs) {
         TypeElement superclass = utils.getFirstVisibleSuperClassAsTypeElement(typeElement);
         if (superclass != null) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassUseMapper.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassUseMapper.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@
 import javax.lang.model.util.Types;
 
 import jdk.javadoc.doclet.DocletEnvironment;
-import jdk.javadoc.internal.doclets.formats.html.ConfigurationImpl;
+import jdk.javadoc.internal.doclets.formats.html.HtmlConfiguration;
 
 /**
  * Map all class uses for a given class.
@@ -190,7 +190,7 @@
     private final Types typeUtils;
     private final Utils utils;
 
-    public ClassUseMapper(ConfigurationImpl configuration, ClassTree classtree) {
+    public ClassUseMapper(HtmlConfiguration configuration, ClassTree classtree) {
         docEnv = configuration.docEnv;
         elementUtils = docEnv.getElementUtils();
         typeUtils = docEnv.getTypeUtils();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,7 +69,7 @@
 import com.sun.source.util.DocTrees;
 import com.sun.source.util.SimpleDocTreeVisitor;
 import com.sun.source.util.TreePath;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 
 import static com.sun.source.doctree.DocTree.Kind.*;
 
@@ -89,7 +89,7 @@
 
     public static final String SPACER = " ";
 
-    public CommentHelper(Configuration configuration, Element element, TreePath path, DocCommentTree dctree) {
+    public CommentHelper(BaseConfiguration configuration, Element element, TreePath path, DocCommentTree dctree) {
         //this.configuration = configuration;
         this.element = element;
         this.path = path;
@@ -143,7 +143,7 @@
         }
     }
 
-    Element getElement(Configuration c, ReferenceTree rtree) {
+    Element getElement(BaseConfiguration c, ReferenceTree rtree) {
         // likely a synthesized tree
         if (path == null) {
             TypeMirror symbol = c.utils.getSymbol(rtree.getSignature());
@@ -178,7 +178,7 @@
         return doctrees.getElement(docTreePath);
     }
 
-    public Element getException(Configuration c, DocTree dtree) {
+    public Element getException(BaseConfiguration c, DocTree dtree) {
         if (dtree.getKind() == THROWS || dtree.getKind() == EXCEPTION) {
             ThrowsTree tt = (ThrowsTree)dtree;
             ReferenceTree exceptionName = tt.getExceptionName();
@@ -187,7 +187,7 @@
         return null;
     }
 
-    public List<? extends DocTree> getDescription(Configuration c, DocTree dtree) {
+    public List<? extends DocTree> getDescription(BaseConfiguration c, DocTree dtree) {
         return getTags(c, dtree);
     }
 
@@ -334,7 +334,7 @@
         return sb;
     }
 
-    public String getLabel(Configuration c, DocTree dtree) {
+    public String getLabel(BaseConfiguration c, DocTree dtree) {
         return new SimpleDocTreeVisitor<String, Void>() {
             @Override
             public String visitLink(LinkTree node, Void p) {
@@ -361,7 +361,7 @@
         }.visit(dtree, null);
     }
 
-    public TypeElement getReferencedClass(Configuration c, DocTree dtree) {
+    public TypeElement getReferencedClass(BaseConfiguration c, DocTree dtree) {
         Element e = getReferencedElement(c, dtree);
         if (e == null) {
             return null;
@@ -373,7 +373,7 @@
         return null;
     }
 
-    public String getReferencedClassName(Configuration c, DocTree dtree) {
+    public String getReferencedClassName(BaseConfiguration c, DocTree dtree) {
         Element e = getReferencedClass(c, dtree);
         if (e != null) {
             return c.utils.isTypeElement(e) ? c.utils.getSimpleName(e) : null;
@@ -386,7 +386,7 @@
         return (n == -1) ? s : s.substring(0, n);
     }
 
-    public Element getReferencedMember(Configuration c, DocTree dtree) {
+    public Element getReferencedMember(BaseConfiguration c, DocTree dtree) {
         Element e = getReferencedElement(c, dtree);
         if (e == null) {
             return null;
@@ -403,7 +403,7 @@
         return (n == -1) ? null : s.substring(n + 1);
     }
 
-    public String getReferencedMemberName(Configuration c, Element e) {
+    public String getReferencedMemberName(BaseConfiguration c, Element e) {
         if (e == null) {
             return null;
         }
@@ -412,7 +412,7 @@
                 : c.utils.getSimpleName(e);
     }
 
-    public PackageElement getReferencedPackage(Configuration c, DocTree dtree) {
+    public PackageElement getReferencedPackage(BaseConfiguration c, DocTree dtree) {
         Element e = getReferencedElement(c, dtree);
         if (e != null) {
             return c.utils.containingPackage(e);
@@ -420,16 +420,16 @@
         return null;
     }
 
-    public List<? extends DocTree> getFirstSentenceTrees(Configuration c, List<? extends DocTree> body) {
+    public List<? extends DocTree> getFirstSentenceTrees(BaseConfiguration c, List<? extends DocTree> body) {
         List<DocTree> firstSentence = c.docEnv.getDocTrees().getFirstSentence(body);
         return firstSentence;
     }
 
-    public List<? extends DocTree> getFirstSentenceTrees(Configuration c, DocTree dtree) {
+    public List<? extends DocTree> getFirstSentenceTrees(BaseConfiguration c, DocTree dtree) {
         return getFirstSentenceTrees(c, getBody(c, dtree));
     }
 
-    private Element getReferencedElement(Configuration c, DocTree dtree) {
+    private Element getReferencedElement(BaseConfiguration c, DocTree dtree) {
         return new SimpleDocTreeVisitor<Element, Void>() {
             @Override
             public Element visitSee(SeeTree node, Void p) {
@@ -476,7 +476,7 @@
         }.visit(dtree, null);
     }
 
-    public TypeElement getServiceType(Configuration c, DocTree dtree) {
+    public TypeElement getServiceType(BaseConfiguration c, DocTree dtree) {
         Element e = getReferencedElement(c, dtree);
         if (e != null) {
             return c.utils.isTypeElement(e) ? (TypeElement) e : null;
@@ -542,7 +542,7 @@
             }
     }
 
-    public List<? extends DocTree> getTags(Configuration c, DocTree dtree) {
+    public List<? extends DocTree> getTags(BaseConfiguration c, DocTree dtree) {
         return new SimpleDocTreeVisitor<List<? extends DocTree>, Void>() {
             List<? extends DocTree> asList(String content) {
                 List<DocTree> out = new ArrayList<>();
@@ -647,7 +647,7 @@
         }.visit(dtree, null);
     }
 
-    public List<? extends DocTree> getBody(Configuration c, DocTree dtree) {
+    public List<? extends DocTree> getBody(BaseConfiguration c, DocTree dtree) {
         return getTags(c, dtree);
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DeprecatedAPIListBuilder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 
 /**
  * Build list of all the deprecated packages, classes, constructors, fields and methods.
@@ -49,7 +49,7 @@
      * List of deprecated type Lists.
      */
     private final Map<DeprElementKind, SortedSet<Element>> deprecatedMap;
-    private final Configuration configuration;
+    private final BaseConfiguration configuration;
     private final Utils utils;
     public static enum DeprElementKind {
         REMOVAL,
@@ -72,7 +72,7 @@
      *
      * @param configuration the current configuration of the doclet
      */
-    public DeprecatedAPIListBuilder(Configuration configuration) {
+    public DeprecatedAPIListBuilder(BaseConfiguration configuration) {
         this.configuration = configuration;
         this.utils = configuration.utils;
         deprecatedMap = new EnumMap<>(DeprElementKind.class);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFile.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFile.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
 import javax.tools.JavaFileManager.Location;
 import javax.tools.StandardLocation;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 
 /**
  * Abstraction for handling files, which may be specified directly
@@ -51,17 +51,17 @@
 public abstract class DocFile {
 
     /** Create a DocFile for a directory. */
-    public static DocFile createFileForDirectory(Configuration configuration, String file) {
+    public static DocFile createFileForDirectory(BaseConfiguration configuration, String file) {
         return DocFileFactory.getFactory(configuration).createFileForDirectory(file);
     }
 
     /** Create a DocFile for a file that will be opened for reading. */
-    public static DocFile createFileForInput(Configuration configuration, String file) {
+    public static DocFile createFileForInput(BaseConfiguration configuration, String file) {
         return DocFileFactory.getFactory(configuration).createFileForInput(file);
     }
 
     /** Create a DocFile for a file that will be opened for writing. */
-    public static DocFile createFileForOutput(Configuration configuration, DocPath path) {
+    public static DocFile createFileForOutput(BaseConfiguration configuration, DocPath path) {
         return DocFileFactory.getFactory(configuration).createFileForOutput(path);
     }
 
@@ -85,7 +85,7 @@
      * @param path the subdirectory of the directories of the location for which to
      *  list files
      */
-    public static Iterable<DocFile> list(Configuration configuration, Location location, DocPath path) {
+    public static Iterable<DocFile> list(BaseConfiguration configuration, Location location, DocPath path) {
         return DocFileFactory.getFactory(configuration).list(location, path);
     }
 
@@ -173,7 +173,7 @@
             return;
 
         try {
-            InputStream in = Configuration.class.getResourceAsStream(resource.getPath());
+            InputStream in = BaseConfiguration.class.getResourceAsStream(resource.getPath());
             if (in == null)
                 return;
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFileFactory.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFileFactory.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 import javax.tools.StandardJavaFileManager;
 import javax.tools.StandardLocation;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.DocletException;
 
 /**
@@ -50,7 +50,7 @@
      * @param configuration the configuration for this doclet
      * @return the factory associated with this configuration
      */
-    public static synchronized DocFileFactory getFactory(Configuration configuration) {
+    public static synchronized DocFileFactory getFactory(BaseConfiguration configuration) {
         DocFileFactory f = configuration.docFileFactory;
         if (f == null) {
             JavaFileManager fm = configuration.getFileManager();
@@ -64,9 +64,9 @@
         return f;
     }
 
-    protected Configuration configuration;
+    protected BaseConfiguration configuration;
 
-    protected DocFileFactory(Configuration configuration) {
+    protected DocFileFactory(BaseConfiguration configuration) {
         this.configuration = configuration;
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFinder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFinder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
 import javax.lang.model.type.TypeMirror;
 
 import com.sun.source.doctree.DocTree;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.taglets.InheritableTaglet;
 
 /**
@@ -241,7 +241,7 @@
      *
      * @return an Output object representing the documentation that was found.
      */
-    public static Output search(Configuration configuration, Input input) {
+    public static Output search(BaseConfiguration configuration, Input input) {
         Output output = new Output();
         Utils utils = configuration.utils;
         if (input.isInheritDocTag) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,7 @@
 import javax.tools.DocumentationTool;
 
 import jdk.javadoc.doclet.Reporter;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 
 /**
  * Process and manage "-link" and "-linkoffline" to external packages. The
@@ -64,7 +64,7 @@
     /**
      * The global configuration information for this run.
      */
-    private final Configuration configuration;
+    private final BaseConfiguration configuration;
 
     /**
      * True if we are using -linkoffline and false if -link is used instead.
@@ -123,7 +123,7 @@
         }
     }
 
-    public Extern(Configuration configuration) {
+    public Extern(BaseConfiguration configuration) {
         this.configuration = configuration;
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Group.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Group.java	Wed Jul 05 23:37:13 2017 +0200
@@ -30,7 +30,7 @@
 import javax.lang.model.element.ModuleElement;
 import javax.lang.model.element.PackageElement;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
 
 
@@ -87,7 +87,7 @@
     /**
      * The global configuration information for this run.
      */
-    private final Configuration configuration;
+    private final BaseConfiguration configuration;
     private Messages messages;
 
     /**
@@ -101,7 +101,7 @@
         }
     }
 
-    public Group(Configuration configuration) {
+    public Group(BaseConfiguration configuration) {
         this.configuration = configuration;
         messages = configuration.getMessages();
     }
@@ -199,7 +199,7 @@
     }
 
     // Lazy init of the messages for now, because Group is created
-    // in Configuration before configuration is fully initialized.
+    // in BaseConfiguration before configuration is fully initialized.
     private void initMessages() {
         if (messages == null) {
             messages = configuration.getMessages();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ImplementedMethods.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ImplementedMethods.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, 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
@@ -31,7 +31,7 @@
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.TypeMirror;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 
 /**
  * For a given class method, build an array of interface methods which it
@@ -52,7 +52,7 @@
     private final TypeElement typeElement;
     private final ExecutableElement method;
 
-    public ImplementedMethods(ExecutableElement method, Configuration configuration) {
+    public ImplementedMethods(ExecutableElement method, BaseConfiguration configuration) {
         this.method = method;
         this.utils = configuration.utils;
         typeElement = utils.getEnclosingTypeElement(method);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/IndexBuilder.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
 import javax.lang.model.element.TypeElement;
 
 import jdk.javadoc.doclet.DocletEnvironment;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
 
 /**
@@ -73,7 +73,7 @@
      */
     private boolean javafx;
 
-    private final Configuration configuration;
+    private final BaseConfiguration configuration;
     private final Utils utils;
     private final Comparator<Element> comparator;
 
@@ -84,7 +84,7 @@
      * @param noDeprecated  true if -nodeprecated option is used,
      *                      false otherwise.
      */
-    public IndexBuilder(Configuration configuration, boolean noDeprecated) {
+    public IndexBuilder(BaseConfiguration configuration, boolean noDeprecated) {
         this(configuration, noDeprecated, false);
     }
 
@@ -96,7 +96,7 @@
      *                      false otherwise.
      * @param classesOnly   Include only classes in index.
      */
-    public IndexBuilder(Configuration configuration, boolean noDeprecated,
+    public IndexBuilder(BaseConfiguration configuration, boolean noDeprecated,
                         boolean classesOnly) {
         this.configuration  = configuration;
         this.utils = configuration.utils;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/MetaKeywords.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/MetaKeywords.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 
 /**
  * Provides methods for creating an array of class, method and
@@ -52,12 +52,12 @@
     /**
      * The global configuration information for this run.
      */
-    private final Configuration config;
+    private final BaseConfiguration config;
 
     /**
      * Constructor
      */
-    public MetaKeywords(Configuration configuration) {
+    public MetaKeywords(BaseConfiguration configuration) {
         config = configuration;
     }
 
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PackageListWriter.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PackageListWriter.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 import javax.lang.model.element.PackageElement;
 
 import jdk.javadoc.doclet.DocletEnvironment;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 
 
 /**
@@ -45,7 +45,7 @@
  */
 public class PackageListWriter {
 
-    private final Configuration configuration;
+    private final BaseConfiguration configuration;
     private final Utils utils;
     private final DocFile file;
 
@@ -54,7 +54,7 @@
      *
      * @param configuration the current configuration of the doclet.
      */
-    public PackageListWriter(Configuration configuration) {
+    public PackageListWriter(BaseConfiguration configuration) {
         file = DocFile.createFileForOutput(configuration, DocPaths.PACKAGE_LIST);
         this.configuration = configuration;
         this.utils = configuration.utils;
@@ -66,7 +66,7 @@
      * @param configuration the current configuration of the doclet.
      * @throws DocFileIOException if there is a problem writing the output
      */
-    public static void generate(Configuration configuration) throws DocFileIOException {
+    public static void generate(BaseConfiguration configuration) throws DocFileIOException {
         PackageListWriter packgen = new PackageListWriter(configuration);
         packgen.generatePackageListFile(configuration.docEnv);
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/StandardDocFileFactory.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/StandardDocFileFactory.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,7 +53,7 @@
 import javax.tools.StandardLocation;
 
 import com.sun.tools.javac.util.Assert;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 
 /**
  * Implementation of DocFileFactory using a {@link StandardJavaFileManager}.
@@ -68,7 +68,7 @@
     private final StandardJavaFileManager fileManager;
     private Path destDir;
 
-    public StandardDocFileFactory(Configuration configuration) {
+    public StandardDocFileFactory(BaseConfiguration configuration) {
         super(configuration);
         fileManager = (StandardJavaFileManager) configuration.getFileManager();
     }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/TypeElementCatalog.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/TypeElementCatalog.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
 import javax.lang.model.element.PackageElement;
 import javax.lang.model.element.TypeElement;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 
 /**
  * This class acts as an artificial container for classes specified on the command line when
@@ -88,7 +88,7 @@
      */
     private final Map<PackageElement, SortedSet<TypeElement>> interfaces;
 
-    private final Configuration configuration;
+    private final BaseConfiguration configuration;
     private final Utils utils;
     private final Comparator<Element> comparator;
 
@@ -97,7 +97,7 @@
      *
      * @param typeElements the array of TypeElements to catalog
      */
-    public TypeElementCatalog(Iterable<TypeElement> typeElements, Configuration config) {
+    public TypeElementCatalog(Iterable<TypeElement> typeElements, BaseConfiguration config) {
         this(config);
         for (TypeElement typeElement : typeElements) {
             addTypeElement(typeElement);
@@ -108,7 +108,7 @@
      * Construct a new TypeElementCatalog.
      *
      */
-    public TypeElementCatalog(Configuration config) {
+    public TypeElementCatalog(BaseConfiguration config) {
         this.configuration = config;
         this.utils = config.utils;
         comparator = utils.makeGeneralPurposeComparator();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java	Wed Jul 05 23:37:13 2017 +0200
@@ -78,8 +78,8 @@
 import com.sun.source.util.DocTrees;
 import com.sun.source.util.TreePath;
 import com.sun.tools.javac.model.JavacTypes;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.CommentUtils.DocCommentDuo;
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
 import jdk.javadoc.internal.doclets.toolkit.WorkArounds;
 import jdk.javadoc.internal.tool.DocEnvImpl;
@@ -104,14 +104,14 @@
  * @author Jamie Ho
  */
 public class Utils {
-    public final Configuration configuration;
+    public final BaseConfiguration configuration;
     public final Messages messages;
     public final DocTrees docTrees;
     public final Elements elementUtils;
     public final Types typeUtils;
     public final JavaScriptScanner javaScriptScanner;
 
-    public Utils(Configuration c) {
+    public Utils(BaseConfiguration c) {
         configuration = c;
         messages = configuration.getMessages();
         elementUtils = c.docEnv.getElementUtils();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberMap.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/VisibleMemberMap.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,7 @@
 import com.sun.source.doctree.DocCommentTree;
 import com.sun.source.doctree.DocTree;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Messages;
 
 /**
@@ -126,7 +126,7 @@
     /**
      * The configuration this VisibleMemberMap was created with.
      */
-    private final Configuration configuration;
+    private final BaseConfiguration configuration;
     private final Messages messages;
     private final Utils utils;
     private final Comparator<Element> comparator;
@@ -147,7 +147,7 @@
      */
     public VisibleMemberMap(TypeElement typeElement,
                             Kind kind,
-                            Configuration configuration) {
+                            BaseConfiguration configuration) {
         this.typeElement = typeElement;
         this.kind = kind;
         this.configuration = configuration;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkInfo.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkInfo.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,7 +29,7 @@
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.TypeMirror;
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 import jdk.javadoc.internal.doclets.toolkit.Content;
 
 /**
@@ -140,7 +140,7 @@
      * @param configuration the current configuration of the doclet.
      * @return the label for this class link.
      */
-    public Content getClassLinkLabel(Configuration configuration) {
+    public Content getClassLinkLabel(BaseConfiguration configuration) {
         if (label != null && !label.isEmpty()) {
             return label;
         } else if (isLinkable()) {
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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;
--- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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;
 
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ArgTokenizer.java	Wed Jul 05 23:37:13 2017 +0200
@@ -121,6 +121,17 @@
     }
 
     /**
+     * Is the specified option allowed.
+     *
+     * @param opt the option to check
+     * @return true if the option is allowed
+     */
+    boolean isAllowedOption(String opt) {
+        Boolean has = options.get(opt);
+        return has != null;
+    }
+
+    /**
      * Has the specified option been encountered.
      *
      * @param opt the option to check
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java	Wed Jul 05 23:37:13 2017 +0200
@@ -90,7 +90,6 @@
 import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
 import static java.nio.file.StandardOpenOption.WRITE;
 import java.util.MissingResourceException;
-import java.util.Optional;
 import java.util.ResourceBundle;
 import java.util.ServiceLoader;
 import java.util.Spliterators;
@@ -126,6 +125,7 @@
 public class JShellTool implements MessageHandler {
 
     private static final Pattern LINEBREAK = Pattern.compile("\\R");
+    private static final Pattern ID = Pattern.compile("[se]?\\d+([-\\s].*)?");
             static final String RECORD_SEPARATOR = "\u241E";
     private static final String RB_NAME_PREFIX  = "jdk.internal.jshell.tool.resources";
     private static final String VERSION_RB_NAME = RB_NAME_PREFIX + ".version";
@@ -1189,36 +1189,54 @@
         }
     }
 
-    private void processCommand(String cmd) {
-        if (cmd.startsWith("/-")) {
+    /**
+     * Process a command (as opposed to a snippet) -- things that start with
+     * slash.
+     *
+     * @param input
+     */
+    private void processCommand(String input) {
+        if (input.startsWith("/-")) {
             try {
                 //handle "/-[number]"
-                cmdUseHistoryEntry(Integer.parseInt(cmd.substring(1)));
+                cmdUseHistoryEntry(Integer.parseInt(input.substring(1)));
                 return ;
             } catch (NumberFormatException ex) {
                 //ignore
             }
         }
-        String arg = "";
-        int idx = cmd.indexOf(' ');
+        String cmd;
+        String arg;
+        int idx = input.indexOf(' ');
         if (idx > 0) {
-            arg = cmd.substring(idx + 1).trim();
-            cmd = cmd.substring(0, idx);
+            arg = input.substring(idx + 1).trim();
+            cmd = input.substring(0, idx);
+        } else {
+            cmd = input;
+            arg = "";
         }
+        // find the command as a "real command", not a pseudo-command or doc subject
         Command[] candidates = findCommand(cmd, c -> c.kind.isRealCommand);
         switch (candidates.length) {
             case 0:
-                if (!rerunHistoryEntryById(cmd.substring(1))) {
-                    errormsg("jshell.err.no.such.command.or.snippet.id", cmd);
+                // not found, it is either a snippet command or an error
+                if (ID.matcher(cmd.substring(1)).matches()) {
+                    // it is in the form of a snipppet id, see if it is a valid history reference
+                    rerunHistoryEntriesById(input);
+                } else {
+                    errormsg("jshell.err.invalid.command", cmd);
                     fluffmsg("jshell.msg.help.for.help");
-                }   break;
+                }
+                break;
             case 1:
                 Command command = candidates[0];
                 // If comand was successful and is of a replayable kind, add it the replayable history
                 if (command.run.apply(arg) && command.kind == CommandKind.REPLAY) {
                     addToReplayHistory((command.command + " " + arg).trim());
-                }   break;
+                }
+                break;
             default:
+                // command if too short (ambigous), show the possibly matches
                 errormsg("jshell.err.command.ambiguous", cmd,
                         Arrays.stream(candidates).map(c -> c.command).collect(Collectors.joining(", ")));
                 fluffmsg("jshell.msg.help.for.help");
@@ -1701,6 +1719,9 @@
         registerCommand(new Command("context",
                 "help.context",
                 CommandKind.HELP_SUBJECT));
+        registerCommand(new Command("rerun",
+                "help.rerun",
+                CommandKind.HELP_SUBJECT));
 
         commandCompletions = new ContinuousCompletionProvider(
                 commands.values().stream()
@@ -2247,6 +2268,20 @@
             Predicate<Snippet> defFilter, String rawargs, String cmd) {
         ArgTokenizer at = new ArgTokenizer(cmd, rawargs.trim());
         at.allowedOptions("-all", "-start");
+        return argsOptionsToSnippets(snippetSupplier, defFilter, at);
+    }
+
+    /**
+     * Convert user arguments to a Stream of snippets referenced by those
+     * arguments (or lack of arguments).
+     *
+     * @param snippets the base list of possible snippets
+     * @param defFilter the filter to apply to the arguments if no argument
+     * @param at the ArgTokenizer, with allowed options set
+     * @return
+     */
+    private <T extends Snippet> Stream<T> argsOptionsToSnippets(Supplier<Stream<T>> snippetSupplier,
+            Predicate<Snippet> defFilter, ArgTokenizer at) {
         List<String> args = new ArrayList<>();
         String s;
         while ((s = at.next()) != null) {
@@ -2263,11 +2298,11 @@
             errormsg("jshell.err.conflicting.options", at.whole());
             return null;
         }
-        if (at.hasOption("-all")) {
+        if (at.isAllowedOption("-all") && at.hasOption("-all")) {
             // all snippets including start-up, failed, and overwritten
             return snippetSupplier.get();
         }
-        if (at.hasOption("-start")) {
+        if (at.isAllowedOption("-start") && at.hasOption("-start")) {
             // start-up snippets
             return snippetSupplier.get()
                     .filter(this::inStartUp);
@@ -2277,54 +2312,227 @@
             return snippetSupplier.get()
                     .filter(defFilter);
         }
-        return argsToSnippets(snippetSupplier, args);
+        return new ArgToSnippets<>(snippetSupplier).argsToSnippets(args);
     }
 
     /**
-     * Convert user arguments to a Stream of snippets referenced by those
-     * arguments.
+     * Support for converting arguments that are definition names, snippet ids,
+     * or snippet id ranges into a stream of snippets,
      *
-     * @param snippetSupplier the base list of possible snippets
-     * @param args the user's argument to the command, maybe be the empty list
-     * @return a Stream of referenced snippets or null if no matches to specific
-     * arg
+     * @param <T> the snipper subtype
      */
-    private <T extends Snippet> Stream<T> argsToSnippets(Supplier<Stream<T>> snippetSupplier,
-            List<String> args) {
-        Stream<T> result = null;
-        for (String arg : args) {
+    private class ArgToSnippets<T extends Snippet> {
+
+        // the supplier of snippet streams
+        final Supplier<Stream<T>> snippetSupplier;
+        // these two are parallel, and lazily filled if a range is encountered
+        List<T> allSnippets;
+        String[] allIds = null;
+
+        /**
+         *
+         * @param snippetSupplier the base list of possible snippets
+        */
+        ArgToSnippets(Supplier<Stream<T>> snippetSupplier) {
+            this.snippetSupplier = snippetSupplier;
+        }
+
+        /**
+         * Convert user arguments to a Stream of snippets referenced by those
+         * arguments.
+         *
+         * @param args the user's argument to the command, maybe be the empty
+         * list
+         * @return a Stream of referenced snippets or null if no matches to
+         * specific arg
+         */
+        Stream<T> argsToSnippets(List<String> args) {
+            Stream<T> result = null;
+            for (String arg : args) {
+                // Find the best match
+                Stream<T> st = argToSnippets(arg);
+                if (st == null) {
+                    return null;
+                } else {
+                    result = (result == null)
+                            ? st
+                            : Stream.concat(result, st);
+                }
+            }
+            return result;
+        }
+
+        /**
+         * Convert a user argument to a Stream of snippets referenced by the
+         * argument.
+         *
+         * @param snippetSupplier the base list of possible snippets
+         * @param arg the user's argument to the command
+         * @return a Stream of referenced snippets or null if no matches to
+         * specific arg
+         */
+        Stream<T> argToSnippets(String arg) {
+            if (arg.contains("-")) {
+                return range(arg);
+            }
             // Find the best match
             Stream<T> st = layeredSnippetSearch(snippetSupplier, arg);
             if (st == null) {
-                Stream<Snippet> est = layeredSnippetSearch(state::snippets, arg);
-                if (est == null) {
+                badSnippetErrormsg(arg);
+                return null;
+            } else {
+                return st;
+            }
+        }
+
+        /**
+         * Look for inappropriate snippets to give best error message
+         *
+         * @param arg the bad snippet arg
+         * @param errKey the not found error key
+         */
+        void badSnippetErrormsg(String arg) {
+            Stream<Snippet> est = layeredSnippetSearch(state::snippets, arg);
+            if (est == null) {
+                if (ID.matcher(arg).matches()) {
+                    errormsg("jshell.err.no.snippet.with.id", arg);
+                } else {
                     errormsg("jshell.err.no.such.snippets", arg);
-                } else {
-                    errormsg("jshell.err.the.snippet.cannot.be.used.with.this.command",
-                            arg, est.findFirst().get().source());
                 }
-                return null;
-            }
-            if (result == null) {
-                result = st;
             } else {
-                result = Stream.concat(result, st);
+                errormsg("jshell.err.the.snippet.cannot.be.used.with.this.command",
+                        arg, est.findFirst().get().source());
             }
         }
-        return result;
-    }
-
-    private <T extends Snippet> Stream<T> layeredSnippetSearch(Supplier<Stream<T>> snippetSupplier, String arg) {
-        return nonEmptyStream(
-                // the stream supplier
-                snippetSupplier,
-                // look for active user declarations matching the name
-                sn -> isActive(sn) && matchingDeclaration(sn, arg),
-                // else, look for any declarations matching the name
-                sn -> matchingDeclaration(sn, arg),
-                // else, look for an id of this name
-                sn -> sn.id().equals(arg)
-        );
+
+        /**
+         * Search through the snippets for the best match to the id/name.
+         *
+         * @param <R> the snippet type
+         * @param aSnippetSupplier the supplier of snippet streams
+         * @param arg the arg to match
+         * @return a Stream of referenced snippets or null if no matches to
+         * specific arg
+         */
+        <R extends Snippet> Stream<R> layeredSnippetSearch(Supplier<Stream<R>> aSnippetSupplier, String arg) {
+            return nonEmptyStream(
+                    // the stream supplier
+                    aSnippetSupplier,
+                    // look for active user declarations matching the name
+                    sn -> isActive(sn) && matchingDeclaration(sn, arg),
+                    // else, look for any declarations matching the name
+                    sn -> matchingDeclaration(sn, arg),
+                    // else, look for an id of this name
+                    sn -> sn.id().equals(arg)
+            );
+        }
+
+        /**
+         * Given an id1-id2 range specifier, return a stream of snippets within
+         * our context
+         *
+         * @param arg the range arg
+         * @return a Stream of referenced snippets or null if no matches to
+         * specific arg
+         */
+        Stream<T> range(String arg) {
+            int dash = arg.indexOf('-');
+            String iid = arg.substring(0, dash);
+            String tid = arg.substring(dash + 1);
+            int iidx = snippetIndex(iid);
+            if (iidx < 0) {
+                return null;
+            }
+            int tidx = snippetIndex(tid);
+            if (tidx < 0) {
+                return null;
+            }
+            if (tidx < iidx) {
+                errormsg("jshell.err.end.snippet.range.less.than.start", iid, tid);
+                return null;
+            }
+            return allSnippets.subList(iidx, tidx+1).stream();
+        }
+
+        /**
+         * Lazily initialize the id mapping -- needed only for id ranges.
+         */
+        void initIdMapping() {
+            if (allIds == null) {
+                allSnippets = snippetSupplier.get()
+                        .sorted((a, b) -> order(a) - order(b))
+                        .collect(toList());
+                allIds = allSnippets.stream()
+                        .map(sn -> sn.id())
+                        .toArray(n -> new String[n]);
+            }
+        }
+
+        /**
+         * Return all the snippet ids -- within the context, and in order.
+         *
+         * @return the snippet ids
+         */
+        String[] allIds() {
+            initIdMapping();
+            return allIds;
+        }
+
+        /**
+         * Establish an order on snippet ids.  All startup snippets are first,
+         * all error snippets are last -- within that is by snippet number.
+         *
+         * @param id the id string
+         * @return an ordering int
+         */
+        int order(String id) {
+            try {
+                switch (id.charAt(0)) {
+                    case 's':
+                        return Integer.parseInt(id.substring(1));
+                    case 'e':
+                        return 0x40000000 + Integer.parseInt(id.substring(1));
+                    default:
+                        return 0x20000000 + Integer.parseInt(id);
+                }
+            } catch (Exception ex) {
+                return 0x60000000;
+            }
+        }
+
+        /**
+         * Establish an order on snippets, based on its snippet id. All startup
+         * snippets are first, all error snippets are last -- within that is by
+         * snippet number.
+         *
+         * @param sn the id string
+         * @return an ordering int
+         */
+        int order(Snippet sn) {
+            return order(sn.id());
+        }
+
+        /**
+         * Find the index into the parallel allSnippets and allIds structures.
+         *
+         * @param s the snippet id name
+         * @return the index, or, if not found, report the error and return a
+         * negative number
+         */
+        int snippetIndex(String s) {
+            int idx = Arrays.binarySearch(allIds(), 0, allIds().length, s,
+                    (a, b) -> order(a) - order(b));
+            if (idx < 0) {
+                // the id is not in the snippet domain, find the right error to report
+                if (!ID.matcher(s).matches()) {
+                    errormsg("jshell.err.range.requires.id", s);
+                } else {
+                    badSnippetErrormsg(s);
+                }
+            }
+            return idx;
+        }
+
     }
 
     private boolean cmdDrop(String rawargs) {
@@ -2342,24 +2550,13 @@
             errormsg("jshell.err.drop.arg");
             return false;
         }
-        Stream<Snippet> stream = argsToSnippets(this::dropableSnippets, args);
+        Stream<Snippet> stream = new ArgToSnippets<>(this::dropableSnippets).argsToSnippets(args);
         if (stream == null) {
             // Snippet not found. Error already printed
             fluffmsg("jshell.msg.see.classes.etc");
             return false;
         }
-        List<Snippet> snippets = stream.collect(toList());
-        if (snippets.size() > args.size()) {
-            // One of the args references more thean one snippet
-            errormsg("jshell.err.drop.ambiguous");
-            fluffmsg("jshell.msg.use.one.of", snippets.stream()
-                    .map(sn -> String.format("\n/drop %-5s :   %s", sn.id(), sn.source().replace("\n", "\n       ")))
-                    .collect(Collectors.joining(", "))
-            );
-            return false;
-        }
-        snippets.stream()
-                .forEach(sn -> state.drop(sn).forEach(this::handleEvent));
+        stream.forEach(sn -> state.drop(sn).forEach(this::handleEvent));
         return true;
     }
 
@@ -2690,37 +2887,38 @@
     }
 
     private boolean cmdSave(String rawargs) {
-        ArgTokenizer at = new ArgTokenizer("/save", rawargs.trim());
-        at.allowedOptions("-all", "-start", "-history");
-        String filename = at.next();
-        if (filename == null) {
+        // The filename to save to is the last argument, extract it
+        String[] args = rawargs.split("\\s");
+        String filename = args[args.length - 1];
+        if (filename.isEmpty()) {
             errormsg("jshell.err.file.filename", "/save");
             return false;
         }
-        if (!checkOptionsAndRemainingInput(at)) {
-            return false;
-        }
-        if (at.optionCount() > 1) {
-            errormsg("jshell.err.conflicting.options", at.whole());
+        // All the non-filename arguments are the specifier of what to save
+        String srcSpec = Arrays.stream(args, 0, args.length - 1)
+                .collect(Collectors.joining("\n"));
+        // From the what to save specifier, compute the snippets (as a stream)
+        ArgTokenizer at = new ArgTokenizer("/save", srcSpec);
+        at.allowedOptions("-all", "-start", "-history");
+        Stream<Snippet> snippetStream = argsOptionsToSnippets(state::snippets, this::mainActive, at);
+        if (snippetStream == null) {
+            // error occurred, already reported
             return false;
         }
         try (BufferedWriter writer = Files.newBufferedWriter(toPathResolvingUserHome(filename),
                 Charset.defaultCharset(),
                 CREATE, TRUNCATE_EXISTING, WRITE)) {
             if (at.hasOption("-history")) {
+                // they want history (commands and snippets), ignore the snippet stream
                 for (String s : input.currentSessionHistory()) {
                     writer.write(s);
                     writer.write("\n");
                 }
-            } else if (at.hasOption("-start")) {
-                writer.append(startup.toString());
             } else {
-                String sources = (at.hasOption("-all")
-                        ? state.snippets()
-                        : state.snippets().filter(this::mainActive))
+                // write the snippet stream to the file
+                writer.write(snippetStream
                         .map(Snippet::source)
-                        .collect(Collectors.joining("\n"));
-                writer.write(sources);
+                        .collect(Collectors.joining("\n")));
             }
         } catch (FileNotFoundException e) {
             errormsg("jshell.err.file.not.found", "/save", filename, e.getMessage());
@@ -2837,14 +3035,21 @@
         return true;
     }
 
-    private boolean rerunHistoryEntryById(String id) {
-        Optional<Snippet> snippet = state.snippets()
-            .filter(s -> s.id().equals(id))
-            .findFirst();
-        return snippet.map(s -> {
-            rerunSnippet(s);
-            return true;
-        }).orElse(false);
+    /**
+     * Handle snippet reevaluation commands: {@code /<id>}. These commands are a
+     * sequence of ids and id ranges (names are permitted, though not in the
+     * first position. Support for names is purposely not documented).
+     *
+     * @param rawargs the whole command including arguments
+     */
+    private void rerunHistoryEntriesById(String rawargs) {
+        ArgTokenizer at = new ArgTokenizer("/<id>", rawargs.trim().substring(1));
+        at.allowedOptions();
+        Stream<Snippet> stream = argsOptionsToSnippets(state::snippets, sn -> true, at);
+        if (stream != null) {
+            // successfully parsed, rerun snippets
+            stream.forEach(sn -> rerunSnippet(sn));
+        }
     }
 
     private void rerunSnippet(Snippet snippet) {
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties	Wed Jul 05 23:37:13 2017 +0200
@@ -50,7 +50,7 @@
 jshell.err.startup.unexpected.exception = Unexpected exception reading start-up: {0}
 jshell.err.unexpected.exception = Unexpected exception: {0}
 
-jshell.err.no.such.command.or.snippet.id = No such command or snippet id: {0}
+jshell.err.invalid.command = Invalid command: {0}
 jshell.err.command.ambiguous = Command: ''{0}'' is ambiguous: {1}
 jshell.msg.set.restore = Setting new options and restoring state.
 jshell.msg.set.editor.set = Editor set to: {0}
@@ -105,10 +105,13 @@
 Subjects:\n\
 \n
 
+jshell.err.no.snippet.with.id = No snippet with id: {0}
+jshell.err.end.snippet.range.less.than.start = End of snippet range less than start: {0} - {1}
+jshell.err.range.requires.id = Snippet ranges require snippet ids: {0}
+
 jshell.err.drop.arg =\
 In the /drop argument, please specify an import, variable, method, or class to drop.\n\
 Specify by id or name. Use /list to see ids. Use /reset to reset all state.
-jshell.err.drop.ambiguous = The argument references more than one import, variable, method, or class.
 jshell.err.failed = Failed.
 jshell.msg.native.method = Native Method
 jshell.msg.unknown.source = Unknown Source
@@ -225,7 +228,11 @@
 /list <name>\n\t\
     List snippets with the specified name (preference for active snippets)\n\n\
 /list <id>\n\t\
-    List the snippet with the specified snippet id
+    List the snippet with the specified snippet id\n\n\
+/list <id> <id>...\n\t\
+    List the snippets with the specified snippet ids\n\n\
+/list <id>-<id>\n\t\
+    List the snippets within the range of snippet ids
 
 help.edit.summary = edit a source entry referenced by name or id
 help.edit.args = <name or id>
@@ -238,6 +245,10 @@
     Edit the snippet or snippets with the specified name (preference for active snippets)\n\n\
 /edit <id>\n\t\
     Edit the snippet with the specified snippet id\n\n\
+/edit <id> <id>...\n\t\
+    Edit the snippets with the specified snippet ids\n\n\
+/edit <id>-<id>\n\t\
+    Edit the snippets within the range of snippet ids\n\n\
 /edit\n\t\
     Edit the currently active snippets of code that you typed or read with /open
 
@@ -249,7 +260,11 @@
 /drop <name>\n\t\
     Drop the snippet with the specified name\n\n\
 /drop <id>\n\t\
-    Drop the snippet with the specified snippet id
+    Drop the snippet with the specified snippet id\n\n\
+/drop <id> <id>...\n\t\
+    Drop the snippets with the specified snippet ids\n\n\
+/drop <id>-<id>\n\t\
+    Drop the snippets within the range of snippet ids
 
 help.save.summary = Save snippet source to a file.
 help.save.args = [-all|-history|-start] <file>
@@ -264,7 +279,13 @@
 /save -history <file>\n\t\
     Save the sequential history of all commands and snippets entered since jshell was launched.\n\n\
 /save -start <file>\n\t\
-    Save the current start-up definitions to the file.
+    Save the current start-up definitions to the file.\n\n\
+/save <id> <file>\n\t\
+    Save the snippet with the specified snippet id\n\n\
+/save <id> <id>... <file>\n\t\
+    Save the snippets with the specified snippet ids\n\n\
+/save <id>-<id> <file>\n\t\
+    Save the snippets within the range of snippet ids
 
 help.open.summary = open a file as source input
 help.open.args = <file>
@@ -285,6 +306,10 @@
     List jshell variables with the specified name (preference for active variables)\n\n\
 /vars <id>\n\t\
     List the jshell variable with the specified snippet id\n\n\
+/vars <id> <id>... <file>\n\t\
+    List the jshell variables with the specified snippet ids\n\n\
+/vars <id>-<id> <file>\n\t\
+    List the jshell variables within the range of snippet ids\n\n\
 /vars -start\n\t\
     List the automatically added start-up jshell variables\n\n\
 /vars -all\n\t\
@@ -301,6 +326,10 @@
     List jshell methods with the specified name (preference for active methods)\n\n\
 /methods <id>\n\t\
     List the jshell method with the specified snippet id\n\n\
+/methods <id> <id>... <file>\n\t\
+    List jshell methods with the specified snippet ids\n\n\
+/methods <id>-<id> <file>\n\t\
+    List jshell methods within the range of snippet ids\n\n\
 /methods -start\n\t\
     List the automatically added start-up jshell methods\n\n\
 /methods -all\n\t\
@@ -317,6 +346,10 @@
     List jshell types with the specified name (preference for active types)\n\n\
 /types <id>\n\t\
     List the jshell type with the specified snippet id\n\n\
+/types <id> <id>... <file>\n\t\
+    List jshell types with the specified snippet ids\n\n\
+/types <id>-<id> <file>\n\t\
+    List jshell types within the range of snippet ids\n\n\
 /types -start\n\t\
     List the automatically added start-up jshell types\n\n\
 /types -all\n\t\
@@ -461,17 +494,24 @@
 /? <subject>\n\t\
      Display information about the specified help subject. Example: /? intro
 
-help.bang.summary = re-run last snippet
+help.bang.summary = rerun last snippet -- see /help rerun
 help.bang.args =
 help.bang =\
 Reevaluate the most recently entered snippet.
 
-help.id.summary = re-run snippet by id
+help.id.summary = rerun snippets by id or id range -- see /help rerun
 help.id.args =
 help.id =\
-Reevaluate the snippet specified by the id.
+/<id> <id> <id>\n\
+\n\
+/<id>-<id>\n\
+\n\
+Reevaluate the snippets specified by the id or id range.\n\
+An id range is represented as a two ids separated by a hyphen, e.g.:  3-17\n\
+Start-up and error snippets maybe used, e.g.:  s3-s9    or   e1-e4\n\
+Any number of ids or id ranges may be used, e.g.:  /3-7 s4 14-16 e2
 
-help.previous.summary = re-run n-th previous snippet
+help.previous.summary = rerun n-th previous snippet -- see /help rerun
 help.previous.args =
 help.previous =\
 Reevaluate the n-th most recently entered snippet.
@@ -509,7 +549,7 @@
         then release and press "i", and jshell will propose possible imports\n\t\t\
         which will resolve the identifier based on the content of the specified classpath.
 
-help.context.summary = the evaluation context options for /env /reload and /reset
+help.context.summary = a description of the evaluation context options for /env /reload and /reset
 help.context =\
 These options configure the evaluation context, they can be specified when\n\
 jshell is started: on the command-line, or restarted with the commands /env,\n\
@@ -540,6 +580,38 @@
 On the command-line these options must have two dashes, e.g.: --module-path\n\
 On jshell commands they can have one or two dashes, e.g.: -module-path\n\
 
+help.rerun.summary = a description of ways to re-evaluate previously entered snippets
+help.rerun =\
+There are four ways to re-evaluate previously entered snippets.\n\
+The last snippet can be re-evaluated using: /!\n\
+The n-th previous snippet can be re-evaluated by slash-minus and the digits of n, e.g.:  /-4\n\
+For example:\n\
+\n\
+    \tjshell> 2 + 2\n\
+    \t$1 ==> 4\n\
+\n\
+    \tjshell> /!\n\
+    \t2 + 2\n\
+    \t$2 ==> 4\n\
+\n\
+    \tjshell> int z\n\
+    \tz ==> 0\n\
+\n\
+    \tjshell> /-1\n\
+    \tint z;\n\
+    \tz ==> 0\n\
+\n\
+    \tjshell> /-4\n\
+    \t2 + 2\n\
+    \t$5 ==> 4\n\
+\n\
+The snippets to re-evaluate may be specified by snippet id or id range.\n\
+An id range is represented as a two ids separated by a hyphen, e.g.:  3-17\n\
+Start-up and error snippets maybe used, e.g.:  s3-s9    or   e1-e4\n\
+Any number of ids or id ranges may be used, e.g.:  /3-7 s4 14-16 e2\n\
+\n\
+Finally, you can search backwards through history by entering ctrl-R followed by the string to search for.
+
 help.set._retain = \
 The '-retain' option saves a setting so that it is used in future sessions.\n\
 The -retain option can be used on the following forms of /set:\n\n\t\
--- a/langtools/test/ProblemList.txt	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/ProblemList.txt	Wed Jul 05 23:37:13 2017 +0200
@@ -53,6 +53,7 @@
 tools/javac/annotations/typeAnnotations/referenceinfos/Lambda.java              8057687    generic-all    emit correct byte code an attributes for type annotations
 tools/javac/annotations/typeAnnotations/referenceinfos/NestedTypes.java         8057687    generic-all    emit correct byte code an attributes for type annotations
 tools/javac/warnings/suppress/TypeAnnotations.java                              8057683    generic-all    improve ordering of errors with type annotations
+tools/javac/modules/SourceInSymlinkTest.java                                    8180263    windows-all    fails when run on a subst drive
 tools/javac/modules/T8159439/NPEForModuleInfoWithNonZeroSuperClassTest.java     8160396    generic-all    current version of jtreg needs a new promotion to include lastes version of ASM
 
 ###########################################################################
--- a/langtools/test/jdk/javadoc/tool/T4696488.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/jdk/javadoc/tool/T4696488.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,7 @@
  * @run main T4696488 T4696488.java
  */
 
-import jdk.javadoc.internal.doclets.toolkit.Configuration;
+import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration;
 
 public class T4696488 {
 
@@ -49,7 +49,7 @@
     }
 
     private static void assertAddTrailingFileSep(String input, String expectedOutput) {
-        String output = Configuration.addTrailingFileSep(input);
+        String output = BaseConfiguration.addTrailingFileSep(input);
         if (!expectedOutput.equals(output)) {
             throw new Error("expected " + expectedOutput + " but was " + output);
         }
--- a/langtools/test/jdk/jshell/CommandCompletionTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/jdk/jshell/CommandCompletionTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8144095 8164825 8169818 8153402 8165405 8177079 8178013
+ * @bug 8144095 8164825 8169818 8153402 8165405 8177079 8178013 8167554
  * @summary Test Command Completion
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -162,13 +162,13 @@
                 "/edit ", "/env ", "/exit ",
                 "/help ", "/history ", "/imports ",
                 "/list ", "/methods ", "/open ", "/reload ", "/reset ",
-                "/save ", "/set ", "/types ", "/vars ", "context ", "intro ", "shortcuts "),
+                "/save ", "/set ", "/types ", "/vars ", "context ", "intro ", "rerun ", "shortcuts "),
                 a -> assertCompletion(a, "/? |", false,
                 "/! ", "/-<n> ", "/<id> ", "/? ", "/drop ",
                 "/edit ", "/env ", "/exit ",
                 "/help ", "/history ", "/imports ",
                 "/list ", "/methods ", "/open ", "/reload ", "/reset ",
-                "/save ", "/set ", "/types ", "/vars ", "context ", "intro ", "shortcuts "),
+                "/save ", "/set ", "/types ", "/vars ", "context ", "intro ", "rerun ", "shortcuts "),
                 a -> assertCompletion(a, "/help /s|", false,
                 "/save ", "/set "),
                 a -> assertCompletion(a, "/help /set |", false,
--- a/langtools/test/jdk/jshell/EditorTestBase.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/jdk/jshell/EditorTestBase.java	Wed Jul 05 23:37:13 2017 +0200
@@ -73,7 +73,7 @@
         for (String edit : new String[] {"/ed", "/edit"}) {
             test(new String[]{"--no-startup"},
                     a -> assertCommandOutputStartsWith(a, edit + " 1",
-                            "|  No such snippet: 1"),
+                            "|  No snippet with id: 1"),
                     a -> assertCommandOutputStartsWith(a, edit + " unknown",
                             "|  No such snippet: unknown")
             );
--- a/langtools/test/jdk/jshell/MergedTabShiftTabCommandTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/jdk/jshell/MergedTabShiftTabCommandTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -66,17 +66,17 @@
                             Pattern.quote(getResource("jshell.console.see.next.command.doc")) + "\n" +
                             "\r\u0005/");
 
-            inputSink.write("lis\011");
-            waitOutput(out, "list $");
+            inputSink.write("ed\011");
+            waitOutput(out, "edit $");
 
             inputSink.write("\011");
             waitOutput(out, ".*-all.*" +
                             "\n\n" + Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n\r\u0005/");
             inputSink.write("\011");
-            waitOutput(out, Pattern.quote(getResource("help.list.summary")) + "\n\n" +
-                            Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/list ");
+            waitOutput(out, Pattern.quote(getResource("help.edit.summary")) + "\n\n" +
+                            Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/edit ");
             inputSink.write("\011");
-            waitOutput(out, Pattern.quote(getResource("help.list").replaceAll("\t", "    ")));
+            waitOutput(out, Pattern.quote(getResource("help.edit").replaceAll("\t", "    ")));
 
             inputSink.write("\u0003/env \011");
             waitOutput(out, "\u0005/env -\n" +
--- a/langtools/test/jdk/jshell/ToolBasicTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/jdk/jshell/ToolBasicTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 8154714 8166649 8167643 8170162 8172102 8165405 8174796 8174797 8175304
+ * @bug 8143037 8142447 8144095 8140265 8144906 8146138 8147887 8147886 8148316 8148317 8143955 8157953 8080347 8154714 8166649 8167643 8170162 8172102 8165405 8174796 8174797 8175304 8167554 8180508
  * @summary Tests for Basic tests for REPL tool
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -190,8 +190,8 @@
 
     public void testRerun() {
         test(false, new String[] {"--no-startup"},
-                (a) -> assertCommand(a, "/0", "|  No such command or snippet id: /0\n|  Type /help for help."),
-                (a) -> assertCommand(a, "/5", "|  No such command or snippet id: /5\n|  Type /help for help.")
+                (a) -> assertCommand(a, "/0", "|  No snippet with id: 0"),
+                (a) -> assertCommand(a, "/5", "|  No snippet with id: 5")
         );
         String[] codes = new String[] {
                 "int a = 0;", // var
@@ -252,9 +252,9 @@
         );
 
         test(false, new String[] {"--no-startup"},
-                (a) -> assertCommand(a, "/s1", "|  No such command or snippet id: /s1\n|  Type /help for help."),
-                (a) -> assertCommand(a, "/1", "|  No such command or snippet id: /1\n|  Type /help for help."),
-                (a) -> assertCommand(a, "/e1", "|  No such command or snippet id: /e1\n|  Type /help for help.")
+                (a) -> assertCommand(a, "/s1", "|  No snippet with id: s1"),
+                (a) -> assertCommand(a, "/1", "|  No snippet with id: 1"),
+                (a) -> assertCommand(a, "/e1", "|  No snippet with id: e1")
         );
     }
 
@@ -481,17 +481,19 @@
     public void testSave() throws IOException {
         Compiler compiler = new Compiler();
         Path path = compiler.getPath("testSave.repl");
-        List<String> list = Arrays.asList(
-                "int a;",
-                "class A { public String toString() { return \"A\"; } }"
-        );
-        test(
-                (a) -> assertVariable(a, "int", "a"),
-                (a) -> assertCommand(a, "()", null, null, null, "", ""),
-                (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"),
-                (a) -> assertCommand(a, "/save " + path.toString(), "")
-        );
-        assertEquals(Files.readAllLines(path), list);
+        {
+            List<String> list = Arrays.asList(
+                    "int a;",
+                    "class A { public String toString() { return \"A\"; } }"
+            );
+            test(
+                    (a) -> assertVariable(a, "int", "a"),
+                    (a) -> assertCommand(a, "()", null, null, null, "", ""),
+                    (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"),
+                    (a) -> assertCommand(a, "/save " + path.toString(), "")
+            );
+            assertEquals(Files.readAllLines(path), list);
+        }
         {
             List<String> output = new ArrayList<>();
             test(
@@ -499,28 +501,47 @@
                     (a) -> assertCommand(a, "()", null, null, null, "", ""),
                     (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"),
                     (a) -> assertCommandCheckOutput(a, "/list -all", (out) ->
-                            output.addAll(Stream.of(out.split("\n"))
-                                    .filter(str -> !str.isEmpty())
-                                    .map(str -> str.substring(str.indexOf(':') + 2))
-                                    .filter(str -> !str.startsWith("/"))
-                                    .collect(Collectors.toList()))),
+                                    output.addAll(Stream.of(out.split("\n"))
+                            .filter(str -> !str.isEmpty())
+                            .map(str -> str.substring(str.indexOf(':') + 2))
+                            .filter(str -> !str.startsWith("/"))
+                            .collect(Collectors.toList()))),
                     (a) -> assertCommand(a, "/save -all " + path.toString(), "")
             );
             assertEquals(Files.readAllLines(path), output);
         }
-        List<String> output = new ArrayList<>();
-        test(
-                (a) -> assertVariable(a, "int", "a"),
-                (a) -> assertCommand(a, "()", null, null, null, "", ""),
-                (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"),
-                (a) -> assertCommandCheckOutput(a, "/history", (out) ->
-                        output.addAll(Stream.of(out.split("\n"))
-                                .filter(str -> !str.isEmpty())
-                                .collect(Collectors.toList()))),
-                (a) -> assertCommand(a, "/save -history " + path.toString(), "")
-        );
-        output.add("/save -history " + path.toString());
-        assertEquals(Files.readAllLines(path), output);
+        {
+            List<String> output = new ArrayList<>();
+            test(
+                    (a) -> assertCommand(a, "int a;", null),
+                    (a) -> assertCommand(a, "int b;", null),
+                    (a) -> assertCommand(a, "int c;", null),
+                    (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"),
+                    (a) -> assertCommandCheckOutput(a, "/list b c a A", (out) ->
+                                    output.addAll(Stream.of(out.split("\n"))
+                            .filter(str -> !str.isEmpty())
+                            .map(str -> str.substring(str.indexOf(':') + 2))
+                            .filter(str -> !str.startsWith("/"))
+                            .collect(Collectors.toList()))),
+                    (a) -> assertCommand(a, "/save 2-3 1 4 " + path.toString(), "")
+            );
+            assertEquals(Files.readAllLines(path), output);
+        }
+        {
+            List<String> output = new ArrayList<>();
+            test(
+                    (a) -> assertVariable(a, "int", "a"),
+                    (a) -> assertCommand(a, "()", null, null, null, "", ""),
+                    (a) -> assertClass(a, "class A { public String toString() { return \"A\"; } }", "class", "A"),
+                    (a) -> assertCommandCheckOutput(a, "/history", (out) ->
+                                output.addAll(Stream.of(out.split("\n"))
+                            .filter(str -> !str.isEmpty())
+                            .collect(Collectors.toList()))),
+                    (a) -> assertCommand(a, "/save -history " + path.toString(), "")
+            );
+            output.add("/save -history " + path.toString());
+            assertEquals(Files.readAllLines(path), output);
+        }
     }
 
     public void testStartRetain() {
@@ -652,6 +673,64 @@
         );
     }
 
+    public void testRerunIdRange() {
+        Compiler compiler = new Compiler();
+        Path startup = compiler.getPath("rangeStartup");
+        String[] startupSources = new String[] {
+            "boolean go = false",
+            "void println(String s) { if (go) System.out.println(s); }",
+            "void println(int i) { if (go) System.out.println(i); }",
+            "println(\"s4\")",
+            "println(\"s5\")",
+            "println(\"s6\")"
+        };
+        String[] sources = new String[] {
+            "frog",
+            "go = true",
+            "println(2)",
+            "println(3)",
+            "println(4)",
+            "querty"
+        };
+        compiler.writeToFile(startup, startupSources);
+        test(false, new String[]{"--startup", startup.toString()},
+                a -> assertCommandOutputStartsWith(a, sources[0], "|  Error:"),
+                a -> assertCommand(a, sources[1], "go ==> true", "", null, "", ""),
+                a -> assertCommand(a, sources[2], "", "", null, "2\n", ""),
+                a -> assertCommand(a, sources[3], "", "", null, "3\n", ""),
+                a -> assertCommand(a, sources[4], "", "", null, "4\n", ""),
+                a -> assertCommandOutputStartsWith(a, sources[5], "|  Error:"),
+                a -> assertCommand(a, "/3", "println(3)", "", null, "3\n", ""),
+                a -> assertCommand(a, "/s4", "println(\"s4\")", "", null, "s4\n", ""),
+                a -> assertCommandOutputStartsWith(a, "/e1", "frog\n|  Error:"),
+                a -> assertCommand(a, "/2-4",
+                        "println(2)\nprintln(3)\nprintln(4)",
+                        "", null, "2\n3\n4\n", ""),
+                a -> assertCommand(a, "/s4-s6",
+                        startupSources[3] + "\n" +startupSources[4] + "\n" +startupSources[5],
+                        "", null, "s4\ns5\ns6\n", ""),
+                a -> assertCommand(a, "/s4-4", null,
+                        "", null, "s4\ns5\ns6\n2\n3\n4\n", ""),
+                a -> assertCommandCheckOutput(a, "/e1-e2",
+                        s -> {
+                            assertTrue(s.trim().startsWith("frog\n|  Error:"),
+                                    "Output: \'" + s + "' does not start with: " + "|  Error:");
+                            assertTrue(s.trim().lastIndexOf("|  Error:") > 10,
+                                    "Output: \'" + s + "' does not have second: " + "|  Error:");
+                        }),
+                a -> assertCommand(a, "/4  s4 2",
+                        "println(4)\nprintln(\"s4\")\nprintln(2)",
+                        "", null, "4\ns4\n2\n", ""),
+                a -> assertCommand(a, "/s5 2-4 3",
+                        "println(\"s5\")\nprintln(2)\nprintln(3)\nprintln(4)\nprintln(3)",
+                        "", null, "s5\n2\n3\n4\n3\n", ""),
+                a -> assertCommand(a, "/2 ff", "|  No such snippet: ff"),
+                a -> assertCommand(a, "/4-2", "|  End of snippet range less than start: 4 - 2"),
+                a -> assertCommand(a, "/s5-s3", "|  End of snippet range less than start: s5 - s3"),
+                a -> assertCommand(a, "/4-s5", "|  End of snippet range less than start: 4 - s5")
+        );
+    }
+
     @Test(enabled = false) // TODO 8158197
     public void testHeadlessEditPad() {
         String prevHeadless = System.getProperty("java.awt.headless");
--- a/langtools/test/jdk/jshell/ToolLocaleMessageTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/jdk/jshell/ToolLocaleMessageTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -117,7 +117,6 @@
                     (a) -> assertCommandFail(a, "/drop rats"),
                     (a) -> assertCommandOK(a, "void dup() {}"),
                     (a) -> assertCommandOK(a, "int dup"),
-                    (a) -> assertCommandFail(a, "/drop dup"),
                     (a) -> assertCommandFail(a, "/edit zebra", "zebra"),
                     (a) -> assertCommandFail(a, "/list zebra", "zebra", "No such snippet: zebra"),
                     (a) -> assertCommandFail(a, "/open", "/open"),
--- a/langtools/test/jdk/jshell/ToolSimpleTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/jdk/jshell/ToolSimpleTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103  8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079
+ * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 8153897 8167128 8154513 8170015 8170368 8172102 8172103  8165405 8173073 8173848 8174041 8173916 8174028 8174262 8174797 8177079 8180508
  * @summary Simple jshell tool tests
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.main
@@ -37,6 +37,7 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.function.Consumer;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -202,7 +203,7 @@
     @Test
     public void testUnknownCommand() {
         test((a) -> assertCommand(a, "/unknown",
-                "|  No such command or snippet id: /unknown\n" +
+                "|  Invalid command: /unknown\n" +
                 "|  Type /help for help."));
     }
 
@@ -275,9 +276,25 @@
     }
 
     @Test
+    public void testDropRange() {
+        test(false, new String[]{"--no-startup"},
+                a -> assertVariable(a, "int", "a"),
+                a -> assertMethod(a, "int b() { return 0; }", "()int", "b"),
+                a -> assertClass(a, "class A {}", "class", "A"),
+                a -> assertImport(a, "import java.util.stream.*;", "", "java.util.stream.*"),
+                a -> assertCommand(a, "for (int i = 0; i < 10; ++i) {}", ""),
+                a -> assertCommand(a, "/drop 3-5 b 1",
+                        "|  dropped class A\n" +
+                        "|  dropped method b()\n" +
+                        "|  dropped variable a\n"),
+                a -> assertCommand(a, "/list", "")
+        );
+    }
+
+    @Test
     public void testDropNegative() {
         test(false, new String[]{"--no-startup"},
-                a -> assertCommandOutputStartsWith(a, "/drop 0", "|  No such snippet: 0"),
+                a -> assertCommandOutputStartsWith(a, "/drop 0", "|  No snippet with id: 0"),
                 a -> assertCommandOutputStartsWith(a, "/drop a", "|  No such snippet: a"),
                 a -> assertCommandCheckOutput(a, "/drop",
                         assertStartsWith("|  In the /drop argument, please specify an import, variable, method, or class to drop.")),
@@ -292,27 +309,23 @@
 
     @Test
     public void testAmbiguousDrop() {
-        Consumer<String> check = s -> {
-            assertTrue(s.startsWith("|  The argument references more than one import, variable, method, or class"), s);
-            int lines = s.split("\n").length;
-            assertEquals(lines, 5, "Expected 3 ambiguous keys, but found: " + (lines - 2) + "\n" + s);
-        };
         test(
                 a -> assertVariable(a, "int", "a"),
                 a -> assertMethod(a, "int a() { return 0; }", "()int", "a"),
                 a -> assertClass(a, "class a {}", "class", "a"),
-                a -> assertCommandCheckOutput(a, "/drop a", check),
-                a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
-                a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
-                a -> assertCommandCheckOutput(a, "/types", assertClasses()),
-                a -> assertCommandCheckOutput(a, "/imports", assertImports())
+                a -> assertCommand(a, "/drop a",
+                        "|  dropped variable a\n" +
+                        "|  dropped method a()\n" +
+                        "|  dropped class a")
         );
         test(
                 a -> assertMethod(a, "int a() { return 0; }", "()int", "a"),
                 a -> assertMethod(a, "double a(int a) { return 0; }", "(int)double", "a"),
                 a -> assertMethod(a, "double a(double a) { return 0; }", "(double)double", "a"),
-                a -> assertCommandCheckOutput(a, "/drop a", check),
-                a -> assertCommandCheckOutput(a, "/methods", assertMethods())
+                a -> assertCommand(a, "/drop a",
+                        "|  dropped method a()\n" +
+                        "|  dropped method a(int)\n" +
+                        "|  dropped method a(double)\n")
         );
     }
 
@@ -402,12 +415,14 @@
         String arg = "qqqq";
         List<String> startVarList = new ArrayList<>(START_UP);
         startVarList.add("int aardvark");
+        startVarList.add("int weevil");
         test(
                 a -> assertCommandCheckOutput(a, "/list -all",
                         s -> checkLineToList(s, START_UP)),
                 a -> assertCommandOutputStartsWith(a, "/list " + arg,
                         "|  No such snippet: " + arg),
                 a -> assertVariable(a, "int", "aardvark"),
+                a -> assertVariable(a, "int", "weevil"),
                 a -> assertCommandOutputContains(a, "/list aardvark", "aardvark"),
                 a -> assertCommandCheckOutput(a, "/list -start",
                         s -> checkLineToList(s, START_UP)),
@@ -415,6 +430,11 @@
                         s -> checkLineToList(s, startVarList)),
                 a -> assertCommandOutputStartsWith(a, "/list s3",
                         "s3 : import"),
+                a -> assertCommandCheckOutput(a, "/list 1-2 s3",
+                        s -> {
+                            assertTrue(Pattern.matches(".*aardvark.*\\R.*weevil.*\\R.*s3.*import.*", s.trim()),
+                                    "No match: " + s);
+                        }),
                 a -> assertCommandOutputStartsWith(a, "/list " + arg,
                         "|  No such snippet: " + arg)
         );
@@ -439,6 +459,8 @@
                         s -> checkLineToList(s, startVarList)),
                 a -> assertCommandOutputStartsWith(a, "/vars -all",
                         "|    int aardvark = 0\n|    int a = "),
+                a -> assertCommandOutputStartsWith(a, "/vars 1-4",
+                        "|    int aardvark = 0\n|    int a = "),
                 a -> assertCommandOutputStartsWith(a, "/vars f",
                         "|  This command does not accept the snippet 'f'"),
                 a -> assertCommand(a, "/var " + arg,
--- a/langtools/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/T7008643/InlinedFinallyConfuseDebuggersTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,6 +72,7 @@
         {9,           21},      //System.out.println("finally");
         {10,          29},
         {9,           32},      //System.out.println("finally");
+        {10,          41},      //}
         {11,          43},
     };
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8180141/MissingLNTEntryForBreakContinueTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8180141
+ * @summary Missing entry in LineNumberTable for break statement that jumps out of try-finally
+ * @modules jdk.jdeps/com.sun.tools.classfile
+ *          jdk.compiler/com.sun.tools.javac.code
+ *          jdk.compiler/com.sun.tools.javac.comp
+ *          jdk.compiler/com.sun.tools.javac.file
+ *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.compiler/com.sun.tools.javac.tree
+ *          jdk.compiler/com.sun.tools.javac.util
+ * @compile -g MissingLNTEntryForBreakContinueTest.java
+ * @run main MissingLNTEntryForBreakContinueTest
+ */
+
+import java.io.File;
+import java.net.URI;
+
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+import com.sun.tools.classfile.*;
+import com.sun.tools.javac.comp.Attr;
+import com.sun.tools.javac.comp.AttrContext;
+import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.comp.Modules;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.List;
+
+import static com.sun.tools.javac.util.List.of;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
+
+public class MissingLNTEntryForBreakContinueTest {
+    protected ReusableJavaCompiler tool;
+    Context context;
+
+    MissingLNTEntryForBreakContinueTest() {
+        context = new Context();
+        JavacFileManager.preRegister(context);
+        MyAttr.preRegister(context);
+        tool = new ReusableJavaCompiler(context);
+    }
+
+    public static void main(String... args) throws Throwable {
+        new MissingLNTEntryForBreakContinueTest().test();
+    }
+
+    void test() throws Throwable {
+        testFor("1", "break");
+        testFor("2", "continue");
+    }
+
+    void testFor(String id, String statement) throws Throwable {
+        JavaSource source = new JavaSource(id, statement);
+        tool.clear();
+        List<JavaFileObject> inputs = of(source);
+        try {
+            tool.compile(inputs);
+        } catch (Throwable ex) {
+            throw new AssertionError(ex);
+        }
+        File testClasses = new File(".");
+        File file = new File(testClasses, "Test" + id + ".class");
+        ClassFile classFile = ClassFile.read(file);
+        for (Method m : classFile.methods) {
+            if (classFile.constant_pool.getUTF8Value(m.name_index).equals("foo")) {
+                Code_attribute code = (Code_attribute)m.attributes.get(Attribute.Code);
+                LineNumberTable_attribute lnt = (LineNumberTable_attribute)code.attributes.get(Attribute.LineNumberTable);
+                checkLNT(lnt, MyAttr.lineNumber);
+            }
+        }
+    }
+
+    void checkLNT(LineNumberTable_attribute lnt, int lineToCheckFor) {
+        for (LineNumberTable_attribute.Entry e: lnt.line_number_table) {
+            if (e.line_number == lineToCheckFor) {
+                return;
+            }
+        }
+        throw new AssertionError("seek line number not found in the LNT for method foo()");
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+        String statement;
+        String id;
+        String template =
+                "class Test#Id {\n" +
+                "    void foo(boolean condition) {\n" +
+                "        while (true) {\n" +
+                "            try {\n" +
+                "                if (condition) {\n" +
+                "                    #STM;\n" +
+                "                }\n" +
+                "            } finally {\n" +
+                "                System.out.println(\"finalizer\");\n" +
+                "            }\n" +
+                "        }\n" +
+                "    }" +
+                "}";
+
+        JavaSource(String id, String statement) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            this.statement = statement;
+            this.id = id;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return template.replace("#Id", id).replace("#STM", statement);
+        }
+    }
+
+    /* this class has been set up to do not depend on a fixed line number, this Attr subclass will
+     * look for 'break' or 'continue' statements in order to find the actual line number they occupy.
+     * This way the test can find if that line number appears in the LNT generated for a given class.
+     */
+    static class MyAttr extends Attr {
+        static int lineNumber;
+
+        static void preRegister(Context context) {
+            context.put(attrKey, (com.sun.tools.javac.util.Context.Factory<Attr>) c -> new MyAttr(c));
+        }
+
+        MyAttr(Context context) {
+            super(context);
+        }
+
+        @Override
+        public com.sun.tools.javac.code.Type attribStat(JCTree tree, Env<AttrContext> env) {
+            com.sun.tools.javac.code.Type result = super.attribStat(tree, env);
+            if (tree.hasTag(BREAK) || tree.hasTag(CONTINUE)) {
+                lineNumber = env.toplevel.lineMap.getLineNumber(tree.pos);
+            }
+            return result;
+        }
+    }
+
+    static class ReusableJavaCompiler extends JavaCompiler {
+        ReusableJavaCompiler(Context context) {
+            super(context);
+        }
+
+        @Override
+        protected void checkReusable() {
+            // do nothing
+        }
+
+        @Override
+        public void close() {
+            //do nothing
+        }
+
+        void clear() {
+            newRound();
+            Modules.instance(context).newRound();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T8180660/MissingLNTEntryForFinalizerTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8180141
+ * @summary Missing entry in LineNumberTable for break statement that jumps out of try-finally
+ * @modules jdk.jdeps/com.sun.tools.classfile
+ *          jdk.compiler/com.sun.tools.javac.code
+ *          jdk.compiler/com.sun.tools.javac.comp
+ *          jdk.compiler/com.sun.tools.javac.file
+ *          jdk.compiler/com.sun.tools.javac.main
+ *          jdk.compiler/com.sun.tools.javac.tree
+ *          jdk.compiler/com.sun.tools.javac.util
+ * @compile -g MissingLNTEntryForFinalizerTest.java
+ * @run main MissingLNTEntryForFinalizerTest
+ */
+
+import java.io.File;
+import java.net.URI;
+
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+import com.sun.tools.classfile.*;
+import com.sun.tools.javac.comp.Attr;
+import com.sun.tools.javac.comp.AttrContext;
+import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.comp.Modules;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.List;
+
+import static com.sun.tools.javac.util.List.of;
+import static com.sun.tools.javac.tree.JCTree.Tag.*;
+
+public class MissingLNTEntryForFinalizerTest {
+    protected ReusableJavaCompiler tool;
+    Context context;
+
+    MissingLNTEntryForFinalizerTest() {
+        context = new Context();
+        JavacFileManager.preRegister(context);
+        MyAttr.preRegister(context);
+        tool = new ReusableJavaCompiler(context);
+    }
+
+    public static void main(String... args) throws Throwable {
+        new MissingLNTEntryForFinalizerTest().test();
+    }
+
+    void test() throws Throwable {
+        JavaSource source = new JavaSource("1");
+        tool.clear();
+        List<JavaFileObject> inputs = of(source);
+        try {
+            tool.compile(inputs);
+        } catch (Throwable ex) {
+            throw new AssertionError(ex);
+        }
+        File testClasses = new File(".");
+        File file = new File(testClasses, "Test1.class");
+        ClassFile classFile = ClassFile.read(file);
+        for (Method m : classFile.methods) {
+            if (classFile.constant_pool.getUTF8Value(m.name_index).equals("foo")) {
+                Code_attribute code = (Code_attribute)m.attributes.get(Attribute.Code);
+                LineNumberTable_attribute lnt = (LineNumberTable_attribute)code.attributes.get(Attribute.LineNumberTable);
+                checkLNT(lnt, MyAttr.lineNumber);
+            }
+        }
+    }
+
+    void checkLNT(LineNumberTable_attribute lnt, int lineToCheckFor) {
+        for (LineNumberTable_attribute.Entry e: lnt.line_number_table) {
+            if (e.line_number == lineToCheckFor) {
+                return;
+            }
+        }
+        throw new AssertionError("seek line number not found in the LNT for method foo()");
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+        String id;
+        String template =
+                "import java.util.*;\n" +
+                "class Test#Id {\n" +
+                "    void foo() {\n" +
+                "        List<String> l = null;\n" +
+                "        String first = null;\n" +
+                "        try {\n" +
+                "            first = l.get(0);\n" +
+                "        } finally {\n" +
+                "            if (first != null) {\n" +
+                "                System.out.println(\"finalizer\");\n" +
+                "            }\n" +
+                "        }\n" +
+                "    }\n" +
+                "}";
+
+        JavaSource(String id) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            this.id = id;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return template.replace("#Id", id);
+        }
+    }
+
+    /* this class has been set up to do not depend on a fixed line number, this Attr subclass will
+     * look for 'break' or 'continue' statements in order to find the actual line number they occupy.
+     * This way the test can find if that line number appears in the LNT generated for a given class.
+     */
+    static class MyAttr extends Attr {
+        static int lineNumber;
+
+        static void preRegister(Context context) {
+            context.put(attrKey, (com.sun.tools.javac.util.Context.Factory<Attr>) c -> new MyAttr(c));
+        }
+
+        MyAttr(Context context) {
+            super(context);
+        }
+
+        @Override
+        public com.sun.tools.javac.code.Type attribStat(JCTree tree, Env<AttrContext> env) {
+            com.sun.tools.javac.code.Type result = super.attribStat(tree, env);
+            if (tree.hasTag(TRY)) {
+                JCTry tryTree = (JCTry)tree;
+                lineNumber = env.toplevel.lineMap.getLineNumber(tryTree.finalizer.endpos);
+            }
+            return result;
+        }
+    }
+
+    static class ReusableJavaCompiler extends JavaCompiler {
+        ReusableJavaCompiler(Context context) {
+            super(context);
+        }
+
+        @Override
+        protected void checkReusable() {
+            // do nothing
+        }
+
+        @Override
+        public void close() {
+            //do nothing
+        }
+
+        void clear() {
+            newRound();
+            Modules.instance(context).newRound();
+        }
+    }
+}
--- a/langtools/test/tools/javac/api/T6265137.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/api/T6265137.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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();
         }
     }
 }
--- a/langtools/test/tools/javac/api/T6395981.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/api/T6395981.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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;
--- a/langtools/test/tools/javac/generics/6182950/T6182950b.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6182950/T6182950b.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T6182950b.java:15:16: compiler.err.name.clash.same.erasure.no.override: m(java.util.List<java.lang.Integer>), T6182950b.B, m(java.util.List<java.lang.String>), T6182950b.A, m(java.util.List<java.lang.Integer>), T6182950b.B
+T6182950b.java:15:16: compiler.err.name.clash.same.erasure.no.override: m, java.util.List<java.lang.Integer>, T6182950b.B, m, java.util.List<java.lang.String>, T6182950b.A
 1 error
--- a/langtools/test/tools/javac/generics/6476118/T6476118a.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6476118/T6476118a.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
 /**
  * @test  /nodynamiccopyright/
- * @bug 6476118
+ * @bug 6476118 7170058
  * @summary compiler bug causes runtime ClassCastException for generics overloading
  * @compile/fail/ref=T6476118a.out -XDrawDiagnostics T6476118a.java
  */
--- a/langtools/test/tools/javac/generics/6476118/T6476118a.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6476118/T6476118a.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T6476118a.java:14:20: compiler.err.name.clash.same.erasure.no.override.1: compareTo(T6476118a.B), T6476118a.B, compareTo(java.lang.Object), T6476118a.A, compareTo(T), java.lang.Comparable
+T6476118a.java:14:20: compiler.err.name.clash.same.erasure.no.override.1: class, B, compareTo, T6476118a.B, java.lang.Comparable, compareTo, java.lang.Object, T6476118a.A
 1 error
--- a/langtools/test/tools/javac/generics/6476118/T6476118b.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6476118/T6476118b.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
 /**
  * @test  /nodynamiccopyright/
- * @bug 6476118 6533652
+ * @bug 6476118 6533652 7170058
  * @summary compiler bug causes runtime ClassCastException for generics overloading
  * @compile/fail/ref=T6476118b.out -XDrawDiagnostics T6476118b.java
  */
--- a/langtools/test/tools/javac/generics/6476118/T6476118b.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6476118/T6476118b.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T6476118b.java:12:20: compiler.err.name.clash.same.erasure.no.override.1: compareTo(T6476118b.B), T6476118b.B, compareTo(java.lang.Object), T6476118b, compareTo(T), java.lang.Comparable
+T6476118b.java:12:20: compiler.err.name.clash.same.erasure.no.override.1: class, B, compareTo, T6476118b.B, java.lang.Comparable, compareTo, java.lang.Object, T6476118b
 1 error
--- a/langtools/test/tools/javac/generics/6476118/T6476118c.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6476118/T6476118c.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
 /**
  * @test  /nodynamiccopyright/
- * @bug 6476118
+ * @bug 6476118 7170058
  * @summary compiler bug causes runtime ClassCastException for generics overloading
  * @compile/fail/ref=T6476118c.out -XDrawDiagnostics T6476118c.java
  */
--- a/langtools/test/tools/javac/generics/6476118/T6476118c.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6476118/T6476118c.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,3 +1,3 @@
-T6476118c.java:18:21: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Object), T6476118c.C, foo(T), T6476118c.A, foo(java.lang.Object), T6476118c.C
-T6476118c.java:19:21: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Number), T6476118c.C, foo(T), T6476118c.B, foo(java.lang.Number), T6476118c.C
+T6476118c.java:18:21: compiler.err.name.clash.same.erasure.no.override: foo, java.lang.Object, T6476118c.C, foo, java.lang.Integer, T6476118c.A
+T6476118c.java:19:21: compiler.err.name.clash.same.erasure.no.override: foo, java.lang.Number, T6476118c.C, foo, java.lang.Integer, T6476118c.B
 2 errors
--- a/langtools/test/tools/javac/generics/6985719/T6985719a.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6985719/T6985719a.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T6985719a.java:14:5: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719a.B, f(java.util.List<java.lang.String>), T6985719a.A
+T6985719a.java:14:5: compiler.err.name.clash.same.erasure.no.override: f, java.util.List<java.lang.Integer>, T6985719a.B, f, java.util.List<java.lang.String>, T6985719a.A
 1 error
--- a/langtools/test/tools/javac/generics/6985719/T6985719b.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6985719/T6985719b.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T6985719b.java:14:14: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719b.B, f(java.util.List<java.lang.String>), T6985719b.A
+T6985719b.java:14:14: compiler.err.name.clash.same.erasure.no.override: f, java.util.List<java.lang.Integer>, T6985719b.B, f, java.util.List<java.lang.String>, T6985719b.A
 1 error
--- a/langtools/test/tools/javac/generics/6985719/T6985719c.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6985719/T6985719c.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug     6985719
+ * @bug     6985719 7170058
  * @summary Alike methods in interfaces (Inheritance and Overriding)
  * @author  mcimadamore
  * @compile/fail/ref=T6985719c.out -XDrawDiagnostics T6985719c.java
--- a/langtools/test/tools/javac/generics/6985719/T6985719c.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6985719/T6985719c.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T6985719c.java:14:5: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<X>), T6985719c.B, f(java.util.List<java.lang.String>), T6985719c.A
+T6985719c.java:14:5: compiler.err.name.clash.same.erasure.no.override: f, java.util.List<java.lang.Integer>, T6985719c.B, f, java.util.List<java.lang.String>, T6985719c.A
 1 error
--- a/langtools/test/tools/javac/generics/6985719/T6985719d.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6985719/T6985719d.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug     6985719
+ * @bug     6985719 7170058
  * @summary Alike methods in interfaces (Inheritance and Overriding)
  * @author  mcimadamore
  * @compile/fail/ref=T6985719d.out -XDrawDiagnostics T6985719d.java
--- a/langtools/test/tools/javac/generics/6985719/T6985719d.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6985719/T6985719d.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T6985719d.java:14:14: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<X>), T6985719d.B, f(java.util.List<java.lang.String>), T6985719d.A
+T6985719d.java:14:14: compiler.err.name.clash.same.erasure.no.override: f, java.util.List<java.lang.Integer>, T6985719d.B, f, java.util.List<java.lang.String>, T6985719d.A
 1 error
--- a/langtools/test/tools/javac/generics/6985719/T6985719e.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6985719/T6985719e.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T6985719e.java:13:34: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719e.B, f(java.util.List<java.lang.String>), T6985719e.A, f(java.util.List<java.lang.Integer>), T6985719e.B
+T6985719e.java:13:34: compiler.err.name.clash.same.erasure.no.override: f, java.util.List<java.lang.Integer>, T6985719e.B, f, java.util.List<java.lang.String>, T6985719e.A
 1 error
--- a/langtools/test/tools/javac/generics/6985719/T6985719f.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6985719/T6985719f.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T6985719f.java:13:39: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719f.B, f(java.util.List<java.lang.String>), T6985719f.A, f(java.util.List<java.lang.Integer>), T6985719f.B
+T6985719f.java:13:39: compiler.err.name.clash.same.erasure.no.override: f, java.util.List<java.lang.Integer>, T6985719f.B, f, java.util.List<java.lang.String>, T6985719f.A
 1 error
--- a/langtools/test/tools/javac/generics/6985719/T6985719g.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6985719/T6985719g.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug     6985719
+ * @bug     6985719 7170058
  * @summary Alike methods in interfaces (Inheritance and Overriding)
  * @author  mcimadamore
  * @compile/fail/ref=T6985719g.out -XDrawDiagnostics T6985719g.java
--- a/langtools/test/tools/javac/generics/6985719/T6985719g.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6985719/T6985719g.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T6985719g.java:13:42: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719g.B, f(java.util.List<X>), T6985719g.A, f(java.util.List<java.lang.Integer>), T6985719g.B
+T6985719g.java:13:42: compiler.err.name.clash.same.erasure.no.override: f, java.util.List<java.lang.Integer>, T6985719g.B, f, java.util.List<java.lang.String>, T6985719g.A
 1 error
--- a/langtools/test/tools/javac/generics/6985719/T6985719h.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6985719/T6985719h.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug     6985719
+ * @bug     6985719 7170058
  * @summary Alike methods in interfaces (Inheritance and Overriding)
  * @author  mcimadamore
  * @compile/fail/ref=T6985719h.out -XDrawDiagnostics T6985719h.java
--- a/langtools/test/tools/javac/generics/6985719/T6985719h.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/6985719/T6985719h.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T6985719h.java:13:56: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719h.B, f(java.util.List<X>), T6985719h.A, f(java.util.List<java.lang.Integer>), T6985719h.B
+T6985719h.java:13:56: compiler.err.name.clash.same.erasure.no.override: f, java.util.List<java.lang.Integer>, T6985719h.B, f, java.util.List<java.lang.String>, T6985719h.A
 1 error
--- a/langtools/test/tools/javac/generics/7007615/T7007615.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/7007615/T7007615.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug     7007615
+ * @bug     7007615 7170058
  * @summary java_util/generics/phase2/NameClashTest02 fails since jdk7/pit/b123.
  * @author  mcimadamore
  * @compile/fail/ref=T7007615.out -XDrawDiagnostics T7007615.java
--- a/langtools/test/tools/javac/generics/7007615/T7007615.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/7007615/T7007615.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,3 +1,3 @@
-T7007615.java:21:14: compiler.err.name.clash.same.erasure.no.override: foo(java.lang.Number), T6985719a.DX, foo(T), T6985719a.AX, foo(java.lang.Number), T6985719a.DX
-T7007615.java:22:14: compiler.err.name.clash.same.erasure.no.override: bar(T6985719a.BX<?>), T6985719a.DX, bar(T6985719a.BX), T6985719a.BX, bar(T6985719a.BX<?>), T6985719a.DX
+T7007615.java:21:14: compiler.err.name.clash.same.erasure.no.override: foo, java.lang.Number, T6985719a.DX, foo, java.lang.Integer, T6985719a.AX
+T7007615.java:22:14: compiler.err.name.clash.same.erasure.no.override: bar, T6985719a.BX<?>, T6985719a.DX, bar, T6985719a.BX, T6985719a.BX
 2 errors
--- a/langtools/test/tools/javac/generics/7020657/T7020657neg.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/7020657/T7020657neg.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T7020657neg.java:22:5: compiler.err.name.clash.same.erasure.no.override: get(java.util.List<java.lang.Integer>), T7020657neg.B, get(java.util.List<java.lang.String>), T7020657neg.A
+T7020657neg.java:22:5: compiler.err.name.clash.same.erasure.no.override: get, java.util.List<java.lang.Integer>, T7020657neg.B, get, java.util.List<java.lang.String>, T7020657neg.A
 1 error
--- a/langtools/test/tools/javac/generics/7022054/T7022054neg1.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/7022054/T7022054neg1.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T7022054neg1.java:15:30: compiler.err.name.clash.same.erasure.no.override: <X>m(X), T7022054neg1.B, m(java.lang.String), T7022054neg1.A, <X>m(X), T7022054neg1.B
+T7022054neg1.java:15:30: compiler.err.name.clash.same.erasure.no.override: m, X, T7022054neg1.B, m, java.lang.String, T7022054neg1.A
 1 error
--- a/langtools/test/tools/javac/generics/7022054/T7022054pos1.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/7022054/T7022054pos1.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-T7022054pos1.java:39:25: compiler.err.name.clash.same.erasure.no.override: <X>m(java.lang.String), T7022054pos1.B, m(java.lang.String), T7022054pos1.A, <X>m(java.lang.String), T7022054pos1.B
+T7022054pos1.java:39:25: compiler.err.name.clash.same.erasure.no.override: m, java.lang.String, T7022054pos1.B, m, java.lang.String, T7022054pos1.A
 1 error
--- a/langtools/test/tools/javac/generics/7034019/T7034019c.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/7034019/T7034019c.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,3 +1,3 @@
-T7034019c.java:18:20: compiler.err.name.clash.same.erasure.no.override: <T>foo(), T7034019c.B, <T>foo(), T7034019c.A
+T7034019c.java:18:20: compiler.err.name.clash.same.erasure.no.override: foo, , T7034019c.B, foo, , T7034019c.A
 T7034019c.java:20:14: compiler.err.ref.ambiguous: foo, kindname.method, <T>foo(), T7034019c.B, kindname.method, <T>foo(), T7034019c.A
 2 errors
--- a/langtools/test/tools/javac/generics/7034019/T7034019d.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/7034019/T7034019d.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,3 +1,3 @@
-T7034019d.java:18:21: compiler.err.name.clash.same.erasure.no.override: <T>foo(), T7034019c.B, <T>foo(), T7034019c.A
+T7034019d.java:18:21: compiler.err.name.clash.same.erasure.no.override: foo, , T7034019c.B, foo, , T7034019c.A
 T7034019d.java:20:13: compiler.err.ref.ambiguous: foo, kindname.method, <T>foo(), T7034019c.B, kindname.method, <T>foo(), T7034019c.A
 2 errors
--- a/langtools/test/tools/javac/generics/ErasureClashCrash.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/ErasureClashCrash.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 4951670
+ * @bug 4951670 7170058
  * @summary javac crash with improper overrider
  * @author gafter
  *
--- a/langtools/test/tools/javac/generics/ErasureClashCrash.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/ErasureClashCrash.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-ErasureClashCrash.java:14:16: compiler.err.name.clash.same.erasure.no.override: compareTo(java.lang.Object), ErasureClashCrash, compareTo(T), Compar, compareTo(java.lang.Object), ErasureClashCrash
+ErasureClashCrash.java:14:16: compiler.err.name.clash.same.erasure.no.override: compareTo, java.lang.Object, ErasureClashCrash, compareTo, ErasureClashCrash, Compar
 1 error
--- a/langtools/test/tools/javac/generics/T4757416.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/T4757416.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 4756416
+ * @bug 4756416 7170058
  * @summary generics: erasure clash not detected
  * @author gafter
  *
--- a/langtools/test/tools/javac/generics/T4757416.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/T4757416.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,3 +1,3 @@
-T4757416.java:14:23: compiler.err.name.clash.same.erasure.no.override.1: id(java.lang.String), T4756416.D, id(A), T4756416.I, id(A), T4756416.C
-T4757416.java:15:24: compiler.err.name.clash.same.erasure.no.override.1: id(java.lang.Integer), T4756416.D, id(A), T4756416.C, id(A), T4756416.I
+T4757416.java:14:23: compiler.err.name.clash.same.erasure.no.override.1: class, D, id, java.lang.String, T4756416.C, id, java.lang.Integer, T4756416.I
+T4757416.java:15:24: compiler.err.name.clash.same.erasure.no.override.1: class, D, id, java.lang.Integer, T4756416.I, id, java.lang.String, T4756416.C
 2 errors
--- a/langtools/test/tools/javac/generics/rawOverride/7157798/Test4.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/rawOverride/7157798/Test4.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
 /**
  * @test     /nodynamiccopyright/
- * @bug      7062745 7157798
+ * @bug      7062745 7157798 7170058
  * @summary  Negative test of conflicting same-name methods inherited from multiple interfaces when parameter types not compatible
  * @compile/fail/ref=Test4.out -Werror -Xlint:unchecked -XDrawDiagnostics Test4.java
  */
--- a/langtools/test/tools/javac/generics/rawOverride/7157798/Test4.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/generics/rawOverride/7157798/Test4.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
-Test4.java:15:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<java.lang.String>), B, m(java.util.Set<java.lang.Integer>), A
-Test4.java:17:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<?>), C, m(java.util.Set<java.lang.Integer>), A
-Test4.java:23:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<T>), D, m(java.util.Set<java.lang.Integer>), A
-Test4.java:25:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<T>), D, m(java.util.Set<?>), C
-Test4.java:29:1: compiler.err.name.clash.same.erasure.no.override: <T>m(java.util.Set<T>), E, m(java.util.Set<T>), D
+Test4.java:15:1: compiler.err.name.clash.same.erasure.no.override: m, java.util.Set<java.lang.String>, B, m, java.util.Set<java.lang.Integer>, A
+Test4.java:17:1: compiler.err.name.clash.same.erasure.no.override: m, java.util.Set<?>, C, m, java.util.Set<java.lang.Integer>, A
+Test4.java:23:1: compiler.err.name.clash.same.erasure.no.override: m, java.util.Set<java.lang.Number>, D, m, java.util.Set<java.lang.Integer>, A
+Test4.java:25:1: compiler.err.name.clash.same.erasure.no.override: m, java.util.Set<T>, D, m, java.util.Set<?>, C
+Test4.java:29:1: compiler.err.name.clash.same.erasure.no.override: m, java.util.Set<T>, E, m, java.util.Set<T>, D
 5 errors
--- a/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 8003280
+ * @bug 8003280 7170058
  * @summary Add lambda tests
  *   This test is for identifying a non-SAM type: Having more than one methods due to inheritance, and none of them has a subsignature of all other methods
  * @compile/fail/ref=NonSAM2.out -XDrawDiagnostics NonSAM2.java Helper.java
--- a/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/lambda/funcInterfaces/NonSAM2.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 NonSAM2.java:13:1: compiler.err.types.incompatible.diff.ret: Bar1, Foo1, getAge(java.lang.String)
-NonSAM2.java:15:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List<?>), C, getOldest(java.util.List<java.lang.Number>), A
-NonSAM2.java:17:1: compiler.err.name.clash.same.erasure.no.override: getOldest(java.util.List<java.lang.Integer>), D, getOldest(java.util.List<java.lang.Number>), A
-NonSAM2.java:21:1: compiler.err.name.clash.same.erasure.no.override: m(S), Bar2, m(T), Foo2
+NonSAM2.java:15:1: compiler.err.name.clash.same.erasure.no.override: getOldest, java.util.List<?>, C, getOldest, java.util.List<java.lang.Number>, A
+NonSAM2.java:17:1: compiler.err.name.clash.same.erasure.no.override: getOldest, java.util.List<java.lang.Integer>, D, getOldest, java.util.List<java.lang.Number>, A
+NonSAM2.java:21:1: compiler.err.name.clash.same.erasure.no.override: m, T2, Bar2, m, T1, Foo2
 4 errors
--- a/langtools/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/lambda/intersection/IntersectionTargetTypeTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -26,7 +26,6 @@
  * @bug 8002099 8010822
  * @summary Add support for intersection types in cast expression
  * @modules jdk.compiler/com.sun.tools.javac.util
- * @run main/othervm IntersectionTargetTypeTest
  */
 
 import com.sun.source.util.JavacTask;
--- a/langtools/test/tools/javac/linenumbers/FinallyLineNumberTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/linenumbers/FinallyLineNumberTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@
 import com.sun.tools.classfile.LineNumberTable_attribute;
 import com.sun.tools.classfile.LineNumberTable_attribute.Entry;
 
-import java.io.File;
 import java.io.IOException;
 
 public class FinallyLineNumberTest {
@@ -46,13 +45,13 @@
         if (lines == null) {
             throw new Exception("finally line number table could not be loaded");
         }
-        if (lines.length != 4) {
+        if (lines.length != 5) {
             // Help debug
             System.err.println("LineTable error, got lines:");
             for (Entry e : lines) {
                 System.err.println(e.line_number);
             }
-            throw new Exception("finally line number table incorrect: length=" + lines.length + " expected length=4");
+            throw new Exception("finally line number table incorrect: length=" + lines.length + " expected length=5");
         }
 
         // return null line, for the load null operation
@@ -71,11 +70,17 @@
             throw new Exception("finally line number table incorrect: got=" + current + " expected=" + first);
         }
 
-        // finally line, for when exception is thrown
+        // for when exception is thrown
         current = lines[3].line_number;
         if (current != first + 2) {
             throw new Exception("finally line number table incorrect: got=" + current + " expected=" + (first + 2));
         }
+
+        // the '}' closing the finally block
+        current = lines[4].line_number;
+        if (current != first + 3) {
+            throw new Exception("finally line number table incorrect: got=" + current + " expected=" + (first + 3));
+        }
     }
 
     static Entry[] findEntries() throws IOException, ConstantPoolException {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/linenumbers/NullCheckLineNumberTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,87 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8172880
+ * @summary  Wrong LineNumberTable for synthetic null checks
+ * @modules jdk.jdeps/com.sun.tools.classfile
+ */
+
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Method;
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.LineNumberTable_attribute;
+
+import java.io.IOException;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class NullCheckLineNumberTest {
+
+    //test data:
+    static class Test {
+
+        public Test() {
+            String a = "", b = null;
+
+            Stream.of("x")
+                  .filter(a::equals)
+                  .filter(b::equals)
+                  .count();
+        }
+
+    }
+
+    public static void main(String[] args) throws Exception {
+        List<Entry> actualEntries = findEntries();
+        List<Entry> expectedEntries = List.of(
+                new SimpleEntry<>(29, 0),
+                new SimpleEntry<>(30, 4),
+                new SimpleEntry<>(32, 9),
+                new SimpleEntry<>(33, 16),
+                new SimpleEntry<>(34, 32),
+                new SimpleEntry<>(35, 46),
+                new SimpleEntry<>(36, 52)
+        );
+        if (!Objects.equals(actualEntries, expectedEntries)) {
+            error(String.format("Unexpected LineNumberTable: %s", actualEntries.toString()));
+        }
+
+        try {
+            new Test();
+        } catch (NullPointerException npe) {
+            if (Arrays.stream(npe.getStackTrace())
+                      .noneMatch(se -> se.getFileName().contains("NullCheckLineNumberTest") &&
+                                       se.getLineNumber() == 34)) {
+                throw new AssertionError("Should go through line 34!");
+            }
+        }
+    }
+
+    static List<Entry> findEntries() throws IOException, ConstantPoolException {
+        ClassFile self = ClassFile.read(NullCheckLineNumberTest.Test.class.getResourceAsStream("NullCheckLineNumberTest$Test.class"));
+        for (Method m : self.methods) {
+            if ("<init>".equals(m.getName(self.constant_pool))) {
+                Code_attribute code_attribute = (Code_attribute)m.attributes.get(Attribute.Code);
+                for (Attribute at : code_attribute.attributes) {
+                    if (Attribute.LineNumberTable.equals(at.getName(self.constant_pool))) {
+                        return Arrays.stream(((LineNumberTable_attribute)at).line_number_table)
+                                     .map(e -> new SimpleEntry<> (e.line_number, e.start_pc))
+                                     .collect(Collectors.toList());
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    static void error(String msg) {
+        throw new AssertionError(msg);
+    }
+
+}
--- a/langtools/test/tools/javac/modules/T8159439/NPEForModuleInfoWithNonZeroSuperClassTest.out	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/modules/T8159439/NPEForModuleInfoWithNonZeroSuperClassTest.out	Wed Jul 05 23:37:13 2017 +0200
@@ -1,2 +1,2 @@
-- compiler.err.cant.access: mod.module-info, (compiler.misc.bad.class.file.header: module-info.class, (compiler.misc.module.info.invalid.super.class))
+- compiler.err.cant.access: <error>.module-info, (compiler.misc.bad.class.file.header: module-info.class, (compiler.misc.module.name.mismatch: mod/module-info, <error>))
 1 error
--- a/langtools/test/tools/javac/processing/StopAfterError/StopAfterError.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/processing/StopAfterError/StopAfterError.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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();
-    }
-
 }
--- a/langtools/test/tools/javac/processing/errors/StopOnInapplicableAnnotations/Processor.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/processing/errors/StopOnInapplicableAnnotations/Processor.java	Wed Jul 05 23:37:13 2017 +0200
@@ -63,7 +63,7 @@
         if (args.length != 1) throw new IllegalStateException("Must provide class name!");
         String testContent = null;
         List<File> sourcePath = new ArrayList<>();
-        for (String sourcePaths : System.getProperty("test.src.path").split(":")) {
+        for (String sourcePaths : System.getProperty("test.src.path").split(File.pathSeparator)) {
             sourcePath.add(new File(sourcePaths));
         }
         JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
--- a/langtools/test/tools/javac/processing/model/LocalClasses/LocalClassesModel.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/LocalClasses/LocalClassesModel.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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();
-    }
 }
--- a/langtools/test/tools/javac/processing/model/TestSourceVersion.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/TestSourceVersion.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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());
--- a/langtools/test/tools/javac/processing/model/nestedTypeVars/NestedTypeVars.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/processing/model/nestedTypeVars/NestedTypeVars.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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> {
--- a/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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;
--- a/langtools/test/tools/javac/profiles/ProfileOptionTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/profiles/ProfileOptionTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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)
--- a/langtools/test/tools/javac/tree/ArrayTypeToString.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/tree/ArrayTypeToString.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,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) {
--- a/langtools/test/tools/javac/tree/JavacTreeScannerTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/tree/JavacTreeScannerTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -41,7 +41,7 @@
  *          jdk.compiler/com.sun.tools.javac.tree
  *          jdk.compiler/com.sun.tools.javac.util
  * @build AbstractTreeScannerTest JavacTreeScannerTest
- * @run main/othervm JavacTreeScannerTest -q -r .
+ * @run main JavacTreeScannerTest -q -r .
  */
 
 import java.io.*;
--- a/langtools/test/tools/javac/tree/SourceTreeScannerTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/tree/SourceTreeScannerTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -41,7 +41,7 @@
  *          jdk.compiler/com.sun.tools.javac.tree
  *          jdk.compiler/com.sun.tools.javac.util
  * @build AbstractTreeScannerTest SourceTreeScannerTest
- * @run main/othervm SourceTreeScannerTest -q -r .
+ * @run main SourceTreeScannerTest -q -r .
  */
 
 import java.io.*;
--- a/langtools/test/tools/javac/tree/TreePosTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/tree/TreePosTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -108,7 +108,7 @@
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.tree
  *          jdk.compiler/com.sun.tools.javac.util
- * @run main/othervm TreePosTest -q -r .
+ * @run main TreePosTest -q -r .
  */
 public class TreePosTest {
     /**
--- a/langtools/test/tools/javac/varargs/7043922/T7043922.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/varargs/7043922/T7043922.java	Wed Jul 05 23:37:13 2017 +0200
@@ -28,7 +28,6 @@
  * @modules jdk.compiler/com.sun.tools.javac.api
  *          jdk.compiler/com.sun.tools.javac.file
  *          jdk.compiler/com.sun.tools.javac.util
- * @run main/othervm T7043922
  */
 
 import com.sun.source.util.JavacTask;
--- a/langtools/test/tools/javac/versions/Versions.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/versions/Versions.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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);
 
--- a/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java	Wed Jul 05 23:37:13 2017 +0200
@@ -66,7 +66,7 @@
         if (args.length != 1) throw new IllegalStateException("Must provide class name!");
         String testContent = null;
         List<File> sourcePath = new ArrayList<>();
-        for (String sourcePaths : System.getProperty("test.src.path").split(":")) {
+        for (String sourcePaths : System.getProperty("test.src.path").split(File.pathSeparator)) {
             sourcePath.add(new File(sourcePaths));
         }
         JavacFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
--- a/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestRelease.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestRelease.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,6 +49,7 @@
         assertTrue(invoke("7"));
         assertTrue(invoke("8"));
         assertTrue(invoke("9"));
+        assertTrue(invoke("10"));
     }
 
     @Test
--- a/make/Help.gmk	Wed Jul 05 23:35:20 2017 +0200
+++ b/make/Help.gmk	Wed Jul 05 23:37:13 2017 +0200
@@ -56,6 +56,8 @@
 	$(info $(_) make test              # Run tests, default is all tests (see TEST below))
 	$(info $(_) make run-test-<test>   # Run test, e.g. run-test-tier1)
 	$(info $(_) make run-test TEST=<t> # Run test(s) given by TEST specification)
+	$(info $(_) make exploded-run-test TEST=<t> # Run test(s) on the exploded image instead of)
+	$(info $(_)                        # the full jdk image)
 	$(info )
 	$(info Targets for cleaning)
 	$(info $(_) make clean             # Remove all files generated by make, but not those)
--- a/make/Init.gmk	Wed Jul 05 23:35:20 2017 +0200
+++ b/make/Init.gmk	Wed Jul 05 23:37:13 2017 +0200
@@ -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)
--- a/make/InitSupport.gmk	Wed Jul 05 23:35:20 2017 +0200
+++ b/make/InitSupport.gmk	Wed Jul 05 23:37:13 2017 +0200
@@ -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
--- a/make/Main.gmk	Wed Jul 05 23:35:20 2017 +0200
+++ b/make/Main.gmk	Wed Jul 05 23:37:13 2017 +0200
@@ -450,13 +450,18 @@
   run-test-$1:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test TEST="$1")
 
+  exploded-run-test-$1:
+	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test \
+	    TEST="$1" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR))
+
 endef
 
 # ALL_NAMED_TESTS is defined in FindTests.gmk
 $(foreach t, $(ALL_NAMED_TESTS), $(eval $(call DeclareRunTestRecipe,$t)))
 ALL_TEST_TARGETS := $(addprefix run-test-, $(ALL_NAMED_TESTS))
+ALL_EXPLODED_TEST_TARGETS := $(addprefix exploded-run-test-, $(ALL_NAMED_TESTS))
 
-ALL_TARGETS += $(ALL_TEST_TARGETS)
+ALL_TARGETS += $(ALL_TEST_TARGETS) $(ALL_EXPLODED_TEST_TARGETS)
 
 ################################################################################
 # Build tests
@@ -485,6 +490,10 @@
 run-test:
 	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test TEST="$(TEST)")
 
+exploded-run-test:
+	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test \
+	    TEST="$(TEST)" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR))
+
 ifeq ($(BUILD_GTEST), true)
   test-image-hotspot-gtest:
 	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f GtestImage.gmk)
@@ -514,7 +523,7 @@
     test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \
     test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \
     test-failure-handler test-image-failure-handler test-image-hotspot-gtest \
-    run-test
+    run-test exploded-run-test
 
 ################################################################################
 # Run tests
@@ -808,9 +817,11 @@
   test: jdk-image test-image
 
   run-test: jdk-image test-image
+  exploded-run-test: exploded-image test-image
 
   # Declare dependency for all generated test targets
   $(foreach t, $(ALL_TEST_TARGETS), $(eval $t: jdk-image test-image))
+  $(foreach t, $(ALL_EXPLODED_TEST_TARGETS), $(eval $t: exploded-image test-image))
 
   create-buildjdk-copy: jdk.jlink-java java.base-gendata \
       $(addsuffix -java, $(INTERIM_IMAGE_MODULES))
--- a/make/common/MakeBase.gmk	Wed Jul 05 23:35:20 2017 +0200
+++ b/make/common/MakeBase.gmk	Wed Jul 05 23:37:13 2017 +0200
@@ -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 :=
--- a/make/common/SetupJavaCompilers.gmk	Wed Jul 05 23:35:20 2017 +0200
+++ b/make/common/SetupJavaCompilers.gmk	Wed Jul 05 23:37:13 2017 +0200
@@ -69,7 +69,7 @@
 $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \
     JVM := $(JAVA_JAVAC), \
     JAVAC := $(NEW_JAVAC), \
-    FLAGS := -source 9 -target 9 --doclint-format html5 \
+    FLAGS := -source 10 -target 10 --doclint-format html5 \
         -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)))
--- a/nashorn/.hgtags	Wed Jul 05 23:35:20 2017 +0200
+++ b/nashorn/.hgtags	Wed Jul 05 23:37:13 2017 +0200
@@ -387,9 +387,11 @@
 2a0437036a64853334e538044eb68d2df70075fa jdk-9+151
 ddc52e72757086a75a54371e8e7f56a3f89f1e55 jdk-9+152
 19aaaf2d02b7d6986538cd9a8c46901ecb50eebf jdk-9+153
+a84b49cfee63716975535abae2865ffef4dd6474 jdk-10+0
 a84b49cfee63716975535abae2865ffef4dd6474 jdk-9+154
 f9bb37a817b3cd3b758a60f3c68258a6554eb382 jdk-9+155
 d577398d31111be4bdaa08008247cf4242eaea94 jdk-9+156
+ac893c3a86ddeda4bed2573037175a2913ec570e jdk-10+1
 f6070efba6af0dc003e24ca736426c93e99ee96a jdk-9+157
 13ae2480a4c395026b3aa1739e0f9895dc8b25d9 jdk-9+158
 d75af059cff651c1b5cccfeb4c9ea8d054b28cfd jdk-9+159
@@ -400,6 +402,18 @@
 b473fab09baab51a06ffba02eb06c7f5ee8578f7 jdk-9+164
 e36e62d3ea53c316f295b37bcc19867fbf510235 jdk-9+165
 5b2e7b2101c0048ba9f1df722e56611f523fdfe8 jdk-9+166
+47277bbced66869e17899eee7ac197b78a5c69b8 jdk-10+2
+a76a5e1c9d0b94541826e2121f5754aaa78f0376 jdk-10+3
+e6bc0ad505e65c884a66c42cc92b24371ccf971d jdk-10+4
+59278e0c6ccd7cc6d2427c29e8c3446fc2af0e26 jdk-10+5
+0c5f25cc0d1b89664d1517a256b805e2a97116a4 jdk-10+6
 e118c818dbf84d15191414c453b77c089116fdc0 jdk-9+167
 0f81cde5a1f75786f381dbfb59b9afbab70174c7 jdk-9+168
 131e250080158e57ce45130560f5f987b92642b5 jdk-9+169
+550bfc15779f8f339610793867fdc251125811b5 jdk-9+170
+7e9cb37e6d6edbe56fdf4d510e5110f797823f09 jdk-10+7
+edb825e2dfb140c8e57a61b5d45de19edebccccf jdk-10+8
+d7d69c89088aec56d13bbff81a6f0a8b68ca75f4 jdk-10+9
+fc416270a776409b74006262dd0a9f5f5ff31555 jdk-9+171
+f381e171bec90afee95dc2920793754b58b6f705 jdk-10+10
+c8d6b740f0f7ec834b4157bf0d4523e8bbddb3f0 jdk-9+172
--- a/nashorn/.jcheck/conf	Wed Jul 05 23:35:20 2017 +0200
+++ b/nashorn/.jcheck/conf	Wed Jul 05 23:37:13 2017 +0200
@@ -1,1 +1,1 @@
-project=jdk9
+project=jdk10
--- a/test/lib/jdk/test/lib/JDKToolLauncher.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/test/lib/jdk/test/lib/JDKToolLauncher.java	Wed Jul 05 23:37:13 2017 +0200
@@ -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()));
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/LockFreeLogger.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,84 @@
+/*
+ * 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
+ * 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;
+
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
+
+/**
+ * A logger designed specifically to allow collecting ordered log messages
+ * in a multi-threaded environment without involving any kind of locking.
+ * <p>
+ * It is particularly useful in situations when one needs to assert various
+ * details about the tested thread state or the locks it hold while also wanting
+ * to produce diagnostic log messages.
+ * <p>
+ * The logger does not provide any guarantees about the completness of the
+ * logs written from different threads - it is up to the caller to make sure
+ * {@code toString()} method is called only when all the activity has ceased
+ * and the per-thread logs contain all the necessary data.
+ *
+ * @author Jaroslav Bachorik
+ **/
+public class LockFreeLogger {
+    private final AtomicInteger logCntr = new AtomicInteger(0);
+    private final Collection<Map<Integer, String>> allRecords = new ConcurrentLinkedQueue<>();
+    private final ThreadLocal<Map<Integer, String>> records = ThreadLocal.withInitial(ConcurrentHashMap::new);
+
+    public LockFreeLogger() {
+        allRecords.add(records.get());
+    }
+
+    /**
+     * Log a message
+     * @param format Message format
+     * @param params Message parameters
+     */
+    public void log(String format, Object ... params) {
+        int id = logCntr.getAndIncrement();
+        records.get().put(id, String.format(format, params));
+    }
+
+    /**
+     * Will generate an aggregated log of chronologically ordered messages.
+     * <p>
+     * Make sure that you call this method only when all the related threads
+     * have finished; otherwise you might get incomplete data.
+     *
+     * @return An aggregated log of chronologically ordered messages
+     */
+    @Override
+    public String toString() {
+        return allRecords.stream()
+            .flatMap(m -> m.entrySet().stream())
+            .sorted(Comparator.comparing(Map.Entry::getKey))
+            .map(Map.Entry::getValue)
+            .collect(Collectors.joining());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/NetworkConfiguration.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,272 @@
+/*
+ * 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;
+
+import java.io.PrintStream;
+import java.io.UncheckedIOException;
+import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import static java.net.NetworkInterface.getNetworkInterfaces;
+import static java.util.Collections.list;
+
+/**
+ * Helper class for retrieving network interfaces and local addresses
+ * suitable for testing.
+ */
+public class NetworkConfiguration {
+
+    private Map<NetworkInterface,List<Inet4Address>> ip4Interfaces;
+    private Map<NetworkInterface,List<Inet6Address>> ip6Interfaces;
+
+    private NetworkConfiguration(
+            Map<NetworkInterface,List<Inet4Address>> ip4Interfaces,
+            Map<NetworkInterface,List<Inet6Address>> ip6Interfaces) {
+        this.ip4Interfaces = ip4Interfaces;
+        this.ip6Interfaces = ip6Interfaces;
+    }
+
+    /**
+     * Returns a stream of interfaces suitable for functional tests.
+     */
+    public Stream<NetworkInterface> interfaces() {
+        return Stream.concat(ip4Interfaces(), ip6Interfaces())
+                     .distinct();
+    }
+
+    /**
+     * Returns a stream of interfaces suitable for IPv4 functional tests.
+     */
+    public Stream<NetworkInterface> ip4Interfaces() {
+        return ip4Interfaces.keySet()
+                            .stream()
+                            .filter(NetworkConfiguration::isNotExcludedInterface)
+                            .filter(hasIp4Addresses);
+    }
+
+    /**
+     * Returns a stream of interfaces suitable for IPv6 functional tests.
+     */
+    public Stream<NetworkInterface> ip6Interfaces() {
+        return ip6Interfaces.keySet()
+                            .stream()
+                            .filter(NetworkConfiguration::isNotExcludedInterface)
+                            .filter(hasIp6Addresses);
+    }
+
+    private static boolean isNotExcludedInterface(NetworkInterface nif) {
+        if (Platform.isOSX() && nif.getName().contains("awdl")) {
+            return false;
+        }
+        String dName = nif.getDisplayName();
+        if (Platform.isWindows() && dName != null && dName.contains("Teredo")) {
+            return false;
+        }
+        return true;
+    }
+
+    private final Predicate<NetworkInterface> hasIp4Addresses = nif ->
+            ip4Interfaces.get(nif).stream().anyMatch(a -> !a.isAnyLocalAddress());
+
+    private final Predicate<NetworkInterface> hasIp6Addresses = nif ->
+            ip6Interfaces.get(nif).stream().anyMatch(a -> !a.isAnyLocalAddress());
+
+
+    /**
+     * Returns a stream of interfaces suitable for IPv4 multicast tests.
+     */
+    public Stream<NetworkInterface> ip4MulticastInterfaces() {
+        return ip4Interfaces().filter(supportsIp4Multicast);
+    }
+
+    /**
+     * Returns a stream of interfaces suitable for IPv6 multicast tests.
+     */
+    public Stream<NetworkInterface> ip6MulticastInterfaces() {
+        return ip6Interfaces().filter(supportsIp6Multicast);
+    }
+
+    private final Predicate<NetworkInterface> supportsIp4Multicast = nif -> {
+        try {
+            if (!nif.supportsMulticast() || nif.isLoopback()) {
+                return false;
+            }
+            return hasIp4Addresses.test(nif);
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    };
+
+    private final Predicate<NetworkInterface> supportsIp6Multicast = nif -> {
+        try {
+            if (!nif.supportsMulticast() || nif.isLoopback()) {
+                return false;
+            }
+
+            return hasIp6Addresses.test(nif);
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    };
+
+    /**
+     * Returns all addresses on all "functional" interfaces.
+     */
+    public Stream<InetAddress> addresses(NetworkInterface nif) {
+        return Stream.concat(ip4Interfaces.get(nif).stream(),
+                             ip6Interfaces.get(nif).stream());
+    }
+
+    /**
+     * Returns all IPv4 addresses on all "functional" interfaces.
+     */
+    public Stream<Inet4Address> ip4Addresses() {
+        return ip4Interfaces().flatMap(this::ip4Addresses);
+    }
+
+    /**
+     * Returns all IPv6 addresses on all "functional" interfaces.
+     */
+    public Stream<Inet6Address> ip6Addresses() {
+        return ip6Interfaces().flatMap(this::ip6Addresses);
+    }
+
+    /**
+     * Returns all IPv4 addresses the given interface.
+     */
+    public Stream<Inet4Address> ip4Addresses(NetworkInterface nif) {
+        return ip4Interfaces.get(nif).stream();
+    }
+
+    /**
+     * Returns all IPv6 addresses for the given interface.
+     */
+    public Stream<Inet6Address> ip6Addresses(NetworkInterface nif) {
+        return ip6Interfaces.get(nif).stream();
+    }
+
+    /**
+     * Return a NetworkConfiguration instance.
+     */
+    public static NetworkConfiguration probe() throws IOException {
+        Map<NetworkInterface, List<Inet4Address>> ip4Interfaces = new HashMap<>();
+        Map<NetworkInterface, List<Inet6Address>> ip6Interfaces = new HashMap<>();
+
+        List<NetworkInterface> nifs = list(getNetworkInterfaces());
+        for (NetworkInterface nif : nifs) {
+            // ignore interfaces that are down
+            if (!nif.isUp() || nif.isPointToPoint()) {
+                continue;
+            }
+
+            List<Inet4Address> ip4Addresses = new LinkedList<>();
+            List<Inet6Address> ip6Addresses = new LinkedList<>();
+            ip4Interfaces.put(nif, ip4Addresses);
+            ip6Interfaces.put(nif, ip6Addresses);
+            for (InetAddress addr : list(nif.getInetAddresses())) {
+                if (addr instanceof Inet4Address) {
+                    ip4Addresses.add((Inet4Address) addr);
+                } else if (addr instanceof Inet6Address) {
+                    ip6Addresses.add((Inet6Address) addr);
+                }
+            }
+        }
+        return new NetworkConfiguration(ip4Interfaces, ip6Interfaces);
+    }
+
+    @Override
+    public String toString() {
+        return interfaces().map(NetworkConfiguration::interfaceInformation)
+                           .collect(Collectors.joining());
+    }
+
+    /** Returns detailed information for the given interface. */
+    public static String interfaceInformation(NetworkInterface nif) {
+        StringBuilder sb = new StringBuilder();
+        try {
+            sb.append("Display name: ")
+              .append(nif.getDisplayName())
+              .append("\n");
+            sb.append("Name: ")
+              .append(nif.getName())
+              .append("\n");
+            for (InetAddress inetAddress : list(nif.getInetAddresses())) {
+                sb.append("InetAddress: ")
+                  .append(inetAddress)
+                  .append("\n");
+            }
+            sb.append("Up? ")
+              .append(nif.isUp())
+              .append("\n");
+            sb.append("Loopback? ")
+              .append(nif.isLoopback())
+              .append("\n");
+            sb.append("PointToPoint? ")
+              .append(nif.isPointToPoint())
+              .append("\n");
+            sb.append("Supports multicast? ")
+              .append(nif.supportsMulticast())
+              .append("\n");
+            sb.append("Virtual? ")
+              .append(nif.isVirtual())
+              .append("\n");
+            sb.append("Hardware address: ")
+              .append(Arrays.toString(nif.getHardwareAddress()))
+              .append("\n");
+            sb.append("MTU: ")
+              .append(nif.getMTU())
+              .append("\n");
+            sb.append("Index: ")
+              .append(nif.getIndex())
+              .append("\n");
+            sb.append("\n");
+            return sb.toString();
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+
+    /** Prints all the system interface information to the give stream. */
+    public static void printSystemConfiguration(PrintStream out) {
+        try {
+            out.println("*** all system network interface configuration ***");
+            for (NetworkInterface nif : list(getNetworkInterfaces())) {
+                out.print(interfaceInformation(nif));
+            }
+            out.println("*** end ***");
+        } catch (IOException e) {
+            throw new UncheckedIOException(e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/RandomFactory.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.lib;
+
+import java.util.Random;
+import java.util.SplittableRandom;
+
+/**
+ * Factory class which generates and prints to STDOUT a long-valued seed
+ * for use in initializing a PRNG.  An instance of {@code Random} or
+ * {@code SplittableRandom} may likewise be obtained.
+ */
+public class RandomFactory {
+    /**
+     * Attempt to obtain the seed from the value of the "seed" property.
+     * @return The seed or {@code null} if the "seed" property was not set or
+     *         could not be parsed.
+     */
+    private static Long getSystemSeed() {
+        Long seed = null;
+        try {
+            // note that Long.valueOf(null) also throws a
+            // NumberFormatException so if the property is undefined this
+            // will still work correctly
+            seed = Long.valueOf(System.getProperty("seed"));
+        } catch (NumberFormatException e) {
+            // do nothing: seed is still null
+        }
+
+        return seed;
+    }
+
+    /**
+     * Obtain a seed from an independent PRNG.
+     *
+     * @return A random seed.
+     */
+    private static long getRandomSeed() {
+        return new Random().nextLong();
+    }
+
+    /**
+     * Obtain and print to STDOUT a seed appropriate for initializing a PRNG.
+     * If the system property "seed" is set and has value which may be correctly
+     * parsed it is used, otherwise a seed is generated using an independent
+     * PRNG.
+     *
+     * @return The seed.
+     */
+    public static long getSeed() {
+        Long seed = getSystemSeed();
+        if (seed == null) {
+            seed = getRandomSeed();
+        }
+        System.out.println("Seed from RandomFactory = "+seed+"L");
+        return seed;
+    }
+
+    /**
+     * Obtain and print to STDOUT a seed and use it to initialize a new
+     * {@code Random} instance which is returned. If the system
+     * property "seed" is set and has value which may be correctly parsed it
+     * is used, otherwise a seed is generated using an independent PRNG.
+     *
+     * @return The {@code Random} instance.
+     */
+    public static Random getRandom() {
+        return new Random(getSeed());
+    }
+
+    /**
+     * Obtain and print to STDOUT a seed and use it to initialize a new
+     * {@code SplittableRandom} instance which is returned. If the system
+     * property "seed" is set and has value which may be correctly parsed it
+     * is used, otherwise a seed is generated using an independent PRNG.
+     *
+     * @return The {@code SplittableRandom} instance.
+     */
+    public static SplittableRandom getSplittableRandom() {
+        return new SplittableRandom(getSeed());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/classloader/FilterClassLoader.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,50 @@
+/*
+ * 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
+ * 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.classloader;
+
+import java.util.function.Predicate;
+/**
+ * A classloader, which using target classloader in case provided condition
+ * for class name is met, and using parent otherwise
+ */
+public class FilterClassLoader extends ClassLoader {
+
+    private final ClassLoader target;
+    private final Predicate<String> condition;
+
+    public FilterClassLoader(ClassLoader target, ClassLoader parent,
+            Predicate<String> condition) {
+        super(parent);
+        this.condition = condition;
+        this.target = target;
+    }
+
+    @Override
+    public Class<?> loadClass(String name) throws ClassNotFoundException {
+        if (condition.test(name)) {
+            return target.loadClass(name);
+        }
+        return super.loadClass(name);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/classloader/ParentLastURLClassLoader.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,51 @@
+/*
+ * 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
+ * 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.classloader;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * An url classloader, which trying to load class from provided URL[] first,
+ * and using parent classloader in case it failed
+ */
+public class ParentLastURLClassLoader extends URLClassLoader {
+
+    public ParentLastURLClassLoader(URL urls[], ClassLoader parent) {
+        super(urls, parent);
+    }
+
+    @Override
+    public Class<?> loadClass(String name) throws ClassNotFoundException {
+        try {
+            Class<?> c = findClass(name);
+            if (c != null) {
+                return c;
+            }
+        } catch (ClassNotFoundException e) {
+            // ignore
+        }
+        return super.loadClass(name);
+    }
+}
--- a/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/test/lib/jdk/test/lib/cli/CommandLineOptionTest.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -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);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/compiler/CompilerUtils.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.lib.compiler;
+
+import javax.tools.JavaCompiler;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * This class consists exclusively of static utility methods for invoking the
+ * java compiler.
+ */
+public final class CompilerUtils {
+    private CompilerUtils() { }
+
+    /**
+     * Compile all the java sources in {@code <source>/**} to
+     * {@code <destination>/**}. The destination directory will be created if
+     * it doesn't exist.
+     *
+     * All warnings/errors emitted by the compiler are output to System.out/err.
+     *
+     * @return true if the compilation is successful
+     *
+     * @throws IOException
+     *         if there is an I/O error scanning the source tree or
+     *         creating the destination directory
+     * @throws UnsupportedOperationException
+     *         if there is no system java compiler
+     */
+    public static boolean compile(Path source, Path destination, String... options)
+        throws IOException
+    {
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            // no compiler available
+            throw new UnsupportedOperationException("Unable to get system java compiler. "
+                    + "Perhaps, jdk.compiler module is not available.");
+        }
+        StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null);
+
+        List<Path> sources
+            = Files.find(source, Integer.MAX_VALUE,
+                (file, attrs) -> (file.toString().endsWith(".java")))
+                .collect(Collectors.toList());
+
+        Files.createDirectories(destination);
+        jfm.setLocation(StandardLocation.CLASS_PATH, Collections.emptyList());
+        jfm.setLocationFromPaths(StandardLocation.CLASS_OUTPUT,
+                Collections.singletonList(destination));
+
+        List<String> opts = Arrays.asList(options);
+        JavaCompiler.CompilationTask task
+            = compiler.getTask(null, jfm, null, opts, null,
+                jfm.getJavaFileObjectsFromPaths(sources));
+
+        return task.call();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/compiler/ModuleInfoMaker.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,129 @@
+/*
+ * 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.
+ */
+
+package jdk.test.lib.compiler;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Stream;
+
+/**
+ * Utility class for creating test modules.
+ */
+public class ModuleInfoMaker {
+    private static final String MODULE_INFO_JAVA = "module-info.java";
+    private static final Pattern MODULE_PATTERN =
+        Pattern.compile("module\\s+((?:\\w+\\.)*)");
+    private static final Pattern PACKAGE_PATTERN =
+                       Pattern.compile("package\\s+(((?:\\w+\\.)*)(?:\\w+))");
+    private static final Pattern CLASS_PATTERN =
+          Pattern.compile("(?:public\\s+)?(?:class|enum|interface)\\s+(\\w+)");
+
+    private final Path dir;
+
+    public ModuleInfoMaker(Path dir) {
+        this.dir = dir;
+    }
+
+    /**
+     * Create java source files of the given module
+     */
+    public void writeJavaFiles(String module, String moduleInfoJava, String... contents)
+        throws IOException
+    {
+        Path msrc = dir.resolve(module);
+        new JavaSource(moduleInfoJava).write(msrc);
+        for (String c : contents) {
+            new JavaSource(c).write(msrc);
+        }
+    }
+
+    /**
+     * Compile the module to the given destination.
+     */
+    public void compile(String module, Path dest, String... options)
+        throws IOException
+    {
+        Path msrc = dir.resolve(module);
+        String[] args =
+            Stream.concat(Arrays.stream(options),
+                          Stream.of("--module-source-path",
+                                    dir.toString())).toArray(String[]::new);
+        if (!CompilerUtils.compile(msrc, dest, args)) {
+            throw new Error("Fail to compile " + module);
+        }
+    }
+
+    static class JavaSource {
+        final String source;
+        JavaSource(String source) {
+            this.source = source;
+        }
+
+        /**
+         * Writes the source code to a file in a specified directory.
+         * @param dir the directory
+         * @throws IOException if there is a problem writing the file
+         */
+        public void write(Path dir) throws IOException {
+            Path file = dir.resolve(getJavaFileNameFromSource(source));
+            Files.createDirectories(file.getParent());
+            try (BufferedWriter out = Files.newBufferedWriter(file)) {
+                out.write(source.replace("\n", System.lineSeparator()));
+            }
+        }
+
+        /**
+         * Extracts the Java file name from the class declaration.
+         * This method is intended for simple files and uses regular expressions,
+         * so comments matching the pattern can make the method fail.
+         */
+        static String getJavaFileNameFromSource(String source) {
+            String packageName = null;
+
+            Matcher matcher = MODULE_PATTERN.matcher(source);
+            if (matcher.find())
+                return MODULE_INFO_JAVA;
+
+            matcher = PACKAGE_PATTERN.matcher(source);
+            if (matcher.find())
+                packageName = matcher.group(1).replace(".", "/");
+
+            matcher = CLASS_PATTERN.matcher(source);
+            if (matcher.find()) {
+                String className = matcher.group(1) + ".java";
+                return (packageName == null) ? className : packageName + "/" + className;
+            } else if (packageName != null) {
+                return packageName + "/package-info.java";
+            } else {
+                throw new Error("Could not extract the java class " +
+                    "name from the provided source");
+            }
+        }
+    }
+}
--- a/test/lib/jdk/test/lib/hprof/parser/HprofReader.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/test/lib/jdk/test/lib/hprof/parser/HprofReader.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@
 import java.io.*;
 import java.util.Date;
 import java.util.Hashtable;
+import java.util.Map;
 import jdk.test.lib.hprof.model.ArrayTypeCodes;
 import jdk.test.lib.hprof.model.*;
 
@@ -357,6 +358,22 @@
         return snapshot;
     }
 
+    public String printStackTraces() {
+        StringBuffer output = new StringBuffer();
+        for (Map.Entry<Integer, StackTrace> entry : stackTraces.entrySet()) {
+            StackFrame[] frames = entry.getValue().getFrames();
+            output.append("SerialNo " + entry.getKey() + "\n");
+            for (int i = 0; i < frames.length; i++) {
+                output.append("  " + frames[i].getClassName() + "." + frames[i].getMethodName()
+                        + frames[i].getMethodSignature() + " (" + frames[i].getSourceFileName()
+                        + ":" + frames[i].getLineNumber() + ")" + "\n");
+            }
+        }
+
+        System.out.println(output);
+        return output.toString();
+    }
+
     private void skipBytes(long length) throws IOException {
         while (length > 0) {
             long skipped = in.skip(length);
--- a/test/lib/jdk/test/lib/hprof/parser/Reader.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/test/lib/jdk/test/lib/hprof/parser/Reader.java	Wed Jul 05 23:37:13 2017 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -94,4 +94,42 @@
             }
         }
     }
+
+    /**
+     * Get Stack Traces from a Hprof file.
+     *
+     * @param heapFile The name of a file containing a heap dump
+     */
+    public static String getStack(String heapFile, int debugLevel)
+            throws IOException {
+        int dumpNumber = 1;
+        int pos = heapFile.lastIndexOf('#');
+        if (pos > -1) {
+            String num = heapFile.substring(pos+1, heapFile.length());
+            try {
+                dumpNumber = Integer.parseInt(num, 10);
+            } catch (java.lang.NumberFormatException ex) {
+                String msg = "In file name \"" + heapFile
+                             + "\", a dump number was "
+                             + "expected after the :, but \""
+                             + num + "\" was found instead.";
+                System.err.println(msg);
+                throw new IOException(msg);
+            }
+            heapFile = heapFile.substring(0, pos);
+        }
+        try (PositionDataInputStream in = new PositionDataInputStream(
+                new BufferedInputStream(new FileInputStream(heapFile)))) {
+            int i = in.readInt();
+            if (i == HprofReader.MAGIC_NUMBER) {
+                HprofReader r
+                    = new HprofReader(heapFile, in, dumpNumber,
+                                      true, debugLevel);
+                r.read();
+                return r.printStackTraces();
+            } else {
+                throw new IOException("Unrecognized magic number: " + i);
+            }
+        }
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/management/InputArguments.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+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()]);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/management/ThreadMXBeanTool.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.lib.management;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.ThreadInfo;
+import java.lang.management.ThreadMXBean;
+
+/**
+ * A few utility methods to use ThreadMXBean.
+ */
+public final class ThreadMXBeanTool {
+
+    /**
+     * Waits until {@link Thread} is in the certain {@link Thread.State}
+     * and blocking on {@code object}.
+     *
+     * @param state The thread state
+     * @param object The object to block on
+     */
+    public static void waitUntilBlockingOnObject(Thread thread, Thread.State state, Object object)
+        throws InterruptedException {
+        String want = object == null ? null : object.getClass().getName() + '@'
+                + Integer.toHexString(System.identityHashCode(object));
+        ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
+        while (thread.isAlive()) {
+            ThreadInfo ti = tmx.getThreadInfo(thread.getId());
+            if (ti.getThreadState() == state
+                    && (want == null || want.equals(ti.getLockName()))) {
+                return;
+            }
+            Thread.sleep(1);
+        }
+    }
+
+    /**
+     * Waits until {@link Thread} is in native.
+     */
+    public static void waitUntilInNative(Thread thread) throws InterruptedException {
+        ThreadMXBean tmx = ManagementFactory.getThreadMXBean();
+        while (thread.isAlive()) {
+            ThreadInfo ti = tmx.getThreadInfo(thread.getId());
+            if (ti.isInNative()) {
+                return;
+            }
+            Thread.sleep(1);
+        }
+    }
+
+}
--- a/test/lib/jdk/test/lib/process/OutputAnalyzer.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/test/lib/jdk/test/lib/process/OutputAnalyzer.java	Wed Jul 05 23:37:13 2017 +0200
@@ -24,6 +24,7 @@
 package jdk.test.lib.process;
 
 import java.io.IOException;
+import java.io.PrintStream;
 import java.util.Arrays;
 import java.util.List;
 import java.util.regex.Matcher;
@@ -415,6 +416,25 @@
       System.err.println(msg);
   }
 
+  /**
+   * Print the stdout buffer to the given {@code PrintStream}.
+   *
+   * @return this OutputAnalyzer
+   */
+  public OutputAnalyzer outputTo(PrintStream out) {
+      out.println(getStdout());
+      return this;
+  }
+
+  /**
+   * Print the stderr buffer to the given {@code PrintStream}.
+   *
+   * @return this OutputAnalyzer
+   */
+  public OutputAnalyzer errorTo(PrintStream out) {
+      out.println(getStderr());
+      return this;
+  }
 
   /**
    * Get the contents of the output buffer (stdout and stderr)
--- a/test/lib/jdk/test/lib/process/ProcessTools.java	Wed Jul 05 23:35:20 2017 +0200
+++ b/test/lib/jdk/test/lib/process/ProcessTools.java	Wed Jul 05 23:37:13 2017 +0200
@@ -28,13 +28,10 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintStream;
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.concurrent.CountDownLatch;
-import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
@@ -45,7 +42,6 @@
 import java.util.stream.Collectors;
 
 import jdk.test.lib.JDKToolFinder;
-import jdk.test.lib.Platform;
 import jdk.test.lib.Utils;
 
 public final class ProcessTools {
@@ -66,23 +62,23 @@
     }
 
     /**
-    * Pumps stdout and stderr from running the process into a String.
-    *
-    * @param processHandler ProcessHandler to run.
-    * @return Output from process.
-    * @throws IOException If an I/O error occurs.
-    */
+     * Pumps stdout and stderr from running the process into a String.
+     *
+     * @param processHandler ProcessHandler to run.
+     * @return Output from process.
+     * @throws IOException If an I/O error occurs.
+     */
     public static OutputBuffer getOutput(ProcessBuilder processBuilder) throws IOException {
         return getOutput(processBuilder.start());
     }
 
     /**
-    * Pumps stdout and stderr the running process into a String.
-    *
-    * @param process Process to pump.
-    * @return Output from process.
-    * @throws IOException If an I/O error occurs.
-    */
+     * Pumps stdout and stderr the running process into a String.
+     *
+     * @param process Process to pump.
+     * @return Output from process.
+     * @throws IOException If an I/O error occurs.
+     */
     public static OutputBuffer getOutput(Process process) throws IOException {
         ByteArrayOutputStream stderrBuffer = new ByteArrayOutputStream();
         ByteArrayOutputStream stdoutBuffer = new ByteArrayOutputStream();
@@ -304,38 +300,14 @@
     public static long getProcessId() throws Exception {
         return ProcessHandle.current().pid();
     }
-    /**
-     * Gets the array of strings containing input arguments passed to the VM
-     *
-     * @return arguments
-     */
-    public static String[] getVmInputArgs() {
-        RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
-        List<String> args = runtime.getInputArguments();
-        return args.toArray(new String[args.size()]);
-    }
 
-    /**
-     * Get platform specific VM arguments (e.g. -d64 on 64bit Solaris)
-     *
-     * @return String[] with platform specific arguments, empty if there are
-     *         none
-     */
-    public static String[] getPlatformSpecificVMArgs() {
-
-    if (Platform.is64bit() && Platform.isSolaris()) {
-            return new String[] { "-d64" };
-        }
-
-        return new String[] {};
-    }
 
 
     /**
      * Create ProcessBuilder using the java launcher from the jdk to be tested and
      * with any platform specific arguments prepended
      */
-    public static ProcessBuilder createJavaProcessBuilder(String... command) throws Exception {
+    public static ProcessBuilder createJavaProcessBuilder(String... command) {
         return createJavaProcessBuilder(false, command);
     }
 
@@ -348,12 +320,11 @@
      * @param command Arguments to pass to the java command.
      * @return The ProcessBuilder instance representing the java command.
      */
-    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) throws Exception {
+    public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) {
         String javapath = JDKToolFinder.getJDKTool("java");
 
         ArrayList<String> args = new ArrayList<>();
         args.add(javapath);
-        Collections.addAll(args, getPlatformSpecificVMArgs());
 
         args.add("-cp");
         args.add(System.getProperty("java.class.path"));
@@ -386,26 +357,6 @@
 
     /**
      * Executes a test jvm process, waits for it to finish and returns the process output.
-     * The default jvm options from the test's run command, jtreg, test.vm.opts and test.java.opts, are added.
-     * The java from the test.jdk is used to execute the command.
-     *
-     * The command line will be like:
-     * {test.jdk}/bin/java {test.fromRun.opts} {test.vm.opts} {test.java.opts} cmds
-     *
-     * @param cmds User specifed arguments.
-     * @return The output from the process.
-     */
-    public static OutputAnalyzer executeTestJvmAllArgs(String... cmds) throws Throwable {
-        List<String> argsList = new ArrayList<>();
-        String[] testArgs = getVmInputArgs();
-        Collections.addAll(argsList, testArgs);
-        Collections.addAll(argsList, Utils.addTestJavaOpts(cmds));
-        ProcessBuilder pb = createJavaProcessBuilder(argsList.toArray(new String[argsList.size()]));
-        return executeProcess(pb);
-    }
-
-    /**
-     * Executes a test jvm process, waits for it to finish and returns the process output.
      * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added.
      * The java from the test.jdk is used to execute the command.
      *
@@ -414,7 +365,7 @@
      *
      * The jvm process will have exited before this method returns.
      *
-     * @param cmds User specifed arguments.
+     * @param cmds User specified arguments.
      * @return The output from the process.
      */
     public static OutputAnalyzer executeTestJvm(String... cmds) throws Exception {
@@ -423,6 +374,15 @@
     }
 
     /**
+     * @see #executeTestJvm(String...)
+     * @param cmds User specified arguments.
+     * @return The output from the process.
+     */
+    public static OutputAnalyzer executeTestJava(String... cmds) throws Exception {
+        return executeTestJvm(cmds);
+    }
+
+    /**
      * Executes a process, waits for it to finish and returns the process output.
      * The process will have exited before this method returns.
      * @param pb The ProcessBuilder to execute.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/util/FileUtils.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,229 @@
+/*
+ * 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.util;
+
+import jdk.test.lib.Platform;
+
+import java.io.IOException;
+import java.nio.file.DirectoryNotEmptyException;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
+import java.nio.file.Path;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+
+/**
+ * Common library for various test file utility functions.
+ */
+public final class FileUtils {
+    private static final boolean IS_WINDOWS = Platform.isWindows();
+    private static final int RETRY_DELETE_MILLIS = IS_WINDOWS ? 500 : 0;
+    private static final int MAX_RETRY_DELETE_TIMES = IS_WINDOWS ? 15 : 0;
+
+    /**
+     * Deletes a file, retrying if necessary.
+     *
+     * @param path  the file to delete
+     *
+     * @throws NoSuchFileException
+     *         if the file does not exist (optional specific exception)
+     * @throws DirectoryNotEmptyException
+     *         if the file is a directory and could not otherwise be deleted
+     *         because the directory is not empty (optional specific exception)
+     * @throws IOException
+     *         if an I/O error occurs
+     */
+    public static void deleteFileWithRetry(Path path) throws IOException {
+        try {
+            deleteFileWithRetry0(path);
+        } catch (InterruptedException x) {
+            throw new IOException("Interrupted while deleting.", x);
+        }
+    }
+
+    /**
+     * Deletes a file, retrying if necessary.
+     * No exception thrown if file doesn't exist.
+     *
+     * @param path  the file to delete
+     *
+     * @throws NoSuchFileException
+     *         if the file does not exist (optional specific exception)
+     * @throws DirectoryNotEmptyException
+     *         if the file is a directory and could not otherwise be deleted
+     *         because the directory is not empty (optional specific exception)
+     * @throws IOException
+     *         if an I/O error occurs
+     */
+    public static void deleteFileIfExistsWithRetry(Path path) throws IOException {
+        try {
+            if (Files.exists(path)) {
+                deleteFileWithRetry0(path);
+            }
+        } catch (InterruptedException x) {
+            throw new IOException("Interrupted while deleting.", x);
+        }
+    }
+
+    private static void deleteFileWithRetry0(Path path)
+            throws IOException, InterruptedException {
+        int times = 0;
+        IOException ioe = null;
+        while (true) {
+            try {
+                Files.delete(path);
+                while (Files.exists(path)) {
+                    times++;
+                    if (times > MAX_RETRY_DELETE_TIMES) {
+                        throw new IOException("File still exists after " + times + " waits.");
+                    }
+                    Thread.sleep(RETRY_DELETE_MILLIS);
+                }
+                break;
+            } catch (NoSuchFileException | DirectoryNotEmptyException x) {
+                throw x;
+            } catch (IOException x) {
+                // Backoff/retry in case another process is accessing the file
+                times++;
+                if (ioe == null) {
+                    ioe = x;
+                } else {
+                    ioe.addSuppressed(x);
+                }
+
+                if (times > MAX_RETRY_DELETE_TIMES) {
+                    throw ioe;
+                }
+                Thread.sleep(RETRY_DELETE_MILLIS);
+            }
+        }
+    }
+
+    /**
+     * Deletes a directory and its subdirectories, retrying if necessary.
+     *
+     * @param dir  the directory to delete
+     *
+     * @throws  IOException
+     *          If an I/O error occurs. Any such exceptions are caught
+     *          internally. If only one is caught, then it is re-thrown.
+     *          If more than one exception is caught, then the second and
+     *          following exceptions are added as suppressed exceptions of the
+     *          first one caught, which is then re-thrown.
+     */
+    public static void deleteFileTreeWithRetry(Path dir) throws IOException {
+        IOException ioe = null;
+        final List<IOException> excs = deleteFileTreeUnchecked(dir);
+        if (!excs.isEmpty()) {
+            ioe = excs.remove(0);
+            for (IOException x : excs) {
+                ioe.addSuppressed(x);
+            }
+        }
+        if (ioe != null) {
+            throw ioe;
+        }
+    }
+
+    public static List<IOException> deleteFileTreeUnchecked(Path dir) {
+        final List<IOException> excs = new ArrayList<>();
+        try {
+            java.nio.file.Files.walkFileTree(dir, new SimpleFileVisitor<>() {
+                @Override
+                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
+                    try {
+                        deleteFileWithRetry0(file);
+                    } catch (IOException x) {
+                        excs.add(x);
+                    } catch (InterruptedException x) {
+                        excs.add(new IOException("Interrupted while deleting.", x));
+                        return FileVisitResult.TERMINATE;
+                    }
+                    return FileVisitResult.CONTINUE;
+                }
+                @Override
+                public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
+                    try {
+                        deleteFileWithRetry0(dir);
+                    } catch (IOException x) {
+                        excs.add(x);
+                    } catch (InterruptedException x) {
+                        excs.add(new IOException("Interrupted while deleting.", x));
+                        return FileVisitResult.TERMINATE;
+                    }
+                    return FileVisitResult.CONTINUE;
+                }
+                @Override
+                public FileVisitResult visitFileFailed(Path file, IOException exc) {
+                    excs.add(exc);
+                    return FileVisitResult.CONTINUE;
+                }
+            });
+        } catch (IOException x) {
+            excs.add(x);
+        }
+        return excs;
+    }
+
+    /**
+     * Checks whether all file systems are accessible. This is performed
+     * by checking free disk space on all mounted file systems via a
+     * separate, spawned process. File systems are considered to be
+     * accessible if this process completes successfully before a given
+     * fixed duration has elapsed.
+     *
+     * @implNote On Unix this executes the {@code df} command in a separate
+     * process and on Windows always returns {@code true}.
+     */
+    public static boolean areFileSystemsAccessible() throws IOException {
+        boolean areFileSystemsAccessible = true;
+        if (!IS_WINDOWS) {
+            // try to check whether 'df' hangs
+            System.out.println("\n--- df output ---");
+            System.out.flush();
+            Process proc = new ProcessBuilder("df").inheritIO().start();
+            try {
+                proc.waitFor(90, TimeUnit.SECONDS);
+            } catch (InterruptedException ignored) {
+            }
+            try {
+                int exitValue = proc.exitValue();
+                if (exitValue != 0) {
+                    System.err.printf("df process exited with %d != 0%n",
+                        exitValue);
+                    areFileSystemsAccessible = false;
+                }
+            } catch (IllegalThreadStateException ignored) {
+                System.err.println("df command apparently hung");
+                areFileSystemsAccessible = false;
+            }
+        }
+        return areFileSystemsAccessible;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/util/JarUtils.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.lib.util;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+/**
+ * Common library for various test jar file utility functions.
+ */
+public final class JarUtils {
+
+    /**
+     * Create jar file with specified files. If a specified file does not exist,
+     * a new jar entry will be created with the file name itself as the content.
+     */
+    public static void createJar(String dest, String... files)
+            throws IOException {
+        try (JarOutputStream jos = new JarOutputStream(
+                new FileOutputStream(dest), new Manifest())) {
+            for (String file : files) {
+                System.out.println(String.format("Adding %s to %s",
+                        file, dest));
+
+                // add an archive entry, and write a file
+                jos.putNextEntry(new JarEntry(file));
+                try (FileInputStream fis = new FileInputStream(file)) {
+                    fis.transferTo(jos);
+                } catch (FileNotFoundException e) {
+                    jos.write(file.getBytes());
+                }
+            }
+        }
+        System.out.println();
+    }
+
+    /**
+     * Add or remove specified files to existing jar file. If a specified file
+     * to be updated or added does not exist, the jar entry will be created
+     * with the file name itself as the content.
+     *
+     * @param src the original jar file name
+     * @param dest the new jar file name
+     * @param files the files to update. The list is broken into 2 groups
+     *              by a "-" string. The files before in the 1st group will
+     *              be either updated or added. The files in the 2nd group
+     *              will be removed. If no "-" exists, all files belong to
+     *              the 1st group.
+     */
+    public static void updateJar(String src, String dest, String... files)
+            throws IOException {
+        try (JarOutputStream jos = new JarOutputStream(
+                new FileOutputStream(dest))) {
+
+            // copy each old entry into destination unless the entry name
+            // is in the updated list
+            List<String> updatedFiles = new ArrayList<>();
+            try (JarFile srcJarFile = new JarFile(src)) {
+                Enumeration<JarEntry> entries = srcJarFile.entries();
+                while (entries.hasMoreElements()) {
+                    JarEntry entry = entries.nextElement();
+                    String name = entry.getName();
+                    boolean found = false;
+                    boolean update = true;
+                    for (String file : files) {
+                        if (file.equals("-")) {
+                            update = false;
+                        } else if (name.equals(file)) {
+                            updatedFiles.add(file);
+                            found = true;
+                            break;
+                        }
+                    }
+
+                    if (found) {
+                        if (update) {
+                            System.out.println(String.format("Updating %s with %s",
+                                    dest, name));
+                            jos.putNextEntry(new JarEntry(name));
+                            try (FileInputStream fis = new FileInputStream(name)) {
+                                fis.transferTo(jos);
+                            } catch (FileNotFoundException e) {
+                                jos.write(name.getBytes());
+                            }
+                        } else {
+                            System.out.println(String.format("Removing %s from %s",
+                                    name, dest));
+                        }
+                    } else {
+                        System.out.println(String.format("Copying %s to %s",
+                                name, dest));
+                        jos.putNextEntry(entry);
+                        srcJarFile.getInputStream(entry).transferTo(jos);
+                    }
+                }
+            }
+
+            // append new files
+            for (String file : files) {
+                if (file.equals("-")) {
+                    break;
+                }
+                if (!updatedFiles.contains(file)) {
+                    System.out.println(String.format("Adding %s with %s",
+                            dest, file));
+                    jos.putNextEntry(new JarEntry(file));
+                    try (FileInputStream fis = new FileInputStream(file)) {
+                        fis.transferTo(jos);
+                    } catch (FileNotFoundException e) {
+                        jos.write(file.getBytes());
+                    }
+                }
+            }
+        }
+        System.out.println();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/lib/jdk/test/lib/util/SerializationUtils.java	Wed Jul 05 23:37:13 2017 +0200
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package jdk.test.lib.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+/**
+ * Common library for various test serialization utility functions.
+ */
+public final class SerializationUtils {
+    /**
+     * Serialize an object into byte array.
+     */
+    public static byte[] serialize(Object obj) throws IOException {
+        ByteArrayOutputStream bs = new ByteArrayOutputStream();
+        try (ObjectOutputStream out = new ObjectOutputStream(bs)) {
+            out.writeObject(obj);
+        }
+        return bs.toByteArray();
+    }
+
+    /**
+     * Deserialize an object from byte array.
+     */
+    public static Object deserialize(byte[] ba) throws IOException, ClassNotFoundException {
+        try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(ba))) {
+            return in.readObject();
+        }
+    }
+    private SerializationUtils() {}
+}